mind-elixir 3.3.0 → 3.3.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -8,5 +8,5 @@ var MindElixir=function(){"use strict";const yn="";(function(e){var t,n,o,i,s,r,
8
8
  `;function n(o,i){for(let s=0;s<o.length;s++)i<=6?t+="".padStart(i,"#")+" "+o[s].topic+`
9
9
 
10
10
  `:t+="".padStart(i-7," ")+"- "+o[s].topic+`
11
- `,o[s].children&&n(o[s].children||[],i+1)}return n(e.children||[],2),t},getDataString:function(){const e=Ae(this);return JSON.stringify(e,(t,n)=>{if(!(t==="parent"&&typeof n!="string"))return n})},initLeft:function(){this.direction=0,this.refresh()},initRight:function(){this.direction=1,this.refresh()},initSide:function(){this.direction=2,this.refresh()},install:function(e){e(this)},refresh:function(e){e&&(e=JSON.parse(JSON.stringify(e)),this.nodeData=e.nodeData,this.linkData=e.linkData||{},this.summaries=e.summaries||[]),D(this.nodeData),this.layout(),this.linkDiv()},scale:function(e){this.scaleVal=e,this.map.style.transform="scale("+e+")"},selectFirstChild:function(){if(!this.currentNode)return;const e=this.currentNode.parentElement.nextSibling;if(e&&e.firstChild){const t=e.firstChild.firstChild.firstChild;this.selectNode(t)}},selectNextSibling:function(){if(!this.currentNode||this.currentNode.dataset.nodeid==="meroot")return!1;const e=this.currentNode.parentElement.parentElement.nextSibling;let t;if(e)t=e.firstChild.firstChild;else return!1;return this.selectNode(t),!0},selectNode:function(e,t,n){if(e){if(console.time("selectNode"),typeof e=="string"){const o=w(e);return o?this.selectNode(o):void 0}this.currentNode&&(this.currentNode.className=""),e.className="selected",e.scrollIntoView({block:"nearest",inline:"nearest"}),this.currentNode=e,t?this.bus.fire("selectNewNode",e.nodeObj):this.bus.fire("selectNode",e.nodeObj,n),console.timeEnd("selectNode")}},selectNodes:function(e){if(e){console.time("selectNodes");for(const t of e)t.className="selected";this.currentNodes=e,this.bus.fire("selectNodes",e.map(t=>t.nodeObj)),console.timeEnd("selectNodes")}},selectParent:function(){if(!this.currentNode||this.currentNode.dataset.nodeid==="meroot")return;const e=this.currentNode.parentElement.parentElement.parentElement.previousSibling;if(e){const t=e.firstChild;this.selectNode(t)}},selectPrevSibling:function(){if(!this.currentNode||this.currentNode.dataset.nodeid==="meroot")return!1;const e=this.currentNode.parentElement.parentElement.previousSibling;let t;if(e)t=e.firstChild.firstChild;else return!1;return this.selectNode(t),!0},setLocale:function(e){this.locale=e,this.refresh()},toCenter:function(){this.container.scrollTo(1e4-this.container.offsetWidth/2,1e4-this.container.offsetHeight/2)},unselectNode:function(){this.currentNode&&(this.currentNode.className=""),this.currentNode=null,this.bus.fire("unselectNode")},unselectNodes:function(){if(this.currentNodes)for(const e of this.currentNodes)e.classList.remove("selected");this.currentNodes=null,this.bus.fire("unselectNodes")}},Symbol.toStringTag,{value:"Module"})),A=e=>{var o;const t=(o=e.parent)==null?void 0:o.children,n=t.indexOf(e);return{siblings:t,index:n}};function Ht(e){const{siblings:t,index:n}=A(e),o=t[n];n===0?(t[n]=t[t.length-1],t[t.length-1]=o):(t[n]=t[n-1],t[n-1]=o)}function Bt(e){const{siblings:t,index:n}=A(e),o=t[n];n===t.length-1?(t[n]=t[0],t[0]=o):(t[n]=t[n+1],t[n+1]=o)}function X(e){const{siblings:t,index:n}=A(e);return t.splice(n,1),t.length}function zt(e,t){const{siblings:n,index:o}=A(e);n.splice(o+1,0,t)}function Rt(e,t){const{siblings:n,index:o}=A(e);n.splice(o,0,t)}function qt(e,t){const{siblings:n,index:o}=A(e);n[o]=t,t.children=[e]}function Ft(e,t){X(e),t.children?t.children.push(e):t.children=[e]}function Vt(e,t){X(e);const{siblings:n,index:o}=A(t);n.splice(o,0,e)}function Wt(e,t){X(e);const{siblings:n,index:o}=A(t);n.splice(o+1,0,e)}const Pe=function(e,t){var n,o;if(e===k)return k;if(e===P)return P;if(e===U){const i=((n=document.querySelector(".lhs"))==null?void 0:n.childElementCount)||0,s=((o=document.querySelector(".rhs"))==null?void 0:o.childElementCount)||0;return i<=s?(t.direction=k,k):(t.direction=P,P)}},He=function(e,t){var l,c;if(!e)return null;const n=e.nodeObj;n.expanded===!1&&(this.expandNode(e,!0),e=w(n.id));const o=t||this.generateNewObj();n.children?n.children.push(o):n.children=[o],D(this.nodeData);const i=e.parentElement,{grp:s,top:r}=this.createWrapper(o);if(i.tagName==="ME-PARENT"){if(i.children[1])i.nextSibling.appendChild(s);else{const h=this.createChildren([s]);i.appendChild(ne(!0)),i.insertAdjacentElement("afterend",h)}this.linkDiv(s.offsetParent)}else i.tagName==="ME-ROOT"&&(Pe(this.direction,o)===k?(l=document.querySelector(".lhs"))==null||l.appendChild(s):(c=document.querySelector(".rhs"))==null||c.appendChild(s),this.linkDiv());return{newTop:r,newNodeObj:o}},Be=function(e,t){const n=e.parentNode;if(t===0){const o=n.parentNode.parentNode;o.tagName!=="ME-MAIN"&&o.previousSibling.children[1].remove()}n.parentNode.remove()},ie=function(e){const n=e.parentElement.parentElement.lastElementChild;(n==null?void 0:n.tagName)==="svg"&&(n==null||n.remove())},ze=Object.freeze(Object.defineProperty({__proto__:null,addChild:function(e,t){console.time("addChild");const n=e||this.currentNode;if(!n)return;const o=He.call(this,n,t);if(!o)return;const{newTop:i,newNodeObj:s}=o;this.bus.fire("operation",{name:"addChild",obj:s}),console.timeEnd("addChild"),t||this.editTopic(i.firstChild),this.selectNode(i.firstChild,!0)},beginEdit:function(e){const t=e||this.currentNode;t&&this.editTopic(t)},copyNode:function(e,t){console.time("copyNode");const n=ve(e.nodeObj);me(n);const o=He.call(this,t,n);if(!o)return;const{newNodeObj:i}=o;console.timeEnd("copyNode"),this.bus.fire("operation",{name:"copyNode",obj:i})},insertBefore:function(e,t){const n=e||this.currentNode;if(!n)return;const o=n.nodeObj;if(o.root===!0){this.addChild();return}const i=t||this.generateNewObj();Rt(o,i),D(this.nodeData);const s=n.parentElement;console.time("insertSibling_DOM");const{grp:r,top:l}=this.createWrapper(i);s.parentNode.parentNode.insertBefore(r,s.parentNode),this.linkDiv(r.offsetParent),t||this.editTopic(l.firstChild),this.selectNode(l.firstChild,!0),console.timeEnd("insertSibling_DOM"),this.bus.fire("operation",{name:"insertBefore",obj:i})},insertParent:function(e,t){const n=e||this.currentNode;if(!n)return;ie(n);const o=n.nodeObj;if(o.root===!0)return;const i=t||this.generateNewObj();qt(o,i),D(this.nodeData);const s=n.parentElement.parentElement;console.time("insertParent_DOM");const{grp:r,top:l}=this.createWrapper(i,!0);l.appendChild(ne(!0)),s.insertAdjacentElement("afterend",r);const c=this.createChildren([s]);l.insertAdjacentElement("afterend",c),this.linkDiv(),t||this.editTopic(l.firstChild),this.selectNode(l.firstChild,!0),console.timeEnd("insertParent_DOM"),this.bus.fire("operation",{name:"insertParent",obj:i})},insertSibling:function(e,t){var h,a,u;const n=e||this.currentNode;if(!n)return;const o=n.nodeObj;if(o.root===!0){this.addChild();return}else if(((h=o.parent)==null?void 0:h.root)===!0&&((u=(a=o.parent)==null?void 0:a.children)==null?void 0:u.length)===1){this.addChild(w(o.parent.id));return}const i=t||this.generateNewObj();zt(o,i),D(this.nodeData);const s=n.parentElement;console.time("insertSibling_DOM");const{grp:r,top:l}=this.createWrapper(i);s.parentNode.parentNode.insertBefore(r,s.parentNode.nextSibling),this.linkDiv(r.offsetParent),t||this.editTopic(l.firstChild),this.selectNode(l.firstChild,!0),console.timeEnd("insertSibling_DOM"),this.bus.fire("operation",{name:"insertSibling",obj:i})},moveDownNode:function(e){const t=e||this.currentNode;if(!t)return;const n=t.nodeObj;Bt(n);const o=t.parentNode.parentNode;o.nextSibling?o.nextSibling.insertAdjacentElement("afterend",o):o.parentNode.prepend(o),this.linkDiv(),this.bus.fire("operation",{name:"moveDownNode",obj:n})},moveNode:function(e,t){var l;const n=e.nodeObj,o=t.nodeObj,i=(l=n==null?void 0:n.parent)==null?void 0:l.id;if(o.expanded===!1&&(this.expandNode(t,!0),e=w(n.id),t=w(o.id)),!Je(n,o)){console.warn("Invalid move");return}console.time("moveNode"),Ft(n,o),D(this.nodeData);const s=e.parentElement,r=t.parentElement;if(r.tagName==="ME-PARENT")if(ie(e),r.children[1])r.nextSibling.appendChild(s.parentElement);else{const c=this.createChildren([s.parentElement]);r.appendChild(ne(!0)),r.parentElement.insertBefore(c,r.nextSibling)}else r.tagName==="ME-ROOT"&&(Pe(this.direction,n),r.nextSibling.appendChild(s.parentElement));this.linkDiv(),this.bus.fire("operation",{name:"moveNode",obj:n,toObj:o,originParentId:i}),console.timeEnd("moveNode")},moveNodeAfter:function(e,t){var l;const n=e.nodeObj,o=t.nodeObj,i=(l=n.parent)==null?void 0:l.id;Wt(n,o),D(this.nodeData),ie(e);const s=e.parentElement.parentNode;t.parentElement.parentNode.insertAdjacentElement("afterend",s),this.linkDiv(),this.bus.fire("operation",{name:"moveNodeAfter",obj:n,toObj:o,originParentId:i})},moveNodeBefore:function(e,t){var l;const n=e.nodeObj,o=t.nodeObj,i=(l=n.parent)==null?void 0:l.id;Vt(n,o),D(this.nodeData),ie(e);const s=e.parentElement.parentNode;t.parentElement.parentNode.insertAdjacentElement("beforebegin",s),this.linkDiv(),this.bus.fire("operation",{name:"moveNodeBefore",obj:n,toObj:o,originParentId:i})},moveUpNode:function(e){const t=e||this.currentNode;if(!t)return;const n=t.nodeObj;Ht(n);const o=t.parentNode.parentNode;o.parentNode.insertBefore(o,o.previousSibling),this.linkDiv(),this.bus.fire("operation",{name:"moveUpNode",obj:n})},removeNode:function(e){var r;const t=e||this.currentNode;if(!t)return;const n=t.nodeObj;if(n.root===!0)throw new Error("Can not remove root node");const o=n.parent.children,i=o.findIndex(l=>l===n),s=X(n);if(Be(t,s),o.length!==0){const l=o[i]||o[i-1];this.selectNode(w(l.id))}else this.selectNode(w(n.parent.id));this.linkDiv(),this.bus.fire("operation",{name:"removeNode",obj:n,originIndex:i,originParentId:(r=n==null?void 0:n.parent)==null?void 0:r.id})},removeNodes:function(e){for(const t of e){const n=t.nodeObj;if(n.root===!0)continue;const o=X(n);Be(t,o)}this.linkDiv(),this.bus.fire("operation",{name:"removeNodes",objs:e.map(t=>t.nodeObj)})},reshapeNode:function(e,t){console.log(t);const n=e.nodeObj,o=ve(n);o.style&&t.style&&(t.style=Object.assign(o.style,t.style));const i=Object.assign(n,t);ae(e,i),this.linkDiv(),this.bus.fire("operation",{name:"reshapeNode",obj:i,origin:o})},setNodeTopic:function(e,t){e.text.textContent=t,e.nodeObj.topic=t,this.linkDiv()}},Symbol.toStringTag,{value:"Module"})),Re={create:function(e){return{dom:e,moved:!1,mousedown:!1,handleMouseMove(t){this.mousedown&&(this.moved=!0,this.cb&&this.cb(t.movementX,t.movementY))},handleMouseDown(t){t.button===0&&(this.mousedown=!0)},handleClear(t){this.mousedown=!1},cb:null,init(t,n){this.cb=n,this.handleClear=this.handleClear.bind(this),this.handleMouseMove=this.handleMouseMove.bind(this),this.handleMouseDown=this.handleMouseDown.bind(this),t.addEventListener("mousemove",this.handleMouseMove),t.addEventListener("mouseleave",this.handleClear),t.addEventListener("mouseup",this.handleClear),this.dom.addEventListener("mousedown",this.handleMouseDown)},destory(t){t.removeEventListener("mousemove",this.handleMouseMove),t.removeEventListener("mouseleave",this.handleClear),t.removeEventListener("mouseup",this.handleClear),this.dom.removeEventListener("mousedown",this.handleMouseDown)},clear(){this.moved=!1,this.mousedown=!1}}}};function se(e,t,n){const{offsetLeft:o,offsetTop:i}=V(e.nodes,t),s=t.offsetWidth,r=t.offsetHeight,l=o+s/2,c=i+r/2,h=l+n.x,a=c+n.y;return{w:s,h:r,cx:l,cy:c,ctrlX:h,ctrlY:a}}function K(e){let t,n;const o=(e.cy-e.ctrlY)/(e.ctrlX-e.cx);return o>e.h/e.w||o<-e.h/e.w?e.cy-e.ctrlY<0?(t=e.cx-e.h/2/o,n=e.cy+e.h/2):(t=e.cx+e.h/2/o,n=e.cy-e.h/2):e.cx-e.ctrlX<0?(t=e.cx+e.w/2,n=e.cy-e.w*o/2):(t=e.cx-e.w/2,n=e.cy+e.w*o/2),{x:t,y:n}}const It=function(e,t,n,o){const i=document.createElementNS("http://www.w3.org/2000/svg","text");return C(i,{"text-anchor":"middle",x:t+"",y:n+"",fill:o||"#666"}),i.dataset.type="custom-link",i.innerHTML=e,i},Kt=function(e,t,n,o){if(!e||!t)return;const i=performance.now(),s=se(this,e,n.delta1),r=se(this,t,n.delta2),{x:l,y:c}=K(s),{ctrlX:h,ctrlY:a}=s,{ctrlX:u,ctrlY:d}=r,{x:p,y:g}=K(r),m=ge(u,d,p,g),f=dt(`M ${l} ${c} C ${h} ${a} ${u} ${d} ${p} ${g}`,`M ${m.x1} ${m.y1} L ${p} ${g} L ${m.x2} ${m.y2}`),v=l/8+h*3/8+u*3/8+p/8,y=c/8+a*3/8+d*3/8+g/8,b=It(n.label,v,y,this.theme.cssVar["--color"]);f.appendChild(b),f.linkObj=n,f.dataset.linkid=n.id,this.linkSvgGroup.appendChild(f),o||(this.linkData[n.id]=n,this.currentLink=f,this.showLinkController(n,s,r));const x=performance.now();console.log(`DrawCustomLink Execution time: ${x-i} ms`)},Ut=function(e,t){const n={id:Y(),label:"Custom Link",from:e.nodeObj.id,to:t.nodeObj.id,delta1:{x:0,y:-200},delta2:{x:0,y:-200}};this.drawCustomLink(e,t,n),this.bus.fire("operation",{name:"createCustomLink",obj:n})},Yt=function(e){let t;if(e?t=e:t=this.currentLink,!t)return;this.hideLinkController();const n=t.linkObj.id;delete this.linkData[n],t.remove(),this.bus.fire("operation",{name:"removeCustomLink",obj:{id:n}})},Gt=function(e){this.currentLink=e;const t=e.linkObj,n=w(t.from),o=w(t.to),i=se(this,n,t.delta1),s=se(this,o,t.delta2);this.showLinkController(t,i,s)},Xt=function(){this.currentLink=null,this.hideLinkController()},Jt=function(){this.linkController.style.display="none",this.P2.style.display="none",this.P3.style.display="none"},Qt=function(e,t,n){var u;this.linkController.style.display="initial",this.P2.style.display="initial",this.P3.style.display="initial",this.nodes.appendChild(this.linkController),this.nodes.appendChild(this.P2),this.nodes.appendChild(this.P3);let{x:o,y:i}=K(t),{ctrlX:s,ctrlY:r}=t,{ctrlX:l,ctrlY:c}=n,{x:h,y:a}=K(n);this.P2.style.cssText=`top:${r}px;left:${s}px;`,this.P3.style.cssText=`top:${c}px;left:${l}px;`,C(this.line1,{x1:o+"",y1:i+"",x2:s+"",y2:r+""}),C(this.line2,{x1:l+"",y1:c+"",x2:h+"",y2:a+""}),this.helper1&&(this.helper1.destory(this.map),(u=this.helper2)==null||u.destory(this.map)),this.helper1=Re.create(this.P2),this.helper2=Re.create(this.P3),this.helper1.init(this.map,(d,p)=>{var v;s=s+d/this.scaleVal,r=r+p/this.scaleVal;const g=K({...t,ctrlX:s,ctrlY:r});o=g.x,i=g.y;const m=o/8+s*3/8+l*3/8+h/8,f=i/8+r*3/8+c*3/8+a/8;this.P2.style.top=r+"px",this.P2.style.left=s+"px",(v=this.currentLink)==null||v.children[0].setAttribute("d",`M ${o} ${i} C ${s} ${r} ${l} ${c} ${h} ${a}`),C(this.currentLink.children[2],{x:m+"",y:f+""}),C(this.line1,{x1:o+"",y1:i+"",x2:s+"",y2:r+""}),e.delta1.x=s-t.cx,e.delta1.y=r-t.cy}),this.helper2.init(this.map,(d,p)=>{var y,b;l=l-d/this.scaleVal,c=c-p/this.scaleVal;const g=K({...n,ctrlX:l,ctrlY:c});h=g.x,a=g.y;const m=o/8+s*3/8+l*3/8+h/8,f=i/8+r*3/8+c*3/8+a/8,v=ge(l,c,h,a);this.P3.style.top=c+"px",this.P3.style.left=l+"px",(y=this.currentLink)==null||y.children[0].setAttribute("d",`M ${o} ${i} C ${s} ${r} ${l} ${c} ${h} ${a}`),(b=this.currentLink)==null||b.children[1].setAttribute("d",`M ${v.x1} ${v.y1} L ${h} ${a} L ${v.x2} ${v.y2}`),C(this.currentLink.children[2],{x:m+"",y:f+""}),C(this.line2,{x1:l+"",y1:c+"",x2:h+"",y2:a+""}),e.delta2.x=l-n.cx,e.delta2.y=c-n.cy})};function Zt(){this.linkSvgGroup.innerHTML="";for(const e in this.linkData){const t=this.linkData[e];try{this.drawCustomLink(w(t.from),w(t.to),t,!0)}catch{console.warn("Node may not be expanded")}}this.nodes.appendChild(this.linkSvgGroup)}function en(e){if(console.time("editSummary"),!e)return;const t=e.children[2];console.log(t,e),xe(this,t,n=>{var s;const o=e.linkObj,i=((s=n.textContent)==null?void 0:s.trim())||"";i===""?o.label=origin:o.label=i,n.remove(),i!==origin&&(t.innerHTML=o.label,this.linkDiv(),this.bus.fire("operation",{name:"finishEditCustomLinkLabel",obj:o}))}),console.timeEnd("editSummary")}function tn(){for(const e in this.linkData){const t=this.linkData[e];(!ee(t.from,this.nodeData)||!ee(t.to,this.nodeData))&&delete this.linkData[t.id]}}const nn=Object.freeze(Object.defineProperty({__proto__:null,createLink:Ut,drawCustomLink:Kt,editCutsomLinkLabel:en,hideLinkController:Jt,removeLink:Yt,renderCustomLink:Zt,selectLink:Gt,showLinkController:Qt,tidyCustomLink:tn,unselectLink:Xt},Symbol.toStringTag,{value:"Module"})),on=function(e){var c,h;if(e.length===0)throw new Error("No selected node.");if(e.length===1){const a=e[0].nodeObj,u=e[0].nodeObj.parent;if(!u)throw new Error("Can not select root node.");const d=u.children.findIndex(p=>a===p);return{parent:u.id,start:d,end:d}}let t=0;const n=e.map(a=>{let u=a.nodeObj;const d=[];for(;u.parent;){const p=u.parent,g=p.children,m=g==null?void 0:g.indexOf(u);u=p,d.unshift({node:u,index:m})}return d.length>t&&(t=d.length),d});let o=0;e:for(;o<t;o++){const a=(c=n[0][o])==null?void 0:c.node;for(let u=1;u<n.length;u++)if(((h=n[u][o])==null?void 0:h.node)!==a)break e}if(!o)throw new Error("Can not select root node.");const i=n.map(a=>a[o-1].index).sort(),s=i[0]||0,r=i[i.length-1]||0,l=n[0][o-1].node;if(l.root)throw new Error("Please select nodes in the same main topic.");return{parent:l.id,start:s,end:r}},sn=function(e){const t=document.createElementNS("http://www.w3.org/2000/svg","g");return t.setAttribute("id",e),t},qe=function(e,t){const n=document.createElementNS("http://www.w3.org/2000/svg","path");return C(n,{d:e,stroke:t||"#666",fill:"none","stroke-linecap":"round","stroke-width":"2"}),n},Fe=function(e,t,n,o,i){const s=document.createElementNS("http://www.w3.org/2000/svg","text");return C(s,{"text-anchor":o,x:t+"",y:n+"",fill:i||"#666"}),s.innerHTML=e,s},rn=e=>w(e).parentElement.parentElement,ln=function({parent:e,start:t}){var s,r;const n=w(e),o=n.nodeObj;let i;return o.root===!0?i=(s=w(o.children[t].id).closest("me-main"))==null?void 0:s.className:i=(r=n.closest("me-main"))==null?void 0:r.className,i},Ve=function(e,t){var _;const{id:n,text:o,parent:i,start:s,end:r}=t,l=e.nodes,h=w(i).nodeObj,a=ln(t);let u=1/0,d=0,p=0,g=0;for(let q=s;q<=r;q++){const Q=(_=h.children)==null?void 0:_[q];if(!Q)return console.warn("Child not found"),e.removeSummary(n),null;const F=rn(Q.id),{offsetLeft:le,offsetTop:Ue}=V(l,F);q===s&&(p=Ue),q===r&&(g=Ue+F.offsetHeight),le<u&&(u=le),F.offsetWidth+le>d&&(d=F.offsetWidth+le)}let m,f;const v=p+10,y=g+10,b=(v+y)/2,x=e.theme.cssVar["--color"];a==="lhs"?(m=qe(`M ${u+10} ${v} c -5 0 -10 5 -10 10 L ${u} ${y-10} c 0 5 5 10 10 10 M ${u} ${b} h -10`,x),f=Fe(o,u-20,b+6,"end",x)):(m=qe(`M ${d-10} ${v} c 5 0 10 5 10 10 L ${d} ${y-10} c 0 5 -5 10 -10 10 M ${d} ${b} h 10`,x),f=Fe(o,d+20,b+6,"start",x));const E=sn("s-"+n);return E.appendChild(m),E.appendChild(f),E.summaryObj=t,e.summarySvg.appendChild(E),E},cn=Object.freeze(Object.defineProperty({__proto__:null,createSummary:function(){let e=[];this.currentNode?e=[this.currentNode]:this.currentNodes&&(e=this.currentNodes);const{parent:t,start:n,end:o}=on(e),i={id:Y(),parent:t,start:n,end:o,text:"summary"},s=Ve(this,i);this.summaries.push(i),this.editSummary(s),this.bus.fire("operation",{name:"createSummary",obj:i})},editSummary:function(e){if(console.time("editSummary"),!e)return;const t=e.childNodes[1];xe(this,t,n=>{var s;const o=e.summaryObj,i=((s=n.textContent)==null?void 0:s.trim())||"";i===""?o.text=origin:o.text=i,n.remove(),i!==origin&&(t.innerHTML=o.text,this.linkDiv(),this.bus.fire("operation",{name:"finishEditSummary",obj:o}))}),console.timeEnd("editSummary")},removeSummary:function(e){var n;const t=this.summaries.findIndex(o=>o.id===e);t>-1&&(this.summaries.splice(t,1),(n=document.querySelector("#s-"+e))==null||n.remove()),this.bus.fire("operation",{name:"removeSummary",obj:{id:e}})},renderSummary:function(){this.summarySvg.innerHTML="",this.summaries.forEach(e=>{Ve(this,e)}),this.nodes.insertAdjacentElement("beforeend",this.summarySvg)},selectSummary:function(e){const t=e.children[1].getBBox(),n=6,o=3,i=document.createElementNS("http://www.w3.org/2000/svg","rect");C(i,{x:t.x-n+"",y:t.y-n+"",width:t.width+n*2+"",height:t.height+n*2+"",rx:o+"",stroke:this.theme.cssVar["--selected"]||"#4dc4ff","stroke-width":"2",fill:"none"}),i.classList.add("selected"),e.appendChild(i),this.currentSummary=e},unselectSummary:function(){var e,t;(t=(e=this.currentSummary)==null?void 0:e.querySelector("rect"))==null||t.remove(),this.currentSummary=null}},Symbol.toStringTag,{value:"Module"}));function an(e,t){const n=document.createElementNS("http://www.w3.org/2000/svg","svg");return C(n,{version:"1.1",xmlns:"http://www.w3.org/2000/svg",height:e,width:t}),n}function dn(e,t){return(parseInt(e)-parseInt(t))/2}function hn(e,t,n,o){const i=document.createElementNS("http://www.w3.org/2000/svg","g");let s="";return e.text?s=e.text.textContent:s=e.childNodes[0].textContent,s.split(`
12
- `).forEach((l,c)=>{const h=document.createElementNS("http://www.w3.org/2000/svg","text");C(h,{x:n+parseInt(t.paddingLeft)+"",y:o+parseInt(t.paddingTop)+dn(t.lineHeight,t.fontSize)*(c+1)+parseFloat(t.fontSize)*(c+1)+"","text-anchor":"start","font-family":t.fontFamily,"font-size":`${t.fontSize}`,"font-weight":`${t.fontWeight}`,fill:`${t.color}`}),h.innerHTML=l,i.appendChild(h)}),i}function un(e,t,n,o){let i="";e.text?i=e.text.textContent:i=e.childNodes[0].textContent;const s=document.createElementNS("http://www.w3.org/2000/svg","foreignObject");C(s,{x:n+parseInt(t.paddingLeft)+"",y:o+parseInt(t.paddingTop)+"",width:t.width,height:t.height});const r=document.createElement("div");return C(r,{xmlns:"http://www.w3.org/1999/xhtml",style:`font-family: ${t.fontFamily}; font-size: ${t.fontSize}; font-weight: ${t.fontWeight}; color: ${t.color}; white-space: pre-wrap;`}),r.innerHTML=i,s.appendChild(r),s}function ue(e,t,n=!1){const o=getComputedStyle(t),{offsetLeft:i,offsetTop:s}=V(e.nodes,t),r=document.createElementNS("http://www.w3.org/2000/svg","rect");C(r,{x:i+"",y:s+"",rx:o.borderRadius,ry:o.borderRadius,width:o.width,height:o.height,fill:o.backgroundColor,stroke:o.borderColor,"stroke-width":o.borderWidth});const l=document.createElementNS("http://www.w3.org/2000/svg","g");l.appendChild(r);let c;return n?c=un(t,o,i,s):c=hn(t,o,i,s),l.appendChild(c),l}function fn(e,t){const n=getComputedStyle(t),{offsetLeft:o,offsetTop:i}=V(e.nodes,t),s=document.createElementNS("http://www.w3.org/2000/svg","a"),r=document.createElementNS("http://www.w3.org/2000/svg","text");return C(r,{x:o+"",y:i+parseInt(n.fontSize)+"","text-anchor":"start","font-family":n.fontFamily,"font-size":`${n.fontSize}`,"font-weight":`${n.fontWeight}`,fill:`${n.color}`}),r.innerHTML=t.textContent,s.appendChild(r),s.setAttribute("href",t.href),s}const re=100,pn='<?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">',We=(e,t=!1)=>{var u,d,p;const n=e.nodes,o=n.offsetHeight+re*2,i=n.offsetWidth+re*2,s=an(o+"px",i+"px"),r=document.createElementNS("http://www.w3.org/2000/svg","svg"),l=document.createElementNS("http://www.w3.org/2000/svg","rect");C(l,{x:"0",y:"0",width:`${i}`,height:`${o}`,fill:e.theme.cssVar["--bgcolor"]}),s.appendChild(l),n.querySelectorAll(".subLines").forEach(g=>{const m=g.cloneNode(!0),{offsetLeft:f,offsetTop:v}=V(n,g.parentElement);m.setAttribute("x",`${f}`),m.setAttribute("y",`${v}`),r.appendChild(m)});const c=(u=n.querySelector(".lines"))==null?void 0:u.cloneNode(!0);c&&r.appendChild(c);const h=(d=n.querySelector(".topiclinks"))==null?void 0:d.cloneNode(!0);h&&r.appendChild(h);const a=(p=n.querySelector(".summary"))==null?void 0:p.cloneNode(!0);return a&&r.appendChild(a),n.querySelectorAll("me-tpc").forEach(g=>{r.appendChild(ue(e,g,!t))}),n.querySelectorAll(".tags > span").forEach(g=>{r.appendChild(ue(e,g))}),n.querySelectorAll(".icons > span").forEach(g=>{r.appendChild(ue(e,g))}),n.querySelectorAll(".hyper-link").forEach(g=>{r.appendChild(fn(e,g))}),C(r,{x:re+"",y:re+"",overflow:"visible"}),s.appendChild(r),pn+s.outerHTML};function mn(e){return new Promise((t,n)=>{const o=new FileReader;o.onload=i=>{t(i.target.result)},o.onerror=i=>{n(i)},o.readAsDataURL(e)})}const gn=Object.freeze(Object.defineProperty({__proto__:null,exportPng:async function(e=!1){const t=We(this,e),n=new Blob([t],{type:"image/svg+xml"}),o=await mn(n);return new Promise((i,s)=>{const r=new Image;r.setAttribute("crossOrigin","anonymous"),r.onload=()=>{const l=document.createElement("canvas");l.width=r.width,l.height=r.height,l.getContext("2d").drawImage(r,0,0),l.toBlob(i,"image/png",1)},r.src=o,r.onerror=s})},exportSvg:function(e=!1){const t=We(this,e);return new Blob([t],{type:"image/svg+xml"})}},Symbol.toStringTag,{value:"Module"}));function vn(e,t){return async function(...n){const o=this.before[t];o&&!await o.apply(this,n)||e.apply(this,n)}}const Ie=Object.keys(ze),Ke={};for(let e=0;e<Ie.length;e++){const t=Ie[e];Ke[t]=vn(ze[t],t)}const bn={getObjById:ee,generateNewObj:Xe,layout:et,linkDiv:ht,editTopic:lt,createWrapper:ot,createParent:it,createChildren:st,createTopic:rt,findEle:w,changeTheme:At,...Pt,...Ke,...nn,...cn,...gn,init(e){if(!e||!e.nodeData)return new Error("MindElixir: `data` is required");e.direction!==void 0&&(this.direction=e.direction),this.changeTheme(e.theme||this.theme,!1),this.nodeData=e.nodeData,D(this.nodeData),this.linkData=e.linkData||{},this.summaries=e.summaries||[],this.tidyCustomLink(),this.toolBar&&kt(this),this.keypress&&bt(this),this.editable&&Ot(this),Ye()&&this.mobileMenu?yt(this):this.contextMenu&&mt(this,this.contextMenuOption),this.draggable&&Et(this),this.allowUndo&&Ct(this),this.toCenter(),this.layout(),this.linkDiv()}},J=document;function M({el:e,direction:t,locale:n,draggable:o,editable:i,contextMenu:s,contextMenuOption:r,toolBar:l,keypress:c,mouseSelectionButton:h,before:a,newTopicName:u,allowUndo:d,mainLinkStyle:p,subLinkStyle:g,overflowHidden:m,mobileMenu:f,theme:v}){console.log("ME_version "+M.version,this);let y=null;const b=Object.prototype.toString.call(e);if(b==="[object HTMLDivElement]"?y=e:b==="[object String]"&&(y=document.querySelector(e)),!y)throw new Error("MindElixir: el is not a valid element");y.className+=" mind-elixir",y.innerHTML="",y.style.setProperty("--gap",T+"px"),this.mindElixirBox=y,this.before=a||{},this.locale=n||"en",this.contextMenuOption=r,this.contextMenu=s===void 0?!0:s,this.toolBar=l===void 0?!0:l,this.keypress=c===void 0?!0:c,this.mouseSelectionButton=h||0,this.mobileMenu=f||!1,this.direction=typeof t=="number"?t:1,this.draggable=o===void 0?!0:o,this.newTopicName=u||"new node",this.editable=i===void 0?!0:i,this.allowUndo=d===void 0?!1:d,this.currentNode=null,this.currentLink=null,this.scaleVal=1,this.tempDirection=null,this.mainLinkStyle=p||0,this.subLinkStyle=g||0,this.overflowHidden=m||!1,this.bus=Ze.create(),this.container=J.createElement("div"),this.container.className="map-container";const x=window.matchMedia("(prefers-color-scheme: dark)");this.theme=v||(x.matches?pe:fe);const E=J.createElement("div");E.className="map-canvas",this.map=E,this.map.setAttribute("tabindex","0"),this.container.appendChild(this.map),this.mindElixirBox.appendChild(this.container),this.nodes=J.createElement("me-nodes"),this.nodes.className="main-node-container",this.lines=G("lines"),this.summarySvg=G("summary"),this.linkController=G("linkcontroller"),this.P2=J.createElement("div"),this.P3=J.createElement("div"),this.P2.className=this.P3.className="circle",this.P2.style.display=this.P3.style.display="none",this.line1=ye(),this.line2=ye(),this.linkController.appendChild(this.line1),this.linkController.appendChild(this.line2),this.linkSvgGroup=G("topiclinks"),this.map.appendChild(this.nodes),this.overflowHidden?this.container.style.overflow="hidden":Qe(this)}return M.prototype=bn,M.LEFT=k,M.RIGHT=P,M.SIDE=U,M.THEME=fe,M.DARK_THEME=pe,M.version="3.3.0",M.E=w,M.new=e=>({nodeData:{id:Y(),topic:e||"new topic",root:!0,children:[]},linkData:{}}),M}();
11
+ `,o[s].children&&n(o[s].children||[],i+1)}return n(e.children||[],2),t},getDataString:function(){const e=Ae(this);return JSON.stringify(e,(t,n)=>{if(!(t==="parent"&&typeof n!="string"))return n})},initLeft:function(){this.direction=0,this.refresh()},initRight:function(){this.direction=1,this.refresh()},initSide:function(){this.direction=2,this.refresh()},install:function(e){e(this)},refresh:function(e){e&&(e=JSON.parse(JSON.stringify(e)),this.nodeData=e.nodeData,this.linkData=e.linkData||{},this.summaries=e.summaries||[]),D(this.nodeData),this.layout(),this.linkDiv()},scale:function(e){this.scaleVal=e,this.map.style.transform="scale("+e+")"},selectFirstChild:function(){if(!this.currentNode)return;const e=this.currentNode.parentElement.nextSibling;if(e&&e.firstChild){const t=e.firstChild.firstChild.firstChild;this.selectNode(t)}},selectNextSibling:function(){if(!this.currentNode||this.currentNode.dataset.nodeid==="meroot")return!1;const e=this.currentNode.parentElement.parentElement.nextSibling;let t;if(e)t=e.firstChild.firstChild;else return!1;return this.selectNode(t),!0},selectNode:function(e,t,n){if(e){if(console.time("selectNode"),typeof e=="string"){const o=w(e);return o?this.selectNode(o):void 0}this.currentNode&&(this.currentNode.className=""),e.className="selected",e.scrollIntoView({block:"nearest",inline:"nearest"}),this.currentNode=e,t?this.bus.fire("selectNewNode",e.nodeObj):this.bus.fire("selectNode",e.nodeObj,n),console.timeEnd("selectNode")}},selectNodes:function(e){if(e){console.time("selectNodes");for(const t of e)t.className="selected";this.currentNodes=e,this.bus.fire("selectNodes",e.map(t=>t.nodeObj)),console.timeEnd("selectNodes")}},selectParent:function(){if(!this.currentNode||this.currentNode.dataset.nodeid==="meroot")return;const e=this.currentNode.parentElement.parentElement.parentElement.previousSibling;if(e){const t=e.firstChild;this.selectNode(t)}},selectPrevSibling:function(){if(!this.currentNode||this.currentNode.dataset.nodeid==="meroot")return!1;const e=this.currentNode.parentElement.parentElement.previousSibling;let t;if(e)t=e.firstChild.firstChild;else return!1;return this.selectNode(t),!0},setLocale:function(e){this.locale=e,this.refresh()},toCenter:function(){this.container.scrollTo(1e4-this.container.offsetWidth/2,1e4-this.container.offsetHeight/2)},unselectNode:function(){this.currentNode&&(this.currentNode.className=""),this.currentNode=null,this.bus.fire("unselectNode")},unselectNodes:function(){if(this.currentNodes)for(const e of this.currentNodes)e.classList.remove("selected");this.currentNodes=null,this.bus.fire("unselectNodes")}},Symbol.toStringTag,{value:"Module"})),A=e=>{var o;const t=(o=e.parent)==null?void 0:o.children,n=t.indexOf(e);return{siblings:t,index:n}};function Ht(e){const{siblings:t,index:n}=A(e),o=t[n];n===0?(t[n]=t[t.length-1],t[t.length-1]=o):(t[n]=t[n-1],t[n-1]=o)}function Bt(e){const{siblings:t,index:n}=A(e),o=t[n];n===t.length-1?(t[n]=t[0],t[0]=o):(t[n]=t[n+1],t[n+1]=o)}function X(e){const{siblings:t,index:n}=A(e);return t.splice(n,1),t.length}function zt(e,t){const{siblings:n,index:o}=A(e);n.splice(o+1,0,t)}function Rt(e,t){const{siblings:n,index:o}=A(e);n.splice(o,0,t)}function qt(e,t){const{siblings:n,index:o}=A(e);n[o]=t,t.children=[e]}function Ft(e,t){X(e),t.children?t.children.push(e):t.children=[e]}function Vt(e,t){e.direction!==void 0&&(e.direction=t.direction),X(e);const{siblings:n,index:o}=A(t);n.splice(o,0,e)}function Wt(e,t){e.direction!==void 0&&(e.direction=t.direction),X(e);const{siblings:n,index:o}=A(t);n.splice(o+1,0,e)}const Pe=function(e,t){var n,o;if(e===k)return k;if(e===P)return P;if(e===U){const i=((n=document.querySelector(".lhs"))==null?void 0:n.childElementCount)||0,s=((o=document.querySelector(".rhs"))==null?void 0:o.childElementCount)||0;return i<=s?(t.direction=k,k):(t.direction=P,P)}},He=function(e,t){var l,c;if(!e)return null;const n=e.nodeObj;n.expanded===!1&&(this.expandNode(e,!0),e=w(n.id));const o=t||this.generateNewObj();n.children?n.children.push(o):n.children=[o],D(this.nodeData);const i=e.parentElement,{grp:s,top:r}=this.createWrapper(o);if(i.tagName==="ME-PARENT"){if(i.children[1])i.nextSibling.appendChild(s);else{const h=this.createChildren([s]);i.appendChild(ne(!0)),i.insertAdjacentElement("afterend",h)}this.linkDiv(s.offsetParent)}else i.tagName==="ME-ROOT"&&(Pe(this.direction,o)===k?(l=document.querySelector(".lhs"))==null||l.appendChild(s):(c=document.querySelector(".rhs"))==null||c.appendChild(s),this.linkDiv());return{newTop:r,newNodeObj:o}},Be=function(e,t){const n=e.parentNode;if(t===0){const o=n.parentNode.parentNode;o.tagName!=="ME-MAIN"&&o.previousSibling.children[1].remove()}n.parentNode.remove()},ie=function(e){const n=e.parentElement.parentElement.lastElementChild;(n==null?void 0:n.tagName)==="svg"&&(n==null||n.remove())},ze=Object.freeze(Object.defineProperty({__proto__:null,addChild:function(e,t){console.time("addChild");const n=e||this.currentNode;if(!n)return;const o=He.call(this,n,t);if(!o)return;const{newTop:i,newNodeObj:s}=o;this.bus.fire("operation",{name:"addChild",obj:s}),console.timeEnd("addChild"),t||this.editTopic(i.firstChild),this.selectNode(i.firstChild,!0)},beginEdit:function(e){const t=e||this.currentNode;t&&this.editTopic(t)},copyNode:function(e,t){console.time("copyNode");const n=ve(e.nodeObj);me(n);const o=He.call(this,t,n);if(!o)return;const{newNodeObj:i}=o;console.timeEnd("copyNode"),this.bus.fire("operation",{name:"copyNode",obj:i})},insertBefore:function(e,t){const n=e||this.currentNode;if(!n)return;const o=n.nodeObj;if(o.root===!0){this.addChild();return}const i=t||this.generateNewObj();Rt(o,i),D(this.nodeData);const s=n.parentElement;console.time("insertSibling_DOM");const{grp:r,top:l}=this.createWrapper(i);s.parentNode.parentNode.insertBefore(r,s.parentNode),this.linkDiv(r.offsetParent),t||this.editTopic(l.firstChild),this.selectNode(l.firstChild,!0),console.timeEnd("insertSibling_DOM"),this.bus.fire("operation",{name:"insertBefore",obj:i})},insertParent:function(e,t){const n=e||this.currentNode;if(!n)return;ie(n);const o=n.nodeObj;if(o.root===!0)return;const i=t||this.generateNewObj();qt(o,i),D(this.nodeData);const s=n.parentElement.parentElement;console.time("insertParent_DOM");const{grp:r,top:l}=this.createWrapper(i,!0);l.appendChild(ne(!0)),s.insertAdjacentElement("afterend",r);const c=this.createChildren([s]);l.insertAdjacentElement("afterend",c),this.linkDiv(),t||this.editTopic(l.firstChild),this.selectNode(l.firstChild,!0),console.timeEnd("insertParent_DOM"),this.bus.fire("operation",{name:"insertParent",obj:i})},insertSibling:function(e,t){var h,a,u;const n=e||this.currentNode;if(!n)return;const o=n.nodeObj;if(o.root===!0){this.addChild();return}else if(((h=o.parent)==null?void 0:h.root)===!0&&((u=(a=o.parent)==null?void 0:a.children)==null?void 0:u.length)===1){this.addChild(w(o.parent.id));return}const i=t||this.generateNewObj();zt(o,i),D(this.nodeData);const s=n.parentElement;console.time("insertSibling_DOM");const{grp:r,top:l}=this.createWrapper(i);s.parentNode.parentNode.insertBefore(r,s.parentNode.nextSibling),this.linkDiv(r.offsetParent),t||this.editTopic(l.firstChild),this.selectNode(l.firstChild,!0),console.timeEnd("insertSibling_DOM"),this.bus.fire("operation",{name:"insertSibling",obj:i})},moveDownNode:function(e){const t=e||this.currentNode;if(!t)return;const n=t.nodeObj;Bt(n);const o=t.parentNode.parentNode;o.nextSibling?o.nextSibling.insertAdjacentElement("afterend",o):o.parentNode.prepend(o),this.linkDiv(),this.bus.fire("operation",{name:"moveDownNode",obj:n})},moveNode:function(e,t){var l;const n=e.nodeObj,o=t.nodeObj,i=(l=n==null?void 0:n.parent)==null?void 0:l.id;if(o.expanded===!1&&(this.expandNode(t,!0),e=w(n.id),t=w(o.id)),!Je(n,o)){console.warn("Invalid move");return}console.time("moveNode"),Ft(n,o),D(this.nodeData);const s=e.parentElement,r=t.parentElement;if(r.tagName==="ME-PARENT")if(ie(e),r.children[1])r.nextSibling.appendChild(s.parentElement);else{const c=this.createChildren([s.parentElement]);r.appendChild(ne(!0)),r.parentElement.insertBefore(c,r.nextSibling)}else r.tagName==="ME-ROOT"&&(Pe(this.direction,n),r.nextSibling.appendChild(s.parentElement));this.linkDiv(),this.bus.fire("operation",{name:"moveNode",obj:n,toObj:o,originParentId:i}),console.timeEnd("moveNode")},moveNodeAfter:function(e,t){var l;const n=e.nodeObj,o=t.nodeObj,i=(l=n.parent)==null?void 0:l.id;Wt(n,o),D(this.nodeData),ie(e);const s=e.parentElement.parentNode;t.parentElement.parentNode.insertAdjacentElement("afterend",s),this.linkDiv(),this.bus.fire("operation",{name:"moveNodeAfter",obj:n,toObj:o,originParentId:i})},moveNodeBefore:function(e,t){var l;const n=e.nodeObj,o=t.nodeObj,i=(l=n.parent)==null?void 0:l.id;Vt(n,o),D(this.nodeData),ie(e);const s=e.parentElement.parentNode;t.parentElement.parentNode.insertAdjacentElement("beforebegin",s),this.linkDiv(),this.bus.fire("operation",{name:"moveNodeBefore",obj:n,toObj:o,originParentId:i})},moveUpNode:function(e){const t=e||this.currentNode;if(!t)return;const n=t.nodeObj;Ht(n);const o=t.parentNode.parentNode;o.parentNode.insertBefore(o,o.previousSibling),this.linkDiv(),this.bus.fire("operation",{name:"moveUpNode",obj:n})},removeNode:function(e){var r;const t=e||this.currentNode;if(!t)return;const n=t.nodeObj;if(n.root===!0)throw new Error("Can not remove root node");const o=n.parent.children,i=o.findIndex(l=>l===n),s=X(n);if(Be(t,s),o.length!==0){const l=o[i]||o[i-1];this.selectNode(w(l.id))}else this.selectNode(w(n.parent.id));this.linkDiv(),this.bus.fire("operation",{name:"removeNode",obj:n,originIndex:i,originParentId:(r=n==null?void 0:n.parent)==null?void 0:r.id})},removeNodes:function(e){for(const t of e){const n=t.nodeObj;if(n.root===!0)continue;const o=X(n);Be(t,o)}this.linkDiv(),this.bus.fire("operation",{name:"removeNodes",objs:e.map(t=>t.nodeObj)})},reshapeNode:function(e,t){console.log(t);const n=e.nodeObj,o=ve(n);o.style&&t.style&&(t.style=Object.assign(o.style,t.style));const i=Object.assign(n,t);ae(e,i),this.linkDiv(),this.bus.fire("operation",{name:"reshapeNode",obj:i,origin:o})},setNodeTopic:function(e,t){e.text.textContent=t,e.nodeObj.topic=t,this.linkDiv()}},Symbol.toStringTag,{value:"Module"})),Re={create:function(e){return{dom:e,moved:!1,mousedown:!1,handleMouseMove(t){this.mousedown&&(this.moved=!0,this.cb&&this.cb(t.movementX,t.movementY))},handleMouseDown(t){t.button===0&&(this.mousedown=!0)},handleClear(t){this.mousedown=!1},cb:null,init(t,n){this.cb=n,this.handleClear=this.handleClear.bind(this),this.handleMouseMove=this.handleMouseMove.bind(this),this.handleMouseDown=this.handleMouseDown.bind(this),t.addEventListener("mousemove",this.handleMouseMove),t.addEventListener("mouseleave",this.handleClear),t.addEventListener("mouseup",this.handleClear),this.dom.addEventListener("mousedown",this.handleMouseDown)},destory(t){t.removeEventListener("mousemove",this.handleMouseMove),t.removeEventListener("mouseleave",this.handleClear),t.removeEventListener("mouseup",this.handleClear),this.dom.removeEventListener("mousedown",this.handleMouseDown)},clear(){this.moved=!1,this.mousedown=!1}}}};function se(e,t,n){const{offsetLeft:o,offsetTop:i}=V(e.nodes,t),s=t.offsetWidth,r=t.offsetHeight,l=o+s/2,c=i+r/2,h=l+n.x,a=c+n.y;return{w:s,h:r,cx:l,cy:c,ctrlX:h,ctrlY:a}}function K(e){let t,n;const o=(e.cy-e.ctrlY)/(e.ctrlX-e.cx);return o>e.h/e.w||o<-e.h/e.w?e.cy-e.ctrlY<0?(t=e.cx-e.h/2/o,n=e.cy+e.h/2):(t=e.cx+e.h/2/o,n=e.cy-e.h/2):e.cx-e.ctrlX<0?(t=e.cx+e.w/2,n=e.cy-e.w*o/2):(t=e.cx-e.w/2,n=e.cy+e.w*o/2),{x:t,y:n}}const It=function(e,t,n,o){const i=document.createElementNS("http://www.w3.org/2000/svg","text");return C(i,{"text-anchor":"middle",x:t+"",y:n+"",fill:o||"#666"}),i.dataset.type="custom-link",i.innerHTML=e,i},Kt=function(e,t,n,o){if(!e||!t)return;const i=performance.now(),s=se(this,e,n.delta1),r=se(this,t,n.delta2),{x:l,y:c}=K(s),{ctrlX:h,ctrlY:a}=s,{ctrlX:u,ctrlY:d}=r,{x:p,y:g}=K(r),m=ge(u,d,p,g),f=dt(`M ${l} ${c} C ${h} ${a} ${u} ${d} ${p} ${g}`,`M ${m.x1} ${m.y1} L ${p} ${g} L ${m.x2} ${m.y2}`),v=l/8+h*3/8+u*3/8+p/8,y=c/8+a*3/8+d*3/8+g/8,b=It(n.label,v,y,this.theme.cssVar["--color"]);f.appendChild(b),f.linkObj=n,f.dataset.linkid=n.id,this.linkSvgGroup.appendChild(f),o||(this.linkData[n.id]=n,this.currentLink=f,this.showLinkController(n,s,r));const x=performance.now();console.log(`DrawCustomLink Execution time: ${x-i} ms`)},Ut=function(e,t){const n={id:Y(),label:"Custom Link",from:e.nodeObj.id,to:t.nodeObj.id,delta1:{x:0,y:-200},delta2:{x:0,y:-200}};this.drawCustomLink(e,t,n),this.bus.fire("operation",{name:"createCustomLink",obj:n})},Yt=function(e){let t;if(e?t=e:t=this.currentLink,!t)return;this.hideLinkController();const n=t.linkObj.id;delete this.linkData[n],t.remove(),this.bus.fire("operation",{name:"removeCustomLink",obj:{id:n}})},Gt=function(e){this.currentLink=e;const t=e.linkObj,n=w(t.from),o=w(t.to),i=se(this,n,t.delta1),s=se(this,o,t.delta2);this.showLinkController(t,i,s)},Xt=function(){this.currentLink=null,this.hideLinkController()},Jt=function(){this.linkController.style.display="none",this.P2.style.display="none",this.P3.style.display="none"},Qt=function(e,t,n){var u;this.linkController.style.display="initial",this.P2.style.display="initial",this.P3.style.display="initial",this.nodes.appendChild(this.linkController),this.nodes.appendChild(this.P2),this.nodes.appendChild(this.P3);let{x:o,y:i}=K(t),{ctrlX:s,ctrlY:r}=t,{ctrlX:l,ctrlY:c}=n,{x:h,y:a}=K(n);this.P2.style.cssText=`top:${r}px;left:${s}px;`,this.P3.style.cssText=`top:${c}px;left:${l}px;`,C(this.line1,{x1:o+"",y1:i+"",x2:s+"",y2:r+""}),C(this.line2,{x1:l+"",y1:c+"",x2:h+"",y2:a+""}),this.helper1&&(this.helper1.destory(this.map),(u=this.helper2)==null||u.destory(this.map)),this.helper1=Re.create(this.P2),this.helper2=Re.create(this.P3),this.helper1.init(this.map,(d,p)=>{var v;s=s+d/this.scaleVal,r=r+p/this.scaleVal;const g=K({...t,ctrlX:s,ctrlY:r});o=g.x,i=g.y;const m=o/8+s*3/8+l*3/8+h/8,f=i/8+r*3/8+c*3/8+a/8;this.P2.style.top=r+"px",this.P2.style.left=s+"px",(v=this.currentLink)==null||v.children[0].setAttribute("d",`M ${o} ${i} C ${s} ${r} ${l} ${c} ${h} ${a}`),C(this.currentLink.children[2],{x:m+"",y:f+""}),C(this.line1,{x1:o+"",y1:i+"",x2:s+"",y2:r+""}),e.delta1.x=s-t.cx,e.delta1.y=r-t.cy}),this.helper2.init(this.map,(d,p)=>{var y,b;l=l+d/this.scaleVal,c=c+p/this.scaleVal;const g=K({...n,ctrlX:l,ctrlY:c});h=g.x,a=g.y;const m=o/8+s*3/8+l*3/8+h/8,f=i/8+r*3/8+c*3/8+a/8,v=ge(l,c,h,a);this.P3.style.top=c+"px",this.P3.style.left=l+"px",(y=this.currentLink)==null||y.children[0].setAttribute("d",`M ${o} ${i} C ${s} ${r} ${l} ${c} ${h} ${a}`),(b=this.currentLink)==null||b.children[1].setAttribute("d",`M ${v.x1} ${v.y1} L ${h} ${a} L ${v.x2} ${v.y2}`),C(this.currentLink.children[2],{x:m+"",y:f+""}),C(this.line2,{x1:l+"",y1:c+"",x2:h+"",y2:a+""}),e.delta2.x=l-n.cx,e.delta2.y=c-n.cy})};function Zt(){this.linkSvgGroup.innerHTML="";for(const e in this.linkData){const t=this.linkData[e];try{this.drawCustomLink(w(t.from),w(t.to),t,!0)}catch{console.warn("Node may not be expanded")}}this.nodes.appendChild(this.linkSvgGroup)}function en(e){if(console.time("editSummary"),!e)return;const t=e.children[2];console.log(t,e),xe(this,t,n=>{var s;const o=e.linkObj,i=((s=n.textContent)==null?void 0:s.trim())||"";i===""?o.label=origin:o.label=i,n.remove(),i!==origin&&(t.innerHTML=o.label,this.linkDiv(),this.bus.fire("operation",{name:"finishEditCustomLinkLabel",obj:o}))}),console.timeEnd("editSummary")}function tn(){for(const e in this.linkData){const t=this.linkData[e];(!ee(t.from,this.nodeData)||!ee(t.to,this.nodeData))&&delete this.linkData[t.id]}}const nn=Object.freeze(Object.defineProperty({__proto__:null,createLink:Ut,drawCustomLink:Kt,editCutsomLinkLabel:en,hideLinkController:Jt,removeLink:Yt,renderCustomLink:Zt,selectLink:Gt,showLinkController:Qt,tidyCustomLink:tn,unselectLink:Xt},Symbol.toStringTag,{value:"Module"})),on=function(e){var c,h;if(e.length===0)throw new Error("No selected node.");if(e.length===1){const a=e[0].nodeObj,u=e[0].nodeObj.parent;if(!u)throw new Error("Can not select root node.");const d=u.children.findIndex(p=>a===p);return{parent:u.id,start:d,end:d}}let t=0;const n=e.map(a=>{let u=a.nodeObj;const d=[];for(;u.parent;){const p=u.parent,g=p.children,m=g==null?void 0:g.indexOf(u);u=p,d.unshift({node:u,index:m})}return d.length>t&&(t=d.length),d});let o=0;e:for(;o<t;o++){const a=(c=n[0][o])==null?void 0:c.node;for(let u=1;u<n.length;u++)if(((h=n[u][o])==null?void 0:h.node)!==a)break e}if(!o)throw new Error("Can not select root node.");const i=n.map(a=>a[o-1].index).sort(),s=i[0]||0,r=i[i.length-1]||0,l=n[0][o-1].node;if(l.root)throw new Error("Please select nodes in the same main topic.");return{parent:l.id,start:s,end:r}},sn=function(e){const t=document.createElementNS("http://www.w3.org/2000/svg","g");return t.setAttribute("id",e),t},qe=function(e,t){const n=document.createElementNS("http://www.w3.org/2000/svg","path");return C(n,{d:e,stroke:t||"#666",fill:"none","stroke-linecap":"round","stroke-width":"2"}),n},Fe=function(e,t,n,o,i){const s=document.createElementNS("http://www.w3.org/2000/svg","text");return C(s,{"text-anchor":o,x:t+"",y:n+"",fill:i||"#666"}),s.innerHTML=e,s},rn=e=>w(e).parentElement.parentElement,ln=function({parent:e,start:t}){var s,r;const n=w(e),o=n.nodeObj;let i;return o.root===!0?i=(s=w(o.children[t].id).closest("me-main"))==null?void 0:s.className:i=(r=n.closest("me-main"))==null?void 0:r.className,i},Ve=function(e,t){var _;const{id:n,text:o,parent:i,start:s,end:r}=t,l=e.nodes,h=w(i).nodeObj,a=ln(t);let u=1/0,d=0,p=0,g=0;for(let q=s;q<=r;q++){const Q=(_=h.children)==null?void 0:_[q];if(!Q)return console.warn("Child not found"),e.removeSummary(n),null;const F=rn(Q.id),{offsetLeft:le,offsetTop:Ue}=V(l,F);q===s&&(p=Ue),q===r&&(g=Ue+F.offsetHeight),le<u&&(u=le),F.offsetWidth+le>d&&(d=F.offsetWidth+le)}let m,f;const v=p+10,y=g+10,b=(v+y)/2,x=e.theme.cssVar["--color"];a==="lhs"?(m=qe(`M ${u+10} ${v} c -5 0 -10 5 -10 10 L ${u} ${y-10} c 0 5 5 10 10 10 M ${u} ${b} h -10`,x),f=Fe(o,u-20,b+6,"end",x)):(m=qe(`M ${d-10} ${v} c 5 0 10 5 10 10 L ${d} ${y-10} c 0 5 -5 10 -10 10 M ${d} ${b} h 10`,x),f=Fe(o,d+20,b+6,"start",x));const E=sn("s-"+n);return E.appendChild(m),E.appendChild(f),E.summaryObj=t,e.summarySvg.appendChild(E),E},cn=Object.freeze(Object.defineProperty({__proto__:null,createSummary:function(){let e=[];this.currentNode?e=[this.currentNode]:this.currentNodes&&(e=this.currentNodes);const{parent:t,start:n,end:o}=on(e),i={id:Y(),parent:t,start:n,end:o,text:"summary"},s=Ve(this,i);this.summaries.push(i),this.editSummary(s),this.bus.fire("operation",{name:"createSummary",obj:i})},editSummary:function(e){if(console.time("editSummary"),!e)return;const t=e.childNodes[1];xe(this,t,n=>{var s;const o=e.summaryObj,i=((s=n.textContent)==null?void 0:s.trim())||"";i===""?o.text=origin:o.text=i,n.remove(),i!==origin&&(t.innerHTML=o.text,this.linkDiv(),this.bus.fire("operation",{name:"finishEditSummary",obj:o}))}),console.timeEnd("editSummary")},removeSummary:function(e){var n;const t=this.summaries.findIndex(o=>o.id===e);t>-1&&(this.summaries.splice(t,1),(n=document.querySelector("#s-"+e))==null||n.remove()),this.bus.fire("operation",{name:"removeSummary",obj:{id:e}})},renderSummary:function(){this.summarySvg.innerHTML="",this.summaries.forEach(e=>{try{Ve(this,e)}catch{console.warn("Node may not be expanded")}}),this.nodes.insertAdjacentElement("beforeend",this.summarySvg)},selectSummary:function(e){const t=e.children[1].getBBox(),n=6,o=3,i=document.createElementNS("http://www.w3.org/2000/svg","rect");C(i,{x:t.x-n+"",y:t.y-n+"",width:t.width+n*2+"",height:t.height+n*2+"",rx:o+"",stroke:this.theme.cssVar["--selected"]||"#4dc4ff","stroke-width":"2",fill:"none"}),i.classList.add("selected"),e.appendChild(i),this.currentSummary=e},unselectSummary:function(){var e,t;(t=(e=this.currentSummary)==null?void 0:e.querySelector("rect"))==null||t.remove(),this.currentSummary=null}},Symbol.toStringTag,{value:"Module"}));function an(e,t){const n=document.createElementNS("http://www.w3.org/2000/svg","svg");return C(n,{version:"1.1",xmlns:"http://www.w3.org/2000/svg",height:e,width:t}),n}function dn(e,t){return(parseInt(e)-parseInt(t))/2}function hn(e,t,n,o){const i=document.createElementNS("http://www.w3.org/2000/svg","g");let s="";return e.text?s=e.text.textContent:s=e.childNodes[0].textContent,s.split(`
12
+ `).forEach((l,c)=>{const h=document.createElementNS("http://www.w3.org/2000/svg","text");C(h,{x:n+parseInt(t.paddingLeft)+"",y:o+parseInt(t.paddingTop)+dn(t.lineHeight,t.fontSize)*(c+1)+parseFloat(t.fontSize)*(c+1)+"","text-anchor":"start","font-family":t.fontFamily,"font-size":`${t.fontSize}`,"font-weight":`${t.fontWeight}`,fill:`${t.color}`}),h.innerHTML=l,i.appendChild(h)}),i}function un(e,t,n,o){let i="";e.text?i=e.text.textContent:i=e.childNodes[0].textContent;const s=document.createElementNS("http://www.w3.org/2000/svg","foreignObject");C(s,{x:n+parseInt(t.paddingLeft)+"",y:o+parseInt(t.paddingTop)+"",width:t.width,height:t.height});const r=document.createElement("div");return C(r,{xmlns:"http://www.w3.org/1999/xhtml",style:`font-family: ${t.fontFamily}; font-size: ${t.fontSize}; font-weight: ${t.fontWeight}; color: ${t.color}; white-space: pre-wrap;`}),r.innerHTML=i,s.appendChild(r),s}function ue(e,t,n=!1){const o=getComputedStyle(t),{offsetLeft:i,offsetTop:s}=V(e.nodes,t),r=document.createElementNS("http://www.w3.org/2000/svg","rect");C(r,{x:i+"",y:s+"",rx:o.borderRadius,ry:o.borderRadius,width:o.width,height:o.height,fill:o.backgroundColor,stroke:o.borderColor,"stroke-width":o.borderWidth});const l=document.createElementNS("http://www.w3.org/2000/svg","g");l.appendChild(r);let c;return n?c=un(t,o,i,s):c=hn(t,o,i,s),l.appendChild(c),l}function fn(e,t){const n=getComputedStyle(t),{offsetLeft:o,offsetTop:i}=V(e.nodes,t),s=document.createElementNS("http://www.w3.org/2000/svg","a"),r=document.createElementNS("http://www.w3.org/2000/svg","text");return C(r,{x:o+"",y:i+parseInt(n.fontSize)+"","text-anchor":"start","font-family":n.fontFamily,"font-size":`${n.fontSize}`,"font-weight":`${n.fontWeight}`,fill:`${n.color}`}),r.innerHTML=t.textContent,s.appendChild(r),s.setAttribute("href",t.href),s}const re=100,pn='<?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">',We=(e,t=!1)=>{var u,d,p;const n=e.nodes,o=n.offsetHeight+re*2,i=n.offsetWidth+re*2,s=an(o+"px",i+"px"),r=document.createElementNS("http://www.w3.org/2000/svg","svg"),l=document.createElementNS("http://www.w3.org/2000/svg","rect");C(l,{x:"0",y:"0",width:`${i}`,height:`${o}`,fill:e.theme.cssVar["--bgcolor"]}),s.appendChild(l),n.querySelectorAll(".subLines").forEach(g=>{const m=g.cloneNode(!0),{offsetLeft:f,offsetTop:v}=V(n,g.parentElement);m.setAttribute("x",`${f}`),m.setAttribute("y",`${v}`),r.appendChild(m)});const c=(u=n.querySelector(".lines"))==null?void 0:u.cloneNode(!0);c&&r.appendChild(c);const h=(d=n.querySelector(".topiclinks"))==null?void 0:d.cloneNode(!0);h&&r.appendChild(h);const a=(p=n.querySelector(".summary"))==null?void 0:p.cloneNode(!0);return a&&r.appendChild(a),n.querySelectorAll("me-tpc").forEach(g=>{r.appendChild(ue(e,g,!t))}),n.querySelectorAll(".tags > span").forEach(g=>{r.appendChild(ue(e,g))}),n.querySelectorAll(".icons > span").forEach(g=>{r.appendChild(ue(e,g))}),n.querySelectorAll(".hyper-link").forEach(g=>{r.appendChild(fn(e,g))}),C(r,{x:re+"",y:re+"",overflow:"visible"}),s.appendChild(r),pn+s.outerHTML};function mn(e){return new Promise((t,n)=>{const o=new FileReader;o.onload=i=>{t(i.target.result)},o.onerror=i=>{n(i)},o.readAsDataURL(e)})}const gn=Object.freeze(Object.defineProperty({__proto__:null,exportPng:async function(e=!1){const t=We(this,e),n=new Blob([t],{type:"image/svg+xml"}),o=await mn(n);return new Promise((i,s)=>{const r=new Image;r.setAttribute("crossOrigin","anonymous"),r.onload=()=>{const l=document.createElement("canvas");l.width=r.width,l.height=r.height,l.getContext("2d").drawImage(r,0,0),l.toBlob(i,"image/png",1)},r.src=o,r.onerror=s})},exportSvg:function(e=!1){const t=We(this,e);return new Blob([t],{type:"image/svg+xml"})}},Symbol.toStringTag,{value:"Module"}));function vn(e,t){return async function(...n){const o=this.before[t];o&&!await o.apply(this,n)||e.apply(this,n)}}const Ie=Object.keys(ze),Ke={};for(let e=0;e<Ie.length;e++){const t=Ie[e];Ke[t]=vn(ze[t],t)}const bn={getObjById:ee,generateNewObj:Xe,layout:et,linkDiv:ht,editTopic:lt,createWrapper:ot,createParent:it,createChildren:st,createTopic:rt,findEle:w,changeTheme:At,...Pt,...Ke,...nn,...cn,...gn,init(e){if(!e||!e.nodeData)return new Error("MindElixir: `data` is required");e.direction!==void 0&&(this.direction=e.direction),this.changeTheme(e.theme||this.theme,!1),this.nodeData=e.nodeData,D(this.nodeData),this.linkData=e.linkData||{},this.summaries=e.summaries||[],this.tidyCustomLink(),this.toolBar&&kt(this),this.keypress&&bt(this),this.editable&&Ot(this),Ye()&&this.mobileMenu?yt(this):this.contextMenu&&mt(this,this.contextMenuOption),this.draggable&&Et(this),this.allowUndo&&Ct(this),this.toCenter(),this.layout(),this.linkDiv()}},J=document;function M({el:e,direction:t,locale:n,draggable:o,editable:i,contextMenu:s,contextMenuOption:r,toolBar:l,keypress:c,mouseSelectionButton:h,before:a,newTopicName:u,allowUndo:d,mainLinkStyle:p,subLinkStyle:g,overflowHidden:m,mobileMenu:f,theme:v}){console.log("ME_version "+M.version,this);let y=null;const b=Object.prototype.toString.call(e);if(b==="[object HTMLDivElement]"?y=e:b==="[object String]"&&(y=document.querySelector(e)),!y)throw new Error("MindElixir: el is not a valid element");y.className+=" mind-elixir",y.innerHTML="",y.style.setProperty("--gap",T+"px"),this.mindElixirBox=y,this.before=a||{},this.locale=n||"en",this.contextMenuOption=r,this.contextMenu=s===void 0?!0:s,this.toolBar=l===void 0?!0:l,this.keypress=c===void 0?!0:c,this.mouseSelectionButton=h||0,this.mobileMenu=f||!1,this.direction=typeof t=="number"?t:1,this.draggable=o===void 0?!0:o,this.newTopicName=u||"new node",this.editable=i===void 0?!0:i,this.allowUndo=d===void 0?!1:d,this.currentNode=null,this.currentLink=null,this.scaleVal=1,this.tempDirection=null,this.mainLinkStyle=p||0,this.subLinkStyle=g||0,this.overflowHidden=m||!1,this.bus=Ze.create(),this.container=J.createElement("div"),this.container.className="map-container";const x=window.matchMedia("(prefers-color-scheme: dark)");this.theme=v||(x.matches?pe:fe);const E=J.createElement("div");E.className="map-canvas",this.map=E,this.map.setAttribute("tabindex","0"),this.container.appendChild(this.map),this.mindElixirBox.appendChild(this.container),this.nodes=J.createElement("me-nodes"),this.nodes.className="main-node-container",this.lines=G("lines"),this.summarySvg=G("summary"),this.linkController=G("linkcontroller"),this.P2=J.createElement("div"),this.P3=J.createElement("div"),this.P2.className=this.P3.className="circle",this.P2.style.display=this.P3.style.display="none",this.line1=ye(),this.line2=ye(),this.linkController.appendChild(this.line1),this.linkController.appendChild(this.line2),this.linkSvgGroup=G("topiclinks"),this.map.appendChild(this.nodes),this.overflowHidden?this.container.style.overflow="hidden":Qe(this)}return M.prototype=bn,M.LEFT=k,M.RIGHT=P,M.SIDE=U,M.THEME=fe,M.DARK_THEME=pe,M.version="3.3.2",M.E=w,M.new=e=>({nodeData:{id:Y(),topic:e||"new topic",root:!0,children:[]},linkData:{}}),M}();
@@ -1541,12 +1541,12 @@ function fn(e, t) {
1541
1541
  Q(e), t.children ? t.children.push(e) : t.children = [e];
1542
1542
  }
1543
1543
  function pn(e, t) {
1544
- Q(e);
1544
+ e.direction !== void 0 && (e.direction = t.direction), Q(e);
1545
1545
  const { siblings: n, index: o } = A(t);
1546
1546
  n.splice(o, 0, e);
1547
1547
  }
1548
1548
  function mn(e, t) {
1549
- Q(e);
1549
+ e.direction !== void 0 && (e.direction = t.direction), Q(e);
1550
1550
  const { siblings: n, index: o } = A(t);
1551
1551
  n.splice(o + 1, 0, e);
1552
1552
  }
@@ -1942,7 +1942,7 @@ const Dn = function(e, t, n, o) {
1942
1942
  }), e.delta1.x = s - t.cx, e.delta1.y = r - t.cy;
1943
1943
  }), this.helper2.init(this.map, (d, p) => {
1944
1944
  var y, b;
1945
- l = l - d / this.scaleVal, c = c - p / this.scaleVal;
1945
+ l = l + d / this.scaleVal, c = c + p / this.scaleVal;
1946
1946
  const g = I({ ...n, ctrlX: l, ctrlY: c });
1947
1947
  h = g.x, a = g.y;
1948
1948
  const m = o / 8 + s * 3 / 8 + l * 3 / 8 + h / 8, f = i / 8 + r * 3 / 8 + c * 3 / 8 + a / 8, v = $e(l, c, h, a);
@@ -2116,7 +2116,11 @@ const Vn = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
2116
2116
  (t = (e = this.currentSummary) == null ? void 0 : e.querySelector("rect")) == null || t.remove(), this.currentSummary = null;
2117
2117
  }, Qn = function() {
2118
2118
  this.summarySvg.innerHTML = "", this.summaries.forEach((e) => {
2119
- Ie(this, e);
2119
+ try {
2120
+ Ie(this, e);
2121
+ } catch {
2122
+ console.warn("Node may not be expanded");
2123
+ }
2120
2124
  }), this.nodes.insertAdjacentElement("beforeend", this.summarySvg);
2121
2125
  }, Zn = function(e) {
2122
2126
  if (console.time("editSummary"), !e)
@@ -2344,7 +2348,7 @@ D.RIGHT = z;
2344
2348
  D.SIDE = X;
2345
2349
  D.THEME = Le;
2346
2350
  D.DARK_THEME = Me;
2347
- D.version = "3.3.0";
2351
+ D.version = "3.3.2";
2348
2352
  D.E = N;
2349
2353
  D.new = (e) => ({
2350
2354
  nodeData: {
@@ -6,5 +6,5 @@ var MindElixirLite=function(){"use strict";const Nt="";(function(t){var e,n,i,s,
6
6
  `;function n(i,s){for(let o=0;o<i.length;o++)s<=6?e+="".padStart(s,"#")+" "+i[o].topic+`
7
7
 
8
8
  `:e+="".padStart(s-7," ")+"- "+i[o].topic+`
9
- `,i[o].children&&n(i[o].children||[],s+1)}return n(t.children||[],2),e},getDataString:function(){const t=we(this);return JSON.stringify(t,(e,n)=>{if(!(e==="parent"&&typeof n!="string"))return n})},initLeft:function(){this.direction=0,this.refresh()},initRight:function(){this.direction=1,this.refresh()},initSide:function(){this.direction=2,this.refresh()},install:function(t){t(this)},refresh:function(t){t&&(t=JSON.parse(JSON.stringify(t)),this.nodeData=t.nodeData,this.linkData=t.linkData||{},this.summaries=t.summaries||[]),ee(this.nodeData),this.layout(),this.linkDiv()},scale:function(t){this.scaleVal=t,this.map.style.transform="scale("+t+")"},selectFirstChild:function(){if(!this.currentNode)return;const t=this.currentNode.parentElement.nextSibling;if(t&&t.firstChild){const e=t.firstChild.firstChild.firstChild;this.selectNode(e)}},selectNextSibling:function(){if(!this.currentNode||this.currentNode.dataset.nodeid==="meroot")return!1;const t=this.currentNode.parentElement.parentElement.nextSibling;let e;if(t)e=t.firstChild.firstChild;else return!1;return this.selectNode(e),!0},selectNode:function(t,e,n){if(t){if(console.time("selectNode"),typeof t=="string"){const i=L(t);return i?this.selectNode(i):void 0}this.currentNode&&(this.currentNode.className=""),t.className="selected",t.scrollIntoView({block:"nearest",inline:"nearest"}),this.currentNode=t,e?this.bus.fire("selectNewNode",t.nodeObj):this.bus.fire("selectNode",t.nodeObj,n),console.timeEnd("selectNode")}},selectNodes:function(t){if(t){console.time("selectNodes");for(const e of t)e.className="selected";this.currentNodes=t,this.bus.fire("selectNodes",t.map(e=>e.nodeObj)),console.timeEnd("selectNodes")}},selectParent:function(){if(!this.currentNode||this.currentNode.dataset.nodeid==="meroot")return;const t=this.currentNode.parentElement.parentElement.parentElement.previousSibling;if(t){const e=t.firstChild;this.selectNode(e)}},selectPrevSibling:function(){if(!this.currentNode||this.currentNode.dataset.nodeid==="meroot")return!1;const t=this.currentNode.parentElement.parentElement.previousSibling;let e;if(t)e=t.firstChild.firstChild;else return!1;return this.selectNode(e),!0},setLocale:function(t){this.locale=t,this.refresh()},toCenter:function(){this.container.scrollTo(1e4-this.container.offsetWidth/2,1e4-this.container.offsetHeight/2)},unselectNode:function(){this.currentNode&&(this.currentNode.className=""),this.currentNode=null,this.bus.fire("unselectNode")},unselectNodes:function(){if(this.currentNodes)for(const t of this.currentNodes)t.classList.remove("selected");this.currentNodes=null,this.bus.fire("unselectNodes")}},Symbol.toStringTag,{value:"Module"})),_e={create:function(t){return{dom:t,moved:!1,mousedown:!1,handleMouseMove(e){this.mousedown&&(this.moved=!0,this.cb&&this.cb(e.movementX,e.movementY))},handleMouseDown(e){e.button===0&&(this.mousedown=!0)},handleClear(e){this.mousedown=!1},cb:null,init(e,n){this.cb=n,this.handleClear=this.handleClear.bind(this),this.handleMouseMove=this.handleMouseMove.bind(this),this.handleMouseDown=this.handleMouseDown.bind(this),e.addEventListener("mousemove",this.handleMouseMove),e.addEventListener("mouseleave",this.handleClear),e.addEventListener("mouseup",this.handleClear),this.dom.addEventListener("mousedown",this.handleMouseDown)},destory(e){e.removeEventListener("mousemove",this.handleMouseMove),e.removeEventListener("mouseleave",this.handleClear),e.removeEventListener("mouseup",this.handleClear),this.dom.removeEventListener("mousedown",this.handleMouseDown)},clear(){this.moved=!1,this.mousedown=!1}}}};function G(t,e,n){const{offsetLeft:i,offsetTop:s}=z(t.nodes,e),o=e.offsetWidth,r=e.offsetHeight,l=i+o/2,c=s+r/2,u=l+n.x,h=c+n.y;return{w:o,h:r,cx:l,cy:c,ctrlX:u,ctrlY:h}}function q(t){let e,n;const i=(t.cy-t.ctrlY)/(t.ctrlX-t.cx);return i>t.h/t.w||i<-t.h/t.w?t.cy-t.ctrlY<0?(e=t.cx-t.h/2/i,n=t.cy+t.h/2):(e=t.cx+t.h/2/i,n=t.cy-t.h/2):t.cx-t.ctrlX<0?(e=t.cx+t.w/2,n=t.cy-t.w*i/2):(e=t.cx-t.w/2,n=t.cy+t.w*i/2),{x:e,y:n}}const rt=function(t,e,n,i){const s=document.createElementNS("http://www.w3.org/2000/svg","text");return w(s,{"text-anchor":"middle",x:e+"",y:n+"",fill:i||"#666"}),s.dataset.type="custom-link",s.innerHTML=t,s},lt=function(t,e,n,i){if(!t||!e)return;const s=performance.now(),o=G(this,t,n.delta1),r=G(this,e,n.delta2),{x:l,y:c}=q(o),{ctrlX:u,ctrlY:h}=o,{ctrlX:d,ctrlY:a}=r,{x:f,y:g}=q(r),p=re(d,a,f,g),m=Fe(`M ${l} ${c} C ${u} ${h} ${d} ${a} ${f} ${g}`,`M ${p.x1} ${p.y1} L ${f} ${g} L ${p.x2} ${p.y2}`),v=l/8+u*3/8+d*3/8+f/8,b=c/8+h*3/8+a*3/8+g/8,x=rt(n.label,v,b,this.theme.cssVar["--color"]);m.appendChild(x),m.linkObj=n,m.dataset.linkid=n.id,this.linkSvgGroup.appendChild(m),i||(this.linkData[n.id]=n,this.currentLink=m,this.showLinkController(n,o,r));const E=performance.now();console.log(`DrawCustomLink Execution time: ${E-s} ms`)},ct=function(t,e){const n={id:te(),label:"Custom Link",from:t.nodeObj.id,to:e.nodeObj.id,delta1:{x:0,y:-200},delta2:{x:0,y:-200}};this.drawCustomLink(t,e,n),this.bus.fire("operation",{name:"createCustomLink",obj:n})},at=function(t){let e;if(t?e=t:e=this.currentLink,!e)return;this.hideLinkController();const n=e.linkObj.id;delete this.linkData[n],e.remove(),this.bus.fire("operation",{name:"removeCustomLink",obj:{id:n}})},ht=function(t){this.currentLink=t;const e=t.linkObj,n=L(e.from),i=L(e.to),s=G(this,n,e.delta1),o=G(this,i,e.delta2);this.showLinkController(e,s,o)},dt=function(){this.currentLink=null,this.hideLinkController()},ut=function(){this.linkController.style.display="none",this.P2.style.display="none",this.P3.style.display="none"},ft=function(t,e,n){var d;this.linkController.style.display="initial",this.P2.style.display="initial",this.P3.style.display="initial",this.nodes.appendChild(this.linkController),this.nodes.appendChild(this.P2),this.nodes.appendChild(this.P3);let{x:i,y:s}=q(e),{ctrlX:o,ctrlY:r}=e,{ctrlX:l,ctrlY:c}=n,{x:u,y:h}=q(n);this.P2.style.cssText=`top:${r}px;left:${o}px;`,this.P3.style.cssText=`top:${c}px;left:${l}px;`,w(this.line1,{x1:i+"",y1:s+"",x2:o+"",y2:r+""}),w(this.line2,{x1:l+"",y1:c+"",x2:u+"",y2:h+""}),this.helper1&&(this.helper1.destory(this.map),(d=this.helper2)==null||d.destory(this.map)),this.helper1=_e.create(this.P2),this.helper2=_e.create(this.P3),this.helper1.init(this.map,(a,f)=>{var v;o=o+a/this.scaleVal,r=r+f/this.scaleVal;const g=q({...e,ctrlX:o,ctrlY:r});i=g.x,s=g.y;const p=i/8+o*3/8+l*3/8+u/8,m=s/8+r*3/8+c*3/8+h/8;this.P2.style.top=r+"px",this.P2.style.left=o+"px",(v=this.currentLink)==null||v.children[0].setAttribute("d",`M ${i} ${s} C ${o} ${r} ${l} ${c} ${u} ${h}`),w(this.currentLink.children[2],{x:p+"",y:m+""}),w(this.line1,{x1:i+"",y1:s+"",x2:o+"",y2:r+""}),t.delta1.x=o-e.cx,t.delta1.y=r-e.cy}),this.helper2.init(this.map,(a,f)=>{var b,x;l=l-a/this.scaleVal,c=c-f/this.scaleVal;const g=q({...n,ctrlX:l,ctrlY:c});u=g.x,h=g.y;const p=i/8+o*3/8+l*3/8+u/8,m=s/8+r*3/8+c*3/8+h/8,v=re(l,c,u,h);this.P3.style.top=c+"px",this.P3.style.left=l+"px",(b=this.currentLink)==null||b.children[0].setAttribute("d",`M ${i} ${s} C ${o} ${r} ${l} ${c} ${u} ${h}`),(x=this.currentLink)==null||x.children[1].setAttribute("d",`M ${v.x1} ${v.y1} L ${u} ${h} L ${v.x2} ${v.y2}`),w(this.currentLink.children[2],{x:p+"",y:m+""}),w(this.line2,{x1:l+"",y1:c+"",x2:u+"",y2:h+""}),t.delta2.x=l-n.cx,t.delta2.y=c-n.cy})};function pt(){this.linkSvgGroup.innerHTML="";for(const t in this.linkData){const e=this.linkData[t];try{this.drawCustomLink(L(e.from),L(e.to),e,!0)}catch{console.warn("Node may not be expanded")}}this.nodes.appendChild(this.linkSvgGroup)}function mt(t){if(console.time("editSummary"),!t)return;const e=t.children[2];console.log(e,t),de(this,e,n=>{var o;const i=t.linkObj,s=((o=n.textContent)==null?void 0:o.trim())||"";s===""?i.label=origin:i.label=s,n.remove(),s!==origin&&(e.innerHTML=i.label,this.linkDiv(),this.bus.fire("operation",{name:"finishEditCustomLinkLabel",obj:i}))}),console.timeEnd("editSummary")}function gt(){for(const t in this.linkData){const e=this.linkData[t];(!I(e.from,this.nodeData)||!I(e.to,this.nodeData))&&delete this.linkData[e.id]}}const vt=Object.freeze(Object.defineProperty({__proto__:null,createLink:ct,drawCustomLink:lt,editCutsomLinkLabel:mt,hideLinkController:ut,removeLink:at,renderCustomLink:pt,selectLink:ht,showLinkController:ft,tidyCustomLink:gt,unselectLink:dt},Symbol.toStringTag,{value:"Module"})),yt=function(t){var c,u;if(t.length===0)throw new Error("No selected node.");if(t.length===1){const h=t[0].nodeObj,d=t[0].nodeObj.parent;if(!d)throw new Error("Can not select root node.");const a=d.children.findIndex(f=>h===f);return{parent:d.id,start:a,end:a}}let e=0;const n=t.map(h=>{let d=h.nodeObj;const a=[];for(;d.parent;){const f=d.parent,g=f.children,p=g==null?void 0:g.indexOf(d);d=f,a.unshift({node:d,index:p})}return a.length>e&&(e=a.length),a});let i=0;e:for(;i<e;i++){const h=(c=n[0][i])==null?void 0:c.node;for(let d=1;d<n.length;d++)if(((u=n[d][i])==null?void 0:u.node)!==h)break e}if(!i)throw new Error("Can not select root node.");const s=n.map(h=>h[i-1].index).sort(),o=s[0]||0,r=s[s.length-1]||0,l=n[0][i-1].node;if(l.root)throw new Error("Please select nodes in the same main topic.");return{parent:l.id,start:o,end:r}},bt=function(t){const e=document.createElementNS("http://www.w3.org/2000/svg","g");return e.setAttribute("id",t),e},Ee=function(t,e){const n=document.createElementNS("http://www.w3.org/2000/svg","path");return w(n,{d:t,stroke:e||"#666",fill:"none","stroke-linecap":"round","stroke-width":"2"}),n},Ce=function(t,e,n,i,s){const o=document.createElementNS("http://www.w3.org/2000/svg","text");return w(o,{"text-anchor":i,x:e+"",y:n+"",fill:s||"#666"}),o.innerHTML=t,o},xt=t=>L(t).parentElement.parentElement,wt=function({parent:t,start:e}){var o,r;const n=L(t),i=n.nodeObj;let s;return i.root===!0?s=(o=L(i.children[e].id).closest("me-main"))==null?void 0:o.className:s=(r=n.closest("me-main"))==null?void 0:r.className,s},Le=function(t,e){var K;const{id:n,text:i,parent:s,start:o,end:r}=e,l=t.nodes,u=L(s).nodeObj,h=wt(e);let d=1/0,a=0,f=0,g=0;for(let F=o;F<=r;F++){const ke=(K=u.children)==null?void 0:K[F];if(!ke)return console.warn("Child not found"),t.removeSummary(n),null;const J=xt(ke.id),{offsetLeft:Q,offsetTop:Me}=z(l,J);F===o&&(f=Me),F===r&&(g=Me+J.offsetHeight),Q<d&&(d=Q),J.offsetWidth+Q>a&&(a=J.offsetWidth+Q)}let p,m;const v=f+10,b=g+10,x=(v+b)/2,E=t.theme.cssVar["--color"];h==="lhs"?(p=Ee(`M ${d+10} ${v} c -5 0 -10 5 -10 10 L ${d} ${b-10} c 0 5 5 10 10 10 M ${d} ${x} h -10`,E),m=Ce(i,d-20,x+6,"end",E)):(p=Ee(`M ${a-10} ${v} c 5 0 10 5 10 10 L ${a} ${b-10} c 0 5 -5 10 -10 10 M ${a} ${x} h 10`,E),m=Ce(i,a+20,x+6,"start",E));const C=bt("s-"+n);return C.appendChild(p),C.appendChild(m),C.summaryObj=e,t.summarySvg.appendChild(C),C},_t=Object.freeze(Object.defineProperty({__proto__:null,createSummary:function(){let t=[];this.currentNode?t=[this.currentNode]:this.currentNodes&&(t=this.currentNodes);const{parent:e,start:n,end:i}=yt(t),s={id:te(),parent:e,start:n,end:i,text:"summary"},o=Le(this,s);this.summaries.push(s),this.editSummary(o),this.bus.fire("operation",{name:"createSummary",obj:s})},editSummary:function(t){if(console.time("editSummary"),!t)return;const e=t.childNodes[1];de(this,e,n=>{var o;const i=t.summaryObj,s=((o=n.textContent)==null?void 0:o.trim())||"";s===""?i.text=origin:i.text=s,n.remove(),s!==origin&&(e.innerHTML=i.text,this.linkDiv(),this.bus.fire("operation",{name:"finishEditSummary",obj:i}))}),console.timeEnd("editSummary")},removeSummary:function(t){var n;const e=this.summaries.findIndex(i=>i.id===t);e>-1&&(this.summaries.splice(e,1),(n=document.querySelector("#s-"+t))==null||n.remove()),this.bus.fire("operation",{name:"removeSummary",obj:{id:t}})},renderSummary:function(){this.summarySvg.innerHTML="",this.summaries.forEach(t=>{Le(this,t)}),this.nodes.insertAdjacentElement("beforeend",this.summarySvg)},selectSummary:function(t){const e=t.children[1].getBBox(),n=6,i=3,s=document.createElementNS("http://www.w3.org/2000/svg","rect");w(s,{x:e.x-n+"",y:e.y-n+"",width:e.width+n*2+"",height:e.height+n*2+"",rx:i+"",stroke:this.theme.cssVar["--selected"]||"#4dc4ff","stroke-width":"2",fill:"none"}),s.classList.add("selected"),t.appendChild(s),this.currentSummary=t},unselectSummary:function(){var t,e;(e=(t=this.currentSummary)==null?void 0:t.querySelector("rect"))==null||e.remove(),this.currentSummary=null}},Symbol.toStringTag,{value:"Module"}));function Et(t,e){const n=document.createElementNS("http://www.w3.org/2000/svg","svg");return w(n,{version:"1.1",xmlns:"http://www.w3.org/2000/svg",height:t,width:e}),n}function Ct(t,e){return(parseInt(t)-parseInt(e))/2}function Lt(t,e,n,i){const s=document.createElementNS("http://www.w3.org/2000/svg","g");let o="";return t.text?o=t.text.textContent:o=t.childNodes[0].textContent,o.split(`
10
- `).forEach((l,c)=>{const u=document.createElementNS("http://www.w3.org/2000/svg","text");w(u,{x:n+parseInt(e.paddingLeft)+"",y:i+parseInt(e.paddingTop)+Ct(e.lineHeight,e.fontSize)*(c+1)+parseFloat(e.fontSize)*(c+1)+"","text-anchor":"start","font-family":e.fontFamily,"font-size":`${e.fontSize}`,"font-weight":`${e.fontWeight}`,fill:`${e.color}`}),u.innerHTML=l,s.appendChild(u)}),s}function St(t,e,n,i){let s="";t.text?s=t.text.textContent:s=t.childNodes[0].textContent;const o=document.createElementNS("http://www.w3.org/2000/svg","foreignObject");w(o,{x:n+parseInt(e.paddingLeft)+"",y:i+parseInt(e.paddingTop)+"",width:e.width,height:e.height});const r=document.createElement("div");return w(r,{xmlns:"http://www.w3.org/1999/xhtml",style:`font-family: ${e.fontFamily}; font-size: ${e.fontSize}; font-weight: ${e.fontWeight}; color: ${e.color}; white-space: pre-wrap;`}),r.innerHTML=s,o.appendChild(r),o}function ne(t,e,n=!1){const i=getComputedStyle(e),{offsetLeft:s,offsetTop:o}=z(t.nodes,e),r=document.createElementNS("http://www.w3.org/2000/svg","rect");w(r,{x:s+"",y:o+"",rx:i.borderRadius,ry:i.borderRadius,width:i.width,height:i.height,fill:i.backgroundColor,stroke:i.borderColor,"stroke-width":i.borderWidth});const l=document.createElementNS("http://www.w3.org/2000/svg","g");l.appendChild(r);let c;return n?c=St(e,i,s,o):c=Lt(e,i,s,o),l.appendChild(c),l}function kt(t,e){const n=getComputedStyle(e),{offsetLeft:i,offsetTop:s}=z(t.nodes,e),o=document.createElementNS("http://www.w3.org/2000/svg","a"),r=document.createElementNS("http://www.w3.org/2000/svg","text");return w(r,{x:i+"",y:s+parseInt(n.fontSize)+"","text-anchor":"start","font-family":n.fontFamily,"font-size":`${n.fontSize}`,"font-weight":`${n.fontWeight}`,fill:`${n.color}`}),r.innerHTML=e.textContent,o.appendChild(r),o.setAttribute("href",e.href),o}const U=100,Mt='<?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">',Se=(t,e=!1)=>{var d,a,f;const n=t.nodes,i=n.offsetHeight+U*2,s=n.offsetWidth+U*2,o=Et(i+"px",s+"px"),r=document.createElementNS("http://www.w3.org/2000/svg","svg"),l=document.createElementNS("http://www.w3.org/2000/svg","rect");w(l,{x:"0",y:"0",width:`${s}`,height:`${i}`,fill:t.theme.cssVar["--bgcolor"]}),o.appendChild(l),n.querySelectorAll(".subLines").forEach(g=>{const p=g.cloneNode(!0),{offsetLeft:m,offsetTop:v}=z(n,g.parentElement);p.setAttribute("x",`${m}`),p.setAttribute("y",`${v}`),r.appendChild(p)});const c=(d=n.querySelector(".lines"))==null?void 0:d.cloneNode(!0);c&&r.appendChild(c);const u=(a=n.querySelector(".topiclinks"))==null?void 0:a.cloneNode(!0);u&&r.appendChild(u);const h=(f=n.querySelector(".summary"))==null?void 0:f.cloneNode(!0);return h&&r.appendChild(h),n.querySelectorAll("me-tpc").forEach(g=>{r.appendChild(ne(t,g,!e))}),n.querySelectorAll(".tags > span").forEach(g=>{r.appendChild(ne(t,g))}),n.querySelectorAll(".icons > span").forEach(g=>{r.appendChild(ne(t,g))}),n.querySelectorAll(".hyper-link").forEach(g=>{r.appendChild(kt(t,g))}),w(r,{x:U+"",y:U+"",overflow:"visible"}),o.appendChild(r),Mt+o.outerHTML};function $t(t){return new Promise((e,n)=>{const i=new FileReader;i.onload=s=>{e(s.target.result)},i.onerror=s=>{n(s)},i.readAsDataURL(t)})}const Tt={getObjById:I,generateNewObj:$e,layout:De,linkDiv:We,editTopic:je,createWrapper:Pe,createParent:Be,createChildren:ze,createTopic:Oe,findEle:L,changeTheme:st,...ot,...{},...vt,..._t,...Object.freeze(Object.defineProperty({__proto__:null,exportPng:async function(t=!1){const e=Se(this,t),n=new Blob([e],{type:"image/svg+xml"}),i=await $t(n);return new Promise((s,o)=>{const r=new Image;r.setAttribute("crossOrigin","anonymous"),r.onload=()=>{const l=document.createElement("canvas");l.width=r.width,l.height=r.height,l.getContext("2d").drawImage(r,0,0),l.toBlob(s,"image/png",1)},r.src=i,r.onerror=o})},exportSvg:function(t=!1){const e=Se(this,t);return new Blob([e],{type:"image/svg+xml"})}},Symbol.toStringTag,{value:"Module"})),init(t){if(!t||!t.nodeData)return new Error("MindElixir: `data` is required");t.direction!==void 0&&(this.direction=t.direction),this.changeTheme(t.theme||this.theme,!1),this.nodeData=t.nodeData,ee(this.nodeData),this.linkData=t.linkData||{},this.summaries=t.summaries||[],this.tidyCustomLink(),this.toolBar&&Ke(this),this.toCenter(),this.layout(),this.linkDiv()}},V=document;function M({el:t,direction:e,locale:n,draggable:i,editable:s,contextMenu:o,contextMenuOption:r,toolBar:l,keypress:c,mouseSelectionButton:u,before:h,newTopicName:d,allowUndo:a,mainLinkStyle:f,subLinkStyle:g,overflowHidden:p,mobileMenu:m,theme:v}){console.log("ME_version "+M.version,this);let b=null;const x=Object.prototype.toString.call(t);if(x==="[object HTMLDivElement]"?b=t:x==="[object String]"&&(b=document.querySelector(t)),!b)throw new Error("MindElixir: el is not a valid element");b.className+=" mind-elixir",b.innerHTML="",b.style.setProperty("--gap",S+"px"),this.mindElixirBox=b,this.before=h||{},this.locale=n||"en",this.contextMenuOption=r,this.contextMenu=o===void 0?!0:o,this.toolBar=l===void 0?!0:l,this.keypress=c===void 0?!0:c,this.mouseSelectionButton=u||0,this.mobileMenu=m||!1,this.direction=typeof e=="number"?e:1,this.draggable=i===void 0?!0:i,this.newTopicName=d||"new node",this.editable=s===void 0?!0:s,this.allowUndo=a===void 0?!1:a,this.currentNode=null,this.currentLink=null,this.scaleVal=1,this.tempDirection=null,this.mainLinkStyle=f||0,this.subLinkStyle=g||0,this.overflowHidden=p||!1,this.bus=Ne.create(),this.container=V.createElement("div"),this.container.className="map-container";const E=window.matchMedia("(prefers-color-scheme: dark)");this.theme=v||(E.matches?se:ie);const C=V.createElement("div");C.className="map-canvas",this.map=C,this.map.setAttribute("tabindex","0"),this.container.appendChild(this.map),this.mindElixirBox.appendChild(this.container),this.nodes=V.createElement("me-nodes"),this.nodes.className="main-node-container",this.lines=R("lines"),this.summarySvg=R("summary"),this.linkController=R("linkcontroller"),this.P2=V.createElement("div"),this.P3=V.createElement("div"),this.P2.className=this.P3.className="circle",this.P2.style.display=this.P3.style.display="none",this.line1=he(),this.line2=he(),this.linkController.appendChild(this.line1),this.linkController.appendChild(this.line2),this.linkSvgGroup=R("topiclinks"),this.map.appendChild(this.nodes),this.overflowHidden?this.container.style.overflow="hidden":Te(this)}return M.prototype=Tt,M.LEFT=B,M.RIGHT=Z,M.SIDE=W,M.THEME=ie,M.DARK_THEME=se,M.version="3.3.0",M.E=L,M}();
9
+ `,i[o].children&&n(i[o].children||[],s+1)}return n(t.children||[],2),e},getDataString:function(){const t=we(this);return JSON.stringify(t,(e,n)=>{if(!(e==="parent"&&typeof n!="string"))return n})},initLeft:function(){this.direction=0,this.refresh()},initRight:function(){this.direction=1,this.refresh()},initSide:function(){this.direction=2,this.refresh()},install:function(t){t(this)},refresh:function(t){t&&(t=JSON.parse(JSON.stringify(t)),this.nodeData=t.nodeData,this.linkData=t.linkData||{},this.summaries=t.summaries||[]),ee(this.nodeData),this.layout(),this.linkDiv()},scale:function(t){this.scaleVal=t,this.map.style.transform="scale("+t+")"},selectFirstChild:function(){if(!this.currentNode)return;const t=this.currentNode.parentElement.nextSibling;if(t&&t.firstChild){const e=t.firstChild.firstChild.firstChild;this.selectNode(e)}},selectNextSibling:function(){if(!this.currentNode||this.currentNode.dataset.nodeid==="meroot")return!1;const t=this.currentNode.parentElement.parentElement.nextSibling;let e;if(t)e=t.firstChild.firstChild;else return!1;return this.selectNode(e),!0},selectNode:function(t,e,n){if(t){if(console.time("selectNode"),typeof t=="string"){const i=L(t);return i?this.selectNode(i):void 0}this.currentNode&&(this.currentNode.className=""),t.className="selected",t.scrollIntoView({block:"nearest",inline:"nearest"}),this.currentNode=t,e?this.bus.fire("selectNewNode",t.nodeObj):this.bus.fire("selectNode",t.nodeObj,n),console.timeEnd("selectNode")}},selectNodes:function(t){if(t){console.time("selectNodes");for(const e of t)e.className="selected";this.currentNodes=t,this.bus.fire("selectNodes",t.map(e=>e.nodeObj)),console.timeEnd("selectNodes")}},selectParent:function(){if(!this.currentNode||this.currentNode.dataset.nodeid==="meroot")return;const t=this.currentNode.parentElement.parentElement.parentElement.previousSibling;if(t){const e=t.firstChild;this.selectNode(e)}},selectPrevSibling:function(){if(!this.currentNode||this.currentNode.dataset.nodeid==="meroot")return!1;const t=this.currentNode.parentElement.parentElement.previousSibling;let e;if(t)e=t.firstChild.firstChild;else return!1;return this.selectNode(e),!0},setLocale:function(t){this.locale=t,this.refresh()},toCenter:function(){this.container.scrollTo(1e4-this.container.offsetWidth/2,1e4-this.container.offsetHeight/2)},unselectNode:function(){this.currentNode&&(this.currentNode.className=""),this.currentNode=null,this.bus.fire("unselectNode")},unselectNodes:function(){if(this.currentNodes)for(const t of this.currentNodes)t.classList.remove("selected");this.currentNodes=null,this.bus.fire("unselectNodes")}},Symbol.toStringTag,{value:"Module"})),_e={create:function(t){return{dom:t,moved:!1,mousedown:!1,handleMouseMove(e){this.mousedown&&(this.moved=!0,this.cb&&this.cb(e.movementX,e.movementY))},handleMouseDown(e){e.button===0&&(this.mousedown=!0)},handleClear(e){this.mousedown=!1},cb:null,init(e,n){this.cb=n,this.handleClear=this.handleClear.bind(this),this.handleMouseMove=this.handleMouseMove.bind(this),this.handleMouseDown=this.handleMouseDown.bind(this),e.addEventListener("mousemove",this.handleMouseMove),e.addEventListener("mouseleave",this.handleClear),e.addEventListener("mouseup",this.handleClear),this.dom.addEventListener("mousedown",this.handleMouseDown)},destory(e){e.removeEventListener("mousemove",this.handleMouseMove),e.removeEventListener("mouseleave",this.handleClear),e.removeEventListener("mouseup",this.handleClear),this.dom.removeEventListener("mousedown",this.handleMouseDown)},clear(){this.moved=!1,this.mousedown=!1}}}};function G(t,e,n){const{offsetLeft:i,offsetTop:s}=z(t.nodes,e),o=e.offsetWidth,r=e.offsetHeight,l=i+o/2,c=s+r/2,u=l+n.x,h=c+n.y;return{w:o,h:r,cx:l,cy:c,ctrlX:u,ctrlY:h}}function q(t){let e,n;const i=(t.cy-t.ctrlY)/(t.ctrlX-t.cx);return i>t.h/t.w||i<-t.h/t.w?t.cy-t.ctrlY<0?(e=t.cx-t.h/2/i,n=t.cy+t.h/2):(e=t.cx+t.h/2/i,n=t.cy-t.h/2):t.cx-t.ctrlX<0?(e=t.cx+t.w/2,n=t.cy-t.w*i/2):(e=t.cx-t.w/2,n=t.cy+t.w*i/2),{x:e,y:n}}const rt=function(t,e,n,i){const s=document.createElementNS("http://www.w3.org/2000/svg","text");return w(s,{"text-anchor":"middle",x:e+"",y:n+"",fill:i||"#666"}),s.dataset.type="custom-link",s.innerHTML=t,s},lt=function(t,e,n,i){if(!t||!e)return;const s=performance.now(),o=G(this,t,n.delta1),r=G(this,e,n.delta2),{x:l,y:c}=q(o),{ctrlX:u,ctrlY:h}=o,{ctrlX:d,ctrlY:a}=r,{x:f,y:g}=q(r),p=re(d,a,f,g),m=Fe(`M ${l} ${c} C ${u} ${h} ${d} ${a} ${f} ${g}`,`M ${p.x1} ${p.y1} L ${f} ${g} L ${p.x2} ${p.y2}`),v=l/8+u*3/8+d*3/8+f/8,b=c/8+h*3/8+a*3/8+g/8,x=rt(n.label,v,b,this.theme.cssVar["--color"]);m.appendChild(x),m.linkObj=n,m.dataset.linkid=n.id,this.linkSvgGroup.appendChild(m),i||(this.linkData[n.id]=n,this.currentLink=m,this.showLinkController(n,o,r));const E=performance.now();console.log(`DrawCustomLink Execution time: ${E-s} ms`)},ct=function(t,e){const n={id:te(),label:"Custom Link",from:t.nodeObj.id,to:e.nodeObj.id,delta1:{x:0,y:-200},delta2:{x:0,y:-200}};this.drawCustomLink(t,e,n),this.bus.fire("operation",{name:"createCustomLink",obj:n})},at=function(t){let e;if(t?e=t:e=this.currentLink,!e)return;this.hideLinkController();const n=e.linkObj.id;delete this.linkData[n],e.remove(),this.bus.fire("operation",{name:"removeCustomLink",obj:{id:n}})},ht=function(t){this.currentLink=t;const e=t.linkObj,n=L(e.from),i=L(e.to),s=G(this,n,e.delta1),o=G(this,i,e.delta2);this.showLinkController(e,s,o)},dt=function(){this.currentLink=null,this.hideLinkController()},ut=function(){this.linkController.style.display="none",this.P2.style.display="none",this.P3.style.display="none"},ft=function(t,e,n){var d;this.linkController.style.display="initial",this.P2.style.display="initial",this.P3.style.display="initial",this.nodes.appendChild(this.linkController),this.nodes.appendChild(this.P2),this.nodes.appendChild(this.P3);let{x:i,y:s}=q(e),{ctrlX:o,ctrlY:r}=e,{ctrlX:l,ctrlY:c}=n,{x:u,y:h}=q(n);this.P2.style.cssText=`top:${r}px;left:${o}px;`,this.P3.style.cssText=`top:${c}px;left:${l}px;`,w(this.line1,{x1:i+"",y1:s+"",x2:o+"",y2:r+""}),w(this.line2,{x1:l+"",y1:c+"",x2:u+"",y2:h+""}),this.helper1&&(this.helper1.destory(this.map),(d=this.helper2)==null||d.destory(this.map)),this.helper1=_e.create(this.P2),this.helper2=_e.create(this.P3),this.helper1.init(this.map,(a,f)=>{var v;o=o+a/this.scaleVal,r=r+f/this.scaleVal;const g=q({...e,ctrlX:o,ctrlY:r});i=g.x,s=g.y;const p=i/8+o*3/8+l*3/8+u/8,m=s/8+r*3/8+c*3/8+h/8;this.P2.style.top=r+"px",this.P2.style.left=o+"px",(v=this.currentLink)==null||v.children[0].setAttribute("d",`M ${i} ${s} C ${o} ${r} ${l} ${c} ${u} ${h}`),w(this.currentLink.children[2],{x:p+"",y:m+""}),w(this.line1,{x1:i+"",y1:s+"",x2:o+"",y2:r+""}),t.delta1.x=o-e.cx,t.delta1.y=r-e.cy}),this.helper2.init(this.map,(a,f)=>{var b,x;l=l+a/this.scaleVal,c=c+f/this.scaleVal;const g=q({...n,ctrlX:l,ctrlY:c});u=g.x,h=g.y;const p=i/8+o*3/8+l*3/8+u/8,m=s/8+r*3/8+c*3/8+h/8,v=re(l,c,u,h);this.P3.style.top=c+"px",this.P3.style.left=l+"px",(b=this.currentLink)==null||b.children[0].setAttribute("d",`M ${i} ${s} C ${o} ${r} ${l} ${c} ${u} ${h}`),(x=this.currentLink)==null||x.children[1].setAttribute("d",`M ${v.x1} ${v.y1} L ${u} ${h} L ${v.x2} ${v.y2}`),w(this.currentLink.children[2],{x:p+"",y:m+""}),w(this.line2,{x1:l+"",y1:c+"",x2:u+"",y2:h+""}),t.delta2.x=l-n.cx,t.delta2.y=c-n.cy})};function pt(){this.linkSvgGroup.innerHTML="";for(const t in this.linkData){const e=this.linkData[t];try{this.drawCustomLink(L(e.from),L(e.to),e,!0)}catch{console.warn("Node may not be expanded")}}this.nodes.appendChild(this.linkSvgGroup)}function mt(t){if(console.time("editSummary"),!t)return;const e=t.children[2];console.log(e,t),de(this,e,n=>{var o;const i=t.linkObj,s=((o=n.textContent)==null?void 0:o.trim())||"";s===""?i.label=origin:i.label=s,n.remove(),s!==origin&&(e.innerHTML=i.label,this.linkDiv(),this.bus.fire("operation",{name:"finishEditCustomLinkLabel",obj:i}))}),console.timeEnd("editSummary")}function gt(){for(const t in this.linkData){const e=this.linkData[t];(!I(e.from,this.nodeData)||!I(e.to,this.nodeData))&&delete this.linkData[e.id]}}const vt=Object.freeze(Object.defineProperty({__proto__:null,createLink:ct,drawCustomLink:lt,editCutsomLinkLabel:mt,hideLinkController:ut,removeLink:at,renderCustomLink:pt,selectLink:ht,showLinkController:ft,tidyCustomLink:gt,unselectLink:dt},Symbol.toStringTag,{value:"Module"})),yt=function(t){var c,u;if(t.length===0)throw new Error("No selected node.");if(t.length===1){const h=t[0].nodeObj,d=t[0].nodeObj.parent;if(!d)throw new Error("Can not select root node.");const a=d.children.findIndex(f=>h===f);return{parent:d.id,start:a,end:a}}let e=0;const n=t.map(h=>{let d=h.nodeObj;const a=[];for(;d.parent;){const f=d.parent,g=f.children,p=g==null?void 0:g.indexOf(d);d=f,a.unshift({node:d,index:p})}return a.length>e&&(e=a.length),a});let i=0;e:for(;i<e;i++){const h=(c=n[0][i])==null?void 0:c.node;for(let d=1;d<n.length;d++)if(((u=n[d][i])==null?void 0:u.node)!==h)break e}if(!i)throw new Error("Can not select root node.");const s=n.map(h=>h[i-1].index).sort(),o=s[0]||0,r=s[s.length-1]||0,l=n[0][i-1].node;if(l.root)throw new Error("Please select nodes in the same main topic.");return{parent:l.id,start:o,end:r}},bt=function(t){const e=document.createElementNS("http://www.w3.org/2000/svg","g");return e.setAttribute("id",t),e},Ee=function(t,e){const n=document.createElementNS("http://www.w3.org/2000/svg","path");return w(n,{d:t,stroke:e||"#666",fill:"none","stroke-linecap":"round","stroke-width":"2"}),n},Ce=function(t,e,n,i,s){const o=document.createElementNS("http://www.w3.org/2000/svg","text");return w(o,{"text-anchor":i,x:e+"",y:n+"",fill:s||"#666"}),o.innerHTML=t,o},xt=t=>L(t).parentElement.parentElement,wt=function({parent:t,start:e}){var o,r;const n=L(t),i=n.nodeObj;let s;return i.root===!0?s=(o=L(i.children[e].id).closest("me-main"))==null?void 0:o.className:s=(r=n.closest("me-main"))==null?void 0:r.className,s},Le=function(t,e){var K;const{id:n,text:i,parent:s,start:o,end:r}=e,l=t.nodes,u=L(s).nodeObj,h=wt(e);let d=1/0,a=0,f=0,g=0;for(let F=o;F<=r;F++){const ke=(K=u.children)==null?void 0:K[F];if(!ke)return console.warn("Child not found"),t.removeSummary(n),null;const J=xt(ke.id),{offsetLeft:Q,offsetTop:Me}=z(l,J);F===o&&(f=Me),F===r&&(g=Me+J.offsetHeight),Q<d&&(d=Q),J.offsetWidth+Q>a&&(a=J.offsetWidth+Q)}let p,m;const v=f+10,b=g+10,x=(v+b)/2,E=t.theme.cssVar["--color"];h==="lhs"?(p=Ee(`M ${d+10} ${v} c -5 0 -10 5 -10 10 L ${d} ${b-10} c 0 5 5 10 10 10 M ${d} ${x} h -10`,E),m=Ce(i,d-20,x+6,"end",E)):(p=Ee(`M ${a-10} ${v} c 5 0 10 5 10 10 L ${a} ${b-10} c 0 5 -5 10 -10 10 M ${a} ${x} h 10`,E),m=Ce(i,a+20,x+6,"start",E));const C=bt("s-"+n);return C.appendChild(p),C.appendChild(m),C.summaryObj=e,t.summarySvg.appendChild(C),C},_t=Object.freeze(Object.defineProperty({__proto__:null,createSummary:function(){let t=[];this.currentNode?t=[this.currentNode]:this.currentNodes&&(t=this.currentNodes);const{parent:e,start:n,end:i}=yt(t),s={id:te(),parent:e,start:n,end:i,text:"summary"},o=Le(this,s);this.summaries.push(s),this.editSummary(o),this.bus.fire("operation",{name:"createSummary",obj:s})},editSummary:function(t){if(console.time("editSummary"),!t)return;const e=t.childNodes[1];de(this,e,n=>{var o;const i=t.summaryObj,s=((o=n.textContent)==null?void 0:o.trim())||"";s===""?i.text=origin:i.text=s,n.remove(),s!==origin&&(e.innerHTML=i.text,this.linkDiv(),this.bus.fire("operation",{name:"finishEditSummary",obj:i}))}),console.timeEnd("editSummary")},removeSummary:function(t){var n;const e=this.summaries.findIndex(i=>i.id===t);e>-1&&(this.summaries.splice(e,1),(n=document.querySelector("#s-"+t))==null||n.remove()),this.bus.fire("operation",{name:"removeSummary",obj:{id:t}})},renderSummary:function(){this.summarySvg.innerHTML="",this.summaries.forEach(t=>{try{Le(this,t)}catch{console.warn("Node may not be expanded")}}),this.nodes.insertAdjacentElement("beforeend",this.summarySvg)},selectSummary:function(t){const e=t.children[1].getBBox(),n=6,i=3,s=document.createElementNS("http://www.w3.org/2000/svg","rect");w(s,{x:e.x-n+"",y:e.y-n+"",width:e.width+n*2+"",height:e.height+n*2+"",rx:i+"",stroke:this.theme.cssVar["--selected"]||"#4dc4ff","stroke-width":"2",fill:"none"}),s.classList.add("selected"),t.appendChild(s),this.currentSummary=t},unselectSummary:function(){var t,e;(e=(t=this.currentSummary)==null?void 0:t.querySelector("rect"))==null||e.remove(),this.currentSummary=null}},Symbol.toStringTag,{value:"Module"}));function Et(t,e){const n=document.createElementNS("http://www.w3.org/2000/svg","svg");return w(n,{version:"1.1",xmlns:"http://www.w3.org/2000/svg",height:t,width:e}),n}function Ct(t,e){return(parseInt(t)-parseInt(e))/2}function Lt(t,e,n,i){const s=document.createElementNS("http://www.w3.org/2000/svg","g");let o="";return t.text?o=t.text.textContent:o=t.childNodes[0].textContent,o.split(`
10
+ `).forEach((l,c)=>{const u=document.createElementNS("http://www.w3.org/2000/svg","text");w(u,{x:n+parseInt(e.paddingLeft)+"",y:i+parseInt(e.paddingTop)+Ct(e.lineHeight,e.fontSize)*(c+1)+parseFloat(e.fontSize)*(c+1)+"","text-anchor":"start","font-family":e.fontFamily,"font-size":`${e.fontSize}`,"font-weight":`${e.fontWeight}`,fill:`${e.color}`}),u.innerHTML=l,s.appendChild(u)}),s}function St(t,e,n,i){let s="";t.text?s=t.text.textContent:s=t.childNodes[0].textContent;const o=document.createElementNS("http://www.w3.org/2000/svg","foreignObject");w(o,{x:n+parseInt(e.paddingLeft)+"",y:i+parseInt(e.paddingTop)+"",width:e.width,height:e.height});const r=document.createElement("div");return w(r,{xmlns:"http://www.w3.org/1999/xhtml",style:`font-family: ${e.fontFamily}; font-size: ${e.fontSize}; font-weight: ${e.fontWeight}; color: ${e.color}; white-space: pre-wrap;`}),r.innerHTML=s,o.appendChild(r),o}function ne(t,e,n=!1){const i=getComputedStyle(e),{offsetLeft:s,offsetTop:o}=z(t.nodes,e),r=document.createElementNS("http://www.w3.org/2000/svg","rect");w(r,{x:s+"",y:o+"",rx:i.borderRadius,ry:i.borderRadius,width:i.width,height:i.height,fill:i.backgroundColor,stroke:i.borderColor,"stroke-width":i.borderWidth});const l=document.createElementNS("http://www.w3.org/2000/svg","g");l.appendChild(r);let c;return n?c=St(e,i,s,o):c=Lt(e,i,s,o),l.appendChild(c),l}function kt(t,e){const n=getComputedStyle(e),{offsetLeft:i,offsetTop:s}=z(t.nodes,e),o=document.createElementNS("http://www.w3.org/2000/svg","a"),r=document.createElementNS("http://www.w3.org/2000/svg","text");return w(r,{x:i+"",y:s+parseInt(n.fontSize)+"","text-anchor":"start","font-family":n.fontFamily,"font-size":`${n.fontSize}`,"font-weight":`${n.fontWeight}`,fill:`${n.color}`}),r.innerHTML=e.textContent,o.appendChild(r),o.setAttribute("href",e.href),o}const U=100,Mt='<?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">',Se=(t,e=!1)=>{var d,a,f;const n=t.nodes,i=n.offsetHeight+U*2,s=n.offsetWidth+U*2,o=Et(i+"px",s+"px"),r=document.createElementNS("http://www.w3.org/2000/svg","svg"),l=document.createElementNS("http://www.w3.org/2000/svg","rect");w(l,{x:"0",y:"0",width:`${s}`,height:`${i}`,fill:t.theme.cssVar["--bgcolor"]}),o.appendChild(l),n.querySelectorAll(".subLines").forEach(g=>{const p=g.cloneNode(!0),{offsetLeft:m,offsetTop:v}=z(n,g.parentElement);p.setAttribute("x",`${m}`),p.setAttribute("y",`${v}`),r.appendChild(p)});const c=(d=n.querySelector(".lines"))==null?void 0:d.cloneNode(!0);c&&r.appendChild(c);const u=(a=n.querySelector(".topiclinks"))==null?void 0:a.cloneNode(!0);u&&r.appendChild(u);const h=(f=n.querySelector(".summary"))==null?void 0:f.cloneNode(!0);return h&&r.appendChild(h),n.querySelectorAll("me-tpc").forEach(g=>{r.appendChild(ne(t,g,!e))}),n.querySelectorAll(".tags > span").forEach(g=>{r.appendChild(ne(t,g))}),n.querySelectorAll(".icons > span").forEach(g=>{r.appendChild(ne(t,g))}),n.querySelectorAll(".hyper-link").forEach(g=>{r.appendChild(kt(t,g))}),w(r,{x:U+"",y:U+"",overflow:"visible"}),o.appendChild(r),Mt+o.outerHTML};function $t(t){return new Promise((e,n)=>{const i=new FileReader;i.onload=s=>{e(s.target.result)},i.onerror=s=>{n(s)},i.readAsDataURL(t)})}const Tt={getObjById:I,generateNewObj:$e,layout:De,linkDiv:We,editTopic:je,createWrapper:Pe,createParent:Be,createChildren:ze,createTopic:Oe,findEle:L,changeTheme:st,...ot,...{},...vt,..._t,...Object.freeze(Object.defineProperty({__proto__:null,exportPng:async function(t=!1){const e=Se(this,t),n=new Blob([e],{type:"image/svg+xml"}),i=await $t(n);return new Promise((s,o)=>{const r=new Image;r.setAttribute("crossOrigin","anonymous"),r.onload=()=>{const l=document.createElement("canvas");l.width=r.width,l.height=r.height,l.getContext("2d").drawImage(r,0,0),l.toBlob(s,"image/png",1)},r.src=i,r.onerror=o})},exportSvg:function(t=!1){const e=Se(this,t);return new Blob([e],{type:"image/svg+xml"})}},Symbol.toStringTag,{value:"Module"})),init(t){if(!t||!t.nodeData)return new Error("MindElixir: `data` is required");t.direction!==void 0&&(this.direction=t.direction),this.changeTheme(t.theme||this.theme,!1),this.nodeData=t.nodeData,ee(this.nodeData),this.linkData=t.linkData||{},this.summaries=t.summaries||[],this.tidyCustomLink(),this.toolBar&&Ke(this),this.toCenter(),this.layout(),this.linkDiv()}},V=document;function M({el:t,direction:e,locale:n,draggable:i,editable:s,contextMenu:o,contextMenuOption:r,toolBar:l,keypress:c,mouseSelectionButton:u,before:h,newTopicName:d,allowUndo:a,mainLinkStyle:f,subLinkStyle:g,overflowHidden:p,mobileMenu:m,theme:v}){console.log("ME_version "+M.version,this);let b=null;const x=Object.prototype.toString.call(t);if(x==="[object HTMLDivElement]"?b=t:x==="[object String]"&&(b=document.querySelector(t)),!b)throw new Error("MindElixir: el is not a valid element");b.className+=" mind-elixir",b.innerHTML="",b.style.setProperty("--gap",S+"px"),this.mindElixirBox=b,this.before=h||{},this.locale=n||"en",this.contextMenuOption=r,this.contextMenu=o===void 0?!0:o,this.toolBar=l===void 0?!0:l,this.keypress=c===void 0?!0:c,this.mouseSelectionButton=u||0,this.mobileMenu=m||!1,this.direction=typeof e=="number"?e:1,this.draggable=i===void 0?!0:i,this.newTopicName=d||"new node",this.editable=s===void 0?!0:s,this.allowUndo=a===void 0?!1:a,this.currentNode=null,this.currentLink=null,this.scaleVal=1,this.tempDirection=null,this.mainLinkStyle=f||0,this.subLinkStyle=g||0,this.overflowHidden=p||!1,this.bus=Ne.create(),this.container=V.createElement("div"),this.container.className="map-container";const E=window.matchMedia("(prefers-color-scheme: dark)");this.theme=v||(E.matches?se:ie);const C=V.createElement("div");C.className="map-canvas",this.map=C,this.map.setAttribute("tabindex","0"),this.container.appendChild(this.map),this.mindElixirBox.appendChild(this.container),this.nodes=V.createElement("me-nodes"),this.nodes.className="main-node-container",this.lines=R("lines"),this.summarySvg=R("summary"),this.linkController=R("linkcontroller"),this.P2=V.createElement("div"),this.P3=V.createElement("div"),this.P2.className=this.P3.className="circle",this.P2.style.display=this.P3.style.display="none",this.line1=he(),this.line2=he(),this.linkController.appendChild(this.line1),this.linkController.appendChild(this.line2),this.linkSvgGroup=R("topiclinks"),this.map.appendChild(this.nodes),this.overflowHidden?this.container.style.overflow="hidden":Te(this)}return M.prototype=Tt,M.LEFT=B,M.RIGHT=Z,M.SIDE=W,M.THEME=ie,M.DARK_THEME=se,M.version="3.3.2",M.E=L,M}();
@@ -1173,7 +1173,7 @@ const Nt = function(t, e, n, i) {
1173
1173
  }), t.delta1.x = o - e.cx, t.delta1.y = r - e.cy;
1174
1174
  }), this.helper2.init(this.map, (a, f) => {
1175
1175
  var y, x;
1176
- l = l - a / this.scaleVal, c = c - f / this.scaleVal;
1176
+ l = l + a / this.scaleVal, c = c + f / this.scaleVal;
1177
1177
  const g = O({ ...n, ctrlX: l, ctrlY: c });
1178
1178
  u = g.x, h = g.y;
1179
1179
  const p = i / 8 + o * 3 / 8 + l * 3 / 8 + u / 8, m = s / 8 + r * 3 / 8 + c * 3 / 8 + h / 8, v = ye(l, c, u, h);
@@ -1347,7 +1347,11 @@ const Rt = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
1347
1347
  (e = (t = this.currentSummary) == null ? void 0 : t.querySelector("rect")) == null || e.remove(), this.currentSummary = null;
1348
1348
  }, Jt = function() {
1349
1349
  this.summarySvg.innerHTML = "", this.summaries.forEach((t) => {
1350
- ke(this, t);
1350
+ try {
1351
+ ke(this, t);
1352
+ } catch {
1353
+ console.warn("Node may not be expanded");
1354
+ }
1351
1355
  }), this.nodes.insertAdjacentElement("beforeend", this.summarySvg);
1352
1356
  }, Qt = function(t) {
1353
1357
  if (console.time("editSummary"), !t)
@@ -1563,7 +1567,7 @@ M.RIGHT = ee;
1563
1567
  M.SIDE = Q;
1564
1568
  M.THEME = ge;
1565
1569
  M.DARK_THEME = ve;
1566
- M.version = "3.3.0";
1570
+ M.version = "3.3.2";
1567
1571
  M.E = L;
1568
1572
  export {
1569
1573
  M as default
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "mind-elixir",
3
- "version": "3.3.0",
3
+ "version": "3.3.2",
4
4
  "type": "module",
5
5
  "description": "Mind elixir is a free open source mind map core.",
6
6
  "keywords": [