UNPKG

mind-elixir

Version:

Mind elixir is a free open source mind map core.

1,032 lines 70.6 kB
const In = 0, On = 1, Yn = 2, rt = { 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" } }, ct = { 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 Ht(t) { return t.replace(/&/g, "&amp;").replace(/</g, "&lt;").replace(/"/g, "&quot;"); } const K = function(t, e) { if (e.id === t) return e; if (e.children && e.children.length) { for (let n = 0; n < e.children.length; n++) { const o = K(t, e.children[n]); if (o) return o; } return null; } else return null; }, lt = (t, e) => { if (t.parent = e, t.children) for (let n = 0; n < t.children.length; n++) lt(t.children[n], t); }, xt = (t, e, n) => { t.expanded = e, t.children && t.children.forEach((o) => { xt(o, e); }); }; function J(t, e, n, o) { const s = n - t, i = o - e, c = Math.atan2(i, s) * 180 / Math.PI, a = 12, l = 30, h = (c + 180 - l) * Math.PI / 180, f = (c + 180 + l) * Math.PI / 180; return { x1: n + Math.cos(h) * a, y1: o + Math.sin(h) * a, x2: n + Math.cos(f) * a, y2: o + Math.sin(f) * a }; } function F() { return ((/* @__PURE__ */ new Date()).getTime().toString(16) + Math.random().toString(16).substring(2)).substring(2, 18); } const It = function() { const t = F(); return { topic: this.newTopicName, id: t }; }, H = (t, e) => { let n = 0, o = 0; for (; e && e !== t; ) n += e.offsetLeft, o += e.offsetTop, e = e.offsetParent; return { offsetLeft: n, offsetTop: o }; }, N = (t, e) => { for (const n in e) t.setAttribute(n, e[n]); }, nt = (t) => t ? t.tagName === "ME-TPC" : !1, at = (t) => { const e = /translate3d\(([^,]+),\s*([^,]+)/, n = t.match(e); return n ? { x: parseFloat(n[1]), y: parseFloat(n[2]) } : { x: 0, y: 0 }; }, Ct = function(t) { for (let e = 0; e < t.length; e++) { const { dom: n, evt: o, func: s } = t[e]; n.addEventListener(o, s); } return function() { for (let n = 0; n < t.length; n++) { const { dom: o, evt: s, func: i } = t[n]; o.removeEventListener(s, i); } }; }, ut = (t, e) => { const n = t.x - e.x, o = t.y - e.y; return Math.sqrt(n * n + o * o); }, V = { LHS: "lhs", RHS: "rhs" }, Ot = function() { this.nodes.innerHTML = ""; const t = this.createTopic(this.nodeData); St.call(this, t, this.nodeData), t.draggable = !1; const e = document.createElement("me-root"); e.appendChild(t); 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, e); }, Yt = function(t, e, n) { const o = document.createElement("me-main"); o.className = V.LHS; const s = document.createElement("me-main"); s.className = V.RHS; for (let i = 0; i < e.length; i++) { const r = e[i], { grp: c } = t.createWrapper(r); t.direction === 2 ? r.direction === 0 ? o.appendChild(c) : s.appendChild(c) : t.direction === 0 ? o.appendChild(c) : s.appendChild(c); } t.nodes.appendChild(o), t.nodes.appendChild(n), t.nodes.appendChild(s), t.nodes.appendChild(t.lines), t.nodes.appendChild(t.labelContainer); }, Bt = function(t, e) { const n = document.createElement("me-children"); for (let o = 0; o < e.length; o++) { const s = e[o], { grp: i } = t.createWrapper(s); n.appendChild(i); } return n; }, Et = function(t, e) { const o = (this?.el ? this.el : e || document).querySelector(`[data-nodeid="me${t}"]`); if (!o) throw new Error(`FindEle: Node ${t} not found, maybe it's collapsed.`); return o; }, St = function(t, e) { if (t.innerHTML = "", e.style) { const n = e.style; for (const o in n) t.style[o] = n[o]; } if (e.dangerouslySetInnerHTML) { t.innerHTML = e.dangerouslySetInnerHTML; return; } if (e.image) { const n = e.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), t.appendChild(o), t.image = o; } } else t.image && (t.image = void 0); { const n = document.createElement("span"); n.className = "text", this.markdown ? n.innerHTML = this.markdown(e.topic, e) : n.textContent = e.topic, t.appendChild(n), t.text = n; } if (e.hyperLink) { const n = document.createElement("a"); n.className = "hyper-link", n.target = "_blank", n.innerText = "🔗", n.href = e.hyperLink, t.appendChild(n), t.link = n; } else t.link && (t.link = void 0); if (e.icons && e.icons.length) { const n = document.createElement("span"); n.className = "icons", n.innerHTML = e.icons.map((o) => `<span>${Ht(o)}</span>`).join(""), t.appendChild(n), t.icons = n; } else t.icons && (t.icons = void 0); if (e.tags && e.tags.length) { const n = document.createElement("div"); n.className = "tags", e.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); }), t.appendChild(n), t.tags = n; } else t.tags && (t.tags = void 0); }, Rt = function(t, e) { const n = document.createElement("me-wrapper"), { p: o, tpc: s } = this.createParent(t); if (n.appendChild(o), !e && t.children && t.children.length > 0) { const i = zt(t.expanded); if (o.appendChild(i), t.expanded !== !1) { const r = Bt(this, t.children); n.appendChild(r); } } return { grp: n, top: o, tpc: s }; }, Wt = function(t) { const e = document.createElement("me-parent"), n = this.createTopic(t); return St.call(this, n, t), e.appendChild(n), { p: e, tpc: n }; }, Xt = function(t) { const e = document.createElement("me-children"); return e.append(...t), e; }, Vt = function(t) { const e = document.createElement("me-tpc"); return e.nodeObj = t, e.dataset.nodeid = "me" + t.id, e; }; function Tt(t) { const e = document.createRange(); e.selectNodeContents(t); const n = window.getSelection(); n && (n.removeAllRanges(), n.addRange(e)); } const Gt = function(t) { if (!t) return; const e = document.createElement("div"), n = t.nodeObj, o = n.topic, { offsetLeft: s, offsetTop: i } = H(this.nodes, t); this.nodes.appendChild(e), e.id = "input-box", e.textContent = o, e.contentEditable = "plaintext-only", e.spellcheck = !1; const r = getComputedStyle(t); e.style.cssText = ` left: ${s}px; top: ${i}px; min-width:${t.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 && (e.style.right = "0"), Tt(e), this.bus.fire("operation", { name: "beginEdit", obj: t.nodeObj }), e.addEventListener("keydown", (c) => { c.stopPropagation(); const a = c.key; if (a === "Enter" || a === "Tab") { if (c.shiftKey) return; c.preventDefault(), e.blur(), this.container.focus(); } else a === "Escape" && (c.preventDefault(), e.textContent = o, e.blur(), this.container.focus()); }), e.addEventListener("blur", () => { if (!e) return; e.remove(); const c = e.innerText?.trim() || ""; c === o || c === "" || (n.topic = c, this.markdown ? t.text.innerHTML = this.markdown(n.topic, n) : t.text.textContent = c, this.linkDiv(), this.bus.fire("operation", { name: "finishEdit", obj: n, origin: o })); }); }, zt = function(t) { const e = document.createElement("me-epd"); return e.expanded = t !== !1, e.className = t !== !1 ? "minus" : "", e; }, Ft = function(t) { const n = t.parentElement.parentElement.lastElementChild; n?.tagName === "svg" && n?.remove(); }; function qt(t) { return { nodeData: t.isFocusMode ? t.nodeDataBackup : t.nodeData, arrows: t.arrows, summaries: t.summaries, direction: t.direction, theme: t.theme }; } const jt = function(t) { const e = this.container, n = t.getBoundingClientRect(), o = e.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, r = n.top + n.height / 2, c = o.left + o.width / 2, a = o.top + o.height / 2, l = i - c, h = r - a; this.move(-l, -h, !0); } }, _t = function(t, e, n) { this.clearSelection(), this.scrollIntoView(t), this.selection?.select(t), e && this.bus.fire("selectNewNode", t.nodeObj); }, Ut = function(t) { this.selection?.select(t); }, Kt = function(t) { this.selection?.deselect(t); }, Jt = function() { this.unselectNodes(this.currentNodes), this.unselectSummary(), this.unselectArrow(); }, Lt = function(t) { return JSON.stringify(t, (e, n) => { if (!(e === "parent" && typeof n != "string")) return n; }); }, Qt = function() { const t = qt(this); return Lt(t); }, Zt = function() { return JSON.parse(this.getDataString()); }, te = function() { this.editable = !0; }, ee = function() { this.editable = !1; }, ne = function(t, e = { x: 0, y: 0 }) { if (t < this.scaleMin && t < this.scaleVal || t > this.scaleMax && t > this.scaleVal) return; const n = this.container.getBoundingClientRect(), o = e.x ? e.x - n.left - n.width / 2 : 0, s = e.y ? e.y - n.top - n.height / 2 : 0, { dx: i, dy: r } = dt(this), c = this.map.style.transform, { x: a, y: l } = at(c), h = a - i, f = l - r, u = this.scaleVal, y = (-o + h) * (1 - t / u), m = (-s + f) * (1 - t / u); this.map.style.transform = `translate3d(${a - y}px, ${l - m}px, 0) scale(${t})`, this.scaleVal = t, this.bus.fire("scale", t); }, oe = function() { const t = this.nodes.offsetHeight / this.container.offsetHeight, e = this.nodes.offsetWidth / this.container.offsetWidth, n = 1 / Math.max(1, Math.max(t, e)); this.scaleVal = n; const { dx: o, dy: s } = dt(this, !0); this.map.style.transform = `translate3d(${o}px, ${s}px, 0) scale(${n})`, this.bus.fire("scale", n); }, se = function(t, e, n = !1) { const { map: o, scaleVal: s, bus: i, container: r, nodes: c } = this; if (n && o.style.transition === "transform 0.3s") return; const a = o.style.transform; let { x: l, y: h } = at(a); const f = r.getBoundingClientRect(), u = c.getBoundingClientRect(), y = u.left < f.right && u.right > f.left, m = u.top < f.bottom && u.bottom > f.top; if (y) { const p = u.left + t, g = u.right + t; (p >= f.right || g <= f.left) && (t = 0); } if (m) { const p = u.top + e, g = u.bottom + e; (p >= f.bottom || g <= f.top) && (e = 0); } l += t, h += e, n && (o.style.transition = "transform 0.3s", setTimeout(() => { o.style.transition = "none"; }, 300)), o.style.transform = `translate3d(${l}px, ${h}px, 0) scale(${s})`, i.fire("move", { dx: t, dy: e }); }, dt = (t, e = !1) => { const { container: n, map: o, nodes: s } = t; let i, r; if (t.alignment === "nodes" || e) i = (n.offsetWidth - s.offsetWidth) / 2, r = (n.offsetHeight - s.offsetHeight) / 2, o.style.transformOrigin = "50% 50%"; else { const c = o.querySelector("me-root"), a = c.offsetTop, l = c.offsetLeft, h = c.offsetWidth, f = c.offsetHeight; i = n.offsetWidth / 2 - l - h / 2, r = n.offsetHeight / 2 - a - f / 2, o.style.transformOrigin = `${l + h / 2}px 50%`; } return { dx: i, dy: r }; }, ie = function() { const { map: t, container: e } = this, { dx: n, dy: o } = dt(this); e.scrollTop = 0, e.scrollLeft = 0, t.style.transform = `translate3d(${n}px, ${o}px, 0) scale(${this.scaleVal})`; }, re = function(t) { t(this); }, ce = function(t) { t.nodeObj.parent && (this.clearSelection(), this.tempDirection === null && (this.tempDirection = this.direction), this.isFocusMode || (this.nodeDataBackup = this.nodeData, this.isFocusMode = !0), this.nodeData = t.nodeObj, this.initRight(), this.toCenter()); }, le = function() { this.isFocusMode = !1, this.tempDirection !== null && (this.nodeData = this.nodeDataBackup, this.direction = this.tempDirection, this.tempDirection = null, this.refresh(), this.toCenter()); }, ae = function() { this.direction = 0, this.refresh(), this.toCenter(), this.bus.fire("changeDirection", this.direction); }, de = function() { this.direction = 1, this.refresh(), this.toCenter(), this.bus.fire("changeDirection", this.direction); }, he = function() { this.direction = 2, this.refresh(), this.toCenter(), this.bus.fire("changeDirection", this.direction); }, fe = function(t) { this.locale = t, this.refresh(); }, ue = function(t, e) { const n = t.nodeObj; typeof e == "boolean" ? n.expanded = e : n.expanded !== !1 ? n.expanded = !1 : n.expanded = !0; const o = t.getBoundingClientRect(), s = { x: o.left, y: o.top }, i = t.parentNode, r = i.children[1]; if (r.expanded = n.expanded, r.className = n.expanded ? "minus" : "", Ft(t), n.expanded) { const f = this.createChildren( n.children.map((u) => this.createWrapper(u).grp) ); i.parentNode.appendChild(f); } else i.parentNode.children[1].remove(); this.linkDiv(t.closest("me-main > me-wrapper")); const c = t.getBoundingClientRect(), a = { x: c.left, y: c.top }, l = s.x - a.x, h = s.y - a.y; this.move(l, h), this.bus.fire("expandNode", n); }, pe = function(t, e) { const n = t.nodeObj, o = t.getBoundingClientRect(), s = { x: o.left, y: o.top }; xt(n, e ?? !n.expanded), this.refresh(); const i = this.findEle(n.id).getBoundingClientRect(), r = { x: i.left, y: i.top }, c = s.x - r.x, a = s.y - r.y; this.move(c, a); }, ge = function(t) { this.clearSelection(), t && (t = JSON.parse(JSON.stringify(t)), this.nodeData = t.nodeData, this.arrows = t.arrows || [], this.summaries = t.summaries || [], t.theme && this.changeTheme(t.theme)), lt(this.nodeData), this.layout(), this.linkDiv(); }, me = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({ __proto__: null, cancelFocus: le, clearSelection: Jt, disableEdit: ee, enableEdit: te, expandNode: ue, expandNodeAll: pe, focusNode: ce, getData: Zt, getDataString: Qt, initLeft: ae, initRight: de, initSide: he, install: re, move: se, refresh: ge, scale: ne, scaleFit: oe, scrollIntoView: jt, selectNode: _t, selectNodes: Ut, setLocale: fe, stringifyData: Lt, toCenter: ie, unselectNodes: Kt }, Symbol.toStringTag, { value: "Module" })), pt = function(t, e, n) { const { scaleVal: o, scaleSensitivity: s } = t; switch (e) { case "in": t.scale(o + s, n); break; case "out": t.scale(o - s, n); } }, ye = function(t, e) { if (!e) return Z(t), t; let n = t.querySelector(".insert-preview"); const o = `insert-preview ${e} show`; return n || (n = document.createElement("div"), t.appendChild(n)), n.className = o, t; }, Z = function(t) { if (!t) return; const e = t.querySelectorAll(".insert-preview"); for (const n of e || []) n.remove(); }, gt = function(t, e) { for (const n of e) { const o = n.parentElement.parentElement.contains(t); if (!(t && t.tagName === "ME-TPC" && t !== n && !o && t.nodeObj.parent)) return !1; } return !0; }, ve = function(t) { const e = document.createElement("div"); return e.className = "mind-elixir-ghost", t.container.appendChild(e), e; }; class we { mind; isMoving = !1; interval = null; speed = 20; constructor(e) { this.mind = e; } move(e, n) { this.isMoving || (this.isMoving = !0, this.interval = setInterval(() => { this.mind.move(e * 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 be(t) { return { isDragging: !1, insertType: null, meet: null, ghost: ve(t), edgeMoveController: new we(t), startX: 0, startY: 0, pointerId: null }; } const xe = 5; function mt(t, e, n, o = !1) { if (t.spacePressed) return !1; const s = n.target; if (s?.tagName !== "ME-TPC" || !s.nodeObj.parent) return !1; e.startX = n.clientX, e.startY = n.clientY, e.pointerId = n.pointerId, t.selection?.cancel(); let i = t.currentNodes; return i?.includes(s) || (t.selectNode(s), i = t.currentNodes), t.dragged = i, o && Mt(t, e), !0; } function Dt(t, e, n) { t.style.transform = `translate(${e - 10}px, ${n - 10}px)`, t.style.display = "block"; } function Mt(t, e) { const { dragged: n } = t; if (!n) return; const o = document.activeElement; o && o.isContentEditable && o.blur(), e.isDragging = !0, n.length > 1 ? e.ghost.innerHTML = n.length + "" : e.ghost.innerHTML = n[0].innerHTML; for (const s of n) s.parentElement.parentElement.style.opacity = "0.5"; t.dragMoveHelper.clear(); } function Ce(t, e, n) { const { dragged: o } = t; if (!o || e.pointerId !== n.pointerId) return; const s = n.clientX - e.startX, i = n.clientY - e.startY, r = Math.sqrt(s * s + i * i); if (!e.isDragging && r > xe && Mt(t, e), !e.isDragging) return; const c = t.container.getBoundingClientRect(); Dt(e.ghost, n.clientX - c.x, n.clientY - c.y), n.clientX < c.x + 50 ? e.edgeMoveController.move(1, 0) : n.clientX > c.x + c.width - 50 ? e.edgeMoveController.move(-1, 0) : n.clientY < c.y + 50 ? e.edgeMoveController.move(0, 1) : n.clientY > c.y + c.height - 50 ? e.edgeMoveController.move(0, -1) : e.edgeMoveController.stop(), Z(e.meet); const a = 12 * t.scaleVal, l = document.elementFromPoint(n.clientX, n.clientY - a); if (gt(l, o)) { e.meet = l; const h = l.getBoundingClientRect(), f = h.y; n.clientY > f + h.height ? e.insertType = "after" : e.insertType = "in"; } else { const h = document.elementFromPoint(n.clientX, n.clientY + a); if (gt(h, o)) { e.meet = h; const u = h.getBoundingClientRect().y; n.clientY < u ? e.insertType = "before" : e.insertType = "in"; } else e.insertType = null, e.meet = null; } e.meet && ye(e.meet, e.insertType); } function Ee(t, e, n) { const { dragged: o } = t; if (!(!o || e.pointerId !== n.pointerId)) { e.edgeMoveController.stop(); for (const s of o) s.parentElement.parentElement.style.opacity = "1"; e.ghost.style.display = "none", e.ghost.innerHTML = "", e.isDragging && e.meet && (Z(e.meet), e.insertType === "before" ? t.moveNodeBefore(o, e.meet) : e.insertType === "after" ? t.moveNodeAfter(o, e.meet) : e.insertType === "in" && t.moveNodeIn(o, e.meet)), t.dragged = null, e.isDragging = !1, e.insertType = null, e.meet = null, e.pointerId = null; } } function ot(t, e) { const { dragged: n } = t; if (n) { e.edgeMoveController.stop(); for (const o of n) o.parentElement.parentElement.style.opacity = "1"; e.meet && Z(e.meet), e.ghost.style.display = "none", e.ghost.innerHTML = "", t.dragged = null, e.isDragging = !1, e.insertType = null, e.meet = null, e.pointerId = null; } } function Se(t) { const { dragMoveHelper: e } = t; let n = 0; t.spacePressed = !1; let o = null; const s = /* @__PURE__ */ new Map(), i = be(t); let r = null, c = null, a = null, l = null; const h = 500, f = 10, u = () => { r !== null && (clearTimeout(r), r = null, c = null, a = null, l = null); }, y = (d, v) => { d.hasPointerCapture && d.hasPointerCapture(v) && d.releasePointerCapture(v); }, m = (d, v) => { if (d.id === "input-box" || d.closest("#input-box")) return !1; const C = d.closest(".svg-label"); if (C) { const $ = C.dataset.svgId, q = C.dataset.type, G = document.getElementById($); if (G) { if (q === "arrow") return v ? t.editArrowLabel(G) : t.selectArrow(G), !0; if (q === "summary") return v ? t.editSummary(G) : t.selectSummary(G), !0; } } if (d.closest(".topiclinks")) { const $ = d.closest("g"); if ($) return v ? t.editArrowLabel($) : t.selectArrow($), !0; } if (d.closest(".summary")) { const $ = d.closest("g"); if ($) return v ? t.editSummary($) : t.selectSummary($), !0; } return !1; }, p = (d) => { if (d.button !== 0) return; if (t.helper1?.moved) { t.helper1.clear(); return; } if (t.helper2?.moved) { t.helper2.clear(); return; } if (e.moved) { e.clear(); return; } if (i?.isDragging) return; const v = d.target; if (v.tagName === "ME-EPD") d.ctrlKey || d.metaKey ? t.expandNodeAll(v.previousSibling) : t.expandNode(v.previousSibling); else if (v.tagName === "ME-TPC" && t.currentNodes.length > 1) t.selectNode(v); else if (!t.editable) return; m(v, !1); }, g = (d) => { if (!t.editable) return; const v = d.target; nt(v) && t.beginEdit(v), m(v, !0); }, b = (d) => { if (d.pointerType === "mouse" || s.size > 1) return; const v = (/* @__PURE__ */ new Date()).getTime(), C = v - n; C < 300 && C > 0 && g(d), n = v; }, w = (d) => { d.code === "Space" && (t.spacePressed = !0, t.container.classList.add("space-pressed")); }, x = (d) => { d.code === "Space" && (t.spacePressed = !1, t.container.classList.remove("space-pressed")); }, S = (d) => { if (d.pointerType === "touch" && (s.set(d.pointerId, { x: d.clientX, y: d.clientY }), s.size === 2)) { const [$, q] = Array.from(s.values()); o = ut($, q), u(); } e.moved = !1; const v = d.target, C = t.mouseSelectionButton === 0 ? 2 : 0; if (t.editable && i && (d.button === 0 || d.pointerType === "touch")) { if (d.pointerType === "touch" && s.size > 1) (i.isDragging || i.pointerId !== null) && ot(t, i); else if (d.pointerType === "touch" && s.size === 1) (nt(v) || v.closest("me-tpc")) && (c = { x: d.clientX, y: d.clientY }, a = v, l = d.pointerId, r = window.setTimeout(() => { mt(t, i, d, !0) && (a && a.setPointerCapture(d.pointerId), Dt(i.ghost, d.clientX, d.clientY)), r = null, c = null, a = null, l = null; }, h)); else if (d.pointerType === "mouse" && mt(t, i, d, !1)) { v.setPointerCapture(d.pointerId); return; } } const P = t.spacePressed && d.button === 0 && d.pointerType === "mouse", B = !t.editable || d.button === C && d.pointerType === "mouse" || d.pointerType === "touch"; !P && !B || (e.x = d.clientX, e.y = d.clientY, v.className !== "circle" && v.contentEditable !== "plaintext-only" && (e.mousedown = !0, v.setPointerCapture(d.pointerId))); }, T = (d) => { if (d.pointerType === "touch" && s.has(d.pointerId)) { if (s.set(d.pointerId, { x: d.clientX, y: d.clientY }), r !== null && c !== null && d.pointerId === l) { const v = d.clientX - c.x, C = d.clientY - c.y; Math.sqrt(v * v + C * C) > f && u(); } if (s.size >= 2) { const [v, C] = Array.from(s.values()), P = ut(v, C); if (o == null) o = P; else { if (o > 0) { const B = P / o; t.scale(t.scaleVal * B, { x: (v.x + C.x) / 2, y: (v.y + C.y) / 2 }); } o = P; } return; } } if (!(i && i.pointerId !== null && (Ce(t, i, d), i.isDragging))) { if (d.target.contentEditable !== "plaintext-only" || t.spacePressed && e.mousedown) { const v = d.clientX - e.x, C = d.clientY - e.y; e.onMove(v, C); } e.x = d.clientX, e.y = d.clientY; } }, M = (d) => { if (d.pointerType === "touch" && (s.delete(d.pointerId), s.size < 2 && (o = null), u()), i && i.pointerId !== null) { const v = i.isDragging; if (Ee(t, i, d), y(d.target, d.pointerId), v) return; } e.mousedown && (y(d.target, d.pointerId), e.clear()); }, E = () => { u(), e.mousedown && e.clear(), i && (i.isDragging || i.pointerId !== null) && ot(t, i); }, L = (d) => { d.pointerType === "touch" && (s.delete(d.pointerId), s.size < 2 && (o = null), u()), i && i.pointerId === d.pointerId && ot(t, i), M(d); }, k = (d) => { if (d.preventDefault(), d.button !== 2 || !t.editable) return; const v = d.target; nt(v) && !v.classList.contains("selected") && t.selectNode(v), setTimeout(() => { t.dragMoveHelper.moved || t.bus.fire("showContextMenu", d); }, 200); }, Y = (d) => { d.stopPropagation(), d.preventDefault(), d.ctrlKey || d.metaKey ? d.deltaY < 0 ? pt(t, "in", t.dragMoveHelper) : t.scaleVal - t.scaleSensitivity > 0 && pt(t, "out", t.dragMoveHelper) : d.shiftKey ? t.move(-d.deltaY, 0) : t.move(-d.deltaX, -d.deltaY); }, { container: D } = t; return Ct([ { dom: D, evt: "pointerdown", func: S }, { dom: D, evt: "pointermove", func: T }, { dom: D, evt: "pointerup", func: M }, { dom: D, evt: "pointercancel", func: L }, { dom: D, evt: "pointerdown", func: b }, { dom: D, evt: "click", func: p }, { dom: D, evt: "dblclick", func: g }, { dom: D, evt: "contextmenu", func: k }, { dom: D, evt: "wheel", func: typeof t.handleWheel == "function" ? t.handleWheel : Y }, { dom: D, evt: "blur", func: E }, { dom: D, evt: "keydown", func: w }, { dom: D, evt: "keyup", func: x } ]); } function Te() { return { handlers: {}, addListener: function(t, e) { this.handlers[t] === void 0 && (this.handlers[t] = []), this.handlers[t].push(e); }, fire: function(t, ...e) { if (this.handlers[t] instanceof Array) { const n = this.handlers[t]; for (let o = 0; o < n.length; o++) n[o](...e); } }, removeListener: function(t, e) { if (!this.handlers[t]) return; const n = this.handlers[t]; if (!e) n.length = 0; else if (n.length) for (let o = 0; o < n.length; o++) n[o] === e && this.handlers[t].splice(o, 1); } }; } const I = "http://www.w3.org/2000/svg", tt = function(t) { const e = t.clientWidth, n = t.clientHeight, o = t.dataset, s = Number(o.x), i = Number(o.y), r = o.anchor; let c = s; r === "middle" ? c = s - e / 2 : r === "end" && (c = s - e), t.style.left = `${c}px`, t.style.top = `${i - n / 2}px`, t.style.visibility = "visible"; }, it = function(t, e, n, o) { const { anchor: s = "middle", color: i, dataType: r, svgId: c } = o, a = document.createElement("div"); a.className = "svg-label", a.style.color = i || "#666"; const l = "label-" + c; return a.id = l, a.innerHTML = t, a.dataset.type = r, a.dataset.svgId = c, a.dataset.x = e.toString(), a.dataset.y = n.toString(), a.dataset.anchor = s, a; }, kt = function(t, e, n) { const o = document.createElementNS(I, "path"); return N(o, { d: t, stroke: e || "#666", fill: "none", "stroke-width": n }), o; }, z = function(t) { const e = document.createElementNS(I, "svg"); return e.setAttribute("class", t), e.setAttribute("overflow", "visible"), e; }, yt = function() { const t = document.createElementNS(I, "line"); return t.setAttribute("stroke", "#4dc4ff"), t.setAttribute("fill", "none"), t.setAttribute("stroke-width", "2"), t.setAttribute("opacity", "0.45"), t; }, Le = function(t, e, n, o) { const s = document.createElementNS(I, "g"); return [ { name: "line", d: t }, { name: "arrow1", d: e }, { name: "arrow2", d: n } ].forEach((r, c) => { const a = r.d, l = document.createElementNS(I, "path"), h = { d: a, stroke: o?.stroke || "rgb(227, 125, 116)", fill: "none", "stroke-linecap": o?.strokeLinecap || "cap", "stroke-width": String(o?.strokeWidth || "2") }; o?.opacity !== void 0 && (h.opacity = String(o.opacity)), N(l, h), c === 0 && l.setAttribute("stroke-dasharray", o?.strokeDasharray || "8,2"); const f = document.createElementNS(I, "path"); N(f, { d: a, stroke: "transparent", fill: "none", "stroke-width": "15" }), s.appendChild(f), s.appendChild(l), s[r.name] = l; }), s; }, Nt = function(t, e, n) { if (!e) return; const o = n.label, s = e.cloneNode(!0); t.nodes.appendChild(s), s.id = "input-box", s.textContent = o, s.contentEditable = "plaintext-only", s.spellcheck = !1, s.style.cssText = ` left:${e.style.left}; top:${e.style.top}; max-width: 200px; `, Tt(s), t.scrollIntoView(s), s.addEventListener("keydown", (i) => { i.stopPropagation(); const r = i.key; if (r === "Enter" || r === "Tab") { if (i.shiftKey) return; i.preventDefault(), s.blur(), t.container.focus(); } }), s.addEventListener("blur", () => { if (!s) return; const i = s.innerText?.trim() || ""; i === "" ? n.label = o : n.label = i, s.remove(), i !== o && (t.markdown ? e.innerHTML = t.markdown(n.label, n) : e.textContent = n.label, tt(e), "parent" in n ? t.bus.fire("operation", { name: "finishEditSummary", obj: n }) : t.bus.fire("operation", { name: "finishEditArrowLabel", obj: n })); }); }, De = function(t) { const e = this.map.querySelector("me-root"), n = e.offsetTop, o = e.offsetLeft, s = e.offsetWidth, i = e.offsetHeight, r = this.map.querySelectorAll("me-main > me-wrapper"); this.lines.innerHTML = ""; for (let c = 0; c < r.length; c++) { const a = r[c], l = a.querySelector("me-tpc"), { offsetLeft: h, offsetTop: f } = H(this.nodes, l), u = l.offsetWidth, y = l.offsetHeight, m = a.parentNode.className, p = this.generateMainBranch({ pT: n, pL: o, pW: s, pH: i, cT: f, cL: h, cW: u, cH: y, direction: m, containerHeight: this.nodes.offsetHeight }), g = this.theme.palette, b = l.nodeObj.branchColor || g[c % g.length]; if (l.style.borderColor = b, this.lines.appendChild(kt(p, b, "3")), t && t !== a) continue; const w = z("subLines"), x = a.lastChild; x.tagName === "svg" && x.remove(), a.appendChild(w), $t(this, w, b, a, m, !0); } this.labelContainer.innerHTML = "", this.renderArrow(), this.renderSummary(), this.bus.fire("linkDiv"); }, $t = function(t, e, n, o, s, i) { const r = o.firstChild, c = o.children[1].children; if (c.length === 0) return; const a = r.offsetTop, l = r.offsetLeft, h = r.offsetWidth, f = r.offsetHeight; for (let u = 0; u < c.length; u++) { const y = c[u], m = y.firstChild, p = m.offsetTop, g = m.offsetLeft, b = m.offsetWidth, w = m.offsetHeight, x = m.firstChild.nodeObj.branchColor || n, S = t.generateSubBranch({ pT: a, pL: l, pW: h, pH: f, cT: p, cL: g, cW: b, cH: w, direction: s, isFirst: i }); e.appendChild(kt(S, x, "2")); const T = m.children[1]; if (T) { if (!T.expanded) continue; } else continue; $t(t, e, x, y, s); } }, Me = '<?xml version="1.0" standalone="no"?><!DOCTYPE svg PUBLIC "-//W3C//DTD SVG 1.1//EN" "http://www.w3.org/Graphics/SVG/1.1/DTD/svg11.dtd"><svg t="1750169394918" class="icon" viewBox="0 0 1024 1024" version="1.1" xmlns="http://www.w3.org/2000/svg" p-id="2021" xmlns:xlink="http://www.w3.org/1999/xlink" width="200" height="200"><path d="M851.91168 328.45312c-59.97056 0-108.6208 48.47104-108.91264 108.36992l-137.92768 38.4a109.14304 109.14304 0 0 0-63.46752-46.58688l1.39264-137.11872c47.29344-11.86816 82.31936-54.66624 82.31936-105.64096 0-60.15488-48.76288-108.91776-108.91776-108.91776s-108.91776 48.76288-108.91776 108.91776c0 49.18784 32.60928 90.75712 77.38368 104.27392l-1.41312 138.87488a109.19936 109.19936 0 0 0-63.50336 48.55808l-138.93632-39.48544 0.01024-0.72704c0-60.15488-48.76288-108.91776-108.91776-108.91776s-108.91776 48.75776-108.91776 108.91776c0 60.15488 48.76288 108.91264 108.91776 108.91264 39.3984 0 73.91232-20.92032 93.03552-52.2496l139.19232 39.552-0.00512 0.2304c0 25.8304 9.00096 49.5616 24.02816 68.23424l-90.14272 132.63872a108.7488 108.7488 0 0 0-34.2528-5.504c-60.15488 0-108.91776 48.768-108.91776 108.91776 0 60.16 48.76288 108.91776 108.91776 108.91776 60.16 0 108.92288-48.75776 108.92288-108.91776 0-27.14624-9.9328-51.968-26.36288-71.04l89.04704-131.03104a108.544 108.544 0 0 0 37.6832 6.70208 108.672 108.672 0 0 0 36.48512-6.272l93.13792 132.57216a108.48256 108.48256 0 0 0-24.69888 69.0688c0 60.16 48.768 108.92288 108.91776 108.92288 60.16 0 108.91776-48.76288 108.91776-108.92288 0-60.14976-48.75776-108.91776-108.91776-108.91776a108.80512 108.80512 0 0 0-36.69504 6.3488l-93.07136-132.48a108.48768 108.48768 0 0 0 24.79616-72.22784l136.09984-37.888c18.99008 31.93856 53.84192 53.3504 93.69088 53.3504 60.16 0 108.92288-48.75776 108.92288-108.91264-0.00512-60.15488-48.77312-108.92288-108.92288-108.92288z" p-id="2022"></path></svg>', ke = '<?xml version="1.0" standalone="no"?><!DOCTYPE svg PUBLIC "-//W3C//DTD SVG 1.1//EN" "http://www.w3.org/Graphics/SVG/1.1/DTD/svg11.dtd"><svg t="1750169375313" class="icon" viewBox="0 0 1024 1024" version="1.1" xmlns="http://www.w3.org/2000/svg" p-id="1775" xmlns:xlink="http://www.w3.org/1999/xlink" width="200" height="200"><path d="M639 463.30000001L639 285.1c0-36.90000001-26.4-68.5-61.3-68.5l-150.2 0c-1.5 0-3 0.1-4.5 0.3-10.2-38.7-45.5-67.3-87.5-67.3-50 0-90.5 40.5-90.5 90.5s40.5 90.5 90.5 90.5c42 0 77.3-28.6 87.5-67.39999999 1.4 0.3 2.9 0.4 4.5 0.39999999L577.7 263.6c6.8 0 14.3 8.9 14.3 21.49999999l0 427.00000001c0 12.7-7.40000001 21.5-14.30000001 21.5l-150.19999999 0c-1.5 0-3 0.2-4.5 0.4-10.2-38.8-45.5-67.3-87.5-67.3-50 0-90.5 40.5-90.5 90.4 0 49.9 40.5 90.6 90.5 90.59999999 42 0 77.3-28.6 87.5-67.39999999 1.4 0.2 2.9 0.4 4.49999999 0.4L577.7 780.7c34.80000001 0 61.3-31.6 61.3-68.50000001L639 510.3l79.1 0c10.4 38.5 45.49999999 67 87.4 67 50 0 90.5-40.5 90.5-90.5s-40.5-90.5-90.5-90.5c-41.79999999 0-77.00000001 28.4-87.4 67L639 463.30000001z" fill="currentColor" p-id="1776"></path></svg>', Ne = '<?xml version="1.0" standalone="no"?><!DOCTYPE svg PUBLIC "-//W3C//DTD SVG 1.1//EN" "http://www.w3.org/Graphics/SVG/1.1/DTD/svg11.dtd"><svg t="1750169667709" class="icon" viewBox="0 0 1024 1024" version="1.1" xmlns="http://www.w3.org/2000/svg" p-id="3037" xmlns:xlink="http://www.w3.org/1999/xlink" width="200" height="200"><path d="M385 560.69999999L385 738.9c0 36.90000001 26.4 68.5 61.3 68.5l150.2 0c1.5 0 3-0.1 4.5-0.3 10.2 38.7 45.5 67.3 87.5 67.3 50 0 90.5-40.5 90.5-90.5s-40.5-90.5-90.5-90.5c-42 0-77.3 28.6-87.5 67.39999999-1.4-0.3-2.9-0.4-4.5-0.39999999L446.3 760.4c-6.8 0-14.3-8.9-14.3-21.49999999l0-427.00000001c0-12.7 7.40000001-21.5 14.30000001-21.5l150.19999999 0c1.5 0 3-0.2 4.5-0.4 10.2 38.8 45.5 67.3 87.5 67.3 50 0 90.5-40.5 90.5-90.4 0-49.9-40.5-90.6-90.5-90.59999999-42 0-77.3 28.6-87.5 67.39999999-1.4-0.2-2.9-0.4-4.49999999-0.4L446.3 243.3c-34.80000001 0-61.3 31.6-61.3 68.50000001L385 513.7l-79.1 0c-10.4-38.5-45.49999999-67-87.4-67-50 0-90.5 40.5-90.5 90.5s40.5 90.5 90.5 90.5c41.79999999 0 77.00000001-28.4 87.4-67L385 560.69999999z" fill="currentColor" p-id="3038"></path></svg>', $e = '<?xml version="1.0" standalone="no"?><!DOCTYPE svg PUBLIC "-//W3C//DTD SVG 1.1//EN" "http://www.w3.org/Graphics/SVG/1.1/DTD/svg11.dtd"><svg t="1750169402629" class="icon" viewBox="0 0 1024 1024" version="1.1" xmlns="http://www.w3.org/2000/svg" p-id="2170" xmlns:xlink="http://www.w3.org/1999/xlink" width="200" height="200"><path d="M639.328 416c8.032 0 16.096-3.008 22.304-9.056l202.624-197.184-0.8 143.808c-0.096 17.696 14.144 32.096 31.808 32.192 0.064 0 0.128 0 0.192 0 17.6 0 31.904-14.208 32-31.808l1.248-222.208c0-0.672-0.352-1.248-0.384-1.92 0.032-0.512 0.288-0.896 0.288-1.408 0.032-17.664-14.272-32-31.968-32.032L671.552 96l-0.032 0c-17.664 0-31.968 14.304-32 31.968C639.488 145.632 653.824 160 671.488 160l151.872 0.224-206.368 200.8c-12.672 12.32-12.928 32.608-0.64 45.248C622.656 412.736 630.976 416 639.328 416z" p-id="2171"></path><path d="M896.032 639.552 896.032 639.552c-17.696 0-32 14.304-32.032 31.968l-0.224 151.872-200.832-206.4c-12.32-12.64-32.576-12.96-45.248-0.64-12.672 12.352-12.928 32.608-0.64 45.248l197.184 202.624-143.808-0.8c-0.064 0-0.128 0-0.192 0-17.6 0-31.904 14.208-32 31.808-0.096 17.696 14.144 32.096 31.808 32.192l222.24 1.248c0.064 0 0.128 0 0.192 0 0.64 0 1.12-0.32 1.76-0.352 0.512 0.032 0.896 0.288 1.408 0.288l0.032 0c17.664 0 31.968-14.304 32-31.968L928 671.584C928.032 653.952 913.728 639.584 896.032 639.552z" p-id="2172"></path><path d="M209.76 159.744l143.808 0.8c0.064 0 0.128 0 0.192 0 17.6 0 31.904-14.208 32-31.808 0.096-17.696-14.144-32.096-31.808-32.192L131.68 95.328c-0.064 0-0.128 0-0.192 0-0.672 0-1.248 0.352-1.888 0.384-0.448 0-0.8-0.256-1.248-0.256 0 0-0.032 0-0.032 0-17.664 0-31.968 14.304-32 31.968L96 352.448c-0.032 17.664 14.272 32 31.968 32.032 0 0 0.032 0 0.032 0 17.664 0 31.968-14.304 32-31.968l0.224-151.936 200.832 206.4c6.272 6.464 14.624 9.696 22.944 9.696 8.032 0 16.096-3.008 22.304-9.056 12.672-12.32 12.96-32.608 0.64-45.248L209.76 159.744z" p-id="2173"></path><path d="M362.368 617.056l-202.624 197.184 0.8-143.808c0.096-17.696-14.144-32.096-31.808-32.192-0.064 0-0.128 0-0.192 0-17.6 0-31.904 14.208-32 31.808l-1.248 222.24c0 0.704 0.352 1.312 0.384 2.016 0 0.448-0.256 0.832-0.256 1.312-0.032 17.664 14.272 32 31.968 32.032L352.448 928c0 0 0.032 0 0.032 0 17.664 0 31.968-14.304 32-31.968s-14.272-32-31.968-32.032l-151.936-0.224 206.4-200.832c12.672-12.352 12.96-32.608 0.64-45.248S375.008 604.704 362.368 617.056z" p-id="2174"></path></svg>', Ae = '<?xml version="1.0" standalone="no"?><!DOCTYPE svg PUBLIC "-//W3C//DTD SVG 1.1//EN" "http://www.w3.org/Graphics/SVG/1.1/DTD/svg11.dtd"><svg t="1750169573443" class="icon" viewBox="0 0 1024 1024" version="1.1" xmlns="http://www.w3.org/2000/svg" p-id="2883" xmlns:xlink="http://www.w3.org/1999/xlink" width="200" height="200"><path d="M514.133333 488.533333m-106.666666 0a106.666667 106.666667 0 1 0 213.333333 0 106.666667 106.666667 0 1 0-213.333333 0Z" fill="currentColor" p-id="2884"></path><path d="M512 64C264.533333 64 64 264.533333 64 512c0 236.8 183.466667 428.8 416 445.866667v-134.4c-53.333333-59.733333-200.533333-230.4-200.533333-334.933334 0-130.133333 104.533333-234.666667 234.666666-234.666666s234.666667 104.533333 234.666667 234.666666c0 61.866667-49.066667 153.6-145.066667 270.933334l-59.733333 68.266666V960C776.533333 942.933333 960 748.8 960 512c0-247.466667-200.533333-448-448-448z" fill="currentColor" p-id="2885"></path></svg>', Pe = '<?xml version="1.0" standalone="no"?><!DOCTYPE svg PUBLIC "-//W3C//DTD SVG 1.1//EN" "http://www.w3.org/Graphics/SVG/1.1/DTD/svg11.dtd"><svg t="1750169419447" class="icon" viewBox="0 0 1024 1024" version="1.1" xmlns="http://www.w3.org/2000/svg" p-id="2480" xmlns:xlink="http://www.w3.org/1999/xlink" width="200" height="200"><path d="M863.328 482.56l-317.344-1.12L545.984 162.816c0-17.664-14.336-32-32-32s-32 14.336-32 32l0 318.4L159.616 480.064c-0.032 0-0.064 0-0.096 0-17.632 0-31.936 14.24-32 31.904C127.424 529.632 141.728 544 159.392 544.064l322.592 1.152 0 319.168c0 17.696 14.336 32 32 32s32-14.304 32-32l0-318.944 317.088 1.12c0.064 0 0.096 0 0.128 0 17.632 0 31.936-14.24 32-31.904C895.264 496.992 880.96 482.624 863.328 482.56z" p-id="2481"></path></svg>', He = '<?xml version="1.0" standalone="no"?><!DOCTYPE svg PUBLIC "-//W3C//DTD SVG 1.1//EN" "http://www.w3.org/Graphics/SVG/1.1/DTD/svg11.dtd"><svg t="1750169426515" class="icon" viewBox="0 0 1024 1024" version="1.1" xmlns="http://www.w3.org/2000/svg" p-id="2730" xmlns:xlink="http://www.w3.org/1999/xlink" width="200" height="200"><path d="M863.744 544 163.424 544c-17.664 0-32-14.336-32-32s14.336-32 32-32l700.32 0c17.696 0 32 14.336 32 32S881.44 544 863.744 544z" p-id="2731"></path></svg>', Ie = { side: Me, left: ke, right: Ne, full: $e, living: Ae, zoomin: Pe, zoomout: He }, R = (t, e) => { const n = document.createElement("span"); return n.id = t, n.innerHTML = Ie[e], n; }; function Oe(t) { const e = document.createElement("div"), n = R("fullscreen", "full"), o = R("toCenter", "living"), s = R("zoomout", "zoomout"), i = R("zoomin", "zoomin"); e.appendChild(n), e.appendChild(o), e.appendChild(s), e.appendChild(i), e.className = "mind-elixir-toolbar rb"; let r = null; const c = () => { const l = t.container.getBoundingClientRect(), h = at(t.map.style.transform), f = l.width / 2, u = l.height / 2, y = (f - h.x) / t.scaleVal, m = (u - h.y) / t.scaleVal; r = { containerRect: l, currentTransform: h, mapCenterX: y, mapCenterY: m }; }, a = () => { if (r) { const l = t.container.getBoundingClientRect(), h = l.width / 2, f = l.height / 2, u = h - r.mapCenterX * t.scaleVal, y = f - r.mapCenterY * t.scaleVal, m = u - r.currentTransform.x, p = y - r.currentTransform.y; t.move(m, p); } }; return t.el.addEventListener("fullscreenchange", a), n.onclick = () => { c(), document.fullscreenElement !== t.el ? t.el.requestFullscreen() : document.exitFullscreen(); }, o.onclick = () => { t.toCenter(); }, s.onclick = () => { t.scale(t.scaleVal - t.scaleSensitivity); }, i.onclick = () => { t.scale(t.scaleVal + t.scaleSensitivity); }, e; } function Ye(t) { const e = document.createElement("div"), n = R("tbltl", "left"), o = R("tbltr", "right"), s = R("tblts", "side"); return e.appendChild(n), e.appendChild(o), e.appendChild(s), e.className = "mind-elixir-toolbar lt", n.onclick = () => { t.initLeft(); }, o.onclick = () => { t.initRight(); }, s.onclick = () => { t.initSide(); }, e; } function Be(t) { t.container.append(Oe(t)), t.container.append(Ye(t)); } const Re = function(t, e = !0) { this.theme = t; const o = { ...(t.type === "dark" ? ct : rt).cssVar, ...t.cssVar }, s = Object.keys(o); for (let i = 0; i < s.length; i++) { const r = s[i]; this.container.style.setProperty(r, o[r]); } e && this.refresh(); }, We = function(t) { return { dom: t, moved: !1, // differentiate click and move pointerdown: !1, lastX: 0, lastY: 0, handlePointerMove(e) { if (this.pointerdown) { this.moved = !0; const n = e.clientX - this.lastX, o = e.clientY - this.lastY; this.lastX = e.clientX, this.lastY = e.clientY, this.cb && this.cb(n, o); } }, handlePointerDown(e) { e.button === 0 && (this.pointerdown = !0, this.lastX = e.clientX, this.lastY = e.clientY, this.dom.setPointerCapture(e.pointerId)); }, handleClear(e) { this.pointerdown = !1, e.pointerId !== void 0 && this.dom.releasePointerCapture(e.pointerId); }, cb: null, init(e, n) { this.cb = n, this.handleClear = this.handleClear.bind(this), this.handlePointerMove = this.handlePointerMove.bind(this), this.handlePointerDown = this.handlePointerDown.bind(this), this.destroy = Ct([ { dom: e, evt: "pointermove", func: this.handlePointerMove }, { dom: e, evt: "pointerleave", func: this.handleClear }, { dom: e, evt: "pointerup", func: this.handleClear }, { dom: this.dom, evt: "pointerdown", func: this.handlePointerDown } ]); }, destroy: null, clear() { this.moved = !1, this.pointerdown = !1; } }; }, vt = { create: We }, Xe = "#4dc4ff"; function At(t, e, n, o, s, i, r, c) { return { x: t / 8 + n * 3 / 8 + s * 3 / 8 + r / 8, y: e / 8 + o * 3 / 8 + i * 3 / 8 + c / 8 }; } function Ve(t, e, n) { t && (t.dataset.x = e.toString(), t.dataset.y = n.toString(), tt(t)); } function j(t, e, n, o, s) { N(t, { x1: e + "", y1: n + "", x2: o + "", y2: s + "" }); } function wt(t, e, n, o, s, i, r, c, a, l) { const h = `M ${e} ${n} C ${o} ${s} ${i} ${r} ${c} ${a}`; if (t.line.setAttribute("d", h), l.style) { const p = l.style; p.stroke && t.line.setAttribute("stroke", p.stroke), p.strokeWidth && t.line.setAttribute("stroke-width", String(p.strokeWidth)), p.strokeDasharray && t.line.setAttribute("stroke-dasharray", p.strokeDasharray), p.strokeLinecap && t.line.setAttribute("stroke-linecap", p.strokeLinecap), p.opacity !== void 0 && t.line.setAttribute("opacity", String(p.opacity)); } const f = t.querySelectorAll('path[stroke="transparent"]'); f.length > 0 && f[0].setAttribute("d", h); const u = J(i, r, c, a); if (u) { const p = `M ${u.x1} ${u.y1} L ${c} ${a} L ${u.x2} ${u.y2}`; if (t.arrow1.setAttribute("d", p), f.length > 1 && f[1].setAttribute("d", p), l.style) { const g = l.style; g.stroke && t.arrow1.setAttribute("stroke", g.stroke), g.strokeWidth && t.arrow1.setAttribute("stroke-width", String(g.strokeWidth)), g.strokeLinecap && t.arrow1.setAttribute("stroke-linecap", g.strokeLinecap), g.opacity !== void 0 && t.arrow1.setAttribute("opacity", String(g.opacity)); } } if (l.bidirectional) { const p = J(o, s, e, n); if (p) { const g = `M ${p.x1} ${p.y1} L ${e} ${n} L ${p.x2} ${p.y2}`; if (t.arrow2.setAttribute("d", g), f.length > 2 && f[2].setAttribute("d", g), l.style) { const b = l.style; b.stroke && t.arrow2.setAttribute("stroke", b.stroke), b.strokeWidth && t.arrow2.setAttribute("stroke-width", String(b.strokeWidth)), b.strokeLinecap && t.arrow2.setAttribute("stroke-linecap", b.strokeLinecap), b.opacity !== void 0 && t.arrow2.setAttribute("opacity", String(b.opacity)); } } } const { x: y, y: m } = At(e, n, o, s, i, r, c, a); if (t.labelEl && Ve(t.labelEl, y, m), l.style?.labelColor) { const p = t.labelEl; p && (p.style.color = l.style.labelColor); } Je(t); } function Q(t, e, n) { const { offsetLeft: o, offsetTop: s } = H(t.nodes, e), i = e.offsetWidth, r = e.offsetHeight, c = o + i / 2, a = s + r / 2, l = c + n.x, h = a + n.y; return { w: i, h: r, cx: c, cy: a, ctrlX: l, ctrlY: h }; } function X(t) { let e, n; const o = (t.cy - t.ctrlY) / (t.ctrlX - t.cx); return o > t.h / t.w || o < -t.h / t.w ? t.cy - t.ctrlY < 0 ? (e = t.cx - t.h / 2 / o, n = t.cy + t.h / 2) : (e = t.cx + t.h / 2 / o, n = t.cy - t.h / 2) : t.cx - t.ctrlX < 0 ? (e = t.cx + t.w / 2, n = t.cy - t.w * o / 2) : (e = t.cx - t.w / 2, n = t.cy + t.w * o / 2), { x: e, y: n }; } const Ge = function(t, e, n) { const o = H(t.nodes, e), s = H(t.nodes, n), i = o.offsetLeft + e.offsetWidth / 2, r = o.offsetTop + e.offsetHeight / 2, c = s.offsetLeft + n.offsetWidth / 2, a = s.offsetTop + n.offsetHeight / 2, l = c - i, h = a - r, f = Math.sqrt(l * l + h * h), u = Math.max(50, Math.min(200, f * 0.3)), y = Math.abs(l), m = Math.abs(h); let p, g; if (f < 150) { const w = e.closest("me-main").className === "lhs" ? -1 : 1; p = { x: 200 * w, y: 0 }, g = { x: 200 * w, y: 0 }; } else if (y > m * 1.5) { const w = l > 0 ? e.offsetWidth / 2 : -e.offsetWidth / 2, x = l > 0 ? -n.offsetWidth / 2 : n.offsetWidth / 2; p = { x: w + (l > 0 ? u : -u), y: 0 }, g = { x: x + (l > 0 ? -u : u), y: 0 }; } else if (m > y * 1.5) { const w = h > 0 ? e.offsetHeight / 2 : -e.offsetHeight / 2, x = h > 0 ? -n.offsetHeight / 2 : n.offsetHeight / 2; p = { x: 0, y: w + (h > 0 ? u : -u) }, g = { x: 0, y: x + (h > 0 ? -u : u) }; } else { const w = Math.atan2(h, l), x = e.offsetWidth / 2 * Math.cos(w), S = e.offsetHeight / 2 * Math.sin(w), T = -(n.offsetWidth / 2) * Math.cos(w), M = -(n.offsetHeight / 2) * Math.sin(w), E = u * 0.7 * (l > 0 ? 1 : -1), L = u * 0.7 * (h > 0 ? 1 : -1); p = { x: x + E, y: S + L }, g = { x: T - E, y: M - L }; } return { delta1: p, delta2: g }; }, ht = function(t, e, n, o, s) { if (!e || !n) return; if (!o.delta1 || !o.delta2) { const k = Ge(t, e, n); o.delta1 = k.delta1, o.delta2 = k.delta2; } const i = Q(t, e, o.delta1), r = Q(t, n, o.delta2), { x: c, y: a } = X(i), { ctrlX: l, ctrlY: h } = i, { ctrlX: f, ctrlY: u } = r, { x: y, y: m } = X(r), p = J(f, u, y, m); if (!p) return; const g = `M ${p.x1} ${p.y1} L ${y} ${m} L ${p.x2} ${p.y2}`; let b = ""; if (o.bidirectional) { const k = J(l, h, c, a); if (!k) return; b = `M ${k.x1} ${k.y1} L ${c} ${a} L ${k.x2} ${k.y2}`; } const w = Le(`M ${c} ${a} C ${l} ${h} ${f} ${u} ${y} ${m}`, g, b, o.style), { x, y: S } = At(c, a, l, h, f, u, y, m), T = o.style?.labelColor || "rgb(235, 95, 82)", M = "arrow-" + o.id; w.id = M; const E = t.markdown ? t.markdown(o.label, o) : o.label, L = it(E, x, S, { anchor: "middle", color: T, dataType: "arrow", svgId: M }); w.labelEl = L, w.arrowObj = o, w.dataset.l