UNPKG

mind-elixir

Version:

Mind elixir is a free open source mind map core.

1,359 lines 121 kB
const ss = 0, is = 1, rs = 2, ls = 3, me = { 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-border": "", // you can customize, it will fallback to 2px solid main-color "--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" } }, ye = { 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-border": "", "--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 be(e) { return e.replace(/&/g, "&amp;").replace(/</g, "&lt;").replace(/"/g, "&quot;"); } const ce = 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 = ce(e, t.children[n]); if (o) return o; } return null; } else return null; }, Y = (e, t) => { if (e.parent = t, e.children) for (let n = 0; n < e.children.length; n++) Y(e.children[n], e); }, G = (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) => { G(s, t, o); }); } else e.children.forEach((o) => { G(o, !1); }); }; function we(e) { if (e.id = X(), e.children) for (let t = 0; t < e.children.length; t++) we(e.children[t]); } function ae(e, t, n, o) { const s = n - e, i = o - t, l = Math.atan2(i, s) * 180 / Math.PI, a = 12, c = 30, h = (l + 180 - c) * Math.PI / 180, d = (l + 180 + c) * Math.PI / 180; return { x1: n + Math.cos(h) * a, y1: o + Math.sin(h) * a, x2: n + Math.cos(d) * a, y2: o + Math.sin(d) * a }; } function X() { return ((/* @__PURE__ */ new Date()).getTime().toString(16) + Math.random().toString(16).substring(2)).substring(2, 18); } const Et = function() { const e = X(); return { topic: this.newTopicName, id: e }; }; function q(e) { return JSON.parse( JSON.stringify(e, (n, o) => { if (n !== "parent") return o; }) ); } const $ = (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 }; }, _ = (e, t) => { for (const n in t) e.setAttribute(n, t[n]); }, re = (e) => e ? e.tagName === "ME-TPC" : !1, Ee = (e) => { const t = new Set(e.map((n) => n.nodeObj)); return e.filter((n) => n.nodeObj.parent).filter((n) => { let o = n.nodeObj.parent; for (; o; ) { if (t.has(o)) return !1; o = o.parent; } return !0; }); }, Ce = (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); } }; }, ke = (e, t) => { const n = e.x - t.x, o = e.y - t.y; return Math.sqrt(n * n + o * o); }, Ae = function(e, t) { if (!t) return de(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; }, de = function(e) { if (!e) return; const t = e.querySelectorAll(".insert-preview"); for (const n of t || []) n.remove(); }, te = 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; }, Ct = function(e) { const t = document.createElement("div"); return t.className = "mind-elixir-ghost", e.container.appendChild(t), t; }; class St { 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 Nt(e) { return { isDragging: !1, insertType: null, meet: null, ghost: Ct(e), edgeMoveController: new St(e), startX: 0, startY: 0, pointerId: null }; } const Tt = 5; function Pe(e, t, n, o = !1) { if (e.spacePressed) return !1; const s = n.target; if (s?.tagName !== "ME-TPC" || !s.nodeObj.parent) return !1; if (t.startX = n.clientX, t.startY = n.clientY, t.pointerId = n.pointerId, e.dragged = e.currentNodes, o) { Ue(e, t); const i = e.container.getBoundingClientRect(); ze(t.ghost, n.clientX - i.x, n.clientY - i.y); } return !0; } function ze(e, t, n) { e.style.transform = `translate(${t - 10}px, ${n - 10}px)`, e.style.display = "block"; } function Ue(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.panHelper.clear(); } function Dt(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, r = Math.sqrt(s * s + i * i); if (!t.isDragging && r > Tt && Ue(e, t), !t.isDragging) return; const l = e.container.getBoundingClientRect(); ze(t.ghost, n.clientX - l.x, n.clientY - l.y), n.clientX < l.x + 50 ? t.edgeMoveController.move(1, 0) : n.clientX > l.x + l.width - 50 ? t.edgeMoveController.move(-1, 0) : n.clientY < l.y + 50 ? t.edgeMoveController.move(0, 1) : n.clientY > l.y + l.height - 50 ? t.edgeMoveController.move(0, -1) : t.edgeMoveController.stop(), de(t.meet); const a = 12 * e.scaleVal; if (e.direction === 3) { const h = document.elementFromPoint(n.clientX - a, n.clientY); if (te(h, o)) { t.meet = h; const d = h.getBoundingClientRect(); n.clientX > d.x + d.width ? t.insertType = "after" : t.insertType = "in"; } else { const d = document.elementFromPoint(n.clientX + a, n.clientY); if (te(d, o)) { t.meet = d; const u = d.getBoundingClientRect(); n.clientX < u.x ? t.insertType = "before" : t.insertType = "in"; } else t.insertType = null, t.meet = null; } t.meet && Ae(t.meet, t.insertType); return; } const c = document.elementFromPoint(n.clientX, n.clientY - a); if (te(c, o)) { t.meet = c; const h = c.getBoundingClientRect(), d = h.y; n.clientY > d + h.height ? t.insertType = "after" : t.insertType = "in"; } else { const h = document.elementFromPoint(n.clientX, n.clientY + a); if (te(h, o)) { t.meet = h; const u = h.getBoundingClientRect().y; n.clientY < u ? t.insertType = "before" : t.insertType = "in"; } else t.insertType = null, t.meet = null; } t.meet && Ae(t.meet, t.insertType); } function Mt(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 && (de(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 Oe(e, t) { const { dragged: n } = e; if (n) { t.edgeMoveController.stop(); for (const o of n) o.parentElement.parentElement.style.opacity = "1"; t.meet && de(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 _t(e) { return () => { }; } const L = { LHS: "lhs", RHS: "rhs", DOWN: "down" }, Lt = function() { this.nodes.innerHTML = "", this.nodes.className = this.direction === 3 ? "down" : ""; const e = this.createTopic(this.nodeData); Se.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); }); } kt(this, n, t); }, kt = function(e, t, n) { if (e.direction === 3) { const i = document.createElement("me-main"); i.className = L.DOWN; for (let r = 0; r < t.length; r++) { const { grp: l } = e.createWrapper(t[r]); i.appendChild(l); } e.nodes.appendChild(n), e.nodes.appendChild(i), e.nodes.appendChild(e.lines), e.nodes.appendChild(e.labelContainer); return; } const o = document.createElement("me-main"); o.className = L.LHS; const s = document.createElement("me-main"); s.className = L.RHS; for (let i = 0; i < t.length; i++) { const r = t[i], { grp: l } = e.createWrapper(r); e.direction === 2 ? r.direction === 0 ? o.appendChild(l) : s.appendChild(l) : e.direction === 0 ? o.appendChild(l) : s.appendChild(l); } e.nodes.appendChild(o), e.nodes.appendChild(n), e.nodes.appendChild(s), e.nodes.appendChild(e.lines), e.nodes.appendChild(e.labelContainer); }, At = 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; }, Je = 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; }, Se = 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>${be(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); }, Pt = 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 = Ne(e.expanded); if (o.appendChild(i), e.expanded !== !1) { const r = At(this, e.children); n.appendChild(r); } } return { grp: n, top: o, tpc: s }; }, Ot = function(e) { const t = document.createElement("me-parent"), n = this.createTopic(e); return Se.call(this, n, e), t.appendChild(n), { p: t, tpc: n }; }, $t = function(e) { const t = document.createElement("me-children"); return t.append(...e), t; }, Ht = function(e) { const t = document.createElement("me-tpc"); return t.nodeObj = e, t.dataset.nodeid = "me" + e.id, t; }; function Ze(e) { const t = document.createRange(); t.selectNodeContents(e); const n = window.getSelection(); n && (n.removeAllRanges(), n.addRange(t)); } const It = function(e) { if (!e) return; const t = document.createElement("div"), n = e.nodeObj, o = n.topic, { offsetLeft: s, offsetTop: i } = $(this.nodes, e); this.nodes.appendChild(t), t.id = "input-box", t.textContent = o, t.contentEditable = "plaintext-only", t.spellcheck = !1; const r = getComputedStyle(e); t.style.cssText = ` left: ${s}px; top: ${i}px; min-width:${e.offsetWidth - 8}px; color:${r.color}; font-size:${r.fontSize}; padding:${r.padding}; margin:${r.margin}; background-color:${r.backgroundColor !== "rgba(0, 0, 0, 0)" && r.backgroundColor}; border: ${r.border}; border-radius:${r.borderRadius}; `, this.direction === 0 && (t.style.right = "0"), e.style.opacity = "0", Ze(t), this.bus.fire("operation", { name: "beginEdit", obj: e.nodeObj }), t.addEventListener("keydown", (l) => { if (l.stopPropagation(), l.isComposing) return; const a = l.key; if (a === "Enter" || a === "Tab") { if (l.shiftKey) return; l.preventDefault(), t.blur(), this.container.focus(); } else a === "Escape" && (l.preventDefault(), t.textContent = o, t.blur(), this.container.focus()); }), t.addEventListener("blur", () => { if (!t) return; e.style.opacity = "1"; const l = t.innerText?.trim() || ""; t.remove(), !(l === o || l === "") && (n.topic = l, this.markdown ? e.text.innerHTML = this.markdown(n.topic, n) : e.text.textContent = l, this.linkDiv(), this.bus.fire("operation", { name: "finishEdit", obj: n, origin: o })); }); }, Ne = function(e) { const t = document.createElement("me-epd"); return t.expanded = e !== !1, t.className = e !== !1 ? "minus" : "", t; }, he = (e) => { const t = e.parent?.children, n = t?.indexOf(e) ?? 0; return { siblings: t, index: n }; }; function Qe(e) { const { siblings: t, index: n } = he(e); return t === void 0 ? 0 : (t.splice(n, 1), t.length); } function jt(e, t, n) { const { siblings: o, index: s } = he(n); o !== void 0 && (t === "before" ? o.splice(s, 0, e) : o.splice(s + 1, 0, e)); } function Rt(e, t) { const { siblings: n, index: o } = he(e); n !== void 0 && (n[o] = t, t.children = [e]); } function Bt(e, t, n) { if (Qe(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 } = he(n); if (o === void 0) return; e === "before" ? o.splice(s, 0, t) : o.splice(s + 1, 0, t); } } const Wt = function({ map: e, direction: t }, n) { if (t === 0) return 0; if (t === 1) return 1; if (t === 3) return 3; 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); } }, et = function(e, t, n) { const o = n.children[0].children[0], s = t.parentElement; if (s.tagName === "ME-PARENT") { if (J(o), s.children[1]) s.nextSibling.appendChild(n); else { const i = e.createChildren([n]); s.appendChild(Ne(!0)), s.insertAdjacentElement("afterend", i); } e.linkDiv(n.offsetParent); } else if (s.tagName === "ME-ROOT") { const i = Wt(e, o.nodeObj); i === 3 ? e.container.querySelector("me-main.down")?.appendChild(n) : i === 0 ? e.container.querySelector(".lhs")?.appendChild(n) : e.container.querySelector(".rhs")?.appendChild(n), e.linkDiv(); } }, Yt = 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(); }, tt = { before: "beforebegin", after: "afterend" }, J = function(e) { const n = e.parentElement.parentElement.lastElementChild; n?.tagName === "svg" && n?.remove(); }, Xt = function(e, t) { const n = e.nodeObj, o = q(n); o.style && t.style && (t.style = Object.assign(o.style, t.style)); const s = Object.assign(n, t); Se.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], Y(e.nodeData); const { grp: i, top: r } = e.createWrapper(s); return et(e, t, i), { newTop: r, newNodeObj: s }; }, Ft = 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 c = this.map.querySelector(".lhs")?.childElementCount || 0, h = this.map.querySelector(".rhs")?.childElementCount || 0; if (!c || !h) { this.addChild(this.findEle(s.parent.id), n); return; } } } else { this.addChild(); return; } const i = n || this.generateNewObj(); if (!s.parent?.parent) { const c = o.closest("me-main").className === L.LHS ? 0 : 1; i.direction = c; } jt(i, e, s), Y(this.nodeData); const r = o.parentElement, { grp: l, top: a } = this.createWrapper(i); r.parentElement.insertAdjacentElement(tt[e], l), this.linkDiv(l.offsetParent), n || this.editTopic(a.firstChild), this.bus.fire("operation", { name: "insertSibling", type: e, obj: i }), this.selectNode(a.firstChild, !0); }, Kt = function(e, t) { const n = e || this.currentNode; if (!n) return; J(n); const o = n.nodeObj; if (!o.parent) return; const s = t || this.generateNewObj(); if (!o.parent?.parent) { const c = n.closest("me-main").className === L.LHS ? 0 : 1; s.direction = c; } Rt(o, s), Y(this.nodeData); const i = n.parentElement.parentElement, { grp: r, top: l } = this.createWrapper(s, !0); l.appendChild(Ne(!0)), i.insertAdjacentElement("afterend", r); const a = this.createChildren([i]); l.insertAdjacentElement("afterend", a), this.linkDiv(), t || this.editTopic(l.firstChild), this.bus.fire("operation", { name: "insertParent", obj: s }), this.selectNode(l.firstChild, !0); }, Vt = 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); }, Gt = function(e, t) { const n = q(e.nodeObj); we(n); const o = Te(this, t, n); if (!o) return; const { newNodeObj: s } = o; this.bus.fire("operation", { name: "copyNode", obj: s }), this.selectNode(this.findEle(s.id)); }, qt = function(e, t) { const n = []; for (let o = 0; o < e.length; o++) { const s = e[o], i = q(s.nodeObj); we(i); const r = Te(this, t, i); if (!r) return; const { newNodeObj: l } = r; n.push(l); } this.bus.fire("operation", { name: "copyNodes", objs: n }), this.unselectNodes(this.currentNodes), this.selectNodes(n.map((o) => this.findEle(o.id))); }, nt = function(e, t, n) { const o = t.parent?.children; if (o === void 0) return; const s = e.direction === 2 && !t.parent?.parent, i = (a) => !s || a.direction === t.direction; let r, l = !1; for (const a of o) if (i(a)) { if (a === t) { if (n === -1) return r ? { to: r, type: "before" } : void 0; l = !0; continue; } if (l) return { to: a, type: "after" }; r = a; } }, zt = function(e) { const t = e || this.currentNode; if (!t) return; const n = t.nodeObj; if (!n.parent) return; const o = nt(this, n, -1); o && Z([t], o.type, this.findEle(o.to.id), this); }, Ut = function(e) { const t = e || this.currentNode; if (!t) return; const n = t.nodeObj; if (!n.parent) return; const o = nt(this, n, 1); o && Z([t], o.type, this.findEle(o.to.id), this); }, Jt = function(e) { if (e = Ee(e), e.length === 0) return; for (const n of e) { const o = n.nodeObj, s = Qe(o); Yt(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) }); }, Z = (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 = /* @__PURE__ */ new Set(); for (const l of e) { const a = l.nodeObj; if (Bt(t, a, s), Y(o.nodeData), t === "in") { const h = l.parentElement.parentElement, d = h.parentElement; et(o, n, h), i.add(d); } else { J(l); const c = l.parentElement.parentNode; i.add(c.parentElement), n.parentElement.parentNode.insertAdjacentElement(tt[t], c); } } for (const l of i) l.childElementCount === 0 && l.tagName !== "ME-MAIN" && (l.previousSibling.children[1].remove(), l.remove()); o.linkDiv(), o.scrollIntoView(e[e.length - 1]); const r = t === "before" ? "moveNodeBefore" : t === "after" ? "moveNodeAfter" : "moveNodeIn"; o.bus.fire("operation", { name: r, objs: e.map((l) => l.nodeObj), toObj: s }); }, Zt = function(e, t) { Z(e, "in", t, this); }, Qt = function(e, t) { Z(e, "before", t, this); }, en = function(e, t) { Z(e, "after", t, this); }, tn = function(e) { const t = e || this.currentNode; t && (t.nodeObj.dangerouslySetInnerHTML || this.editTopic(t)); }, nn = function(e, t) { e.text.textContent = t, e.nodeObj.topic = t, this.linkDiv(); }, ot = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({ __proto__: null, addChild: Vt, beginEdit: tn, copyNode: Gt, copyNodes: qt, insertParent: Kt, insertSibling: Ft, moveDownNode: Ut, moveNodeAfter: en, moveNodeBefore: Qt, moveNodeIn: Zt, moveUpNode: zt, removeNodes: Jt, reshapeNode: Xt, rmSubline: J, setNodeTopic: nn }, Symbol.toStringTag, { value: "Module" })); function on(e) { return { nodeData: e.isFocusMode ? e.nodeDataBackup : e.nodeData, arrows: e.arrows, summaries: e.summaries, direction: e.direction, theme: e.theme, compact: e.compact, meta: e.meta }; } const sn = function(e, t = !1) { const n = this.container, o = e.getBoundingClientRect(), s = n.getBoundingClientRect(); if (t || o.top > s.bottom - 50 || o.bottom < s.top + 50 || o.left > s.right - 50 || o.right < s.left + 50) { const r = o.left + o.width / 2, l = o.top + o.height / 2, a = s.left + s.width / 2, c = s.top + s.height / 2, h = r - a, d = l - c; this.move(-h, -d, !0); } }, rn = function(e, t, n) { this.clearSelection(), this.scrollIntoView(e), this.selection?.select(e), t && this.bus.fire("selectNewNode", e.nodeObj); }, ln = function(e) { this.selection?.select(e); }, cn = function(e) { this.selection?.deselect(e); }, an = function() { this.unselectNodes(this.currentNodes), this.unselectSummary(), this.unselectArrow(); }, De = function(e) { return JSON.stringify(e, (t, n) => { if (!(t === "parent" && typeof n != "string")) return n; }); }, dn = function() { const e = on(this); return De(e); }, hn = function() { return JSON.parse(this.getDataString()); }, fn = function() { this.editable = !0; }, un = function() { this.editable = !1; }, pn = 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: r } = Me(this), l = this.map.style.transform, { x: a, y: c } = Ce(l), h = a - i, d = c - r, u = this.scaleVal, p = (-o + h) * (1 - e / u), m = (-s + d) * (1 - e / u); this.map.style.transform = `translate3d(${a - p}px, ${c - m}px, 0) scale(${e})`, this.scaleVal = e, this.bus.fire("scale", e); }, gn = 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 } = Me(this, !0); this.map.style.transform = `translate3d(${o}px, ${s}px, 0) scale(${n})`, this.bus.fire("scale", n); }, mn = function(e, t, n = !1) { const { map: o, scaleVal: s, bus: i, container: r, nodes: l } = this; if (n && o.style.transition === "transform 0.3s") return !1; const a = o.style.transform; let { x: c, y: h } = Ce(a); const d = r.getBoundingClientRect(), u = l.getBoundingClientRect(), p = (d.left + d.right) / 2, m = (d.top + d.bottom) / 2; return e > 0 ? e = Math.min(e, Math.max(0, p - u.left)) : e < 0 && (e = Math.max(e, Math.min(0, p - u.right))), t > 0 ? t = Math.min(t, Math.max(0, m - u.top)) : t < 0 && (t = Math.max(t, Math.min(0, m - u.bottom))), e === 0 && t === 0 ? !1 : (c += e, h += t, n && (o.style.transition = "transform 0.3s", setTimeout(() => { o.style.transition = "none"; }, 300)), o.style.transform = `translate3d(${c}px, ${h}px, 0) scale(${s})`, i.fire("move", { dx: e, dy: t }), !0); }, Me = (e, t = !1) => { const { container: n, map: o, nodes: s } = e; let i, r; if (e.alignment === "nodes" || t || e.direction === 3) i = (n.offsetWidth - s.offsetWidth) / 2, r = (n.offsetHeight - s.offsetHeight) / 2, o.style.transformOrigin = "50% 50%"; else { const l = o.querySelector("me-root"), a = l.offsetTop, c = l.offsetLeft, h = l.offsetWidth, d = l.offsetHeight; i = n.offsetWidth / 2 - c - h / 2, r = n.offsetHeight / 2 - a - d / 2, o.style.transformOrigin = `${c + h / 2}px 50%`; } return { dx: i, dy: r }; }, yn = function() { const { map: e, container: t } = this, { dx: n, dy: o } = Me(this); t.scrollTop = 0, t.scrollLeft = 0, e.style.transform = `translate3d(${n}px, ${o}px, 0) scale(${this.scaleVal})`; }, bn = function(e) { e(this); }, vn = 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()); }, xn = function() { this.isFocusMode = !1, this.tempDirection !== null && (this.nodeData = this.nodeDataBackup, this.direction = this.tempDirection, this.tempDirection = null, this.refresh(), this.toCenter()); }, wn = function() { this.direction = 0, this.refresh(), this.toCenter(), this.bus.fire("changeDirection", this.direction); }, En = function() { this.direction = 1, this.refresh(), this.toCenter(), this.bus.fire("changeDirection", this.direction); }, Cn = function() { this.direction = 2, this.refresh(), this.toCenter(), this.bus.fire("changeDirection", this.direction); }, Sn = function() { this.direction = 3, this.refresh(), this.toCenter(), this.bus.fire("changeDirection", this.direction); }, Nn = 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, r = i.children[1]; if (r.expanded = n.expanded, r.className = n.expanded ? "minus" : "", J(e), n.expanded) { const d = this.createChildren( n.children.map((u) => this.createWrapper(u).grp) ); i.parentNode.appendChild(d); } else i.parentNode.children[1].remove(); this.linkDiv(e.closest("me-main > me-wrapper")); const l = e.getBoundingClientRect(), a = { x: l.left, y: l.top }, c = s.x - a.x, h = s.y - a.y; this.move(c, h), this.bus.fire("expandNode", n); }, Tn = function(e, t) { const n = e.nodeObj, o = e.getBoundingClientRect(), s = { x: o.left, y: o.top }; G(n, t ?? !n.expanded), this.refresh(); const i = this.findEle(n.id).getBoundingClientRect(), r = { x: i.left, y: i.top }, l = s.x - r.x, a = s.y - r.y; this.move(l, a); }, Dn = function(e) { this.clearSelection(), e && (e = JSON.parse(JSON.stringify(e)), this.nodeData = e.nodeData, this.arrows = e.arrows || [], this.summaries = e.summaries || [], e.meta && (this.meta = e.meta)), Y(this.nodeData), this.layout(), this.linkDiv(); }, Mn = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({ __proto__: null, cancelFocus: xn, clearSelection: an, disableEdit: un, enableEdit: fn, expandNode: Nn, expandNodeAll: Tn, focusNode: vn, getData: hn, getDataString: dn, initDown: Sn, initLeft: wn, initRight: En, initSide: Cn, install: bn, move: mn, refresh: Dn, scale: pn, scaleFit: gn, scrollIntoView: sn, selectNode: rn, selectNodes: ln, stringifyData: De, toCenter: yn, unselectNodes: cn }, Symbol.toStringTag, { value: "Module" })), $e = "MIND-ELIXIR-WAIT-COPY", _n = 40, Ln = 10, kn = ({ deltaMode: e, deltaY: t, viewportHeight: n }) => e === WheelEvent.DOM_DELTA_LINE ? t * _n : e === WheelEvent.DOM_DELTA_PAGE ? t * n : t, An = ({ deltaMode: e, deltaY: t, scaleSensitivity: n, viewportHeight: o }) => { const i = -kn({ deltaMode: e, deltaY: t, viewportHeight: o }) / Ln * n; return Math.max(-n, Math.min(n, i)); }, st = (e, t, n) => { t !== 0 && e.scale(e.scaleVal + t, n); }, Pn = (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]); }, it = (e) => { e.selectNode(e.map.querySelector("me-root>me-tpc")); }, rt = function(e, t) { const n = t.parentElement.parentElement.parentElement.previousSibling; if (n) { const o = n.firstChild; e.selectNode(o); } }, lt = function(e, t) { const n = t.parentElement.nextSibling; if (n && n.firstChild) { const o = n.firstChild.firstChild.firstChild; e.selectNode(o); } }, He = 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 ? lt(e, n) : o.parent?.parent ? rt(e, n) : it(e) : Pn(e, t); }, ne = 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); }, On = function(e, t) { const n = t.nodeObj; n.parent && (n.parent.parent ? rt(e, t) : it(e)); }, $n = function(e, t) { if (t.nodeObj.parent) lt(e, t); else { const o = e.map.querySelectorAll(".down>me-wrapper>me-parent>me-tpc"); if (o.length === 0) return; e.selectNode(o[Math.ceil(o.length / 2) - 1]); } }, Ie = function(e, t, n) { const o = t === "in" ? e.scaleSensitivity : -e.scaleSensitivity; st(e, o, n); }, Hn = (e, t) => { const n = An({ deltaMode: t.deltaMode, deltaY: t.deltaY, scaleSensitivity: e.scaleSensitivity, viewportHeight: e.container.clientHeight || window.innerHeight }); st(e, n, { x: t.clientX, y: t.clientY }); }; function In(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 = () => { o = !1, s && (clearTimeout(s), s = null), e.container.removeEventListener("keydown", r); }, r = (c) => { if (["Control", "Meta", "Shift", "Alt"].includes(c.key)) return; const h = e.nodeData; if (!h.children?.length) { i(); return; } let d = !0; if (c.key === "0") for (const u of h.children) G(u, !1); else if (c.key === "=") for (const u of h.children) G(u, !0); else if (["1", "2", "3", "4", "5", "6", "7", "8", "9"].includes(c.key)) for (const u of h.children) G(u, !0, Number(c.key) - 1); else d = !1; d && (e.refresh(), e.toCenter()), i(); }, l = { Enter: (c) => { c.shiftKey ? e.insertSibling("before") : c.ctrlKey || c.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: (c) => { if (c.altKey) e.moveUpNode(); else { if (c.metaKey || c.ctrlKey) return e.initSide(); if (e.direction === 3) { const h = e.currentNode || e.currentNodes?.[0]; h && On(e, h); } else ne(e, "previous"); } }, ArrowDown: (c) => { if (c.altKey) e.moveDownNode(); else if (e.direction === 3) { const h = e.currentNode || e.currentNodes?.[0]; h && $n(e, h); } else ne(e, "next"); }, ArrowLeft: (c) => { if (c.metaKey || c.ctrlKey) return e.initLeft(); e.direction === 3 ? ne(e, "previous") : He(e, L.LHS); }, ArrowRight: (c) => { if (c.metaKey || c.ctrlKey) return e.initRight(); e.direction === 3 ? ne(e, "next") : He(e, L.RHS); }, PageUp: () => e.moveUpNode(), PageDown: () => { e.moveDownNode(); }, "=": (c) => { (c.metaKey || c.ctrlKey) && Ie(e, "in"); }, "-": (c) => { (c.metaKey || c.ctrlKey) && Ie(e, "out"); }, 0: (c) => { if (c.metaKey || c.ctrlKey) { if (o) return; e.scale(1); } }, k: (c) => { (c.metaKey || c.ctrlKey) && (i(), o = !0, s = window.setTimeout(() => { s = null, i(); }, 2e3), e.container.addEventListener("keydown", r)); }, Delete: n, Backspace: n, ...t }; e.container.onkeydown = (c) => { if ((c.ctrlKey || c.metaKey) && ["c", "v", "x"].includes(c.key) || c.preventDefault(), !e.editable) return; const d = l[c.key]; d && d(c); }; const a = (c) => { if (c.target instanceof HTMLElement && c.target.id === "input-box" || e.currentNodes.length === 0) return !1; if (c.clipboardData) { const h = Ee(e.currentNodes).map((u) => u.nodeObj), d = De({ magic: $e, data: h }); return c.clipboardData.setData("text/plain", d), c.preventDefault(), !0; } return !1; }; e.container.addEventListener("copy", a), e.container.addEventListener("cut", (c) => { a(c) && n(); }), e.container.addEventListener("paste", (c) => { const h = c.clipboardData?.getData("text/plain"); if (h) try { const d = JSON.parse(h); if (d && d.magic === $e && Array.isArray(d.data)) { const u = d.data, p = u.map((m) => ({ nodeObj: m })); u.length > 0 && e.currentNode && (e.copyNodes(p, e.currentNode), c.preventDefault()); return; } } catch { } e.pasteHandler && e.pasteHandler(c); }); } function jn(e) { const { panHelper: t, container: n } = e; let o = null; e.spacePressed = !1; const s = { lastTap: 0, lastTapTarget: null, DOUBLE_CLICK_THRESHOLD: 300, detect(f, b) { if (f.button !== 0) { this.clear(); return; } const w = (/* @__PURE__ */ new Date()).getTime(), E = w - this.lastTap, S = E < this.DOUBLE_CLICK_THRESHOLD && E > 0 && this.lastTapTarget === f.target; this.lastTap = w, this.lastTapTarget = f.target, S && b(f); }, clear() { this.lastTap = 0, this.lastTapTarget = null; } }, i = { Idle: 0, Pinch: 1, DragWait: 2, Drag: 3, Pan: 4, BoxSelect: 5 }; e.ptState = i.Idle; const r = { lastDistance: null, activePointers: /* @__PURE__ */ new Map(), handlePointerDown(f) { if (f.pointerType !== "touch") return !1; if (this.activePointers.set(f.pointerId, { x: f.clientX, y: f.clientY }), this.activePointers.size >= 2) { const [b, w] = Array.from(this.activePointers.values()); return this.lastDistance = ke(b, w), !0; } return !1; }, handlePointerMove(f) { if (f.pointerType !== "touch" || !this.activePointers.has(f.pointerId)) return !1; if (this.activePointers.set(f.pointerId, { x: f.clientX, y: f.clientY }), this.activePointers.size >= 2) { const [b, w] = Array.from(this.activePointers.values()), E = ke(b, w); if (this.lastDistance !== null && this.lastDistance > 0) { const S = E / this.lastDistance; e.scale(e.scaleVal * S, { x: (b.x + w.x) / 2, y: (b.y + w.y) / 2 }); } return this.lastDistance = E, !0; } return !1; }, handlePointerUp(f) { f.pointerType === "touch" && (this.activePointers.delete(f.pointerId), this.activePointers.size < 2 && (this.lastDistance = null)); }, clear() { this.activePointers.clear(), this.lastDistance = null; } }, l = Nt(e), a = { timer: null, startPos: null, pointerId: null, DURATION: 500, MOVE_THRESHOLD: 10, clear() { this.timer !== null && (clearTimeout(this.timer), this.timer = null, this.startPos = null, this.pointerId = null); }, start(f, b) { this.timer = window.setTimeout(() => { b(f), this.timer = null, this.startPos = null, this.pointerId = null; }, this.DURATION), this.startPos = { x: f.clientX, y: f.clientY }, this.pointerId = f.pointerId; }, handleMove(f) { if (this.timer !== null && this.startPos !== null && f.pointerId === this.pointerId) { const b = f.clientX - this.startPos.x, w = f.clientY - this.startPos.y; Math.sqrt(b * b + w * w) > this.MOVE_THRESHOLD && this.clear(); } } }, c = (f, b) => { if (f.closest("#input-box")) return !1; const w = f.closest(".svg-label"), E = f.closest(".topiclinks, .summary"), S = w ? { type: w.dataset.type, element: document.getElementById(w.dataset.svgId) } : E ? { type: E.classList.contains("topiclinks") ? "arrow" : "summary", element: f.closest("g") } : null; if (!S?.type || !S?.element) return !1; const { type: M, element: N } = S; return e.clearSelection(), M === "arrow" ? b ? e.editArrowLabel(N) : e.selectArrow(N) : b ? e.editSummary(N) : e.selectSummary(N), !0; }, h = (f) => { if (f.pointerType === "mouse" && 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 (l?.isDragging) return; const b = f.target; b.tagName === "ME-EPD" && (f.ctrlKey || f.metaKey ? e.expandNodeAll(b.previousSibling) : e.expandNode(b.previousSibling)); }, d = (f) => { if (!e.editable) return; const b = f.target; if (re(b)) { e.selectNode(b), e.beginEdit(b); return; } c(b, !0); }, u = (f) => { if (f.pointerType === "touch" && r.handlePointerDown(f)) { e.ptState = i.Pinch, a.clear(), t.clear(), (l.isDragging || l.pointerId !== null) && Oe(e, l); return; } if (e.ptState === i.Pinch) return; const b = f.target; if (e.editable && b.className === "map-container" && f.button === 0 && f.pointerType === "mouse") { e.ptState = i.BoxSelect; return; } if (t.handlePointerDown(f), t.mousedown && (e.ptState = i.Pan), f.button === 0 || f.pointerType === "touch") if (re(b)) { e.selection?.cancel(); const E = e.currentNodes || []; if (f.ctrlKey || f.metaKey || e.mobileMultiSelect ? E.includes(b) ? o = b : ((e.currentArrow || e.currentSummary) && e.clearSelection(), e.selection?.select(b)) : E.includes(b) || e.selectNode(b), !e.editable) return; f.pointerType === "touch" ? (e.ptState = i.DragWait, a.start(f, (M) => { Pe(e, l, M, !0) && (e.ptState = i.Drag, b.setPointerCapture(M.pointerId)); })) : Pe(e, l, f, !1) && (e.ptState = i.Drag, b.setPointerCapture(f.pointerId)); } else c(b, !1); }, p = (f) => { switch (e.ptState) { case i.Pinch: r.handlePointerMove(f); break; case i.DragWait: a.handleMove(f), a.timer === null && (e.ptState = i.Pan, t.handlePointerMove(f)); break; case i.Drag: Dt(e, l, f); break; case i.Pan: t.handlePointerMove(f); break; } }, m = (f) => { f.preventDefault(), window.removeEventListener("contextmenu", m, !0); }, x = (f) => { f.pointerType === "touch" && r.handlePointerUp(f); const b = l.isDragging, w = t.moved; switch (e.ptState) { case i.DragWait: a.clear(); break; case i.Drag: Mt(e, l, f); break; case i.Pan: t.handlePointerUp(f), t.moved && f.button === 2 && f.pointerType === "mouse" && (window.addEventListener("contextmenu", m, { capture: !0, once: !0 }), setTimeout(() => window.removeEventListener("contextmenu", m, !0), 300)); break; } s.detect(f, d), (e.ptState !== i.Pinch || r.activePointers.size < 2) && (e.ptState = i.Idle), o && (!b && !w && e.selection?.deselect(o), o = null); }, y = () => { r.clear(), a.clear(), t.clear(), s.clear(), (l.isDragging || l.pointerId !== null) && Oe(e, l), e.ptState = i.Idle, o = null; }, g = (f) => { f.preventDefault(), f.button === 2 && e.editable && setTimeout(() => { if (e.panHelper.moved || e.ptState !== i.Idle && e.ptState !== i.Pan) return; const b = f.target; re(b) && !b.classList.contains("selected") && e.selectNode(b), e.bus.fire("showContextMenu", f); }, 200); }, v = (f) => { if (f.ctrlKey || f.metaKey) return f.stopPropagation(), f.preventDefault(), Hn(e, f); (f.shiftKey ? e.move(-f.deltaY, 0) : e.move(-f.deltaX, -f.deltaY)) && (f.stopPropagation(), f.preventDefault()); }, C = (f) => { f.code === "Space" && (e.spacePressed = !0, e.container.classList.add("space-pressed")); }, T = (f) => { f.code === "Space" && (e.spacePressed = !1, e.container.classList.remove("space-pressed")); }; return qe([ { dom: n, evt: "pointerdown", func: u }, { dom: n, evt: "pointermove", func: p }, { dom: n, evt: "pointerup", func: x }, { dom: n, evt: "pointercancel", func: y }, { dom: n, evt: "click", func: h }, { dom: n, evt: "contextmenu", func: g }, { dom: n, evt: "wheel", func: typeof e.handleWheel == "function" ? e.handleWheel : v }, { dom: n, evt: "blur", func: y }, { dom: n, evt: "keydown", func: C }, { dom: n, evt: "keyup", func: T } ]); } function Rn() { 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), r = o.anchor; let l = s; r === "middle" ? l = s - t / 2 : r === "end" && (l = s - t), e.style.left = `${l}px`, e.style.top = `${i - n / 2}px`, e.style.visibility = "visible"; }, le = function(e, t, n, o) { const { anchor: s = "middle", color: i, dataType: r, svgId: l } = o, a = document.createElement("div"); a.className = "svg-label", a.style.color = i || "#666"; const c = "label-" + l; return a.id = c, a.innerHTML = e, a.dataset.type = r, a.dataset.svgId = l, a.dataset.x = t.toString(), a.dataset.y = n.toString(), a.dataset.anchor = s, a; }, ct = function(e, t, n) { const o = document.createElementNS(H, "path"); return _(o, { d: e, stroke: t || "#666", fill: "none", "stroke-width": n }), o; }, U = function(e) { const t = document.createElementNS(H, "svg"); return t.setAttribute("class", e), t.setAttribute("overflow", "visible"), t; }, je = 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; }, Bn = 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((r, l) => { const a = r.d, c = document.createElementNS(H, "path"), h = { d: a, stroke: o?.stroke || "rgb(227, 125, 116)", fill: "none", "stroke-width": String(o?.strokeWidth || "2") }; o?.opacity !== void 0 && (h.opacity = String(o.opacity)), _(c, h), l === 0 && c.setAttribute("stroke-dasharray", o?.strokeDasharray || "8,2"); const d = document.createElementNS(H, "path"); _(d, { d: a, stroke: "transparent", fill: "none", "stroke-width": "15" }), s.appendChild(d), s.appendChild(c), s[r.name] = c; }), s; }, at = function(e, t, n) { if (!t) return; const o = n.label; t.style.opacity = "0"; const 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; `, Ze(s), e.scrollIntoView(s), s.addEventListener("keydown", (i) => { if (i.stopPropagation(), i.isComposing) return; const r = i.key; if (r === "Enter" || r === "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, t.style.opacity = "1", 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 })); }); }, Wn = function(e) { const t = this.map.querySelector("me-root"), n = t.offsetTop, o = t.offsetLeft, s = t.offsetWidth, i = t.offsetHeight, r = this.map.querySelectorAll("me-main > me-wrapper"); this.lines.innerHTML = ""; for (let l = 0; l < r.length; l++) { const a = r[l], c = a.querySelector("me-tpc"), { offsetLeft: h, offsetTop: d } = $(this.nodes, c), u = c.offsetWidth, p = c.offsetHeight, m = a.parentNode.className, x = this.generateMainBranch({ pT: n, pL: o, pW: s, pH: i, cT: d, cL: h, cW: u, cH: p, direction: m, containerHeight: this.nodes.offsetHeight, containerWidth: this.nodes.offsetWidth }), y = this.theme.palette, g = c.nodeObj.branchColor || y[l % y.length]; if (c.style.borderColor = g, this.lines.appendChild(ct(x, g, "3")), e && e !== a) continue; const v = U("subLines"), C = a.lastChild; C.tagName === "svg" && C.remove(), a.appendChild(v), dt(this, v, g, a, m, !0); } this.labelContainer.innerHTML = "", this.renderArrow(), this.renderSummary(), this.bus.fire("linkDiv"); }, dt = function(e, t, n, o, s, i) { const r = o.firstChild, l = o.children[1].children; if (l.length === 0) return; const a = r.offsetTop, c = r.offsetLeft, h = r.offsetWidth, d = r.offsetHeight; for (let u = 0; u < l.length; u++) { const p = l[u], m = p.firstChild, x = m.offsetTop, y = m.offsetLeft, g = m.offsetWidth, v = m.offsetHeight, C = m.firstChild.