mind-elixir 4.6.1 → 4.6.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/MindElixir.iife.js
CHANGED
|
@@ -14,10 +14,10 @@ var MindElixir=function(){"use strict";const Dn="";(function(e){var t,n,o,s,i,r,
|
|
|
14
14
|
margin: -2px -4px;
|
|
15
15
|
`,o.focus(),Se(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)})},pt=function(e){const t=this.map.querySelector("me-root"),n=t.offsetTop,o=t.offsetLeft,s=t.offsetWidth,i=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-s/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:s,pH:i,cT:p,cL:h,cW:g,cH:v,direction:m,containerHeight:this.nodes.offsetHeight}),y=this.theme.palette,x=u.nodeObj.branchColor||y[d%y.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 b=G("subLines"),w=a.lastChild;w.tagName==="svg"&&w.remove(),a.appendChild(b),Me(this,b,x,a,m,!0)}this.renderArrow(),this.renderSummary(),this.bus.fire("linkDiv")},Me=function(e,t,n,o,s,i){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,y=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:y,direction:s,isFirst:i});t.appendChild(Ce(N,x,"2"));const b=g.children[1];if(b){if(b.style.bottom=-(b.offsetHeight/2)+"px",s===L.LHS?b.style.left="10px":s===L.RHS&&(b.style.right="10px"),!b.expanded)continue}else continue;Me(e,t,x,p,s)}},ke={addChild:"插入子节点",addParent:"插入父节点",addSibling:"插入同级节点",removeNode:"删除节点",focus:"专注",cancelFocus:"取消专注",moveUp:"上移",moveDown:"下移",link:"连接",clickTips:"请点击目标节点",summary:"摘要"},Te={cn:ke,zh_CN:ke,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:"요약"}},On="";function mt(e,t){t=t===!0?{focus:!0,link:!0}:t;const n=b=>{const w=document.createElement("div");return w.innerText=b,w.className="tips",w},o=(b,w,_)=>{const A=document.createElement("li");return A.id=b,A.innerHTML=`<span>${te(w)}</span><span ${_?'class="key"':""}>${te(_)}</span>`,A},s=Te[e.locale]?e.locale:"en",i=Te[s],r=o("cm-add_child",i.addChild,"Tab"),c=o("cm-add_parent",i.addParent,"Ctrl + Enter"),l=o("cm-add_sibling",i.addSibling,"Enter"),d=o("cm-remove_child",i.removeNode,"Delete"),a=o("cm-fucus",i.focus,""),u=o("cm-unfucus",i.cancelFocus,""),h=o("cm-up",i.moveUp,"PgUp"),p=o("cm-down",i.moveDown,"Pgdn"),g=o("cm-link",i.link,""),v=o("cm-link-bidirectional","Bidirectional Link",""),m=o("cm-summary",i.summary,""),f=document.createElement("ul");if(f.className="menu-list",f.appendChild(r),f.appendChild(c),f.appendChild(l),f.appendChild(d),t.focus&&(f.appendChild(a),f.appendChild(u)),f.appendChild(h),f.appendChild(p),f.appendChild(m),t.link&&(f.appendChild(g),f.appendChild(v)),t&&t.extend)for(let b=0;b<t.extend.length;b++){const w=t.extend[b],_=o(w.name,w.name,w.key||"");f.appendChild(_),_.onclick=A=>{w.onclick(A)}}const y=document.createElement("div");y.className="context-menu",y.appendChild(f),y.hidden=!0,e.container.append(y);let x=!0;e.container.oncontextmenu=function(b){if(b.preventDefault(),!e.editable||M.moved)return;const w=b.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),y.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=b.clientY-_.top,Q=b.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")}},y.onclick=b=>{b.target===y&&(y.hidden=!0)},r.onclick=()=>{e.addChild(),y.hidden=!0},c.onclick=()=>{e.insertParent(),y.hidden=!0},l.onclick=()=>{x||(e.insertSibling("after"),y.hidden=!0)},d.onclick=()=>{x||(e.removeNode(),y.hidden=!0)},a.onclick=()=>{x||(e.focusNode(e.currentNode),y.hidden=!0)},u.onclick=()=>{e.cancelFocus(),y.hidden=!0},h.onclick=()=>{x||(e.moveUpNode(),y.hidden=!0)},p.onclick=()=>{x||(e.moveDownNode(),y.hidden=!0)};const N=b=>{y.hidden=!0;const w=e.currentNode,_=n(i.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,b)},{once:!0})};return g.onclick=()=>N(),v.onclick=()=>N({bidirectional:!0}),m.onclick=()=>{y.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,y.onclick=null,e.container.oncontextmenu=null}}const gt=e=>{const t=e.map.querySelectorAll(".lhs>me-wrapper>me-parent>me-tpc");e.selectNode(t[Math.ceil(t.length/2)-1])},vt=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"))},bt=function(e,t){const n=t.parentElement.parentElement.parentElement.previousSibling;if(n){const o=n.firstChild;e.selectNode(o)}},xt=function(e,t){const n=t.parentElement.nextSibling;if(n&&n.firstChild){const o=n.firstChild.firstChild.firstChild;e.selectNode(o)}},Ae=function(e,t){var i,r;const n=e.currentNode||((i=e.currentNodes)==null?void 0:i[0]);if(!n)return;const o=n.nodeObj,s=n.offsetParent.offsetParent.parentElement;o.parent?s.className===t?xt(e,n):(r=o.parent)!=null&&r.parent?bt(e,n):yt(e):t===L.LHS?gt(e):vt(e)},$e=function(e,t){var r;const n=e.currentNode||((r=e.currentNodes)==null?void 0:r[0]);if(!n||!n.nodeObj.parent)return;const s=t+"Sibling",i=n.parentElement.parentElement[s];i&&e.selectNode(i.firstChild.firstChild)},re=function(e,t){switch(t){case"in":if(e.scaleVal>1.6)return;e.scale(e.scaleVal+=e.scaleSensitivity);break;case"out":if(e.scaleVal<.6)return;e.scale(e.scaleVal-=e.scaleSensitivity)}};function wt(e,t){t=t===!0?{}:t;const n=()=>{e.currentArrow?e.removeArrow():e.currentSummary?e.removeSummary(e.currentSummary.summaryObj.id):e.currentNode?e.removeNode():e.currentNodes&&e.removeNodes(e.currentNodes)},o={Enter:s=>{s.shiftKey?e.insertSibling("before"):s.ctrlKey?e.insertParent():e.insertSibling("after")},Tab:()=>{e.addChild()},F1:()=>{e.toCenter()},F2:()=>{e.beginEdit()},ArrowUp:s=>{if(s.altKey)e.moveUpNode();else{if(s.metaKey||s.ctrlKey)return e.initSide();$e(e,"previous")}},ArrowDown:s=>{s.altKey?e.moveDownNode():$e(e,"next")},ArrowLeft:s=>{if(s.metaKey||s.ctrlKey)return e.initLeft();Ae(e,L.LHS)},ArrowRight:s=>{if(s.metaKey||s.ctrlKey)return e.initRight();Ae(e,L.RHS)},PageUp:()=>e.moveUpNode(),PageDown:()=>{e.moveDownNode()},c:s=>{(s.metaKey||s.ctrlKey)&&(e.currentNode?e.waitCopy=[e.currentNode]:e.currentNodes&&(e.waitCopy=e.currentNodes))},x:s=>{(s.metaKey||s.ctrlKey)&&(e.currentNode?e.waitCopy=[e.currentNode]:e.currentNodes&&(e.waitCopy=e.currentNodes),n())},v:s=>{!e.waitCopy||!e.currentNode||(s.metaKey||s.ctrlKey)&&(e.waitCopy.length===1?e.copyNode(e.waitCopy[0],e.currentNode):e.copyNodes(e.waitCopy,e.currentNode))},"+":s=>{(s.metaKey||s.ctrlKey)&&re(e,"in")},"-":s=>{(s.metaKey||s.ctrlKey)&&re(e,"out")},0:s=>{(s.metaKey||s.ctrlKey)&&e.scale(1)},Delete:n,Backspace:n,...t};e.map.onkeydown=s=>{if(s.preventDefault(),!e.editable||s.target!==s.currentTarget)return;const i=o[s.key];i&&i(s)},e.map.onwheel=s=>{(s.ctrlKey||s.metaKey)&&(s.preventDefault(),s.deltaY<0?re(e,"in"):e.scaleVal-e.scaleSensitivity>0&&re(e,"out"),s.stopPropagation())}}const ge=document,Et=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()},je=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},Nt=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 s=Nt(e),i=12;e.map.addEventListener("dragstart",r=>{var l;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,s.innerHTML=e.currentNodes.length+""):(t=[c],s.innerHTML=c.innerHTML);for(const d of t)d.parentElement.parentElement.style.opacity="0.5";r.dataTransfer.setDragImage(s,0,0),r.dataTransfer.dropEffect="move",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",function(r){if(r.preventDefault(),!t)return;ve(o);const c=ge.elementFromPoint(r.clientX,r.clientY-i);if(je(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+i);if(je(l,t)){o=l;const d=l.getBoundingClientRect().y;r.clientY<d?n="before":n="in"}else n=o=null}o&&Et(o,n)})}const Ct=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 _t(e){let t=[],n=-1,o=e.getData();e.bus.addListener("operation",s=>{if(s.name==="beginEdit")return;t=t.slice(0,n+1);const i=e.getData();t.push({prev:o,currentObject:Ct(s),next:i}),o=i,n=t.length-1}),e.undo=function(){if(n>-1){const s=t[n];o=s.prev,e.refresh(s.prev);try{s.currentObject.type==="node"?e.selectNode(C(s.currentObject.value)):s.currentObject.type==="nodes"&&e.selectNodes(s.currentObject.value.map(i=>C(i)))}catch{}finally{n--}}},e.redo=function(){if(n<t.length-1){n++;const s=t[n];o=s.next,e.refresh(s.next),s.currentObject.type==="node"?e.selectNode(C(s.currentObject.value)):s.currentObject.type==="nodes"&&e.selectNodes(s.currentObject.value.map(i=>C(i)))}},e.map.addEventListener("keydown",s=>{(s.metaKey||s.ctrlKey)&&(s.shiftKey&&s.key==="Z"||s.key==="y")?e.redo():(s.metaKey||s.ctrlKey)&&s.key==="z"&&e.undo()})}const Hn="",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 Lt(e){const t=document.createElement("div"),n=z("fullscreen","full"),o=z("toCenter","living"),s=z("zoomout","move"),i=z("zoomin","add"),r=document.createElement("span");return r.innerText="100%",t.appendChild(n),t.appendChild(o),t.appendChild(s),t.appendChild(i),t.className="mind-elixir-toolbar rb",n.onclick=()=>{document.fullscreenElement===e.el?document.exitFullscreen():e.el.requestFullscreen()},o.onclick=()=>{e.toCenter()},s.onclick=()=>{e.scaleVal<.6||e.scale(e.scaleVal-e.scaleSensitivity)},i.onclick=()=>{e.scaleVal>1.6||e.scale(e.scaleVal+e.scaleSensitivity)},t}function Mt(e){const t=document.createElement("div"),n=z("tbltl","left"),o=z("tbltr","right"),s=z("tblts","side");return t.appendChild(n),t.appendChild(o),t.appendChild(s),t.className="mind-elixir-toolbar lt",n.onclick=()=>{e.initLeft()},o.onclick=()=>{e.initRight()},s.onclick=()=>{e.initSide()},t}function kt(e){e.container.append(Lt(e)),e.container.append(Mt(e))}/*! @viselect/vanilla v3.5.1 MIT | https://github.com/Simonwep/selection/tree/master/packages/vanilla */var Tt=Object.defineProperty,At=(e,t,n)=>t in e?Tt(e,t,{enumerable:!0,configurable:!0,writable:!0,value:n}):e[t]=n,E=(e,t,n)=>(At(e,typeof t!="symbol"?t+"":t,n),n);class $t{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 s of this._listeners.get(t)??[])o=s(...n)!==!1&&o;return o}unbindAllListeners(){this._listeners.clear()}}const De=(e,t="px")=>typeof e=="number"?e+t:e;function B({style:e},t,n){if(typeof t=="object")for(const[o,s]of Object.entries(t))s!==void 0&&(e[o]=De(s));else n!==void 0&&(e[t]=De(n))}const Oe=e=>(t,n,o,s={})=>{t instanceof HTMLCollection||t instanceof NodeList?t=Array.from(t):Array.isArray(t)||(t=[t]),Array.isArray(n)||(n=[n]);for(const i of t)if(i)for(const r of n)i[e](r,o,{capture:!1,...s});return[t,n,o,s]},W=Oe("addEventListener"),R=Oe("removeEventListener"),ce=e=>{var t;const{clientX:n,clientY:o,target:s}=((t=e.touches)==null?void 0:t[0])??e;return{x:n,y:o,target:s}};function He(e,t,n="touch"){switch(n){case"center":{const o=t.left+t.width/2,s=t.top+t.height/2;return o>=e.left&&o<=e.right&&s>=e.top&&s<=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 K(e,t=document){const n=Array.isArray(e)?e:[e];let o=[];for(let s=0,i=n.length;s<i;s++){const r=n[s];typeof r=="string"?o=o.concat(Array.from(t.querySelectorAll(r))):r instanceof Element&&o.push(r)}return o}const jt=()=>matchMedia("(hover: none), (pointer: coarse)").matches,Dt=()=>"safari"in window,Ot=e=>{let t,n=-1,o=!1;return{next(...s){t=s,o||(o=!0,n=requestAnimationFrame(()=>{e(...t),o=!1}))},cancel(){cancelAnimationFrame(n),o=!1}}};function Ht(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,s=n.modifiers.every(i=>{switch(i){case"alt":return e.altKey;case"ctrl":return e.ctrlKey||e.metaKey;case"shift":return e.shiftKey}});return o&&s}}return!1}const{abs:F,max:Pe,min:Be,ceil:Re}=Math;class ze extends $t{constructor(t){var n,o,s,i,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,...(i=(s=t.behaviour)==null?void 0:s.scrolling)==null?void 0:i.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=Ot(a=>{this._recalculateSelectionAreaRect(),this._updateElementSelection(),this._emitEvent("move",a),this._redrawSelectionArea()}),this.enable()}_bindStartEvents(t=!0){const{document:n,features:o}=this._options,s=t?W:R;s(n,"mousedown",this._onTapStart),o.touch&&s(n,"touchstart",this._onTapStart,{passive:!1})}_onTapStart(t,n=!1){const{x:o,y:s,target:i}=ce(t),{_options:r}=this,{document:c}=this._options,l=i.getBoundingClientRect();if(t instanceof MouseEvent&&!Ht(t,r.behaviour.triggers))return;const d=K(r.startAreas,r.document),a=K(r.boundaries,r.document);this._targetElement=a.find(p=>He(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:s,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),W(c,["touchmove","mousemove"],this._delayedTapMove,{passive:!1}),W(c,["mouseup","touchcancel","touchend"],this._onTapStop),W(c,"scroll",this._onScroll)}_onSingleTap(t){const{singleTap:{intersect:n},range:o}=this._options.features,s=ce(t);let i;if(n==="native")i=s.target;else if(n==="touch"){this.resolveSelectables();const{x:c,y:l}=s;i=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(!i)return;for(this.resolveSelectables();!this._selectables.includes(i);){if(!i.parentElement)return;i=i.parentElement}const{stored:r}=this._selection;if(this._emitEvent("start",t),t.shiftKey&&o&&this._latestElement){const c=this._latestElement,[l,d]=c.compareDocumentPosition(i)&4?[i,c]:[c,i],a=[...this._selectables.filter(u=>u.compareDocumentPosition(l)&4&&u.compareDocumentPosition(d)&2),l,d];this.select(a),this._latestElement=c}else r.includes(i)&&(r.length===1||t.ctrlKey||r.every(c=>this._selection.stored.includes(c)))?this.deselect(i):(this.select(i),this._latestElement=i)}_delayedTapMove(t){const{container:n,document:o,behaviour:{startThreshold:s}}=this._options,{x1:i,y1:r}=this._areaLocation,{x:c,y:l}=ce(t);if(typeof s=="number"&&F(c+l-(i+r))>=s||typeof s=="object"&&F(c-i)>=s.x||F(l-r)>=s.y){if(R(o,["mousemove","touchmove"],this._delayedTapMove,{passive:!1}),this._emitEvent("beforedrag",t)===!1){R(o,["mouseup","touchcancel","touchend"],this._onTapStop);return}W(o,["mousemove","touchmove"],this._onTapMove,{passive:!1}),B(this._area,"display","block"),K(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&&(W(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,s=this._targetRect=n.getBoundingClientRect();this._scrollAvailable?(B(t,{top:s.top,left:s.left,width:s.width,height:s.height}),B(o,{marginTop:-s.top,marginLeft:-s.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:s,_areaLocation:i,_options:r,_frame:c}=this,{speedDivider:l}=r.behaviour.scrolling,d=this._targetElement;if(i.x2=n,i.y2=o,this._scrollAvailable&&!this._scrollingActive&&(s.y||s.x)){this._scrollingActive=!0;const a=()=>{if(!s.x&&!s.y){this._scrollingActive=!1;return}const{scrollTop:u,scrollLeft:h}=d;s.y&&(d.scrollTop+=Re(s.y/l),i.y1-=d.scrollTop-u),s.x&&(d.scrollLeft+=Re(s.x/l),i.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&&jt()||this._scrollAvailable&&Dt())&&t.preventDefault()}_onScroll(){const{_scrollDelta:t,_options:{document:n}}=this,{scrollTop:o,scrollLeft:s}=n.scrollingElement??n.body;this._areaLocation.x1+=t.x-s,this._areaLocation.y1+=t.y-o,t.x=s,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,s=t.deltaX?t.deltaX>0?1:-1:0;this._scrollSpeed.y+=o*n,this._scrollSpeed.x+=s*n,this._onTapMove(t),t.preventDefault()}_recalculateSelectionAreaRect(){const{_scrollSpeed:t,_areaLocation:n,_areaRect:o,_targetElement:s,_options:i}=this,{scrollTop:r,scrollHeight:c,clientHeight:l,scrollLeft:d,scrollWidth:a,clientWidth:u}=s,h=this._targetRect,{x1:p,y1:g}=n;let{x2:v,y2:m}=n;const{behaviour:{scrolling:{startScrollMargins:f}}}=i;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 y=Be(p,v),x=Be(g,m),N=Pe(p,v),b=Pe(g,m);o.x=y,o.y=x,o.width=N-y,o.height=b-x}_redrawSelectionArea(){const{x:t,y:n,width:o,height:s}=this._areaRect,{style:i}=this._area;i.left=`${t}px`,i.top=`${n}px`,i.width=`${o}px`,i.height=`${s}px`}_onTapStop(t,n){var o;const{document:s,features:i}=this._options,{_singleClick:r}=this;R(s,["mousemove","touchmove"],this._delayedTapMove),R(s,["touchmove","mousemove"],this._onTapMove),R(s,["mouseup","touchcancel","touchend"],this._onTapStop),R(s,"scroll",this._onScroll),this._keepSelection(),t&&r&&i.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:s}=this,{stored:i,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(He(s,m.getBoundingClientRect(),l)){if(r.includes(m))i.includes(m)&&!c.includes(m)&&c.push(m);else if(a&&i.includes(m)){p.push(m);continue}else h.push(m);u.push(m)}}a&&h.push(...i.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&&i.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:s,touched:i,stored:r}=n,c=o.filter(l=>!r.includes(l));switch(t.behaviour.overlap){case"drop":{n.stored=[...c,...r.filter(l=>!i.includes(l))];break}case"invert":{n.stored=[...c,...r.filter(l=>!s.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=K(this._options.selectables,this._options.document)}clearSelection(t=!0,n=!1){const{selected:o,stored:s,changed:i}=this._selection;i.added=[],i.removed.push(...o,...t?s:[]),n||(this._emitEvent("move",null),this._emitEvent("stop",null)),this._selection={stored:t?[]:s,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:s,stored:i}=this._selection,r=K(t,this._options.document).filter(c=>!s.includes(c)&&!i.includes(c));return i.push(...r),s.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:s,changed:i}=this._selection,r=K(t,this._options.document).filter(c=>o.includes(c)||s.includes(c));r.length&&(this._selection.stored=s.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=>!i.removed.includes(c))),this._latestElement=void 0,n||(this._emitEvent("move",null),this._emitEvent("stop",null)))}}E(ze,"version","3.5.1");function Pt(e){const t=e.mouseSelectionButton===2?[2]:[0],n=new ze({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 s=n.getSelectionArea();return s.style.background="#4f90f22d",s.style.border="1px solid #4f90f2",s.parentElement&&(s.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:s}}})=>{M.moved=!0;for(const i of o)i.classList.add("selected");for(const i of s)i.classList.remove("selected")}).on("stop",({store:{stored:o}})=>{e.selectNodes(o)});e.selection=n}const Bt=function(e,t=!0){this.theme=e;const n=this.theme.cssVar,o=Object.keys(n);this.container.style.cssText="";for(let s=0;s<o.length;s++){const i=o[s];this.container.style.setProperty(i,n[i])}e.cssVar["--gap"]||this.container.style.setProperty("--gap","30px"),t&&this.refresh()},U=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 Rt(e){const{siblings:t,index:n}=U(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 zt(e){const{siblings:t,index:n}=U(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 ye(e){const{siblings:t,index:n}=U(e);return t===void 0?0:(t.splice(n,1),t.length)}function Ft(e,t,n){const{siblings:o,index:s}=U(n);o!==void 0&&(t==="before"?o.splice(s,0,e):o.splice(s+1,0,e))}function qt(e,t){const{siblings:n,index:o}=U(e);n!==void 0&&(n[o]=t,t.children=[e])}function Fe(e,t,n){var o;if(ye(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:s,index:i}=U(n);if(s===void 0)return;e==="before"?s.splice(i,0,t):s.splice(i+1,0,t)}}const It=function({map:e,direction:t},n){var o,s;if(t===$)return $;if(t===O)return O;if(t===ee){const i=((o=e.querySelector(".lhs"))==null?void 0:o.childElementCount)||0,r=((s=e.querySelector(".rhs"))==null?void 0:s.childElementCount)||0;return i<=r?(n.direction=$,$):(n.direction=O,O)}},qe=function(e,t,n){var i,r;const o=n.children[0].children[0],s=t.parentElement;if(s.tagName==="ME-PARENT"){if(J(o),s.children[1])s.nextSibling.appendChild(n);else{const c=e.createChildren([n]);s.appendChild(me(!0)),s.insertAdjacentElement("afterend",c)}e.linkDiv(n.offsetParent)}else s.tagName==="ME-ROOT"&&(It(e,o.nodeObj)===$?(i=e.container.querySelector(".lhs"))==null||i.appendChild(n):(r=e.container.querySelector(".rhs"))==null||r.appendChild(n),e.linkDiv())},Ie=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())},Vt=function(e,t){const n=e.nodeObj,o=ue(n);o.style&&t.style&&(t.style=Object.assign(o.style,t.style));const s=Object.assign(n,t);pe(e,s),this.linkDiv(),this.bus.fire("operation",{name:"reshapeNode",obj:s,origin:o})},be=function(e,t,n){if(!t)return null;const o=t.nodeObj;o.expanded===!1&&(e.expandNode(t,!0),t=C(o.id));const s=n||e.generateNewObj();o.children?o.children.push(s):o.children=[s],H(e.nodeData);const{grp:i,top:r}=e.createWrapper(s);return qe(e,t,i),{newTop:r,newNodeObj:s}},Wt=function(e,t,n){var d,a,u,h;const o=t||this.currentNode;if(!o)return;const s=o.nodeObj;if(s.parent){if(!((d=s.parent)!=null&&d.parent)&&((u=(a=s.parent)==null?void 0:a.children)==null?void 0:u.length)===1){this.addChild(C(s.parent.id),n);return}}else{this.addChild();return}const i=n||this.generateNewObj();if(!((h=s.parent)!=null&&h.parent)){const p=o.closest("me-main").className===L.LHS?$:O;i.direction=p}Ft(i,e,s),H(this.nodeData);const r=o.parentElement,{grp:c,top:l}=this.createWrapper(i);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:i})},Kt=function(e,t){const n=e||this.currentNode;if(!n)return;J(n);const o=n.nodeObj;if(!o.parent)return;const s=t||this.generateNewObj();qt(o,s),H(this.nodeData);const i=n.parentElement.parentElement,{grp:r,top:c}=this.createWrapper(s,!0);c.appendChild(me(!0)),i.insertAdjacentElement("afterend",r);const l=this.createChildren([i]);c.insertAdjacentElement("afterend",l),this.linkDiv(),t||this.editTopic(c.firstChild),this.selectNode(c.firstChild,!0),this.bus.fire("operation",{name:"insertParent",obj:s})},Ut=function(e,t){const n=e||this.currentNode;if(!n)return;const o=be(this,n,t);if(!o)return;const{newTop:s,newNodeObj:i}=o;this.bus.fire("operation",{name:"addChild",obj:i}),t||this.editTopic(s.firstChild),this.selectNode(s.firstChild,!0)},Yt=function(e,t){const n=ue(e.nodeObj);he(n);const o=be(this,t,n);if(!o)return;const{newNodeObj:s}=o;this.selectNode(C(s.id)),this.bus.fire("operation",{name:"copyNode",obj:s})},Xt=function(e,t){e=se(e);const n=[];for(let o=0;o<e.length;o++){const s=e[o],i=ue(s.nodeObj);he(i);const r=be(this,t,i);if(!r)return;const{newNodeObj:c}=r;n.push(c)}this.selectNodes(n.map(o=>C(o.id))),this.bus.fire("operation",{name:"copyNodes",objs:n})},Gt=function(e){const t=e||this.currentNode;if(!t)return;const n=t.nodeObj;Rt(n);const o=t.parentNode.parentNode;o.parentNode.insertBefore(o,o.previousSibling),this.linkDiv(),this.bus.fire("operation",{name:"moveUpNode",obj:n})},Jt=function(e){const t=e||this.currentNode;if(!t)return;const n=t.nodeObj;zt(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})},Zt=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,s=o.findIndex(c=>c===n),i=ye(n);if(Ie(t,i),o.length!==0){const c=o[s]||o[s-1];this.selectNode(C(c.id))}else this.selectNode(C(n.parent.id));this.linkDiv(),this.bus.fire("operation",{name:"removeNode",obj:n,originIndex:s,originParentId:(r=n==null?void 0:n.parent)==null?void 0:r.id})},Qt=function(e){e=se(e);for(const t of e){const n=t.nodeObj;if(!n.parent)continue;const o=ye(n);Ie(t,o)}this.linkDiv(),this.bus.fire("operation",{name:"removeNodes",objs:e.map(t=>t.nodeObj)})},en=function(e,t){e=se(e);const n=t.nodeObj;n.expanded===!1&&(this.expandNode(t,!0),t=C(n.id));for(const o of e){const s=o.nodeObj;Fe("in",s,n),H(this.nodeData);const i=o.parentElement;qe(this,t,i.parentElement)}this.linkDiv(),this.bus.fire("operation",{name:"moveNodeIn",objs:e.map(o=>o.nodeObj),toObj:n})},We=(e,t,n,o)=>{e=se(e),t==="after"&&(e=e.reverse());const s=n.nodeObj,i=[];for(const r of e){const c=r.nodeObj;Fe(t,c,s),H(o.nodeData),J(r);const l=r.parentElement.parentNode;i.includes(l.parentElement)||i.push(l.parentElement),n.parentElement.parentNode.insertAdjacentElement(Ve[t],l)}for(const r of i)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:s})},Ke=Object.freeze(Object.defineProperty({__proto__:null,addChild:Ut,beginEdit:function(e){const t=e||this.currentNode;t&&(t.nodeObj.dangerouslySetInnerHTML||this.editTopic(t))},copyNode:Yt,copyNodes:Xt,insertParent:Kt,insertSibling:Wt,moveDownNode:Jt,moveNodeAfter:function(e,t){We(e,"after",t,this)},moveNodeBefore:function(e,t){We(e,"before",t,this)},moveNodeIn:en,moveUpNode:Gt,removeNode:Zt,removeNodes:Qt,reshapeNode:Vt,rmSubline:J,setNodeTopic:function(e,t){e.text.textContent=t,e.nodeObj.topic=t,this.linkDiv()}},Symbol.toStringTag,{value:"Module"}));function Ue(e){return{nodeData:e.isFocusMode?e.nodeDataBackup:e.nodeData,arrows:e.arrows,summaries:e.summaries,direction:e.direction,theme:e.theme}}const tn=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,s=o.children[1];if(s.expanded=n.expanded,s.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 i=e.getBoundingClientRect(),r=this.container.getBoundingClientRect();(i.bottom>r.bottom||i.top<r.top||i.right>r.right||i.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=Ue(this).nodeData;let t="# "+e.topic+`
|
|
17
|
+
</svg>`,n};function Lt(e){const t=document.createElement("div"),n=z("fullscreen","full"),o=z("toCenter","living"),s=z("zoomout","move"),i=z("zoomin","add"),r=document.createElement("span");return r.innerText="100%",t.appendChild(n),t.appendChild(o),t.appendChild(s),t.appendChild(i),t.className="mind-elixir-toolbar rb",n.onclick=()=>{document.fullscreenElement===e.el?document.exitFullscreen():e.el.requestFullscreen()},o.onclick=()=>{e.toCenter()},s.onclick=()=>{e.scaleVal<.6||e.scale(e.scaleVal-e.scaleSensitivity)},i.onclick=()=>{e.scaleVal>1.6||e.scale(e.scaleVal+e.scaleSensitivity)},t}function Mt(e){const t=document.createElement("div"),n=z("tbltl","left"),o=z("tbltr","right"),s=z("tblts","side");return t.appendChild(n),t.appendChild(o),t.appendChild(s),t.className="mind-elixir-toolbar lt",n.onclick=()=>{e.initLeft()},o.onclick=()=>{e.initRight()},s.onclick=()=>{e.initSide()},t}function kt(e){e.container.append(Lt(e)),e.container.append(Mt(e))}/*! @viselect/vanilla v3.5.1 MIT | https://github.com/Simonwep/selection/tree/master/packages/vanilla */var Tt=Object.defineProperty,At=(e,t,n)=>t in e?Tt(e,t,{enumerable:!0,configurable:!0,writable:!0,value:n}):e[t]=n,E=(e,t,n)=>(At(e,typeof t!="symbol"?t+"":t,n),n);class $t{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 s of this._listeners.get(t)??[])o=s(...n)!==!1&&o;return o}unbindAllListeners(){this._listeners.clear()}}const De=(e,t="px")=>typeof e=="number"?e+t:e;function B({style:e},t,n){if(typeof t=="object")for(const[o,s]of Object.entries(t))s!==void 0&&(e[o]=De(s));else n!==void 0&&(e[t]=De(n))}const Oe=e=>(t,n,o,s={})=>{t instanceof HTMLCollection||t instanceof NodeList?t=Array.from(t):Array.isArray(t)||(t=[t]),Array.isArray(n)||(n=[n]);for(const i of t)if(i)for(const r of n)i[e](r,o,{capture:!1,...s});return[t,n,o,s]},W=Oe("addEventListener"),R=Oe("removeEventListener"),ce=e=>{var t;const{clientX:n,clientY:o,target:s}=((t=e.touches)==null?void 0:t[0])??e;return{x:n,y:o,target:s}};function He(e,t,n="touch"){switch(n){case"center":{const o=t.left+t.width/2,s=t.top+t.height/2;return o>=e.left&&o<=e.right&&s>=e.top&&s<=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 K(e,t=document){const n=Array.isArray(e)?e:[e];let o=[];for(let s=0,i=n.length;s<i;s++){const r=n[s];typeof r=="string"?o=o.concat(Array.from(t.querySelectorAll(r))):r instanceof Element&&o.push(r)}return o}const jt=()=>matchMedia("(hover: none), (pointer: coarse)").matches,Dt=()=>"safari"in window,Ot=e=>{let t,n=-1,o=!1;return{next(...s){t=s,o||(o=!0,n=requestAnimationFrame(()=>{e(...t),o=!1}))},cancel(){cancelAnimationFrame(n),o=!1}}};function Ht(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,s=n.modifiers.every(i=>{switch(i){case"alt":return e.altKey;case"ctrl":return e.ctrlKey||e.metaKey;case"shift":return e.shiftKey}});return o&&s}}return!1}const{abs:F,max:Pe,min:Be,ceil:Re}=Math;class ze extends $t{constructor(t){var n,o,s,i,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,...(i=(s=t.behaviour)==null?void 0:s.scrolling)==null?void 0:i.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=Ot(a=>{this._recalculateSelectionAreaRect(),this._updateElementSelection(),this._emitEvent("move",a),this._redrawSelectionArea()}),this.enable()}_bindStartEvents(t=!0){const{document:n,features:o}=this._options,s=t?W:R;s(n,"mousedown",this._onTapStart),o.touch&&s(n,"touchstart",this._onTapStart,{passive:!1})}_onTapStart(t,n=!1){const{x:o,y:s,target:i}=ce(t),{_options:r}=this,{document:c}=this._options,l=i.getBoundingClientRect();if(t instanceof MouseEvent&&!Ht(t,r.behaviour.triggers))return;const d=K(r.startAreas,r.document),a=K(r.boundaries,r.document);this._targetElement=a.find(p=>He(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:s,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),W(c,["touchmove","mousemove"],this._delayedTapMove,{passive:!1}),W(c,["mouseup","touchcancel","touchend"],this._onTapStop),W(c,"scroll",this._onScroll)}_onSingleTap(t){const{singleTap:{intersect:n},range:o}=this._options.features,s=ce(t);let i;if(n==="native")i=s.target;else if(n==="touch"){this.resolveSelectables();const{x:c,y:l}=s;i=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(!i)return;for(this.resolveSelectables();!this._selectables.includes(i);){if(!i.parentElement)return;i=i.parentElement}const{stored:r}=this._selection;if(this._emitEvent("start",t),t.shiftKey&&o&&this._latestElement){const c=this._latestElement,[l,d]=c.compareDocumentPosition(i)&4?[i,c]:[c,i],a=[...this._selectables.filter(u=>u.compareDocumentPosition(l)&4&&u.compareDocumentPosition(d)&2),l,d];this.select(a),this._latestElement=c}else r.includes(i)&&(r.length===1||t.ctrlKey||r.every(c=>this._selection.stored.includes(c)))?this.deselect(i):(this.select(i),this._latestElement=i)}_delayedTapMove(t){const{container:n,document:o,behaviour:{startThreshold:s}}=this._options,{x1:i,y1:r}=this._areaLocation,{x:c,y:l}=ce(t);if(typeof s=="number"&&F(c+l-(i+r))>=s||typeof s=="object"&&F(c-i)>=s.x||F(l-r)>=s.y){if(R(o,["mousemove","touchmove"],this._delayedTapMove,{passive:!1}),this._emitEvent("beforedrag",t)===!1){R(o,["mouseup","touchcancel","touchend"],this._onTapStop);return}W(o,["mousemove","touchmove"],this._onTapMove,{passive:!1}),B(this._area,"display","block"),K(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&&(W(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,s=this._targetRect=n.getBoundingClientRect();this._scrollAvailable?(B(t,{top:s.top,left:s.left,width:s.width,height:s.height}),B(o,{marginTop:-s.top,marginLeft:-s.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:s,_areaLocation:i,_options:r,_frame:c}=this,{speedDivider:l}=r.behaviour.scrolling,d=this._targetElement;if(i.x2=n,i.y2=o,this._scrollAvailable&&!this._scrollingActive&&(s.y||s.x)){this._scrollingActive=!0;const a=()=>{if(!s.x&&!s.y){this._scrollingActive=!1;return}const{scrollTop:u,scrollLeft:h}=d;s.y&&(d.scrollTop+=Re(s.y/l),i.y1-=d.scrollTop-u),s.x&&(d.scrollLeft+=Re(s.x/l),i.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&&jt()||this._scrollAvailable&&Dt())&&t.preventDefault()}_onScroll(){const{_scrollDelta:t,_options:{document:n}}=this,{scrollTop:o,scrollLeft:s}=n.scrollingElement??n.body;this._areaLocation.x1+=t.x-s,this._areaLocation.y1+=t.y-o,t.x=s,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,s=t.deltaX?t.deltaX>0?1:-1:0;this._scrollSpeed.y+=o*n,this._scrollSpeed.x+=s*n,this._onTapMove(t),t.preventDefault()}_recalculateSelectionAreaRect(){const{_scrollSpeed:t,_areaLocation:n,_areaRect:o,_targetElement:s,_options:i}=this,{scrollTop:r,scrollHeight:c,clientHeight:l,scrollLeft:d,scrollWidth:a,clientWidth:u}=s,h=this._targetRect,{x1:p,y1:g}=n;let{x2:v,y2:m}=n;const{behaviour:{scrolling:{startScrollMargins:f}}}=i;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 y=Be(p,v),x=Be(g,m),N=Pe(p,v),b=Pe(g,m);o.x=y,o.y=x,o.width=N-y,o.height=b-x}_redrawSelectionArea(){const{x:t,y:n,width:o,height:s}=this._areaRect,{style:i}=this._area;i.left=`${t}px`,i.top=`${n}px`,i.width=`${o}px`,i.height=`${s}px`}_onTapStop(t,n){var o;const{document:s,features:i}=this._options,{_singleClick:r}=this;R(s,["mousemove","touchmove"],this._delayedTapMove),R(s,["touchmove","mousemove"],this._onTapMove),R(s,["mouseup","touchcancel","touchend"],this._onTapStop),R(s,"scroll",this._onScroll),this._keepSelection(),t&&r&&i.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:s}=this,{stored:i,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(He(s,m.getBoundingClientRect(),l)){if(r.includes(m))i.includes(m)&&!c.includes(m)&&c.push(m);else if(a&&i.includes(m)){p.push(m);continue}else h.push(m);u.push(m)}}a&&h.push(...i.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&&i.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:s,touched:i,stored:r}=n,c=o.filter(l=>!r.includes(l));switch(t.behaviour.overlap){case"drop":{n.stored=[...c,...r.filter(l=>!i.includes(l))];break}case"invert":{n.stored=[...c,...r.filter(l=>!s.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=K(this._options.selectables,this._options.document)}clearSelection(t=!0,n=!1){const{selected:o,stored:s,changed:i}=this._selection;i.added=[],i.removed.push(...o,...t?s:[]),n||(this._emitEvent("move",null),this._emitEvent("stop",null)),this._selection={stored:t?[]:s,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:s,stored:i}=this._selection,r=K(t,this._options.document).filter(c=>!s.includes(c)&&!i.includes(c));return i.push(...r),s.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:s,changed:i}=this._selection,r=K(t,this._options.document).filter(c=>o.includes(c)||s.includes(c));r.length&&(this._selection.stored=s.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=>!i.removed.includes(c))),this._latestElement=void 0,n||(this._emitEvent("move",null),this._emitEvent("stop",null)))}}E(ze,"version","3.5.1");function Pt(e){const t=e.mouseSelectionButton===2?[2]:[0],n=new ze({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 s=n.getSelectionArea();return s.style.background="#4f90f22d",s.style.border="1px solid #4f90f2",s.parentElement&&(s.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:s}}})=>{M.moved=!0;for(const i of o)i.classList.add("selected");for(const i of s)i.classList.remove("selected")}).on("stop",({store:{stored:o}})=>{e.selectNodes(o)});e.selection=n}const Bt=function(e,t=!0){this.theme=e;const n=this.theme.cssVar,o=Object.keys(n);this.container.style.cssText="";for(let s=0;s<o.length;s++){const i=o[s];this.container.style.setProperty(i,n[i])}e.cssVar["--gap"]||this.container.style.setProperty("--gap","30px"),t&&this.refresh()},U=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 Rt(e){const{siblings:t,index:n}=U(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 zt(e){const{siblings:t,index:n}=U(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 ye(e){const{siblings:t,index:n}=U(e);return t===void 0?0:(t.splice(n,1),t.length)}function Ft(e,t,n){const{siblings:o,index:s}=U(n);o!==void 0&&(t==="before"?o.splice(s,0,e):o.splice(s+1,0,e))}function qt(e,t){const{siblings:n,index:o}=U(e);n!==void 0&&(n[o]=t,t.children=[e])}function Fe(e,t,n){var o;if(ye(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:s,index:i}=U(n);if(s===void 0)return;e==="before"?s.splice(i,0,t):s.splice(i+1,0,t)}}const It=function({map:e,direction:t},n){var o,s;if(t===$)return $;if(t===O)return O;if(t===ee){const i=((o=e.querySelector(".lhs"))==null?void 0:o.childElementCount)||0,r=((s=e.querySelector(".rhs"))==null?void 0:s.childElementCount)||0;return i<=r?(n.direction=$,$):(n.direction=O,O)}},qe=function(e,t,n){var i,r;const o=n.children[0].children[0],s=t.parentElement;if(s.tagName==="ME-PARENT"){if(J(o),s.children[1])s.nextSibling.appendChild(n);else{const c=e.createChildren([n]);s.appendChild(me(!0)),s.insertAdjacentElement("afterend",c)}e.linkDiv(n.offsetParent)}else s.tagName==="ME-ROOT"&&(It(e,o.nodeObj)===$?(i=e.container.querySelector(".lhs"))==null||i.appendChild(n):(r=e.container.querySelector(".rhs"))==null||r.appendChild(n),e.linkDiv())},Ie=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())},Vt=function(e,t){const n=e.nodeObj,o=ue(n);o.style&&t.style&&(t.style=Object.assign(o.style,t.style));const s=Object.assign(n,t);pe(e,s),this.linkDiv(),this.bus.fire("operation",{name:"reshapeNode",obj:s,origin:o})},be=function(e,t,n){if(!t)return null;const o=t.nodeObj;o.expanded===!1&&(e.expandNode(t,!0),t=C(o.id));const s=n||e.generateNewObj();o.children?o.children.push(s):o.children=[s],H(e.nodeData);const{grp:i,top:r}=e.createWrapper(s);return qe(e,t,i),{newTop:r,newNodeObj:s}},Wt=function(e,t,n){var d,a,u,h;const o=t||this.currentNode;if(!o)return;const s=o.nodeObj;if(s.parent){if(!((d=s.parent)!=null&&d.parent)&&((u=(a=s.parent)==null?void 0:a.children)==null?void 0:u.length)===1&&this.direction===2){this.addChild(C(s.parent.id),n);return}}else{this.addChild();return}const i=n||this.generateNewObj();if(!((h=s.parent)!=null&&h.parent)){const p=o.closest("me-main").className===L.LHS?$:O;i.direction=p}Ft(i,e,s),H(this.nodeData);const r=o.parentElement,{grp:c,top:l}=this.createWrapper(i);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:i})},Kt=function(e,t){const n=e||this.currentNode;if(!n)return;J(n);const o=n.nodeObj;if(!o.parent)return;const s=t||this.generateNewObj();qt(o,s),H(this.nodeData);const i=n.parentElement.parentElement,{grp:r,top:c}=this.createWrapper(s,!0);c.appendChild(me(!0)),i.insertAdjacentElement("afterend",r);const l=this.createChildren([i]);c.insertAdjacentElement("afterend",l),this.linkDiv(),t||this.editTopic(c.firstChild),this.selectNode(c.firstChild,!0),this.bus.fire("operation",{name:"insertParent",obj:s})},Ut=function(e,t){const n=e||this.currentNode;if(!n)return;const o=be(this,n,t);if(!o)return;const{newTop:s,newNodeObj:i}=o;this.bus.fire("operation",{name:"addChild",obj:i}),t||this.editTopic(s.firstChild),this.selectNode(s.firstChild,!0)},Yt=function(e,t){const n=ue(e.nodeObj);he(n);const o=be(this,t,n);if(!o)return;const{newNodeObj:s}=o;this.selectNode(C(s.id)),this.bus.fire("operation",{name:"copyNode",obj:s})},Xt=function(e,t){e=se(e);const n=[];for(let o=0;o<e.length;o++){const s=e[o],i=ue(s.nodeObj);he(i);const r=be(this,t,i);if(!r)return;const{newNodeObj:c}=r;n.push(c)}this.selectNodes(n.map(o=>C(o.id))),this.bus.fire("operation",{name:"copyNodes",objs:n})},Gt=function(e){const t=e||this.currentNode;if(!t)return;const n=t.nodeObj;Rt(n);const o=t.parentNode.parentNode;o.parentNode.insertBefore(o,o.previousSibling),this.linkDiv(),this.bus.fire("operation",{name:"moveUpNode",obj:n})},Jt=function(e){const t=e||this.currentNode;if(!t)return;const n=t.nodeObj;zt(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})},Zt=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,s=o.findIndex(c=>c===n),i=ye(n);if(Ie(t,i),o.length!==0){const c=o[s]||o[s-1];this.selectNode(C(c.id))}else this.selectNode(C(n.parent.id));this.linkDiv(),this.bus.fire("operation",{name:"removeNode",obj:n,originIndex:s,originParentId:(r=n==null?void 0:n.parent)==null?void 0:r.id})},Qt=function(e){e=se(e);for(const t of e){const n=t.nodeObj;if(!n.parent)continue;const o=ye(n);Ie(t,o)}this.linkDiv(),this.bus.fire("operation",{name:"removeNodes",objs:e.map(t=>t.nodeObj)})},en=function(e,t){e=se(e);const n=t.nodeObj;n.expanded===!1&&(this.expandNode(t,!0),t=C(n.id));for(const o of e){const s=o.nodeObj;Fe("in",s,n),H(this.nodeData);const i=o.parentElement;qe(this,t,i.parentElement)}this.linkDiv(),this.bus.fire("operation",{name:"moveNodeIn",objs:e.map(o=>o.nodeObj),toObj:n})},We=(e,t,n,o)=>{e=se(e),t==="after"&&(e=e.reverse());const s=n.nodeObj,i=[];for(const r of e){const c=r.nodeObj;Fe(t,c,s),H(o.nodeData),J(r);const l=r.parentElement.parentNode;i.includes(l.parentElement)||i.push(l.parentElement),n.parentElement.parentNode.insertAdjacentElement(Ve[t],l)}for(const r of i)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:s})},Ke=Object.freeze(Object.defineProperty({__proto__:null,addChild:Ut,beginEdit:function(e){const t=e||this.currentNode;t&&(t.nodeObj.dangerouslySetInnerHTML||this.editTopic(t))},copyNode:Yt,copyNodes:Xt,insertParent:Kt,insertSibling:Wt,moveDownNode:Jt,moveNodeAfter:function(e,t){We(e,"after",t,this)},moveNodeBefore:function(e,t){We(e,"before",t,this)},moveNodeIn:en,moveUpNode:Gt,removeNode:Zt,removeNodes:Qt,reshapeNode:Vt,rmSubline:J,setNodeTopic:function(e,t){e.text.textContent=t,e.nodeObj.topic=t,this.linkDiv()}},Symbol.toStringTag,{value:"Module"}));function Ue(e){return{nodeData:e.isFocusMode?e.nodeDataBackup:e.nodeData,arrows:e.arrows,summaries:e.summaries,direction:e.direction,theme:e.theme}}const tn=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,s=o.children[1];if(s.expanded=n.expanded,s.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 i=e.getBoundingClientRect(),r=this.container.getBoundingClientRect();(i.bottom>r.bottom||i.top<r.top||i.right>r.right||i.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=Ue(this).nodeData;let t="# "+e.topic+`
|
|
18
18
|
|
|
19
19
|
`;function n(o,s){for(let i=0;i<o.length;i++)s<=6?t+="".padStart(s,"#")+" "+o[i].topic+`
|
|
20
20
|
|
|
21
21
|
`:t+="".padStart(s-7," ")+"- "+o[i].topic+`
|
|
22
22
|
`,o[i].children&&n(o[i].children||[],s+1)}return n(e.children||[],2),t},getDataString:function(){const e=Ue(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=C(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"})),Ye={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:s}=P(e.nodes,t),i=t.offsetWidth,r=t.offsetHeight,c=o+i/2,l=s+r/2,d=c+n.x,a=l+n.y;return{w:i,h:r,cx:c,cy:l,ctrlX:d,ctrlY:a}}function Y(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 nn=function(e,t,n,o){const s=document.createElementNS("http://www.w3.org/2000/svg","text");return S(s,{"text-anchor":"middle",x:t+"",y:n+"",fill:o||"#666"}),s.dataset.type="custom-link",s.innerHTML=e,s},Xe=function(e,t,n,o,s){if(!t||!n)return;performance.now();const i=le(e,t,o.delta1),r=le(e,n,o.delta2),{x:c,y:l}=Y(i),{ctrlX:d,ctrlY:a}=i,{ctrlX:u,ctrlY:h}=r,{x:p,y:g}=Y(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 y=ft(`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,b=nn(o.label,x,N,e.theme.cssVar["--color"]);y.appendChild(b),y.arrowObj=o,y.dataset.linkid=o.id,e.linkSvgGroup.appendChild(y),s||(e.arrows.push(o),e.currentArrow=y,Ge(e,o,i,r)),performance.now()},on=function(e,t,n={}){const o={id:I(),label:"Custom Link",from:e.nodeObj.id,to:t.nodeObj.id,delta1:{x:0,y:-200},delta2:{x:0,y:-200},...n};Xe(this,e,t,o),this.bus.fire("operation",{name:"createArrow",obj:o})},sn=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}})},rn=function(e){this.currentArrow=e;const t=e.arrowObj,n=C(t.from),o=C(t.to),s=le(this,n,t.delta1),i=le(this,o,t.delta2);Ge(this,t,s,i)},cn=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"},Ge=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:s,y:i}=Y(n),{ctrlX:r,ctrlY:c}=n,{ctrlX:l,ctrlY:d}=o,{x:a,y:u}=Y(o);e.P2.style.cssText=`top:${c}px;left:${r}px;`,e.P3.style.cssText=`top:${d}px;left:${l}px;`,S(e.line1,{x1:s+"",y1:i+"",x2:r+"",y2:c+""}),S(e.line2,{x1:l+"",y1:d+"",x2:a+"",y2:u+""}),e.helper1=Ye.create(e.P2),e.helper2=Ye.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=Y({...n,ctrlX:r,ctrlY:c});s=g.x,i=g.y;const v=s/8+r*3/8+l*3/8+a/8,m=i/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 ${s} ${i} C ${r} ${c} ${l} ${d} ${a} ${u}`),t.bidirectional){const f=oe(r,c,s,i);e.currentArrow.children[2].setAttribute("d",`M ${f.x1} ${f.y1} L ${s} ${i} L ${f.x2} ${f.y2}`)}S(e.currentArrow.children[3],{x:v+"",y:m+""}),S(e.line1,{x1:s+"",y1:i+"",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=Y({...o,ctrlX:l,ctrlY:d});a=g.x,u=g.y;const v=s/8+r*3/8+l*3/8+a/8,m=i/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 ${s} ${i} 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}`),S(e.currentArrow.children[3],{x:v+"",y:m+""}),S(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 ln(){this.linkSvgGroup.innerHTML="";for(let e=0;e<this.arrows.length;e++){const t=this.arrows[e];try{Xe(this,C(t.from),C(t.to),t,!0)}catch{}}this.nodes.appendChild(this.linkSvgGroup)}function an(e){if(xe(this),!e)return;const t=e.children[3];Le(this,t,n=>{var i;const o=e.arrowObj,s=((i=n.textContent)==null?void 0:i.trim())||"";s===""?o.label=origin:o.label=s,n.remove(),s!==origin&&(t.innerHTML=o.label,this.linkDiv(),this.bus.fire("operation",{name:"finishEditArrowLabel",obj:o}))})}function dn(){this.arrows=this.arrows.filter(e=>ne(e.from,this.nodeData)&&ne(e.to,this.nodeData))}const hn=Object.freeze(Object.defineProperty({__proto__:null,createArrow:on,editArrowLabel:an,removeArrow:sn,renderArrow:ln,selectArrow:rn,tidyArrow:dn,unselectArrow:cn},Symbol.toStringTag,{value:"Module"})),un=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 s=n.map(a=>a[o-1].index).sort(),i=s[0]||0,r=s[s.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:i,end:r}},fn=function(e){const t=document.createElementNS("http://www.w3.org/2000/svg","g");return t.setAttribute("id",e),t},Je=function(e,t){const n=document.createElementNS("http://www.w3.org/2000/svg","path");return S(n,{d:e,stroke:t||"#666",fill:"none","stroke-linecap":"round","stroke-width":"2"}),n},Ze=function(e,t,n,o,s){const i=document.createElementNS("http://www.w3.org/2000/svg","text");return S(i,{"text-anchor":o,x:t+"",y:n+"",fill:s||"#666"}),i.innerHTML=e,i},pn=e=>C(e).parentElement.parentElement,mn=function({parent:e,start:t}){const n=C(e),o=n.nodeObj;let s;return o.parent?s=n.closest("me-main").className:s=C(o.children[t].id).closest("me-main").className,s},we=function(e,t){var w;const{id:n,text:o,parent:s,start:i,end:r}=t,c=e.nodes,d=C(s).nodeObj,a=mn(t);let u=1/0,h=0,p=0,g=0;for(let _=i;_<=r;_++){const A=(w=d.children)==null?void 0:w[_];if(!A)return e.removeSummary(n),null;const D=pn(A.id),{offsetLeft:q,offsetTop:Q}=P(c,D),tt=i===r?10:20;_===i&&(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,y=g+10,x=(f+y)/2,N=e.theme.cssVar["--color"];a===L.LHS?(v=Je(`M ${u+10} ${f} c -5 0 -10 5 -10 10 L ${u} ${y-10} c 0 5 5 10 10 10 M ${u} ${x} h -10`,N),m=Ze(o,u-20,x+6,"end",N)):(v=Je(`M ${h-10} ${f} c 5 0 10 5 10 10 L ${h} ${y-10} c 0 5 -5 10 -10 10 M ${h} ${x} h 10`,N),m=Ze(o,h+20,x+6,"start",N));const b=fn("s-"+n);return b.appendChild(v),b.appendChild(m),b.summaryObj=t,e.summarySvg.appendChild(b),b},gn=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}=un(e),s={id:I(),parent:t,start:n,end:o,text:"summary"},i=we(this,s);this.summaries.push(s),this.editSummary(i),this.bus.fire("operation",{name:"createSummary",obj:s})},createSummaryFrom:function(e){const t=I(),n={...e,id:t};we(this,n),this.summaries.push(n),this.bus.fire("operation",{name:"createSummary",obj:n})},editSummary:function(e){if(!e)return;const t=e.childNodes[1];Le(this,t,n=>{var i;const o=e.summaryObj,s=((i=n.textContent)==null?void 0:i.trim())||"";s===""?o.text=origin:o.text=s,n.remove(),s!==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{we(this,e)}catch{}}),this.nodes.insertAdjacentElement("beforeend",this.summarySvg)},selectSummary:function(e){const t=e.children[1].getBBox(),n=6,o=3,s=document.createElementNS("http://www.w3.org/2000/svg","rect");S(s,{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(s),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 vn(e,t){const n=document.createElementNS(T,"svg");return S(n,{version:"1.1",xmlns:T,height:e,width:t}),n}function yn(e,t){return(parseInt(e)-parseInt(t))/2}function bn(e,t,n,o){const s=document.createElementNS(T,"g");let i="";return e.text?i=e.text.textContent:i=e.childNodes[0].textContent,i.split(`
|
|
23
|
-
`).forEach((c,l)=>{const d=document.createElementNS(T,"text");S(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,s.appendChild(d)}),s}function xn(e,t,n,o){var c;let s="";(c=e.nodeObj)!=null&&c.dangerouslySetInnerHTML?s=e.nodeObj.dangerouslySetInnerHTML:e.text?s=e.text.textContent:s=e.childNodes[0].textContent;const i=document.createElementNS(T,"foreignObject");S(i,{x:n+parseInt(t.paddingLeft)+"",y:o+parseInt(t.paddingTop)+"",width:t.width,height:t.height});const r=document.createElement("div");return S(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=s,i.appendChild(r),i}function wn(e,t){const n=getComputedStyle(t),{offsetLeft:o,offsetTop:s}=P(e.nodes,t),i=document.createElementNS(T,"rect");return S(i,{x:o+"",y:s+"",rx:n.borderRadius,ry:n.borderRadius,width:n.width,height:n.height,fill:n.backgroundColor,stroke:n.borderColor,"stroke-width":n.borderWidth}),i}function ae(e,t,n=!1){const o=getComputedStyle(t),{offsetLeft:s,offsetTop:i}=P(e.nodes,t),r=document.createElementNS(T,"rect");S(r,{x:s+"",y:i+"",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=xn(t,o,s,i):l=bn(t,o,s,i),c.appendChild(l),c}function En(e,t){const n=getComputedStyle(t),{offsetLeft:o,offsetTop:s}=P(e.nodes,t),i=document.createElementNS(T,"a"),r=document.createElementNS(T,"text");return S(r,{x:o+"",y:s+parseInt(n.fontSize)+"","text-anchor":"start","font-family":n.fontFamily,"font-size":`${n.fontSize}`,"font-weight":`${n.fontWeight}`,fill:`${n.color}`}),r.innerHTML=t.textContent,i.appendChild(r),i.setAttribute("href",t.href),i}function Nn(e,t){const n=getComputedStyle(t),{offsetLeft:o,offsetTop:s}=P(e.nodes,t),i=document.createElementNS(T,"image");return S(i,{x:o+"",y:s+"",width:n.width+"",height:n.height+"",href:t.src}),i}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">',Cn=(e,t=!1)=>{var u,h,p;const n=e.nodes,o=n.offsetHeight+de*2,s=n.offsetWidth+de*2,i=vn(o+"px",s+"px"),r=document.createElementNS(T,"svg"),c=document.createElementNS(T,"rect");S(c,{x:"0",y:"0",width:`${s}`,height:`${o}`,fill:e.theme.cssVar["--bgcolor"]}),i.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(wn(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(En(e,g))}),n.querySelectorAll("img").forEach(g=>{r.appendChild(Nn(e,g))}),S(r,{x:de+"",y:de+"",overflow:"visible"}),i.appendChild(r),i},_n=(e,t)=>(t&&e.insertAdjacentHTML("afterbegin","<style>"+t+"</style>"),Sn+e.outerHTML);function Ln(e){return new Promise((t,n)=>{const o=new FileReader;o.onload=s=>{t(s.target.result)},o.onerror=s=>{n(s)},o.readAsDataURL(e)})}const Mn=Object.freeze(Object.defineProperty({__proto__:null,exportPng:async function(e=!1,t){const n=this.exportSvg(e,t),o=await Ln(n);return new Promise((s,i)=>{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(s,"image/png",1)},r.src=o,r.onerror=i})},exportSvg:function(e=!1,t){const n=Cn(this,e),o=_n(n,t);return new Blob([o],{type:"image/svg+xml"})}},Symbol.toStringTag,{value:"Module"}));function kn(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]=kn(Ke[t],t)}const Tn={getObjById:ne,generateNewObj:nt,layout:it,linkDiv:pt,editTopic:ut,createWrapper:lt,createParent:at,createChildren:dt,createTopic:ht,findEle:C,changeTheme:Bt,...tn,...et,...hn,...gn,...Mn,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&&kt(this),this.keypress&&wt(this,this.keypress),this.editable&&Pt(this),this.contextMenu&&this.disposable.push(mt(this,this.contextMenu)),this.draggable&&St(this),this.allowUndo&&_t(this),this.toCenter(),this.layout(),this.linkDiv()},destroy(){var e;this.disposable.forEach(t=>t()),this.el&&(this.el.innerHTML=""),this.el=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 An({pT:e,pL:t,pW:n,pH:o,cT:s,cL:i,cW:r,cH:c,direction:l,containerHeight:d}){let a=t+n/2;const u=e+o/2;let h;l===L.LHS?h=i+r:h=i;const p=s+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 $n({pT:e,pL:t,pW:n,pH:o,cT:s,cL:i,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=s+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=i+a,`M ${g} ${u} C ${m} ${u} ${m+f} ${p} ${v} ${p} H ${h}`):(m=t+n,g=m-a,v=m+a,h=i+r-a,`M ${g} ${u} C ${m} ${u} ${m-f} ${p} ${v} ${p} H ${h}`)}const jn="4.6.
|
|
23
|
+
`).forEach((c,l)=>{const d=document.createElementNS(T,"text");S(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,s.appendChild(d)}),s}function xn(e,t,n,o){var c;let s="";(c=e.nodeObj)!=null&&c.dangerouslySetInnerHTML?s=e.nodeObj.dangerouslySetInnerHTML:e.text?s=e.text.textContent:s=e.childNodes[0].textContent;const i=document.createElementNS(T,"foreignObject");S(i,{x:n+parseInt(t.paddingLeft)+"",y:o+parseInt(t.paddingTop)+"",width:t.width,height:t.height});const r=document.createElement("div");return S(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=s,i.appendChild(r),i}function wn(e,t){const n=getComputedStyle(t),{offsetLeft:o,offsetTop:s}=P(e.nodes,t),i=document.createElementNS(T,"rect");return S(i,{x:o+"",y:s+"",rx:n.borderRadius,ry:n.borderRadius,width:n.width,height:n.height,fill:n.backgroundColor,stroke:n.borderColor,"stroke-width":n.borderWidth}),i}function ae(e,t,n=!1){const o=getComputedStyle(t),{offsetLeft:s,offsetTop:i}=P(e.nodes,t),r=document.createElementNS(T,"rect");S(r,{x:s+"",y:i+"",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=xn(t,o,s,i):l=bn(t,o,s,i),c.appendChild(l),c}function En(e,t){const n=getComputedStyle(t),{offsetLeft:o,offsetTop:s}=P(e.nodes,t),i=document.createElementNS(T,"a"),r=document.createElementNS(T,"text");return S(r,{x:o+"",y:s+parseInt(n.fontSize)+"","text-anchor":"start","font-family":n.fontFamily,"font-size":`${n.fontSize}`,"font-weight":`${n.fontWeight}`,fill:`${n.color}`}),r.innerHTML=t.textContent,i.appendChild(r),i.setAttribute("href",t.href),i}function Nn(e,t){const n=getComputedStyle(t),{offsetLeft:o,offsetTop:s}=P(e.nodes,t),i=document.createElementNS(T,"image");return S(i,{x:o+"",y:s+"",width:n.width+"",height:n.height+"",href:t.src}),i}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">',Cn=(e,t=!1)=>{var u,h,p;const n=e.nodes,o=n.offsetHeight+de*2,s=n.offsetWidth+de*2,i=vn(o+"px",s+"px"),r=document.createElementNS(T,"svg"),c=document.createElementNS(T,"rect");S(c,{x:"0",y:"0",width:`${s}`,height:`${o}`,fill:e.theme.cssVar["--bgcolor"]}),i.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(wn(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(En(e,g))}),n.querySelectorAll("img").forEach(g=>{r.appendChild(Nn(e,g))}),S(r,{x:de+"",y:de+"",overflow:"visible"}),i.appendChild(r),i},_n=(e,t)=>(t&&e.insertAdjacentHTML("afterbegin","<style>"+t+"</style>"),Sn+e.outerHTML);function Ln(e){return new Promise((t,n)=>{const o=new FileReader;o.onload=s=>{t(s.target.result)},o.onerror=s=>{n(s)},o.readAsDataURL(e)})}const Mn=Object.freeze(Object.defineProperty({__proto__:null,exportPng:async function(e=!1,t){const n=this.exportSvg(e,t),o=await Ln(n);return new Promise((s,i)=>{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(s,"image/png",1)},r.src=o,r.onerror=i})},exportSvg:function(e=!1,t){const n=Cn(this,e),o=_n(n,t);return new Blob([o],{type:"image/svg+xml"})}},Symbol.toStringTag,{value:"Module"}));function kn(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]=kn(Ke[t],t)}const Tn={getObjById:ne,generateNewObj:nt,layout:it,linkDiv:pt,editTopic:ut,createWrapper:lt,createParent:at,createChildren:dt,createTopic:ht,findEle:C,changeTheme:Bt,...tn,...et,...hn,...gn,...Mn,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&&kt(this),this.keypress&&wt(this,this.keypress),this.editable&&Pt(this),this.contextMenu&&this.disposable.push(mt(this,this.contextMenu)),this.draggable&&St(this),this.allowUndo&&_t(this),this.toCenter(),this.layout(),this.linkDiv()},destroy(){var e;this.disposable.forEach(t=>t()),this.el&&(this.el.innerHTML=""),this.el=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 An({pT:e,pL:t,pW:n,pH:o,cT:s,cL:i,cW:r,cH:c,direction:l,containerHeight:d}){let a=t+n/2;const u=e+o/2;let h;l===L.LHS?h=i+r:h=i;const p=s+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 $n({pT:e,pL:t,pW:n,pH:o,cT:s,cL:i,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=s+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=i+a,`M ${g} ${u} C ${m} ${u} ${m+f} ${p} ${v} ${p} H ${h}`):(m=t+n,g=m-a,v=m+a,h=i+r-a,`M ${g} ${u} C ${m} ${u} ${m-f} ${p} ${v} ${p} H ${h}`)}const jn="4.6.2",Z=document;function j({el:e,direction:t,locale:n,draggable:o,editable:s,contextMenu:i,toolBar:r,keypress:c,mouseSelectionButton:l,selectionContainer:d,before:a,newTopicName:u,allowUndo:h,generateMainBranch:p,generateSubBranch:g,overflowHidden:v,theme:m,alignment:f,scaleSensitivity:y}){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.el=x,this.disposable=[],this.before=a||{},this.locale=n||"en",this.contextMenu=i===void 0?!0:i,this.toolBar=r===void 0?!0:r,this.keypress=c===void 0?!0:c,this.mouseSelectionButton=l||0,this.direction=typeof t=="number"?t:1,this.draggable=o===void 0?!0:o,this.newTopicName=u||"new node",this.editable=s===void 0?!0:s,this.allowUndo=h===void 0?!1:h,this.scaleSensitivity=typeof y=="number"?y:.2,this.currentNode=null,this.currentArrow=null,this.scaleVal=1,this.tempDirection=null,this.generateMainBranch=p||An,this.generateSubBranch=g||$n,this.overflowHidden=v||!1,this.bus=st.create(),this.container=Z.createElement("div"),this.selectionContainer=d||this.container,this.container.className="map-container";const b=window.matchMedia("(prefers-color-scheme: dark)");this.theme=m||(b.matches?Ne:Ee);const w=Z.createElement("div");w.className="map-canvas",this.map=w,this.map.setAttribute("tabindex","0"),this.container.appendChild(this.map),this.el.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=_e(),this.line2=_e(),this.linkController.appendChild(this.line1),this.linkController.appendChild(this.line2),this.linkSvgGroup=G("topiclinks"),this.alignment=f??"root",this.map.appendChild(this.nodes),this.overflowHidden?this.container.style.overflow="hidden":ot(this)}return j.prototype=Tn,j.LEFT=$,j.RIGHT=O,j.SIDE=ee,j.THEME=Ee,j.DARK_THEME=Ne,j.version=jn,j.E=C,j.new=e=>({nodeData:{id:I(),topic:e||"new topic",children:[]}}),j.dragMoveHelper=M,j}();
|
package/dist/MindElixir.js
CHANGED
|
@@ -1508,7 +1508,7 @@ const It = function({ map: e, direction: t }, n) {
|
|
|
1508
1508
|
return;
|
|
1509
1509
|
const s = o.nodeObj;
|
|
1510
1510
|
if (s.parent) {
|
|
1511
|
-
if (!((d = s.parent) != null && d.parent) && ((u = (a = s.parent) == null ? void 0 : a.children) == null ? void 0 : u.length) === 1) {
|
|
1511
|
+
if (!((d = s.parent) != null && d.parent) && ((u = (a = s.parent) == null ? void 0 : a.children) == null ? void 0 : u.length) === 1 && this.direction === 2) {
|
|
1512
1512
|
this.addChild(S(s.parent.id), n);
|
|
1513
1513
|
return;
|
|
1514
1514
|
}
|
|
@@ -2378,7 +2378,7 @@ function mo({ pT: e, pL: t, pW: n, pH: o, cT: s, cL: i, cW: r, cH: c, direction:
|
|
|
2378
2378
|
const f = Math.abs(u - p) / 300 * a;
|
|
2379
2379
|
return l === L.LHS ? (m = t, g = m + a, v = m - a, h = i + a, `M ${g} ${u} C ${m} ${u} ${m + f} ${p} ${v} ${p} H ${h}`) : (m = t + n, g = m - a, v = m + a, h = i + r - a, `M ${g} ${u} C ${m} ${u} ${m - f} ${p} ${v} ${p} H ${h}`);
|
|
2380
2380
|
}
|
|
2381
|
-
const go = "4.6.
|
|
2381
|
+
const go = "4.6.2", G = document;
|
|
2382
2382
|
function D({
|
|
2383
2383
|
el: e,
|
|
2384
2384
|
direction: t,
|
|
@@ -20,4 +20,4 @@ var MindElixirLite=function(){"use strict";const Dt="";(function(e){var t,n,o,s,
|
|
|
20
20
|
|
|
21
21
|
`:t+="".padStart(s-7," ")+"- "+o[i].topic+`
|
|
22
22
|
`,o[i].children&&n(o[i].children||[],s+1)}return n(e.children||[],2),t},getDataString:function(){const e=_e(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||[]),oe(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=M(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"})),Se={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 J(e,t,n){const{offsetLeft:o,offsetTop:s}=N(e.nodes,t),i=t.offsetWidth,r=t.offsetHeight,l=o+i/2,c=s+r/2,d=l+n.x,a=c+n.y;return{w:i,h:r,cx:l,cy:c,ctrlX:d,ctrlY:a}}function R(e){let t,n;const o=(e.cy-e.ctrlY)/(e.ctrlX-e.cx);return o>e.h/e.w||o<-e.h/e.w?e.cy-e.ctrlY<0?(t=e.cx-e.h/2/o,n=e.cy+e.h/2):(t=e.cx+e.h/2/o,n=e.cy-e.h/2):e.cx-e.ctrlX<0?(t=e.cx+e.w/2,n=e.cy-e.w*o/2):(t=e.cx-e.w/2,n=e.cy+e.w*o/2),{x:t,y:n}}const it=function(e,t,n,o){const s=document.createElementNS("http://www.w3.org/2000/svg","text");return x(s,{"text-anchor":"middle",x:t+"",y:n+"",fill:o||"#666"}),s.dataset.type="custom-link",s.innerHTML=e,s},Ee=function(e,t,n,o,s){if(!t||!n)return;performance.now();const i=J(e,t,o.delta1),r=J(e,n,o.delta2),{x:l,y:c}=R(i),{ctrlX:d,ctrlY:a}=i,{ctrlX:u,ctrlY:h}=r,{x:p,y:m}=R(r),g=X(u,h,p,m),f=`M ${g.x1} ${g.y1} L ${p} ${m} L ${g.x2} ${g.y2}`;let v="";if(o.bidirectional){const L=X(d,a,l,c);v=`M ${L.x1} ${L.y1} L ${l} ${c} L ${L.x2} ${L.y2}`}const _=Fe(`M ${l} ${c} C ${d} ${a} ${u} ${h} ${p} ${m}`,f,v),b=l/8+d*3/8+u*3/8+p/8,S=c/8+a*3/8+h*3/8+m/8,w=it(o.label,b,S,e.theme.cssVar["--color"]);_.appendChild(w),_.arrowObj=o,_.dataset.linkid=o.id,e.linkSvgGroup.appendChild(_),s||(e.arrows.push(o),e.currentArrow=_,Ce(e,o,i,r)),performance.now()},rt=function(e,t,n={}){const o={id:Y(),label:"Custom Link",from:e.nodeObj.id,to:t.nodeObj.id,delta1:{x:0,y:-200},delta2:{x:0,y:-200},...n};Ee(this,e,t,o),this.bus.fire("operation",{name:"createArrow",obj:o})},lt=function(e){let t;if(e?t=e:t=this.currentArrow,!t)return;se(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}})},ct=function(e){this.currentArrow=e;const t=e.arrowObj,n=M(t.from),o=M(t.to),s=J(this,n,t.delta1),i=J(this,o,t.delta2);Ce(this,t,s,i)},at=function(){this.currentArrow=null,se(this)},se=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"},Ce=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:s,y:i}=R(n),{ctrlX:r,ctrlY:l}=n,{ctrlX:c,ctrlY:d}=o,{x:a,y:u}=R(o);e.P2.style.cssText=`top:${l}px;left:${r}px;`,e.P3.style.cssText=`top:${d}px;left:${c}px;`,x(e.line1,{x1:s+"",y1:i+"",x2:r+"",y2:l+""}),x(e.line2,{x1:c+"",y1:d+"",x2:a+"",y2:u+""}),e.helper1=Se.create(e.P2),e.helper2=Se.create(e.P3),e.helper1.init(e.map,(h,p)=>{if(!e.currentArrow)return;r=r+h/e.scaleVal,l=l+p/e.scaleVal;const m=R({...n,ctrlX:r,ctrlY:l});s=m.x,i=m.y;const g=s/8+r*3/8+c*3/8+a/8,f=i/8+l*3/8+d*3/8+u/8;if(e.P2.style.top=l+"px",e.P2.style.left=r+"px",e.currentArrow.children[0].setAttribute("d",`M ${s} ${i} C ${r} ${l} ${c} ${d} ${a} ${u}`),t.bidirectional){const v=X(r,l,s,i);e.currentArrow.children[2].setAttribute("d",`M ${v.x1} ${v.y1} L ${s} ${i} L ${v.x2} ${v.y2}`)}x(e.currentArrow.children[3],{x:g+"",y:f+""}),x(e.line1,{x1:s+"",y1:i+"",x2:r+"",y2:l+""}),t.delta1.x=r-n.cx,t.delta1.y=l-n.cy,e.bus.fire("updateArrowDelta",t)}),e.helper2.init(e.map,(h,p)=>{if(!e.currentArrow)return;c=c+h/e.scaleVal,d=d+p/e.scaleVal;const m=R({...o,ctrlX:c,ctrlY:d});a=m.x,u=m.y;const g=s/8+r*3/8+c*3/8+a/8,f=i/8+l*3/8+d*3/8+u/8,v=X(c,d,a,u);e.P3.style.top=d+"px",e.P3.style.left=c+"px",e.currentArrow.children[0].setAttribute("d",`M ${s} ${i} C ${r} ${l} ${c} ${d} ${a} ${u}`),e.currentArrow.children[1].setAttribute("d",`M ${v.x1} ${v.y1} L ${a} ${u} L ${v.x2} ${v.y2}`),x(e.currentArrow.children[3],{x:g+"",y:f+""}),x(e.line2,{x1:c+"",y1:d+"",x2:a+"",y2:u+""}),t.delta2.x=c-o.cx,t.delta2.y=d-o.cy,e.bus.fire("updateArrowDelta",t)})};function ht(){this.linkSvgGroup.innerHTML="";for(let e=0;e<this.arrows.length;e++){const t=this.arrows[e];try{Ee(this,M(t.from),M(t.to),t,!0)}catch{}}this.nodes.appendChild(this.linkSvgGroup)}function dt(e){if(se(this),!e)return;const t=e.children[3];pe(this,t,n=>{var i;const o=e.arrowObj,s=((i=n.textContent)==null?void 0:i.trim())||"";s===""?o.label=origin:o.label=s,n.remove(),s!==origin&&(t.innerHTML=o.label,this.linkDiv(),this.bus.fire("operation",{name:"finishEditArrowLabel",obj:o}))})}function ut(){this.arrows=this.arrows.filter(e=>I(e.from,this.nodeData)&&I(e.to,this.nodeData))}const ft=Object.freeze(Object.defineProperty({__proto__:null,createArrow:rt,editArrowLabel:dt,removeArrow:lt,renderArrow:ht,selectArrow:ct,tidyArrow:ut,unselectArrow:at},Symbol.toStringTag,{value:"Module"})),pt=function(e){var c,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,m=p.children,g=m==null?void 0:m.indexOf(u);u=p,h.unshift({node:u,index:g})}return h.length>t&&(t=h.length),h});let o=0;e:for(;o<t;o++){const a=(c=n[0][o])==null?void 0:c.node;for(let u=1;u<n.length;u++)if(((d=n[u][o])==null?void 0:d.node)!==a)break e}if(!o)throw new Error("Can not select root node.");const s=n.map(a=>a[o-1].index).sort(),i=s[0]||0,r=s[s.length-1]||0,l=n[0][o-1].node;if(!l.parent)throw new Error("Please select nodes in the same main topic.");return{parent:l.id,start:i,end:r}},mt=function(e){const t=document.createElementNS("http://www.w3.org/2000/svg","g");return t.setAttribute("id",e),t},Le=function(e,t){const n=document.createElementNS("http://www.w3.org/2000/svg","path");return x(n,{d:e,stroke:t||"#666",fill:"none","stroke-linecap":"round","stroke-width":"2"}),n},Me=function(e,t,n,o,s){const i=document.createElementNS("http://www.w3.org/2000/svg","text");return x(i,{"text-anchor":o,x:t+"",y:n+"",fill:s||"#666"}),i.innerHTML=e,i},gt=e=>M(e).parentElement.parentElement,vt=function({parent:e,start:t}){const n=M(e),o=n.nodeObj;let s;return o.parent?s=n.closest("me-main").className:s=M(o.children[t].id).closest("me-main").className,s},ie=function(e,t){var L;const{id:n,text:o,parent:s,start:i,end:r}=t,l=e.nodes,d=M(s).nodeObj,a=vt(t);let u=1/0,h=0,p=0,m=0;for(let W=i;W<=r;W++){const Te=(L=d.children)==null?void 0:L[W];if(!Te)return e.removeSummary(n),null;const Z=gt(Te.id),{offsetLeft:ee,offsetTop:$e}=N(l,Z),Ne=i===r?10:20;W===i&&(p=$e+Ne),W===r&&(m=$e+Z.offsetHeight-Ne),ee<u&&(u=ee),Z.offsetWidth+ee>h&&(h=Z.offsetWidth+ee)}let g,f;const v=p+10,_=m+10,b=(v+_)/2,S=e.theme.cssVar["--color"];a===T.LHS?(g=Le(`M ${u+10} ${v} c -5 0 -10 5 -10 10 L ${u} ${_-10} c 0 5 5 10 10 10 M ${u} ${b} h -10`,S),f=Me(o,u-20,b+6,"end",S)):(g=Le(`M ${h-10} ${v} c 5 0 10 5 10 10 L ${h} ${_-10} c 0 5 -5 10 -10 10 M ${h} ${b} h 10`,S),f=Me(o,h+20,b+6,"start",S));const w=mt("s-"+n);return w.appendChild(g),w.appendChild(f),w.summaryObj=t,e.summarySvg.appendChild(w),w},yt=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}=pt(e),s={id:Y(),parent:t,start:n,end:o,text:"summary"},i=ie(this,s);this.summaries.push(s),this.editSummary(i),this.bus.fire("operation",{name:"createSummary",obj:s})},createSummaryFrom:function(e){const t=Y(),n={...e,id:t};ie(this,n),this.summaries.push(n),this.bus.fire("operation",{name:"createSummary",obj:n})},editSummary:function(e){if(!e)return;const t=e.childNodes[1];pe(this,t,n=>{var i;const o=e.summaryObj,s=((i=n.textContent)==null?void 0:i.trim())||"";s===""?o.text=origin:o.text=s,n.remove(),s!==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{ie(this,e)}catch{}}),this.nodes.insertAdjacentElement("beforeend",this.summarySvg)},selectSummary:function(e){const t=e.children[1].getBBox(),n=6,o=3,s=document.createElementNS("http://www.w3.org/2000/svg","rect");x(s,{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(s),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"})),C="http://www.w3.org/2000/svg";function bt(e,t){const n=document.createElementNS(C,"svg");return x(n,{version:"1.1",xmlns:C,height:e,width:t}),n}function xt(e,t){return(parseInt(e)-parseInt(t))/2}function wt(e,t,n,o){const s=document.createElementNS(C,"g");let i="";return e.text?i=e.text.textContent:i=e.childNodes[0].textContent,i.split(`
|
|
23
|
-
`).forEach((l,c)=>{const d=document.createElementNS(C,"text");x(d,{x:n+parseInt(t.paddingLeft)+"",y:o+parseInt(t.paddingTop)+xt(t.lineHeight,t.fontSize)*(c+1)+parseFloat(t.fontSize)*(c+1)+"","text-anchor":"start","font-family":t.fontFamily,"font-size":`${t.fontSize}`,"font-weight":`${t.fontWeight}`,fill:`${t.color}`}),d.innerHTML=l,s.appendChild(d)}),s}function _t(e,t,n,o){var l;let s="";(l=e.nodeObj)!=null&&l.dangerouslySetInnerHTML?s=e.nodeObj.dangerouslySetInnerHTML:e.text?s=e.text.textContent:s=e.childNodes[0].textContent;const i=document.createElementNS(C,"foreignObject");x(i,{x:n+parseInt(t.paddingLeft)+"",y:o+parseInt(t.paddingTop)+"",width:t.width,height:t.height});const r=document.createElement("div");return x(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=s,i.appendChild(r),i}function St(e,t){const n=getComputedStyle(t),{offsetLeft:o,offsetTop:s}=N(e.nodes,t),i=document.createElementNS(C,"rect");return x(i,{x:o+"",y:s+"",rx:n.borderRadius,ry:n.borderRadius,width:n.width,height:n.height,fill:n.backgroundColor,stroke:n.borderColor,"stroke-width":n.borderWidth}),i}function U(e,t,n=!1){const o=getComputedStyle(t),{offsetLeft:s,offsetTop:i}=N(e.nodes,t),r=document.createElementNS(C,"rect");x(r,{x:s+"",y:i+"",rx:o.borderRadius,ry:o.borderRadius,width:o.width,height:o.height,fill:o.backgroundColor,stroke:o.borderColor,"stroke-width":o.borderWidth});const l=document.createElementNS(C,"g");l.appendChild(r);let c;return n?c=_t(t,o,s,i):c=wt(t,o,s,i),l.appendChild(c),l}function Et(e,t){const n=getComputedStyle(t),{offsetLeft:o,offsetTop:s}=N(e.nodes,t),i=document.createElementNS(C,"a"),r=document.createElementNS(C,"text");return x(r,{x:o+"",y:s+parseInt(n.fontSize)+"","text-anchor":"start","font-family":n.fontFamily,"font-size":`${n.fontSize}`,"font-weight":`${n.fontWeight}`,fill:`${n.color}`}),r.innerHTML=t.textContent,i.appendChild(r),i.setAttribute("href",t.href),i}function Ct(e,t){const n=getComputedStyle(t),{offsetLeft:o,offsetTop:s}=N(e.nodes,t),i=document.createElementNS(C,"image");return x(i,{x:o+"",y:s+"",width:n.width+"",height:n.height+"",href:t.src}),i}const Q=100,Lt='<?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">',Mt=(e,t=!1)=>{var u,h,p;const n=e.nodes,o=n.offsetHeight+Q*2,s=n.offsetWidth+Q*2,i=bt(o+"px",s+"px"),r=document.createElementNS(C,"svg"),l=document.createElementNS(C,"rect");x(l,{x:"0",y:"0",width:`${s}`,height:`${o}`,fill:e.theme.cssVar["--bgcolor"]}),i.appendChild(l),n.querySelectorAll(".subLines").forEach(m=>{const g=m.cloneNode(!0),{offsetLeft:f,offsetTop:v}=N(n,m.parentElement);g.setAttribute("x",`${f}`),g.setAttribute("y",`${v}`),r.appendChild(g)});const c=(u=n.querySelector(".lines"))==null?void 0:u.cloneNode(!0);c&&r.appendChild(c);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(m=>{m.nodeObj.dangerouslySetInnerHTML?r.appendChild(U(e,m,!t)):(r.appendChild(St(e,m)),r.appendChild(U(e,m.text,!t)))}),n.querySelectorAll(".tags > span").forEach(m=>{r.appendChild(U(e,m))}),n.querySelectorAll(".icons > span").forEach(m=>{r.appendChild(U(e,m))}),n.querySelectorAll(".hyper-link").forEach(m=>{r.appendChild(Et(e,m))}),n.querySelectorAll("img").forEach(m=>{r.appendChild(Ct(e,m))}),x(r,{x:Q+"",y:Q+"",overflow:"visible"}),i.appendChild(r),i},Tt=(e,t)=>(t&&e.insertAdjacentHTML("afterbegin","<style>"+t+"</style>"),Lt+e.outerHTML);function $t(e){return new Promise((t,n)=>{const o=new FileReader;o.onload=s=>{t(s.target.result)},o.onerror=s=>{n(s)},o.readAsDataURL(e)})}const Nt={getObjById:I,generateNewObj:Ae,layout:De,linkDiv:We,editTopic:qe,createWrapper:ze,createParent:Oe,createChildren:je,createTopic:Re,findEle:M,changeTheme:nt,...st,...{},...ft,...yt,...Object.freeze(Object.defineProperty({__proto__:null,exportPng:async function(e=!1,t){const n=this.exportSvg(e,t),o=await $t(n);return new Promise((s,i)=>{const r=new Image;r.setAttribute("crossOrigin","anonymous"),r.onload=()=>{const l=document.createElement("canvas");l.width=r.width,l.height=r.height,l.getContext("2d").drawImage(r,0,0),l.toBlob(s,"image/png",1)},r.src=o,r.onerror=i})},exportSvg:function(e=!1,t){const n=Mt(this,e),o=Tt(n,t);return new Blob([o],{type:"image/svg+xml"})}},Symbol.toStringTag,{value:"Module"})),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,oe(this.nodeData),this.arrows=e.arrows||[],this.summaries=e.summaries||[],this.tidyArrow(),this.toolBar&&Ye(this),this.toCenter(),this.layout(),this.linkDiv()},destroy(){var e;this.disposable.forEach(t=>t()),this.el&&(this.el.innerHTML=""),this.el=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 At({pT:e,pL:t,pW:n,pH:o,cT:s,cL:i,cW:r,cH:l,direction:c,containerHeight:d}){let a=t+n/2;const u=e+o/2;let h;c===T.LHS?h=i+r:h=i;const p=s+l/2,g=(1-Math.abs(p-u)/d)*.25*(n/2);return c===T.LHS?a=a-n/10-g:a=a+n/10+g,`M ${a} ${u} Q ${a} ${p} ${h} ${p}`}function kt({pT:e,pL:t,pW:n,pH:o,cT:s,cL:i,cW:r,cH:l,direction:c,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=s+l;let m=0,g=0,f=0;const v=Math.abs(u-p)/300*a;return c===T.LHS?(f=t,m=f+a,g=f-a,h=i+a,`M ${m} ${u} C ${f} ${u} ${f+v} ${p} ${g} ${p} H ${h}`):(f=t+n,m=f-a,g=f+a,h=i+r-a,`M ${m} ${u} C ${f} ${u} ${f-v} ${p} ${g} ${p} H ${h}`)}const Ht="4.6.
|
|
23
|
+
`).forEach((l,c)=>{const d=document.createElementNS(C,"text");x(d,{x:n+parseInt(t.paddingLeft)+"",y:o+parseInt(t.paddingTop)+xt(t.lineHeight,t.fontSize)*(c+1)+parseFloat(t.fontSize)*(c+1)+"","text-anchor":"start","font-family":t.fontFamily,"font-size":`${t.fontSize}`,"font-weight":`${t.fontWeight}`,fill:`${t.color}`}),d.innerHTML=l,s.appendChild(d)}),s}function _t(e,t,n,o){var l;let s="";(l=e.nodeObj)!=null&&l.dangerouslySetInnerHTML?s=e.nodeObj.dangerouslySetInnerHTML:e.text?s=e.text.textContent:s=e.childNodes[0].textContent;const i=document.createElementNS(C,"foreignObject");x(i,{x:n+parseInt(t.paddingLeft)+"",y:o+parseInt(t.paddingTop)+"",width:t.width,height:t.height});const r=document.createElement("div");return x(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=s,i.appendChild(r),i}function St(e,t){const n=getComputedStyle(t),{offsetLeft:o,offsetTop:s}=N(e.nodes,t),i=document.createElementNS(C,"rect");return x(i,{x:o+"",y:s+"",rx:n.borderRadius,ry:n.borderRadius,width:n.width,height:n.height,fill:n.backgroundColor,stroke:n.borderColor,"stroke-width":n.borderWidth}),i}function U(e,t,n=!1){const o=getComputedStyle(t),{offsetLeft:s,offsetTop:i}=N(e.nodes,t),r=document.createElementNS(C,"rect");x(r,{x:s+"",y:i+"",rx:o.borderRadius,ry:o.borderRadius,width:o.width,height:o.height,fill:o.backgroundColor,stroke:o.borderColor,"stroke-width":o.borderWidth});const l=document.createElementNS(C,"g");l.appendChild(r);let c;return n?c=_t(t,o,s,i):c=wt(t,o,s,i),l.appendChild(c),l}function Et(e,t){const n=getComputedStyle(t),{offsetLeft:o,offsetTop:s}=N(e.nodes,t),i=document.createElementNS(C,"a"),r=document.createElementNS(C,"text");return x(r,{x:o+"",y:s+parseInt(n.fontSize)+"","text-anchor":"start","font-family":n.fontFamily,"font-size":`${n.fontSize}`,"font-weight":`${n.fontWeight}`,fill:`${n.color}`}),r.innerHTML=t.textContent,i.appendChild(r),i.setAttribute("href",t.href),i}function Ct(e,t){const n=getComputedStyle(t),{offsetLeft:o,offsetTop:s}=N(e.nodes,t),i=document.createElementNS(C,"image");return x(i,{x:o+"",y:s+"",width:n.width+"",height:n.height+"",href:t.src}),i}const Q=100,Lt='<?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">',Mt=(e,t=!1)=>{var u,h,p;const n=e.nodes,o=n.offsetHeight+Q*2,s=n.offsetWidth+Q*2,i=bt(o+"px",s+"px"),r=document.createElementNS(C,"svg"),l=document.createElementNS(C,"rect");x(l,{x:"0",y:"0",width:`${s}`,height:`${o}`,fill:e.theme.cssVar["--bgcolor"]}),i.appendChild(l),n.querySelectorAll(".subLines").forEach(m=>{const g=m.cloneNode(!0),{offsetLeft:f,offsetTop:v}=N(n,m.parentElement);g.setAttribute("x",`${f}`),g.setAttribute("y",`${v}`),r.appendChild(g)});const c=(u=n.querySelector(".lines"))==null?void 0:u.cloneNode(!0);c&&r.appendChild(c);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(m=>{m.nodeObj.dangerouslySetInnerHTML?r.appendChild(U(e,m,!t)):(r.appendChild(St(e,m)),r.appendChild(U(e,m.text,!t)))}),n.querySelectorAll(".tags > span").forEach(m=>{r.appendChild(U(e,m))}),n.querySelectorAll(".icons > span").forEach(m=>{r.appendChild(U(e,m))}),n.querySelectorAll(".hyper-link").forEach(m=>{r.appendChild(Et(e,m))}),n.querySelectorAll("img").forEach(m=>{r.appendChild(Ct(e,m))}),x(r,{x:Q+"",y:Q+"",overflow:"visible"}),i.appendChild(r),i},Tt=(e,t)=>(t&&e.insertAdjacentHTML("afterbegin","<style>"+t+"</style>"),Lt+e.outerHTML);function $t(e){return new Promise((t,n)=>{const o=new FileReader;o.onload=s=>{t(s.target.result)},o.onerror=s=>{n(s)},o.readAsDataURL(e)})}const Nt={getObjById:I,generateNewObj:Ae,layout:De,linkDiv:We,editTopic:qe,createWrapper:ze,createParent:Oe,createChildren:je,createTopic:Re,findEle:M,changeTheme:nt,...st,...{},...ft,...yt,...Object.freeze(Object.defineProperty({__proto__:null,exportPng:async function(e=!1,t){const n=this.exportSvg(e,t),o=await $t(n);return new Promise((s,i)=>{const r=new Image;r.setAttribute("crossOrigin","anonymous"),r.onload=()=>{const l=document.createElement("canvas");l.width=r.width,l.height=r.height,l.getContext("2d").drawImage(r,0,0),l.toBlob(s,"image/png",1)},r.src=o,r.onerror=i})},exportSvg:function(e=!1,t){const n=Mt(this,e),o=Tt(n,t);return new Blob([o],{type:"image/svg+xml"})}},Symbol.toStringTag,{value:"Module"})),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,oe(this.nodeData),this.arrows=e.arrows||[],this.summaries=e.summaries||[],this.tidyArrow(),this.toolBar&&Ye(this),this.toCenter(),this.layout(),this.linkDiv()},destroy(){var e;this.disposable.forEach(t=>t()),this.el&&(this.el.innerHTML=""),this.el=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 At({pT:e,pL:t,pW:n,pH:o,cT:s,cL:i,cW:r,cH:l,direction:c,containerHeight:d}){let a=t+n/2;const u=e+o/2;let h;c===T.LHS?h=i+r:h=i;const p=s+l/2,g=(1-Math.abs(p-u)/d)*.25*(n/2);return c===T.LHS?a=a-n/10-g:a=a+n/10+g,`M ${a} ${u} Q ${a} ${p} ${h} ${p}`}function kt({pT:e,pL:t,pW:n,pH:o,cT:s,cL:i,cW:r,cH:l,direction:c,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=s+l;let m=0,g=0,f=0;const v=Math.abs(u-p)/300*a;return c===T.LHS?(f=t,m=f+a,g=f-a,h=i+a,`M ${m} ${u} C ${f} ${u} ${f+v} ${p} ${g} ${p} H ${h}`):(f=t+n,m=f-a,g=f+a,h=i+r-a,`M ${m} ${u} C ${f} ${u} ${f-v} ${p} ${g} ${p} H ${h}`)}const Ht="4.6.2",F=document;function $({el:e,direction:t,locale:n,draggable:o,editable:s,contextMenu:i,toolBar:r,keypress:l,mouseSelectionButton:c,selectionContainer:d,before:a,newTopicName:u,allowUndo:h,generateMainBranch:p,generateSubBranch:m,overflowHidden:g,theme:f,alignment:v,scaleSensitivity:_}){let b=null;const S=Object.prototype.toString.call(e);if(S==="[object HTMLDivElement]"?b=e:S==="[object String]"&&(b=document.querySelector(e)),!b)throw new Error("MindElixir: el is not a valid element");b.style.position="relative",b.innerHTML="",this.el=b,this.disposable=[],this.before=a||{},this.locale=n||"en",this.contextMenu=i===void 0?!0:i,this.toolBar=r===void 0?!0:r,this.keypress=l===void 0?!0:l,this.mouseSelectionButton=c||0,this.direction=typeof t=="number"?t:1,this.draggable=o===void 0?!0:o,this.newTopicName=u||"new node",this.editable=s===void 0?!0:s,this.allowUndo=h===void 0?!1:h,this.scaleSensitivity=typeof _=="number"?_:.2,this.currentNode=null,this.currentArrow=null,this.scaleVal=1,this.tempDirection=null,this.generateMainBranch=p||At,this.generateSubBranch=m||kt,this.overflowHidden=g||!1,this.bus=He.create(),this.container=F.createElement("div"),this.selectionContainer=d||this.container,this.container.className="map-container";const w=window.matchMedia("(prefers-color-scheme: dark)");this.theme=f||(w.matches?le:re);const L=F.createElement("div");L.className="map-canvas",this.map=L,this.map.setAttribute("tabindex","0"),this.container.appendChild(this.map),this.el.appendChild(this.container),this.nodes=F.createElement("me-nodes"),this.nodes.className="main-node-container",this.lines=V("lines"),this.summarySvg=V("summary"),this.linkController=V("linkcontroller"),this.P2=F.createElement("div"),this.P3=F.createElement("div"),this.P2.className=this.P3.className="circle",this.P2.style.display=this.P3.style.display="none",this.line1=fe(),this.line2=fe(),this.linkController.appendChild(this.line1),this.linkController.appendChild(this.line2),this.linkSvgGroup=V("topiclinks"),this.alignment=v??"root",this.map.appendChild(this.nodes),this.overflowHidden?this.container.style.overflow="hidden":ke(this)}return $.prototype=Nt,$.LEFT=B,$.RIGHT=te,$.SIDE=ne,$.THEME=re,$.DARK_THEME=le,$.version=Ht,$.E=M,$.dragMoveHelper=A,$}();
|
package/dist/MindElixirLite.js
CHANGED
|
@@ -1575,7 +1575,7 @@ function fn({ pT: e, pL: t, pW: n, pH: o, cT: s, cL: i, cW: r, cH: l, direction:
|
|
|
1575
1575
|
const v = Math.abs(u - p) / 300 * a;
|
|
1576
1576
|
return c === T.LHS ? (f = t, m = f + a, g = f - a, h = i + a, `M ${m} ${u} C ${f} ${u} ${f + v} ${p} ${g} ${p} H ${h}`) : (f = t + n, m = f - a, g = f + a, h = i + r - a, `M ${m} ${u} C ${f} ${u} ${f - v} ${p} ${g} ${p} H ${h}`);
|
|
1577
1577
|
}
|
|
1578
|
-
const pn = "4.6.
|
|
1578
|
+
const pn = "4.6.2", V = document;
|
|
1579
1579
|
function $({
|
|
1580
1580
|
el: e,
|
|
1581
1581
|
direction: t,
|