mind-elixir 4.4.3 → 4.5.0

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.
@@ -14,10 +14,10 @@ var MindElixir=function(){"use strict";const On="";(function(e){var t,n,o,i,s,r,
14
14
  margin: -2px -4px;
15
15
  `,o.focus(),Ne(o),o.addEventListener("keydown",r=>{r.stopPropagation();const c=r.key;if(c==="Enter"||c==="Tab"){if(r.shiftKey)return;r.preventDefault(),o.blur(),e.map.focus()}}),o.addEventListener("blur",()=>{o&&n(o)})},mt=function(e){const t=this.map.querySelector("me-root"),n=t.offsetTop,o=t.offsetLeft,i=t.offsetWidth,s=t.offsetHeight,c=this.map.querySelector("me-nodes").offsetWidth;this.nodes.style.top=`${1e4-this.nodes.offsetHeight/2}px`,this.alignment==="root"?this.nodes.style.left=`${1e4-o-i/2}px`:this.nodes.style.left=`${1e4-c/2}px`;const l=this.map.querySelectorAll("me-main > me-wrapper");this.lines.innerHTML="";for(let d=0;d<l.length;d++){const a=l[d],u=a.querySelector("me-tpc"),{offsetLeft:h,offsetTop:p}=P(this.nodes,u),g=u.offsetWidth,v=u.offsetHeight,m=a.parentNode.className,f=this.generateMainBranch({pT:n,pL:o,pW:i,pH:s,cT:p,cL:h,cW:g,cH:v,direction:m,containerHeight:this.nodes.offsetHeight}),b=this.theme.palette,x=u.nodeObj.branchColor||b[d%b.length];u.style.borderColor=x,this.lines.appendChild(Ce(f,x,"3"));const N=a.children[0].children[1];if(N&&(N.style.top=(N.parentNode.offsetHeight-N.offsetHeight)/2+"px",m===L.LHS?N.style.left="-10px":N.style.right="-10px"),e&&e!==a)continue;const y=G("subLines"),w=a.lastChild;w.tagName==="svg"&&w.remove(),a.appendChild(y),Le(this,y,x,a,m,!0)}this.renderArrow(),this.renderSummary(),this.bus.fire("linkDiv")},Le=function(e,t,n,o,i,s){const r=o.firstChild,c=o.children[1].children;if(c.length===0)return;const l=r.offsetTop,d=r.offsetLeft,a=r.offsetWidth,u=r.offsetHeight;for(let h=0;h<c.length;h++){const p=c[h],g=p.firstChild,v=g.offsetTop,m=g.offsetLeft,f=g.offsetWidth,b=g.offsetHeight,x=g.firstChild.nodeObj.branchColor||n,N=e.generateSubBranch({pT:l,pL:d,pW:a,pH:u,cT:v,cL:m,cW:f,cH:b,direction:i,isFirst:s});t.appendChild(Ce(N,x,"2"));const y=g.children[1];if(y){if(y.style.bottom=-(y.offsetHeight/2)+"px",i===L.LHS?y.style.left="10px":i===L.RHS&&(y.style.right="10px"),!y.expanded)continue}else continue;Le(e,t,x,p,i)}},Me={addChild:"插入子节点",addParent:"插入父节点",addSibling:"插入同级节点",removeNode:"删除节点",focus:"专注",cancelFocus:"取消专注",moveUp:"上移",moveDown:"下移",link:"连接",clickTips:"请点击目标节点",summary:"摘要"},ke={cn:Me,zh_CN:Me,zh_TW:{addChild:"插入子節點",addParent:"插入父節點",addSibling:"插入同級節點",removeNode:"刪除節點",focus:"專注",cancelFocus:"取消專注",moveUp:"上移",moveDown:"下移",link:"連接",clickTips:"請點擊目標節點",summary:"摘要"},en:{addChild:"Add child",addParent:"Add parent",addSibling:"Add sibling",removeNode:"Remove node",focus:"Focus Mode",cancelFocus:"Cancel Focus Mode",moveUp:"Move up",moveDown:"Move down",link:"Link",clickTips:"Please click the target node",summary:"Summary"},ru:{addChild:"Добавить дочерний элемент",addParent:"Добавить родительский элемент",addSibling:"Добавить на этом уровне",removeNode:"Удалить узел",focus:"Режим фокусировки",cancelFocus:"Отменить режим фокусировки",moveUp:"Поднять выше",moveDown:"Опустить ниже",link:"Ссылка",clickTips:"Пожалуйста, нажмите на целевой узел",summary:"Описание"},ja:{addChild:"子ノードを追加する",addParent:"親ノードを追加します",addSibling:"兄弟ノードを追加する",removeNode:"ノードを削除",focus:"集中",cancelFocus:"集中解除",moveUp:"上へ移動",moveDown:"下へ移動",link:"コネクト",clickTips:"ターゲットノードをクリックしてください",summary:"概要"},pt:{addChild:"Adicionar item filho",addParent:"Adicionar item pai",addSibling:"Adicionar item irmao",removeNode:"Remover item",focus:"Modo Foco",cancelFocus:"Cancelar Modo Foco",moveUp:"Mover para cima",moveDown:"Mover para baixo",link:"Link",clickTips:"Favor clicar no item alvo",summary:"Resumo"},it:{addChild:"Aggiungi figlio",addParent:"Aggiungi genitore",addSibling:"Aggiungi fratello",removeNode:"Rimuovi nodo",focus:"Modalità Focus",cancelFocus:"Annulla Modalità Focus",moveUp:"Sposta su",moveDown:"Sposta giù",link:"Collega",clickTips:"Si prega di fare clic sul nodo di destinazione",summary:"Unisci nodi"},es:{addChild:"Agregar hijo",addParent:"Agregar padre",addSibling:"Agregar hermano",removeNode:"Eliminar nodo",focus:"Modo Enfoque",cancelFocus:"Cancelar Modo Enfoque",moveUp:"Mover hacia arriba",moveDown:"Mover hacia abajo",link:"Enlace",clickTips:"Por favor haga clic en el nodo de destino",summary:"Resumen"},fr:{addChild:"Ajout enfant",addParent:"Ajout parent",addSibling:"Ajout voisin",removeNode:"Supprimer",focus:"Cibler",cancelFocus:"Retour",moveUp:"Monter",moveDown:"Descendre",link:"Lier",clickTips:"Cliquer sur le noeud cible",summary:"Annoter"},ko:{addChild:"자식 추가",addParent:"부모 추가",addSibling:"형제 추가",removeNode:"노드 삭제",focus:"포커스 모드",cancelFocus:"포커스 모드 취소",moveUp:"위로 이동",moveDown:"아래로 이동",link:"연결",clickTips:"대상 노드를 클릭하십시오",summary:"요약"}},Hn="";function gt(e,t){const n=y=>{const w=document.createElement("div");return w.innerText=y,w.className="tips",w},o=(y,w,_)=>{const A=document.createElement("li");return A.id=y,A.innerHTML=`<span>${te(w)}</span><span ${_?'class="key"':""}>${te(_)}</span>`,A},i=ke[e.locale]?e.locale:"en",s=ke[i],r=o("cm-add_child",s.addChild,"Tab"),c=o("cm-add_parent",s.addParent,"Ctrl + Enter"),l=o("cm-add_sibling",s.addSibling,"Enter"),d=o("cm-remove_child",s.removeNode,"Delete"),a=o("cm-fucus",s.focus,""),u=o("cm-unfucus",s.cancelFocus,""),h=o("cm-up",s.moveUp,"PgUp"),p=o("cm-down",s.moveDown,"Pgdn"),g=o("cm-link",s.link,""),v=o("cm-link-bidirectional","Bidreactional Link",""),m=o("cm-summary",s.summary,""),f=document.createElement("ul");if(f.className="menu-list",f.appendChild(r),f.appendChild(c),f.appendChild(l),f.appendChild(d),(!t||t.focus)&&(f.appendChild(a),f.appendChild(u)),f.appendChild(h),f.appendChild(p),f.appendChild(m),(!t||t.link)&&(f.appendChild(g),f.appendChild(v)),t&&t.extend)for(let y=0;y<t.extend.length;y++){const w=t.extend[y],_=o(w.name,w.name,w.key||"");f.appendChild(_),_.onclick=A=>{w.onclick(A)}}const b=document.createElement("div");b.className="context-menu",b.appendChild(f),b.hidden=!0,e.container.append(b);let x=!0;e.container.oncontextmenu=function(y){if(y.preventDefault(),!e.editable||M.moved)return;const w=y.target;if(fe(w)){w.parentElement.tagName==="ME-ROOT"?x=!0:x=!1,x?(a.className="disabled",h.className="disabled",p.className="disabled",c.className="disabled",l.className="disabled",d.className="disabled"):(a.className="",h.className="",p.className="",c.className="",l.className="",d.className=""),e.currentNodes||e.selectNode(w),b.hidden=!1,M.mousedown&&(M.mousedown=!1),f.style.top="",f.style.bottom="",f.style.left="",f.style.right="";const _=f.getBoundingClientRect(),A=f.offsetHeight,D=f.offsetWidth,q=y.clientY-_.top,Q=y.clientX-_.left;A+q>window.innerHeight?(f.style.top="",f.style.bottom="0px"):(f.style.bottom="",f.style.top=q+15+"px"),D+Q>window.innerWidth?(f.style.left="",f.style.right="0px"):(f.style.right="",f.style.left=Q+10+"px")}},b.onclick=y=>{y.target===b&&(b.hidden=!0)},r.onclick=()=>{e.addChild(),b.hidden=!0},c.onclick=()=>{e.insertParent(),b.hidden=!0},l.onclick=()=>{x||(e.insertSibling("after"),b.hidden=!0)},d.onclick=()=>{x||(e.removeNode(),b.hidden=!0)},a.onclick=()=>{x||(e.focusNode(e.currentNode),b.hidden=!0)},u.onclick=()=>{e.cancelFocus(),b.hidden=!0},h.onclick=()=>{x||(e.moveUpNode(),b.hidden=!0)},p.onclick=()=>{x||(e.moveDownNode(),b.hidden=!0)};const N=y=>{b.hidden=!0;const w=e.currentNode,_=n(s.clickTips);e.container.appendChild(_),e.map.addEventListener("click",A=>{A.preventDefault(),_.remove();const D=A.target;(D.parentElement.tagName==="ME-PARENT"||D.parentElement.tagName==="ME-ROOT")&&e.createArrow(w,D,y)},{once:!0})};return g.onclick=()=>N(),v.onclick=()=>N({bidirectional:!0}),m.onclick=()=>{b.hidden=!0,e.createSummary(),e.unselectNodes()},()=>{r.onclick=null,c.onclick=null,l.onclick=null,d.onclick=null,a.onclick=null,u.onclick=null,h.onclick=null,p.onclick=null,g.onclick=null,m.onclick=null,b.onclick=null,e.container.oncontextmenu=null}}const vt=e=>{const t=e.map.querySelectorAll(".lhs>me-wrapper>me-parent>me-tpc");e.selectNode(t[Math.ceil(t.length/2)-1])},bt=e=>{const t=e.map.querySelectorAll(".rhs>me-wrapper>me-parent>me-tpc");e.selectNode(t[Math.ceil(t.length/2)-1])},yt=e=>{e.selectNode(e.map.querySelector("me-root>me-tpc"))},xt=function(e,t){const n=t.parentElement.parentElement.parentElement.previousSibling;if(n){const o=n.firstChild;e.selectNode(o)}},wt=function(e,t){const n=t.parentElement.nextSibling;if(n&&n.firstChild){const o=n.firstChild.firstChild.firstChild;e.selectNode(o)}},Te=function(e,t){var s,r;const n=e.currentNode||((s=e.currentNodes)==null?void 0:s[0]);if(!n)return;const o=n.nodeObj,i=n.offsetParent.offsetParent.parentElement;o.parent?i.className===t?wt(e,n):(r=o.parent)!=null&&r.parent?xt(e,n):yt(e):t===L.LHS?vt(e):bt(e)},Ae=function(e,t){var r;const n=e.currentNode||((r=e.currentNodes)==null?void 0:r[0]);if(!n||!n.nodeObj.parent)return;const i=t+"Sibling",s=n.parentElement.parentElement[i];s&&e.selectNode(s.firstChild.firstChild)},re=function(e,t,n=1){switch(t){case"in":if(e.scaleVal*n>1.6)return;e.scale(e.scaleVal+=.2);break;case"out":if(e.scaleVal*n<.6)return;e.scale(e.scaleVal-=.2)}};function Et(e){const t=()=>{e.currentArrow?e.removeArrow():e.currentSummary?e.removeSummary(e.currentSummary.summaryObj.id):e.currentNode?e.removeNode():e.currentNodes&&e.removeNodes(e.currentNodes)},n={Enter:o=>{o.shiftKey?e.insertSibling("before"):o.ctrlKey?e.insertParent():e.insertSibling("after")},Tab:()=>{e.addChild()},F1:()=>{e.toCenter()},F2:()=>{e.beginEdit()},ArrowUp:o=>{if(o.altKey)e.moveUpNode();else{if(o.metaKey||o.ctrlKey)return e.initSide();Ae(e,"previous")}},ArrowDown:o=>{o.altKey?e.moveDownNode():Ae(e,"next")},ArrowLeft:o=>{if(o.metaKey||o.ctrlKey)return e.initLeft();Te(e,L.LHS)},ArrowRight:o=>{if(o.metaKey||o.ctrlKey)return e.initRight();Te(e,L.RHS)},PageUp:()=>e.moveUpNode(),PageDown:()=>{e.moveDownNode()},c:o=>{(o.metaKey||o.ctrlKey)&&(e.currentNode?e.waitCopy=[e.currentNode]:e.currentNodes&&(e.waitCopy=e.currentNodes))},x:o=>{(o.metaKey||o.ctrlKey)&&(e.currentNode?e.waitCopy=[e.currentNode]:e.currentNodes&&(e.waitCopy=e.currentNodes),t())},v:o=>{!e.waitCopy||!e.currentNode||(o.metaKey||o.ctrlKey)&&(e.waitCopy.length===1?e.copyNode(e.waitCopy[0],e.currentNode):e.copyNodes(e.waitCopy,e.currentNode))},"+":o=>{(o.metaKey||o.ctrlKey)&&re(e,"in")},"-":o=>{(o.metaKey||o.ctrlKey)&&re(e,"out")},0:o=>{(o.metaKey||o.ctrlKey)&&e.scale(1)},Delete:t,Backspace:t};e.map.onkeydown=o=>{if(o.preventDefault(),!e.editable||o.target!==o.currentTarget)return;const i=n[o.key];i&&i(o)},e.map.onwheel=o=>{if(o.ctrlKey||o.metaKey){o.preventDefault();const i=Math.abs(o.deltaY/100);o.deltaY<0?re(e,"in",i):e.scaleVal-.2>0&&re(e,"out",i),o.stopPropagation()}}}const ge=document,Nt=function(e,t){if(!t)return ve(e),e;let n=e.querySelector(".insert-preview");const o=`insert-preview ${t} show`;return n||(n=ge.createElement("div"),e.appendChild(n)),n.className=o,e},ve=function(e){if(!e)return;const t=e.querySelectorAll(".insert-preview");for(const n of t||[])n.remove()},$e=function(e,t){for(const n of t){const o=n.parentElement.parentElement.contains(e);if(!(e&&e.tagName==="ME-TPC"&&e!==n&&!o&&e.nodeObj.parent))return!1}return!0},Ct=function(e){const t=document.createElement("div");return t.className="mind-elixir-ghost",e.map.appendChild(t),t};function St(e){let t=null,n=null,o=null;const i=Ct(e),s=12;e.map.addEventListener("dragstart",r=>{var l,d;const c=r.target;if((c==null?void 0:c.tagName)!=="ME-TPC"){r.preventDefault();return}(l=e.currentNodes)!=null&&l.includes(c)||(e.unselectNodes(),e.selectNode(c)),e.currentNodes?(t=e.currentNodes,i.innerHTML=e.currentNodes.length+" nodes"):(t=[c],i.innerHTML=c.innerHTML);for(const a of t)a.parentElement.parentElement.style.opacity="0.5";(d=r.dataTransfer)==null||d.setDragImage(i,0,0),M.clear()}),e.map.addEventListener("dragend",async r=>{if(!t)return;for(const l of t)l.parentElement.parentElement.style.opacity="1";const c=r.target;c.style.opacity="",o&&(ve(o),n==="before"?e.moveNodeBefore(t,o):n==="after"?e.moveNodeAfter(t,o):n==="in"&&e.moveNodeIn(t,o),t=null)}),e.map.addEventListener("dragover",nt(function(r){if(!t)return;ve(o);const c=ge.elementFromPoint(r.clientX,r.clientY-s);if($e(c,t)){o=c;const l=c.getBoundingClientRect().y;r.clientY>l+c.clientHeight?n="after":n="in"}else{const l=ge.elementFromPoint(r.clientX,r.clientY+s);if($e(l,t)){o=l;const d=l.getBoundingClientRect().y;r.clientY<d?n="before":n="in"}else n=o=null}o&&Nt(o,n)},100))}const _t=function(e){return["createSummary","removeSummary","finishEditSummary"].includes(e.name)?{type:"summary",value:e.obj.id}:["createArrow","removeArrow","finishEditArrowLabel"].includes(e.name)?{type:"arrow",value:e.obj.id}:["removeNodes","copyNodes","moveNodeBefore","moveNodeAfter","moveNodeIn"].includes(e.name)?{type:"nodes",value:e.objs.map(t=>t.id)}:{type:"node",value:e.obj.id}};function Lt(e){let t=[],n=-1,o=e.getData();e.bus.addListener("operation",i=>{if(i.name==="beginEdit")return;t=t.slice(0,n+1);const s=e.getData();t.push({prev:o,currentObject:_t(i),next:s}),o=s,n=t.length-1}),e.undo=function(){if(n>-1){const i=t[n];o=i.prev,e.refresh(i.prev);try{i.currentObject.type==="node"?e.selectNode(S(i.currentObject.value)):i.currentObject.type==="nodes"&&e.selectNodes(i.currentObject.value.map(s=>S(s)))}catch{}finally{n--}}},e.redo=function(){if(n<t.length-1){n++;const i=t[n];o=i.next,e.refresh(i.next),i.currentObject.type==="node"?e.selectNode(S(i.currentObject.value)):i.currentObject.type==="nodes"&&e.selectNodes(i.currentObject.value.map(s=>S(s)))}},e.map.addEventListener("keydown",i=>{(i.metaKey||i.ctrlKey)&&(i.shiftKey&&i.key==="Z"||i.key==="y")?e.redo():(i.metaKey||i.ctrlKey)&&i.key==="z"&&e.undo()})}const Pn="",z=(e,t)=>{const n=document.createElement("span");return n.id=e,n.innerHTML=`<svg class="icon" aria-hidden="true">
16
16
  <use xlink:href="#icon-${t}"></use>
17
- </svg>`,n};function Mt(e){const t=document.createElement("div"),n=z("fullscreen","full"),o=z("toCenter","living"),i=z("zoomout","move"),s=z("zoomin","add"),r=document.createElement("span");return r.innerText="100%",t.appendChild(n),t.appendChild(o),t.appendChild(i),t.appendChild(s),t.className="mind-elixir-toolbar rb",n.onclick=()=>{e.mindElixirBox.requestFullscreen()},o.onclick=()=>{e.toCenter()},i.onclick=()=>{e.scaleVal<.6||e.scale(e.scaleVal-.2)},s.onclick=()=>{e.scaleVal>1.6||e.scale(e.scaleVal+.2)},t}function kt(e){const t=document.createElement("div"),n=z("tbltl","left"),o=z("tbltr","right"),i=z("tblts","side");return t.appendChild(n),t.appendChild(o),t.appendChild(i),t.className="mind-elixir-toolbar lt",n.onclick=()=>{e.initLeft()},o.onclick=()=>{e.initRight()},i.onclick=()=>{e.initSide()},t}function Tt(e){e.container.append(Mt(e)),e.container.append(kt(e))}/*! @viselect/vanilla v3.5.1 MIT | https://github.com/Simonwep/selection/tree/master/packages/vanilla */var At=Object.defineProperty,$t=(e,t,n)=>t in e?At(e,t,{enumerable:!0,configurable:!0,writable:!0,value:n}):e[t]=n,E=(e,t,n)=>($t(e,typeof t!="symbol"?t+"":t,n),n);class jt{constructor(){E(this,"_listeners",new Map),E(this,"on",this.addEventListener),E(this,"off",this.removeEventListener),E(this,"emit",this.dispatchEvent)}addEventListener(t,n){const o=this._listeners.get(t)??new Set;return this._listeners.set(t,o),o.add(n),this}removeEventListener(t,n){var o;return(o=this._listeners.get(t))==null||o.delete(n),this}dispatchEvent(t,...n){let o=!0;for(const i of this._listeners.get(t)??[])o=i(...n)!==!1&&o;return o}unbindAllListeners(){this._listeners.clear()}}const je=(e,t="px")=>typeof e=="number"?e+t:e;function B({style:e},t,n){if(typeof t=="object")for(const[o,i]of Object.entries(t))i!==void 0&&(e[o]=je(i));else n!==void 0&&(e[t]=je(n))}const De=e=>(t,n,o,i={})=>{t instanceof HTMLCollection||t instanceof NodeList?t=Array.from(t):Array.isArray(t)||(t=[t]),Array.isArray(n)||(n=[n]);for(const s of t)if(s)for(const r of n)s[e](r,o,{capture:!1,...i});return[t,n,o,i]},V=De("addEventListener"),R=De("removeEventListener"),ce=e=>{var t;const{clientX:n,clientY:o,target:i}=((t=e.touches)==null?void 0:t[0])??e;return{x:n,y:o,target:i}};function Oe(e,t,n="touch"){switch(n){case"center":{const o=t.left+t.width/2,i=t.top+t.height/2;return o>=e.left&&o<=e.right&&i>=e.top&&i<=e.bottom}case"cover":return t.left>=e.left&&t.top>=e.top&&t.right<=e.right&&t.bottom<=e.bottom;case"touch":return e.right>=t.left&&e.left<=t.right&&e.bottom>=t.top&&e.top<=t.bottom}}function I(e,t=document){const n=Array.isArray(e)?e:[e];let o=[];for(let i=0,s=n.length;i<s;i++){const r=n[i];typeof r=="string"?o=o.concat(Array.from(t.querySelectorAll(r))):r instanceof Element&&o.push(r)}return o}const Dt=()=>matchMedia("(hover: none), (pointer: coarse)").matches,Ot=()=>"safari"in window,Ht=e=>{let t,n=-1,o=!1;return{next(...i){t=i,o||(o=!0,n=requestAnimationFrame(()=>{e(...t),o=!1}))},cancel(){cancelAnimationFrame(n),o=!1}}};function Pt(e,t){for(const n of t){if(typeof n=="number")return e.button===n;if(typeof n=="object"){const o=n.button===e.button,i=n.modifiers.every(s=>{switch(s){case"alt":return e.altKey;case"ctrl":return e.ctrlKey||e.metaKey;case"shift":return e.shiftKey}});return o&&i}}return!1}const{abs:F,max:He,min:Pe,ceil:Be}=Math;class Re extends jt{constructor(t){var n,o,i,s,r;super(),E(this,"_options"),E(this,"_selection",{stored:[],selected:[],touched:[],changed:{added:[],removed:[]}}),E(this,"_area"),E(this,"_clippingElement"),E(this,"_targetElement"),E(this,"_targetRect"),E(this,"_selectables",[]),E(this,"_latestElement"),E(this,"_areaRect",new DOMRect),E(this,"_areaLocation",{y1:0,x2:0,y2:0,x1:0}),E(this,"_singleClick",!0),E(this,"_frame"),E(this,"_scrollAvailable",!0),E(this,"_scrollingActive",!1),E(this,"_scrollSpeed",{x:0,y:0}),E(this,"_scrollDelta",{x:0,y:0}),E(this,"disable",this._bindStartEvents.bind(this,!1)),E(this,"enable",this._bindStartEvents),this._options={selectionAreaClass:"selection-area",selectionContainerClass:void 0,selectables:[],document:window.document,startAreas:["html"],boundaries:["html"],container:"body",...t,behaviour:{overlap:"invert",intersect:"touch",triggers:[0],...t.behaviour,startThreshold:(n=t.behaviour)!=null&&n.startThreshold?typeof t.behaviour.startThreshold=="number"?t.behaviour.startThreshold:{x:10,y:10,...t.behaviour.startThreshold}:{x:10,y:10},scrolling:{speedDivider:10,manualSpeed:750,...(o=t.behaviour)==null?void 0:o.scrolling,startScrollMargins:{x:0,y:0,...(s=(i=t.behaviour)==null?void 0:i.scrolling)==null?void 0:s.startScrollMargins}}},features:{range:!0,touch:!0,...t.features,singleTap:{allow:!0,intersect:"native",...(r=t.features)==null?void 0:r.singleTap}}};for(const a of Object.getOwnPropertyNames(Object.getPrototypeOf(this)))typeof this[a]=="function"&&(this[a]=this[a].bind(this));const{document:c,selectionAreaClass:l,selectionContainerClass:d}=this._options;this._area=c.createElement("div"),this._clippingElement=c.createElement("div"),this._clippingElement.appendChild(this._area),this._area.classList.add(l),d&&this._clippingElement.classList.add(d),B(this._area,{willChange:"top, left, bottom, right, width, height",top:0,left:0,position:"fixed"}),B(this._clippingElement,{overflow:"hidden",position:"fixed",transform:"translate3d(0, 0, 0)",pointerEvents:"none",zIndex:"1"}),this._frame=Ht(a=>{this._recalculateSelectionAreaRect(),this._updateElementSelection(),this._emitEvent("move",a),this._redrawSelectionArea()}),this.enable()}_bindStartEvents(t=!0){const{document:n,features:o}=this._options,i=t?V:R;i(n,"mousedown",this._onTapStart),o.touch&&i(n,"touchstart",this._onTapStart,{passive:!1})}_onTapStart(t,n=!1){const{x:o,y:i,target:s}=ce(t),{_options:r}=this,{document:c}=this._options,l=s.getBoundingClientRect();if(t instanceof MouseEvent&&!Pt(t,r.behaviour.triggers))return;const d=I(r.startAreas,r.document),a=I(r.boundaries,r.document);this._targetElement=a.find(p=>Oe(p.getBoundingClientRect(),l));const u=t.composedPath();if(!this._targetElement||!d.find(p=>u.includes(p))||!a.find(p=>u.includes(p))||!n&&this._emitEvent("beforestart",t)===!1)return;this._areaLocation={x1:o,y1:i,x2:0,y2:0};const h=c.scrollingElement??c.body;this._scrollDelta={x:h.scrollLeft,y:h.scrollTop},this._singleClick=!0,this.clearSelection(!1,!0),V(c,["touchmove","mousemove"],this._delayedTapMove,{passive:!1}),V(c,["mouseup","touchcancel","touchend"],this._onTapStop),V(c,"scroll",this._onScroll)}_onSingleTap(t){const{singleTap:{intersect:n},range:o}=this._options.features,i=ce(t);let s;if(n==="native")s=i.target;else if(n==="touch"){this.resolveSelectables();const{x:c,y:l}=i;s=this._selectables.find(d=>{const{right:a,left:u,top:h,bottom:p}=d.getBoundingClientRect();return c<a&&c>u&&l<p&&l>h})}if(!s)return;for(this.resolveSelectables();!this._selectables.includes(s);){if(!s.parentElement)return;s=s.parentElement}const{stored:r}=this._selection;if(this._emitEvent("start",t),t.shiftKey&&o&&this._latestElement){const c=this._latestElement,[l,d]=c.compareDocumentPosition(s)&4?[s,c]:[c,s],a=[...this._selectables.filter(u=>u.compareDocumentPosition(l)&4&&u.compareDocumentPosition(d)&2),l,d];this.select(a),this._latestElement=c}else r.includes(s)&&(r.length===1||t.ctrlKey||r.every(c=>this._selection.stored.includes(c)))?this.deselect(s):(this.select(s),this._latestElement=s)}_delayedTapMove(t){const{container:n,document:o,behaviour:{startThreshold:i}}=this._options,{x1:s,y1:r}=this._areaLocation,{x:c,y:l}=ce(t);if(typeof i=="number"&&F(c+l-(s+r))>=i||typeof i=="object"&&F(c-s)>=i.x||F(l-r)>=i.y){if(R(o,["mousemove","touchmove"],this._delayedTapMove,{passive:!1}),this._emitEvent("beforedrag",t)===!1){R(o,["mouseup","touchcancel","touchend"],this._onTapStop);return}V(o,["mousemove","touchmove"],this._onTapMove,{passive:!1}),B(this._area,"display","block"),I(n,o)[0].appendChild(this._clippingElement),this.resolveSelectables(),this._singleClick=!1,this._targetRect=this._targetElement.getBoundingClientRect(),this._scrollAvailable=this._targetElement.scrollHeight!==this._targetElement.clientHeight||this._targetElement.scrollWidth!==this._targetElement.clientWidth,this._scrollAvailable&&(V(this._targetElement,"wheel",this._manualScroll,{passive:!1}),this._selectables=this._selectables.filter(d=>this._targetElement.contains(d))),this._setupSelectionArea(),this._emitEvent("start",t),this._onTapMove(t)}this._handleMoveEvent(t)}_setupSelectionArea(){const{_clippingElement:t,_targetElement:n,_area:o}=this,i=this._targetRect=n.getBoundingClientRect();this._scrollAvailable?(B(t,{top:i.top,left:i.left,width:i.width,height:i.height}),B(o,{marginTop:-i.top,marginLeft:-i.left})):(B(t,{top:0,left:0,width:"100%",height:"100%"}),B(o,{marginTop:0,marginLeft:0}))}_onTapMove(t){const{x:n,y:o}=ce(t),{_scrollSpeed:i,_areaLocation:s,_options:r,_frame:c}=this,{speedDivider:l}=r.behaviour.scrolling,d=this._targetElement;if(s.x2=n,s.y2=o,this._scrollAvailable&&!this._scrollingActive&&(i.y||i.x)){this._scrollingActive=!0;const a=()=>{if(!i.x&&!i.y){this._scrollingActive=!1;return}const{scrollTop:u,scrollLeft:h}=d;i.y&&(d.scrollTop+=Be(i.y/l),s.y1-=d.scrollTop-u),i.x&&(d.scrollLeft+=Be(i.x/l),s.x1-=d.scrollLeft-h),c.next(t),requestAnimationFrame(a)};requestAnimationFrame(a)}else c.next(t);this._handleMoveEvent(t)}_handleMoveEvent(t){const{features:n}=this._options;(n.touch&&Dt()||this._scrollAvailable&&Ot())&&t.preventDefault()}_onScroll(){const{_scrollDelta:t,_options:{document:n}}=this,{scrollTop:o,scrollLeft:i}=n.scrollingElement??n.body;this._areaLocation.x1+=t.x-i,this._areaLocation.y1+=t.y-o,t.x=i,t.y=o,this._setupSelectionArea(),this._frame.next(null)}_manualScroll(t){const{manualSpeed:n}=this._options.behaviour.scrolling,o=t.deltaY?t.deltaY>0?1:-1:0,i=t.deltaX?t.deltaX>0?1:-1:0;this._scrollSpeed.y+=o*n,this._scrollSpeed.x+=i*n,this._onTapMove(t),t.preventDefault()}_recalculateSelectionAreaRect(){const{_scrollSpeed:t,_areaLocation:n,_areaRect:o,_targetElement:i,_options:s}=this,{scrollTop:r,scrollHeight:c,clientHeight:l,scrollLeft:d,scrollWidth:a,clientWidth:u}=i,h=this._targetRect,{x1:p,y1:g}=n;let{x2:v,y2:m}=n;const{behaviour:{scrolling:{startScrollMargins:f}}}=s;v<h.left+f.x?(t.x=d?-F(h.left-v+f.x):0,v=v<h.left?h.left:v):v>h.right-f.x?(t.x=a-d-u?F(h.left+h.width-v-f.x):0,v=v>h.right?h.right:v):t.x=0,m<h.top+f.y?(t.y=r?-F(h.top-m+f.y):0,m=m<h.top?h.top:m):m>h.bottom-f.y?(t.y=c-r-l?F(h.top+h.height-m-f.y):0,m=m>h.bottom?h.bottom:m):t.y=0;const b=Pe(p,v),x=Pe(g,m),N=He(p,v),y=He(g,m);o.x=b,o.y=x,o.width=N-b,o.height=y-x}_redrawSelectionArea(){const{x:t,y:n,width:o,height:i}=this._areaRect,{style:s}=this._area;s.left=`${t}px`,s.top=`${n}px`,s.width=`${o}px`,s.height=`${i}px`}_onTapStop(t,n){var o;const{document:i,features:s}=this._options,{_singleClick:r}=this;R(i,["mousemove","touchmove"],this._delayedTapMove),R(i,["touchmove","mousemove"],this._onTapMove),R(i,["mouseup","touchcancel","touchend"],this._onTapStop),R(i,"scroll",this._onScroll),this._keepSelection(),t&&r&&s.singleTap.allow?this._onSingleTap(t):!r&&!n&&(this._updateElementSelection(),this._emitEvent("stop",t)),this._scrollSpeed.x=0,this._scrollSpeed.y=0,R(this._targetElement,"wheel",this._manualScroll,{passive:!0}),this._clippingElement.remove(),(o=this._frame)==null||o.cancel(),B(this._area,"display","none")}_updateElementSelection(){const{_selectables:t,_options:n,_selection:o,_areaRect:i}=this,{stored:s,selected:r,touched:c}=o,{intersect:l,overlap:d}=n.behaviour,a=d==="invert",u=[],h=[],p=[];for(let v=0;v<t.length;v++){const m=t[v];if(Oe(i,m.getBoundingClientRect(),l)){if(r.includes(m))s.includes(m)&&!c.includes(m)&&c.push(m);else if(a&&s.includes(m)){p.push(m);continue}else h.push(m);u.push(m)}}a&&h.push(...s.filter(v=>!r.includes(v)));const g=d==="keep";for(let v=0;v<r.length;v++){const m=r[v];!u.includes(m)&&!(g&&s.includes(m))&&p.push(m)}o.selected=u,o.changed={added:h,removed:p},this._latestElement=void 0}_emitEvent(t,n){return this.emit(t,{event:n,store:this._selection,selection:this})}_keepSelection(){const{_options:t,_selection:n}=this,{selected:o,changed:i,touched:s,stored:r}=n,c=o.filter(l=>!r.includes(l));switch(t.behaviour.overlap){case"drop":{n.stored=[...c,...r.filter(l=>!s.includes(l))];break}case"invert":{n.stored=[...c,...r.filter(l=>!i.removed.includes(l))];break}case"keep":{n.stored=[...r,...o.filter(l=>!r.includes(l))];break}}}trigger(t,n=!0){this._onTapStart(t,n)}resolveSelectables(){this._selectables=I(this._options.selectables,this._options.document)}clearSelection(t=!0,n=!1){const{selected:o,stored:i,changed:s}=this._selection;s.added=[],s.removed.push(...o,...t?i:[]),n||(this._emitEvent("move",null),this._emitEvent("stop",null)),this._selection={stored:t?[]:i,selected:[],touched:[],changed:{added:[],removed:[]}}}getSelection(){return this._selection.stored}getSelectionArea(){return this._area}cancel(t=!1){this._onTapStop(null,!t)}destroy(){this.cancel(),this.disable(),this._clippingElement.remove(),super.unbindAllListeners()}select(t,n=!1){const{changed:o,selected:i,stored:s}=this._selection,r=I(t,this._options.document).filter(c=>!i.includes(c)&&!s.includes(c));return s.push(...r),i.push(...r),o.added.push(...r),o.removed=[],this._latestElement=void 0,n||(this._emitEvent("move",null),this._emitEvent("stop",null)),r}deselect(t,n=!1){const{selected:o,stored:i,changed:s}=this._selection,r=I(t,this._options.document).filter(c=>o.includes(c)||i.includes(c));r.length&&(this._selection.stored=i.filter(c=>!r.includes(c)),this._selection.selected=o.filter(c=>!r.includes(c)),this._selection.changed.added=[],this._selection.changed.removed.push(...r.filter(c=>!s.removed.includes(c))),this._latestElement=void 0,n||(this._emitEvent("move",null),this._emitEvent("stop",null)))}}E(Re,"version","3.5.1");function Bt(e){const t=e.mouseSelectionButton===2?[2]:[0],n=new Re({selectables:[".map-container me-tpc"],boundaries:[e.container],container:e.selectionContainer,behaviour:{triggers:t,scrolling:{speedDivider:10,manualSpeed:750,startScrollMargins:{x:10,y:10}}}}).on("beforestart",({event:o})=>{if(o.target.tagName==="ME-TPC"||o.target.id==="input-box"||o.target.className==="circle")return!1;const i=n.getSelectionArea();return i.style.background="#4f90f22d",i.style.border="1px solid #4f90f2",i.parentElement&&(i.parentElement.style.zIndex="9999"),!0}).on("start",({event:o})=>{!o.ctrlKey&&!o.metaKey&&(e.clearSelection(),n.clearSelection(!0,!0))}).on("move",({store:{changed:{added:o,removed:i}}})=>{M.moved=!0;for(const s of o)s.classList.add("selected");for(const s of i)s.classList.remove("selected")}).on("stop",({store:{stored:o}})=>{e.selectNodes(o)});e.selection=n}const Rt=function(e,t=!0){this.theme=e;const n=this.theme.cssVar,o=Object.keys(n);this.container.style.cssText="";for(let i=0;i<o.length;i++){const s=o[i];this.container.style.setProperty(s,n[s])}e.cssVar["--gap"]||this.container.style.setProperty("--gap","30px"),t&&this.refresh()},K=e=>{var o;const t=(o=e.parent)==null?void 0:o.children,n=(t==null?void 0:t.indexOf(e))??0;return{siblings:t,index:n}};function zt(e){const{siblings:t,index:n}=K(e);if(t===void 0)return;const o=t[n];n===0?(t[n]=t[t.length-1],t[t.length-1]=o):(t[n]=t[n-1],t[n-1]=o)}function Ft(e){const{siblings:t,index:n}=K(e);if(t===void 0)return;const o=t[n];n===t.length-1?(t[n]=t[0],t[0]=o):(t[n]=t[n+1],t[n+1]=o)}function be(e){const{siblings:t,index:n}=K(e);return t===void 0?0:(t.splice(n,1),t.length)}function qt(e,t,n){const{siblings:o,index:i}=K(n);o!==void 0&&(t==="before"?o.splice(i,0,e):o.splice(i+1,0,e))}function Vt(e,t){const{siblings:n,index:o}=K(e);n!==void 0&&(n[o]=t,t.children=[e])}function ze(e,t,n){if(be(t),e==="in")n.children?n.children.push(t):n.children=[t];else{t.direction!==void 0&&(t.direction=n.direction);const{siblings:o,index:i}=K(n);if(o===void 0)return;e==="before"?o.splice(i,0,t):o.splice(i+1,0,t)}}const It=function(e,t){var n,o;if(e===$)return $;if(e===O)return O;if(e===ee){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=$,$):(t.direction=O,O)}},Fe=function(e,t,n){var s,r;const o=n.children[0].children[0],i=t.parentElement;if(i.tagName==="ME-PARENT"){if(J(o),i.children[1])i.nextSibling.appendChild(n);else{const c=e.createChildren([n]);i.appendChild(me(!0)),i.insertAdjacentElement("afterend",c)}e.linkDiv(n.offsetParent)}else i.tagName==="ME-ROOT"&&(It(e.direction,o.nodeObj)===$?(s=e.container.querySelector(".lhs"))==null||s.appendChild(n):(r=e.container.querySelector(".rhs"))==null||r.appendChild(n),e.linkDiv())},qe=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()},Ve={before:"beforebegin",after:"afterend"},J=function(e){const n=e.parentElement.parentElement.lastElementChild;(n==null?void 0:n.tagName)==="svg"&&(n==null||n.remove())},Kt=function(e,t){const n=e.nodeObj,o=ue(n);o.style&&t.style&&(t.style=Object.assign(o.style,t.style));const i=Object.assign(n,t);pe(e,i),this.linkDiv(),this.bus.fire("operation",{name:"reshapeNode",obj:i,origin:o})},ye=function(e,t,n){if(!t)return null;const o=t.nodeObj;o.expanded===!1&&(e.expandNode(t,!0),t=S(o.id));const i=n||e.generateNewObj();o.children?o.children.push(i):o.children=[i],H(e.nodeData);const{grp:s,top:r}=e.createWrapper(i);return Fe(e,t,s),{newTop:r,newNodeObj:i}},Wt=function(e,t,n){var d,a,u,h;const o=t||this.currentNode;if(!o)return;const i=o.nodeObj;if(i.parent){if(!((d=i.parent)!=null&&d.parent)&&((u=(a=i.parent)==null?void 0:a.children)==null?void 0:u.length)===1){this.addChild(S(i.parent.id),n);return}}else{this.addChild();return}const s=n||this.generateNewObj();if(!((h=i.parent)!=null&&h.parent)){const p=o.closest("me-main").className===L.LHS?$:O;s.direction=p}qt(s,e,i),H(this.nodeData);const r=o.parentElement,{grp:c,top:l}=this.createWrapper(s);r.parentElement.insertAdjacentElement(Ve[e],c),this.linkDiv(c.offsetParent),n||this.editTopic(l.firstChild),this.selectNode(l.firstChild,!0),this.bus.fire("operation",{name:"insertSibling",type:e,obj:s})},Ut=function(e,t){const n=e||this.currentNode;if(!n)return;J(n);const o=n.nodeObj;if(!o.parent)return;const i=t||this.generateNewObj();Vt(o,i),H(this.nodeData);const s=n.parentElement.parentElement,{grp:r,top:c}=this.createWrapper(i,!0);c.appendChild(me(!0)),s.insertAdjacentElement("afterend",r);const l=this.createChildren([s]);c.insertAdjacentElement("afterend",l),this.linkDiv(),t||this.editTopic(c.firstChild),this.selectNode(c.firstChild,!0),this.bus.fire("operation",{name:"insertParent",obj:i})},Yt=function(e,t){const n=e||this.currentNode;if(!n)return;const o=ye(this,n,t);if(!o)return;const{newTop:i,newNodeObj:s}=o;this.bus.fire("operation",{name:"addChild",obj:s}),t||this.editTopic(i.firstChild),this.selectNode(i.firstChild,!0)},Xt=function(e,t){const n=ue(e.nodeObj);he(n);const o=ye(this,t,n);if(!o)return;const{newNodeObj:i}=o;this.selectNode(S(i.id)),this.bus.fire("operation",{name:"copyNode",obj:i})},Gt=function(e,t){e=ie(e);const n=[];for(let o=0;o<e.length;o++){const i=e[o],s=ue(i.nodeObj);he(s);const r=ye(this,t,s);if(!r)return;const{newNodeObj:c}=r;n.push(c)}this.selectNodes(n.map(o=>S(o.id))),this.bus.fire("operation",{name:"copyNodes",objs:n})},Jt=function(e){const t=e||this.currentNode;if(!t)return;const n=t.nodeObj;zt(n);const o=t.parentNode.parentNode;o.parentNode.insertBefore(o,o.previousSibling),this.linkDiv(),this.bus.fire("operation",{name:"moveUpNode",obj:n})},Zt=function(e){const t=e||this.currentNode;if(!t)return;const n=t.nodeObj;Ft(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})},Qt=function(e){var r;const t=e||this.currentNode;if(!t)return;const n=t.nodeObj;if(!n.parent)throw new Error("Can not remove root node");const o=n.parent.children,i=o.findIndex(c=>c===n),s=be(n);if(qe(t,s),o.length!==0){const c=o[i]||o[i-1];this.selectNode(S(c.id))}else this.selectNode(S(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})},en=function(e){e=ie(e);for(const t of e){const n=t.nodeObj;if(!n.parent)continue;const o=be(n);qe(t,o)}this.linkDiv(),this.bus.fire("operation",{name:"removeNodes",objs:e.map(t=>t.nodeObj)})},tn=function(e,t){e=ie(e);const n=t.nodeObj;n.expanded===!1&&(this.expandNode(t,!0),t=S(n.id));for(const o of e){const i=o.nodeObj;ze("in",i,n),H(this.nodeData);const s=o.parentElement;Fe(this,t,s.parentElement)}this.linkDiv(),this.bus.fire("operation",{name:"moveNodeIn",objs:e.map(o=>o.nodeObj),toObj:n})},Ie=(e,t,n,o)=>{e=ie(e),t==="after"&&(e=e.reverse());const i=n.nodeObj;for(const s of e){const r=s.nodeObj;ze(t,r,i),H(o.nodeData),J(s);const c=s.parentElement.parentNode;n.parentElement.parentNode.insertAdjacentElement(Ve[t],c)}o.linkDiv(),o.bus.fire("operation",{name:t==="before"?"moveNodeBefore":"moveNodeAfter",objs:e.map(s=>s.nodeObj),toObj:i})},Ke=Object.freeze(Object.defineProperty({__proto__:null,addChild:Yt,beginEdit:function(e){const t=e||this.currentNode;t&&(t.nodeObj.dangerouslySetInnerHTML||this.editTopic(t))},copyNode:Xt,copyNodes:Gt,insertParent:Ut,insertSibling:Wt,moveDownNode:Zt,moveNodeAfter:function(e,t){Ie(e,"after",t,this)},moveNodeBefore:function(e,t){Ie(e,"before",t,this)},moveNodeIn:tn,moveUpNode:Jt,removeNode:Qt,removeNodes:en,reshapeNode:Kt,rmSubline:J,setNodeTopic:function(e,t){e.text.textContent=t,e.nodeObj.topic=t,this.linkDiv()}},Symbol.toStringTag,{value:"Module"}));function We(e){return{nodeData:e.isFocusMode?e.nodeDataBackup:e.nodeData,arrows:e.arrows,summaries:e.summaries,direction:e.direction,theme:e.theme}}const nn=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:function(){this.unselectNode(),this.unselectNodes(),this.unselectSummary(),this.unselectArrow()},disableEdit:function(){this.editable=!1},enableEdit:function(){this.editable=!0},expandNode:function(e,t){const n=e.nodeObj;typeof t=="boolean"?n.expanded=t:n.expanded!==!1?n.expanded=!1:n.expanded=!0;const o=e.parentNode,i=o.children[1];if(i.expanded=n.expanded,i.className=n.expanded?"minus":"",J(e),n.expanded){const l=this.createChildren(n.children.map(d=>this.createWrapper(d).grp));o.parentNode.appendChild(l)}else o.parentNode.children[1].remove();this.linkDiv(e.closest("me-main > me-wrapper"));const s=e.getBoundingClientRect(),r=this.container.getBoundingClientRect();(s.bottom>r.bottom||s.top<r.top||s.right>r.right||s.left<r.left)&&e.scrollIntoView({block:"center",inline:"center"}),this.bus.fire("expandNode",n)},focusNode:function(e){e.nodeObj.parent&&(this.tempDirection===null&&(this.tempDirection=this.direction),this.isFocusMode||(this.nodeDataBackup=this.nodeData,this.isFocusMode=!0),this.nodeData=e.nodeObj,this.initRight(),this.toCenter())},getData:function(){return JSON.parse(this.getDataString())},getDataMd:function(){const e=We(this).nodeData;let t="# "+e.topic+`
17
+ </svg>`,n};function Mt(e){const t=document.createElement("div"),n=z("fullscreen","full"),o=z("toCenter","living"),i=z("zoomout","move"),s=z("zoomin","add"),r=document.createElement("span");return r.innerText="100%",t.appendChild(n),t.appendChild(o),t.appendChild(i),t.appendChild(s),t.className="mind-elixir-toolbar rb",n.onclick=()=>{e.mindElixirBox.requestFullscreen()},o.onclick=()=>{e.toCenter()},i.onclick=()=>{e.scaleVal<.6||e.scale(e.scaleVal-.2)},s.onclick=()=>{e.scaleVal>1.6||e.scale(e.scaleVal+.2)},t}function kt(e){const t=document.createElement("div"),n=z("tbltl","left"),o=z("tbltr","right"),i=z("tblts","side");return t.appendChild(n),t.appendChild(o),t.appendChild(i),t.className="mind-elixir-toolbar lt",n.onclick=()=>{e.initLeft()},o.onclick=()=>{e.initRight()},i.onclick=()=>{e.initSide()},t}function Tt(e){e.container.append(Mt(e)),e.container.append(kt(e))}/*! @viselect/vanilla v3.5.1 MIT | https://github.com/Simonwep/selection/tree/master/packages/vanilla */var At=Object.defineProperty,$t=(e,t,n)=>t in e?At(e,t,{enumerable:!0,configurable:!0,writable:!0,value:n}):e[t]=n,E=(e,t,n)=>($t(e,typeof t!="symbol"?t+"":t,n),n);class jt{constructor(){E(this,"_listeners",new Map),E(this,"on",this.addEventListener),E(this,"off",this.removeEventListener),E(this,"emit",this.dispatchEvent)}addEventListener(t,n){const o=this._listeners.get(t)??new Set;return this._listeners.set(t,o),o.add(n),this}removeEventListener(t,n){var o;return(o=this._listeners.get(t))==null||o.delete(n),this}dispatchEvent(t,...n){let o=!0;for(const i of this._listeners.get(t)??[])o=i(...n)!==!1&&o;return o}unbindAllListeners(){this._listeners.clear()}}const je=(e,t="px")=>typeof e=="number"?e+t:e;function B({style:e},t,n){if(typeof t=="object")for(const[o,i]of Object.entries(t))i!==void 0&&(e[o]=je(i));else n!==void 0&&(e[t]=je(n))}const De=e=>(t,n,o,i={})=>{t instanceof HTMLCollection||t instanceof NodeList?t=Array.from(t):Array.isArray(t)||(t=[t]),Array.isArray(n)||(n=[n]);for(const s of t)if(s)for(const r of n)s[e](r,o,{capture:!1,...i});return[t,n,o,i]},V=De("addEventListener"),R=De("removeEventListener"),ce=e=>{var t;const{clientX:n,clientY:o,target:i}=((t=e.touches)==null?void 0:t[0])??e;return{x:n,y:o,target:i}};function Oe(e,t,n="touch"){switch(n){case"center":{const o=t.left+t.width/2,i=t.top+t.height/2;return o>=e.left&&o<=e.right&&i>=e.top&&i<=e.bottom}case"cover":return t.left>=e.left&&t.top>=e.top&&t.right<=e.right&&t.bottom<=e.bottom;case"touch":return e.right>=t.left&&e.left<=t.right&&e.bottom>=t.top&&e.top<=t.bottom}}function W(e,t=document){const n=Array.isArray(e)?e:[e];let o=[];for(let i=0,s=n.length;i<s;i++){const r=n[i];typeof r=="string"?o=o.concat(Array.from(t.querySelectorAll(r))):r instanceof Element&&o.push(r)}return o}const Dt=()=>matchMedia("(hover: none), (pointer: coarse)").matches,Ot=()=>"safari"in window,Ht=e=>{let t,n=-1,o=!1;return{next(...i){t=i,o||(o=!0,n=requestAnimationFrame(()=>{e(...t),o=!1}))},cancel(){cancelAnimationFrame(n),o=!1}}};function Pt(e,t){for(const n of t){if(typeof n=="number")return e.button===n;if(typeof n=="object"){const o=n.button===e.button,i=n.modifiers.every(s=>{switch(s){case"alt":return e.altKey;case"ctrl":return e.ctrlKey||e.metaKey;case"shift":return e.shiftKey}});return o&&i}}return!1}const{abs:F,max:He,min:Pe,ceil:Be}=Math;class Re extends jt{constructor(t){var n,o,i,s,r;super(),E(this,"_options"),E(this,"_selection",{stored:[],selected:[],touched:[],changed:{added:[],removed:[]}}),E(this,"_area"),E(this,"_clippingElement"),E(this,"_targetElement"),E(this,"_targetRect"),E(this,"_selectables",[]),E(this,"_latestElement"),E(this,"_areaRect",new DOMRect),E(this,"_areaLocation",{y1:0,x2:0,y2:0,x1:0}),E(this,"_singleClick",!0),E(this,"_frame"),E(this,"_scrollAvailable",!0),E(this,"_scrollingActive",!1),E(this,"_scrollSpeed",{x:0,y:0}),E(this,"_scrollDelta",{x:0,y:0}),E(this,"disable",this._bindStartEvents.bind(this,!1)),E(this,"enable",this._bindStartEvents),this._options={selectionAreaClass:"selection-area",selectionContainerClass:void 0,selectables:[],document:window.document,startAreas:["html"],boundaries:["html"],container:"body",...t,behaviour:{overlap:"invert",intersect:"touch",triggers:[0],...t.behaviour,startThreshold:(n=t.behaviour)!=null&&n.startThreshold?typeof t.behaviour.startThreshold=="number"?t.behaviour.startThreshold:{x:10,y:10,...t.behaviour.startThreshold}:{x:10,y:10},scrolling:{speedDivider:10,manualSpeed:750,...(o=t.behaviour)==null?void 0:o.scrolling,startScrollMargins:{x:0,y:0,...(s=(i=t.behaviour)==null?void 0:i.scrolling)==null?void 0:s.startScrollMargins}}},features:{range:!0,touch:!0,...t.features,singleTap:{allow:!0,intersect:"native",...(r=t.features)==null?void 0:r.singleTap}}};for(const a of Object.getOwnPropertyNames(Object.getPrototypeOf(this)))typeof this[a]=="function"&&(this[a]=this[a].bind(this));const{document:c,selectionAreaClass:l,selectionContainerClass:d}=this._options;this._area=c.createElement("div"),this._clippingElement=c.createElement("div"),this._clippingElement.appendChild(this._area),this._area.classList.add(l),d&&this._clippingElement.classList.add(d),B(this._area,{willChange:"top, left, bottom, right, width, height",top:0,left:0,position:"fixed"}),B(this._clippingElement,{overflow:"hidden",position:"fixed",transform:"translate3d(0, 0, 0)",pointerEvents:"none",zIndex:"1"}),this._frame=Ht(a=>{this._recalculateSelectionAreaRect(),this._updateElementSelection(),this._emitEvent("move",a),this._redrawSelectionArea()}),this.enable()}_bindStartEvents(t=!0){const{document:n,features:o}=this._options,i=t?V:R;i(n,"mousedown",this._onTapStart),o.touch&&i(n,"touchstart",this._onTapStart,{passive:!1})}_onTapStart(t,n=!1){const{x:o,y:i,target:s}=ce(t),{_options:r}=this,{document:c}=this._options,l=s.getBoundingClientRect();if(t instanceof MouseEvent&&!Pt(t,r.behaviour.triggers))return;const d=W(r.startAreas,r.document),a=W(r.boundaries,r.document);this._targetElement=a.find(p=>Oe(p.getBoundingClientRect(),l));const u=t.composedPath();if(!this._targetElement||!d.find(p=>u.includes(p))||!a.find(p=>u.includes(p))||!n&&this._emitEvent("beforestart",t)===!1)return;this._areaLocation={x1:o,y1:i,x2:0,y2:0};const h=c.scrollingElement??c.body;this._scrollDelta={x:h.scrollLeft,y:h.scrollTop},this._singleClick=!0,this.clearSelection(!1,!0),V(c,["touchmove","mousemove"],this._delayedTapMove,{passive:!1}),V(c,["mouseup","touchcancel","touchend"],this._onTapStop),V(c,"scroll",this._onScroll)}_onSingleTap(t){const{singleTap:{intersect:n},range:o}=this._options.features,i=ce(t);let s;if(n==="native")s=i.target;else if(n==="touch"){this.resolveSelectables();const{x:c,y:l}=i;s=this._selectables.find(d=>{const{right:a,left:u,top:h,bottom:p}=d.getBoundingClientRect();return c<a&&c>u&&l<p&&l>h})}if(!s)return;for(this.resolveSelectables();!this._selectables.includes(s);){if(!s.parentElement)return;s=s.parentElement}const{stored:r}=this._selection;if(this._emitEvent("start",t),t.shiftKey&&o&&this._latestElement){const c=this._latestElement,[l,d]=c.compareDocumentPosition(s)&4?[s,c]:[c,s],a=[...this._selectables.filter(u=>u.compareDocumentPosition(l)&4&&u.compareDocumentPosition(d)&2),l,d];this.select(a),this._latestElement=c}else r.includes(s)&&(r.length===1||t.ctrlKey||r.every(c=>this._selection.stored.includes(c)))?this.deselect(s):(this.select(s),this._latestElement=s)}_delayedTapMove(t){const{container:n,document:o,behaviour:{startThreshold:i}}=this._options,{x1:s,y1:r}=this._areaLocation,{x:c,y:l}=ce(t);if(typeof i=="number"&&F(c+l-(s+r))>=i||typeof i=="object"&&F(c-s)>=i.x||F(l-r)>=i.y){if(R(o,["mousemove","touchmove"],this._delayedTapMove,{passive:!1}),this._emitEvent("beforedrag",t)===!1){R(o,["mouseup","touchcancel","touchend"],this._onTapStop);return}V(o,["mousemove","touchmove"],this._onTapMove,{passive:!1}),B(this._area,"display","block"),W(n,o)[0].appendChild(this._clippingElement),this.resolveSelectables(),this._singleClick=!1,this._targetRect=this._targetElement.getBoundingClientRect(),this._scrollAvailable=this._targetElement.scrollHeight!==this._targetElement.clientHeight||this._targetElement.scrollWidth!==this._targetElement.clientWidth,this._scrollAvailable&&(V(this._targetElement,"wheel",this._manualScroll,{passive:!1}),this._selectables=this._selectables.filter(d=>this._targetElement.contains(d))),this._setupSelectionArea(),this._emitEvent("start",t),this._onTapMove(t)}this._handleMoveEvent(t)}_setupSelectionArea(){const{_clippingElement:t,_targetElement:n,_area:o}=this,i=this._targetRect=n.getBoundingClientRect();this._scrollAvailable?(B(t,{top:i.top,left:i.left,width:i.width,height:i.height}),B(o,{marginTop:-i.top,marginLeft:-i.left})):(B(t,{top:0,left:0,width:"100%",height:"100%"}),B(o,{marginTop:0,marginLeft:0}))}_onTapMove(t){const{x:n,y:o}=ce(t),{_scrollSpeed:i,_areaLocation:s,_options:r,_frame:c}=this,{speedDivider:l}=r.behaviour.scrolling,d=this._targetElement;if(s.x2=n,s.y2=o,this._scrollAvailable&&!this._scrollingActive&&(i.y||i.x)){this._scrollingActive=!0;const a=()=>{if(!i.x&&!i.y){this._scrollingActive=!1;return}const{scrollTop:u,scrollLeft:h}=d;i.y&&(d.scrollTop+=Be(i.y/l),s.y1-=d.scrollTop-u),i.x&&(d.scrollLeft+=Be(i.x/l),s.x1-=d.scrollLeft-h),c.next(t),requestAnimationFrame(a)};requestAnimationFrame(a)}else c.next(t);this._handleMoveEvent(t)}_handleMoveEvent(t){const{features:n}=this._options;(n.touch&&Dt()||this._scrollAvailable&&Ot())&&t.preventDefault()}_onScroll(){const{_scrollDelta:t,_options:{document:n}}=this,{scrollTop:o,scrollLeft:i}=n.scrollingElement??n.body;this._areaLocation.x1+=t.x-i,this._areaLocation.y1+=t.y-o,t.x=i,t.y=o,this._setupSelectionArea(),this._frame.next(null)}_manualScroll(t){const{manualSpeed:n}=this._options.behaviour.scrolling,o=t.deltaY?t.deltaY>0?1:-1:0,i=t.deltaX?t.deltaX>0?1:-1:0;this._scrollSpeed.y+=o*n,this._scrollSpeed.x+=i*n,this._onTapMove(t),t.preventDefault()}_recalculateSelectionAreaRect(){const{_scrollSpeed:t,_areaLocation:n,_areaRect:o,_targetElement:i,_options:s}=this,{scrollTop:r,scrollHeight:c,clientHeight:l,scrollLeft:d,scrollWidth:a,clientWidth:u}=i,h=this._targetRect,{x1:p,y1:g}=n;let{x2:v,y2:m}=n;const{behaviour:{scrolling:{startScrollMargins:f}}}=s;v<h.left+f.x?(t.x=d?-F(h.left-v+f.x):0,v=v<h.left?h.left:v):v>h.right-f.x?(t.x=a-d-u?F(h.left+h.width-v-f.x):0,v=v>h.right?h.right:v):t.x=0,m<h.top+f.y?(t.y=r?-F(h.top-m+f.y):0,m=m<h.top?h.top:m):m>h.bottom-f.y?(t.y=c-r-l?F(h.top+h.height-m-f.y):0,m=m>h.bottom?h.bottom:m):t.y=0;const b=Pe(p,v),x=Pe(g,m),N=He(p,v),y=He(g,m);o.x=b,o.y=x,o.width=N-b,o.height=y-x}_redrawSelectionArea(){const{x:t,y:n,width:o,height:i}=this._areaRect,{style:s}=this._area;s.left=`${t}px`,s.top=`${n}px`,s.width=`${o}px`,s.height=`${i}px`}_onTapStop(t,n){var o;const{document:i,features:s}=this._options,{_singleClick:r}=this;R(i,["mousemove","touchmove"],this._delayedTapMove),R(i,["touchmove","mousemove"],this._onTapMove),R(i,["mouseup","touchcancel","touchend"],this._onTapStop),R(i,"scroll",this._onScroll),this._keepSelection(),t&&r&&s.singleTap.allow?this._onSingleTap(t):!r&&!n&&(this._updateElementSelection(),this._emitEvent("stop",t)),this._scrollSpeed.x=0,this._scrollSpeed.y=0,R(this._targetElement,"wheel",this._manualScroll,{passive:!0}),this._clippingElement.remove(),(o=this._frame)==null||o.cancel(),B(this._area,"display","none")}_updateElementSelection(){const{_selectables:t,_options:n,_selection:o,_areaRect:i}=this,{stored:s,selected:r,touched:c}=o,{intersect:l,overlap:d}=n.behaviour,a=d==="invert",u=[],h=[],p=[];for(let v=0;v<t.length;v++){const m=t[v];if(Oe(i,m.getBoundingClientRect(),l)){if(r.includes(m))s.includes(m)&&!c.includes(m)&&c.push(m);else if(a&&s.includes(m)){p.push(m);continue}else h.push(m);u.push(m)}}a&&h.push(...s.filter(v=>!r.includes(v)));const g=d==="keep";for(let v=0;v<r.length;v++){const m=r[v];!u.includes(m)&&!(g&&s.includes(m))&&p.push(m)}o.selected=u,o.changed={added:h,removed:p},this._latestElement=void 0}_emitEvent(t,n){return this.emit(t,{event:n,store:this._selection,selection:this})}_keepSelection(){const{_options:t,_selection:n}=this,{selected:o,changed:i,touched:s,stored:r}=n,c=o.filter(l=>!r.includes(l));switch(t.behaviour.overlap){case"drop":{n.stored=[...c,...r.filter(l=>!s.includes(l))];break}case"invert":{n.stored=[...c,...r.filter(l=>!i.removed.includes(l))];break}case"keep":{n.stored=[...r,...o.filter(l=>!r.includes(l))];break}}}trigger(t,n=!0){this._onTapStart(t,n)}resolveSelectables(){this._selectables=W(this._options.selectables,this._options.document)}clearSelection(t=!0,n=!1){const{selected:o,stored:i,changed:s}=this._selection;s.added=[],s.removed.push(...o,...t?i:[]),n||(this._emitEvent("move",null),this._emitEvent("stop",null)),this._selection={stored:t?[]:i,selected:[],touched:[],changed:{added:[],removed:[]}}}getSelection(){return this._selection.stored}getSelectionArea(){return this._area}cancel(t=!1){this._onTapStop(null,!t)}destroy(){this.cancel(),this.disable(),this._clippingElement.remove(),super.unbindAllListeners()}select(t,n=!1){const{changed:o,selected:i,stored:s}=this._selection,r=W(t,this._options.document).filter(c=>!i.includes(c)&&!s.includes(c));return s.push(...r),i.push(...r),o.added.push(...r),o.removed=[],this._latestElement=void 0,n||(this._emitEvent("move",null),this._emitEvent("stop",null)),r}deselect(t,n=!1){const{selected:o,stored:i,changed:s}=this._selection,r=W(t,this._options.document).filter(c=>o.includes(c)||i.includes(c));r.length&&(this._selection.stored=i.filter(c=>!r.includes(c)),this._selection.selected=o.filter(c=>!r.includes(c)),this._selection.changed.added=[],this._selection.changed.removed.push(...r.filter(c=>!s.removed.includes(c))),this._latestElement=void 0,n||(this._emitEvent("move",null),this._emitEvent("stop",null)))}}E(Re,"version","3.5.1");function Bt(e){const t=e.mouseSelectionButton===2?[2]:[0],n=new Re({selectables:[".map-container me-tpc"],boundaries:[e.container],container:e.selectionContainer,behaviour:{triggers:t,scrolling:{speedDivider:10,manualSpeed:750,startScrollMargins:{x:10,y:10}}}}).on("beforestart",({event:o})=>{if(o.target.tagName==="ME-TPC"||o.target.id==="input-box"||o.target.className==="circle")return!1;const i=n.getSelectionArea();return i.style.background="#4f90f22d",i.style.border="1px solid #4f90f2",i.parentElement&&(i.parentElement.style.zIndex="9999"),!0}).on("start",({event:o})=>{!o.ctrlKey&&!o.metaKey&&(e.clearSelection(),n.clearSelection(!0,!0))}).on("move",({store:{changed:{added:o,removed:i}}})=>{M.moved=!0;for(const s of o)s.classList.add("selected");for(const s of i)s.classList.remove("selected")}).on("stop",({store:{stored:o}})=>{e.selectNodes(o)});e.selection=n}const Rt=function(e,t=!0){this.theme=e;const n=this.theme.cssVar,o=Object.keys(n);this.container.style.cssText="";for(let i=0;i<o.length;i++){const s=o[i];this.container.style.setProperty(s,n[s])}e.cssVar["--gap"]||this.container.style.setProperty("--gap","30px"),t&&this.refresh()},I=e=>{var o;const t=(o=e.parent)==null?void 0:o.children,n=(t==null?void 0:t.indexOf(e))??0;return{siblings:t,index:n}};function zt(e){const{siblings:t,index:n}=I(e);if(t===void 0)return;const o=t[n];n===0?(t[n]=t[t.length-1],t[t.length-1]=o):(t[n]=t[n-1],t[n-1]=o)}function Ft(e){const{siblings:t,index:n}=I(e);if(t===void 0)return;const o=t[n];n===t.length-1?(t[n]=t[0],t[0]=o):(t[n]=t[n+1],t[n+1]=o)}function be(e){const{siblings:t,index:n}=I(e);return t===void 0?0:(t.splice(n,1),t.length)}function qt(e,t,n){const{siblings:o,index:i}=I(n);o!==void 0&&(t==="before"?o.splice(i,0,e):o.splice(i+1,0,e))}function Vt(e,t){const{siblings:n,index:o}=I(e);n!==void 0&&(n[o]=t,t.children=[e])}function ze(e,t,n){var o;if(be(t),(o=n.parent)!=null&&o.parent||(t.direction=n.direction),e==="in")n.children?n.children.push(t):n.children=[t];else{t.direction!==void 0&&(t.direction=n.direction);const{siblings:i,index:s}=I(n);if(i===void 0)return;e==="before"?i.splice(s,0,t):i.splice(s+1,0,t)}}const Wt=function(e,t){var n,o;if(e===$)return $;if(e===O)return O;if(e===ee){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=$,$):(t.direction=O,O)}},Fe=function(e,t,n){var s,r;const o=n.children[0].children[0],i=t.parentElement;if(i.tagName==="ME-PARENT"){if(J(o),i.children[1])i.nextSibling.appendChild(n);else{const c=e.createChildren([n]);i.appendChild(me(!0)),i.insertAdjacentElement("afterend",c)}e.linkDiv(n.offsetParent)}else i.tagName==="ME-ROOT"&&(Wt(e.direction,o.nodeObj)===$?(s=e.container.querySelector(".lhs"))==null||s.appendChild(n):(r=e.container.querySelector(".rhs"))==null||r.appendChild(n),e.linkDiv())},qe=function(e,t){const n=e.parentNode;if(t===0){const o=n.parentNode.parentNode;o.tagName!=="ME-MAIN"&&(o.previousSibling.children[1].remove(),o.remove())}n.parentNode.remove()},Ve={before:"beforebegin",after:"afterend"},J=function(e){const n=e.parentElement.parentElement.lastElementChild;(n==null?void 0:n.tagName)==="svg"&&(n==null||n.remove())},It=function(e,t){const n=e.nodeObj,o=ue(n);o.style&&t.style&&(t.style=Object.assign(o.style,t.style));const i=Object.assign(n,t);pe(e,i),this.linkDiv(),this.bus.fire("operation",{name:"reshapeNode",obj:i,origin:o})},ye=function(e,t,n){if(!t)return null;const o=t.nodeObj;o.expanded===!1&&(e.expandNode(t,!0),t=S(o.id));const i=n||e.generateNewObj();o.children?o.children.push(i):o.children=[i],H(e.nodeData);const{grp:s,top:r}=e.createWrapper(i);return Fe(e,t,s),{newTop:r,newNodeObj:i}},Kt=function(e,t,n){var d,a,u,h;const o=t||this.currentNode;if(!o)return;const i=o.nodeObj;if(i.parent){if(!((d=i.parent)!=null&&d.parent)&&((u=(a=i.parent)==null?void 0:a.children)==null?void 0:u.length)===1){this.addChild(S(i.parent.id),n);return}}else{this.addChild();return}const s=n||this.generateNewObj();if(!((h=i.parent)!=null&&h.parent)){const p=o.closest("me-main").className===L.LHS?$:O;s.direction=p}qt(s,e,i),H(this.nodeData);const r=o.parentElement,{grp:c,top:l}=this.createWrapper(s);r.parentElement.insertAdjacentElement(Ve[e],c),this.linkDiv(c.offsetParent),n||this.editTopic(l.firstChild),this.selectNode(l.firstChild,!0),this.bus.fire("operation",{name:"insertSibling",type:e,obj:s})},Ut=function(e,t){const n=e||this.currentNode;if(!n)return;J(n);const o=n.nodeObj;if(!o.parent)return;const i=t||this.generateNewObj();Vt(o,i),H(this.nodeData);const s=n.parentElement.parentElement,{grp:r,top:c}=this.createWrapper(i,!0);c.appendChild(me(!0)),s.insertAdjacentElement("afterend",r);const l=this.createChildren([s]);c.insertAdjacentElement("afterend",l),this.linkDiv(),t||this.editTopic(c.firstChild),this.selectNode(c.firstChild,!0),this.bus.fire("operation",{name:"insertParent",obj:i})},Yt=function(e,t){const n=e||this.currentNode;if(!n)return;const o=ye(this,n,t);if(!o)return;const{newTop:i,newNodeObj:s}=o;this.bus.fire("operation",{name:"addChild",obj:s}),t||this.editTopic(i.firstChild),this.selectNode(i.firstChild,!0)},Xt=function(e,t){const n=ue(e.nodeObj);he(n);const o=ye(this,t,n);if(!o)return;const{newNodeObj:i}=o;this.selectNode(S(i.id)),this.bus.fire("operation",{name:"copyNode",obj:i})},Gt=function(e,t){e=ie(e);const n=[];for(let o=0;o<e.length;o++){const i=e[o],s=ue(i.nodeObj);he(s);const r=ye(this,t,s);if(!r)return;const{newNodeObj:c}=r;n.push(c)}this.selectNodes(n.map(o=>S(o.id))),this.bus.fire("operation",{name:"copyNodes",objs:n})},Jt=function(e){const t=e||this.currentNode;if(!t)return;const n=t.nodeObj;zt(n);const o=t.parentNode.parentNode;o.parentNode.insertBefore(o,o.previousSibling),this.linkDiv(),this.bus.fire("operation",{name:"moveUpNode",obj:n})},Zt=function(e){const t=e||this.currentNode;if(!t)return;const n=t.nodeObj;Ft(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})},Qt=function(e){var r;const t=e||this.currentNode;if(!t)return;const n=t.nodeObj;if(!n.parent)throw new Error("Can not remove root node");const o=n.parent.children,i=o.findIndex(c=>c===n),s=be(n);if(qe(t,s),o.length!==0){const c=o[i]||o[i-1];this.selectNode(S(c.id))}else this.selectNode(S(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})},en=function(e){e=ie(e);for(const t of e){const n=t.nodeObj;if(!n.parent)continue;const o=be(n);qe(t,o)}this.linkDiv(),this.bus.fire("operation",{name:"removeNodes",objs:e.map(t=>t.nodeObj)})},tn=function(e,t){e=ie(e);const n=t.nodeObj;n.expanded===!1&&(this.expandNode(t,!0),t=S(n.id));for(const o of e){const i=o.nodeObj;ze("in",i,n),H(this.nodeData);const s=o.parentElement;Fe(this,t,s.parentElement)}this.linkDiv(),this.bus.fire("operation",{name:"moveNodeIn",objs:e.map(o=>o.nodeObj),toObj:n})},We=(e,t,n,o)=>{e=ie(e),t==="after"&&(e=e.reverse());const i=n.nodeObj,s=[];for(const r of e){const c=r.nodeObj;ze(t,c,i),H(o.nodeData),J(r);const l=r.parentElement.parentNode;s.includes(l.parentElement)||s.push(l.parentElement),n.parentElement.parentNode.insertAdjacentElement(Ve[t],l)}for(const r of s)r.childElementCount===0&&r.tagName!=="ME-MAIN"&&(r.previousSibling.children[1].remove(),r.remove());o.linkDiv(),o.bus.fire("operation",{name:t==="before"?"moveNodeBefore":"moveNodeAfter",objs:e.map(r=>r.nodeObj),toObj:i})},Ie=Object.freeze(Object.defineProperty({__proto__:null,addChild:Yt,beginEdit:function(e){const t=e||this.currentNode;t&&(t.nodeObj.dangerouslySetInnerHTML||this.editTopic(t))},copyNode:Xt,copyNodes:Gt,insertParent:Ut,insertSibling:Kt,moveDownNode:Zt,moveNodeAfter:function(e,t){We(e,"after",t,this)},moveNodeBefore:function(e,t){We(e,"before",t,this)},moveNodeIn:tn,moveUpNode:Jt,removeNode:Qt,removeNodes:en,reshapeNode:It,rmSubline:J,setNodeTopic:function(e,t){e.text.textContent=t,e.nodeObj.topic=t,this.linkDiv()}},Symbol.toStringTag,{value:"Module"}));function Ke(e){return{nodeData:e.isFocusMode?e.nodeDataBackup:e.nodeData,arrows:e.arrows,summaries:e.summaries,direction:e.direction,theme:e.theme}}const nn=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:function(){this.unselectNode(),this.unselectNodes(),this.unselectSummary(),this.unselectArrow()},disableEdit:function(){this.editable=!1},enableEdit:function(){this.editable=!0},expandNode:function(e,t){const n=e.nodeObj;typeof t=="boolean"?n.expanded=t:n.expanded!==!1?n.expanded=!1:n.expanded=!0;const o=e.parentNode,i=o.children[1];if(i.expanded=n.expanded,i.className=n.expanded?"minus":"",J(e),n.expanded){const l=this.createChildren(n.children.map(d=>this.createWrapper(d).grp));o.parentNode.appendChild(l)}else o.parentNode.children[1].remove();this.linkDiv(e.closest("me-main > me-wrapper"));const s=e.getBoundingClientRect(),r=this.container.getBoundingClientRect();(s.bottom>r.bottom||s.top<r.top||s.right>r.right||s.left<r.left)&&e.scrollIntoView({block:"center",inline:"center"}),this.bus.fire("expandNode",n)},focusNode:function(e){e.nodeObj.parent&&(this.tempDirection===null&&(this.tempDirection=this.direction),this.isFocusMode||(this.nodeDataBackup=this.nodeData,this.isFocusMode=!0),this.nodeData=e.nodeObj,this.initRight(),this.toCenter())},getData:function(){return JSON.parse(this.getDataString())},getDataMd:function(){const e=Ke(this).nodeData;let t="# "+e.topic+`
18
18
 
19
19
  `;function n(o,i){for(let s=0;s<o.length;s++)i<=6?t+="".padStart(i,"#")+" "+o[s].topic+`
20
20
 
21
21
  `:t+="".padStart(i-7," ")+"- "+o[s].topic+`
22
- `,o[s].children&&n(o[s].children||[],i+1)}return n(e.children||[],2),t},getDataString:function(){const e=We(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.arrows=e.arrows||[],this.summaries=e.summaries||[]),H(this.nodeData),this.layout(),this.linkDiv()},scale:function(e){this.scaleVal=e,this.map.style.transform="scale("+e+")",this.bus.fire("scale",e)},selectNode:function(e,t,n){if(e){if(this.clearSelection(),typeof e=="string"){const o=S(e);return o?this.selectNode(o):void 0}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)}},selectNodes:function(e){this.clearSelection();for(const t of e)t.className="selected";this.currentNodes=e,this.bus.fire("selectNodes",e.map(t=>t.nodeObj))},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"})),Ue={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 le(e,t,n){const{offsetLeft:o,offsetTop:i}=P(e.nodes,t),s=t.offsetWidth,r=t.offsetHeight,c=o+s/2,l=i+r/2,d=c+n.x,a=l+n.y;return{w:s,h:r,cx:c,cy:l,ctrlX:d,ctrlY:a}}function W(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 on=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},Ye=function(e,t,n,o,i){if(!t||!n)return;performance.now();const s=le(e,t,o.delta1),r=le(e,n,o.delta2),{x:c,y:l}=W(s),{ctrlX:d,ctrlY:a}=s,{ctrlX:u,ctrlY:h}=r,{x:p,y:g}=W(r),v=oe(u,h,p,g),m=`M ${v.x1} ${v.y1} L ${p} ${g} L ${v.x2} ${v.y2}`;let f="";if(o.bidirectional){const w=oe(d,a,c,l);f=`M ${w.x1} ${w.y1} L ${c} ${l} L ${w.x2} ${w.y2}`}const b=pt(`M ${c} ${l} C ${d} ${a} ${u} ${h} ${p} ${g}`,m,f),x=c/8+d*3/8+u*3/8+p/8,N=l/8+a*3/8+h*3/8+g/8,y=on(o.label,x,N,e.theme.cssVar["--color"]);b.appendChild(y),b.arrowObj=o,b.dataset.linkid=o.id,e.linkSvgGroup.appendChild(b),i||(e.arrows.push(o),e.currentArrow=b,Xe(e,o,s,r)),performance.now()},sn=function(e,t,n={}){const o={id:U(),label:"Custom Link",from:e.nodeObj.id,to:t.nodeObj.id,delta1:{x:0,y:-200},delta2:{x:0,y:-200},...n};Ye(this,e,t,o),this.bus.fire("operation",{name:"createArrow",obj:o})},rn=function(e){let t;if(e?t=e:t=this.currentArrow,!t)return;xe(this);const n=t.arrowObj.id;this.arrows=this.arrows.filter(o=>o.id!==n),t.remove(),this.bus.fire("operation",{name:"removeArrow",obj:{id:n}})},cn=function(e){this.currentArrow=e;const t=e.arrowObj,n=S(t.from),o=S(t.to),i=le(this,n,t.delta1),s=le(this,o,t.delta2);Xe(this,t,i,s)},ln=function(){this.currentArrow=null,xe(this)},xe=function(e){var t,n;(t=e.helper1)==null||t.destory(e.map),(n=e.helper2)==null||n.destory(e.map),e.linkController.style.display="none",e.P2.style.display="none",e.P3.style.display="none"},Xe=function(e,t,n,o){e.linkController.style.display="initial",e.P2.style.display="initial",e.P3.style.display="initial",e.nodes.appendChild(e.linkController),e.nodes.appendChild(e.P2),e.nodes.appendChild(e.P3);let{x:i,y:s}=W(n),{ctrlX:r,ctrlY:c}=n,{ctrlX:l,ctrlY:d}=o,{x:a,y:u}=W(o);e.P2.style.cssText=`top:${c}px;left:${r}px;`,e.P3.style.cssText=`top:${d}px;left:${l}px;`,C(e.line1,{x1:i+"",y1:s+"",x2:r+"",y2:c+""}),C(e.line2,{x1:l+"",y1:d+"",x2:a+"",y2:u+""}),e.helper1=Ue.create(e.P2),e.helper2=Ue.create(e.P3),e.helper1.init(e.map,(h,p)=>{if(!e.currentArrow)return;r=r+h/e.scaleVal,c=c+p/e.scaleVal;const g=W({...n,ctrlX:r,ctrlY:c});i=g.x,s=g.y;const v=i/8+r*3/8+l*3/8+a/8,m=s/8+c*3/8+d*3/8+u/8;if(e.P2.style.top=c+"px",e.P2.style.left=r+"px",e.currentArrow.children[0].setAttribute("d",`M ${i} ${s} C ${r} ${c} ${l} ${d} ${a} ${u}`),t.bidirectional){const f=oe(r,c,i,s);e.currentArrow.children[2].setAttribute("d",`M ${f.x1} ${f.y1} L ${i} ${s} L ${f.x2} ${f.y2}`)}C(e.currentArrow.children[3],{x:v+"",y:m+""}),C(e.line1,{x1:i+"",y1:s+"",x2:r+"",y2:c+""}),t.delta1.x=r-n.cx,t.delta1.y=c-n.cy,e.bus.fire("updateArrowDelta",t)}),e.helper2.init(e.map,(h,p)=>{if(!e.currentArrow)return;l=l+h/e.scaleVal,d=d+p/e.scaleVal;const g=W({...o,ctrlX:l,ctrlY:d});a=g.x,u=g.y;const v=i/8+r*3/8+l*3/8+a/8,m=s/8+c*3/8+d*3/8+u/8,f=oe(l,d,a,u);e.P3.style.top=d+"px",e.P3.style.left=l+"px",e.currentArrow.children[0].setAttribute("d",`M ${i} ${s} C ${r} ${c} ${l} ${d} ${a} ${u}`),e.currentArrow.children[1].setAttribute("d",`M ${f.x1} ${f.y1} L ${a} ${u} L ${f.x2} ${f.y2}`),C(e.currentArrow.children[3],{x:v+"",y:m+""}),C(e.line2,{x1:l+"",y1:d+"",x2:a+"",y2:u+""}),t.delta2.x=l-o.cx,t.delta2.y=d-o.cy,e.bus.fire("updateArrowDelta",t)})};function an(){this.linkSvgGroup.innerHTML="";for(let e=0;e<this.arrows.length;e++){const t=this.arrows[e];try{Ye(this,S(t.from),S(t.to),t,!0)}catch{}}this.nodes.appendChild(this.linkSvgGroup)}function dn(e){if(xe(this),!e)return;const t=e.children[3];_e(this,t,n=>{var s;const o=e.arrowObj,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:"finishEditArrowLabel",obj:o}))})}function hn(){this.arrows=this.arrows.filter(e=>ne(e.from,this.nodeData)&&ne(e.to,this.nodeData))}const un=Object.freeze(Object.defineProperty({__proto__:null,createArrow:sn,editArrowLabel:dn,removeArrow:rn,renderArrow:an,selectArrow:cn,tidyArrow:hn,unselectArrow:ln},Symbol.toStringTag,{value:"Module"})),fn=function(e){var l,d;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 h=u.children.findIndex(p=>a===p);return{parent:u.id,start:h,end:h}}let t=0;const n=e.map(a=>{let u=a.nodeObj;const h=[];for(;u.parent;){const p=u.parent,g=p.children,v=g==null?void 0:g.indexOf(u);u=p,h.unshift({node:u,index:v})}return h.length>t&&(t=h.length),h});let o=0;e:for(;o<t;o++){const a=(l=n[0][o])==null?void 0:l.node;for(let u=1;u<n.length;u++)if(((d=n[u][o])==null?void 0:d.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,c=n[0][o-1].node;if(!c.parent)throw new Error("Please select nodes in the same main topic.");return{parent:c.id,start:s,end:r}},pn=function(e){const t=document.createElementNS("http://www.w3.org/2000/svg","g");return t.setAttribute("id",e),t},Ge=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},Je=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},mn=e=>S(e).parentElement.parentElement,gn=function({parent:e,start:t}){const n=S(e),o=n.nodeObj;let i;return o.parent?i=n.closest("me-main").className:i=S(o.children[t].id).closest("me-main").className,i},Ze=function(e,t){var w;const{id:n,text:o,parent:i,start:s,end:r}=t,c=e.nodes,d=S(i).nodeObj,a=gn(t);let u=1/0,h=0,p=0,g=0;for(let _=s;_<=r;_++){const A=(w=d.children)==null?void 0:w[_];if(!A)return e.removeSummary(n),null;const D=mn(A.id),{offsetLeft:q,offsetTop:Q}=P(c,D),tt=s===r?10:20;_===s&&(p=Q+tt),_===r&&(g=Q+D.offsetHeight-tt),q<u&&(u=q),D.offsetWidth+q>h&&(h=D.offsetWidth+q)}let v,m;const f=p+10,b=g+10,x=(f+b)/2,N=e.theme.cssVar["--color"];a===L.LHS?(v=Ge(`M ${u+10} ${f} c -5 0 -10 5 -10 10 L ${u} ${b-10} c 0 5 5 10 10 10 M ${u} ${x} h -10`,N),m=Je(o,u-20,x+6,"end",N)):(v=Ge(`M ${h-10} ${f} c 5 0 10 5 10 10 L ${h} ${b-10} c 0 5 -5 10 -10 10 M ${h} ${x} h 10`,N),m=Je(o,h+20,x+6,"start",N));const y=pn("s-"+n);return y.appendChild(v),y.appendChild(m),y.summaryObj=t,e.summarySvg.appendChild(y),y},vn=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}=fn(e),i={id:U(),parent:t,start:n,end:o,text:"summary"},s=Ze(this,i);this.summaries.push(i),this.editSummary(s),this.bus.fire("operation",{name:"createSummary",obj:i})},editSummary:function(e){if(!e)return;const t=e.childNodes[1];_e(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}))})},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{Ze(this,e)}catch{}}),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"}),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"})),T="http://www.w3.org/2000/svg";function bn(e,t){const n=document.createElementNS(T,"svg");return C(n,{version:"1.1",xmlns:T,height:e,width:t}),n}function yn(e,t){return(parseInt(e)-parseInt(t))/2}function xn(e,t,n,o){const i=document.createElementNS(T,"g");let s="";return e.text?s=e.text.textContent:s=e.childNodes[0].textContent,s.split(`
23
- `).forEach((c,l)=>{const d=document.createElementNS(T,"text");C(d,{x:n+parseInt(t.paddingLeft)+"",y:o+parseInt(t.paddingTop)+yn(t.lineHeight,t.fontSize)*(l+1)+parseFloat(t.fontSize)*(l+1)+"","text-anchor":"start","font-family":t.fontFamily,"font-size":`${t.fontSize}`,"font-weight":`${t.fontWeight}`,fill:`${t.color}`}),d.innerHTML=c,i.appendChild(d)}),i}function wn(e,t,n,o){var c;let i="";(c=e.nodeObj)!=null&&c.dangerouslySetInnerHTML?i=e.nodeObj.dangerouslySetInnerHTML:e.text?i=e.text.textContent:i=e.childNodes[0].textContent;const s=document.createElementNS(T,"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 En(e,t){const n=getComputedStyle(t),{offsetLeft:o,offsetTop:i}=P(e.nodes,t),s=document.createElementNS(T,"rect");return C(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 ae(e,t,n=!1){const o=getComputedStyle(t),{offsetLeft:i,offsetTop:s}=P(e.nodes,t),r=document.createElementNS(T,"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 c=document.createElementNS(T,"g");c.appendChild(r);let l;return n?l=wn(t,o,i,s):l=xn(t,o,i,s),c.appendChild(l),c}function Nn(e,t){const n=getComputedStyle(t),{offsetLeft:o,offsetTop:i}=P(e.nodes,t),s=document.createElementNS(T,"a"),r=document.createElementNS(T,"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}function Cn(e,t){const n=getComputedStyle(t),{offsetLeft:o,offsetTop:i}=P(e.nodes,t),s=document.createElementNS(T,"image");return C(s,{x:o+"",y:i+"",width:n.width+"",height:n.height+"",href:t.src}),s}const de=100,Sn='<?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">',_n=(e,t=!1)=>{var u,h,p;const n=e.nodes,o=n.offsetHeight+de*2,i=n.offsetWidth+de*2,s=bn(o+"px",i+"px"),r=document.createElementNS(T,"svg"),c=document.createElementNS(T,"rect");C(c,{x:"0",y:"0",width:`${i}`,height:`${o}`,fill:e.theme.cssVar["--bgcolor"]}),s.appendChild(c),n.querySelectorAll(".subLines").forEach(g=>{const v=g.cloneNode(!0),{offsetLeft:m,offsetTop:f}=P(n,g.parentElement);v.setAttribute("x",`${m}`),v.setAttribute("y",`${f}`),r.appendChild(v)});const l=(u=n.querySelector(".lines"))==null?void 0:u.cloneNode(!0);l&&r.appendChild(l);const d=(h=n.querySelector(".topiclinks"))==null?void 0:h.cloneNode(!0);d&&r.appendChild(d);const a=(p=n.querySelector(".summary"))==null?void 0:p.cloneNode(!0);return a&&r.appendChild(a),n.querySelectorAll("me-tpc").forEach(g=>{g.nodeObj.dangerouslySetInnerHTML?r.appendChild(ae(e,g,!t)):(r.appendChild(En(e,g)),r.appendChild(ae(e,g.text,!t)))}),n.querySelectorAll(".tags > span").forEach(g=>{r.appendChild(ae(e,g))}),n.querySelectorAll(".icons > span").forEach(g=>{r.appendChild(ae(e,g))}),n.querySelectorAll(".hyper-link").forEach(g=>{r.appendChild(Nn(e,g))}),n.querySelectorAll("img").forEach(g=>{r.appendChild(Cn(e,g))}),C(r,{x:de+"",y:de+"",overflow:"visible"}),s.appendChild(r),s},Ln=(e,t)=>(t&&e.insertAdjacentHTML("afterbegin","<style>"+t+"</style>"),Sn+e.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 kn=Object.freeze(Object.defineProperty({__proto__:null,exportPng:async function(e=!1,t){const n=this.exportSvg(e,t),o=await Mn(n);return new Promise((i,s)=>{const r=new Image;r.setAttribute("crossOrigin","anonymous"),r.onload=()=>{const c=document.createElement("canvas");c.width=r.width,c.height=r.height,c.getContext("2d").drawImage(r,0,0),c.toBlob(i,"image/png",1)},r.src=o,r.onerror=s})},exportSvg:function(e=!1,t){const n=_n(this,e),o=Ln(n,t);return new Blob([o],{type:"image/svg+xml"})}},Symbol.toStringTag,{value:"Module"}));function Tn(e,t){return async function(...n){const o=this.before[t];o&&!await o.apply(this,n)||e.apply(this,n)}}const Qe=Object.keys(Ke),et={};for(let e=0;e<Qe.length;e++){const t=Qe[e];et[t]=Tn(Ke[t],t)}const An={getObjById:ne,generateNewObj:ot,layout:rt,linkDiv:mt,editTopic:ft,createWrapper:at,createParent:dt,createChildren:ht,createTopic:ut,findEle:S,changeTheme:Rt,...nn,...et,...un,...vn,...kn,init(e){if(e=JSON.parse(JSON.stringify(e)),!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,H(this.nodeData),this.arrows=e.arrows||[],this.summaries=e.summaries||[],this.tidyArrow(),this.toolBar&&Tt(this),this.keypress&&Et(this),this.editable&&Bt(this),this.contextMenu&&this.disposable.push(gt(this,this.contextMenuOption)),this.draggable&&St(this),this.allowUndo&&Lt(this),this.toCenter(),this.layout(),this.linkDiv()},destroy(){var e;this.disposable.forEach(t=>t()),this.mindElixirBox&&(this.mindElixirBox.innerHTML=""),this.mindElixirBox=void 0,this.nodeData=void 0,this.arrows=void 0,this.summaries=void 0,this.currentArrow=void 0,this.currentNode=void 0,this.currentNodes=void 0,this.currentSummary=void 0,this.waitCopy=void 0,this.theme=void 0,this.direction=void 0,this.bus=void 0,this.container=void 0,this.map=void 0,this.lines=void 0,this.linkController=void 0,this.linkSvgGroup=void 0,this.P2=void 0,this.P3=void 0,this.line1=void 0,this.line2=void 0,this.nodes=void 0,(e=this.selection)==null||e.destroy(),this.selection=void 0}};function $n({pT:e,pL:t,pW:n,pH:o,cT:i,cL:s,cW:r,cH:c,direction:l,containerHeight:d}){let a=t+n/2;const u=e+o/2;let h;l===L.LHS?h=s+r:h=s;const p=i+c/2,v=(1-Math.abs(p-u)/d)*.25*(n/2);return l===L.LHS?a=a-n/10-v:a=a+n/10+v,`M ${a} ${u} Q ${a} ${p} ${h} ${p}`}function jn({pT:e,pL:t,pW:n,pH:o,cT:i,cL:s,cW:r,cH:c,direction:l,isFirst:d}){const a=parseInt(this.container.style.getPropertyValue("--gap"));let u=0,h=0;d?u=e+o/2:u=e+o;const p=i+c;let g=0,v=0,m=0;const f=Math.abs(u-p)/300*a;return l===L.LHS?(m=t,g=m+a,v=m-a,h=s+a,`M ${g} ${u} C ${m} ${u} ${m+f} ${p} ${v} ${p} H ${h}`):(m=t+n,g=m-a,v=m+a,h=s+r-a,`M ${g} ${u} C ${m} ${u} ${m-f} ${p} ${v} ${p} H ${h}`)}const Dn="4.4.3",Z=document;function j({el:e,direction:t,locale:n,draggable:o,editable:i,contextMenu:s,contextMenuOption:r,toolBar:c,keypress:l,mouseSelectionButton:d,selectionContainer:a,before:u,newTopicName:h,allowUndo:p,generateMainBranch:g,generateSubBranch:v,overflowHidden:m,theme:f,alignment:b}){let x=null;const N=Object.prototype.toString.call(e);if(N==="[object HTMLDivElement]"?x=e:N==="[object String]"&&(x=document.querySelector(e)),!x)throw new Error("MindElixir: el is not a valid element");x.style.position="relative",x.innerHTML="",this.mindElixirBox=x,this.disposable=[],this.before=u||{},this.locale=n||"en",this.contextMenuOption=r,this.contextMenu=s===void 0?!0:s,this.toolBar=c===void 0?!0:c,this.keypress=l===void 0?!0:l,this.mouseSelectionButton=d||0,this.direction=typeof t=="number"?t:1,this.draggable=o===void 0?!0:o,this.newTopicName=h||"new node",this.editable=i===void 0?!0:i,this.allowUndo=p===void 0?!1:p,this.currentNode=null,this.currentArrow=null,this.scaleVal=1,this.tempDirection=null,this.generateMainBranch=g||$n,this.generateSubBranch=v||jn,this.overflowHidden=m||!1,this.bus=st.create(),this.container=Z.createElement("div"),this.selectionContainer=a||this.container,this.container.className="map-container";const y=window.matchMedia("(prefers-color-scheme: dark)");this.theme=f||(y.matches?Ee:we);const w=Z.createElement("div");w.className="map-canvas",this.map=w,this.map.setAttribute("tabindex","0"),this.container.appendChild(this.map),this.mindElixirBox.appendChild(this.container),this.nodes=Z.createElement("me-nodes"),this.nodes.className="main-node-container",this.lines=G("lines"),this.summarySvg=G("summary"),this.linkController=G("linkcontroller"),this.P2=Z.createElement("div"),this.P3=Z.createElement("div"),this.P2.className=this.P3.className="circle",this.P2.style.display=this.P3.style.display="none",this.line1=Se(),this.line2=Se(),this.linkController.appendChild(this.line1),this.linkController.appendChild(this.line2),this.linkSvgGroup=G("topiclinks"),this.alignment=b??"root",this.map.appendChild(this.nodes),this.overflowHidden?this.container.style.overflow="hidden":it(this)}return j.prototype=An,j.LEFT=$,j.RIGHT=O,j.SIDE=ee,j.THEME=we,j.DARK_THEME=Ee,j.version=Dn,j.E=S,j.new=e=>({nodeData:{id:U(),topic:e||"new topic",children:[]}}),j.dragMoveHelper=M,j}();
22
+ `,o[s].children&&n(o[s].children||[],i+1)}return n(e.children||[],2),t},getDataString:function(){const e=Ke(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.arrows=e.arrows||[],this.summaries=e.summaries||[]),H(this.nodeData),this.layout(),this.linkDiv()},scale:function(e){this.scaleVal=e,this.map.style.transform="scale("+e+")",this.bus.fire("scale",e)},scaleFit:function(){const e=this.nodes.offsetHeight/this.container.offsetHeight,t=this.nodes.offsetWidth/this.container.offsetWidth,n=1/Math.max(1,Math.max(e,t));this.scaleVal=n,this.map.style.transform="scale("+n+")",this.bus.fire("scale",n)},selectNode:function(e,t,n){if(e){if(this.clearSelection(),typeof e=="string"){const o=S(e);return o?this.selectNode(o):void 0}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)}},selectNodes:function(e){this.clearSelection();for(const t of e)t.className="selected";this.currentNodes=e,this.bus.fire("selectNodes",e.map(t=>t.nodeObj))},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"})),Ue={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 le(e,t,n){const{offsetLeft:o,offsetTop:i}=P(e.nodes,t),s=t.offsetWidth,r=t.offsetHeight,c=o+s/2,l=i+r/2,d=c+n.x,a=l+n.y;return{w:s,h:r,cx:c,cy:l,ctrlX:d,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 on=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},Ye=function(e,t,n,o,i){if(!t||!n)return;performance.now();const s=le(e,t,o.delta1),r=le(e,n,o.delta2),{x:c,y:l}=K(s),{ctrlX:d,ctrlY:a}=s,{ctrlX:u,ctrlY:h}=r,{x:p,y:g}=K(r),v=oe(u,h,p,g),m=`M ${v.x1} ${v.y1} L ${p} ${g} L ${v.x2} ${v.y2}`;let f="";if(o.bidirectional){const w=oe(d,a,c,l);f=`M ${w.x1} ${w.y1} L ${c} ${l} L ${w.x2} ${w.y2}`}const b=pt(`M ${c} ${l} C ${d} ${a} ${u} ${h} ${p} ${g}`,m,f),x=c/8+d*3/8+u*3/8+p/8,N=l/8+a*3/8+h*3/8+g/8,y=on(o.label,x,N,e.theme.cssVar["--color"]);b.appendChild(y),b.arrowObj=o,b.dataset.linkid=o.id,e.linkSvgGroup.appendChild(b),i||(e.arrows.push(o),e.currentArrow=b,Xe(e,o,s,r)),performance.now()},sn=function(e,t,n={}){const o={id:U(),label:"Custom Link",from:e.nodeObj.id,to:t.nodeObj.id,delta1:{x:0,y:-200},delta2:{x:0,y:-200},...n};Ye(this,e,t,o),this.bus.fire("operation",{name:"createArrow",obj:o})},rn=function(e){let t;if(e?t=e:t=this.currentArrow,!t)return;xe(this);const n=t.arrowObj.id;this.arrows=this.arrows.filter(o=>o.id!==n),t.remove(),this.bus.fire("operation",{name:"removeArrow",obj:{id:n}})},cn=function(e){this.currentArrow=e;const t=e.arrowObj,n=S(t.from),o=S(t.to),i=le(this,n,t.delta1),s=le(this,o,t.delta2);Xe(this,t,i,s)},ln=function(){this.currentArrow=null,xe(this)},xe=function(e){var t,n;(t=e.helper1)==null||t.destory(e.map),(n=e.helper2)==null||n.destory(e.map),e.linkController.style.display="none",e.P2.style.display="none",e.P3.style.display="none"},Xe=function(e,t,n,o){e.linkController.style.display="initial",e.P2.style.display="initial",e.P3.style.display="initial",e.nodes.appendChild(e.linkController),e.nodes.appendChild(e.P2),e.nodes.appendChild(e.P3);let{x:i,y:s}=K(n),{ctrlX:r,ctrlY:c}=n,{ctrlX:l,ctrlY:d}=o,{x:a,y:u}=K(o);e.P2.style.cssText=`top:${c}px;left:${r}px;`,e.P3.style.cssText=`top:${d}px;left:${l}px;`,C(e.line1,{x1:i+"",y1:s+"",x2:r+"",y2:c+""}),C(e.line2,{x1:l+"",y1:d+"",x2:a+"",y2:u+""}),e.helper1=Ue.create(e.P2),e.helper2=Ue.create(e.P3),e.helper1.init(e.map,(h,p)=>{if(!e.currentArrow)return;r=r+h/e.scaleVal,c=c+p/e.scaleVal;const g=K({...n,ctrlX:r,ctrlY:c});i=g.x,s=g.y;const v=i/8+r*3/8+l*3/8+a/8,m=s/8+c*3/8+d*3/8+u/8;if(e.P2.style.top=c+"px",e.P2.style.left=r+"px",e.currentArrow.children[0].setAttribute("d",`M ${i} ${s} C ${r} ${c} ${l} ${d} ${a} ${u}`),t.bidirectional){const f=oe(r,c,i,s);e.currentArrow.children[2].setAttribute("d",`M ${f.x1} ${f.y1} L ${i} ${s} L ${f.x2} ${f.y2}`)}C(e.currentArrow.children[3],{x:v+"",y:m+""}),C(e.line1,{x1:i+"",y1:s+"",x2:r+"",y2:c+""}),t.delta1.x=r-n.cx,t.delta1.y=c-n.cy,e.bus.fire("updateArrowDelta",t)}),e.helper2.init(e.map,(h,p)=>{if(!e.currentArrow)return;l=l+h/e.scaleVal,d=d+p/e.scaleVal;const g=K({...o,ctrlX:l,ctrlY:d});a=g.x,u=g.y;const v=i/8+r*3/8+l*3/8+a/8,m=s/8+c*3/8+d*3/8+u/8,f=oe(l,d,a,u);e.P3.style.top=d+"px",e.P3.style.left=l+"px",e.currentArrow.children[0].setAttribute("d",`M ${i} ${s} C ${r} ${c} ${l} ${d} ${a} ${u}`),e.currentArrow.children[1].setAttribute("d",`M ${f.x1} ${f.y1} L ${a} ${u} L ${f.x2} ${f.y2}`),C(e.currentArrow.children[3],{x:v+"",y:m+""}),C(e.line2,{x1:l+"",y1:d+"",x2:a+"",y2:u+""}),t.delta2.x=l-o.cx,t.delta2.y=d-o.cy,e.bus.fire("updateArrowDelta",t)})};function an(){this.linkSvgGroup.innerHTML="";for(let e=0;e<this.arrows.length;e++){const t=this.arrows[e];try{Ye(this,S(t.from),S(t.to),t,!0)}catch{}}this.nodes.appendChild(this.linkSvgGroup)}function dn(e){if(xe(this),!e)return;const t=e.children[3];_e(this,t,n=>{var s;const o=e.arrowObj,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:"finishEditArrowLabel",obj:o}))})}function hn(){this.arrows=this.arrows.filter(e=>ne(e.from,this.nodeData)&&ne(e.to,this.nodeData))}const un=Object.freeze(Object.defineProperty({__proto__:null,createArrow:sn,editArrowLabel:dn,removeArrow:rn,renderArrow:an,selectArrow:cn,tidyArrow:hn,unselectArrow:ln},Symbol.toStringTag,{value:"Module"})),fn=function(e){var l,d;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 h=u.children.findIndex(p=>a===p);return{parent:u.id,start:h,end:h}}let t=0;const n=e.map(a=>{let u=a.nodeObj;const h=[];for(;u.parent;){const p=u.parent,g=p.children,v=g==null?void 0:g.indexOf(u);u=p,h.unshift({node:u,index:v})}return h.length>t&&(t=h.length),h});let o=0;e:for(;o<t;o++){const a=(l=n[0][o])==null?void 0:l.node;for(let u=1;u<n.length;u++)if(((d=n[u][o])==null?void 0:d.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,c=n[0][o-1].node;if(!c.parent)throw new Error("Please select nodes in the same main topic.");return{parent:c.id,start:s,end:r}},pn=function(e){const t=document.createElementNS("http://www.w3.org/2000/svg","g");return t.setAttribute("id",e),t},Ge=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},Je=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},mn=e=>S(e).parentElement.parentElement,gn=function({parent:e,start:t}){const n=S(e),o=n.nodeObj;let i;return o.parent?i=n.closest("me-main").className:i=S(o.children[t].id).closest("me-main").className,i},Ze=function(e,t){var w;const{id:n,text:o,parent:i,start:s,end:r}=t,c=e.nodes,d=S(i).nodeObj,a=gn(t);let u=1/0,h=0,p=0,g=0;for(let _=s;_<=r;_++){const A=(w=d.children)==null?void 0:w[_];if(!A)return e.removeSummary(n),null;const D=mn(A.id),{offsetLeft:q,offsetTop:Q}=P(c,D),tt=s===r?10:20;_===s&&(p=Q+tt),_===r&&(g=Q+D.offsetHeight-tt),q<u&&(u=q),D.offsetWidth+q>h&&(h=D.offsetWidth+q)}let v,m;const f=p+10,b=g+10,x=(f+b)/2,N=e.theme.cssVar["--color"];a===L.LHS?(v=Ge(`M ${u+10} ${f} c -5 0 -10 5 -10 10 L ${u} ${b-10} c 0 5 5 10 10 10 M ${u} ${x} h -10`,N),m=Je(o,u-20,x+6,"end",N)):(v=Ge(`M ${h-10} ${f} c 5 0 10 5 10 10 L ${h} ${b-10} c 0 5 -5 10 -10 10 M ${h} ${x} h 10`,N),m=Je(o,h+20,x+6,"start",N));const y=pn("s-"+n);return y.appendChild(v),y.appendChild(m),y.summaryObj=t,e.summarySvg.appendChild(y),y},vn=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}=fn(e),i={id:U(),parent:t,start:n,end:o,text:"summary"},s=Ze(this,i);this.summaries.push(i),this.editSummary(s),this.bus.fire("operation",{name:"createSummary",obj:i})},editSummary:function(e){if(!e)return;const t=e.childNodes[1];_e(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}))})},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{Ze(this,e)}catch{}}),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"}),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"})),T="http://www.w3.org/2000/svg";function bn(e,t){const n=document.createElementNS(T,"svg");return C(n,{version:"1.1",xmlns:T,height:e,width:t}),n}function yn(e,t){return(parseInt(e)-parseInt(t))/2}function xn(e,t,n,o){const i=document.createElementNS(T,"g");let s="";return e.text?s=e.text.textContent:s=e.childNodes[0].textContent,s.split(`
23
+ `).forEach((c,l)=>{const d=document.createElementNS(T,"text");C(d,{x:n+parseInt(t.paddingLeft)+"",y:o+parseInt(t.paddingTop)+yn(t.lineHeight,t.fontSize)*(l+1)+parseFloat(t.fontSize)*(l+1)+"","text-anchor":"start","font-family":t.fontFamily,"font-size":`${t.fontSize}`,"font-weight":`${t.fontWeight}`,fill:`${t.color}`}),d.innerHTML=c,i.appendChild(d)}),i}function wn(e,t,n,o){var c;let i="";(c=e.nodeObj)!=null&&c.dangerouslySetInnerHTML?i=e.nodeObj.dangerouslySetInnerHTML:e.text?i=e.text.textContent:i=e.childNodes[0].textContent;const s=document.createElementNS(T,"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 En(e,t){const n=getComputedStyle(t),{offsetLeft:o,offsetTop:i}=P(e.nodes,t),s=document.createElementNS(T,"rect");return C(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 ae(e,t,n=!1){const o=getComputedStyle(t),{offsetLeft:i,offsetTop:s}=P(e.nodes,t),r=document.createElementNS(T,"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 c=document.createElementNS(T,"g");c.appendChild(r);let l;return n?l=wn(t,o,i,s):l=xn(t,o,i,s),c.appendChild(l),c}function Nn(e,t){const n=getComputedStyle(t),{offsetLeft:o,offsetTop:i}=P(e.nodes,t),s=document.createElementNS(T,"a"),r=document.createElementNS(T,"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}function Cn(e,t){const n=getComputedStyle(t),{offsetLeft:o,offsetTop:i}=P(e.nodes,t),s=document.createElementNS(T,"image");return C(s,{x:o+"",y:i+"",width:n.width+"",height:n.height+"",href:t.src}),s}const de=100,Sn='<?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">',_n=(e,t=!1)=>{var u,h,p;const n=e.nodes,o=n.offsetHeight+de*2,i=n.offsetWidth+de*2,s=bn(o+"px",i+"px"),r=document.createElementNS(T,"svg"),c=document.createElementNS(T,"rect");C(c,{x:"0",y:"0",width:`${i}`,height:`${o}`,fill:e.theme.cssVar["--bgcolor"]}),s.appendChild(c),n.querySelectorAll(".subLines").forEach(g=>{const v=g.cloneNode(!0),{offsetLeft:m,offsetTop:f}=P(n,g.parentElement);v.setAttribute("x",`${m}`),v.setAttribute("y",`${f}`),r.appendChild(v)});const l=(u=n.querySelector(".lines"))==null?void 0:u.cloneNode(!0);l&&r.appendChild(l);const d=(h=n.querySelector(".topiclinks"))==null?void 0:h.cloneNode(!0);d&&r.appendChild(d);const a=(p=n.querySelector(".summary"))==null?void 0:p.cloneNode(!0);return a&&r.appendChild(a),n.querySelectorAll("me-tpc").forEach(g=>{g.nodeObj.dangerouslySetInnerHTML?r.appendChild(ae(e,g,!t)):(r.appendChild(En(e,g)),r.appendChild(ae(e,g.text,!t)))}),n.querySelectorAll(".tags > span").forEach(g=>{r.appendChild(ae(e,g))}),n.querySelectorAll(".icons > span").forEach(g=>{r.appendChild(ae(e,g))}),n.querySelectorAll(".hyper-link").forEach(g=>{r.appendChild(Nn(e,g))}),n.querySelectorAll("img").forEach(g=>{r.appendChild(Cn(e,g))}),C(r,{x:de+"",y:de+"",overflow:"visible"}),s.appendChild(r),s},Ln=(e,t)=>(t&&e.insertAdjacentHTML("afterbegin","<style>"+t+"</style>"),Sn+e.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 kn=Object.freeze(Object.defineProperty({__proto__:null,exportPng:async function(e=!1,t){const n=this.exportSvg(e,t),o=await Mn(n);return new Promise((i,s)=>{const r=new Image;r.setAttribute("crossOrigin","anonymous"),r.onload=()=>{const c=document.createElement("canvas");c.width=r.width,c.height=r.height,c.getContext("2d").drawImage(r,0,0),c.toBlob(i,"image/png",1)},r.src=o,r.onerror=s})},exportSvg:function(e=!1,t){const n=_n(this,e),o=Ln(n,t);return new Blob([o],{type:"image/svg+xml"})}},Symbol.toStringTag,{value:"Module"}));function Tn(e,t){return async function(...n){const o=this.before[t];o&&!await o.apply(this,n)||e.apply(this,n)}}const Qe=Object.keys(Ie),et={};for(let e=0;e<Qe.length;e++){const t=Qe[e];et[t]=Tn(Ie[t],t)}const An={getObjById:ne,generateNewObj:ot,layout:rt,linkDiv:mt,editTopic:ft,createWrapper:at,createParent:dt,createChildren:ht,createTopic:ut,findEle:S,changeTheme:Rt,...nn,...et,...un,...vn,...kn,init(e){if(e=JSON.parse(JSON.stringify(e)),!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,H(this.nodeData),this.arrows=e.arrows||[],this.summaries=e.summaries||[],this.tidyArrow(),this.toolBar&&Tt(this),this.keypress&&Et(this),this.editable&&Bt(this),this.contextMenu&&this.disposable.push(gt(this,this.contextMenuOption)),this.draggable&&St(this),this.allowUndo&&Lt(this),this.toCenter(),this.layout(),this.linkDiv()},destroy(){var e;this.disposable.forEach(t=>t()),this.mindElixirBox&&(this.mindElixirBox.innerHTML=""),this.mindElixirBox=void 0,this.nodeData=void 0,this.arrows=void 0,this.summaries=void 0,this.currentArrow=void 0,this.currentNode=void 0,this.currentNodes=void 0,this.currentSummary=void 0,this.waitCopy=void 0,this.theme=void 0,this.direction=void 0,this.bus=void 0,this.container=void 0,this.map=void 0,this.lines=void 0,this.linkController=void 0,this.linkSvgGroup=void 0,this.P2=void 0,this.P3=void 0,this.line1=void 0,this.line2=void 0,this.nodes=void 0,(e=this.selection)==null||e.destroy(),this.selection=void 0}};function $n({pT:e,pL:t,pW:n,pH:o,cT:i,cL:s,cW:r,cH:c,direction:l,containerHeight:d}){let a=t+n/2;const u=e+o/2;let h;l===L.LHS?h=s+r:h=s;const p=i+c/2,v=(1-Math.abs(p-u)/d)*.25*(n/2);return l===L.LHS?a=a-n/10-v:a=a+n/10+v,`M ${a} ${u} Q ${a} ${p} ${h} ${p}`}function jn({pT:e,pL:t,pW:n,pH:o,cT:i,cL:s,cW:r,cH:c,direction:l,isFirst:d}){const a=parseInt(this.container.style.getPropertyValue("--gap"));let u=0,h=0;d?u=e+o/2:u=e+o;const p=i+c;let g=0,v=0,m=0;const f=Math.abs(u-p)/300*a;return l===L.LHS?(m=t,g=m+a,v=m-a,h=s+a,`M ${g} ${u} C ${m} ${u} ${m+f} ${p} ${v} ${p} H ${h}`):(m=t+n,g=m-a,v=m+a,h=s+r-a,`M ${g} ${u} C ${m} ${u} ${m-f} ${p} ${v} ${p} H ${h}`)}const Dn="4.5.0",Z=document;function j({el:e,direction:t,locale:n,draggable:o,editable:i,contextMenu:s,contextMenuOption:r,toolBar:c,keypress:l,mouseSelectionButton:d,selectionContainer:a,before:u,newTopicName:h,allowUndo:p,generateMainBranch:g,generateSubBranch:v,overflowHidden:m,theme:f,alignment:b}){let x=null;const N=Object.prototype.toString.call(e);if(N==="[object HTMLDivElement]"?x=e:N==="[object String]"&&(x=document.querySelector(e)),!x)throw new Error("MindElixir: el is not a valid element");x.style.position="relative",x.innerHTML="",this.mindElixirBox=x,this.disposable=[],this.before=u||{},this.locale=n||"en",this.contextMenuOption=r,this.contextMenu=s===void 0?!0:s,this.toolBar=c===void 0?!0:c,this.keypress=l===void 0?!0:l,this.mouseSelectionButton=d||0,this.direction=typeof t=="number"?t:1,this.draggable=o===void 0?!0:o,this.newTopicName=h||"new node",this.editable=i===void 0?!0:i,this.allowUndo=p===void 0?!1:p,this.currentNode=null,this.currentArrow=null,this.scaleVal=1,this.tempDirection=null,this.generateMainBranch=g||$n,this.generateSubBranch=v||jn,this.overflowHidden=m||!1,this.bus=st.create(),this.container=Z.createElement("div"),this.selectionContainer=a||this.container,this.container.className="map-container";const y=window.matchMedia("(prefers-color-scheme: dark)");this.theme=f||(y.matches?Ee:we);const w=Z.createElement("div");w.className="map-canvas",this.map=w,this.map.setAttribute("tabindex","0"),this.container.appendChild(this.map),this.mindElixirBox.appendChild(this.container),this.nodes=Z.createElement("me-nodes"),this.nodes.className="main-node-container",this.lines=G("lines"),this.summarySvg=G("summary"),this.linkController=G("linkcontroller"),this.P2=Z.createElement("div"),this.P3=Z.createElement("div"),this.P2.className=this.P3.className="circle",this.P2.style.display=this.P3.style.display="none",this.line1=Se(),this.line2=Se(),this.linkController.appendChild(this.line1),this.linkController.appendChild(this.line2),this.linkSvgGroup=G("topiclinks"),this.alignment=b??"root",this.map.appendChild(this.nodes),this.overflowHidden?this.container.style.overflow="hidden":it(this)}return j.prototype=An,j.LEFT=$,j.RIGHT=O,j.SIDE=ee,j.THEME=we,j.DARK_THEME=Ee,j.version=Dn,j.E=S,j.new=e=>({nodeData:{id:U(),topic:e||"new topic",children:[]}}),j.dragMoveHelper=M,j}();