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