"use strict";var C=require("obsidian");class e extends C.Events{trigger(C,...e){super.trigger(C,...e)}on(C,e,t){return super.on(C,e,t)}}const t="pinned",H="expanded",V="active-node",i="inactive-node",L="connected-active-node",n="hover",r="unhover",o="protected",a="connected-hover",M="filtered",s="hard-filtered",l=[t,H,V,i,L,n,r,a,o,M,s],d=function(C){return`${C.configDir}/plugins/juggl/`},u="core";class c{constructor(C,e){this.id=C,this.storeId=e}toString(){return`${this.storeId}:${this.id}`}toId(){return this.toString()}static fromId(C){const e=C.split(":"),t=e[0],H=e.slice(1).join(":");return new c(H,t)}static fromNode(C){return c.fromId(C.id())}static fromNodes(C){return C.map((C=>c.fromNode(C)))}static fromFile(C){return new c(C.name,"core")}static toId(C,e){return new c(C,e).toId()}}const A=function(C){return[].concat(...C.map((C=>{const e=(C=C.slice(1)).split("/"),t=[];for(const C in e){const H=e.slice(0,parseInt(C)+1).join("-");t.push(`tag-${H}`)}return t})))},h=async function(e,t,H,V){V||(V=c.toId(e.name,u));const i=t.app.metadataCache.getFileCache(e),L="md"===e.extension?e.basename:e.name,n=function(e,t){if(e){const H=[];if(["png","jpg","jpeg","gif","bmp","svg","tiff"].contains(e.extension)?H.push("image"):["mp3","webm","wav","m4a","ogg","3gp","flac"].contains(e.extension)?H.push("audio"):["mp4","webm","ogv"].contains(e.extension)?H.push("video"):"pdf"===e.extension&&H.push("pdf"),"md"===e.extension){H.push("note");const V=t.getFileCache(e);if(V?.frontmatter){if("image"in V.frontmatter&&H.push("image"),"tags"in V.frontmatter){const e=C.parseFrontMatterTags(V.frontmatter);e&&H.push(...A(e))}if("cssclass"in V.frontmatter){const e=C.parseFrontMatterStringArray(V.frontmatter,"cssclass");e&&H.push(...e)}}V?.tags&&H.push(...A(V.tags.map((C=>C.tag))))}else H.push("file");return H}return["dangling"]}(e,t.app.metadataCache).join(" "),r={id:V,name:L,path:e.path};if(["png","jpg","jpeg","gif","bmp","svg","tiff"].contains(e.extension))try{r.resource_url=`http://localhost:${t.settings.imgServerPort}/${encodeURI(e.path)}`}catch{}H.readContent&&"md"==e.extension&&(r.content=await t.app.vault.cachedRead(e));const o=i?.frontmatter;return o&&Object.keys(o).forEach((C=>{if("position"!==C)if("image"===C){const e=o[C];try{new URL(e),r[C]=e}catch{try{r[C]=`http://localhost:${t.settings.imgServerPort}/${encodeURI(e)}`}catch{}}}else r[C]=o[C]})),{group:"nodes",data:r,classes:n}},m="\\[\\[([^\\]\\r\\n]+?)\\]\\]",f=function(C){return C.replace(/[-\/\\^$*+?.()|[\]{}]/g,"\\$&")},p=function(C,e,t,H,V,i){const L=e[C.position.start.line];let n={id:t,source:H,target:V,context:L,edgeCount:1,line:C.position.start.line,start:C.position.start.col,end:C.position.end.col};console.log(C);const r=C.original.split("|");r.length>1&&(n.alias=r.slice(1).join().slice(0,-2));let o="";const a=function(C,e,t){const H=new RegExp(`^${f(t)} (publishedIn) (\\d\\d\\d\\d) (${m},? *)+$`).exec(e);if(null!==H)return{class:"type-publishedIn",isInline:!1,properties:{year:H[2],context:"",type:"publishedIn"}};const V=new RegExp(`^${f(t)} ([^\\W\\d]\\w*) (${m},? *)+$`).exec(e),i=C.original.split("|");let L=null;return i.length>1&&(L=i.slice(1).join().slice(0,-2)),null!==V?{class:`type-${V[1]}`,isInline:!1,properties:{alias:L,context:"",type:V[1]}}:null}(C,L,i);return null===a?o=`${o} inline`:(n={...a.properties,...n},o=`${o} ${a.class}`),{group:"edges",data:n,classes:o}},g="juggl_view",v="juggl_nodes",y="juggl_style",Z="Obsidian";class S extends C.Component{constructor(C){super(),this.plugin=C,this.events=new e,this.metadata=C.app.metadataCache,this.vault=C.app.vault}getEvents(C){return this.events}async createEdges(C,e,t,H){if("md"!==C.extension)return[];const V=this.metadata.getFileCache(C);if(!V)return[];const i={},L=(await this.vault.cachedRead(C)).split("\n");if(this.iterLinks(V,((H,V)=>{const n=this.getOtherId(H,C.path).toId();if(t.$id(n).length>0){const C=`${e}->${n}`,t=`${C}${C in i?i[C].length+1:1}`;let r;if(V)r=p(H,L,t,e,n,this.plugin.settings.typedLinkPrefix);else{const C=H,V=C.key.split(".");let i;i=V.length>1?V.slice(0,-1).join():C.key,r={group:"edges",data:{id:t,source:e,target:n,context:"",edgeCount:1,type:i},classes:[i,"type-"+i,"type-"+i.replaceAll(" ","-")]}}C in i?i[C].push(r):i[C]=[r]}})),H.settings.mergeEdges){const C=[];for(const e of Object.keys(i)){const t=i[e];let H=null,V=0;for(const e of t)" inline"===e.classes?H?(H.data.context+=`\n \n---\n\n${e.data.context}`,V+=1):(H=e,V=1):C.push(e);H&&(H.data.edgeCount=V,C.push(H))}return C}return[].concat(...Object.values(i))}async connectNodes(C,e,t){const H=[];for(const V of e){const e=c.fromNode(V);if(e.storeId===this.storeId()){const V=this.getFile(e);if(V){const i=e.toId();H.push(...await this.createEdges(V,i,C,t))}}}for(const V of C.difference(e)){const C=c.fromNode(V);if(C.storeId===this.storeId()){const V=this.getFile(C);if(V){const i=C.toId();H.push(...await this.createEdges(V,i,e,t))}}}return H}getOtherId(e,t){const H=C.getLinkpath(e.link),V=this.metadata.getFirstLinkpathDest(H,t);return new c(V?V.name:H,this.storeId())}async getNodeFromLink(e,t,H){const V=C.getLinkpath(e.link),i=this.metadata.getFirstLinkpathDest(V,t);return i?await h(i,this.plugin,H.settings):function(C){return{group:"nodes",data:{id:c.toId(C,u),name:C},classes:"dangling"}}(V)}getFile(C){return this.metadata.getFirstLinkpathDest(C.id,"")}async fillWithBacklinks(C,e,t){if("core"===e.storeId){const H=this.getFile(e);if(!H)return void console.log("Couldn't get file when filling with backlinks. This should not happen.");const V=H.path,i=this.metadata.resolvedLinks;for(const e of Object.keys(i))if(V in i[e]){const H=this.vault.getAbstractFileByPath(e),V=c.fromFile(H).toId();V in C||(C[V]=await h(H,this.plugin,t.settings))}}}iterLinks(e,t){if(C.iterateCacheRefs(e,(C=>t(C,!0))),e.frontmatterLinks)for(const C of e.frontmatterLinks)t(C,!1)}async getNeighbourhood(C,e){const t={};for(const H of C)if(H.storeId===this.storeId()){const C=this.getFile(H);if(null===C)continue;const V=this.metadata.getFileCache(C);if(null===V)continue;H.toId()in t||(t[H.toId()]=await h(C,this.plugin,e.settings));const i={};this.iterLinks(V,((H,V)=>{const L=this.getOtherId(H,C.path).toId();L in t||(i[L]=this.getNodeFromLink(H,C.path,e))}));for(const C of Object.keys(i))C in t||(t[C]=await i[C]);await this.fillWithBacklinks(t,H,e)}return Object.values(t)}storeId(){return"core"}get(C,e){const t=this.getFile(C);if(null===t)return Promise.resolve(null);return null===this.metadata.getFileCache(t)?(console.log("returning empty cache",C,e),Promise.resolve(null)):Promise.resolve(h(t,this.plugin,e.settings))}async refreshNode(C,e){const t=C.toId();let V,i=e.viz.$id(t);if(null===this.getFile(C))return void(i&&(i.remove(),e.onGraphChanged(!0,!0)));if(i.length>0&&i.hasClass(H))V=await e.expand(i,!0,!1);else{const H=await this.get(C,e);if(!H)return void console.log("Failed to get node definition on refresh. This should not happen!");e.mergeToGraph([H],!0,!1),i=e.viz.$id(t);const L=await e.buildEdges(i);V=e.mergeToGraph(L,!0,!1)}(i.connectedEdges().difference(V.merged).remove().length>0||V.added.length>0)&&e.onGraphChanged(!0,!0)}onload(){super.onload();const e=this;this.registerEvent(this.metadata.on("changed",(C=>{e.plugin.activeGraphs().forEach((async t=>{await e.refreshNode(c.fromFile(C),t)}))}))),this.registerEvent(this.vault.on("rename",((t,H)=>{if(t instanceof C.TFile){const C=c.fromFile(t),V=c.fromPath(H);e.plugin.activeGraphs().forEach((async t=>{setTimeout((async()=>{t.viz.$id(V.toId()).remove(),await e.refreshNode(C,t)}),500)}))}}))),this.registerEvent(this.vault.on("delete",(t=>{t instanceof C.TFile&&e.plugin.activeGraphs().forEach((C=>{C.viz.$id(c.fromFile(t).toId()).remove()}))})))}}function b(){}function w(C){return C()}function x(){return Object.create(null)}function O(C){C.forEach(w)}function k(C){return"function"==typeof C}function E(C,e){return C!=C?e==e:C!==e||C&&"object"==typeof C||"function"==typeof C}let P,T;function B(C,e){C.appendChild(e)}function _(C,e,t){C.insertBefore(e,t||null)}function D(C){C.parentNode&&C.parentNode.removeChild(C)}function R(C,e){for(let t=0;tC.removeEventListener(e,t,H)}function W(C,e,t){null==t?C.removeAttribute(e):C.getAttribute(e)!==t&&C.setAttribute(e,t)}function U(C,e){e=""+e,C.data!==e&&(C.data=e)}function $(C,e){C.value=null==e?"":e}function Y(C,e,t,H){null==t?C.style.removeProperty(e):C.style.setProperty(e,t,H?"important":"")}function X(C,e,t){for(let t=0;t{rC.delete(C),H&&(t&&C.d(1),H())})),C.o(e)}else H&&H()}function sC(C){return void 0!==C?.length?C:Array.from(C)}function lC(C){C&&C.c()}function dC(C,e,t){const{fragment:H,after_update:V}=C.$$;H&&H.m(e,t),HC((()=>{const e=C.$$.on_mount.map(w).filter(k);C.$$.on_destroy?C.$$.on_destroy.push(...e):O(e),C.$$.on_mount=[]})),V.forEach(HC)}function uC(C,e){const t=C.$$;null!==t.fragment&&(!function(C){const e=[],t=[];J.forEach((H=>-1===C.indexOf(H)?e.push(H):t.push(H))),t.forEach((C=>C())),J=e}(t.after_update),O(t.on_destroy),t.fragment&&t.fragment.d(e),t.on_destroy=t.fragment=null,t.ctx=[])}function cC(C,e){-1===C.$$.dirty[0]&&(Q.push(C),tC||(tC=!0,eC.then(LC)),C.$$.dirty.fill(0)),C.$$.dirty[e/31|0]|=1<{const i=H.length?H[0]:t;return o.ctx&&V(o.ctx[e],o.ctx[e]=i)&&(!o.skip_bound&&o.bound[e]&&o.bound[e](i),a&&cC(C,e)),t})):[],o.update(),a=!0,O(o.before_update),o.fragment=!!H&&H(o.ctx),e.target){if(e.hydrate){const C=function(C){return Array.from(C.childNodes)}(e.target);o.fragment&&o.fragment.l(C),C.forEach(D)}else o.fragment&&o.fragment.c();e.intro&&aC(C.$$.fragment),dC(C,e.target,e.anchor),LC()}q(r)}class hC{$$=void 0;$$set=void 0;$destroy(){uC(this,1),this.$destroy=b}$on(C,e){if(!k(e))return b;const t=this.$$.callbacks[C]||(this.$$.callbacks[C]=[]);return t.push(e),()=>{const C=t.indexOf(e);-1!==C&&t.splice(C,1)}}$set(C){var e;this.$$set&&(e=C,0!==Object.keys(e).length)&&(this.$$.skip_bound=!0,this.$$set(C),this.$$.skip_bound=!1)}}"undefined"!=typeof window&&(window.__svelte||(window.__svelte={v:new Set})).v.add("4");const mC=function(C){return`${C.configDir}/plugins/juggl/graph.css`},fC=["ellipse","rectangle","triangle","diamond","pentagon","hexagon","tag","rhomboid","star","vee","round-rectangle","round-triangle","round-diamond","round-pentagon","round-hexagon","round-tag"],pC="\n/* For a full overview of styling options, see https://js.cytoscape.org/#style */\n",gC=function(C){const e=activeDocument.createElement("div");e.addClass("graph-view",C),activeDocument.body.appendChild(e);const t=getComputedStyle(e).getPropertyValue("color");return e.detach(),t};class vC{constructor(C){this.defaultSheet=this.getDefaultStylesheet(),this.yamlModifySheet="\n\n\nnode[title] {\n label: data(title);\n}\n\nnode[color] {\n background-color: data(color);\n}\n\nnode[shape] {\n shape: data(shape);\n}\n\nnode[width] {\n width: data(width);\n}\n\nnode[height] {\n height: data(height);\n}\n\nnode[image] {\n background-image: data(image);\n}\n",this.plugin=C}async getStylesheet(C){const e=this.plugin.vault.adapter,t=mC(this.plugin.vault);let H="";try{H=await e.read(t).catch((async C=>{if("ENOENT"===C.code){const C=pC;return await e.write(t,C),C}throw C}))}catch(C){console.log("Couldn't load user stylesheet. This is probably because we are on mobile"),console.log(C)}let V="";"settings"in this.plugin&&(V=this.styleGroupsToSheet(this.plugin.settings.globalStyleGroups,"global"));const i=this.styleGroupsToSheet(C.settings.styleGroups,"local");return this.defaultSheet+V+H+i+this.yamlModifySheet}colorToRGBA(C){const e=activeDocument.createElement("canvas");e.width=e.height=1;const t=e.getContext("2d");t.clearRect(0,0,1,1),t.fillStyle="#000",t.fillStyle=C;const H=t.fillStyle;if(t.fillStyle="#fff",t.fillStyle=C,H!==t.fillStyle)return;t.fillRect(0,0,1,1);const V=[...t.getImageData(0,0,1,1).data];return`rgb(${V[0]}, ${V[1]}, ${V[2]})`}styleGroupsToSheet(C,e){let t="";const H=new DOMParser;for(const[V,i]of C.entries())if(i.show){let C="";if(i.icon&&i.icon.path){const e=``,t=H.parseFromString(e,"text/xml").documentElement.outerHTML;C=`background-image: url('data:image/svg+xml,${encodeURIComponent(t)}');`}const L=Math.max(Math.min(i.size,1),Math.sqrt(i.size));t+=`\nnode.${e}-${V} {\n background-color: ${i.color};\n shape: ${i.shape};\n background-fit: contain;\n ${C} \n width: mapData(degree, 0, 60, ${5*i.size}, ${35*i.size});\n height: mapData(degree, 0, 60, ${5*i.size}, ${35*i.size});\n font-size: mapData(degree, 0, 60, ${5*L}, ${11*L});\n text-max-width: mapData(degree, 0, 60, ${Math.round(65*L)}px, ${Math.round(100*L)}px);\n} \n`}else t+=`\nnode.${e}-${V} {\n display: none;\n}\n`;return t}getDefaultStylesheet(){let C=getComputedStyle(activeDocument.body).getPropertyValue("--text");C=C.replace("BlinkMacSystemFont,",""),0===C.length&&(C="Helvetica Neue");const e=gC("color-fill"),t=gC("color-fill-highlight"),H=gC("color-circle"),V=gC("color-line"),i=gC("color-line-highlight"),L=gC("color-text");return`\nnode {\n background-color: ${e};\n color: ${L};\n font-family: ${C};\n text-valign: bottom;\n shape: ellipse;\n border-width: 0;\n text-wrap: wrap;\n min-zoomed-font-size: 8;\n}\n\nnode[name] {\n label: data(name);\n}\nnode[degree] {\n width: mapData(degree, 0, 60, 5, 35);\n height: mapData(degree, 0, 60, 5, 35);\n font-size: mapData(degree, 0, 60, 5, 11);\n text-opacity: mapData(degree, 0, 60, 0.7, 1);\n text-max-width: mapData(degree, 0, 60, 65px, 100px);\n}\n\nnode:selected {\n background-blacken: 0.3;\n font-weight: bold;\n \n}\nnode:selected[degree] {\n border-width: mapData(degree, 0, 60, 1, 3);\n}\n\n.dangling {\n background-color: ${gC("color-fill-unresolved")};\n}\n\n.image {\n shape: round-rectangle;\n width: 50;\n height: 50;\n background-opacity: 0;\n background-image: data(resource_url);\n background-image-crossorigin: anonymous;\n background-image-opacity: 1;\n background-fit: contain;\n font-size: 0;\n background-clip: node;\n}\n\n.image.note {\n font-size: mapData(degree, 0, 60, 5, 11);\n}\n\nedge {\n line-color: ${V};\n loop-sweep: -50deg;\n loop-direction: -45deg;\n width: 0.70;\n \n target-arrow-shape: vee;\n target-arrow-fill: filled;\n target-arrow-color: ${V};\n \n arrow-scale: 0.55;\n\n font-size: 6;\n font-family: ${C};\n color: ${L};\n curve-style: straight;\n\n}\n\nedge[edgeCount] {\n width: mapData(edgeCount, 1, 50, 0.55, 3);\n arrow-scale: mapData(edgeCount, 1, 50, 0.35, 1.5);\n}\n\nedge:selected {\n width: 0.7;\n font-weight: bold;\n line-color: ${i};\n}\n\n:loop {\n display: none;\n}\n\nedge[type] {\n label: data(type);\n}\n.inactive-node,\n.unhover {\n opacity: 0.3;\n}\nnode.active-node,\nnode.hover {\n background-color: ${t};\n font-weight: bold;\n border-width: 0.4;\n border-color: ${H};\n opacity: 1;\n}\nedge.hover,\nedge.connected-active-node,\nedge.connected-hover {\n width: 1;\n opacity: 1;\n}\nedge.hover,\nedge.connected-hover {\n font-weight: bold;\n line-color: ${i}; \n target-arrow-color: ${i};\n}\n\nnode.pinned {\n border-style: dotted;\n border-width: 2;\n}\n\nnode.hard-filtered,\nnode.filtered {\n display: none;\n}\n`}}function yC(C){let e,t,H,V,i,L,n,r,o,a,M,s;return{c(){e=F("h3"),e.textContent="Appearance",t=z(),H=F("p"),V=I("You can style the graph with css. This is done in the "),i=I(C[0]),L=I(" file.\n See "),n=F("a"),n.textContent="this page",r=I(" for help with styling."),o=z(),a=F("button"),a.textContent="Open graph.css in default editor.",W(n,"href","https://publish.obsidian.md/semantic-obsidian/Node+styling")},m(l,d){_(l,e,d),_(l,t,d),_(l,H,d),B(H,V),B(H,i),B(H,L),B(H,n),B(H,r),_(l,o,d),_(l,a,d),M||(s=G(a,"click",C[1]),M=!0)},p:b,i:b,o:b,d(C){C&&(D(e),D(t),D(H),D(o),D(a)),M=!1,s()}}}function ZC(C,e,t){let{plugin:H}=e,V=mC(H.vault);return C.$$set=C=>{"plugin"in C&&t(2,H=C.plugin)},[V,async function(){let C=H.vault.adapter.getFullPath(V);try{const e=require("electron").shell,{promises:t}=require("fs");await t.writeFile(C,pC,{flag:"wx"}).catch((C=>{})),await e.openPath(C)}catch(C){console.log("Couldn't open graph.css. This is probably because we are on mobile."),console.log(C)}},H]}class SC extends hC{constructor(C){super(),AC(this,C,ZC,yC,E,{plugin:2})}}function bC(C){let e,t,H,V,i,L;return{c(){var C,i;e=F("script"),e.innerHTML="",H=z(),V=F("div"),W(e,"type","text/javascript"),C=e.src,i=t="https://ko-fi.com/widgets/widget_2.js",C!==i&&(P||(P=document.createElement("a")),P.href=i,C!==P.href)&&W(e,"src","https://ko-fi.com/widgets/widget_2.js")},m(t,n){B(document.head,e),_(t,H,n),_(t,V,n),C[2](V),i||(L=G(e,"load",C[1]),i=!0)},p:b,i:b,o:b,d(t){t&&(D(H),D(V)),D(e),C[2](null),i=!1,L()}}}function wC(C,e,t){let H;return[H,()=>{kofiwidget2.init("Support Juggl development!","#29abe0","B0B23OPUE"),t(0,H.innerHTML=kofiwidget2.getHTML(),H)},function(C){K[C?"unshift":"push"]((()=>{H=C,t(0,H)}))}]}class xC extends hC{constructor(C){super(),AC(this,C,wC,bC,E,{})}}const OC=["force-directed","circle","grid","hierarchy","cola"],kC={filter:"",color:"black",shape:"ellipse",icon:{name:"No icon",path:"",color:"white"},showInPane:!0,show:!0,size:1},EC={splitDirection:"vertical",typedLinkPrefix:"-",useImgServer:!1,imgServerPort:3837,debug:!1,globalStyleGroups:[],globalGraphRibbon:!0,graphSettings:{animateLayout:!0,autoAddNodes:!0,autoExpand:!1,autoZoom:!1,coreStore:Z,expandInitial:!0,fdgdLayout:"cola",filter:"",height:"100%",hoverEdges:!1,layout:"force-directed",limit:1e4,mergeEdges:!0,mode:"local",navigator:!0,openWithShift:!1,readContent:!0,styleGroups:[],toolbar:!0,width:"100%",zoomSpeed:1},embedSettings:{animateLayout:!0,autoAddNodes:!1,autoExpand:!1,autoZoom:!1,coreStore:Z,expandInitial:!0,fdgdLayout:"cola",filter:"",height:"400px",hoverEdges:!1,layout:"force-directed",limit:1e3,mergeEdges:!0,mode:"local",navigator:!1,openWithShift:!1,readContent:!0,styleGroups:[],toolbar:!1,width:"100%",zoomSpeed:1},globalGraphSettings:{animateLayout:!0,autoAddNodes:!0,autoExpand:!1,autoZoom:!1,coreStore:Z,expandInitial:!1,fdgdLayout:"cola",filter:"-class:dangling -class:file",height:"100%",width:"100%",limit:1e4,hoverEdges:!1,layout:"force-directed",mergeEdges:!0,mode:"workspace",navigator:!0,openWithShift:!1,readContent:!1,styleGroups:[],toolbar:!0,zoomSpeed:1}};class PC extends C.PluginSettingTab{constructor(C,e){super(C,e),this.plugin=e}display(){const{containerEl:e}=this;e.empty(),e.createEl("h3"),e.createEl("h3",{text:"Juggl"}),new xC({target:e});const t=activeDocument.createElement("a");t.href="https://juggl.io",t.target="_blank",t.innerHTML="the documentation";const H=activeDocument.createElement("a");H.href="https://discord.gg/sAmSGpaPgM",H.target="_blank",H.innerHTML="the Discord server";const V=activeDocument.createElement("p");V.innerHTML="Check out "+t.outerHTML+" for documentation on how to use the plugin.
Join "+H.outerHTML+" for help, nice discussion and insight into development.",e.appendChild(V),new SC({target:e,props:{plugin:this.plugin}}),e.createEl("h3"),e.createEl("h3",{text:"Extensions"}),new C.Setting(e).setName("Use navigator").setDesc("Use the navigator overview in the bottom-right corner. Disabling could improve performance.").addToggle((C=>{C.setValue(this.plugin.settings.graphSettings.navigator).onChange((C=>{this.plugin.settings.globalGraphSettings.navigator=C,this.plugin.settings.graphSettings.navigator=C,this.plugin.saveData(this.plugin.settings)}))})),new C.Setting(e).setName("Default mode").setDesc("The default mode to open the Advanced Graph View in.").addDropdown((C=>{C.addOption("local","Local Mode"),C.addOption("workspace","Workspace Mode"),C.setValue(this.plugin.settings.graphSettings.mode).onChange((C=>{this.plugin.settings.graphSettings.mode=C,this.plugin.saveData(this.plugin.settings)}))})),new C.Setting(e).setName("Force-directed algorithm").setDesc("The default force-directed graph drawing algorithm to use. Cola is nice, but unstable in some use cases. Obsidian uses D3").addDropdown((C=>{C.addOption("cola","Cola"),C.addOption("d3-force","D3"),C.setValue(this.plugin.settings.graphSettings.fdgdLayout).onChange((C=>{this.plugin.settings.graphSettings.fdgdLayout=C,this.plugin.settings.embedSettings.fdgdLayout=C,this.plugin.settings.globalGraphSettings.fdgdLayout=C,this.plugin.saveData(this.plugin.settings)}))})),new C.Setting(e).setName("Global Graph Icon").setDesc("Show the Global Graph Icon on the left ribbon.").addToggle((C=>{C.setValue(this.plugin.settings.globalGraphRibbon).onChange((C=>{this.plugin.settings.globalGraphRibbon=C,this.plugin.saveData(this.plugin.settings),this.plugin.setGlobalIcon()}))})),e.createEl("h4",{text:"Workspace mode"}),new C.Setting(e).setName("Automatically add nodes").setDesc("This will automatically add nodes to the graph whenever a note is opened.").addToggle((C=>{C.setValue(this.plugin.settings.graphSettings.autoAddNodes).onChange((C=>{this.plugin.settings.graphSettings.autoAddNodes=C,this.plugin.saveData(this.plugin.settings)}))})),new C.Setting(e).setName("Automatically zoom on active nodes").setDesc("This will automatically keep fitting the viewport on the currently active node. In particular, this happens when you open a file.").addToggle((C=>{C.setValue(this.plugin.settings.graphSettings.autoZoom).onChange((C=>{this.plugin.settings.graphSettings.autoZoom=C,this.plugin.settings.globalGraphSettings.autoZoom=C,this.plugin.saveData(this.plugin.settings)}))})),e.createEl("h3",{text:"Advanced"}),new C.Setting(e).setName("Zoom speed").setDesc("Speed with which zooming in and out happens. A value of 1 is recommended, but can be too quick for some mice.").addSlider((C=>{C.setDynamicTooltip().setLimits(.01,1.5,.01).setValue(this.plugin.settings.graphSettings.zoomSpeed).onChange((C=>{this.plugin.settings.graphSettings.zoomSpeed=C,this.plugin.settings.embedSettings.zoomSpeed=C,this.plugin.settings.globalGraphSettings.zoomSpeed=C,this.plugin.saveData(this.plugin.settings)}))})),new C.Setting(e).setName("Hover on edges").setDesc("Hover on edges to show what they are connected to.").addToggle((C=>{C.setValue(this.plugin.settings.graphSettings.hoverEdges).onChange((C=>{this.plugin.settings.graphSettings.hoverEdges=C,this.plugin.settings.embedSettings.hoverEdges=C,this.plugin.settings.globalGraphSettings.hoverEdges=C,this.plugin.saveData(this.plugin.settings)}))})),new C.Setting(e).setName("Open with shift").setDesc("Only opens file when clicking on a node when shift is pressed.").addToggle((C=>{C.setValue(this.plugin.settings.graphSettings.openWithShift).onChange((C=>{this.plugin.settings.graphSettings.openWithShift=C,this.plugin.settings.embedSettings.openWithShift=C,this.plugin.settings.globalGraphSettings.openWithShift=C,this.plugin.saveData(this.plugin.settings)}))})),new C.Setting(e).setName("Typed links prefix").setDesc("Prefix to use for typed links. Default is '-'. Requires a server restart.").addText((C=>{C.setPlaceholder("").setValue(this.plugin.settings.typedLinkPrefix).onChange((C=>{this.plugin.settings.typedLinkPrefix=C,this.plugin.saveData(this.plugin.settings)}))})),new C.Setting(e).setName("Render images in graph").setDesc("This will show image attachments in your vault as images in the graph. Requires reloading Juggl. WARNING: On Windows this will trigger your firewall!").addToggle((C=>{C.setValue(this.plugin.settings.useImgServer).onChange((C=>{this.plugin.settings.useImgServer=C,this.plugin.saveData(this.plugin.settings)}))})),new C.Setting(e).setName("Image server port").setDesc("Set the port of the image server. If you use multiple vaults, these need to be set differently. Default 3837.").addText((C=>{C.setValue(this.plugin.settings.imgServerPort+"").setPlaceholder("3837").onChange((C=>{this.plugin.settings.imgServerPort=parseInt(C.trim()),this.plugin.saveData(this.plugin.settings)}))})),new C.Setting(e).setName("Debug").setDesc("Enable debug mode, which prints a lot of stuff in the developers console.").addToggle((C=>{C.setValue(this.plugin.settings.debug).onChange((C=>{this.plugin.settings.debug=C,this.plugin.saveData(this.plugin.settings)}))}))}}var TC="undefined"!=typeof globalThis?globalThis:"undefined"!=typeof window?window:"undefined"!=typeof global?global:"undefined"!=typeof self?self:{};function BC(C){return C&&C.__esModule&&Object.prototype.hasOwnProperty.call(C,"default")?C.default:C}function _C(C){if(C.__esModule)return C;var e=C.default;if("function"==typeof e){var t=function C(){return this instanceof C?Reflect.construct(e,arguments,this.constructor):e.apply(this,arguments)};t.prototype=e.prototype}else t={};return Object.defineProperty(t,"__esModule",{value:!0}),Object.keys(C).forEach((function(e){var H=Object.getOwnPropertyDescriptor(C,e);Object.defineProperty(t,e,H.get?H:{enumerable:!0,get:function(){return C[e]}})})),t}var DC=function(C){var e=typeof C;return null!=C&&("object"==e||"function"==e)},RC="object"==typeof TC&&TC&&TC.Object===Object&&TC,FC=RC,NC="object"==typeof self&&self&&self.Object===Object&&self,IC=FC||NC||Function("return this")(),zC=IC,jC=function(){return zC.Date.now()},GC=/\s/;var WC=function(C){for(var e=C.length;e--&&GC.test(C.charAt(e)););return e},UC=WC,$C=/^\s+/;var YC=function(C){return C?C.slice(0,UC(C)+1).replace($C,""):C},XC=IC.Symbol,qC=XC,QC=Object.prototype,KC=QC.hasOwnProperty,JC=QC.toString,Ce=qC?qC.toStringTag:void 0;var ee=function(C){var e=KC.call(C,Ce),t=C[Ce];try{C[Ce]=void 0;var H=!0}catch(C){}var V=JC.call(C);return H&&(e?C[Ce]=t:delete C[Ce]),V},te=Object.prototype.toString;var He=ee,Ve=function(C){return te.call(C)},ie=XC?XC.toStringTag:void 0;var Le=function(C){return null==C?void 0===C?"[object Undefined]":"[object Null]":ie&&ie in Object(C)?He(C):Ve(C)};var ne=function(C){return null!=C&&"object"==typeof C},re=Le,oe=ne;var ae=function(C){return"symbol"==typeof C||oe(C)&&"[object Symbol]"==re(C)},Me=YC,se=DC,le=ae,de=/^[-+]0x[0-9a-f]+$/i,ue=/^0b[01]+$/i,ce=/^0o[0-7]+$/i,Ae=parseInt;var he=function(C){if("number"==typeof C)return C;if(le(C))return NaN;if(se(C)){var e="function"==typeof C.valueOf?C.valueOf():C;C=se(e)?e+"":e}if("string"!=typeof C)return 0===C?C:+C;C=Me(C);var t=ue.test(C);return t||ce.test(C)?Ae(C.slice(2),t?2:8):de.test(C)?NaN:+C},me=DC,fe=jC,pe=he,ge=Math.max,ve=Math.min;var ye=function(C,e,t){var H,V,i,L,n,r,o=0,a=!1,M=!1,s=!0;if("function"!=typeof C)throw new TypeError("Expected a function");function l(e){var t=H,i=V;return H=V=void 0,o=e,L=C.apply(i,t)}function d(C){var t=C-r;return void 0===r||t>=e||t<0||M&&C-o>=i}function u(){var C=fe();if(d(C))return c(C);n=setTimeout(u,function(C){var t=e-(C-r);return M?ve(t,i-(C-o)):t}(C))}function c(C){return n=void 0,s&&H?l(C):(H=V=void 0,L)}function A(){var C=fe(),t=d(C);if(H=arguments,V=this,r=C,t){if(void 0===n)return function(C){return o=C,n=setTimeout(u,e),a?l(C):L}(r);if(M)return clearTimeout(n),n=setTimeout(u,e),l(r)}return void 0===n&&(n=setTimeout(u,e)),L}return e=pe(e)||0,me(t)&&(a=!!t.leading,i=(M="maxWait"in t)?ge(pe(t.maxWait)||0,e):i,s="trailing"in t?!!t.trailing:s),A.cancel=function(){void 0!==n&&clearTimeout(n),o=0,H=r=V=n=void 0},A.flush=function(){return void 0===n?L:c(fe())},A},Ze={exports:{}};!function(C,e){(function(){var e,t,H,V,i,L,n,r,o,a,M,s,l,d,u;H=Math.floor,a=Math.min,t=function(C,e){return Ce?1:0},o=function(C,e,V,i,L){var n;if(null==V&&(V=0),null==L&&(L=t),V<0)throw new Error("lo must be non-negative");for(null==i&&(i=C.length);Vt;0<=t?e++:e--)o.push(e);return o}.apply(this).reverse()).length;iu;0<=u?++s:--s)c.push(i(C,H));return c},d=function(C,e,H,V){var i,L,n;for(null==V&&(V=t),i=C[H];H>e&&V(i,L=C[n=H-1>>1])<0;)C[H]=L,H=n;return C[H]=i},u=function(C,e,H){var V,i,L,n,r;for(null==H&&(H=t),i=C.length,r=e,L=C[e],V=2*e+1;V-1},Dt=Et;function Rt(C){var e=-1,t=null==C?0:C.length;for(this.clear();++e-1&&C%1==0&&CC.length)&&(e=C.length);for(var t=0,H=new Array(e);te?1:0},Ci=null!=Object.assign?Object.assign.bind(Object):function(C){for(var e=arguments,t=1;t255)return;e.push(Math.floor(i))}var L=H[1]||H[2]||H[3],n=H[1]&&H[2]&&H[3];if(L&&!n)return;var r=t[4];if(void 0!==r){if((r=parseFloat(r))<0||r>1)return;e.push(r)}}return e}(C)||function(C){var e,t,H,V,i,L,n,r;function o(C,e,t){return t<0&&(t+=1),t>1&&(t-=1),t<1/6?C+6*(e-C)*t:t<.5?e:t<2/3?C+(e-C)*(2/3-t)*6:C}var a=new RegExp("^"+QV+"$").exec(C);if(a){if((t=parseInt(a[1]))<0?t=(360- -1*t%360)%360:t>360&&(t%=360),t/=360,(H=parseFloat(a[2]))<0||H>100)return;if(H/=100,(V=parseFloat(a[3]))<0||V>100)return;if(V/=100,void 0!==(i=a[4])&&((i=parseFloat(i))<0||i>1))return;if(0===H)L=n=r=Math.round(255*V);else{var M=V<.5?V*(1+H):V+H-V*H,s=2*V-M;L=Math.round(255*o(s,M,t+1/3)),n=Math.round(255*o(s,M,t)),r=Math.round(255*o(s,M,t-1/3))}e=[L,n,r,i]}return e}(C)},ti={transparent:[0,0,0,0],aliceblue:[240,248,255],antiquewhite:[250,235,215],aqua:[0,255,255],aquamarine:[127,255,212],azure:[240,255,255],beige:[245,245,220],bisque:[255,228,196],black:[0,0,0],blanchedalmond:[255,235,205],blue:[0,0,255],blueviolet:[138,43,226],brown:[165,42,42],burlywood:[222,184,135],cadetblue:[95,158,160],chartreuse:[127,255,0],chocolate:[210,105,30],coral:[255,127,80],cornflowerblue:[100,149,237],cornsilk:[255,248,220],crimson:[220,20,60],cyan:[0,255,255],darkblue:[0,0,139],darkcyan:[0,139,139],darkgoldenrod:[184,134,11],darkgray:[169,169,169],darkgreen:[0,100,0],darkgrey:[169,169,169],darkkhaki:[189,183,107],darkmagenta:[139,0,139],darkolivegreen:[85,107,47],darkorange:[255,140,0],darkorchid:[153,50,204],darkred:[139,0,0],darksalmon:[233,150,122],darkseagreen:[143,188,143],darkslateblue:[72,61,139],darkslategray:[47,79,79],darkslategrey:[47,79,79],darkturquoise:[0,206,209],darkviolet:[148,0,211],deeppink:[255,20,147],deepskyblue:[0,191,255],dimgray:[105,105,105],dimgrey:[105,105,105],dodgerblue:[30,144,255],firebrick:[178,34,34],floralwhite:[255,250,240],forestgreen:[34,139,34],fuchsia:[255,0,255],gainsboro:[220,220,220],ghostwhite:[248,248,255],gold:[255,215,0],goldenrod:[218,165,32],gray:[128,128,128],grey:[128,128,128],green:[0,128,0],greenyellow:[173,255,47],honeydew:[240,255,240],hotpink:[255,105,180],indianred:[205,92,92],indigo:[75,0,130],ivory:[255,255,240],khaki:[240,230,140],lavender:[230,230,250],lavenderblush:[255,240,245],lawngreen:[124,252,0],lemonchiffon:[255,250,205],lightblue:[173,216,230],lightcoral:[240,128,128],lightcyan:[224,255,255],lightgoldenrodyellow:[250,250,210],lightgray:[211,211,211],lightgreen:[144,238,144],lightgrey:[211,211,211],lightpink:[255,182,193],lightsalmon:[255,160,122],lightseagreen:[32,178,170],lightskyblue:[135,206,250],lightslategray:[119,136,153],lightslategrey:[119,136,153],lightsteelblue:[176,196,222],lightyellow:[255,255,224],lime:[0,255,0],limegreen:[50,205,50],linen:[250,240,230],magenta:[255,0,255],maroon:[128,0,0],mediumaquamarine:[102,205,170],mediumblue:[0,0,205],mediumorchid:[186,85,211],mediumpurple:[147,112,219],mediumseagreen:[60,179,113],mediumslateblue:[123,104,238],mediumspringgreen:[0,250,154],mediumturquoise:[72,209,204],mediumvioletred:[199,21,133],midnightblue:[25,25,112],mintcream:[245,255,250],mistyrose:[255,228,225],moccasin:[255,228,181],navajowhite:[255,222,173],navy:[0,0,128],oldlace:[253,245,230],olive:[128,128,0],olivedrab:[107,142,35],orange:[255,165,0],orangered:[255,69,0],orchid:[218,112,214],palegoldenrod:[238,232,170],palegreen:[152,251,152],paleturquoise:[175,238,238],palevioletred:[219,112,147],papayawhip:[255,239,213],peachpuff:[255,218,185],peru:[205,133,63],pink:[255,192,203],plum:[221,160,221],powderblue:[176,224,230],purple:[128,0,128],red:[255,0,0],rosybrown:[188,143,143],royalblue:[65,105,225],saddlebrown:[139,69,19],salmon:[250,128,114],sandybrown:[244,164,96],seagreen:[46,139,87],seashell:[255,245,238],sienna:[160,82,45],silver:[192,192,192],skyblue:[135,206,235],slateblue:[106,90,205],slategray:[112,128,144],slategrey:[112,128,144],snow:[255,250,250],springgreen:[0,255,127],steelblue:[70,130,180],tan:[210,180,140],teal:[0,128,128],thistle:[216,191,216],tomato:[255,99,71],turquoise:[64,224,208],violet:[238,130,238],wheat:[245,222,179],white:[255,255,255],whitesmoke:[245,245,245],yellow:[255,255,0],yellowgreen:[154,205,50]},Hi=function(C){for(var e=C.map,t=C.keys,H=t.length,V=0;V1&&void 0!==arguments[1]?arguments[1]:ai;!(e=C.next()).done;)t=65599*t+e.value|0;return t},li=function(C){return 65599*(arguments.length>1&&void 0!==arguments[1]?arguments[1]:ai)+C|0},di=function(C){var e=arguments.length>1&&void 0!==arguments[1]?arguments[1]:Mi;return(e<<5)+e+C|0},ui=function(C){return 2097152*C[0]+C[1]},ci=function(C,e){return[li(C[0],e[0]),di(C[1],e[1])]},Ai=function(C,e){var t={value:0,done:!1},H=0,V=C.length;return si({next:function(){return H=0&&(C[H]!==e||(C.splice(H,1),!t));H--);},Di=function(C){C.splice(0,C.length)},Ri=function(C,e,t){return t&&(e=UV(t,e)),C[e]},Fi=function(C,e,t,H){t&&(e=UV(t,e)),C[e]=H},Ni="undefined"!=typeof Map?Map:function(){function C(){AV(this,C),this._obj={}}return mV(C,[{key:"set",value:function(C,e){return this._obj[C]=e,this}},{key:"delete",value:function(C){return this._obj[C]=void 0,this}},{key:"clear",value:function(){this._obj={}}},{key:"has",value:function(C){return void 0!==this._obj[C]}},{key:"get",value:function(C){return this._obj[C]}}]),C}(),Ii=function(){function C(e){if(AV(this,C),this._obj=Object.create(null),this.size=0,null!=e){var t;t=null!=e.instanceString&&e.instanceString()===this.instanceString()?e.toArray():e;for(var H=0;H2&&void 0!==arguments[2])||arguments[2];if(void 0!==C&&void 0!==e&&FV(C)){var H=e.group;if(null==H&&(H=e.data&&null!=e.data.source&&null!=e.data.target?"edges":"nodes"),"nodes"===H||"edges"===H){this.length=1,this[0]=this;var V=this._private={cy:C,single:!0,data:e.data||{},position:e.position||{x:0,y:0},autoWidth:void 0,autoHeight:void 0,autoPadding:void 0,compoundBoundsClean:!1,listeners:[],group:H,style:{},rstyle:{},styleCxts:[],styleKeys:{},removed:!0,selected:!!e.selected,selectable:void 0===e.selectable||!!e.selectable,locked:!!e.locked,grabbed:!1,grabbable:void 0===e.grabbable||!!e.grabbable,pannable:void 0===e.pannable?"edges"===H:!!e.pannable,active:!1,classes:new zi,animation:{current:[],queue:[]},rscratch:{},scratch:e.scratch||{},edges:[],children:[],parent:e.parent&&e.parent.isNode()?e.parent:null,traversalCache:{},backgrounding:!1,bbCache:null,bbCacheShift:{x:0,y:0},bodyBounds:null,overlayBounds:null,labelBounds:{all:null,source:null,target:null,main:null},arrowBounds:{source:null,target:null,"mid-source":null,"mid-target":null}};if(null==V.position.x&&(V.position.x=0),null==V.position.y&&(V.position.y=0),e.renderedPosition){var i=e.renderedPosition,L=C.pan(),n=C.zoom();V.position={x:(i.x-L.x)/n,y:(i.y-L.y)/n}}var r=[];EV(e.classes)?r=e.classes:OV(e.classes)&&(r=e.classes.split(/\s+/));for(var o=0,a=r.length;o0;){var p=A.pop(),g=u(p),v=p.id();if(M[v]=g,g!==1/0)for(var y=p.neighborhood().intersect(l),Z=0;Z0)for(t.unshift(e);a[V];){var i=a[V];t.unshift(i.edge),t.unshift(i.node),V=(H=i.node).id()}return L.spawn(t)}}}},Yi={kruskal:function(C){C=C||function(C){return 1};for(var e=this.byGroup(),t=e.nodes,H=e.edges,V=t.length,i=new Array(V),L=t,n=function(C){for(var e=0;e0;){if(r=u.pop(),o=r.id(),c.delete(o),p++,o===M){for(var g=[],v=V,y=M,Z=h[y];g.unshift(v),null!=Z&&g.unshift(Z),null!=(v=A[y]);)Z=h[y=v.id()];return{found:!0,distance:s[o],path:this.spawn(g),steps:p}}d[o]=!0;for(var S=r._private.edges,b=0;bS&&(l[Z]=S,A[Z]=y,h[Z]=f),!V){var b=y*o+v;!V&&l[b]>S&&(l[b]=S,A[b]=v,h[b]=f)}}}for(var w=0;w1&&void 0!==arguments[1]?arguments[1]:i,H=[],V=h(C);;){if(null==V)return e.spawn();var L=A(V),r=L.edge,o=L.pred;if(H.unshift(V[0]),V.same(t)&&H.length>0)break;null!=r&&H.unshift(r),V=o}return n.spawn(H)},hasNegativeWeightCycle:d,negativeWeightCycles:u}}},eL=Math.sqrt(2),tL=function(C,e,t){0===t.length&&wi("Karger-Stein must be run on a connected (sub)graph");for(var H=t[C],V=H[1],i=H[2],L=e[V],n=e[i],r=t,o=r.length-1;o>=0;o--){var a=r[o],M=a[1],s=a[2];(e[M]===L&&e[s]===n||e[M]===n&&e[s]===L)&&r.splice(o,1)}for(var l=0;lH;){var V=Math.floor(Math.random()*e.length);e=tL(V,C,e),t--}return e},VL={kargerStein:function(){var C=this,e=this.byGroup(),t=e.nodes,H=e.edges;H.unmergeBy((function(C){return C.isLoop()}));var V=t.length,i=H.length,L=Math.ceil(Math.pow(Math.log(V)/Math.LN2,2)),n=Math.floor(V/eL);if(!(V<2)){for(var r=[],o=0;o0?1:C<0?-1:0},ML=function(C,e){return Math.sqrt(sL(C,e))},sL=function(C,e){var t=e.x-C.x,H=e.y-C.y;return t*t+H*H},lL=function(C){for(var e=C.length,t=0,H=0;H=C.x1&&C.y2>=C.y1)return{x1:C.x1,y1:C.y1,x2:C.x2,y2:C.y2,w:C.x2-C.x1,h:C.y2-C.y1};if(null!=C.w&&null!=C.h&&C.w>=0&&C.h>=0)return{x1:C.x1,y1:C.y1,x2:C.x1+C.w,y2:C.y1+C.h,w:C.w,h:C.h}}},hL=function(C,e,t){C.x1=Math.min(C.x1,e),C.x2=Math.max(C.x2,e),C.w=C.x2-C.x1,C.y1=Math.min(C.y1,t),C.y2=Math.max(C.y2,t),C.h=C.y2-C.y1},mL=function(C){var e=arguments.length>1&&void 0!==arguments[1]?arguments[1]:0;return C.x1-=e,C.x2+=e,C.y1-=e,C.y2+=e,C.w=C.x2-C.x1,C.h=C.y2-C.y1,C},fL=function(C){var e,t,H,V,i=arguments.length>1&&void 0!==arguments[1]?arguments[1]:[0];if(1===i.length)e=t=H=V=i[0];else if(2===i.length)e=H=i[0],V=t=i[1];else if(4===i.length){var L=pV(i,4);e=L[0],t=L[1],H=L[2],V=L[3]}return C.x1-=V,C.x2+=t,C.y1-=e,C.y2+=H,C.w=C.x2-C.x1,C.h=C.y2-C.y1,C},pL=function(C,e){C.x1=e.x1,C.y1=e.y1,C.x2=e.x2,C.y2=e.y2,C.w=C.x2-C.x1,C.h=C.y2-C.y1},gL=function(C,e){return!(C.x1>e.x2)&&(!(e.x1>C.x2)&&(!(C.x2e.y2)&&!(e.y1>C.y2)))))))},vL=function(C,e,t){return C.x1<=e&&e<=C.x2&&C.y1<=t&&t<=C.y2},yL=function(C,e){return vL(C,e.x1,e.y1)&&vL(C,e.x2,e.y2)},ZL=function(C,e,t,H,V,i,L){var n,r=jL(V,i),o=V/2,a=i/2,M=H-a-L;if((n=DL(C,e,t,H,t-o+r-L,M,t+o-r+L,M,!1)).length>0)return n;var s=t+o+L;if((n=DL(C,e,t,H,s,H-a+r-L,s,H+a-r+L,!1)).length>0)return n;var l=H+a+L;if((n=DL(C,e,t,H,t-o+r-L,l,t+o-r+L,l,!1)).length>0)return n;var d,u=t-o-L;if((n=DL(C,e,t,H,u,H-a+r-L,u,H+a-r+L,!1)).length>0)return n;var c=t-o+r,A=H-a+r;if((d=BL(C,e,t,H,c,A,r+L)).length>0&&d[0]<=c&&d[1]<=A)return[d[0],d[1]];var h=t+o-r,m=H-a+r;if((d=BL(C,e,t,H,h,m,r+L)).length>0&&d[0]>=h&&d[1]<=m)return[d[0],d[1]];var f=t+o-r,p=H+a-r;if((d=BL(C,e,t,H,f,p,r+L)).length>0&&d[0]>=f&&d[1]>=p)return[d[0],d[1]];var g=t-o+r,v=H+a-r;return(d=BL(C,e,t,H,g,v,r+L)).length>0&&d[0]<=g&&d[1]>=v?[d[0],d[1]]:[]},SL=function(C,e,t,H,V,i,L){var n=L,r=Math.min(t,V),o=Math.max(t,V),a=Math.min(H,i),M=Math.max(H,i);return r-n<=C&&C<=o+n&&a-n<=e&&e<=M+n},bL=function(C,e,t,H,V,i,L,n,r){var o=Math.min(t,L,V)-r,a=Math.max(t,L,V)+r,M=Math.min(H,n,i)-r,s=Math.max(H,n,i)+r;return!(Ca||es)},wL=function(C,e,t,H,V,i,L,n){var r=[];!function(C,e,t,H,V){var i,L,n,r,o,a,M,s;0===C&&(C=1e-5),n=-27*(H/=C)+(e/=C)*(9*(t/=C)-e*e*2),i=(L=(3*t-e*e)/9)*L*L+(n/=54)*n,V[1]=0,M=e/3,i>0?(o=(o=n+Math.sqrt(i))<0?-Math.pow(-o,1/3):Math.pow(o,1/3),a=(a=n-Math.sqrt(i))<0?-Math.pow(-a,1/3):Math.pow(a,1/3),V[0]=-M+o+a,M+=(o+a)/2,V[4]=V[2]=-M,M=Math.sqrt(3)*(-a+o)/2,V[3]=M,V[5]=-M):(V[5]=V[3]=0,0===i?(s=n<0?-Math.pow(-n,1/3):Math.pow(n,1/3),V[0]=2*s-M,V[4]=V[2]=-(s+M)):(r=(L=-L)*L*L,r=Math.acos(n/Math.sqrt(r)),s=2*Math.sqrt(L),V[0]=-M+s*Math.cos(r/3),V[2]=-M+s*Math.cos((r+2*Math.PI)/3),V[4]=-M+s*Math.cos((r+4*Math.PI)/3)))}(1*t*t-4*t*V+2*t*L+4*V*V-4*V*L+L*L+H*H-4*H*i+2*H*n+4*i*i-4*i*n+n*n,9*t*V-3*t*t-3*t*L-6*V*V+3*V*L+9*H*i-3*H*H-3*H*n-6*i*i+3*i*n,3*t*t-6*t*V+t*L-t*C+2*V*V+2*V*C-L*C+3*H*H-6*H*i+H*n-H*e+2*i*i+2*i*e-n*e,1*t*V-t*t+t*C-V*C+H*i-H*H+H*e-i*e,r);for(var o=[],a=0;a<6;a+=2)Math.abs(r[a+1])<1e-7&&r[a]>=0&&r[a]<=1&&o.push(r[a]);o.push(1),o.push(0);for(var M,s,l,d=-1,u=0;u=0?lr?(C-V)*(C-V)+(e-i)*(e-i):o-M},OL=function(C,e,t){for(var H,V,i,L,n=0,r=0;r=C&&C>=i||H<=C&&C<=i))continue;(C-H)/(i-H)*(L-V)+V>e&&n++}return n%2!=0},kL=function(C,e,t,H,V,i,L,n,r){var o,a=new Array(t.length);null!=n[0]?(o=Math.atan(n[1]/n[0]),n[0]<0?o+=Math.PI/2:o=-o-Math.PI/2):o=n;for(var M,s=Math.cos(-o),l=Math.sin(-o),d=0;d0){var u=PL(a,-r);M=EL(u)}else M=a;return OL(C,e,M)},EL=function(C){for(var e,t,H,V,i,L,n,r,o=new Array(C.length/2),a=0;a=0&&d<=1&&c.push(d),u>=0&&u<=1&&c.push(u),0===c.length)return[];var A=c[0]*n[0]+C,h=c[0]*n[1]+e;return c.length>1?c[0]==c[1]?[A,h]:[A,h,c[1]*n[0]+C,c[1]*n[1]+e]:[A,h]},_L=function(C,e,t){return e<=C&&C<=t||t<=C&&C<=e?C:C<=e&&e<=t||t<=e&&e<=C?e:t},DL=function(C,e,t,H,V,i,L,n,r){var o=C-V,a=t-C,M=L-V,s=e-i,l=H-e,d=n-i,u=M*s-d*o,c=a*s-l*o,A=d*a-M*l;if(0!==A){var h=u/A,m=c/A,f=-.001;return f<=h&&h<=1.001&&f<=m&&m<=1.001||r?[C+h*a,e+h*l]:[]}return 0===u||0===c?_L(C,t,L)===L?[L,n]:_L(C,t,V)===V?[V,i]:_L(V,L,t)===t?[t,H]:[]:[]},RL=function(C,e,t,H,V,i,L,n){var r,o,a,M,s,l,d=[],u=new Array(t.length),c=!0;if(null==i&&(c=!1),c){for(var A=0;A0){var h=PL(u,-n);o=EL(h)}else o=u}else o=t;for(var m=0;mo&&(o=e)},M=function(C){return r[C]},s=0;s0?m.edgesTo(h)[0]:h.edgesTo(m)[0];var p=H(f);h=h.id(),s[h]>s[c]+p&&(s[h]=s[c]+p,l.nodes.indexOf(h)<0?l.push(h):l.updateItem(h),o[h]=0,r[h]=[]),s[h]==s[c]+p&&(o[h]=o[h]+o[c],r[h].push(c))}else for(var g=0;g0;){for(var S=t.pop(),b=0;b0&&L.push(t[n]);0!==L.length&&V.push(H.collection(L))}return V}(a,r,e,H);return m=function(C){for(var e=0;e5&&void 0!==arguments[5]?arguments[5]:Mn,L=H,n=0;n=2?An(C,e,t,0,dn,un):An(C,e,t,0,ln)},squaredEuclidean:function(C,e,t){return An(C,e,t,0,dn)},manhattan:function(C,e,t){return An(C,e,t,0,ln)},max:function(C,e,t){return An(C,e,t,-1/0,cn)}};function mn(C,e,t,H,V,i){var L;return L=kV(C)?C:hn[C]||hn.euclidean,0===e&&kV(C)?L(V,i):L(e,t,H,V,i)}hn["squared-euclidean"]=hn.squaredEuclidean,hn.squaredeuclidean=hn.squaredEuclidean;var fn=Bi({k:2,m:2,sensitivityThreshold:1e-4,distance:"euclidean",maxIterations:10,attributes:[],testMode:!1,testCentroids:null}),pn=function(C){return fn(C)},gn=function(C,e,t,H,V){var i="kMedoids"!==V?function(C){return t[C]}:function(C){return H[C](t)},L=t,n=e;return mn(C,H.length,i,(function(C){return H[C](e)}),L,n)},vn=function(C,e,t){for(var H=t.length,V=new Array(H),i=new Array(H),L=new Array(e),n=null,r=0;rt)return!1}return!0},bn=function(C,e,t){for(var H=0;HV&&(V=e[r][o],i=o);L[i].push(C[r])}for(var a=0;a=V.threshold||"dendrogram"===V.mode&&1===C.length)return!1;var l,d=e[L],u=e[H[L]];l="dendrogram"===V.mode?{left:d,right:u,key:d.key}:{value:d.value.concat(u.value),key:d.key},C[d.index]=l,C.splice(u.index,1),e[d.key]=l;for(var c=0;ct[u.key][A.key]&&(i=t[u.key][A.key])):"max"===V.linkage?(i=t[d.key][A.key],t[d.key][A.key]1&&void 0!==arguments[1]?arguments[1]:0,t=arguments.length>2&&void 0!==arguments[2]?arguments[2]:C.length,H=!(arguments.length>4&&void 0!==arguments[4])||arguments[4],V=!(arguments.length>5&&void 0!==arguments[5])||arguments[5];arguments.length>3&&void 0!==arguments[3]&&!arguments[3]?(t0&&C.splice(0,e)):C=C.slice(e,t);for(var i=0,L=C.length-1;L>=0;L--){var n=C[L];V?isFinite(n)||(C[L]=-1/0,i++):C.splice(L,1)}H&&C.sort((function(C,e){return C-e}));var r=C.length,o=Math.floor(r/2);return r%2!=0?C[o+1+i]:(C[o-1+i]+C[o+i])/2}(C):"mean"===e?function(C){for(var e=arguments.length>1&&void 0!==arguments[1]?arguments[1]:0,t=arguments.length>2&&void 0!==arguments[2]?arguments[2]:C.length,H=0,V=0,i=e;i1&&void 0!==arguments[1]?arguments[1]:0,t=arguments.length>2&&void 0!==arguments[2]?arguments[2]:C.length,H=1/0,V=e;V1&&void 0!==arguments[1]?arguments[1]:0,t=arguments.length>2&&void 0!==arguments[2]?arguments[2]:C.length,H=-1/0,V=e;VL&&(i=r,L=e[V*C+r])}i>0&&H.push(i)}for(var o=0;o=S?(b=S,S=x,w=O):x>b&&(b=x);for(var k=0;k0?1:0;v[g%o.minIterations*e+D]=R,_+=R}if(_>0&&(g>=o.minIterations-1||g==o.maxIterations-1)){for(var F=0,N=0;N0&&H.push(V);return H}(e,i,L),j=function(C,e,t){for(var H=Wn(C,e,t),V=0;Vr&&(n=o,r=a)}t[V]=i[n]}return Wn(C,e,t)}(e,H,z),G={},W=0;W1||L>1)&&(o=!0),a[e]=[],C.outgoers().forEach((function(C){C.isEdge()&&a[e].push(C.id())}))}else M[e]=[void 0,C.target().id()]})):r.forEach((function(C){var e=C.id();C.isNode()?(C.degree(!0)%2&&(t?H?o=!0:H=e:t=e),a[e]=[],C.connectedEdges().forEach((function(C){return a[e].push(C.id())}))):M[e]=[C.source().id(),C.target().id()]}));var s={found:!1,trail:void 0};if(o)return s;if(H&&t)if(n){if(V&&H!=V)return s;V=H}else{if(V&&H!=V&&t!=V)return s;V||(V=H)}else V||(V=r[0].id());var l=function(C){for(var e,t,H,V=C,i=[C];a[V].length;)e=a[V].shift(),t=M[e][0],V!=(H=M[e][1])?(a[H]=a[H].filter((function(C){return C!=e})),V=H):n||V==t||(a[t]=a[t].filter((function(C){return C!=e})),V=t),i.unshift(e),i.unshift(V);return i},d=[],u=[];for(u=l(V);1!=u.length;)0==a[u[0]].length?(d.unshift(r.getElementById(u.shift())),d.unshift(r.getElementById(u.shift()))):u=l(u.shift()).concat(u);for(var c in d.unshift(r.getElementById(u.shift())),a)if(a[c].length)return s;return s.found=!0,s.trail=this.spawn(d,!0),s}},qn=function(){var C=this,e={},t=0,H=0,V=[],i=[],L={},n=function n(r,o,a){r===a&&(H+=1),e[o]={id:t,low:t++,cutVertex:!1};var M,s,l,d,u=C.getElementById(o).connectedEdges().intersection(C);0===u.size()?V.push(C.spawn(C.getElementById(o))):u.forEach((function(t){M=t.source().id(),s=t.target().id(),(l=M===o?s:M)!==a&&(d=t.id(),L[d]||(L[d]=!0,i.push({x:o,y:l,edge:t})),l in e?e[o].low=Math.min(e[o].low,e[l].id):(n(r,l,o),e[o].low=Math.min(e[o].low,e[l].low),e[o].id<=e[l].low&&(e[o].cutVertex=!0,function(t,H){for(var L=i.length-1,n=[],r=C.spawn();i[L].x!=t||i[L].y!=H;)n.push(i.pop().edge),L--;n.push(i.pop().edge),n.forEach((function(t){var H=t.connectedNodes().intersection(C);r.merge(t),H.forEach((function(t){var H=t.id(),V=t.connectedEdges().intersection(C);r.merge(t),e[H].cutVertex?r.merge(V.filter((function(C){return C.isLoop()}))):r.merge(V)}))})),V.push(r)}(o,l))))}))};C.forEach((function(C){if(C.isNode()){var t=C.id();t in e||(H=0,n(t,t),e[t].cutVertex=H>1)}}));var r=Object.keys(e).filter((function(C){return e[C].cutVertex})).map((function(e){return C.getElementById(e)}));return{cut:C.spawn(r),components:V}},Qn=function(){var C=this,e={},t=0,H=[],V=[],i=C.spawn(C),L=function L(n){if(V.push(n),e[n]={index:t,low:t++,explored:!1},C.getElementById(n).connectedEdges().intersection(C).forEach((function(C){var t=C.target().id();t!==n&&(t in e||L(t),e[t].explored||(e[n].low=Math.min(e[n].low,e[t].low)))})),e[n].index===e[n].low){for(var r=C.spawn();;){var o=V.pop();if(r.merge(C.getElementById(o)),e[o].low=e[n].index,e[o].explored=!0,o===n)break}var a=r.edgesWith(r),M=r.merge(a);H.push(M),i=i.difference(M)}};return C.forEach((function(C){if(C.isNode()){var t=C.id();t in e||L(t)}})),{cut:i,components:H}},Kn={};[Wi,$i,Yi,qi,Ki,CL,VL,$L,XL,QL,JL,an,Pn,In,$n,Xn,{hopcroftTarjanBiconnected:qn,htbc:qn,htb:qn,hopcroftTarjanBiconnectedComponents:qn},{tarjanStronglyConnected:Qn,tsc:Qn,tscc:Qn,tarjanStronglyConnectedComponents:Qn}].forEach((function(C){Ci(Kn,C)})); /*! Embeddable Minimum Strictly-Compliant Promises/A+ 1.1.1 Thenable Copyright (c) 2013-2014 Ralf S. Engelschall (http://engelschall.com) Licensed under The MIT License (http://opensource.org/licenses/MIT) */ var Jn=function C(e){if(!(this instanceof C))return new C(e);this.id="Thenable/1.0.7",this.state=0,this.fulfillValue=void 0,this.rejectReason=void 0,this.onFulfilled=[],this.onRejected=[],this.proxy={then:this.then.bind(this)},"function"==typeof e&&e.call(this,this.fulfill.bind(this),this.reject.bind(this))};Jn.prototype={fulfill:function(C){return Cr(this,1,"fulfillValue",C)},reject:function(C){return Cr(this,2,"rejectReason",C)},then:function(C,e){var t=this,H=new Jn;return t.onFulfilled.push(Hr(C,H,"fulfill")),t.onRejected.push(Hr(e,H,"reject")),er(t),H.proxy}};var Cr=function(C,e,t,H){return 0===C.state&&(C.state=e,C[t]=H,er(C)),C},er=function(C){1===C.state?tr(C,"onFulfilled",C.fulfillValue):2===C.state&&tr(C,"onRejected",C.rejectReason)},tr=function(C,e,t){if(0!==C[e].length){var H=C[e];C[e]=[];var V=function(){for(var C=0;C0:void 0}},clearQueue:function(){return function(){var C=this,e=void 0!==C.length?C:[C];if(!(this._private.cy||this).styleEnabled())return this;for(var t=0;t0&&this.spawn(H).updateStyle().emit("class"),e},addClass:function(C){return this.toggleClass(C,!0)},hasClass:function(C){var e=this[0];return null!=e&&e._private.classes.has(C)},toggleClass:function(C,e){EV(C)||(C=C.match(/\S+/g)||[]);for(var t=this,H=void 0===e,V=[],i=0,L=t.length;i0&&this.spawn(V).updateStyle().emit("class"),t},removeClass:function(C){return this.toggleClass(C,!1)},flashClass:function(C,e){var t=this;if(null==e)e=250;else if(0===e)return t;return t.addClass(C),setTimeout((function(){t.removeClass(C)}),e),t}};lr.className=lr.classNames=lr.classes;var dr={metaChar:"[\\!\\\"\\#\\$\\%\\&\\'\\(\\)\\*\\+\\,\\.\\/\\:\\;\\<\\=\\>\\?\\@\\[\\]\\^\\`\\{\\|\\}\\~]",comparatorOp:"=|\\!=|>|>=|<|<=|\\$=|\\^=|\\*=",boolOp:"\\?|\\!|\\^",string:"\"(?:\\\\\"|[^\"])*\"|'(?:\\\\'|[^'])*'",number:YV,meta:"degree|indegree|outdegree",separator:"\\s*,\\s*",descendant:"\\s+",child:"\\s+>\\s+",subject:"\\$",group:"node|edge|\\*",directedEdge:"\\s+->\\s+",undirectedEdge:"\\s+<->\\s+"};dr.variable="(?:[\\w-.]|(?:\\\\"+dr.metaChar+"))+",dr.className="(?:[\\w-]|(?:\\\\"+dr.metaChar+"))+",dr.value=dr.string+"|"+dr.number,dr.id=dr.variable,function(){var C,e,t;for(C=dr.comparatorOp.split("|"),t=0;t=0||"="!==e&&(dr.comparatorOp+="|\\!"+e)}();var ur=0,cr=1,Ar=2,hr=3,mr=4,fr=5,pr=6,gr=7,vr=8,yr=9,Zr=10,Sr=11,br=12,wr=13,xr=14,Or=15,kr=16,Er=17,Pr=18,Tr=19,Br=20,_r=[{selector:":selected",matches:function(C){return C.selected()}},{selector:":unselected",matches:function(C){return!C.selected()}},{selector:":selectable",matches:function(C){return C.selectable()}},{selector:":unselectable",matches:function(C){return!C.selectable()}},{selector:":locked",matches:function(C){return C.locked()}},{selector:":unlocked",matches:function(C){return!C.locked()}},{selector:":visible",matches:function(C){return C.visible()}},{selector:":hidden",matches:function(C){return!C.visible()}},{selector:":transparent",matches:function(C){return C.transparent()}},{selector:":grabbed",matches:function(C){return C.grabbed()}},{selector:":free",matches:function(C){return!C.grabbed()}},{selector:":removed",matches:function(C){return C.removed()}},{selector:":inside",matches:function(C){return!C.removed()}},{selector:":grabbable",matches:function(C){return C.grabbable()}},{selector:":ungrabbable",matches:function(C){return!C.grabbable()}},{selector:":animated",matches:function(C){return C.animated()}},{selector:":unanimated",matches:function(C){return!C.animated()}},{selector:":parent",matches:function(C){return C.isParent()}},{selector:":childless",matches:function(C){return C.isChildless()}},{selector:":child",matches:function(C){return C.isChild()}},{selector:":orphan",matches:function(C){return C.isOrphan()}},{selector:":nonorphan",matches:function(C){return C.isChild()}},{selector:":compound",matches:function(C){return C.isNode()?C.isParent():C.source().isParent()||C.target().isParent()}},{selector:":loop",matches:function(C){return C.isLoop()}},{selector:":simple",matches:function(C){return C.isSimple()}},{selector:":active",matches:function(C){return C.active()}},{selector:":inactive",matches:function(C){return!C.active()}},{selector:":backgrounding",matches:function(C){return C.backgrounding()}},{selector:":nonbackgrounding",matches:function(C){return!C.backgrounding()}}].sort((function(C,e){return function(C,e){return-1*JV(C,e)}(C.selector,e.selector)})),Dr=function(){for(var C,e={},t=0;t<_r.length;t++)e[(C=_r[t]).selector]=C.matches;return e}(),Rr="("+_r.map((function(C){return C.selector})).join("|")+")",Fr=function(C){return C.replace(new RegExp("\\\\("+dr.metaChar+")","g"),(function(C,e){return e}))},Nr=function(C,e,t){C[C.length-1]=t},Ir=[{name:"group",query:!0,regex:"("+dr.group+")",populate:function(C,e,t){var H=pV(t,1)[0];e.checks.push({type:ur,value:"*"===H?H:H+"s"})}},{name:"state",query:!0,regex:Rr,populate:function(C,e,t){var H=pV(t,1)[0];e.checks.push({type:gr,value:H})}},{name:"id",query:!0,regex:"\\#("+dr.id+")",populate:function(C,e,t){var H=pV(t,1)[0];e.checks.push({type:vr,value:Fr(H)})}},{name:"className",query:!0,regex:"\\.("+dr.className+")",populate:function(C,e,t){var H=pV(t,1)[0];e.checks.push({type:yr,value:Fr(H)})}},{name:"dataExists",query:!0,regex:"\\[\\s*("+dr.variable+")\\s*\\]",populate:function(C,e,t){var H=pV(t,1)[0];e.checks.push({type:mr,field:Fr(H)})}},{name:"dataCompare",query:!0,regex:"\\[\\s*("+dr.variable+")\\s*("+dr.comparatorOp+")\\s*("+dr.value+")\\s*\\]",populate:function(C,e,t){var H=pV(t,3),V=H[0],i=H[1],L=H[2];L=null!=new RegExp("^"+dr.string+"$").exec(L)?L.substring(1,L.length-1):parseFloat(L),e.checks.push({type:hr,field:Fr(V),operator:i,value:L})}},{name:"dataBool",query:!0,regex:"\\[\\s*("+dr.boolOp+")\\s*("+dr.variable+")\\s*\\]",populate:function(C,e,t){var H=pV(t,2),V=H[0],i=H[1];e.checks.push({type:fr,field:Fr(i),operator:V})}},{name:"metaCompare",query:!0,regex:"\\[\\[\\s*("+dr.meta+")\\s*("+dr.comparatorOp+")\\s*("+dr.number+")\\s*\\]\\]",populate:function(C,e,t){var H=pV(t,3),V=H[0],i=H[1],L=H[2];e.checks.push({type:pr,field:Fr(V),operator:i,value:parseFloat(L)})}},{name:"nextQuery",separator:!0,regex:dr.separator,populate:function(C,e){var t=C.currentSubject,H=C.edgeCount,V=C.compoundCount,i=C[C.length-1];return null!=t&&(i.subject=t,C.currentSubject=null),i.edgeCount=H,i.compoundCount=V,C.edgeCount=0,C.compoundCount=0,C[C.length++]={checks:[]}}},{name:"directedEdge",separator:!0,regex:dr.directedEdge,populate:function(C,e){if(null==C.currentSubject){var t={checks:[]},H=e,V={checks:[]};return t.checks.push({type:Sr,source:H,target:V}),Nr(C,0,t),C.edgeCount++,V}var i={checks:[]},L=e,n={checks:[]};return i.checks.push({type:br,source:L,target:n}),Nr(C,0,i),C.edgeCount++,n}},{name:"undirectedEdge",separator:!0,regex:dr.undirectedEdge,populate:function(C,e){if(null==C.currentSubject){var t={checks:[]},H=e,V={checks:[]};return t.checks.push({type:Zr,nodes:[H,V]}),Nr(C,0,t),C.edgeCount++,V}var i={checks:[]},L=e,n={checks:[]};return i.checks.push({type:xr,node:L,neighbor:n}),Nr(C,0,i),n}},{name:"child",separator:!0,regex:dr.child,populate:function(C,e){if(null==C.currentSubject){var t={checks:[]},H={checks:[]},V=C[C.length-1];return t.checks.push({type:Or,parent:V,child:H}),Nr(C,0,t),C.compoundCount++,H}if(C.currentSubject===e){var i={checks:[]},L=C[C.length-1],n={checks:[]},r={checks:[]},o={checks:[]},a={checks:[]};return i.checks.push({type:Tr,left:L,right:n,subject:r}),r.checks=e.checks,e.checks=[{type:Br}],a.checks.push({type:Br}),n.checks.push({type:Er,parent:a,child:o}),Nr(C,0,i),C.currentSubject=r,C.compoundCount++,o}var M={checks:[]},s={checks:[]},l=[{type:Er,parent:M,child:s}];return M.checks=e.checks,e.checks=l,C.compoundCount++,s}},{name:"descendant",separator:!0,regex:dr.descendant,populate:function(C,e){if(null==C.currentSubject){var t={checks:[]},H={checks:[]},V=C[C.length-1];return t.checks.push({type:kr,ancestor:V,descendant:H}),Nr(C,0,t),C.compoundCount++,H}if(C.currentSubject===e){var i={checks:[]},L=C[C.length-1],n={checks:[]},r={checks:[]},o={checks:[]},a={checks:[]};return i.checks.push({type:Tr,left:L,right:n,subject:r}),r.checks=e.checks,e.checks=[{type:Br}],a.checks.push({type:Br}),n.checks.push({type:Pr,ancestor:a,descendant:o}),Nr(C,0,i),C.currentSubject=r,C.compoundCount++,o}var M={checks:[]},s={checks:[]},l=[{type:Pr,ancestor:M,descendant:s}];return M.checks=e.checks,e.checks=l,C.compoundCount++,s}},{name:"subject",modifier:!0,regex:dr.subject,populate:function(C,e){if(null!=C.currentSubject&&C.currentSubject!==e)return Oi("Redefinition of subject in selector `"+C.toString()+"`"),!1;C.currentSubject=e;var t=C[C.length-1].checks[0],H=null==t?null:t.type;H===Sr?t.type=wr:H===Zr&&(t.type=xr,t.node=t.nodes[1],t.neighbor=t.nodes[0],t.nodes=null)}}];Ir.forEach((function(C){return C.regexObj=new RegExp("^"+C.regex)}));var zr=function(C){for(var e,t,H,V=0;V0&&o.edgeCount>0)return Oi("The selector `"+C+"` is invalid because it uses both a compound selector and an edge selector"),!1;if(o.edgeCount>1)return Oi("The selector `"+C+"` is invalid because it uses multiple edge selectors"),!1;1===o.edgeCount&&Oi("The selector `"+C+"` is deprecated. Edge selectors do not take effect on changes to source and target nodes after an edge is added, for performance reasons. Use a class or data selector on edges instead, updating the class or data of an edge when your app detects a change in source or target nodes.")}return!0},toString:function(){if(null!=this.toStringCache)return this.toStringCache;for(var C=function(C){return null==C?"":C},e=function(e){return OV(e)?'"'+e+'"':C(e)},t=function(C){return" "+C+" "},H=function(H,i){var L=H.type,n=H.value;switch(L){case ur:var r=C(n);return r.substring(0,r.length-1);case hr:var o=H.field,a=H.operator;return"["+o+t(C(a))+e(n)+"]";case fr:var M=H.operator,s=H.field;return"["+C(M)+s+"]";case mr:return"["+H.field+"]";case pr:var l=H.operator;return"[["+H.field+t(C(l))+e(n)+"]]";case gr:return n;case vr:return"#"+n;case yr:return"."+n;case Er:case Or:return V(H.parent,i)+t(">")+V(H.child,i);case Pr:case kr:return V(H.ancestor,i)+" "+V(H.descendant,i);case Tr:var d=V(H.left,i),u=V(H.subject,i),c=V(H.right,i);return d+(d.length>0?" ":"")+u+c;case Br:return""}},V=function(C,e){return C.checks.reduce((function(t,V,i){return t+(e===C&&0===i?"$":"")+H(V,e)}),"")},i="",L=0;L1&&L=0&&(e=e.replace("!",""),a=!0),e.indexOf("@")>=0&&(e=e.replace("@",""),o=!0),(L||r||o)&&(V=L||n?""+C:"",i=""+t),o&&(C=V=V.toLowerCase(),t=i=i.toLowerCase()),e){case"*=":H=V.indexOf(i)>=0;break;case"$=":H=V.indexOf(i,V.length-i.length)>=0;break;case"^=":H=0===V.indexOf(i);break;case"=":H=C===t;break;case">":M=!0,H=C>t;break;case">=":M=!0,H=C>=t;break;case"<":M=!0,H=C0;){var o=V.shift();e(o),i.add(o.id()),L&&H(V,i,o)}return C}function Ho(C,e,t){if(t.isParent())for(var H=t._private.children,V=0;V1&&void 0!==arguments[1])||arguments[1],Ho)},eo.forEachUp=function(C){return to(this,C,!(arguments.length>1&&void 0!==arguments[1])||arguments[1],Vo)},eo.forEachUpAndDown=function(C){return to(this,C,!(arguments.length>1&&void 0!==arguments[1])||arguments[1],io)},eo.ancestors=eo.parents,(Kr=Jr={data:Mr.data({field:"data",bindingEvent:"data",allowBinding:!0,allowSetting:!0,settingEvent:"data",settingTriggersEvent:!0,triggerFnName:"trigger",allowGetting:!0,immutableKeys:{id:!0,source:!0,target:!0,parent:!0},updateStyle:!0}),removeData:Mr.removeData({field:"data",event:"data",triggerFnName:"trigger",triggerEvent:!0,immutableKeys:{id:!0,source:!0,target:!0,parent:!0},updateStyle:!0}),scratch:Mr.data({field:"scratch",bindingEvent:"scratch",allowBinding:!0,allowSetting:!0,settingEvent:"scratch",settingTriggersEvent:!0,triggerFnName:"trigger",allowGetting:!0,updateStyle:!0}),removeScratch:Mr.removeData({field:"scratch",event:"scratch",triggerFnName:"trigger",triggerEvent:!0,updateStyle:!0}),rscratch:Mr.data({field:"rscratch",allowBinding:!1,allowSetting:!0,settingTriggersEvent:!1,allowGetting:!0}),removeRscratch:Mr.removeData({field:"rscratch",triggerEvent:!1}),id:function(){var C=this[0];if(C)return C._private.data.id}}).attr=Kr.data,Kr.removeAttr=Kr.removeData;var Lo,no,ro=Jr,oo={};function ao(C){return function(e){var t=this;if(void 0===e&&(e=!0),0!==t.length&&t.isNode()&&!t.removed()){for(var H=0,V=t[0],i=V._private.edges,L=0;Le})),minIndegree:Mo("indegree",(function(C,e){return Ce})),minOutdegree:Mo("outdegree",(function(C,e){return Ce}))}),Ci(oo,{totalDegree:function(C){for(var e=0,t=this.nodes(),H=0;H0,a=o;o&&(r=r[0]);var M=a?r.position():{x:0,y:0};return V={x:n.x-M.x,y:n.y-M.y},void 0===C?V:V[C]}for(var s=0;s0,c=u;u&&(d=d[0]);var A=c?d.position():{x:0,y:0};void 0!==e?l.position(C,e+A[C]):void 0!==V&&l.position({x:V.x+A.x,y:V.y+A.y})}}else if(!i)return;return this}},Lo.modelPosition=Lo.point=Lo.position,Lo.modelPositions=Lo.points=Lo.positions,Lo.renderedPoint=Lo.renderedPosition,Lo.relativePoint=Lo.relativePosition;var uo,co,Ao=no;uo=co={},co.renderedBoundingBox=function(C){var e=this.boundingBox(C),t=this.cy(),H=t.zoom(),V=t.pan(),i=e.x1*H+V.x,L=e.x2*H+V.x,n=e.y1*H+V.y,r=e.y2*H+V.y;return{x1:i,x2:L,y1:n,y2:r,w:L-i,h:r-n}},co.dirtyCompoundBoundsCache=function(){var C=arguments.length>0&&void 0!==arguments[0]&&arguments[0],e=this.cy();return e.styleEnabled()&&e.hasCompoundNodes()?(this.forEachUp((function(e){if(e.isParent()){var t=e._private;t.compoundBoundsClean=!1,t.bbCache=null,C||e.emitAndNotify("bounds")}})),this):this},co.updateCompoundBounds=function(){var C=arguments.length>0&&void 0!==arguments[0]&&arguments[0],e=this.cy();if(!e.styleEnabled()||!e.hasCompoundNodes())return this;if(!C&&e.batching())return this;function t(C){if(C.isParent()){var e=C._private,t=C.children(),H="include"===C.pstyle("compound-sizing-wrt-labels").value,V={width:{val:C.pstyle("min-width").pfValue,left:C.pstyle("min-width-bias-left"),right:C.pstyle("min-width-bias-right")},height:{val:C.pstyle("min-height").pfValue,top:C.pstyle("min-height-bias-top"),bottom:C.pstyle("min-height-bias-bottom")}},i=t.boundingBox({includeLabels:H,includeOverlays:!1,useCache:!1}),L=e.position;0!==i.w&&0!==i.h||((i={w:C.pstyle("width").pfValue,h:C.pstyle("height").pfValue}).x1=L.x-i.w/2,i.x2=L.x+i.w/2,i.y1=L.y-i.h/2,i.y2=L.y+i.h/2);var n=V.width.left.value;"px"===V.width.left.units&&V.width.val>0&&(n=100*n/V.width.val);var r=V.width.right.value;"px"===V.width.right.units&&V.width.val>0&&(r=100*r/V.width.val);var o=V.height.top.value;"px"===V.height.top.units&&V.height.val>0&&(o=100*o/V.height.val);var a=V.height.bottom.value;"px"===V.height.bottom.units&&V.height.val>0&&(a=100*a/V.height.val);var M=A(V.width.val-i.w,n,r),s=M.biasDiff,l=M.biasComplementDiff,d=A(V.height.val-i.h,o,a),u=d.biasDiff,c=d.biasComplementDiff;e.autoPadding=function(C,e,t,H){if("%"!==t.units)return"px"===t.units?t.pfValue:0;switch(H){case"width":return C>0?t.pfValue*C:0;case"height":return e>0?t.pfValue*e:0;case"average":return C>0&&e>0?t.pfValue*(C+e)/2:0;case"min":return C>0&&e>0?C>e?t.pfValue*e:t.pfValue*C:0;case"max":return C>0&&e>0?C>e?t.pfValue*C:t.pfValue*e:0;default:return 0}}(i.w,i.h,C.pstyle("padding"),C.pstyle("padding-relative-to").value),e.autoWidth=Math.max(i.w,V.width.val),L.x=(-s+i.x1+i.x2+l)/2,e.autoHeight=Math.max(i.h,V.height.val),L.y=(-u+i.y1+i.y2+c)/2}function A(C,e,t){var H=0,V=0,i=e+t;return C>0&&i>0&&(H=e/i*C,V=t/i*C),{biasDiff:H,biasComplementDiff:V}}}for(var H=0;HC.x2?H:C.x2,C.y1=tC.y2?V:C.y2,C.w=C.x2-C.x1,C.h=C.y2-C.y1)},fo=function(C,e){return null==e?C:mo(C,e.x1,e.y1,e.x2,e.y2)},po=function(C,e,t){return Ri(C,e,t)},go=function(C,e,t){if(!e.cy().headless()){var H,V,i=e._private,L=i.rstyle,n=L.arrowWidth/2;if("none"!==e.pstyle(t+"-arrow-shape").value){"source"===t?(H=L.srcX,V=L.srcY):"target"===t?(H=L.tgtX,V=L.tgtY):(H=L.midX,V=L.midY);var r=i.arrowBounds=i.arrowBounds||{},o=r[t]=r[t]||{};o.x1=H-n,o.y1=V-n,o.x2=H+n,o.y2=V+n,o.w=o.x2-o.x1,o.h=o.y2-o.y1,mL(o,1),mo(C,o.x1,o.y1,o.x2,o.y2)}}},vo=function(C,e,t){if(!e.cy().headless()){var H;H=t?t+"-":"";var V=e._private,i=V.rstyle;if(e.pstyle(H+"label").strValue){var L,n,r,o,a=e.pstyle("text-halign"),M=e.pstyle("text-valign"),s=po(i,"labelWidth",t),l=po(i,"labelHeight",t),d=po(i,"labelX",t),u=po(i,"labelY",t),c=e.pstyle(H+"text-margin-x").pfValue,A=e.pstyle(H+"text-margin-y").pfValue,h=e.isEdge(),m=e.pstyle(H+"text-rotation"),f=e.pstyle("text-outline-width").pfValue,p=e.pstyle("text-border-width").pfValue/2,g=e.pstyle("text-background-padding").pfValue,v=l,y=s,Z=y/2,S=v/2;if(h)L=d-Z,n=d+Z,r=u-S,o=u+S;else{switch(a.value){case"left":L=d-y,n=d;break;case"center":L=d-Z,n=d+Z;break;case"right":L=d,n=d+y}switch(M.value){case"top":r=u-v,o=u;break;case"center":r=u-S,o=u+S;break;case"bottom":r=u,o=u+v}}L+=c-Math.max(f,p)-g-2,n+=c+Math.max(f,p)+g+2,r+=A-Math.max(f,p)-g-2,o+=A+Math.max(f,p)+g+2;var b=t||"main",w=V.labelBounds,x=w[b]=w[b]||{};x.x1=L,x.y1=r,x.x2=n,x.y2=o,x.w=n-L,x.h=o-r;var O=h&&"autorotate"===m.strValue,k=null!=m.pfValue&&0!==m.pfValue;if(O||k){var E=O?po(V.rstyle,"labelAngle",t):m.pfValue,P=Math.cos(E),T=Math.sin(E),B=(L+n)/2,_=(r+o)/2;if(!h){switch(a.value){case"left":B=n;break;case"right":B=L}switch(M.value){case"top":_=o;break;case"bottom":_=r}}var D=function(C,e){return{x:(C-=B)*P-(e-=_)*T+B,y:C*T+e*P+_}},R=D(L,r),F=D(L,o),N=D(n,r),I=D(n,o);L=Math.min(R.x,F.x,N.x,I.x),n=Math.max(R.x,F.x,N.x,I.x),r=Math.min(R.y,F.y,N.y,I.y),o=Math.max(R.y,F.y,N.y,I.y)}var z=b+"Rot",j=w[z]=w[z]||{};j.x1=L,j.y1=r,j.x2=n,j.y2=o,j.w=n-L,j.h=o-r,mo(C,L,r,n,o),mo(V.labelBounds.all,L,r,n,o)}return C}},yo=function(C){var e=0,t=function(C){return(C?1:0)<(H=w[1].x)){var x=t;t=H,H=x}if(V>(i=w[1].y)){var O=V;V=i,i=O}mo(s,t-v,V-v,H+v,i+v)}}else if("bezier"===b||"unbundled-bezier"===b||"segments"===b||"taxi"===b){var k;switch(b){case"bezier":case"unbundled-bezier":k=c.bezierPts;break;case"segments":case"taxi":k=c.linePts}if(null!=k)for(var E=0;E(H=B.x)){var _=t;t=H,H=_}if((V=T.y)>(i=B.y)){var D=V;V=i,i=D}mo(s,t-=v,V-=v,H+=v,i+=v)}if(a&&e.includeEdges&&u&&(go(s,C,"mid-source"),go(s,C,"mid-target"),go(s,C,"source"),go(s,C,"target")),a&&"yes"===C.pstyle("ghost").value){var R=C.pstyle("ghost-offset-x").pfValue,F=C.pstyle("ghost-offset-y").pfValue;mo(s,s.x1+R,s.y1+F,s.x2+R,s.y2+F)}var N=l.bodyBounds=l.bodyBounds||{};pL(N,s),fL(N,A),mL(N,1),a&&(t=s.x1,H=s.x2,V=s.y1,i=s.y2,mo(s,t-g,V-g,H+g,i+g));var I=l.overlayBounds=l.overlayBounds||{};pL(I,s),fL(I,A),mL(I,1);var z=l.labelBounds=l.labelBounds||{};null!=z.all?((r=z.all).x1=1/0,r.y1=1/0,r.x2=-1/0,r.y2=-1/0,r.w=0,r.h=0):z.all=AL(),a&&e.includeLabels&&(e.includeMainLabels&&vo(s,C,null),u&&(e.includeSourceLabels&&vo(s,C,"source"),e.includeTargetLabels&&vo(s,C,"target")))}return s.x1=ho(s.x1),s.y1=ho(s.y1),s.x2=ho(s.x2),s.y2=ho(s.y2),s.w=ho(s.x2-s.x1),s.h=ho(s.y2-s.y1),s.w>0&&s.h>0&&m&&(fL(s,A),mL(s,1)),s}(C,bo),H.bbCache=t,H.bbCachePosKey=L):t=H.bbCache,!i){var a=C.isNode();t=AL(),(e.includeNodes&&a||e.includeEdges&&!a)&&(e.includeOverlays?fo(t,H.overlayBounds):fo(t,H.bodyBounds)),e.includeLabels&&(e.includeMainLabels&&(!V||e.includeSourceLabels&&e.includeTargetLabels)?fo(t,H.labelBounds.all):(e.includeMainLabels&&fo(t,H.labelBounds.mainRot),e.includeSourceLabels&&fo(t,H.labelBounds.sourceRot),e.includeTargetLabels&&fo(t,H.labelBounds.targetRot))),t.w=t.x2-t.x1,t.h=t.y2-t.y1}return t},bo={includeNodes:!0,includeEdges:!0,includeLabels:!0,includeMainLabels:!0,includeSourceLabels:!0,includeTargetLabels:!0,includeOverlays:!0,includeUnderlays:!0,useCache:!0},wo=yo(bo),xo=Bi(bo);co.boundingBox=function(C){var e;if(1!==this.length||null==this[0]._private.bbCache||this[0]._private.styleDirty||void 0!==C&&void 0!==C.useCache&&!0!==C.useCache){e=AL();var t=xo(C=C||bo),H=this;if(H.cy().styleEnabled())for(var V=0;V0&&void 0!==arguments[0]?arguments[0]:Go,e=arguments.length>1?arguments[1]:void 0,t=0;t=0;n--)L(n);return this},Uo.removeAllListeners=function(){return this.removeListener("*")},Uo.emit=Uo.trigger=function(C,e,t){var H=this.listeners,V=H.length;return this.emitting++,EV(e)||(e=[e]),Xo(this,(function(C,i){null!=t&&(H=[{event:i.event,type:i.type,namespace:i.namespace,callback:t}],V=H.length);for(var L=function(t){var V=H[t];if(V.type===i.type&&(!V.namespace||V.namespace===i.namespace||".*"===V.namespace)&&C.eventMatches(C.context,V,i)){var L=[i];null!=e&&function(C,e){for(var t=0;t1&&!H){var V=this.length-1,i=this[V],L=i._private.data.id;this[V]=void 0,this[C]=i,t.set(L,{ele:i,index:C})}return this.length--,this},unmergeOne:function(C){C=C[0];var e=this._private,t=C._private.data.id,H=e.map.get(t);if(!H)return this;var V=H.index;return this.unmergeAt(V),this},unmerge:function(C){var e=this._private.cy;if(!C)return this;if(C&&OV(C)){var t=C;C=e.mutableElements().filter(t)}for(var H=0;H=0;e--){C(this[e])&&this.unmergeAt(e)}return this},map:function(C,e){for(var t=[],H=this,V=0;VH&&(H=n,t=L)}return{value:H,ele:t}},min:function(C,e){for(var t,H=1/0,V=this,i=0;i=0&&V1&&void 0!==arguments[1])||arguments[1],t=this[0],H=t.cy();if(H.styleEnabled()&&t){this.cleanStyle();var V=t._private.style[C];return null!=V?V:e?H.style().getDefaultProperty(C):null}},numericStyle:function(C){var e=this[0];if(e.cy().styleEnabled()&&e){var t=e.pstyle(C);return void 0!==t.pfValue?t.pfValue:t.value}},numericStyleUnits:function(C){var e=this[0];if(e.cy().styleEnabled())return e?e.pstyle(C).units:void 0},renderedStyle:function(C){var e=this.cy();if(!e.styleEnabled())return this;var t=this[0];return t?e.style().getRenderedStyle(t,C):void 0},style:function(C,e){var t=this.cy();if(!t.styleEnabled())return this;var H=t.style();if(PV(C)){var V=C;H.applyBypass(this,V,false),this.emitAndNotify("style")}else if(OV(C)){if(void 0===e){var i=this[0];return i?H.getStylePropertyValue(i,C):void 0}H.applyBypass(this,C,e,false),this.emitAndNotify("style")}else if(void 0===C){var L=this[0];return L?H.getRawStyle(L):void 0}return this},removeStyle:function(C){var e=this.cy();if(!e.styleEnabled())return this;var t=e.style(),H=this;if(void 0===C)for(var V=0;V0&&e.push(a[0]),e.push(n[0])}return this.spawn(e,!0).filter(C)}),"neighborhood"),closedNeighborhood:function(C){return this.neighborhood().add(this).filter(C)},openNeighborhood:function(C){return this.neighborhood(C)}}),fa.neighbourhood=fa.neighborhood,fa.closedNeighbourhood=fa.closedNeighborhood,fa.openNeighbourhood=fa.openNeighborhood,Ci(fa,{source:Co((function(C){var e,t=this[0];return t&&(e=t._private.source||t.cy().collection()),e&&C?e.filter(C):e}),"source"),target:Co((function(C){var e,t=this[0];return t&&(e=t._private.target||t.cy().collection()),e&&C?e.filter(C):e}),"target"),sources:ya({attr:"source"}),targets:ya({attr:"target"})}),Ci(fa,{edgesWith:Co(Za(),"edgesWith"),edgesTo:Co(Za({thisIsSrc:!0}),"edgesTo")}),Ci(fa,{connectedEdges:Co((function(C){for(var e=[],t=0;t0);return i},component:function(){var C=this[0];return C.cy().mutableElements().components(C)[0]}}),fa.componentsOf=fa.components;var ba=function(C,e){var t=arguments.length>2&&void 0!==arguments[2]&&arguments[2],H=arguments.length>3&&void 0!==arguments[3]&&arguments[3];if(void 0!==C){var V=new Ni,i=!1;if(e){if(e.length>0&&PV(e[0])&&!DV(e[0])){i=!0;for(var L=[],n=new zi,r=0,o=e.length;r0&&void 0!==arguments[0])||arguments[0],H=!(arguments.length>1&&void 0!==arguments[1])||arguments[1],V=this,i=V.cy(),L=i._private,n=[],r=[],o=0,a=V.length;o0){for(var T=C.length===V.length?V:new ba(i,C),B=0;B0&&void 0!==arguments[0])||arguments[0],e=!(arguments.length>1&&void 0!==arguments[1])||arguments[1],t=this,H=[],V={},i=t._private.cy;function L(C){var t=V[C.id()];e&&C.removed()||t||(V[C.id()]=!0,C.isNode()?(H.push(C),function(C){for(var e=C._private.edges,t=0;t0&&(C?v.emitAndNotify("remove"):e&&v.emit("remove"));for(var y=0;y=.001?function(e,H){for(var i=0;i0?V=r:H=r}while(Math.abs(n)>i&&++oM&&Math.abs(n.v)>M;);return i?function(C){return o[C*(o.length-1)|0]}:a}}(),Ea=function(C,e,t,H){var V=Oa(C,e,t,H);return function(C,e,t){return C+(e-C)*V(t)}},Pa={linear:function(C,e,t){return C+(e-C)*t},ease:Ea(.25,.1,.25,1),"ease-in":Ea(.42,0,1,1),"ease-out":Ea(0,0,.58,1),"ease-in-out":Ea(.42,0,.58,1),"ease-in-sine":Ea(.47,0,.745,.715),"ease-out-sine":Ea(.39,.575,.565,1),"ease-in-out-sine":Ea(.445,.05,.55,.95),"ease-in-quad":Ea(.55,.085,.68,.53),"ease-out-quad":Ea(.25,.46,.45,.94),"ease-in-out-quad":Ea(.455,.03,.515,.955),"ease-in-cubic":Ea(.55,.055,.675,.19),"ease-out-cubic":Ea(.215,.61,.355,1),"ease-in-out-cubic":Ea(.645,.045,.355,1),"ease-in-quart":Ea(.895,.03,.685,.22),"ease-out-quart":Ea(.165,.84,.44,1),"ease-in-out-quart":Ea(.77,0,.175,1),"ease-in-quint":Ea(.755,.05,.855,.06),"ease-out-quint":Ea(.23,1,.32,1),"ease-in-out-quint":Ea(.86,0,.07,1),"ease-in-expo":Ea(.95,.05,.795,.035),"ease-out-expo":Ea(.19,1,.22,1),"ease-in-out-expo":Ea(1,0,0,1),"ease-in-circ":Ea(.6,.04,.98,.335),"ease-out-circ":Ea(.075,.82,.165,1),"ease-in-out-circ":Ea(.785,.135,.15,.86),spring:function(C,e,t){if(0===t)return Pa.linear;var H=ka(C,e,t);return function(C,e,t){return C+(e-C)*H(t)}},"cubic-bezier":Ea};function Ta(C,e,t,H,V){if(1===H)return t;if(e===t)return t;var i=V(e,t,H);return null==C||((C.roundValue||C.color)&&(i=Math.round(i)),void 0!==C.min&&(i=Math.max(i,C.min)),void 0!==C.max&&(i=Math.min(i,C.max))),i}function Ba(C,e){return null!=C.pfValue||null!=C.value?null==C.pfValue||null!=e&&"%"===e.type.units?C.value:C.pfValue:C}function _a(C,e,t,H,V){var i=null!=V?V.type:null;t<0?t=0:t>1&&(t=1);var L=Ba(C,V),n=Ba(e,V);if(TV(L)&&TV(n))return Ta(i,L,n,t,H);if(EV(L)&&EV(n)){for(var r=[],o=0;o0?("spring"===M&&s.push(L.duration),L.easingImpl=Pa[M].apply(null,s)):L.easingImpl=Pa[M]}var l,d=L.easingImpl;if(l=0===L.duration?1:(t-r)/L.duration,L.applying&&(l=L.progress),l<0?l=0:l>1&&(l=1),null==L.delay){var u=L.startPosition,c=L.position;if(c&&V&&!C.locked()){var A={};Ra(u.x,c.x)&&(A.x=_a(u.x,c.x,l,d)),Ra(u.y,c.y)&&(A.y=_a(u.y,c.y,l,d)),C.position(A)}var h=L.startPan,m=L.pan,f=i.pan,p=null!=m&&H;p&&(Ra(h.x,m.x)&&(f.x=_a(h.x,m.x,l,d)),Ra(h.y,m.y)&&(f.y=_a(h.y,m.y,l,d)),C.emit("pan"));var g=L.startZoom,v=L.zoom,y=null!=v&&H;y&&(Ra(g,v)&&(i.zoom=cL(i.minZoom,_a(g,v,l,d),i.maxZoom)),C.emit("zoom")),(p||y)&&C.emit("viewport");var Z=L.style;if(Z&&Z.length>0&&V){for(var S=0;S=0;e--){(0,C[e])()}C.splice(0,C.length)},a=i.length-1;a>=0;a--){var M=i[a],s=M._private;s.stopped?(i.splice(a,1),s.hooked=!1,s.playing=!1,s.started=!1,o(s.frames)):(s.playing||s.applying)&&(s.playing&&s.applying&&(s.applying=!1),s.started||Fa(0,M,C),Da(e,M,C,t),s.applying&&(s.applying=!1),o(s.frames),null!=s.step&&s.step(C),M.completed()&&(i.splice(a,1),s.hooked=!1,s.playing=!1,s.started=!1,o(s.completes)),n=!0)}return t||0!==i.length||0!==L.length||H.push(e),n}for(var i=!1,L=0;L0?e.notify("draw",t):e.notify("draw")),t.unmerge(H),e.emit("step")}var Ia={animate:Mr.animate(),animation:Mr.animation(),animated:Mr.animated(),clearQueue:Mr.clearQueue(),delay:Mr.delay(),delayAnimation:Mr.delayAnimation(),stop:Mr.stop(),addToAnimationPool:function(C){this.styleEnabled()&&this._private.aniEles.merge(C)},stopAnimationLoop:function(){this._private.animationsRunning=!1},startAnimationLoop:function(){var C=this;if(C._private.animationsRunning=!0,C.styleEnabled()){var e=C.renderer();e&&e.beforeRender?e.beforeRender((function(e,t){Na(t,C)}),e.beforeRenderPriorities.animations):function e(){C._private.animationsRunning&&ri((function(t){Na(t,C),e()}))}()}}},za={qualifierCompare:function(C,e){return null==C||null==e?null==C&&null==e:C.sameText(e)},eventMatches:function(C,e,t){var H=e.qualifier;return null==H||C!==t.target&&DV(t.target)&&H.matches(t.target)},addEventFields:function(C,e){e.cy=C,e.target=C},callbackContext:function(C,e,t){return null!=e.qualifier?t.target:C}},ja=function(C){return OV(C)?new Xr(C):C},Ga={createEmitter:function(){var C=this._private;return C.emitter||(C.emitter=new Wo(za,this)),this},emitter:function(){return this._private.emitter},on:function(C,e,t){return this.emitter().on(C,ja(e),t),this},removeListener:function(C,e,t){return this.emitter().removeListener(C,ja(e),t),this},removeAllListeners:function(){return this.emitter().removeAllListeners(),this},one:function(C,e,t){return this.emitter().one(C,ja(e),t),this},once:function(C,e,t){return this.emitter().one(C,ja(e),t),this},emit:function(C,e){return this.emitter().emit(C,e),this},emitAndNotify:function(C,e){return this.emit(C),this.notify(C,e),this}};Mr.eventAliasesOn(Ga);var Wa={png:function(C){return C=C||{},this._private.renderer.png(C)},jpg:function(C){var e=this._private.renderer;return(C=C||{}).bg=C.bg||"#fff",e.jpg(C)}};Wa.jpeg=Wa.jpg;var Ua={layout:function(C){var e=this;if(null!=C)if(null!=C.name){var t=C.name,H=e.extension("layout",t);if(null!=H){var V;V=OV(C.eles)?e.$(C.eles):null!=C.eles?C.eles:e.$();var i=new H(Ci({},C,{cy:e,eles:V}));return i}wi("No such layout `"+t+"` found. Did you forget to import it and `cytoscape.use()` it?")}else wi("A `name` must be specified to make a layout");else wi("Layout options must be specified to make a layout")}};Ua.createLayout=Ua.makeLayout=Ua.layout;var $a={notify:function(C,e){var t=this._private;if(this.batching()){t.batchNotifications=t.batchNotifications||{};var H=t.batchNotifications[C]=t.batchNotifications[C]||this.collection();null!=e&&H.merge(e)}else if(t.notificationsEnabled){var V=this.renderer();!this.destroyed()&&V&&V.notify(C,e)}},notifications:function(C){var e=this._private;return void 0===C?e.notificationsEnabled:(e.notificationsEnabled=!!C,this)},noNotifications:function(C){this.notifications(!1),C(),this.notifications(!0)},batching:function(){return this._private.batchCount>0},startBatch:function(){var C=this._private;return null==C.batchCount&&(C.batchCount=0),0===C.batchCount&&(C.batchStyleEles=this.collection(),C.batchNotifications={}),C.batchCount++,this},endBatch:function(){var C=this._private;if(0===C.batchCount)return this;if(C.batchCount--,0===C.batchCount){C.batchStyleEles.updateStyle();var e=this.renderer();Object.keys(C.batchNotifications).forEach((function(t){var H=C.batchNotifications[t];H.empty()?e.notify(t):e.notify(t,H)}))}return this},batch:function(C){return this.startBatch(),C(),this.endBatch(),this},batchData:function(C){var e=this;return this.batch((function(){for(var t=Object.keys(C),H=0;H0;)e.removeChild(e.childNodes[0]);C._private.renderer=null,C.mutableElements().forEach((function(C){var e=C._private;e.rscratch={},e.rstyle={},e.animation.current=[],e.animation.queue=[]}))},onRender:function(C){return this.on("render",C)},offRender:function(C){return this.off("render",C)}};Xa.invalidateDimensions=Xa.resize;var qa={collection:function(C,e){return OV(C)?this.$(C):_V(C)?C.collection():EV(C)?(e||(e={}),new ba(this,C,e.unique,e.removed)):new ba(this)},nodes:function(C){var e=this.$((function(C){return C.isNode()}));return C?e.filter(C):e},edges:function(C){var e=this.$((function(C){return C.isEdge()}));return C?e.filter(C):e},$:function(C){var e=this._private.elements;return C?e.filter(C):e.spawnSelf()},mutableElements:function(){return this._private.elements}};qa.elements=qa.filter=qa.$;var Qa={},Ka="t";Qa.apply=function(C){for(var e=this,t=e._private.cy.collection(),H=0;H0;if(s||M&&l){var d=void 0;s&&l||s?d=o.properties:l&&(d=o.mappedProperties);for(var u=0;u1&&(c=1),n.color){var p=V.valueMin[0],g=V.valueMax[0],v=V.valueMin[1],y=V.valueMax[1],Z=V.valueMin[2],S=V.valueMax[2],b=null==V.valueMin[3]?1:V.valueMin[3],w=null==V.valueMax[3]?1:V.valueMax[3],x=[Math.round(p+(g-p)*c),Math.round(v+(y-v)*c),Math.round(Z+(S-Z)*c),Math.round(b+(w-b)*c)];t={bypass:V.bypass,name:V.name,value:x,strValue:"rgb("+x[0]+", "+x[1]+", "+x[2]+")"}}else{if(!n.number)return!1;var O=V.valueMin+(V.valueMax-V.valueMin)*c;t=this.parse(V.name,O,V.bypass,s)}if(!t)return u(),!1;t.mapping=V,V=t;break;case L.data:for(var k=V.field.split("."),E=M.data,P=0;P0&&i>0){for(var n={},r=!1,o=0;o0?C.delayAnimation(L).play().promise().then(e):e()})).then((function(){return C.animation({style:n,duration:i,easing:C.pstyle("transition-timing-function").value,queue:!1}).play().promise()})).then((function(){t.removeBypasses(C,V),C.emitAndNotify("style"),H.transitioning=!1}))}else H.transitioning&&(this.removeBypasses(C,V),C.emitAndNotify("style"),H.transitioning=!1)},Qa.checkTrigger=function(C,e,t,H,V,i){var L=this.properties[e],n=V(L);null!=n&&n(t,H)&&i(L)},Qa.checkZOrderTrigger=function(C,e,t,H){var V=this;this.checkTrigger(C,e,t,H,(function(C){return C.triggersZOrder}),(function(){V._private.cy.notify("zorder",C)}))},Qa.checkBoundsTrigger=function(C,e,t,H){this.checkTrigger(C,e,t,H,(function(C){return C.triggersBounds}),(function(V){C.dirtyCompoundBoundsCache(),C.dirtyBoundingBoxCache(),!V.triggersBoundsOfParallelBeziers||("curve-style"!==e||"bezier"!==t&&"bezier"!==H)&&("display"!==e||"none"!==t&&"none"!==H)||C.parallelEdges().forEach((function(C){C.isBundledBezier()&&C.dirtyBoundingBoxCache()}))}))},Qa.checkTriggers=function(C,e,t,H){C.dirtyStyleCache(),this.checkZOrderTrigger(C,e,t,H),this.checkBoundsTrigger(C,e,t,H)};var Ja={applyBypass:function(C,e,t,H){var V=[];if("*"===e||"**"===e){if(void 0!==t)for(var i=0;ie.length?i.substr(e.length):""}function n(){t=t.length>H.length?t.substr(H.length):""}for(i=i.replace(/[/][*](\s|.)+?[*][/]/g,"");;){if(i.match(/^\s*$/))break;var r=i.match(/^\s*((?:.|\s)+?)\s*\{((?:.|\s)+?)\}/);if(!r){Oi("Halting stylesheet parsing: String stylesheet contains more to parse but no selector and block found in: "+i);break}e=r[0];var o=r[1];if("core"!==o)if(new Xr(o).invalid){Oi("Skipping parsing of block: Invalid selector found in string stylesheet: "+o),L();continue}var a=r[2],M=!1;t=a;for(var s=[];;){if(t.match(/^\s*$/))break;var l=t.match(/^\s*(.+?)\s*:\s*(.+?)(?:\s*;|\s*$)/);if(!l){Oi("Skipping parsing of block: Invalid formatting of style property and value definitions found in:"+a),M=!0;break}H=l[0];var d=l[1],u=l[2];if(this.properties[d])V.parse(d,u)?(s.push({name:d,val:u}),n()):(Oi("Skipping property: Invalid property definition in: "+H),n());else Oi("Skipping property: Invalid property name in: "+H),n()}if(M){L();break}V.selector(o);for(var c=0;c=7&&"d"===e[0]&&(o=new RegExp(n.data.regex).exec(e))){if(t)return!1;var s=n.data;return{name:C,value:o,strValue:""+e,mapped:s,field:o[1],bypass:t}}if(e.length>=10&&"m"===e[0]&&(a=new RegExp(n.mapData.regex).exec(e))){if(t)return!1;if(M.multiple)return!1;var l=n.mapData;if(!M.color&&!M.number)return!1;var d=this.parse(C,a[4]);if(!d||d.mapped)return!1;var u=this.parse(C,a[5]);if(!u||u.mapped)return!1;if(d.pfValue===u.pfValue||d.strValue===u.strValue)return Oi("`"+C+": "+e+"` is not a valid mapper because the output range is zero; converting to `"+C+": "+d.strValue+"`"),this.parse(C,d.strValue);if(M.color){var c=d.value,A=u.value;if(!(c[0]!==A[0]||c[1]!==A[1]||c[2]!==A[2]||c[3]!==A[3]&&(null!=c[3]&&1!==c[3]||null!=A[3]&&1!==A[3])))return!1}return{name:C,value:a,strValue:""+e,mapped:l,field:a[1],fieldMin:parseFloat(a[2]),fieldMax:parseFloat(a[3]),valueMin:d.value,valueMax:u.value,bypass:t}}}if(M.multiple&&"multiple"!==H){var h;if(h=r?e.split(/\s+/):EV(e)?e:[e],M.evenMultiple&&h.length%2!=0)return null;for(var m=[],f=[],p=[],g="",v=!1,y=0;y0?" ":"")+Z.strValue}return M.validate&&!M.validate(m,f)?null:M.singleEnum&&v?1===m.length&&OV(m[0])?{name:C,value:m[0],strValue:m[0],bypass:t}:null:{name:C,value:m,pfValue:p,strValue:g,bypass:t,units:f}}var S,b,w=function(){for(var H=0;HM.max||M.strictMax&&e===M.max))return null;var P={name:C,value:e,strValue:""+e+(x||""),units:x,bypass:t};return M.unitless||"px"!==x&&"em"!==x?P.pfValue=e:P.pfValue="px"!==x&&x?this.getEmSizeInPixels()*e:e,"ms"!==x&&"s"!==x||(P.pfValue="ms"===x?e:1e3*e),"deg"!==x&&"rad"!==x||(P.pfValue="rad"===x?e:(S=e,Math.PI*S/180)),"%"===x&&(P.pfValue=e/100),P}if(M.propList){var T=[],B=""+e;if("none"===B);else{for(var _=B.split(/\s*,\s*|\s+/),D=0;D<_.length;D++){var R=_[D].trim();V.properties[R]?T.push(R):Oi("`"+R+"` is not a valid property name")}if(0===T.length)return null}return{name:C,value:T,strValue:0===T.length?"none":T.join(" "),bypass:t}}if(M.color){var F=ei(e);return F?{name:C,value:F,pfValue:F,strValue:"rgb("+F[0]+","+F[1]+","+F[2]+")",bypass:t}:null}if(M.regex||M.regexes){if(M.enums){var N=w();if(N)return N}for(var I=M.regexes?M.regexes:[M.regex],z=0;z0&&r>0&&!isNaN(t.w)&&!isNaN(t.h)&&t.w>0&&t.h>0)return{zoom:L=(L=(L=Math.min((n-2*e)/t.w,(r-2*e)/t.h))>this._private.maxZoom?this._private.maxZoom:L)=t.minZoom&&(t.maxZoom=e),this},minZoom:function(C){return void 0===C?this._private.minZoom:this.zoomRange({min:C})},maxZoom:function(C){return void 0===C?this._private.maxZoom:this.zoomRange({max:C})},getZoomedViewport:function(C){var e,t,H=this._private,V=H.pan,i=H.zoom,L=!1;if(H.zoomingEnabled||(L=!0),TV(C)?t=C:PV(C)&&(t=C.level,null!=C.position?e=iL(C.position,i,V):null!=C.renderedPosition&&(e=C.renderedPosition),null==e||H.panningEnabled||(L=!0)),t=(t=t>H.maxZoom?H.maxZoom:t)e.maxZoom||!e.zoomingEnabled?i=!0:(e.zoom=n,V.push("zoom"))}if(H&&(!i||!C.cancelOnFailedZoom)&&e.panningEnabled){var r=C.pan;TV(r.x)&&(e.pan.x=r.x,L=!1),TV(r.y)&&(e.pan.y=r.y,L=!1),L||V.push("pan")}return V.length>0&&(V.push("viewport"),this.emit(V.join(" ")),this.notify("viewport")),this},center:function(C){var e=this.getCenterPan(C);return e&&(this._private.pan=e,this.emit("pan viewport"),this.notify("viewport")),this},getCenterPan:function(C,e){if(this._private.panningEnabled){if(OV(C)){var t=C;C=this.mutableElements().filter(t)}else _V(C)||(C=this.mutableElements());if(0!==C.length){var H=C.boundingBox(),V=this.width(),i=this.height();return{x:(V-(e=void 0===e?this._private.zoom:e)*(H.x1+H.x2))/2,y:(i-e*(H.y1+H.y2))/2}}}},reset:function(){return this._private.panningEnabled&&this._private.zoomingEnabled?(this.viewport({pan:{x:0,y:0},zoom:1}),this):this},invalidateSize:function(){this._private.sizeCache=null},size:function(){var C,e,t=this._private,H=t.container,V=this;return t.sizeCache=t.sizeCache||(H?(C=V.window().getComputedStyle(H),e=function(e){return parseFloat(C.getPropertyValue(e))},{width:H.clientWidth-e("padding-left")-e("padding-right"),height:H.clientHeight-e("padding-top")-e("padding-bottom")}):{width:1,height:1})},width:function(){return this.size().width},height:function(){return this.size().height},extent:function(){var C=this._private.pan,e=this._private.zoom,t=this.renderedExtent(),H={x1:(t.x1-C.x)/e,x2:(t.x2-C.x)/e,y1:(t.y1-C.y)/e,y2:(t.y2-C.y)/e};return H.w=H.x2-H.x1,H.h=H.y2-H.y1,H},renderedExtent:function(){var C=this.width(),e=this.height();return{x1:0,y1:0,x2:C,y2:e,w:C,h:e}},multiClickDebounceTime:function(C){return C?(this._private.multiClickDebounceTime=C,this):this._private.multiClickDebounceTime}};oM.centre=oM.center,oM.autolockNodes=oM.autolock,oM.autoungrabifyNodes=oM.autoungrabify;var aM={data:Mr.data({field:"data",bindingEvent:"data",allowBinding:!0,allowSetting:!0,settingEvent:"data",settingTriggersEvent:!0,triggerFnName:"trigger",allowGetting:!0,updateStyle:!0}),removeData:Mr.removeData({field:"data",event:"data",triggerFnName:"trigger",triggerEvent:!0,updateStyle:!0}),scratch:Mr.data({field:"scratch",bindingEvent:"scratch",allowBinding:!0,allowSetting:!0,settingEvent:"scratch",settingTriggersEvent:!0,triggerFnName:"trigger",allowGetting:!0,updateStyle:!0}),removeScratch:Mr.removeData({field:"scratch",event:"scratch",triggerFnName:"trigger",triggerEvent:!0,updateStyle:!0})};aM.attr=aM.data,aM.removeAttr=aM.removeData;var MM=function(C){var e=this,t=(C=Ci({},C)).container;t&&!BV(t)&&BV(t[0])&&(t=t[0]);var H=t?t._cyreg:null;(H=H||{})&&H.cy&&(H.cy.destroy(),H={});var V=H.readies=H.readies||[];t&&(t._cyreg=H),H.cy=e;var i=void 0!==vV&&void 0!==t&&!C.headless,L=C;L.layout=Ci({name:i?"grid":"null"},L.layout),L.renderer=Ci({name:i?"canvas":"null"},L.renderer);var n=function(C,e,t){return void 0!==e?e:void 0!==t?t:C},r=this._private={container:t,ready:!1,options:L,elements:new ba(this),listeners:[],aniEles:new ba(this),data:L.data||{},scratch:{},layout:null,renderer:null,destroyed:!1,notificationsEnabled:!0,minZoom:1e-50,maxZoom:1e50,zoomingEnabled:n(!0,L.zoomingEnabled),userZoomingEnabled:n(!0,L.userZoomingEnabled),panningEnabled:n(!0,L.panningEnabled),userPanningEnabled:n(!0,L.userPanningEnabled),boxSelectionEnabled:n(!0,L.boxSelectionEnabled),autolock:n(!1,L.autolock,L.autolockNodes),autoungrabify:n(!1,L.autoungrabify,L.autoungrabifyNodes),autounselectify:n(!1,L.autounselectify),styleEnabled:void 0===L.styleEnabled?i:L.styleEnabled,zoom:TV(L.zoom)?L.zoom:1,pan:{x:PV(L.pan)&&TV(L.pan.x)?L.pan.x:0,y:PV(L.pan)&&TV(L.pan.y)?L.pan.y:0},animation:{current:[],queue:[]},hasCompoundNodes:!1,multiClickDebounceTime:n(250,L.multiClickDebounceTime)};this.createEmitter(),this.selectionType(L.selectionType),this.zoomRange({min:L.minZoom,max:L.maxZoom});r.styleEnabled&&e.setStyle([]);var o=Ci({},L,L.renderer);e.initRenderer(o);!function(C,e){if(C.some(zV))return ir.all(C).then(e);e(C)}([L.style,L.elements],(function(C){var t=C[0],i=C[1];r.styleEnabled&&e.style().append(t),function(C,t,H){e.notifications(!1);var V=e.mutableElements();V.length>0&&V.remove(),null!=C&&(PV(C)||EV(C))&&e.add(C),e.one("layoutready",(function(C){e.notifications(!0),e.emit(C),e.one("load",t),e.emitAndNotify("load")})).one("layoutstop",(function(){e.one("done",H),e.emit("done")}));var i=Ci({},e._private.options.layout);i.eles=e.elements(),e.layout(i).run()}(i,(function(){e.startAnimationLoop(),r.ready=!0,kV(L.ready)&&e.on("ready",L.ready);for(var C=0;C0,o=AL(t.boundingBox?t.boundingBox:{x1:0,y1:0,w:H.width(),h:H.height()});if(_V(t.roots))C=t.roots;else if(EV(t.roots)){for(var a=[],M=0;M0;){var x=S.shift(),O=Z(x,b);if(O)x.outgoers().filter((function(C){return C.isNode()&&V.has(C)})).forEach(w);else if(null===O){Oi("Detected double maximal shift for node `"+x.id()+"`. Bailing maximal adjustment due to cycle. Use `options.maximal: true` only on DAGs.");break}}}y();var k=0;if(t.avoidOverlap)for(var E=0;E0&&A[0].length<=3?r/2:0),M=2*Math.PI/A[H].length*V;return 0===H&&1===A[0].length&&(a=1),{x:G+a*Math.cos(M),y:W+a*Math.sin(M)}}return{x:G+(V+1-(i+1)/2)*L,y:(H+1)*n}})),this};var hM={fit:!0,padding:30,boundingBox:void 0,avoidOverlap:!0,nodeDimensionsIncludeLabels:!1,spacingFactor:void 0,radius:void 0,startAngle:1.5*Math.PI,sweep:void 0,clockwise:!0,sort:void 0,animate:!1,animationDuration:500,animationEasing:void 0,animateFilter:function(C,e){return!0},ready:void 0,stop:void 0,transform:function(C,e){return e}};function mM(C){this.options=Ci({},hM,C)}mM.prototype.run=function(){var C=this.options,e=C,t=C.cy,H=e.eles,V=void 0!==e.counterclockwise?!e.counterclockwise:e.clockwise,i=H.nodes().not(":parent");e.sort&&(i=i.sort(e.sort));for(var L,n=AL(e.boundingBox?e.boundingBox:{x1:0,y1:0,w:t.width(),h:t.height()}),r=n.x1+n.w/2,o=n.y1+n.h/2,a=(void 0===e.sweep?2*Math.PI-2*Math.PI/i.length:e.sweep)/Math.max(1,i.length-1),M=0,s=0;s1&&e.avoidOverlap){M*=1.75;var c=Math.cos(a)-Math.cos(0),A=Math.sin(a)-Math.sin(0),h=Math.sqrt(M*M/(c*c+A*A));L=Math.max(h,L)}return H.nodes().layoutPositions(this,e,(function(C,t){var H=e.startAngle+t*a*(V?1:-1),i=L*Math.cos(H),n=L*Math.sin(H);return{x:r+i,y:o+n}})),this};var fM,pM={fit:!0,padding:30,startAngle:1.5*Math.PI,sweep:void 0,clockwise:!0,equidistant:!1,minNodeSpacing:10,boundingBox:void 0,avoidOverlap:!0,nodeDimensionsIncludeLabels:!1,height:void 0,width:void 0,spacingFactor:void 0,concentric:function(C){return C.degree()},levelWidth:function(C){return C.maxDegree()/4},animate:!1,animationDuration:500,animationEasing:void 0,animateFilter:function(C,e){return!0},ready:void 0,stop:void 0,transform:function(C,e){return e}};function gM(C){this.options=Ci({},pM,C)}gM.prototype.run=function(){for(var C=this.options,e=C,t=void 0!==e.counterclockwise?!e.counterclockwise:e.clockwise,H=C.cy,V=e.eles,i=V.nodes().not(":parent"),L=AL(e.boundingBox?e.boundingBox:{x1:0,y1:0,w:H.width(),h:H.height()}),n=L.x1+L.w/2,r=L.y1+L.h/2,o=[],a=0,M=0;M0)Math.abs(h[0].value-f.value)>=c&&(h=[],A.push(h));h.push(f)}var p=a+e.minNodeSpacing;if(!e.avoidOverlap){var g=A.length>0&&A[0].length>1,v=(Math.min(L.w,L.h)/2-p)/(A.length+g?1:0);p=Math.min(p,v)}for(var y=0,Z=0;Z1&&e.avoidOverlap){var x=Math.cos(w)-Math.cos(0),O=Math.sin(w)-Math.sin(0),k=Math.sqrt(p*p/(x*x+O*O));y=Math.max(k,y)}S.r=y,y+=p}if(e.equidistant){for(var E=0,P=0,T=0;T=C.numIter)&&(kM(H,C),H.temperature=H.temperature*C.coolingFactor,!(H.temperature=C.animationThreshold&&i(),ri(e)):(jM(H,C),n())}()}else{for(;o;)o=L(r),r++;jM(H,C),n()}return this},yM.prototype.stop=function(){return this.stopped=!0,this.thread&&this.thread.stop(),this.emit("layoutstop"),this},yM.prototype.destroy=function(){return this.thread&&this.thread.stop(),this};var ZM=function(C,e,t){for(var H=t.eles.edges(),V=t.eles.nodes(),i=AL(t.boundingBox?t.boundingBox:{x1:0,y1:0,w:C.width(),h:C.height()}),L={isCompound:C.hasCompoundNodes(),layoutNodes:[],idToIndex:{},nodeSize:V.size(),graphSet:[],indexToGraph:[],layoutEdges:[],edgeSize:H.size(),temperature:t.initialTemp,clientWidth:i.w,clientHeight:i.h,boundingBox:i},n=t.eles.components(),r={},o=0;o0){L.graphSet.push(p);for(o=0;oH.count?0:H.graph},bM=function C(e,t,H,V){var i=V.graphSet[H];if(-10)var n=(o=H.nodeOverlap*L)*V/(u=Math.sqrt(V*V+i*i)),r=o*i/u;else{var o,a=_M(C,V,i),M=_M(e,-1*V,-1*i),s=M.x-a.x,l=M.y-a.y,d=s*s+l*l,u=Math.sqrt(d);n=(o=(C.nodeRepulsion+e.nodeRepulsion)/d)*s/u,r=o*l/u}C.isLocked||(C.offsetX-=n,C.offsetY-=r),e.isLocked||(e.offsetX+=n,e.offsetY+=r)}},BM=function(C,e,t,H){if(t>0)var V=C.maxX-e.minX;else V=e.maxX-C.minX;if(H>0)var i=C.maxY-e.minY;else i=e.maxY-C.minY;return V>=0&&i>=0?Math.sqrt(V*V+i*i):0},_M=function(C,e,t){var H=C.positionX,V=C.positionY,i=C.height||1,L=C.width||1,n=t/e,r=i/L,o={};return 0===e&&0t?(o.x=H,o.y=V+i/2,o):0e&&-1*r<=n&&n<=r?(o.x=H-L/2,o.y=V-L*t/2/e,o):0=r)?(o.x=H+i*e/2/t,o.y=V+i/2,o):0>t&&(n<=-1*r||n>=r)?(o.x=H-i*e/2/t,o.y=V-i/2,o):o},DM=function(C,e){for(var t=0;t1){var d=e.gravity*M/l,u=e.gravity*s/l;a.offsetX+=d,a.offsetY+=u}}}}},FM=function(C,e){var t=[],H=0,V=-1;for(t.push.apply(t,C.graphSet[0]),V+=C.graphSet[0].length;H<=V;){var i=t[H++],L=C.idToIndex[i],n=C.layoutNodes[L],r=n.children;if(0t)var V={x:t*C/H,y:t*e/H};else V={x:C,y:e};return V},zM=function C(e,t){var H=e.parentId;if(null!=H){var V=t.layoutNodes[t.idToIndex[H]],i=!1;return(null==V.maxX||e.maxX+V.padRight>V.maxX)&&(V.maxX=e.maxX+V.padRight,i=!0),(null==V.minX||e.minX-V.padLeftV.maxY)&&(V.maxY=e.maxY+V.padBottom,i=!0),(null==V.minY||e.minY-V.padTopd&&(M+=l+e.componentSpacing,a=0,s=0,l=0)}}},GM={fit:!0,padding:30,boundingBox:void 0,avoidOverlap:!0,avoidOverlapPadding:10,nodeDimensionsIncludeLabels:!1,spacingFactor:void 0,condense:!1,rows:void 0,cols:void 0,position:function(C){},sort:void 0,animate:!1,animationDuration:500,animationEasing:void 0,animateFilter:function(C,e){return!0},ready:void 0,stop:void 0,transform:function(C,e){return e}};function WM(C){this.options=Ci({},GM,C)}WM.prototype.run=function(){var C=this.options,e=C,t=C.cy,H=e.eles,V=H.nodes().not(":parent");e.sort&&(V=V.sort(e.sort));var i=AL(e.boundingBox?e.boundingBox:{x1:0,y1:0,w:t.width(),h:t.height()});if(0===i.h||0===i.w)H.nodes().layoutPositions(this,e,(function(C){return{x:i.x1,y:i.y1}}));else{var L=V.size(),n=Math.sqrt(L*i.h/i.w),r=Math.round(n),o=Math.round(i.w/i.h*n),a=function(C){if(null==C)return Math.min(r,o);Math.min(r,o)==r?r=C:o=C},M=function(C){if(null==C)return Math.max(r,o);Math.max(r,o)==r?r=C:o=C},s=e.rows,l=null!=e.cols?e.cols:e.columns;if(null!=s&&null!=l)r=s,o=l;else if(null!=s&&null==l)r=s,o=Math.ceil(L/r);else if(null==s&&null!=l)o=l,r=Math.ceil(L/o);else if(o*r>L){var d=a(),u=M();(d-1)*u>=L?a(d-1):(u-1)*d>=L&&M(u-1)}else for(;o*r=L?M(A+1):a(c+1)}var h=i.w/o,m=i.h/r;if(e.condense&&(h=0,m=0),e.avoidOverlap)for(var f=0;f=o&&(k=0,O++)},P={},T=0;T(H=xL(C,e,f[p],f[p+1],f[p+2],f[p+3])))return c(t,H),!0}else if("bezier"===i.edgeType||"multibezier"===i.edgeType||"self"===i.edgeType||"compound"===i.edgeType)for(f=i.allpts,p=0;p+5(H=wL(C,e,f[p],f[p+1],f[p+2],f[p+3],f[p+4],f[p+5])))return c(t,H),!0;h=h||V.source,m=m||V.target;var g=L.getArrowWidth(r,a),v=[{name:"source",x:i.arrowStartX,y:i.arrowStartY,angle:i.srcArrowAngle},{name:"target",x:i.arrowEndX,y:i.arrowEndY,angle:i.tgtArrowAngle},{name:"mid-source",x:i.midX,y:i.midY,angle:i.midsrcArrowAngle},{name:"mid-target",x:i.midX,y:i.midY,angle:i.midtgtArrowAngle}];for(p=0;p0&&(A(h),A(m))}function m(C,e,t){return Ri(C,e,t)}function f(t,H){var V,i=t._private,L=d;V=H?H+"-":"",t.boundingBox();var n=i.labelBounds[H||"main"],r=t.pstyle(V+"label").value;if("yes"===t.pstyle("text-events").strValue&&r){var o=m(i.rscratch,"labelX",H),a=m(i.rscratch,"labelY",H),M=m(i.rscratch,"labelAngle",H),s=t.pstyle(V+"text-margin-x").pfValue,l=t.pstyle(V+"text-margin-y").pfValue,u=n.x1-L-s,A=n.x2+L-s,h=n.y1-L-l,f=n.y2+L-l;if(M){var p=Math.cos(M),g=Math.sin(M),v=function(C,e){return{x:(C-=o)*p-(e-=a)*g+o,y:C*g+e*p+a}},y=v(u,h),Z=v(u,f),S=v(A,h),b=v(A,f),w=[y.x+s,y.y+l,S.x+s,S.y+l,b.x+s,b.y+l,Z.x+s,Z.y+l];if(OL(C,e,w))return c(t),!0}else if(vL(n,C,e))return c(t),!0}}t&&(r=r.interactive);for(var p=r.length-1;p>=0;p--){var g=r[p];g.isNode()?A(g)||f(g):h(g)||f(g)||f(g,"source")||f(g,"target")}return o},getAllInBox:function(C,e,t,H){for(var V,i,L=this.getCachedZSortedEles().interactive,n=[],r=Math.min(C,t),o=Math.max(C,t),a=Math.min(e,H),M=Math.max(e,H),s=AL({x1:C=r,y1:e=a,x2:t=o,y2:H=M}),l=0;l0?Math.max(C-e,0):Math.min(C+e,0)},b=S(y,g),w=S(Z,v),x=!1;"auto"===c?u=Math.abs(b)>Math.abs(w)?V:H:c===r||c===n?(u=H,x=!0):c!==i&&c!==L||(u=V,x=!0);var O,k=u===H,E=k?w:b,P=k?Z:y,T=aL(P),B=!1;(x&&(h||f)||!(c===n&&P<0||c===r&&P>0||c===i&&P>0||c===L&&P<0)||(E=(T*=-1)*Math.abs(E),B=!0),h)?O=(m<0?1+m:m)*E:O=(m<0?E:0)+m*T;var _=function(C){return Math.abs(C)=Math.abs(E)},D=_(O),R=_(Math.abs(E)-Math.abs(O));if((D||R)&&!B)if(k){var F=Math.abs(P)<=M/2,N=Math.abs(y)<=s/2;if(F){var I=(o.x1+o.x2)/2,z=o.y1,j=o.y2;t.segpts=[I,z,I,j]}else if(N){var G=(o.y1+o.y2)/2,W=o.x1,U=o.x2;t.segpts=[W,G,U,G]}else t.segpts=[o.x1,o.y2]}else{var $=Math.abs(P)<=a/2,Y=Math.abs(Z)<=l/2;if($){var X=(o.y1+o.y2)/2,q=o.x1,Q=o.x2;t.segpts=[q,X,Q,X]}else if(Y){var K=(o.x1+o.x2)/2,J=o.y1,CC=o.y2;t.segpts=[K,J,K,CC]}else t.segpts=[o.x2,o.y1]}else if(k){var eC=o.y1+O+(d?M/2*T:0),tC=o.x1,HC=o.x2;t.segpts=[tC,eC,HC,eC]}else{var VC=o.x1+O+(d?a/2*T:0),iC=o.y1,LC=o.y2;t.segpts=[VC,iC,VC,LC]}},is.tryToCorrectInvalidPoints=function(C,e){var t=C._private.rscratch;if("bezier"===t.edgeType){var H=e.srcPos,V=e.tgtPos,i=e.srcW,L=e.srcH,n=e.tgtW,r=e.tgtH,o=e.srcShape,a=e.tgtShape,M=!TV(t.startX)||!TV(t.startY),s=!TV(t.arrowStartX)||!TV(t.arrowStartY),l=!TV(t.endX)||!TV(t.endY),d=!TV(t.arrowEndX)||!TV(t.arrowEndY),u=3*(this.getArrowWidth(C.pstyle("width").pfValue,C.pstyle("arrow-scale").value)*this.arrowShapeWidth),c=ML({x:t.ctrlpts[0],y:t.ctrlpts[1]},{x:t.startX,y:t.startY}),A=cs.poolIndex()){var l=M;M=s,s=l}var d=n.srcPos=M.position(),u=n.tgtPos=s.position(),c=n.srcW=M.outerWidth(),A=n.srcH=M.outerHeight(),h=n.tgtW=s.outerWidth(),m=n.tgtH=s.outerHeight(),f=n.srcShape=t.nodeShapes[e.getNodeShape(M)],p=n.tgtShape=t.nodeShapes[e.getNodeShape(s)];n.dirCounts={north:0,west:0,south:0,east:0,northwest:0,southwest:0,northeast:0,southeast:0};for(var g=0;g0){var I=o,z=sL(I,nL(e)),j=sL(I,nL(N)),G=z;if(j2)sL(I,{x:N[2],y:N[3]})0){var HC=a,VC=sL(HC,nL(e)),iC=sL(HC,nL(tC)),LC=VC;if(iC2)sL(HC,{x:tC[2],y:tC[3]})=o||h){a={cp:u,segment:A};break}}if(a)break}var m=a.cp,f=a.segment,p=(o-s)/f.length,g=f.t1-f.t0,v=n?f.t0+g*p:f.t1-g*p;v=cL(0,v,1),e=uL(m.p0,m.p1,m.p2,v),V=function(C,e,t,H){var V=cL(0,H-.001,1),i=cL(0,H+.001,1),L=uL(C,e,t,V),n=uL(C,e,t,i);return ss(L,n)}(m.p0,m.p1,m.p2,v);break;case"straight":case"segments":case"haystack":for(var y,Z,S,b,w=0,x=H.allpts.length,O=0;O+3=o));O+=2);var k=(o-Z)/y;k=cL(0,k,1),e=function(C,e,t,H){var V=e.x-C.x,i=e.y-C.y,L=ML(C,e),n=V/L,r=i/L;return t=null==t?0:t,H=null!=H?H:t*L,{x:C.x+n*H,y:C.y+r*H}}(S,b,k),V=ss(S,b)}L("labelX",t,e.x),L("labelY",t,e.y),L("labelAutoAngle",t,V)}};o("source"),o("target"),this.applyLabelDimensions(C)}},as.applyLabelDimensions=function(C){this.applyPrefixedLabelDimensions(C),C.isEdge()&&(this.applyPrefixedLabelDimensions(C,"source"),this.applyPrefixedLabelDimensions(C,"target"))},as.applyPrefixedLabelDimensions=function(C,e){var t=C._private,H=this.getLabelText(C,e),V=this.calculateLabelDimensions(C,H),i=C.pstyle("line-height").pfValue,L=C.pstyle("text-wrap").strValue,n=Ri(t.rscratch,"labelWrapCachedLines",e)||[],r="wrap"!==L?1:Math.max(n.length,1),o=V.height/r,a=o*i,M=V.width,s=V.height+(r-1)*(i-1)*o;Fi(t.rstyle,"labelWidth",e,M),Fi(t.rscratch,"labelWidth",e,M),Fi(t.rstyle,"labelHeight",e,s),Fi(t.rscratch,"labelHeight",e,s),Fi(t.rscratch,"labelLineHeight",e,a)},as.getLabelText=function(C,e){var t=C._private,H=e?e+"-":"",V=C.pstyle(H+"label").strValue,i=C.pstyle("text-transform").value,L=function(C,H){return H?(Fi(t.rscratch,C,e,H),H):Ri(t.rscratch,C,e)};if(!V)return"";"none"==i||("uppercase"==i?V=V.toUpperCase():"lowercase"==i&&(V=V.toLowerCase()));var n=C.pstyle("text-wrap").value;if("wrap"===n){var r=L("labelKey");if(null!=r&&L("labelWrapKey")===r)return L("labelWrapCachedText");for(var o=V.split("\n"),a=C.pstyle("text-max-width").pfValue,M="anywhere"===C.pstyle("text-overflow-wrap").value,s=[],l=/[\s\u200b]+/,d=M?"":" ",u=0;ua){for(var m=c.split(l),f="",p=0;py)break;Z+=V[b],b===V.length-1&&(S=!0)}return S||(Z+="…"),Z}return V},as.getLabelJustification=function(C){var e=C.pstyle("text-justification").strValue,t=C.pstyle("text-halign").strValue;if("auto"!==e)return e;if(!C.isNode())return"center";switch(t){case"left":return"right";case"right":return"left";default:return"center"}},as.calculateLabelDimensions=function(C,e){var t=Ai(e,C._private.labelDimsKey),H=this.labelDimCache||(this.labelDimCache=[]),V=H[t];if(null!=V)return V;var i=C.pstyle("font-style").strValue,L=C.pstyle("font-size").pfValue,n=C.pstyle("font-family").strValue,r=C.pstyle("font-weight").strValue,o=this.labelCalcCanvas,a=this.labelCalcCanvasContext;if(!o){o=this.labelCalcCanvas=document.createElement("canvas"),a=this.labelCalcCanvasContext=o.getContext("2d");var M=o.style;M.position="absolute",M.left="-9999px",M.top="-9999px",M.zIndex="-1",M.visibility="hidden",M.pointerEvents="none"}a.font="".concat(i," ").concat(r," ").concat(L,"px ").concat(n);for(var s=0,l=0,d=e.split("\n"),u=0;u1&&void 0!==arguments[1])||arguments[1];if(e.merge(C),t)for(var H=0;H=C.desktopTapThreshold2}var S=V(e);c&&(C.hoverData.tapholdCancelled=!0);t=!0,H(u,["mousemove","vmousemove","tapdrag"],e,{x:a[0],y:a[1]});var b=function(){C.data.bgActivePosistion=void 0,C.hoverData.selecting||L.emit({originalEvent:e,type:"boxstart",position:{x:a[0],y:a[1]}}),d[4]=1,C.hoverData.selecting=!0,C.redrawHint("select",!0),C.redraw()};if(3===C.hoverData.which){if(c){var w={originalEvent:e,type:"cxtdrag",position:{x:a[0],y:a[1]}};h?h.emit(w):L.emit(w),C.hoverData.cxtDragged=!0,C.hoverData.cxtOver&&u===C.hoverData.cxtOver||(C.hoverData.cxtOver&&C.hoverData.cxtOver.emit({originalEvent:e,type:"cxtdragout",position:{x:a[0],y:a[1]}}),C.hoverData.cxtOver=u,u&&u.emit({originalEvent:e,type:"cxtdragover",position:{x:a[0],y:a[1]}}))}}else if(C.hoverData.dragging){if(t=!0,L.panningEnabled()&&L.userPanningEnabled()){var x;if(C.hoverData.justStartedPan){var O=C.hoverData.mdownPos;x={x:(a[0]-O[0])*n,y:(a[1]-O[1])*n},C.hoverData.justStartedPan=!1}else x={x:m[0]*n,y:m[1]*n};L.panBy(x),L.emit("dragpan"),C.hoverData.dragged=!0}a=C.projectIntoViewport(e.clientX,e.clientY)}else if(1!=d[4]||null!=h&&!h.pannable()){if(h&&h.pannable()&&h.active()&&h.unactivate(),h&&h.grabbed()||u==A||(A&&H(A,["mouseout","tapdragout"],e,{x:a[0],y:a[1]}),u&&H(u,["mouseover","tapdragover"],e,{x:a[0],y:a[1]}),C.hoverData.last=u),h)if(c){if(L.boxSelectionEnabled()&&S)h&&h.grabbed()&&(M(f),h.emit("freeon"),f.emit("free"),C.dragData.didDrag&&(h.emit("dragfreeon"),f.emit("dragfree"))),b();else if(h&&h.grabbed()&&C.nodeIsDraggable(h)){var k=!C.dragData.didDrag;k&&C.redrawHint("eles",!0),C.dragData.didDrag=!0,C.hoverData.draggingEles||o(f,{inDragLayer:!0});var E={x:0,y:0};if(TV(m[0])&&TV(m[1])&&(E.x+=m[0],E.y+=m[1],k)){var P=C.hoverData.dragDelta;P&&TV(P[0])&&TV(P[1])&&(E.x+=P[0],E.y+=P[1])}C.hoverData.draggingEles=!0,f.silentShift(E).emit("position drag"),C.redrawHint("drag",!0),C.redraw()}}else!function(){var e=C.hoverData.dragDelta=C.hoverData.dragDelta||[];0===e.length?(e.push(m[0]),e.push(m[1])):(e[0]+=m[0],e[1]+=m[1])}();t=!0}else if(c){if(C.hoverData.dragging||!L.boxSelectionEnabled()||!S&&L.panningEnabled()&&L.userPanningEnabled()){if(!C.hoverData.selecting&&L.panningEnabled()&&L.userPanningEnabled()){i(h,C.hoverData.downs)&&(C.hoverData.dragging=!0,C.hoverData.justStartedPan=!0,d[4]=0,C.data.bgActivePosistion=nL(s),C.redrawHint("select",!0),C.redraw())}}else b();h&&h.pannable()&&h.active()&&h.unactivate()}return d[2]=a[0],d[3]=a[1],t?(e.stopPropagation&&e.stopPropagation(),e.preventDefault&&e.preventDefault(),!1):void 0}}),!1),C.registerBinding(e,"mouseup",(function(e){if(C.hoverData.capture){C.hoverData.capture=!1;var i=C.cy,L=C.projectIntoViewport(e.clientX,e.clientY),n=C.selection,r=C.findNearestElement(L[0],L[1],!0,!1),o=C.dragData.possibleDragElements,a=C.hoverData.down,s=V(e);if(C.data.bgActivePosistion&&(C.redrawHint("select",!0),C.redraw()),C.hoverData.tapholdCancelled=!0,C.data.bgActivePosistion=void 0,a&&a.unactivate(),3===C.hoverData.which){var l={originalEvent:e,type:"cxttapend",position:{x:L[0],y:L[1]}};if(a?a.emit(l):i.emit(l),!C.hoverData.cxtDragged){var d={originalEvent:e,type:"cxttap",position:{x:L[0],y:L[1]}};a?a.emit(d):i.emit(d)}C.hoverData.cxtDragged=!1,C.hoverData.which=null}else if(1===C.hoverData.which){if(H(r,["mouseup","tapend","vmouseup"],e,{x:L[0],y:L[1]}),C.dragData.didDrag||C.hoverData.dragged||C.hoverData.selecting||C.hoverData.isOverThresholdDrag||(H(a,["click","tap","vclick"],e,{x:L[0],y:L[1]}),m=!1,e.timeStamp-f<=i.multiClickDebounceTime()?(h&&clearTimeout(h),m=!0,f=null,H(a,["dblclick","dbltap","vdblclick"],e,{x:L[0],y:L[1]})):(h=setTimeout((function(){m||H(a,["oneclick","onetap","voneclick"],e,{x:L[0],y:L[1]})}),i.multiClickDebounceTime()),f=e.timeStamp)),null!=a||C.dragData.didDrag||C.hoverData.selecting||C.hoverData.dragged||V(e)||(i.$(t).unselect(["tapunselect"]),o.length>0&&C.redrawHint("eles",!0),C.dragData.possibleDragElements=o=i.collection()),r!=a||C.dragData.didDrag||C.hoverData.selecting||null!=r&&r._private.selectable&&(C.hoverData.dragging||("additive"===i.selectionType()||s?r.selected()?r.unselect(["tapunselect"]):r.select(["tapselect"]):s||(i.$(t).unmerge(r).unselect(["tapunselect"]),r.select(["tapselect"]))),C.redrawHint("eles",!0)),C.hoverData.selecting){var u=i.collection(C.getAllInBox(n[0],n[1],n[2],n[3]));C.redrawHint("select",!0),u.length>0&&C.redrawHint("eles",!0),i.emit({type:"boxend",originalEvent:e,position:{x:L[0],y:L[1]}});var c=function(C){return C.selectable()&&!C.selected()};"additive"===i.selectionType()||s||i.$(t).unmerge(u).unselect(),u.emit("box").stdFilter(c).select().emit("boxselect"),C.redraw()}if(C.hoverData.dragging&&(C.hoverData.dragging=!1,C.redrawHint("select",!0),C.redrawHint("eles",!0),C.redraw()),!n[4]){C.redrawHint("drag",!0),C.redrawHint("eles",!0);var A=a&&a.grabbed();M(o),A&&(a.emit("freeon"),o.emit("free"),C.dragData.didDrag&&(a.emit("dragfreeon"),o.emit("dragfree")))}}n[4]=0,C.hoverData.down=null,C.hoverData.cxtStarted=!1,C.hoverData.draggingEles=!1,C.hoverData.selecting=!1,C.hoverData.isOverThresholdDrag=!1,C.dragData.didDrag=!1,C.hoverData.dragged=!1,C.hoverData.dragDelta=[],C.hoverData.mdownPos=null,C.hoverData.mdownGPos=null}}),!1);var g,v,y,Z,S,b,w,x,O,k,E,P,T,B=function(e){if(!C.scrollingPage){var t=C.cy,H=t.zoom(),V=t.pan(),i=C.projectIntoViewport(e.clientX,e.clientY),L=[i[0]*H+V.x,i[1]*H+V.y];if(C.hoverData.draggingEles||C.hoverData.dragging||C.hoverData.cxtStarted||0!==C.selection[4])e.preventDefault();else if(t.panningEnabled()&&t.userPanningEnabled()&&t.zoomingEnabled()&&t.userZoomingEnabled()){var n;e.preventDefault(),C.data.wheelZooming=!0,clearTimeout(C.data.wheelTimeout),C.data.wheelTimeout=setTimeout((function(){C.data.wheelZooming=!1,C.redrawHint("eles",!0),C.redraw()}),150),n=null!=e.deltaY?e.deltaY/-250:null!=e.wheelDeltaY?e.wheelDeltaY/1e3:e.wheelDelta/1e3,n*=C.wheelSensitivity,1===e.deltaMode&&(n*=33);var r=t.zoom()*Math.pow(10,n);"gesturechange"===e.type&&(r=C.gestureStartZoom*e.scale),t.zoom({level:r,renderedPosition:{x:L[0],y:L[1]}}),t.emit("gesturechange"===e.type?"pinchzoom":"scrollzoom")}}};C.registerBinding(C.container,"wheel",B,!0),C.registerBinding(e,"scroll",(function(e){C.scrollingPage=!0,clearTimeout(C.scrollingPageTimeout),C.scrollingPageTimeout=setTimeout((function(){C.scrollingPage=!1}),250)}),!0),C.registerBinding(C.container,"gesturestart",(function(e){C.gestureStartZoom=C.cy.zoom(),C.hasTouchStarted||e.preventDefault()}),!0),C.registerBinding(C.container,"gesturechange",(function(e){C.hasTouchStarted||B(e)}),!0),C.registerBinding(C.container,"mouseout",(function(e){var t=C.projectIntoViewport(e.clientX,e.clientY);C.cy.emit({originalEvent:e,type:"mouseout",position:{x:t[0],y:t[1]}})}),!1),C.registerBinding(C.container,"mouseover",(function(e){var t=C.projectIntoViewport(e.clientX,e.clientY);C.cy.emit({originalEvent:e,type:"mouseover",position:{x:t[0],y:t[1]}})}),!1);var _,D,R,F,N,I,z,j=function(C,e,t,H){return Math.sqrt((t-C)*(t-C)+(H-e)*(H-e))},G=function(C,e,t,H){return(t-C)*(t-C)+(H-e)*(H-e)};if(C.registerBinding(C.container,"touchstart",_=function(e){if(C.hasTouchStarted=!0,p(e)){l(),C.touchData.capture=!0,C.data.bgActivePosistion=void 0;var t=C.cy,V=C.touchData.now,i=C.touchData.earlier;if(e.touches[0]){var L=C.projectIntoViewport(e.touches[0].clientX,e.touches[0].clientY);V[0]=L[0],V[1]=L[1]}if(e.touches[1]){L=C.projectIntoViewport(e.touches[1].clientX,e.touches[1].clientY);V[2]=L[0],V[3]=L[1]}if(e.touches[2]){L=C.projectIntoViewport(e.touches[2].clientX,e.touches[2].clientY);V[4]=L[0],V[5]=L[1]}if(e.touches[1]){C.touchData.singleTouchMoved=!0,M(C.dragData.touchDragEles);var r=C.findContainerClientCoords();O=r[0],k=r[1],E=r[2],P=r[3],g=e.touches[0].clientX-O,v=e.touches[0].clientY-k,y=e.touches[1].clientX-O,Z=e.touches[1].clientY-k,T=0<=g&&g<=E&&0<=y&&y<=E&&0<=v&&v<=P&&0<=Z&&Z<=P;var s=t.pan(),d=t.zoom();S=j(g,v,y,Z),b=G(g,v,y,Z),x=[((w=[(g+y)/2,(v+Z)/2])[0]-s.x)/d,(w[1]-s.y)/d];if(b<4e4&&!e.touches[2]){var u=C.findNearestElement(V[0],V[1],!0,!0),c=C.findNearestElement(V[2],V[3],!0,!0);return u&&u.isNode()?(u.activate().emit({originalEvent:e,type:"cxttapstart",position:{x:V[0],y:V[1]}}),C.touchData.start=u):c&&c.isNode()?(c.activate().emit({originalEvent:e,type:"cxttapstart",position:{x:V[0],y:V[1]}}),C.touchData.start=c):t.emit({originalEvent:e,type:"cxttapstart",position:{x:V[0],y:V[1]}}),C.touchData.start&&(C.touchData.start._private.grabbed=!1),C.touchData.cxt=!0,C.touchData.cxtDragged=!1,C.data.bgActivePosistion=void 0,void C.redraw()}}if(e.touches[2])t.boxSelectionEnabled()&&e.preventDefault();else if(e.touches[1]);else if(e.touches[0]){var A=C.findNearestElements(V[0],V[1],!0,!0),h=A[0];if(null!=h&&(h.activate(),C.touchData.start=h,C.touchData.starts=A,C.nodeIsGrabbable(h))){var m=C.dragData.touchDragEles=t.collection(),f=null;C.redrawHint("eles",!0),C.redrawHint("drag",!0),h.selected()?(f=t.$((function(e){return e.selected()&&C.nodeIsGrabbable(e)})),o(f,{addToList:m})):a(h,{addToList:m}),n(h);var B=function(C){return{originalEvent:e,type:C,position:{x:V[0],y:V[1]}}};h.emit(B("grabon")),f?f.forEach((function(C){C.emit(B("grab"))})):h.emit(B("grab"))}H(h,["touchstart","tapstart","vmousedown"],e,{x:V[0],y:V[1]}),null==h&&(C.data.bgActivePosistion={x:L[0],y:L[1]},C.redrawHint("select",!0),C.redraw()),C.touchData.singleTouchMoved=!1,C.touchData.singleTouchStartTime=+new Date,clearTimeout(C.touchData.tapholdTimeout),C.touchData.tapholdTimeout=setTimeout((function(){!1!==C.touchData.singleTouchMoved||C.pinching||C.touchData.selecting||H(C.touchData.start,["taphold"],e,{x:V[0],y:V[1]})}),C.tapholdDuration)}if(e.touches.length>=1){for(var _=C.touchData.startPosition=[null,null,null,null,null,null],D=0;D=C.touchTapThreshold2}if(t&&C.touchData.cxt){e.preventDefault();var f=e.touches[0].clientX-O,w=e.touches[0].clientY-k,E=e.touches[1].clientX-O,P=e.touches[1].clientY-k,B=G(f,w,E,P);if(B/b>=2.25||B>=22500){C.touchData.cxt=!1,C.data.bgActivePosistion=void 0,C.redrawHint("select",!0);var _={originalEvent:e,type:"cxttapend",position:{x:n[0],y:n[1]}};C.touchData.start?(C.touchData.start.unactivate().emit(_),C.touchData.start=null):L.emit(_)}}if(t&&C.touchData.cxt){_={originalEvent:e,type:"cxtdrag",position:{x:n[0],y:n[1]}};C.data.bgActivePosistion=void 0,C.redrawHint("select",!0),C.touchData.start?C.touchData.start.emit(_):L.emit(_),C.touchData.start&&(C.touchData.start._private.grabbed=!1),C.touchData.cxtDragged=!0;var D=C.findNearestElement(n[0],n[1],!0,!0);C.touchData.cxtOver&&D===C.touchData.cxtOver||(C.touchData.cxtOver&&C.touchData.cxtOver.emit({originalEvent:e,type:"cxtdragout",position:{x:n[0],y:n[1]}}),C.touchData.cxtOver=D,D&&D.emit({originalEvent:e,type:"cxtdragover",position:{x:n[0],y:n[1]}}))}else if(t&&e.touches[2]&&L.boxSelectionEnabled())e.preventDefault(),C.data.bgActivePosistion=void 0,this.lastThreeTouch=+new Date,C.touchData.selecting||L.emit({originalEvent:e,type:"boxstart",position:{x:n[0],y:n[1]}}),C.touchData.selecting=!0,C.touchData.didSelect=!0,V[4]=1,V&&0!==V.length&&void 0!==V[0]?(V[2]=(n[0]+n[2]+n[4])/3,V[3]=(n[1]+n[3]+n[5])/3):(V[0]=(n[0]+n[2]+n[4])/3,V[1]=(n[1]+n[3]+n[5])/3,V[2]=(n[0]+n[2]+n[4])/3+1,V[3]=(n[1]+n[3]+n[5])/3+1),C.redrawHint("select",!0),C.redraw();else if(t&&e.touches[1]&&!C.touchData.didSelect&&L.zoomingEnabled()&&L.panningEnabled()&&L.userZoomingEnabled()&&L.userPanningEnabled()){if(e.preventDefault(),C.data.bgActivePosistion=void 0,C.redrawHint("select",!0),J=C.dragData.touchDragEles){C.redrawHint("drag",!0);for(var R=0;R0&&!C.hoverData.draggingEles&&!C.swipePanning&&null!=C.data.bgActivePosistion&&(C.data.bgActivePosistion=void 0,C.redrawHint("select",!0),C.redraw())}},!1),C.registerBinding(e,"touchcancel",R=function(e){var t=C.touchData.start;C.touchData.capture=!1,t&&t.unactivate()}),C.registerBinding(e,"touchend",F=function(e){var V=C.touchData.start;if(C.touchData.capture){0===e.touches.length&&(C.touchData.capture=!1),e.preventDefault();var i=C.selection;C.swipePanning=!1,C.hoverData.draggingEles=!1;var L,n=C.cy,r=n.zoom(),o=C.touchData.now,a=C.touchData.earlier;if(e.touches[0]){var s=C.projectIntoViewport(e.touches[0].clientX,e.touches[0].clientY);o[0]=s[0],o[1]=s[1]}if(e.touches[1]){s=C.projectIntoViewport(e.touches[1].clientX,e.touches[1].clientY);o[2]=s[0],o[3]=s[1]}if(e.touches[2]){s=C.projectIntoViewport(e.touches[2].clientX,e.touches[2].clientY);o[4]=s[0],o[5]=s[1]}if(V&&V.unactivate(),C.touchData.cxt){if(L={originalEvent:e,type:"cxttapend",position:{x:o[0],y:o[1]}},V?V.emit(L):n.emit(L),!C.touchData.cxtDragged){var l={originalEvent:e,type:"cxttap",position:{x:o[0],y:o[1]}};V?V.emit(l):n.emit(l)}return C.touchData.start&&(C.touchData.start._private.grabbed=!1),C.touchData.cxt=!1,C.touchData.start=null,void C.redraw()}if(!e.touches[2]&&n.boxSelectionEnabled()&&C.touchData.selecting){C.touchData.selecting=!1;var d=n.collection(C.getAllInBox(i[0],i[1],i[2],i[3]));i[0]=void 0,i[1]=void 0,i[2]=void 0,i[3]=void 0,i[4]=0,C.redrawHint("select",!0),n.emit({type:"boxend",originalEvent:e,position:{x:o[0],y:o[1]}});d.emit("box").stdFilter((function(C){return C.selectable()&&!C.selected()})).select().emit("boxselect"),d.nonempty()&&C.redrawHint("eles",!0),C.redraw()}if(null!=V&&V.unactivate(),e.touches[2])C.data.bgActivePosistion=void 0,C.redrawHint("select",!0);else if(e.touches[1]);else if(e.touches[0]);else if(!e.touches[0]){C.data.bgActivePosistion=void 0,C.redrawHint("select",!0);var u=C.dragData.touchDragEles;if(null!=V){var c=V._private.grabbed;M(u),C.redrawHint("drag",!0),C.redrawHint("eles",!0),c&&(V.emit("freeon"),u.emit("free"),C.dragData.didDrag&&(V.emit("dragfreeon"),u.emit("dragfree"))),H(V,["touchend","tapend","vmouseup","tapdragout"],e,{x:o[0],y:o[1]}),V.unactivate(),C.touchData.start=null}else{var A=C.findNearestElement(o[0],o[1],!0,!0);H(A,["touchend","tapend","vmouseup","tapdragout"],e,{x:o[0],y:o[1]})}var h=C.touchData.startPosition[0]-o[0],m=h*h,f=C.touchData.startPosition[1]-o[1],p=(m+f*f)*r*r;C.touchData.singleTouchMoved||(V||n.$(":selected").unselect(["tapunselect"]),H(V,["tap","vclick"],e,{x:o[0],y:o[1]}),N=!1,e.timeStamp-z<=n.multiClickDebounceTime()?(I&&clearTimeout(I),N=!0,z=null,H(V,["dbltap","vdblclick"],e,{x:o[0],y:o[1]})):(I=setTimeout((function(){N||H(V,["onetap","voneclick"],e,{x:o[0],y:o[1]})}),n.multiClickDebounceTime()),z=e.timeStamp)),null!=V&&!C.dragData.didDrag&&V._private.selectable&&p2){for(var w=[o[0],o[1]],x=Math.pow(w[0]-C,2)+Math.pow(w[1]-e,2),O=1;O0)return c[0]}return null},s=Object.keys(a),l=0;l0?r:ZL(V,i,C,e,t,H,L)},checkPoint:function(C,e,t,H,V,i,L){var n=jL(H,V),r=2*n;if(kL(C,e,this.points,i,L,H,V-r,[0,-1],t))return!0;if(kL(C,e,this.points,i,L,H-r,V,[0,-1],t))return!0;var o=H/2+2*t,a=V/2+2*t;return!!OL(C,e,[i-o,L-a,i-o,L,i+o,L,i+o,L-a])||(!!TL(C,e,r,r,i+H/2-n,L+V/2-n,t)||!!TL(C,e,r,r,i-H/2+n,L+V/2-n,t))}}},fs.registerNodeShapes=function(){var C=this.nodeShapes={},e=this;this.generateEllipse(),this.generatePolygon("triangle",NL(3,0)),this.generateRoundPolygon("round-triangle",NL(3,0)),this.generatePolygon("rectangle",NL(4,0)),C.square=C.rectangle,this.generateRoundRectangle(),this.generateCutRectangle(),this.generateBarrel(),this.generateBottomRoundrectangle();var t=[0,1,1,0,0,-1,-1,0];this.generatePolygon("diamond",t),this.generateRoundPolygon("round-diamond",t),this.generatePolygon("pentagon",NL(5,0)),this.generateRoundPolygon("round-pentagon",NL(5,0)),this.generatePolygon("hexagon",NL(6,0)),this.generateRoundPolygon("round-hexagon",NL(6,0)),this.generatePolygon("heptagon",NL(7,0)),this.generateRoundPolygon("round-heptagon",NL(7,0)),this.generatePolygon("octagon",NL(8,0)),this.generateRoundPolygon("round-octagon",NL(8,0));var H=new Array(20),V=zL(5,0),i=zL(5,Math.PI/5),L=.5*(3-Math.sqrt(5));L*=1.57;for(var n=0;n=C.deqFastCost*u)break}else if(V){if(l>=C.deqCost*r||l>=C.deqAvgCost*n)break}else if(d>=C.deqNoDrawCost*Zs)break;var c=C.deq(e,M,a);if(!(c.length>0))break;for(var A=0;A0&&(C.onDeqd(e,o),!V&&C.shouldRedraw(e,o,M,a)&&H())}),V(e))}}},bs=function(){function C(e){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:Zi;AV(this,C),this.idsByKey=new Ni,this.keyForId=new Ni,this.cachesByLvl=new Ni,this.lvls=[],this.getKey=e,this.doesEleInvalidateKey=t}return mV(C,[{key:"getIdsFor",value:function(C){null==C&&wi("Can not get id list for null key");var e=this.idsByKey,t=this.idsByKey.get(C);return t||(t=new zi,e.set(C,t)),t}},{key:"addIdForKey",value:function(C,e){null!=C&&this.getIdsFor(C).add(e)}},{key:"deleteIdForKey",value:function(C,e){null!=C&&this.getIdsFor(C).delete(e)}},{key:"getNumberOfIdsForKey",value:function(C){return null==C?0:this.getIdsFor(C).size}},{key:"updateKeyMappingFor",value:function(C){var e=C.id(),t=this.keyForId.get(e),H=this.getKey(C);this.deleteIdForKey(t,e),this.addIdForKey(H,e),this.keyForId.set(e,H)}},{key:"deleteKeyMappingFor",value:function(C){var e=C.id(),t=this.keyForId.get(e);this.deleteIdForKey(t,e),this.keyForId.delete(e)}},{key:"keyHasChangedFor",value:function(C){var e=C.id();return this.keyForId.get(e)!==this.getKey(C)}},{key:"isInvalid",value:function(C){return this.keyHasChangedFor(C)||this.doesEleInvalidateKey(C)}},{key:"getCachesAt",value:function(C){var e=this.cachesByLvl,t=this.lvls,H=e.get(C);return H||(H=new Ni,e.set(C,H),t.push(C)),H}},{key:"getCache",value:function(C,e){return this.getCachesAt(e).get(C)}},{key:"get",value:function(C,e){var t=this.getKey(C),H=this.getCache(t,e);return null!=H&&this.updateKeyMappingFor(C),H}},{key:"getForCachedKey",value:function(C,e){var t=this.keyForId.get(C.id());return this.getCache(t,e)}},{key:"hasCache",value:function(C,e){return this.getCachesAt(e).has(C)}},{key:"has",value:function(C,e){var t=this.getKey(C);return this.hasCache(t,e)}},{key:"setCache",value:function(C,e,t){t.key=C,this.getCachesAt(e).set(C,t)}},{key:"set",value:function(C,e,t){var H=this.getKey(C);this.setCache(H,e,t),this.updateKeyMappingFor(C)}},{key:"deleteCache",value:function(C,e){this.getCachesAt(e).delete(C)}},{key:"delete",value:function(C,e){var t=this.getKey(C);this.deleteCache(t,e)}},{key:"invalidateKey",value:function(C){var e=this;this.lvls.forEach((function(t){return e.deleteCache(C,t)}))}},{key:"invalidate",value:function(C){var e=C.id(),t=this.keyForId.get(e);this.deleteKeyMappingFor(C);var H=this.doesEleInvalidateKey(C);return H&&this.invalidateKey(t),H||0===this.getNumberOfIdsForKey(t)}}]),C}(),ws={dequeue:"dequeue",downscale:"downscale",highQuality:"highQuality"},xs=Bi({getKey:null,doesEleInvalidateKey:Zi,drawElement:null,getBoundingBox:null,getRotationPoint:null,getRotationOffset:null,isVisible:yi,allowEdgeTxrCaching:!0,allowParentTxrCaching:!0}),Os=function(C,e){var t=this;t.renderer=C,t.onDequeues=[];var H=xs(e);Ci(t,H),t.lookup=new bs(H.getKey,H.doesEleInvalidateKey),t.setupDequeueing()},ks=Os.prototype;ks.reasons=ws,ks.getTextureQueue=function(C){var e=this;return e.eleImgCaches=e.eleImgCaches||{},e.eleImgCaches[C]=e.eleImgCaches[C]||[]},ks.getRetiredTextureQueue=function(C){var e=this.eleImgCaches.retired=this.eleImgCaches.retired||{};return e[C]=e[C]||[]},ks.getElementQueue=function(){var C=this.eleCacheQueue=this.eleCacheQueue||new sV.default((function(C,e){return e.reqs-C.reqs}));return C},ks.getElementKeyToQueue=function(){return this.eleKeyToCacheQueue=this.eleKeyToCacheQueue||{}},ks.getElement=function(C,e,t,H,V){var i=this,L=this.renderer,n=L.cy.zoom(),r=this.lookup;if(!e||0===e.w||0===e.h||isNaN(e.w)||isNaN(e.h)||!C.visible()||C.removed())return null;if(!i.allowEdgeTxrCaching&&C.isEdge()||!i.allowParentTxrCaching&&C.isParent())return null;if(null==H&&(H=Math.ceil(oL(n*t))),H<-4)H=-4;else if(n>=7.99||H>3)return null;var o=Math.pow(2,H),a=e.h*o,M=e.w*o,s=L.eleTextBiggerThanMin(C,o);if(!this.isVisible(C,s))return null;var l,d=r.get(C,H);if(d&&d.invalidated&&(d.invalidated=!1,d.texture.invalidatedWidth-=d.width),d)return d;if(l=a<=25?25:a<=50?50:50*Math.ceil(a/50),a>1024||M>1024)return null;var u=i.getTextureQueue(l),c=u[u.length-2],A=function(){return i.recycleTexture(l,M)||i.addTexture(l,M)};c||(c=u[u.length-1]),c||(c=A()),c.width-c.usedWidthH;b--)Z=i.getElement(C,e,t,b,ws.downscale);S()}else{var w;if(!f&&!p&&!g)for(var x=H-1;x>=-4;x--){var O=r.get(C,x);if(O){w=O;break}}if(m(w))return i.queueElement(C,H),w;c.context.translate(c.usedWidth,0),c.context.scale(o,o),this.drawElement(c.context,C,e,s,!1),c.context.scale(1/o,1/o),c.context.translate(-c.usedWidth,0)}return d={x:c.usedWidth,texture:c,level:H,scale:o,width:M,height:a,scaledLabelShown:s},c.usedWidth+=Math.ceil(M+8),c.eleCaches.push(d),r.set(C,H,d),i.checkTextureFullness(c),d},ks.invalidateElements=function(C){for(var e=0;e=.2*C.width&&this.retireTexture(C)},ks.checkTextureFullness=function(C){var e=this.getTextureQueue(C.height);C.usedWidth/C.width>.8&&C.fullnessChecks>=10?_i(e,C):C.fullnessChecks++},ks.retireTexture=function(C){var e=C.height,t=this.getTextureQueue(e),H=this.lookup;_i(t,C),C.retired=!0;for(var V=C.eleCaches,i=0;i=e)return i.retired=!1,i.usedWidth=0,i.invalidatedWidth=0,i.fullnessChecks=0,Di(i.eleCaches),i.context.setTransform(1,0,0,1,0,0),i.context.clearRect(0,0,i.width,i.height),_i(H,i),t.push(i),i}},ks.queueElement=function(C,e){var t=this.getElementQueue(),H=this.getElementKeyToQueue(),V=this.getKey(C),i=H[V];if(i)i.level=Math.max(i.level,e),i.eles.merge(C),i.reqs++,t.updateItem(i);else{var L={eles:C.spawn().merge(C),level:e,reqs:1,key:V};t.push(L),H[V]=L}},ks.dequeue=function(C){for(var e=this,t=e.getElementQueue(),H=e.getElementKeyToQueue(),V=[],i=e.lookup,L=0;L<1&&t.size()>0;L++){var n=t.pop(),r=n.key,o=n.eles[0],a=i.hasCache(o,n.level);if(H[r]=null,!a){V.push(n);var M=e.getBoundingBox(o);e.getElement(o,M,C,n.level,ws.dequeue)}}return V},ks.removeFromQueue=function(C){var e=this.getElementQueue(),t=this.getElementKeyToQueue(),H=this.getKey(C),V=t[H];null!=V&&(1===V.eles.length?(V.reqs=vi,e.updateItem(V),e.pop(),t[H]=null):V.eles.unmerge(C))},ks.onDequeue=function(C){this.onDequeues.push(C)},ks.offDequeue=function(C){_i(this.onDequeues,C)},ks.setupDequeueing=Ss({deqRedrawThreshold:100,deqCost:.15,deqAvgCost:.1,deqNoDrawCost:.9,deqFastCost:.9,deq:function(C,e,t){return C.dequeue(e,t)},onDeqd:function(C,e){for(var t=0;t=3.99||t>2)return null;H.validateLayersElesOrdering(t,C);var L,n,r=H.layersByLevel,o=Math.pow(2,t),a=r[t]=r[t]||[];if(H.levelIsComplete(t,C))return a;!function(){var e=function(e){if(H.validateLayersElesOrdering(e,C),H.levelIsComplete(e,C))return n=r[e],!0},V=function(C){if(!n)for(var H=t+C;-4<=H&&H<=2&&!e(H);H+=C);};V(1),V(-1);for(var i=a.length-1;i>=0;i--){var L=a[i];L.invalid&&_i(a,L)}}();var M=function(e){var V=(e=e||{}).after;if(function(){if(!L){L=AL();for(var e=0;e16e6)return null;var i=H.makeLayer(L,t);if(null!=V){var n=a.indexOf(V)+1;a.splice(n,0,i)}else(void 0===e.insert||e.insert)&&a.unshift(i);return i};if(H.skipping&&!i)return null;for(var s=null,l=C.length/1,d=!i,u=0;u=l||!yL(s.bb,c.boundingBox()))&&!(s=M({insert:!0,after:s})))return null;n||d?H.queueLayer(s,c):H.drawEleInLayer(s,c,t,e),s.eles.push(c),h[t]=s}}return n||(d?null:a)},Ps.getEleLevelForLayerLevel=function(C,e){return C},Ps.drawEleInLayer=function(C,e,t,H){var V=this.renderer,i=C.context,L=e.boundingBox();0!==L.w&&0!==L.h&&e.visible()&&(t=this.getEleLevelForLayerLevel(t,H),V.setImgSmoothing(i,!1),V.drawCachedElement(i,e,null,null,t,true),V.setImgSmoothing(i,!0))},Ps.levelIsComplete=function(C,e){var t=this.layersByLevel[C];if(!t||0===t.length)return!1;for(var H=0,V=0;V0)return!1;if(i.invalid)return!1;H+=i.eles.length}return H===e.length},Ps.validateLayersElesOrdering=function(C,e){var t=this.layersByLevel[C];if(t)for(var H=0;H0){C=!0;break}}return C},Ps.invalidateElements=function(C){var e=this;0!==C.length&&(e.lastInvalidationTime=oi(),0!==C.length&&e.haveLayers()&&e.updateElementsInLayers(C,(function(C,t,H){e.invalidateLayer(C)})))},Ps.invalidateLayer=function(C){if(this.lastInvalidationTime=oi(),!C.invalid){var e=C.level,t=C.eles,H=this.layersByLevel[e];_i(H,C),C.elesQueue=[],C.invalid=!0,C.replacement&&(C.replacement.invalid=!0);for(var V=0;V3&&void 0!==arguments[3])||arguments[3],V=!(arguments.length>4&&void 0!==arguments[4])||arguments[4],i=!(arguments.length>5&&void 0!==arguments[5])||arguments[5],L=this,n=e._private.rscratch;if((!i||e.visible())&&!n.badLine&&null!=n.allpts&&!isNaN(n.allpts[0])){var r;t&&(r=t,C.translate(-r.x1,-r.y1));var o=i?e.pstyle("opacity").value:1,a=i?e.pstyle("line-opacity").value:1,M=e.pstyle("curve-style").value,s=e.pstyle("line-style").value,l=e.pstyle("width").pfValue,d=e.pstyle("line-cap").value,u=o*a,c=o*a,A=function(){var t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:u;"straight-triangle"===M?(L.eleStrokeStyle(C,e,t),L.drawEdgeTrianglePath(e,C,n.allpts)):(C.lineWidth=l,C.lineCap=d,L.eleStrokeStyle(C,e,t),L.drawEdgePath(e,C,n.allpts,s),C.lineCap="butt")},h=function(){var t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:c;L.drawArrowheads(C,e,t)};if(C.lineJoin="round","yes"===e.pstyle("ghost").value){var m=e.pstyle("ghost-offset-x").pfValue,f=e.pstyle("ghost-offset-y").pfValue,p=e.pstyle("ghost-opacity").value,g=u*p;C.translate(m,f),A(g),h(g),C.translate(-m,-f)}V&&L.drawEdgeUnderlay(C,e),A(),h(),V&&L.drawEdgeOverlay(C,e),L.drawElementText(C,e,null,H),t&&C.translate(r.x1,r.y1)}}},Qs=function(C){if(!["overlay","underlay"].includes(C))throw new Error("Invalid state");return function(e,t){if(t.visible()){var H=t.pstyle("".concat(C,"-opacity")).value;if(0!==H){var V=this,i=V.usePaths(),L=t._private.rscratch,n=2*t.pstyle("".concat(C,"-padding")).pfValue,r=t.pstyle("".concat(C,"-color")).value;e.lineWidth=n,"self"!==L.edgeType||i?e.lineCap="round":e.lineCap="butt",V.colorStrokeStyle(e,r[0],r[1],r[2],H),V.drawEdgePath(t,e,L.allpts,"solid")}}}};qs.drawEdgeOverlay=Qs("overlay"),qs.drawEdgeUnderlay=Qs("underlay"),qs.drawEdgePath=function(C,e,t,H){var V,i=C._private.rscratch,L=e,n=!1,r=this.usePaths(),o=C.pstyle("line-dash-pattern").pfValue,a=C.pstyle("line-dash-offset").pfValue;if(r){var M=t.join("$");i.pathCacheKey&&i.pathCacheKey===M?(V=e=i.pathCache,n=!0):(V=e=new Path2D,i.pathCacheKey=M,i.pathCache=V)}if(L.setLineDash)switch(H){case"dotted":L.setLineDash([1,1]);break;case"dashed":L.setLineDash(o),L.lineDashOffset=a;break;case"solid":L.setLineDash([])}if(!n&&!i.badLine)switch(e.beginPath&&e.beginPath(),e.moveTo(t[0],t[1]),i.edgeType){case"bezier":case"self":case"compound":case"multibezier":for(var s=2;s+35&&void 0!==arguments[5])||arguments[5],L=this;if(null==H){if(i&&!L.eleTextBiggerThanMin(e))return}else if(!1===H)return;if(e.isNode()){var n=e.pstyle("label");if(!n||!n.value)return;var r=L.getLabelJustification(e);C.textAlign=r,C.textBaseline="bottom"}else{var o=e.element()._private.rscratch.badLine,a=e.pstyle("label"),M=e.pstyle("source-label"),s=e.pstyle("target-label");if(o||(!a||!a.value)&&(!M||!M.value)&&(!s||!s.value))return;C.textAlign="center",C.textBaseline="bottom"}var l,d=!t;t&&(l=t,C.translate(-l.x1,-l.y1)),null==V?(L.drawText(C,e,null,d,i),e.isEdge()&&(L.drawText(C,e,"source",d,i),L.drawText(C,e,"target",d,i))):L.drawText(C,e,V,d,i),t&&C.translate(l.x1,l.y1)},Js.getFontCache=function(C){var e;this.fontCaches=this.fontCaches||[];for(var t=0;t2&&void 0!==arguments[2])||arguments[2],H=e.pstyle("font-style").strValue,V=e.pstyle("font-size").pfValue+"px",i=e.pstyle("font-family").strValue,L=e.pstyle("font-weight").strValue,n=t?e.effectiveOpacity()*e.pstyle("text-opacity").value:1,r=e.pstyle("text-outline-opacity").value*n,o=e.pstyle("color").value,a=e.pstyle("text-outline-color").value;C.font=H+" "+L+" "+V+" "+i,C.lineJoin="round",this.colorFillStyle(C,o[0],o[1],o[2],n),this.colorStrokeStyle(C,a[0],a[1],a[2],r)},Js.getTextAngle=function(C,e){var t=C._private.rscratch,H=e?e+"-":"",V=C.pstyle(H+"text-rotation"),i=Ri(t,"labelAngle",e);return"autorotate"===V.strValue?C.isEdge()?i:0:"none"===V.strValue?0:V.pfValue},Js.drawText=function(C,e,t){var H=!(arguments.length>3&&void 0!==arguments[3])||arguments[3],V=!(arguments.length>4&&void 0!==arguments[4])||arguments[4],i=e._private.rscratch,L=V?e.effectiveOpacity():1;if(!V||0!==L&&0!==e.pstyle("text-opacity").value){"main"===t&&(t=null);var n,r,o=Ri(i,"labelX",t),a=Ri(i,"labelY",t),M=this.getLabelText(e,t);if(null!=M&&""!==M&&!isNaN(o)&&!isNaN(a)){this.setupTextStyle(C,e,V);var s,l=t?t+"-":"",d=Ri(i,"labelWidth",t),u=Ri(i,"labelHeight",t),c=e.pstyle(l+"text-margin-x").pfValue,A=e.pstyle(l+"text-margin-y").pfValue,h=e.isEdge(),m=e.pstyle("text-halign").value,f=e.pstyle("text-valign").value;switch(h&&(m="center",f="center"),o+=c,a+=A,0!==(s=H?this.getTextAngle(e,t):0)&&(n=o,r=a,C.translate(n,r),C.rotate(s),o=0,a=0),f){case"top":break;case"center":a+=u/2;break;case"bottom":a+=u}var p=e.pstyle("text-background-opacity").value,g=e.pstyle("text-border-opacity").value,v=e.pstyle("text-border-width").pfValue,y=e.pstyle("text-background-padding").pfValue;if(p>0||v>0&&g>0){var Z=o-y;switch(m){case"left":Z-=d;break;case"center":Z-=d/2}var S=a-u-y,b=d+2*y,w=u+2*y;if(p>0){var x=C.fillStyle,O=e.pstyle("text-background-color").value;C.fillStyle="rgba("+O[0]+","+O[1]+","+O[2]+","+p*L+")",0===e.pstyle("text-background-shape").strValue.indexOf("round")?function(C,e,t,H,V){var i=arguments.length>5&&void 0!==arguments[5]?arguments[5]:5;C.beginPath(),C.moveTo(e+i,t),C.lineTo(e+H-i,t),C.quadraticCurveTo(e+H,t,e+H,t+i),C.lineTo(e+H,t+V-i),C.quadraticCurveTo(e+H,t+V,e+H-i,t+V),C.lineTo(e+i,t+V),C.quadraticCurveTo(e,t+V,e,t+V-i),C.lineTo(e,t+i),C.quadraticCurveTo(e,t,e+i,t),C.closePath(),C.fill()}(C,Z,S,b,w,2):C.fillRect(Z,S,b,w),C.fillStyle=x}if(v>0&&g>0){var k=C.strokeStyle,E=C.lineWidth,P=e.pstyle("text-border-color").value,T=e.pstyle("text-border-style").value;if(C.strokeStyle="rgba("+P[0]+","+P[1]+","+P[2]+","+g*L+")",C.lineWidth=v,C.setLineDash)switch(T){case"dotted":C.setLineDash([1,1]);break;case"dashed":C.setLineDash([4,2]);break;case"double":C.lineWidth=v/4,C.setLineDash([]);break;case"solid":C.setLineDash([])}if(C.strokeRect(Z,S,b,w),"double"===T){var B=v/2;C.strokeRect(Z+B,S+B,b-2*B,w-2*B)}C.setLineDash&&C.setLineDash([]),C.lineWidth=E,C.strokeStyle=k}}var _=2*e.pstyle("text-outline-width").pfValue;if(_>0&&(C.lineWidth=_),"wrap"===e.pstyle("text-wrap").value){var D=Ri(i,"labelWrapCachedLines",t),R=Ri(i,"labelLineHeight",t),F=d/2,N=this.getLabelJustification(e);switch("auto"===N||("left"===m?"left"===N?o+=-d:"center"===N&&(o+=-F):"center"===m?"left"===N?o+=-F:"right"===N&&(o+=F):"right"===m&&("center"===N?o+=F:"right"===N&&(o+=d))),f){case"top":case"center":case"bottom":a-=(D.length-1)*R}for(var I=0;I0&&C.strokeText(D[I],o,a),C.fillText(D[I],o,a),a+=R}else _>0&&C.strokeText(M,o,a),C.fillText(M,o,a);0!==s&&(C.rotate(-s),C.translate(-n,-r))}}};var Cl={drawNode:function(C,e,t){var H,V,i=!(arguments.length>3&&void 0!==arguments[3])||arguments[3],L=!(arguments.length>4&&void 0!==arguments[4])||arguments[4],n=!(arguments.length>5&&void 0!==arguments[5])||arguments[5],r=this,o=e._private,a=o.rscratch,M=e.position();if(TV(M.x)&&TV(M.y)&&(!n||e.visible())){var s,l,d=n?e.effectiveOpacity():1,u=r.usePaths(),c=!1,A=e.padding();H=e.width()+2*A,V=e.height()+2*A,t&&(l=t,C.translate(-l.x1,-l.y1));for(var h=e.pstyle("background-image").value,m=new Array(h.length),f=new Array(h.length),p=0,g=0;g0&&void 0!==arguments[0]?arguments[0]:b;r.eleFillStyle(C,e,t)},E=function(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:O;r.colorStrokeStyle(C,w[0],w[1],w[2],e)},P=e.pstyle("shape").strValue,T=e.pstyle("shape-polygon-points").pfValue;if(u){C.translate(M.x,M.y);var B=r.nodePathCache=r.nodePathCache||[],_=hi("polygon"===P?P+","+T.join(","):P,""+V,""+H),D=B[_];null!=D?(s=D,c=!0,a.pathCache=s):(s=new Path2D,B[_]=a.pathCache=s)}var R=function(){if(!c){var t=M;u&&(t={x:0,y:0}),r.nodeShapes[r.getNodeShape(e)].draw(s||C,t.x,t.y,H,V)}u?C.fill(s):C.fill()},F=function(){for(var t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:d,H=!(arguments.length>1&&void 0!==arguments[1])||arguments[1],V=o.backgrounding,i=0,L=0;L0&&void 0!==arguments[0]&&arguments[0],i=arguments.length>1&&void 0!==arguments[1]?arguments[1]:d;r.hasPie(e)&&(r.drawPie(C,e,i),t&&(u||r.nodeShapes[r.getNodeShape(e)].draw(C,M.x,M.y,H,V)))},I=function(){var e=(Z>0?Z:-Z)*(arguments.length>0&&void 0!==arguments[0]?arguments[0]:d),t=Z>0?0:255;0!==Z&&(r.colorFillStyle(C,t,t,t,e),u?C.fill(s):C.fill())},z=function(){if(S>0){if(C.lineWidth=S,C.lineCap="butt",C.setLineDash)switch(x){case"dotted":C.setLineDash([1,1]);break;case"dashed":C.setLineDash([4,2]);break;case"solid":case"double":C.setLineDash([])}if(u?C.stroke(s):C.stroke(),"double"===x){C.lineWidth=S/3;var e=C.globalCompositeOperation;C.globalCompositeOperation="destination-out",u?C.stroke(s):C.stroke(),C.globalCompositeOperation=e}C.setLineDash&&C.setLineDash([])}};if("yes"===e.pstyle("ghost").value){var j=e.pstyle("ghost-offset-x").pfValue,G=e.pstyle("ghost-offset-y").pfValue,W=e.pstyle("ghost-opacity").value,U=W*d;C.translate(j,G),k(W*b),R(),F(U,!0),E(W*O),z(),N(0!==Z||0!==S),F(U,!1),I(U),C.translate(-j,-G)}u&&C.translate(-M.x,-M.y),L&&r.drawNodeUnderlay(C,e,M,H,V),u&&C.translate(M.x,M.y),k(),R(),F(d,!0),E(),z(),N(0!==Z||0!==S),F(d,!1),I(),u&&C.translate(-M.x,-M.y),r.drawElementText(C,e,null,i),L&&r.drawNodeOverlay(C,e,M,H,V),t&&C.translate(l.x1,l.y1)}}},el=function(C){if(!["overlay","underlay"].includes(C))throw new Error("Invalid state");return function(e,t,H,V,i){if(t.visible()){var L=t.pstyle("".concat(C,"-padding")).pfValue,n=t.pstyle("".concat(C,"-opacity")).value,r=t.pstyle("".concat(C,"-color")).value,o=t.pstyle("".concat(C,"-shape")).value;if(n>0){if(H=H||t.position(),null==V||null==i){var a=t.padding();V=t.width()+2*a,i=t.height()+2*a}this.colorFillStyle(e,r[0],r[1],r[2],n),this.nodeShapes[o].draw(e,H.x,H.y,V+2*L,i+2*L),e.fill()}}}};Cl.drawNodeOverlay=el("overlay"),Cl.drawNodeUnderlay=el("underlay"),Cl.hasPie=function(C){return(C=C[0])._private.hasPie},Cl.drawPie=function(C,e,t,H){e=e[0],H=H||e.position();var V=e.cy().style(),i=e.pstyle("pie-size"),L=H.x,n=H.y,r=e.width(),o=e.height(),a=Math.min(r,o)/2,M=0;this.usePaths()&&(L=0,n=0),"%"===i.units?a*=i.pfValue:void 0!==i.pfValue&&(a=i.pfValue/2);for(var s=1;s<=V.pieBackgroundN;s++){var l=e.pstyle("pie-"+s+"-background-size").value,d=e.pstyle("pie-"+s+"-background-color").value,u=e.pstyle("pie-"+s+"-background-opacity").value*t,c=l/100;c+M>1&&(c=1-M);var A=1.5*Math.PI+2*Math.PI*M,h=A+2*Math.PI*c;0===l||M>=1||M+c>1||(C.beginPath(),C.moveTo(L,n),C.arc(L,n,a,A,h),C.closePath(),this.colorFillStyle(C,d[0],d[1],d[2],u),C.fill(),M+=c)}};var tl={};tl.getPixelRatio=function(){var C=this.data.contexts[0];if(null!=this.forcedPixelRatio)return this.forcedPixelRatio;var e=C.backingStorePixelRatio||C.webkitBackingStorePixelRatio||C.mozBackingStorePixelRatio||C.msBackingStorePixelRatio||C.oBackingStorePixelRatio||C.backingStorePixelRatio||1;return(window.devicePixelRatio||1)/e},tl.paintCache=function(C){for(var e,t=this.paintCaches=this.paintCaches||[],H=!0,V=0;VL.minMbLowQualFrames&&(L.motionBlurPxRatio=L.mbPxRBlurry)),L.clearingMotionBlur&&(L.motionBlurPxRatio=1),L.textureDrawLastFrame&&!M&&(a[L.NODE]=!0,a[L.SELECT_BOX]=!0);var h=r.style(),m=r.zoom(),f=void 0!==V?V:m,p=r.pan(),g={x:p.x,y:p.y},v={zoom:m,pan:{x:p.x,y:p.y}},y=L.prevViewport;void 0===y||v.zoom!==y.zoom||v.pan.x!==y.pan.x||v.pan.y!==y.pan.y||u&&!d||(L.motionBlurPxRatio=1),i&&(g=i),f*=n,g.x*=n,g.y*=n;var Z=L.getCachedZSortedEles();function S(C,e,t,H,V){var i=C.globalCompositeOperation;C.globalCompositeOperation="destination-out",L.colorFillStyle(C,255,255,255,L.motionBlurTransparency),C.fillRect(e,t,H,V),C.globalCompositeOperation=i}function b(C,H){var n,r,a,M;L.clearingMotionBlur||C!==o.bufferContexts[L.MOTIONBLUR_BUFFER_NODE]&&C!==o.bufferContexts[L.MOTIONBLUR_BUFFER_DRAG]?(n=g,r=f,a=L.canvasWidth,M=L.canvasHeight):(n={x:p.x*l,y:p.y*l},r=m*l,a=L.canvasWidth*l,M=L.canvasHeight*l),C.setTransform(1,0,0,1,0,0),"motionBlur"===H?S(C,0,0,a,M):e||void 0!==H&&!H||C.clearRect(0,0,a,M),t||(C.translate(n.x,n.y),C.scale(r,r)),i&&C.translate(i.x,i.y),V&&C.scale(V,V)}if(M||(L.textureDrawLastFrame=!1),M){if(L.textureDrawLastFrame=!0,!L.textureCache){L.textureCache={},L.textureCache.bb=r.mutableElements().boundingBox(),L.textureCache.texture=L.data.bufferCanvases[L.TEXTURE_BUFFER];var w=L.data.bufferContexts[L.TEXTURE_BUFFER];w.setTransform(1,0,0,1,0,0),w.clearRect(0,0,L.canvasWidth*L.textureMult,L.canvasHeight*L.textureMult),L.render({forcedContext:w,drawOnlyNodeLayer:!0,forcedPxRatio:n*L.textureMult}),(v=L.textureCache.viewport={zoom:r.zoom(),pan:r.pan(),width:L.canvasWidth,height:L.canvasHeight}).mpan={x:(0-v.pan.x)/v.zoom,y:(0-v.pan.y)/v.zoom}}a[L.DRAG]=!1,a[L.NODE]=!1;var x=o.contexts[L.NODE],O=L.textureCache.texture;v=L.textureCache.viewport;x.setTransform(1,0,0,1,0,0),s?S(x,0,0,v.width,v.height):x.clearRect(0,0,v.width,v.height);var k=h.core("outside-texture-bg-color").value,E=h.core("outside-texture-bg-opacity").value;L.colorFillStyle(x,k[0],k[1],k[2],E),x.fillRect(0,0,v.width,v.height);m=r.zoom();b(x,!1),x.clearRect(v.mpan.x,v.mpan.y,v.width/v.zoom/n,v.height/v.zoom/n),x.drawImage(O,v.mpan.x,v.mpan.y,v.width/v.zoom/n,v.height/v.zoom/n)}else L.textureOnViewport&&!e&&(L.textureCache=null);var P=r.extent(),T=L.pinching||L.hoverData.dragging||L.swipePanning||L.data.wheelZooming||L.hoverData.draggingEles||L.cy.animated(),B=L.hideEdgesOnViewport&&T,_=[];if(_[L.NODE]=!a[L.NODE]&&s&&!L.clearedForMotionBlur[L.NODE]||L.clearingMotionBlur,_[L.NODE]&&(L.clearedForMotionBlur[L.NODE]=!0),_[L.DRAG]=!a[L.DRAG]&&s&&!L.clearedForMotionBlur[L.DRAG]||L.clearingMotionBlur,_[L.DRAG]&&(L.clearedForMotionBlur[L.DRAG]=!0),a[L.NODE]||t||H||_[L.NODE]){var D=s&&!_[L.NODE]&&1!==l;b(x=e||(D?L.data.bufferContexts[L.MOTIONBLUR_BUFFER_NODE]:o.contexts[L.NODE]),s&&!D?"motionBlur":void 0),B?L.drawCachedNodes(x,Z.nondrag,n,P):L.drawLayeredElements(x,Z.nondrag,n,P),L.debug&&L.drawDebugPoints(x,Z.nondrag),t||s||(a[L.NODE]=!1)}if(!H&&(a[L.DRAG]||t||_[L.DRAG])){D=s&&!_[L.DRAG]&&1!==l;b(x=e||(D?L.data.bufferContexts[L.MOTIONBLUR_BUFFER_DRAG]:o.contexts[L.DRAG]),s&&!D?"motionBlur":void 0),B?L.drawCachedNodes(x,Z.drag,n,P):L.drawCachedElements(x,Z.drag,n,P),L.debug&&L.drawDebugPoints(x,Z.drag),t||s||(a[L.DRAG]=!1)}if(L.showFps||!H&&a[L.SELECT_BOX]&&!t){if(b(x=e||o.contexts[L.SELECT_BOX]),1==L.selection[4]&&(L.hoverData.selecting||L.touchData.selecting)){m=L.cy.zoom();var R=h.core("selection-box-border-width").value/m;x.lineWidth=R,x.fillStyle="rgba("+h.core("selection-box-color").value[0]+","+h.core("selection-box-color").value[1]+","+h.core("selection-box-color").value[2]+","+h.core("selection-box-opacity").value+")",x.fillRect(L.selection[0],L.selection[1],L.selection[2]-L.selection[0],L.selection[3]-L.selection[1]),R>0&&(x.strokeStyle="rgba("+h.core("selection-box-border-color").value[0]+","+h.core("selection-box-border-color").value[1]+","+h.core("selection-box-border-color").value[2]+","+h.core("selection-box-opacity").value+")",x.strokeRect(L.selection[0],L.selection[1],L.selection[2]-L.selection[0],L.selection[3]-L.selection[1]))}if(o.bgActivePosistion&&!L.hoverData.selecting){m=L.cy.zoom();var F=o.bgActivePosistion;x.fillStyle="rgba("+h.core("active-bg-color").value[0]+","+h.core("active-bg-color").value[1]+","+h.core("active-bg-color").value[2]+","+h.core("active-bg-opacity").value+")",x.beginPath(),x.arc(F.x,F.y,h.core("active-bg-size").pfValue/m,0,2*Math.PI),x.fill()}var N=L.lastRedrawTime;if(L.showFps&&N){N=Math.round(N);var I=Math.round(1e3/N);x.setTransform(1,0,0,1,0,0),x.fillStyle="rgba(255, 0, 0, 0.75)",x.strokeStyle="rgba(255, 0, 0, 0.75)",x.lineWidth=1,x.fillText("1 frame = "+N+" ms = "+I+" fps",0,20);x.strokeRect(0,30,250,20),x.fillRect(0,30,250*Math.min(I/60,1),20)}t||(a[L.SELECT_BOX]=!1)}if(s&&1!==l){var z=o.contexts[L.NODE],j=L.data.bufferCanvases[L.MOTIONBLUR_BUFFER_NODE],G=o.contexts[L.DRAG],W=L.data.bufferCanvases[L.MOTIONBLUR_BUFFER_DRAG],U=function(C,e,t){C.setTransform(1,0,0,1,0,0),t||!A?C.clearRect(0,0,L.canvasWidth,L.canvasHeight):S(C,0,0,L.canvasWidth,L.canvasHeight);var H=l;C.drawImage(e,0,0,L.canvasWidth*H,L.canvasHeight*H,0,0,L.canvasWidth,L.canvasHeight)};(a[L.NODE]||_[L.NODE])&&(U(z,j,_[L.NODE]),a[L.NODE]=!1),(a[L.DRAG]||_[L.DRAG])&&(U(G,W,_[L.DRAG]),a[L.DRAG]=!1)}L.prevViewport=v,L.clearingMotionBlur&&(L.clearingMotionBlur=!1,L.motionBlurCleared=!0,L.motionBlur=!0),s&&(L.motionBlurTimeout=setTimeout((function(){L.motionBlurTimeout=null,L.clearedForMotionBlur[L.NODE]=!1,L.clearedForMotionBlur[L.DRAG]=!1,L.motionBlur=!1,L.clearingMotionBlur=!M,L.mbFrames=0,a[L.NODE]=!0,a[L.DRAG]=!0,L.redraw()}),100)),e||r.emit("render")};for(var Hl={drawPolygonPath:function(C,e,t,H,V,i){var L=H/2,n=V/2;C.beginPath&&C.beginPath(),C.moveTo(e+L*i[0],t+n*i[1]);for(var r=1;r0&&i>0){s.clearRect(0,0,V,i),s.globalCompositeOperation="source-over";var l=this.getCachedZSortedEles();if(C.full)s.translate(-t.x1*r,-t.y1*r),s.scale(r,r),this.drawElements(s,l),s.scale(1/r,1/r),s.translate(t.x1*r,t.y1*r);else{var d=e.pan(),u={x:d.x*r,y:d.y*r};r*=e.zoom(),s.translate(u.x,u.y),s.scale(r,r),this.drawElements(s,l),s.scale(1/r,1/r),s.translate(-u.x,-u.y)}C.bg&&(s.globalCompositeOperation="destination-over",s.fillStyle=C.bg,s.rect(0,0,V,i),s.fill())}return M},al.png=function(C){return sl(C,this.bufferCanvasImage(C),"image/png")},al.jpg=function(C){return sl(C,this.bufferCanvasImage(C),"image/jpeg")};var ll={nodeShapeImpl:function(C,e,t,H,V,i,L){switch(C){case"ellipse":return this.drawEllipsePath(e,t,H,V,i);case"polygon":return this.drawPolygonPath(e,t,H,V,i,L);case"round-polygon":return this.drawRoundPolygonPath(e,t,H,V,i,L);case"roundrectangle":case"round-rectangle":return this.drawRoundRectanglePath(e,t,H,V,i);case"cutrectangle":case"cut-rectangle":return this.drawCutRectanglePath(e,t,H,V,i);case"bottomroundrectangle":case"bottom-round-rectangle":return this.drawBottomRoundRectanglePath(e,t,H,V,i);case"barrel":return this.drawBarrelPath(e,t,H,V,i)}}},dl=cl,ul=cl.prototype;function cl(C){var e=this;e.data={canvases:new Array(ul.CANVAS_LAYERS),contexts:new Array(ul.CANVAS_LAYERS),canvasNeedsRedraw:new Array(ul.CANVAS_LAYERS),bufferCanvases:new Array(ul.BUFFER_COUNT),bufferContexts:new Array(ul.CANVAS_LAYERS)};var t="-webkit-tap-highlight-color",H="rgba(0,0,0,0)";e.data.canvasContainer=document.createElement("div");var V=e.data.canvasContainer.style;e.data.canvasContainer.style[t]=H,V.position="relative",V.zIndex="0",V.overflow="hidden";var i=C.cy.container();i.appendChild(e.data.canvasContainer),i.style[t]=H;var L={"-webkit-user-select":"none","-moz-user-select":"-moz-none","user-select":"none","-webkit-tap-highlight-color":"rgba(0,0,0,0)","outline-style":"none"};yV&&yV.userAgent.match(/msie|trident|edge/i)&&(L["-ms-touch-action"]="none",L["touch-action"]="none");for(var n=0;n\n \n `}const td={ag_expand:El,ag_collapse:kl,ag_select_all:ql,ag_select_inverse:Ql,ag_select_neighbors:Kl,ag_lock:$l,ag_unlock:Yl,ag_hide:_l,ag_unhide:Bl,ag_fit:Fl,ag_image:Ul,ag_workspace:Jl,ag_local:Nl,ag_fdgd:zl,ag_concentric:Gl,ag_grid:Tl,ag_hierarchy:jl,ag_file:Dl,ag_filter:Rl,ag_save:Pl,ag_node_list:Il,ag_style:Xl,ag_help:Wl};function Hd(C){let e,t,H,V,i;return{c(){e=F("button"),t=N("svg"),H=N("path"),W(H,"d",C[0]),Y(t,"width","17px"),Y(t,"height","17px"),W(t,"viewBox","0 0 24 24"),W(t,"xmlns","http://www.w3.org/2000/svg"),W(e,"type","button"),W(e,"class","juggl-button"),W(e,"aria-label",C[3]),e.disabled=C[2]},m(L,n){_(L,e,n),B(e,t),B(t,H),V||(i=G(e,"click",(function(){k(C[1])&&C[1].apply(this,arguments)})),V=!0)},p(t,[V]){C=t,1&V&&W(H,"d",C[0]),8&V&&W(e,"aria-label",C[3]),4&V&&(e.disabled=C[2])},i:b,o:b,d(C){C&&D(e),V=!1,i()}}}function Vd(C,e,t){let{icon:H}=e,{onClick:V}=e,{disabled:i=!1}=e,{title:L}=e;return C.$$set=C=>{"icon"in C&&t(0,H=C.icon),"onClick"in C&&t(1,V=C.onClick),"disabled"in C&&t(2,i=C.disabled),"title"in C&&t(3,L=C.title)},[H,V,i,L]}class id extends hC{constructor(C){super(),AC(this,C,Vd,Hd,E,{icon:0,onClick:1,disabled:2,title:3})}}class Ld extends C.ItemView{constructor(){super(...arguments),this.frame=null}async onOpen(){this.frame=activeDocument.createElement("iframe"),this.frame.addClass("juggl-site"),this.frame.setAttr("style","height: 100%; width:100%"),this.frame.setAttr("src","https://juggl.io"),this.frame.setAttr("tabindex","0"),this.containerEl.children[1].appendChild(this.frame)}getDisplayText(){return"Juggl help"}getViewType(){return"juggl-help"}}function nd(C){let e,t;return e=new id({props:{icon:td.ag_help,title:"Help",onClick:C[0]}}),{c(){lC(e.$$.fragment)},m(C,H){dC(e,C,H),t=!0},p:b,i(C){t||(aC(e.$$.fragment,C),t=!0)},o(C){MC(e.$$.fragment,C),t=!1},d(C){uC(e,C)}}}function rd(C,e,t){let{workspace:H}=e;return C.$$set=C=>{"workspace"in C&&t(1,H=C.workspace)},[function(){let C=H.getLeaf(!0),e=new Ld(C);C.open(e)},H]}class od extends hC{constructor(C){super(),AC(this,C,rd,nd,E,{workspace:1})}}function ad(C){let e,t,H,V,i,L,n,r,o,a,M,s,l,d,u,c,A,h,m,f,p,g,v,y,Z,S,b,w,x,O,E,P,T,R,N,I,j,U,$,Y,X,q,Q,K;return t=new id({props:{icon:td.ag_fdgd,onClick:C[2],title:"Force directed layout"}}),V=new id({props:{icon:td.ag_concentric,onClick:C[3],title:"Circle layout"}}),L=new id({props:{icon:td.ag_grid,onClick:C[4],title:"Grid layout"}}),r=new id({props:{icon:td.ag_hierarchy,onClick:C[5],title:"Hierarchical layout"}}),M=new id({props:{icon:td.ag_fit,onClick:C[14],title:"Fit view"}}),l=new id({props:{icon:td.ag_local,onClick:C[15],title:"Local mode"}}),c=new od({props:{workspace:C[17]}}),h=new id({props:{icon:td.ag_save,onClick:C[16],title:"Manage workspace graphs"}}),p=new id({props:{icon:td.ag_expand,onClick:C[6],disabled:C[18],title:"Expand selected nodes (E)"}}),v=new id({props:{icon:td.ag_collapse,onClick:C[7],disabled:C[18],title:"Collapse expanded nodes (C)"}}),Z=new id({props:{icon:td.ag_hide,onClick:C[8],disabled:C[18],title:"Hide selected nodes (H)"}}),w=new id({props:{icon:td.ag_select_all,onClick:C[9],title:"Select all nodes (A)"}}),O=new id({props:{icon:td.ag_select_inverse,onClick:C[10],disabled:C[18],title:"Invert selection (I)"}}),P=new id({props:{icon:td.ag_select_neighbors,onClick:C[11],disabled:C[18],title:"Select neighbors (N)"}}),N=new id({props:{icon:td.ag_lock,onClick:C[12],disabled:C[19],title:"Lock selected nodes in place (P)"}}),j=new id({props:{icon:td.ag_unlock,onClick:C[13],disabled:C[20],title:"Unlock selected nodes in place (U)"}}),{c(){e=F("div"),lC(t.$$.fragment),H=z(),lC(V.$$.fragment),i=z(),lC(L.$$.fragment),n=z(),lC(r.$$.fragment),o=z(),a=F("div"),lC(M.$$.fragment),s=z(),lC(l.$$.fragment),d=z(),u=F("div"),lC(c.$$.fragment),A=z(),lC(h.$$.fragment),m=z(),f=F("div"),lC(p.$$.fragment),g=z(),lC(v.$$.fragment),y=z(),lC(Z.$$.fragment),S=z(),b=F("div"),lC(w.$$.fragment),x=z(),lC(O.$$.fragment),E=z(),lC(P.$$.fragment),T=z(),R=F("div"),lC(N.$$.fragment),I=z(),lC(j.$$.fragment),U=z(),$=F("br"),Y=F("label"),Y.textContent="Filter: ",X=F("input"),W(e,"class","cy-toolbar-section"),W(a,"class","cy-toolbar-section"),W(u,"class","cy-toolbar-section"),W(f,"class","cy-toolbar-section"),W(b,"class","cy-toolbar-section"),W(R,"class","cy-toolbar-section"),W(Y,"for","ag-filter"),W(X,"type","text"),W(X,"id","ag-filter"),W(X,"name","ag-filter"),X.value=C[1]},m(D,F){_(D,e,F),dC(t,e,null),B(e,H),dC(V,e,null),B(e,i),dC(L,e,null),B(e,n),dC(r,e,null),_(D,o,F),_(D,a,F),dC(M,a,null),B(a,s),dC(l,a,null),_(D,d,F),_(D,u,F),dC(c,u,null),B(u,A),dC(h,u,null),_(D,m,F),_(D,f,F),dC(p,f,null),B(f,g),dC(v,f,null),B(f,y),dC(Z,f,null),_(D,S,F),_(D,b,F),dC(w,b,null),B(b,x),dC(O,b,null),B(b,E),dC(P,b,null),_(D,T,F),_(D,R,F),dC(N,R,null),B(R,I),dC(j,R,null),_(D,U,F),_(D,$,F),_(D,Y,F),_(D,X,F),q=!0,Q||(K=G(X,"input",(function(){k(C[0])&&C[0].apply(this,arguments)})),Q=!0)},p(e,[H]){C=e;const i={};4&H&&(i.onClick=C[2]),t.$set(i);const n={};8&H&&(n.onClick=C[3]),V.$set(n);const o={};16&H&&(o.onClick=C[4]),L.$set(o);const a={};32&H&&(a.onClick=C[5]),r.$set(a);const s={};16384&H&&(s.onClick=C[14]),M.$set(s);const d={};32768&H&&(d.onClick=C[15]),l.$set(d);const u={};131072&H&&(u.workspace=C[17]),c.$set(u);const A={};65536&H&&(A.onClick=C[16]),h.$set(A);const m={};64&H&&(m.onClick=C[6]),262144&H&&(m.disabled=C[18]),p.$set(m);const f={};128&H&&(f.onClick=C[7]),262144&H&&(f.disabled=C[18]),v.$set(f);const g={};256&H&&(g.onClick=C[8]),262144&H&&(g.disabled=C[18]),Z.$set(g);const y={};512&H&&(y.onClick=C[9]),w.$set(y);const S={};1024&H&&(S.onClick=C[10]),262144&H&&(S.disabled=C[18]),O.$set(S);const b={};2048&H&&(b.onClick=C[11]),262144&H&&(b.disabled=C[18]),P.$set(b);const x={};4096&H&&(x.onClick=C[12]),524288&H&&(x.disabled=C[19]),N.$set(x);const k={};8192&H&&(k.onClick=C[13]),1048576&H&&(k.disabled=C[20]),j.$set(k),(!q||2&H&&X.value!==C[1])&&(X.value=C[1])},i(C){q||(aC(t.$$.fragment,C),aC(V.$$.fragment,C),aC(L.$$.fragment,C),aC(r.$$.fragment,C),aC(M.$$.fragment,C),aC(l.$$.fragment,C),aC(c.$$.fragment,C),aC(h.$$.fragment,C),aC(p.$$.fragment,C),aC(v.$$.fragment,C),aC(Z.$$.fragment,C),aC(w.$$.fragment,C),aC(O.$$.fragment,C),aC(P.$$.fragment,C),aC(N.$$.fragment,C),aC(j.$$.fragment,C),q=!0)},o(C){MC(t.$$.fragment,C),MC(V.$$.fragment,C),MC(L.$$.fragment,C),MC(r.$$.fragment,C),MC(M.$$.fragment,C),MC(l.$$.fragment,C),MC(c.$$.fragment,C),MC(h.$$.fragment,C),MC(p.$$.fragment,C),MC(v.$$.fragment,C),MC(Z.$$.fragment,C),MC(w.$$.fragment,C),MC(O.$$.fragment,C),MC(P.$$.fragment,C),MC(N.$$.fragment,C),MC(j.$$.fragment,C),q=!1},d(C){C&&(D(e),D(o),D(a),D(d),D(u),D(m),D(f),D(S),D(b),D(T),D(R),D(U),D($),D(Y),D(X)),uC(t),uC(V),uC(L),uC(r),uC(M),uC(l),uC(c),uC(h),uC(p),uC(v),uC(Z),uC(w),uC(O),uC(P),uC(N),uC(j),Q=!1,K()}}}function Md(e,t,H){let{viz:V}=t,{filterValue:i}=t,{fdgdClick:L}=t,{concentricClick:n}=t,{gridClick:r}=t,{hierarchyClick:o}=t,{expandClick:a}=t,{collapseClick:M}=t,{hideClick:s}=t,{selectAllClick:l}=t,{selectInvertClick:d}=t,{selectNeighborClick:u}=t,{lockClick:c}=t,{unlockClick:A}=t,{fitClick:h}=t,{localModeClick:m}=t,{filterInput:f}=t,{saveClick:p}=t,{workspace:g}=t;f=C.debounce(f,500,!0);let v=!1,y=!1,Z=!0;return e.$$set=C=>{"viz"in C&&H(21,V=C.viz),"filterValue"in C&&H(1,i=C.filterValue),"fdgdClick"in C&&H(2,L=C.fdgdClick),"concentricClick"in C&&H(3,n=C.concentricClick),"gridClick"in C&&H(4,r=C.gridClick),"hierarchyClick"in C&&H(5,o=C.hierarchyClick),"expandClick"in C&&H(6,a=C.expandClick),"collapseClick"in C&&H(7,M=C.collapseClick),"hideClick"in C&&H(8,s=C.hideClick),"selectAllClick"in C&&H(9,l=C.selectAllClick),"selectInvertClick"in C&&H(10,d=C.selectInvertClick),"selectNeighborClick"in C&&H(11,u=C.selectNeighborClick),"lockClick"in C&&H(12,c=C.lockClick),"unlockClick"in C&&H(13,A=C.unlockClick),"fitClick"in C&&H(14,h=C.fitClick),"localModeClick"in C&&H(15,m=C.localModeClick),"filterInput"in C&&H(0,f=C.filterInput),"saveClick"in C&&H(16,p=C.saveClick),"workspace"in C&&H(17,g=C.workspace)},[f,i,L,n,r,o,a,M,s,l,d,u,c,A,h,m,p,g,v,y,Z,V,function(){let C=V.nodes(":selected");H(18,v=0===C.length);let e=V.nodes(".pinned"),t=C.difference(e).length>0,i=C.intersection(e);H(19,y=!t||v),H(20,Z=!i||v)}]}class sd extends hC{constructor(C){super(),AC(this,C,Md,ad,E,{viz:21,filterValue:1,fdgdClick:2,concentricClick:3,gridClick:4,hierarchyClick:5,expandClick:6,collapseClick:7,hideClick:8,selectAllClick:9,selectInvertClick:10,selectNeighborClick:11,lockClick:12,unlockClick:13,fitClick:14,localModeClick:15,filterInput:0,saveClick:16,workspace:17,onSelect:22})}get onSelect(){return this.$$.ctx[22]}}class ld{constructor(C,e){this.options=Object.assign({},ld.DEFAULT,C,{animate:!!e&&"end"})}startLayout(C){return C.layout(this.options).start()}}ld.DEFAULT={name:"cola",animate:!0,refresh:2,maxSimulationTime:1500,ungrabifyWhileSimulating:!1,fit:!1,padding:30,nodeDimensionsIncludeLabels:!0,randomize:!1,avoidOverlap:!0,handleDisconnected:!0,convergenceThreshold:.01,nodeSpacing:10};class dd{constructor(C,e){this.options=Object.assign({},dd.DEFAULT,C,{animate:!!e&&"end"})}startLayout(C){return C.layout(Object.assign(this.options,{linkId:function(C){return C.id}})).start()}}dd.DEFAULT={name:"d3-force",animate:"end",maxIterations:0,maxSimulationTime:1500,ungrabifyWhileSimulating:!1,fixedAfterDragging:!1,fit:!1,padding:30,alpha:1,alphaMin:.001,alphaDecay:1-Math.pow(.001,1/300),alphaTarget:0,velocityDecay:.4,collideRadius:60,collideStrength:.9,collideIterations:1,linkDistance:150,linkStrength:.7,linkIterations:1,manyBodyStrength:-600,manyBodyDistanceMin:5,xStrength:.1,xX:0,yStrength:.1,yY:0,radialStrength:.1,radialX:0,radialY:0,radialRadius:10,randomize:!1,infinite:!1};class ud{constructor(C){this.options=Object.assign({},ud.DEFAULT,C)}startLayout(C){return C.layout(this.options).start()}}ud.DEFAULT={name:"grid",animate:!0,animationDuration:500,spacingFactor:.5,fit:!1,padding:30,nodeDimensionsIncludeLabels:!0,avoidOverlap:!0};class cd{constructor(C){this.options=Object.assign({},cd.DEFAULT,C)}startLayout(C){return C.layout(this.options).start()}}cd.DEFAULT={name:"dagre",animate:!0,animationDuration:500,spacingFactor:.5,fit:!1,padding:30,nodeDimensionsIncludeLabels:!0,avoidOverlap:!0};class Ad{constructor(C){this.options=Object.assign({},Ad.DEFAULT,C)}startLayout(C){return C.layout(Object.assign(this.options,{concentric:C=>C.hasClass(V)?1e3:C.hasClass(H)?100:1})).start()}}Ad.DEFAULT={name:"concentric",animate:"end",animationDuration:500,fit:!1,padding:30,nodeDimensionsIncludeLabels:!0,avoidOverlap:!0};const hd=function(C,e,t){switch(C){case"circle":case"concentric":return new Ad(t);case"force-directed":return e&&"d3-force"===e.fdgdLayout?new dd(t,e.animateLayout):new ld(t,e.animateLayout);case"hierarchy":case"dagre":return new cd(t);case"grid":return new ud(t);case"cola":return new ld(t,e.animateLayout);case"d3-force":return new dd(t,e.animateLayout)}};function md(C){let e,t,H,V,i,L,n,r,o;return{c(){e=F("div"),t=F("div"),H=I(C[0]),V=z(),i=F("button"),i.textContent="Load",L=z(),n=F("div"),n.innerHTML='',W(t,"class","list-item-part mod-extended"),W(i,"class","list-item-part"),W(n,"class","list-item-part clickable-icon"),W(n,"aria-label","Delete graph"),W(e,"class","list-item")},m(a,M){_(a,e,M),B(e,t),B(t,H),B(e,V),B(e,i),B(e,L),B(e,n),r||(o=[G(i,"click",(function(){k(C[1](C[0]))&&C[1](C[0]).apply(this,arguments)})),G(n,"click",(function(){k(C[2](C[0]))&&C[2](C[0]).apply(this,arguments)}))],r=!0)},p(e,[t]){C=e,1&t&&U(H,C[0])},i:b,o:b,d(C){C&&D(e),r=!1,O(o)}}}function fd(C,e,t){let{name:H}=e,{onClick:V}=e,{onDelete:i}=e;return C.$$set=C=>{"name"in C&&t(0,H=C.name),"onClick"in C&&t(1,V=C.onClick),"onDelete"in C&&t(2,i=C.onDelete)},[H,V,i]}class pd extends hC{constructor(C){super(),AC(this,C,fd,md,E,{name:0,onClick:1,onDelete:2})}}function gd(C,e,t){const H=C.slice();return H[9]=e[t],H}function vd(C){let e,t;return e=new pd({props:{name:C[9],onClick:C[1],onDelete:C[4]}}),{c(){lC(e.$$.fragment)},m(C,H){dC(e,C,H),t=!0},p(C,t){const H={};1&t&&(H.name=C[9]),2&t&&(H.onClick=C[1]),e.$set(H)},i(C){t||(aC(e.$$.fragment,C),t=!0)},o(C){MC(e.$$.fragment,C),t=!1},d(C){uC(e,C)}}}function yd(C){let e,t,H,V,i,L,n,r,o,a,M,s=sC(C[0]),l=[];for(let e=0;eMC(l[C],1,1,(()=>{l[C]=null}));return{c(){e=F("div"),t=F("input"),H=z(),V=F("button"),V.textContent="Save",i=z(),L=F("hr"),n=z(),r=F("div");for(let C=0;C{"onLoad"in C&&t(1,H=C.onLoad),"onSave"in C&&t(6,V=C.onSave),"onDelete"in C&&t(7,i=C.onDelete),"savedGraphs"in C&&t(0,L=C.savedGraphs)},[L,H,n,async C=>{await V(C),t(0,L)},async C=>{await i(C),t(0,L)},C=>"/"!==C.key||(C.preventDefault(),!1),V,i,function(){n=this.value,t(2,n)}]}class Sd extends hC{constructor(C){super(),AC(this,C,Zd,yd,E,{onLoad:1,onSave:6,onDelete:7,savedGraphs:0})}}class bd extends C.Modal{constructor(C,e,t){super(C),this.manager=e,this.view=t}onOpen(){super.onOpen(),this.titleEl.innerHTML="Manage workspace graphs",new Sd({target:this.contentEl,props:{onSave:C=>this.manager.saveGraph(C,this.view),savedGraphs:this.manager.graphs,onLoad:C=>this.manager.loadGraph(C,this.view),onDelete:C=>this.manager.deleteGraph(C,this.view)}})}}class wd extends C.Component{constructor(C){super(),this.events=[],this.recursionPreventer=!1,this.view=C}onload(){this.view.vizReady?this._onLoad():this.registerEvent(this.view.on("vizReady",(C=>{this._onLoad()})))}_onLoad(){this.viz=this.view.viz;const C=this,e=this.view,i=getComputedStyle(activeDocument.body),L=i.getPropertyValue("--text-selection"),n=i.getPropertyValue("--background-secondary"),r=i.getPropertyValue("--text-normal");i.getPropertyValue("--text");const a=this.view.plugin,M={menuRadius:70,selector:"node",commands:V=>{const i=[];return"core"===c.fromNode(V).storeId&&i.push({content:ed(td.ag_file),select:async function(C,e,t){await a.openFileFromNode(C,t.originalEvent.metaKey)},enabled:!0}),i.push({content:ed(td.ag_hide),select:function(e){C.removeNodes(e)},enabled:!0},{content:ed(td.ag_fit),select:function(e){C.updateActiveNode(e,!0)},enabled:!0}),V.hasClass(t)?i.push({content:ed(td.ag_unlock),select:function(e){C.unpin(e)},enabled:!0}):i.push({content:ed(td.ag_lock),select:function(e){C.pin(e)},enabled:!0}),V.hasClass(H)?i.push({content:ed(td.ag_collapse),select:function(e){C.removeNodes(e)},enabled:!0}):i.push({content:ed(td.ag_expand),select:function(C){e.expand(C)},enabled:!0}),i},fillColor:`${n}`,activeFillColor:`${L}`,activePadding:20,indicatorSize:24,separatorWidth:3,spotlightPadding:0,adaptativeNodeSpotlightRadius:!0,openMenuEvents:"taphold",itemColor:`${r}`,itemTextShadowColor:"transparent",zIndex:9999,atMouse:!1,outsideMenuCancel:15};this.menu=this.viz.cxtmenu(M),this.registerCyEvent("tap","node",(async C=>{if(!this.view.settings.openWithShift||C.originalEvent.shiftKey){await this.view.plugin.openFileFromNode(C.target,C.originalEvent.metaKey)&&this.updateActiveNode(C.target,this.view.settings.autoZoom)}})),this.registerCyEvent("taphold","node",(C=>{this.view.destroyHover&&this.view.destroyHover()})),this.registerCyEvent("dblclick","node",(async C=>{await this.view.expand(C.target)})),this.registerCyEvent("tapselect tapunselect boxselect",null,(C=>{this.view.trigger("selectChange")})),this.registerEvent(this.view.workspace.on("file-open",(async C=>{if(this.view.settings.autoAddNodes&&C&&this.view.settings.autoAddNodes){const e=C.name,t=new c(e,"core");let H=!0;if(0===this.viz.$id(t.toId()).length){const C=await this.view.datastores.coreStore.get(t,this.view);this.viz.startBatch(),this.viz.add(C).addClass(o);const e=await this.view.buildEdges(this.viz.$id(t.toId()));this.viz.add(e),this.view.onGraphChanged(!1,!0),this.viz.endBatch(),H=!1}const V=this.viz.$id(t.toId());V.addClass(o),this.updateActiveNode(V,H&&this.view.settings.autoZoom)}}))),this.registerEvent(this.view.on("expand",(C=>{this.updateActiveNode(C,!1)}))),this.registerEvent(this.view.on("elementsChange",(()=>{this.recursionPreventer||(this.viz.nodes().difference(this.viz.nodes(`.${o}`)).filter((C=>0===C.closedNeighborhood(`node.${o}`).length)).remove(),this.updateActiveNode(this.viz.nodes(`.${V}`),!1),this.recursionPreventer=!0,this.view.onGraphChanged(),this.recursionPreventer=!1)}))),this.windowEvent=async C=>{activeDocument.activeElement===this.view.element&&("e"===C.key?await this.expandSelection():"h"===C.key||"Backspace"===C.key?this.removeSelection():"i"===C.key?this.invertSelection():"a"===C.key?this.selectAll():"n"===C.key?this.selectNeighboursOfSelected():"p"===C.key?this.pinSelection():"u"===C.key?this.unpinSelection():"c"===C.key?this.collapseSelection():"v"===C.key?this.view.fitView():"f"===C.key&&this.view.fitView(this.viz.nodes(":selected")))},activeDocument.on("keydown",".cy-content",this.windowEvent,!0)}registerCyEvent(C,e,t){this.events.push({eventName:C,selector:e,event:t}),e?this.viz.on(C,e,t):this.viz.on(C,t)}onunload(){for(const C of this.events)C.selector?this.viz.off(C.eventName,C.selector,C.event):this.viz.off(C.eventName,C.event);this.events=[],activeDocument.off("keydown",".cy-content",this.windowEvent,!0),this.toolbar&&this.toolbar.$destroy(),this.menu&&this.menu.destroy()}getName(){return"workspace"}fillMenu(C,e){if(e.length>0&&(C.addItem((C=>{C.setTitle("Expand selection (E)").setIcon("ag-expand").onClick((async C=>{await this.view.expand(e)}))})),C.addItem((C=>{C.setTitle("Collapse selection (C)").setIcon("ag-collapse").onClick((C=>{this.collapse(e)}))})),C.addItem((C=>{C.setTitle("Hide selection (H)").setIcon("ag-hide").onClick((C=>{this.removeNodes(e)}))})),C.addItem((C=>{C.setTitle("Select all (A)").setIcon("ag-select-all").onClick((C=>{this.selectAll()}))})),C.addItem((C=>{C.setTitle("Invert selection (I)").setIcon("ag-select-inverse").onClick((C=>{this.invertSelection()}))}))),e.length>0){C.addItem((C=>{C.setTitle("Select neighbors (N)").setIcon("ag-select-neighbors").onClick((C=>{this.selectNeighbourhood(e)}))}));const t=this.view.getPinned();e.difference(t).length>0&&C.addItem((C=>{C.setTitle("Pin selection (P)").setIcon("ag-lock").onClick((C=>{this.pin(e)}))})),e.intersect(t).length>0&&C.addItem((C=>{C.setTitle("Unpin selection (U)").setIcon("ag-unlock").onClick((C=>{this.unpin(e)}))}))}}createToolbar(C){this.toolbar=new sd({target:C,props:{viz:this.viz,filterValue:this.view.settings.filter,expandClick:this.expandSelection.bind(this),fdgdClick:()=>this.view.setLayout(hd("force-directed",this.view.settings)),concentricClick:()=>this.view.setLayout(hd("circle")),gridClick:()=>this.view.setLayout(hd("grid")),hierarchyClick:()=>this.view.setLayout(hd("hierarchy")),collapseClick:this.collapseSelection.bind(this),hideClick:this.removeSelection.bind(this),selectAllClick:this.selectAll.bind(this),selectInvertClick:this.invertSelection.bind(this),selectNeighborClick:this.selectNeighboursOfSelected.bind(this),lockClick:this.pinSelection.bind(this),unlockClick:this.unpinSelection.bind(this),fitClick:this.view.fitView.bind(this.view),localModeClick:()=>this.view.setMode("local"),filterInput:C=>{this.view.searchFilter(C.target.value),this.view.restartLayout()},saveClick:()=>{"app"in this.view.plugin&&"workspaceManager"in this.view.plugin&&new bd(this.view.plugin.app,this.view.plugin.workspaceManager,this.view).open()},workspace:this.view.plugin.app.workspace}}),this.view.on("selectChange",this.toolbar.onSelect.bind(this.toolbar)),this.view.on("vizReady",(C=>{this.toolbar.$set({viz:C}),this.toolbar.onSelect.bind(this.toolbar)()}))}updateActiveNode(C,e){this.viz.elements().removeClass([L,V,i]).difference(C.closedNeighborhood()).addClass(i),C.addClass(V);const t=C.connectedEdges().addClass(L).connectedNodes().addClass(L).union(C);e&&this.viz.animate({fit:{eles:t,padding:0},duration:250,queue:!1}),this.viz.one("tap",(C=>{C.cy.elements().removeClass([L,V,i])}))}async expandSelection(){await this.view.expand(this.viz.nodes(":selected"))}collapse(C){C.filter(":selected").removeClass([o,H]).openNeighborhood().nodes().filter((C=>0===C.closedNeighborhood(`node.${o}`).length)).remove(),this.recursionPreventer=!0,this.view.onGraphChanged(!0,!0),this.recursionPreventer=!1}collapseSelection(){this.collapse(this.viz.nodes(":selected"))}removeNodes(C){C.addClass(s),this.view.onGraphChanged(!0,!0),this.view.trigger("hide",C),this.view.trigger("selectChange")}removeSelection(){this.removeNodes(this.viz.nodes(":selected"))}selectAll(){this.viz.nodes().select(),this.view.trigger("selectChange")}invertSelection(){this.viz.$(":selected").unselect().absoluteComplement().select(),this.view.trigger("selectChange")}selectNeighboursOfSelected(){this.selectNeighbourhood(this.viz.nodes(":selected"))}selectNeighbourhood(C){this.viz.nodes(":selected").unselect(),C.openNeighborhood().select(),this.view.trigger("selectChange")}unpin(C){const e=C.unlock().removeClass(t);this.view.restartLayout(),this.view.trigger("unpin",e)}unpinSelection(){this.unpin(this.viz.nodes(":selected"))}pin(C){const e=C.lock().addClass(t);this.view.restartLayout(),this.view.trigger("pin",e)}pinSelection(){this.pin(this.viz.nodes(":selected"))}}function xd(C){let e,t,H,V,i,L,n,r,o,a,M,s,l,d,u,c,A,h,m;return t=new id({props:{icon:td.ag_fdgd,onClick:C[1],title:"Force directed layout"}}),V=new id({props:{icon:td.ag_concentric,onClick:C[2],title:"Circle layout"}}),L=new id({props:{icon:td.ag_grid,onClick:C[3],title:"Grid layout"}}),r=new id({props:{icon:td.ag_hierarchy,onClick:C[4],title:"Hierarchical layout"}}),M=new id({props:{icon:td.ag_fit,onClick:C[5],title:"Fit view"}}),l=new id({props:{icon:td.ag_workspace,onClick:C[6],title:"Workspace mode"}}),{c(){e=F("div"),lC(t.$$.fragment),H=z(),lC(V.$$.fragment),i=z(),lC(L.$$.fragment),n=z(),lC(r.$$.fragment),o=z(),a=F("div"),lC(M.$$.fragment),s=z(),lC(l.$$.fragment),d=z(),u=F("br"),c=F("input"),W(e,"class","cy-toolbar-section"),W(a,"class","cy-toolbar-section"),W(c,"type","text"),W(c,"id","ag-filter"),W(c,"name","ag-filter"),c.value=C[7]},m(f,p){_(f,e,p),dC(t,e,null),B(e,H),dC(V,e,null),B(e,i),dC(L,e,null),B(e,n),dC(r,e,null),_(f,o,p),_(f,a,p),dC(M,a,null),B(a,s),dC(l,a,null),_(f,d,p),_(f,u,p),_(f,c,p),A=!0,h||(m=G(c,"input",(function(){k(C[0])&&C[0].apply(this,arguments)})),h=!0)},p(e,[H]){C=e;const i={};2&H&&(i.onClick=C[1]),t.$set(i);const n={};4&H&&(n.onClick=C[2]),V.$set(n);const o={};8&H&&(o.onClick=C[3]),L.$set(o);const a={};16&H&&(a.onClick=C[4]),r.$set(a);const s={};32&H&&(s.onClick=C[5]),M.$set(s);const d={};64&H&&(d.onClick=C[6]),l.$set(d),(!A||128&H&&c.value!==C[7])&&(c.value=C[7])},i(C){A||(aC(t.$$.fragment,C),aC(V.$$.fragment,C),aC(L.$$.fragment,C),aC(r.$$.fragment,C),aC(M.$$.fragment,C),aC(l.$$.fragment,C),A=!0)},o(C){MC(t.$$.fragment,C),MC(V.$$.fragment,C),MC(L.$$.fragment,C),MC(r.$$.fragment,C),MC(M.$$.fragment,C),MC(l.$$.fragment,C),A=!1},d(C){C&&(D(e),D(o),D(a),D(d),D(u),D(c)),uC(t),uC(V),uC(L),uC(r),uC(M),uC(l),h=!1,m()}}}function Od(e,t,H){let{fdgdClick:V}=t,{concentricClick:i}=t,{gridClick:L}=t,{hierarchyClick:n}=t,{fitClick:r}=t,{workspaceModeClick:o}=t,{filterInput:a}=t,{filterValue:M}=t,{workspace:s}=t,{onDepthChange:l}=t;return a=C.debounce(a,500,!0),e.$$set=C=>{"fdgdClick"in C&&H(1,V=C.fdgdClick),"concentricClick"in C&&H(2,i=C.concentricClick),"gridClick"in C&&H(3,L=C.gridClick),"hierarchyClick"in C&&H(4,n=C.hierarchyClick),"fitClick"in C&&H(5,r=C.fitClick),"workspaceModeClick"in C&&H(6,o=C.workspaceModeClick),"filterInput"in C&&H(0,a=C.filterInput),"filterValue"in C&&H(7,M=C.filterValue),"workspace"in C&&H(8,s=C.workspace),"onDepthChange"in C&&H(9,l=C.onDepthChange)},[a,V,i,L,n,r,o,M,s,l]}class kd extends hC{constructor(C){super(),AC(this,C,Od,xd,E,{fdgdClick:1,concentricClick:2,gridClick:3,hierarchyClick:4,fitClick:5,workspaceModeClick:6,filterInput:0,filterValue:7,workspace:8,onDepthChange:9})}}class Ed extends C.Component{constructor(C){super(),this.events=[],this.depth=1,this.maxDepthForCurrentFile=1,this.view=C}onload(){this.view.vizReady?this._onLoad():this.registerEvent(this.view.on("vizReady",(C=>{this._onLoad()})))}_onLoad(){this.viz=this.view.viz,this.registerCyEvent("tap","node",(async C=>{const e=await this.view.plugin.openFileFromNode(C.target,C.originalEvent.metaKey);e&&await this.onOpenFile(e)})),this.registerEvent(this.view.workspace.on("file-open",(async C=>{C&&await this.onOpenFile(C)})))}async onOpenFile(C){if(!this.view.settings.autoAddNodes)return;const e=new c(C.name,"core");let t;if(this.viz.startBatch(),0===this.viz.$id(e.toId()).length){const C=await this.view.datastores.coreStore.get(e,this.view);t=this.viz.add(C)}else t=this.viz.$id(e.toId());await this.view.expand(t,!1),t.addClass(V),this.viz.nodes().difference(t.closedNeighborhood()).remove(),this.view.onGraphChanged(!1),this.updateActiveFile(t),this.viz.endBatch()}changeDepth(C){console.log(`changing depth to ${C}`)}registerCyEvent(C,e,t){this.events.push({eventName:C,selector:e,event:t}),e?this.viz.on(C,e,t):this.viz.on(C,t)}onunload(){for(const C of this.events)C.selector?this.viz.off(C.eventName,C.selector,C.event):this.viz.off(C.eventName,C.event);this.events=[],this.toolbar.$destroy()}getName(){return"local"}fillMenu(C,e){}createToolbar(C){const e=this.view;this.toolbar=new kd({target:C,props:{viz:this.viz,fitClick:this.view.fitView.bind(e),fdgdClick:()=>this.view.setLayout(hd("force-directed",this.view.settings)),concentricClick:()=>this.view.setLayout(hd("circle")),gridClick:()=>this.view.setLayout(hd("grid")),hierarchyClick:()=>this.view.setLayout(hd("hierarchy")),workspaceModeClick:()=>e.setMode("workspace"),filterInput:C=>{this.view.searchFilter(C.target.value),this.view.restartLayout()},onDepthChange:this.changeDepth,filterValue:this.view.settings.filter,workspace:this.view.plugin.app.workspace}})}updateActiveFile(C){this.viz.elements().removeClass([L,V,i]).difference(C.closedNeighborhood()).addClass(i),C.addClass(V),C.connectedEdges().addClass(L).connectedNodes().addClass(L).union(C)}}var Pd,Td={}; /*! * search-query-parser.js * Copyright(c) 2014-2019 * MIT Licensed */(Pd=Td).parse=function(C,e){if(e?e.offsets=void 0===e.offsets||e.offsets:e={offsets:!0},C||(C=""),-1!==C.indexOf(":")||e.tokenize){if(e.keywords||e.ranges||e.tokenize){var t={text:[]};e.offsets&&(t.offsets=[]);for(var H,V={},i=[],L=/(\S+:'(?:[^'\\]|\\.)*')|(\S+:"(?:[^"\\]|\\.)*")|(-?"(?:[^"\\]|\\.)*")|(-?'(?:[^'\\]|\\.)*')|\S+|\S+:\S+/g;null!==(H=L.exec(C));){var n,r=(n=H[0]).indexOf(":");if(-1!==r){n.split(":");var o=n.slice(0,r),a=n.slice(r+1);a=((a=a.replace(/^\"|\"$|^\'|\'$/g,""))+"").replace(/\\(.?)/g,(function(C,e){switch(e){case"\\":return"\\";case"0":return"\0";case"":return"";default:return e}})),i.push({keyword:o,value:a,offsetStart:H.index,offsetEnd:H.index+n.length})}else{var M=!1;"-"===n[0]&&(M=!0,n=n.slice(1)),n=((n=n.replace(/^\"|\"$|^\'|\'$/g,""))+"").replace(/\\(.?)/g,(function(C,e){switch(e){case"\\":return"\\";case"0":return"\0";case"":return"";default:return e}})),M?V.text?(V.text instanceof Array||(V.text=[V.text]),V.text.push(n)):V.text=n:i.push({text:n,offsetStart:H.index,offsetEnd:H.index+n.length})}}for(i.reverse();n=i.pop();)if(n.text)t.text.push(n.text),e.offsets&&t.offsets.push(n);else{o=n.keyword,e.keywords=e.keywords||[];var s=!1,l=!1;if(/^-/.test(o)){if("-"===o[0]){var d=o.slice(1);(s=!(-1===e.keywords.indexOf(d)))&&(o=d,l=!0)}}else s=!(-1===e.keywords.indexOf(o));e.ranges=e.ranges||[];var u=!(-1===e.ranges.indexOf(o));if(s){if(e.offsets&&t.offsets.push({keyword:o,value:n.value,offsetStart:l?n.offsetStart+1:n.offsetStart,offsetEnd:n.offsetEnd}),(A=n.value).length){var c=A.split(",");l?V[o]?V[o]instanceof Array?c.length>1?V[o]=V[o].concat(c):V[o].push(A):(V[o]=[V[o]],V[o].push(A)):c.length>1?V[o]=c:e.alwaysArray?V[o]=[A]:V[o]=A:t[o]?t[o]instanceof Array?c.length>1?t[o]=t[o].concat(c):t[o].push(A):(t[o]=[t[o]],t[o].push(A)):c.length>1?t[o]=c:e.alwaysArray?t[o]=[A]:t[o]=A}}else if(u){e.offsets&&t.offsets.push(n);var A,h=(A=n.value).split("-");t[o]={},2===h.length?(t[o].from=h[0],t[o].to=h[1]):!h.length%2||(t[o].from=A)}else{var m=n.keyword+":"+n.value;t.text.push(m),e.offsets&&t.offsets.push({text:m,offsetStart:n.offsetStart,offsetEnd:n.offsetEnd})}}return t.text.length?e.tokenize||(t.text=t.text.join(" ").trim()):delete t.text,t.exclude=V,t}return C}return C},Pd.stringify=function(C,e,t){if(e||(e={offsets:!0}),!C)return"";if("string"==typeof C)return C;if(Array.isArray(C))return C.join(" ");if(!Object.keys(C).length)return"";if(3===Object.keys(C).length&&C.text&&C.offsets&&C.exclude&&"string"==typeof C.text)return C.text;t||(t="");var H=function(C){return C.indexOf(" ")>-1?JSON.stringify(C):C},V=function(C){return t+C},i=[];if(C.text){var L=[];"string"==typeof C.text?L.push(C.text):L.push.apply(L,C.text),L.length>0&&i.push(L.map(H).map(V).join(" "))}return e.keywords&&e.keywords.forEach((function(e){if(C[e]){var t=[];"string"==typeof C[e]?t.push(C[e]):t.push.apply(t,C[e]),t.length>0&&i.push(V(e+":"+t.map(H).join(",")))}})),e.ranges&&e.ranges.forEach((function(e){if(C[e]){var t=C[e].from,H=C[e].to;H&&(t=t+"-"+H),t&&i.push(V(e+":"+t))}})),C.exclude&&Object.keys(C.exclude).length>0&&i.push(Pd.stringify(C.exclude,e,"-")),i.join(" ")};var Bd=BC(Td);const _d=function(C,e,t="*="){return"string"==typeof e||e instanceof String?[`[${C} ${t} '${e}']`]:e.map((e=>`[${C} ${t} '${e}']`))},Dd=function(C,e){switch(e){case"exclude":return[];case"content":case"ignore-case":case"text":return _d("content",C[e],"@*=");case"match-case":return _d("content",C[e],"*=");case"file":return _d("name",C[e]);case"name":return _d("name",C[e],"@*=");case"tag":return"string"==typeof(H=C[e])||H instanceof String?H.length>0&&"#"===H[0]?(H.slice(1),[`.tag-${H.slice(1).replaceAll("/","-")}`]):[]:H.map((C=>C.length>0&&"#"===C[0]?`.tag-${C.slice(1).replaceAll("/","-")}`:""));case"class":return"string"==typeof(t=C[e])||t instanceof String?[`.${t}`]:t.map((C=>`.${C}`));case"raw":return[C[e]];default:return _d(e,C[e])}var t,H},Rd=function(C,e,t){if(t===C)return function(C,e){const t=new Set;e.forEach((C=>{Object.keys(C.data()).forEach((C=>t.add(C)))}));const H=["file","tag","raw","match-case","ignore-case","class"];H.push(...t);const V={keywords:H,tokenize:!0,offsets:!1},i=Bd.parse(C,V);let L="node";for(const C of Object.keys(i))L+=Dd(i,C).join();let n=e.filter(L);if(i.exclude)for(const C of Object.keys(i.exclude))for(const e of Dd(i.exclude,C)){const C="node"+e;n=n.not(C)}return n}(C,e);const H=[];let V=0,i=0;for(let e=0;eC.union(function(C,e){const t=[],H=[];let V=0,i=-1,L=-1;for(let e=0;e0&&"-"===C[e-1]?e-1:e);V.trim().length>0&&(H.push(!1),t.push(V))}V+=1}else if(")"===C[e])V-=1,0===V&&(L=e,H.push(i>0&&"-"===C[i-1]),t.push(C.slice(i+1,L)));else if(e===C.length-1){const e=C.slice(L+1);e.trim().length>0&&(H.push(!1),t.push(e))}let n=e;for(let e=0;eC.onJugglCreated(this))),this.debouncedRestartLayout=C.debounce(this.restartLayout,2300,!0)}async onload(){try{if(this.element.addClass("cy-content"),this.element.setAttr("tabindex",0),this.settings.toolbar){const C=activeDocument.createElement("div");C.addClass("cy-toolbar"),this.element.appendChild(C),this.mode.createToolbar(C)}const e=activeDocument.createElement("div");let i;e.id="cy"+Nd,this.element.appendChild(e),e.setAttr("style",`height: ${this.settings.height}; width:${this.settings.width}`),e.setAttr("tabindex","0");let L=null;if(this.initialNodes?(L=this.initialNodes.map((C=>new c(C,this.datastores.coreStore.storeId()))),i=this.settings.expandInitial?await this.neighbourhood(L):await Promise.all(L.map((C=>this.datastores.coreStore.get(C,this)))),i=i.filter((C=>C)),this.viz=Ol({container:e,elements:i,minZoom:.3,maxZoom:10,wheelSensitivity:this.settings.zoomSpeed})):this.viz=Ol({container:e,elements:[{data:{id:"a"}},{data:{id:"b"}}],minZoom:.3,maxZoom:10,wheelSensitivity:this.settings.zoomSpeed}),this.viz.dblclick(),this.settings.navigator){const C=activeDocument.createElement("div");C.id="cynav"+Nd,e.children[0].appendChild(C),C.addClass("cy-navigator"),this.viz.navigator({container:"#cynav"+Nd,viewLiveFramerate:0,thumbnailEventFramerate:10,thumbnailLiveFramerate:!1,dblClickDelay:200,removeCustomContainer:!0,rerenderDelay:100})}if(Nd+=1,L){for(const C of L){const e=this.viz.$id(C.toId());this.settings.expandInitial&&e.addClass(H),e.addClass(o)}const C=this.viz.nodes(),e=await this.buildEdges(C);this.viz.add(e),this.onGraphChanged(!0)}await this.updateStylesheet(),L&&this.restartLayout();this.viz.on("tap boxselect",(async C=>{this.element.focus()})),this.viz.on("tap","node",(async C=>{c.fromNode(C.target).storeId})),this.viz.on("tap","edge",(async C=>{})),this.viz.on("mouseover","node",(async C=>{C.target.unlock();const e=C.target;C.cy.elements().difference(e.closedNeighborhood()).addClass(r),e.addClass(n).connectedEdges().addClass(a).connectedNodes().addClass(a);const t=c.fromNode(C.target);if("core"===t.storeId){const e=this.plugin.metadata.getFirstLinkpathDest(t.id,"");e&&this.plugin.app.workspace.trigger("hover-link",{event:C.originalEvent,source:"juggl-plugin",hoverParent:this,targetEl:this.element,linktext:t.id,sourcePath:e.path})}})),this.viz.on("mouseover","edge",(async C=>{const e=C.target;this.settings.hoverEdges&&(C.cy.elements().difference(e.connectedNodes().union(e)).addClass(r),e.addClass("hover").connectedNodes().addClass(a)),!("context"in e.data())||!C.originalEvent.metaKey&&this.settings.metaKeyHover||(this.hoverTimeout[C.target.id()]=setTimeout((async()=>{await this.popover(e.data().context,"",e,"juggl-preview-edge")}),800))})),this.viz.on("mouseout",(C=>{if(C.target===C.cy)return;const e=C.target.id();e in this.hoverTimeout&&(clearTimeout(this.hoverTimeout[e]),this.hoverTimeout[e]=void 0),C.cy.elements().removeClass([n,r,a]),C.target.hasClass(t)&&C.target.lock()})),this.viz.on("grab",(C=>{this.activeLayout&&this.activeLayout.stop()})),this.viz.on("dragfree",(C=>{this.activeLayout&&this.activeLayout.stop(),this.activeLayout.start();const e=C.target;e.lock(),this.activeLayout.one("layoutstop",(C=>{e.hasClass(t)||e.unlock()}))})),this.viz.on("cxttap",(e=>{const t=new C.Menu(this.plugin.app);if(e.target!==this.viz&&"nodes"===e.target.group()){const C=c.fromNode(e.target);if(e.target.select(),"core"===C.storeId){const e=this.plugin.app.metadataCache.getFirstLinkpathDest(C.id,"");void 0!==e&&this.plugin.app.workspace.trigger("file-menu",t,e,"my-context-menu",null)}}this.mode.fillMenu(t,this.viz.nodes(":selected")),t.showAtPosition({x:e.originalEvent.x,y:e.originalEvent.y})})),this.viz.on("layoutstop",C.debounce((C=>{if(!this.settings.autoZoom)return;let e;const t=this.viz.nodes(`.${V}`);e=t.length>0?t.closedNeighborhood():this.viz.nodes(),C.cy.animate({fit:{eles:e,padding:0},duration:250,queue:!1})}),500,!0)),this.vizReady=!0,this.trigger("vizReady",this.viz),console.log("Visualization ready")}catch(C){throw console.log(C),C}}async popover(e,t,H,V){const i=activeDocument.createElement("div");i.addClasses(["popover","hover-popover","is-loaded","juggl-hover"]);const L=activeDocument.createElement("div");L.addClasses(["markdown-embed",V]),i.appendChild(L);const n=activeDocument.createElement("div");n.addClasses(["markdown-embed-content"]),L.appendChild(n);const r=activeDocument.createElement("div");r.addClasses(["markdown-preview-view"]),n.appendChild(r);const o=activeDocument.createElement("div");o.addClasses(["markdown-preview-sizer","markdown-preview-section"]),r.appendChild(o),await C.MarkdownRenderer.renderMarkdown(e,o,t,null),activeDocument.body.appendChild(i);const a=H.popper({content:()=>i,popper:{placement:"top"}}),M=function(){a.update()};H.on("position",M),this.viz.on("pan zoom resize",M),i.addEventListener("mouseenter",(C=>{i.addClass("popover-hovered")})),this.destroyHover=()=>{a.destroy(),i.remove(),this.destroyHover=null},i.addEventListener("mouseleave",this.destroyHover);const s=this.destroyHover;this.viz.one("mouseout",(C=>{setTimeout((function(){i.hasClass("popover-hovered")||s()}),300)}))}async neighbourhood(C){const e=[];for(const t of this.datastores.dataStores){const H=await t.getNeighbourhood(C,this);e.push(...H)}return e}async buildEdges(C){const e=[];for(const t of this.datastores.dataStores)e.push(...await t.connectNodes(this.viz.nodes(),C,this));return e}async expand(C,e=!0,t=!0){if(0===C.length)return Promise.resolve(null);e&&this.viz.startBatch(),C.addClass(H),C.addClass(o);const V=C.map((C=>c.fromNode(C))),i=await this.neighbourhood(V);this.mergeToGraph(i,!1,!1);const L=this.viz.collection();i.forEach((C=>{L.merge(this.viz.$id(C.data.id))}));const n=await this.buildEdges(L),r=this.mergeToGraph(n,!1,t);return e&&this.viz.endBatch(),this.trigger("expand",C),r}async updateStylesheet(){const C=new vC(this.plugin),e=await C.getStylesheet(this);this.viz.style(e),this.trigger("stylesheet",C,e)}onunload(){this.plugin.eventHandlers.map((C=>C.onJugglDestroyed(this)))}removeNodes(C){let e=null;return this.viz.batch((()=>{this.getExpanded().intersection(C.neighborhood()).removeClass("expanded"),e=C.remove(),this.onGraphChanged(!1,!0)})),e}fitView(C){C?this.viz.fit(C):this.viz.fit()}restartLayout(){this.activeLayout&&this.activeLayout.stop();const C="string"==typeof(e=this.settings).layout||e.layout instanceof String?hd(e.layout,e):hd(e.layout.name,e,e.layout);var e;try{const e={layout:C,collection:this.viz.elements()};this.trigger("layout",e),this.activeLayout=C.startLayout(e.collection)}catch(C){console.log(C)}}setLayout(C){this.settings.layout=C.options,this.restartLayout()}mergeToGraph(C,e=!0,t=!0){e&&this.viz.startBatch();const H=[],V=this.viz.collection();C.forEach((C=>{if(0===this.viz.$id(C.data.id).length)H.push(C);else{const e=this.viz.$id(C.data.id),t=l.filter((C=>e.hasClass(C)));t.push(...e.classes().filter((C=>C.startsWith("global-")||C.startsWith("local-")))),e.classes(C.classes);for(const C of t)e.addClass(C);e.data(C.data),V.merge(e)}}));const i=this.viz.add(H);return V.merge(i),t&&this.onGraphChanged(!1),e&&this.viz.endBatch(),{merged:V,added:i}}assignStyleGroups(){const C=this.viz,e=function(e,t){for(const[H,V]of e.entries()){const e=`${t}-${H}`;C.nodes().removeClass(e);Fd(V.filter,C.nodes()).addClass(e)}};e(this.settings.styleGroups,"local"),"settings"in this.plugin&&e(this.plugin.settings.globalStyleGroups,"global")}onGraphChanged(C=!0,e=!1){C&&this.viz.startBatch(),this.viz.nodes().forEach((C=>{C.data("degree",C.degree(!1)),C.data("nameLength",C.data("name").length),C.addClass([...new Set(C.incomers("edge").map((C=>"has-incoming-"+(C.data("type")?C.data("type"):"inline"))))]),C.addClass([...new Set(C.outgoers("edge").map((C=>"has-outgoing-"+(C.data("type")?C.data("type"):"inline"))))])})),C&&this.viz.endBatch(),this.trigger("elementsChange"),this.searchFilter(this.settings.filter),e?this.debouncedRestartLayout():this.restartLayout(),this.assignStyleGroups()}getViz(){return this.viz}setMode(C){this.removeChild(this.mode),"local"===C?this.mode=new Ed(this):"workspace"===C&&(this.mode=new wd(this)),this.addChild(this.mode),this.settings.toolbar&&this.mode.createToolbar(this.element.children[0])}searchFilter(C){this.viz.nodes().removeClass(M);const e=Fd(C,this.viz.nodes());this.viz.nodes().difference(e).addClass(M),this.settings.filter=C}getPinned(){return this.viz.nodes(`.${t}`)}getExpanded(){return this.viz.nodes(`.${H}`)}getProtected(){return this.viz.nodes(`.${o}`)}on(C,e,t){return this.events.on(C,e,t)}off(C,e){this.events.off(C,e)}offref(C){this.events.offref(C)}trigger(C,...e){this.events.trigger(C,...e)}tryTrigger(C,e){this.events.tryTrigger(C,e)}}class zd extends C.Component{constructor(C){super(),this.settings=C.settings,this.plugin=C,this.imgServer=null}async onload(){if(super.onload(),C.Platform.isMobile||!this.settings.useImgServer)return;const e=require("path"),t=require("http"),H=require("fs");let V=null;try{V=e.join(this.plugin.path)}catch(C){return console.log("Couldn't start image server. This is likely because we're on mobile!"),console.log("Alternatively, windows might block it using the firewall"),void console.log(C)}const i={gif:"image/gif",jpg:"image/jpeg",jpeg:"image/jpeg",png:"image/png",svg:"image/svg+xml"},L=this.settings,n=this.plugin.app.vault;this.imgServer=t.createServer((function(C,t){const r=C.url.toString().split("?")[0];if("GET"!==C.method)return t.statusCode=501,t.setHeader("Content-Type","text/plain"),t.end("Method not implemented");let o=e.join(V,decodeURI(r.replace(/\/$/,"/index.html")));o=n.adapter.getFullPath(o),L.debug&&(console.log("entering server query"),console.log(C),console.log(o));const a=i[e.extname(o).slice(1)],M=H.createReadStream(o);M.on("open",(function(){t.setHeader("Content-Type",a),t.setHeader("Access-Control-Allow-Origin","*"),M.pipe(t)})),M.on("error",(function(){console.log("Here3"),t.setHeader("Content-Type","text/plain"),t.statusCode=404,t.end("Not found")}))}));try{const C=this.settings.imgServerPort;this.imgServer.listen(C,(function(){console.log("Image server listening on http://localhost:"+C+"/")}))}catch(e){console.log(e),new C.Notice("Juggl: Couldn't start image server, see console")}}async onunload(){super.onunload(),this.imgServer&&(this.imgServer.close(),this.imgServer=null)}}var jd={exports:{}};!function(C){!function(){var e={container:!1,viewLiveFramerate:0,dblClickDelay:200,removeCustomContainer:!0,rerenderDelay:500},t=function(){var C=Math.max,e=Date.now||function(){return(new Date).getTime()};return function(t,H,V){var i,L,n,r,o,a,M,s,l,d=0,u=!1,c=!0;if("function"!=typeof t)throw new TypeError("Expected a function");if(H=H<0?0:+H||0,!0===V){var A=!0;c=!1}else l=typeof(s=V),!s||"object"!=l&&"function"!=l||(A=!!V.leading,u="maxWait"in V&&C(+V.maxWait||0,H),c="trailing"in V?!!V.trailing:c);function h(C,H){H&&clearTimeout(H),L=a=M=void 0,C&&(d=e(),n=t.apply(o,i),a||L||(i=o=void 0))}function m(){var C=H-(e()-r);C<=0||C>H?h(M,L):a=setTimeout(m,C)}function f(){h(c,a)}function p(){if(i=arguments,r=e(),o=this,M=c&&(a||!A),!1===u)var C=A&&!a;else{L||A||(d=r);var V=u-(r-d),s=V<=0||V>u;s?(L&&(L=clearTimeout(L)),d=r,n=t.apply(o,i)):L||(L=setTimeout(f,V))}return s&&a?a=clearTimeout(a):a||H===u||(a=setTimeout(m,H)),C&&(s=!0,n=t.apply(o,i)),!s||a||L||(i=o=void 0),n}return p.cancel=function(){a&&clearTimeout(a),L&&clearTimeout(L),d=0,L=a=M=void 0},p}}(),H=function(C,e){this._init(C,e)},V=function(){for(var C=1;C0?-1!==C.container.indexOf("#")?this.$panel=document.getElementById(C.container.replace("#","")):this.$panel=document.getElementsByClassName(C.container.replace(".",""))[0]:(this.$panel=document.createElement("div"),this.$panel.className="cytoscape-navigator",document.body.appendChild(this.$panel)),this._setupPanel(),this._addCyListener("resize",this.resize.bind(this))},_setupPanel:function(){this.panelWidth=i(this.$panel),this.panelHeight=L(this.$panel)},_initThumbnail:function(){this.$thumbnail=document.createElement("img"),this.$thumbnail.setAttribute("alt","Graph navigator"),this.$panel.appendChild(this.$thumbnail),this._setupThumbnailSizes(),this._setupThumbnail()},_setupThumbnail:function(){this._updateThumbnailImage()},_setupThumbnailSizes:function(){this.boundingBox=this.bb(),this.thumbnailZoom=Math.min(this.panelHeight/this.boundingBox.h,this.panelWidth/this.boundingBox.w),this.thumbnailPan={x:(this.panelWidth-this.thumbnailZoom*(this.boundingBox.x1+this.boundingBox.x2))/2,y:(this.panelHeight-this.thumbnailZoom*(this.boundingBox.y1+this.boundingBox.y2))/2}},_checkThumbnailSizesAndUpdate:function(){var C=this.thumbnailZoom,e=this.thumbnailPan.x,t=this.thumbnailPan.y;this._setupThumbnailSizes(),C!=this.thumbnailZoom||e!=this.thumbnailPan.x||t!=this.thumbnailPan.y?(this._setupThumbnail(),this._setupView()):this._updateThumbnailImage()},_initView:function(){this.$view=document.createElement("div"),this.$view.className="cytoscape-navigatorView",this.$panel.appendChild(this.$view),this.viewBorderTop=parseInt(this.$view.style["border-top-width"],10)||0,this.viewBorderRight=parseInt(this.$view.style["border-right-width"],10)||0,this.viewBorderBottom=parseInt(this.$view.style["border-bottom-width"],10)||0,this.viewBorderLeft=parseInt(this.$view.style["border-left-width"],10)||0,this.viewBorderHorizontal=this.viewBorderLeft+this.viewBorderRight,this.viewBorderVertical=this.viewBorderTop+this.viewBorderBottom,this._setupView(),this._addCyListener("zoom pan",this._setupView.bind(this))},_setupView:function(){if(!this.viewLocked){var C=this.cy.zoom(),e=this.cy.pan();this.viewW=this.width/C*this.thumbnailZoom,this.viewX=-e.x*this.viewW/this.width+this.thumbnailPan.x-this.viewBorderLeft,this.viewH=this.height/C*this.thumbnailZoom,this.viewY=-e.y*this.viewH/this.height+this.thumbnailPan.y-this.viewBorderTop,this.$view.style.width=this.viewW+"px",this.$view.style.height=this.viewH+"px",this.$view.style.position="absolute",this.$view.style.left=this.viewX+"px",this.$view.style.top=this.viewY+"px"}},_initOverlay:function(){this.$overlay=document.createElement("div"),this.$overlay.className="cytoscape-navigatorOverlay",this.$panel.appendChild(this.$overlay),this.overlayHookPointX=0,this.overlayHookPointY=0,this._initEventsHandling()},resize:function(){this.width=i(this.$element),this.height=L(this.$element),this._thumbnailSetup=!1,this._setupPanel(),this._checkThumbnailSizesAndUpdate(),this._setupView()},_initEventsHandling:function(){for(var C=this,e=["mousedown","mousewheel","DOMMouseScroll","touchstart"],t=["mouseup","mouseout","mousemove","touchmove","touchend"],H=function(e){if("touchstart"==e.type&&(Object.defineProperty(e,"offsetX",{value:C.viewX+C.viewW/2,writable:!0}),Object.defineProperty(e,"offsetY",{value:C.viewY+C.viewH/2,writable:!0})),void 0===e.offsetX||void 0===e.offsetY){var t=e.target.getBoundingClientRect(),H={top:t.top+window.scrollY,left:t.left+window.scrollX};Object.defineProperty(e,"offsetX",{value:e.pageX-H.left,writable:!0}),Object.defineProperty(e,"offsetY",{value:e.pageY-H.top,writable:!0})}return"mousedown"==e.type||"touchstart"==e.type?C._eventMoveStart(e):"mousewheel"!=e.type&&"DOMMouseScroll"!=e.type||C._eventZoom(e),!1},V=function(e){if(C.overlayInMovement){if("touchend"==e.type?(Object.defineProperty(e,"offsetX",{value:C.viewX+C.viewW/2,writable:!0}),Object.defineProperty(e,"offsetY",{value:C.viewY+C.viewH/2,writable:!0})):"touchmove"==e.type&&(Object.defineProperty(e,"pageX",{value:e.originalEvent.touches[0].pageX,writable:!0}),Object.defineProperty(e,"pageY",{value:e.originalEvent.touches[0].pageY,writable:!0})),void 0===e.offsetX||void 0===e.offsetY){var t={top:(H=e.target.getBoundingClientRect()).top+window.scrollY,left:H.left+window.scrollX};Object.defineProperty(e,"offsetX",{value:e.pageX-t.left,writable:!0}),Object.defineProperty(e,"offsetY",{value:e.pageY-t.top,writable:!0})}if(e.target!==C.$overlay){var H=e.target.getBoundingClientRect(),V=C.$overlay.getBoundingClientRect(),i=(t={top:H.top+window.scrollY,left:H.left+window.scrollX},{top:V.top+window.scrollY,left:V.left+window.scrollX});if(!t||!i)return!1;Object.defineProperty(e,"offsetX",{value:e.offsetX-i.left+t.left,writable:!0}),Object.defineProperty(e,"offsetY",{value:e.offsetY-i.top+t.top,writable:!0})}return"mousemove"==e.type||"touchmove"==e.type?C._eventMove(e):"mouseup"!=e.type&&"touchend"!=e.type||C._eventMoveEnd(e),!1}},i=0;ie?(this.overlayLastMoveStartTime=0,this.overlayInMovement=!0,this.overlayHookPointX=this.viewW/2,this.overlayHookPointY=this.viewH/2,!1!==this.options.viewLiveFramerate?this._eventMove({offsetX:this.panelWidth/2,offsetY:this.panelHeight/2}):this._eventMoveEnd({offsetX:this.panelWidth/2,offsetY:this.panelHeight/2}),this.overlayInMovement=!1):(this.overlayLastMoveStartTime=e,this.overlayInMovement=!0,this.viewLocked=!0,C.offsetX>=this.viewX&&C.offsetX<=this.viewX+this.viewW&&C.offsetY>=this.viewY&&C.offsetY<=this.viewY+this.viewH?(this.overlayHookPointX=C.offsetX-this.viewX,this.overlayHookPointY=C.offsetY-this.viewY):(this.overlayHookPointX=this.viewW/2,this.overlayHookPointY=this.viewH/2,this._eventMove(C)))},_eventMove:function(C){var e=this;this._checkMousePosition(C),this.overlayInMovement&&(this.viewX=C.offsetX-this.overlayHookPointX,this.viewY=C.offsetY-this.overlayHookPointY,this.$view.style.left=this.viewX+"px",this.$view.style.top=this.viewY+"px",!1!==this.options.viewLiveFramerate&&(0==this.options.viewLiveFramerate?this._moveCy():this.overlayTimeout||(this.overlayTimeout=setTimeout((function(){e._moveCy(),e.overlayTimeout=!1}),1e3/this.options.viewLiveFramerate))))},_checkMousePosition:function(C){C.offsetX>this.viewX&&C.offsetXthis.viewY&&C.offsetY0&&Zu(H.width)/C.offsetWidth||1,i=C.offsetHeight>0&&Zu(H.height)/C.offsetHeight||1);var L=(hu(C)?Au(C):window).visualViewport,n=!bu()&&t,r=(H.left+(n&&L?L.offsetLeft:0))/V,o=(H.top+(n&&L?L.offsetTop:0))/i,a=H.width/V,M=H.height/i;return{width:a,height:M,top:o,right:r+a,bottom:o+M,left:r,x:r,y:o}}function xu(C){var e=wu(C),t=C.offsetWidth,H=C.offsetHeight;return Math.abs(e.width-t)<=1&&(t=e.width),Math.abs(e.height-H)<=1&&(H=e.height),{x:C.offsetLeft,y:C.offsetTop,width:t,height:H}}function Ou(C,e){var t=e.getRootNode&&e.getRootNode();if(C.contains(e))return!0;if(t&&fu(t)){var H=e;do{if(H&&C.isSameNode(H))return!0;H=H.parentNode||H.host}while(H)}return!1}function ku(C){return Au(C).getComputedStyle(C)}function Eu(C){return["table","td","th"].indexOf(cu(C))>=0}function Pu(C){return((hu(C)?C.ownerDocument:C.document)||window.document).documentElement}function Tu(C){return"html"===cu(C)?C:C.assignedSlot||C.parentNode||(fu(C)?C.host:null)||Pu(C)}function Bu(C){return mu(C)&&"fixed"!==ku(C).position?C.offsetParent:null}function _u(C){for(var e=Au(C),t=Bu(C);t&&Eu(t)&&"static"===ku(t).position;)t=Bu(t);return t&&("html"===cu(t)||"body"===cu(t)&&"static"===ku(t).position)?e:t||function(C){var e=/firefox/i.test(Su());if(/Trident/i.test(Su())&&mu(C)&&"fixed"===ku(C).position)return null;var t=Tu(C);for(fu(t)&&(t=t.host);mu(t)&&["html","body"].indexOf(cu(t))<0;){var H=ku(t);if("none"!==H.transform||"none"!==H.perspective||"paint"===H.contain||-1!==["transform","perspective"].indexOf(H.willChange)||e&&"filter"===H.willChange||e&&H.filter&&"none"!==H.filter)return t;t=t.parentNode}return null}(C)||e}function Du(C){return["top","bottom"].indexOf(C)>=0?"x":"y"}function Ru(C,e,t){return vu(C,yu(e,t))}function Fu(C){return Object.assign({},{top:0,right:0,bottom:0,left:0},C)}function Nu(C,e){return e.reduce((function(e,t){return e[t]=C,e}),{})}var Iu={name:"arrow",enabled:!0,phase:"main",fn:function(C){var e,t=C.state,H=C.name,V=C.options,i=t.elements.arrow,L=t.modifiersData.popperOffsets,n=gu(t.placement),r=Du(n),o=[Xd,Yd].indexOf(n)>=0?"height":"width";if(i&&L){var a=function(C,e){return Fu("number"!=typeof(C="function"==typeof C?C(Object.assign({},e.rects,{placement:e.placement})):C)?C:Nu(C,Qd))}(V.padding,t),M=xu(i),s="y"===r?Ud:Xd,l="y"===r?$d:Yd,d=t.rects.reference[o]+t.rects.reference[r]-L[r]-t.rects.popper[o],u=L[r]-t.rects.reference[r],c=_u(i),A=c?"y"===r?c.clientHeight||0:c.clientWidth||0:0,h=d/2-u/2,m=a[s],f=A-M[o]-a[l],p=A/2-M[o]/2+h,g=Ru(m,p,f),v=r;t.modifiersData[H]=((e={})[v]=g,e.centerOffset=g-p,e)}},effect:function(C){var e=C.state,t=C.options.element,H=void 0===t?"[data-popper-arrow]":t;null!=H&&("string"!=typeof H||(H=e.elements.popper.querySelector(H)))&&Ou(e.elements.popper,H)&&(e.elements.arrow=H)},requires:["popperOffsets"],requiresIfExists:["preventOverflow"]};function zu(C){return C.split("-")[1]}var ju={top:"auto",right:"auto",bottom:"auto",left:"auto"};function Gu(C){var e,t=C.popper,H=C.popperRect,V=C.placement,i=C.variation,L=C.offsets,n=C.position,r=C.gpuAcceleration,o=C.adaptive,a=C.roundOffsets,M=C.isFixed,s=L.x,l=void 0===s?0:s,d=L.y,u=void 0===d?0:d,c="function"==typeof a?a({x:l,y:u}):{x:l,y:u};l=c.x,u=c.y;var A=L.hasOwnProperty("x"),h=L.hasOwnProperty("y"),m=Xd,f=Ud,p=window;if(o){var g=_u(t),v="clientHeight",y="clientWidth";if(g===Au(t)&&"static"!==ku(g=Pu(t)).position&&"absolute"===n&&(v="scrollHeight",y="scrollWidth"),V===Ud||(V===Xd||V===Yd)&&i===Jd)f=$d,u-=(M&&g===p&&p.visualViewport?p.visualViewport.height:g[v])-H.height,u*=r?1:-1;if(V===Xd||(V===Ud||V===$d)&&i===Jd)m=Yd,l-=(M&&g===p&&p.visualViewport?p.visualViewport.width:g[y])-H.width,l*=r?1:-1}var Z,S=Object.assign({position:n},o&&ju),b=!0===a?function(C,e){var t=C.x,H=C.y,V=e.devicePixelRatio||1;return{x:Zu(t*V)/V||0,y:Zu(H*V)/V||0}}({x:l,y:u},Au(t)):{x:l,y:u};return l=b.x,u=b.y,r?Object.assign({},S,((Z={})[f]=h?"0":"",Z[m]=A?"0":"",Z.transform=(p.devicePixelRatio||1)<=1?"translate("+l+"px, "+u+"px)":"translate3d("+l+"px, "+u+"px, 0)",Z)):Object.assign({},S,((e={})[f]=h?u+"px":"",e[m]=A?l+"px":"",e.transform="",e))}var Wu={name:"computeStyles",enabled:!0,phase:"beforeWrite",fn:function(C){var e=C.state,t=C.options,H=t.gpuAcceleration,V=void 0===H||H,i=t.adaptive,L=void 0===i||i,n=t.roundOffsets,r=void 0===n||n,o={placement:gu(e.placement),variation:zu(e.placement),popper:e.elements.popper,popperRect:e.rects.popper,gpuAcceleration:V,isFixed:"fixed"===e.options.strategy};null!=e.modifiersData.popperOffsets&&(e.styles.popper=Object.assign({},e.styles.popper,Gu(Object.assign({},o,{offsets:e.modifiersData.popperOffsets,position:e.options.strategy,adaptive:L,roundOffsets:r})))),null!=e.modifiersData.arrow&&(e.styles.arrow=Object.assign({},e.styles.arrow,Gu(Object.assign({},o,{offsets:e.modifiersData.arrow,position:"absolute",adaptive:!1,roundOffsets:r})))),e.attributes.popper=Object.assign({},e.attributes.popper,{"data-popper-placement":e.placement})},data:{}},Uu={passive:!0};var $u={name:"eventListeners",enabled:!0,phase:"write",fn:function(){},effect:function(C){var e=C.state,t=C.instance,H=C.options,V=H.scroll,i=void 0===V||V,L=H.resize,n=void 0===L||L,r=Au(e.elements.popper),o=[].concat(e.scrollParents.reference,e.scrollParents.popper);return i&&o.forEach((function(C){C.addEventListener("scroll",t.update,Uu)})),n&&r.addEventListener("resize",t.update,Uu),function(){i&&o.forEach((function(C){C.removeEventListener("scroll",t.update,Uu)})),n&&r.removeEventListener("resize",t.update,Uu)}},data:{}},Yu={left:"right",right:"left",bottom:"top",top:"bottom"};function Xu(C){return C.replace(/left|right|bottom|top/g,(function(C){return Yu[C]}))}var qu={start:"end",end:"start"};function Qu(C){return C.replace(/start|end/g,(function(C){return qu[C]}))}function Ku(C){var e=Au(C);return{scrollLeft:e.pageXOffset,scrollTop:e.pageYOffset}}function Ju(C){return wu(Pu(C)).left+Ku(C).scrollLeft}function Cc(C){var e=ku(C),t=e.overflow,H=e.overflowX,V=e.overflowY;return/auto|scroll|overlay|hidden/.test(t+V+H)}function ec(C){return["html","body","#document"].indexOf(cu(C))>=0?C.ownerDocument.body:mu(C)&&Cc(C)?C:ec(Tu(C))}function tc(C,e){var t;void 0===e&&(e=[]);var H=ec(C),V=H===(null==(t=C.ownerDocument)?void 0:t.body),i=Au(H),L=V?[i].concat(i.visualViewport||[],Cc(H)?H:[]):H,n=e.concat(L);return V?n:n.concat(tc(Tu(L)))}function Hc(C){return Object.assign({},C,{left:C.x,top:C.y,right:C.x+C.width,bottom:C.y+C.height})}function Vc(C,e,t){return e===eu?Hc(function(C,e){var t=Au(C),H=Pu(C),V=t.visualViewport,i=H.clientWidth,L=H.clientHeight,n=0,r=0;if(V){i=V.width,L=V.height;var o=bu();(o||!o&&"fixed"===e)&&(n=V.offsetLeft,r=V.offsetTop)}return{width:i,height:L,x:n+Ju(C),y:r}}(C,t)):hu(e)?function(C,e){var t=wu(C,!1,"fixed"===e);return t.top=t.top+C.clientTop,t.left=t.left+C.clientLeft,t.bottom=t.top+C.clientHeight,t.right=t.left+C.clientWidth,t.width=C.clientWidth,t.height=C.clientHeight,t.x=t.left,t.y=t.top,t}(e,t):Hc(function(C){var e,t=Pu(C),H=Ku(C),V=null==(e=C.ownerDocument)?void 0:e.body,i=vu(t.scrollWidth,t.clientWidth,V?V.scrollWidth:0,V?V.clientWidth:0),L=vu(t.scrollHeight,t.clientHeight,V?V.scrollHeight:0,V?V.clientHeight:0),n=-H.scrollLeft+Ju(C),r=-H.scrollTop;return"rtl"===ku(V||t).direction&&(n+=vu(t.clientWidth,V?V.clientWidth:0)-i),{width:i,height:L,x:n,y:r}}(Pu(C)))}function ic(C,e,t,H){var V="clippingParents"===e?function(C){var e=tc(Tu(C)),t=["absolute","fixed"].indexOf(ku(C).position)>=0&&mu(C)?_u(C):C;return hu(t)?e.filter((function(C){return hu(C)&&Ou(C,t)&&"body"!==cu(C)})):[]}(C):[].concat(e),i=[].concat(V,[t]),L=i[0],n=i.reduce((function(e,t){var V=Vc(C,t,H);return e.top=vu(V.top,e.top),e.right=yu(V.right,e.right),e.bottom=yu(V.bottom,e.bottom),e.left=vu(V.left,e.left),e}),Vc(C,L,H));return n.width=n.right-n.left,n.height=n.bottom-n.top,n.x=n.left,n.y=n.top,n}function Lc(C){var e,t=C.reference,H=C.element,V=C.placement,i=V?gu(V):null,L=V?zu(V):null,n=t.x+t.width/2-H.width/2,r=t.y+t.height/2-H.height/2;switch(i){case Ud:e={x:n,y:t.y-H.height};break;case $d:e={x:n,y:t.y+t.height};break;case Yd:e={x:t.x+t.width,y:r};break;case Xd:e={x:t.x-H.width,y:r};break;default:e={x:t.x,y:t.y}}var o=i?Du(i):null;if(null!=o){var a="y"===o?"height":"width";switch(L){case Kd:e[o]=e[o]-(t[a]/2-H[a]/2);break;case Jd:e[o]=e[o]+(t[a]/2-H[a]/2)}}return e}function nc(C,e){void 0===e&&(e={});var t=e,H=t.placement,V=void 0===H?C.placement:H,i=t.strategy,L=void 0===i?C.strategy:i,n=t.boundary,r=void 0===n?Cu:n,o=t.rootBoundary,a=void 0===o?eu:o,M=t.elementContext,s=void 0===M?tu:M,l=t.altBoundary,d=void 0!==l&&l,u=t.padding,c=void 0===u?0:u,A=Fu("number"!=typeof c?c:Nu(c,Qd)),h=s===tu?Hu:tu,m=C.rects.popper,f=C.elements[d?h:s],p=ic(hu(f)?f:f.contextElement||Pu(C.elements.popper),r,a,L),g=wu(C.elements.reference),v=Lc({reference:g,element:m,strategy:"absolute",placement:V}),y=Hc(Object.assign({},m,v)),Z=s===tu?y:g,S={top:p.top-Z.top+A.top,bottom:Z.bottom-p.bottom+A.bottom,left:p.left-Z.left+A.left,right:Z.right-p.right+A.right},b=C.modifiersData.offset;if(s===tu&&b){var w=b[V];Object.keys(S).forEach((function(C){var e=[Yd,$d].indexOf(C)>=0?1:-1,t=[Ud,$d].indexOf(C)>=0?"y":"x";S[C]+=w[t]*e}))}return S}function rc(C,e){void 0===e&&(e={});var t=e,H=t.placement,V=t.boundary,i=t.rootBoundary,L=t.padding,n=t.flipVariations,r=t.allowedAutoPlacements,o=void 0===r?iu:r,a=zu(H),M=a?n?Vu:Vu.filter((function(C){return zu(C)===a})):Qd,s=M.filter((function(C){return o.indexOf(C)>=0}));0===s.length&&(s=M);var l=s.reduce((function(e,t){return e[t]=nc(C,{placement:t,boundary:V,rootBoundary:i,padding:L})[gu(t)],e}),{});return Object.keys(l).sort((function(C,e){return l[C]-l[e]}))}var oc={name:"flip",enabled:!0,phase:"main",fn:function(C){var e=C.state,t=C.options,H=C.name;if(!e.modifiersData[H]._skip){for(var V=t.mainAxis,i=void 0===V||V,L=t.altAxis,n=void 0===L||L,r=t.fallbackPlacements,o=t.padding,a=t.boundary,M=t.rootBoundary,s=t.altBoundary,l=t.flipVariations,d=void 0===l||l,u=t.allowedAutoPlacements,c=e.options.placement,A=gu(c),h=r||(A===c||!d?[Xu(c)]:function(C){if(gu(C)===qd)return[];var e=Xu(C);return[Qu(C),e,Qu(e)]}(c)),m=[c].concat(h).reduce((function(C,t){return C.concat(gu(t)===qd?rc(e,{placement:t,boundary:a,rootBoundary:M,padding:o,flipVariations:d,allowedAutoPlacements:u}):t)}),[]),f=e.rects.reference,p=e.rects.popper,g=new Map,v=!0,y=m[0],Z=0;Z=0,O=x?"width":"height",k=nc(e,{placement:S,boundary:a,rootBoundary:M,altBoundary:s,padding:o}),E=x?w?Yd:Xd:w?$d:Ud;f[O]>p[O]&&(E=Xu(E));var P=Xu(E),T=[];if(i&&T.push(k[b]<=0),n&&T.push(k[E]<=0,k[P]<=0),T.every((function(C){return C}))){y=S,v=!1;break}g.set(S,T)}if(v)for(var B=function(C){var e=m.find((function(e){var t=g.get(e);if(t)return t.slice(0,C).every((function(C){return C}))}));if(e)return y=e,"break"},_=d?3:1;_>0;_--){if("break"===B(_))break}e.placement!==y&&(e.modifiersData[H]._skip=!0,e.placement=y,e.reset=!0)}},requiresIfExists:["offset"],data:{_skip:!1}};function ac(C,e,t){return void 0===t&&(t={x:0,y:0}),{top:C.top-e.height-t.y,right:C.right-e.width+t.x,bottom:C.bottom-e.height+t.y,left:C.left-e.width-t.x}}function Mc(C){return[Ud,Yd,$d,Xd].some((function(e){return C[e]>=0}))}var sc={name:"hide",enabled:!0,phase:"main",requiresIfExists:["preventOverflow"],fn:function(C){var e=C.state,t=C.name,H=e.rects.reference,V=e.rects.popper,i=e.modifiersData.preventOverflow,L=nc(e,{elementContext:"reference"}),n=nc(e,{altBoundary:!0}),r=ac(L,H),o=ac(n,V,i),a=Mc(r),M=Mc(o);e.modifiersData[t]={referenceClippingOffsets:r,popperEscapeOffsets:o,isReferenceHidden:a,hasPopperEscaped:M},e.attributes.popper=Object.assign({},e.attributes.popper,{"data-popper-reference-hidden":a,"data-popper-escaped":M})}};var lc={name:"offset",enabled:!0,phase:"main",requires:["popperOffsets"],fn:function(C){var e=C.state,t=C.options,H=C.name,V=t.offset,i=void 0===V?[0,0]:V,L=iu.reduce((function(C,t){return C[t]=function(C,e,t){var H=gu(C),V=[Xd,Ud].indexOf(H)>=0?-1:1,i="function"==typeof t?t(Object.assign({},e,{placement:C})):t,L=i[0],n=i[1];return L=L||0,n=(n||0)*V,[Xd,Yd].indexOf(H)>=0?{x:n,y:L}:{x:L,y:n}}(t,e.rects,i),C}),{}),n=L[e.placement],r=n.x,o=n.y;null!=e.modifiersData.popperOffsets&&(e.modifiersData.popperOffsets.x+=r,e.modifiersData.popperOffsets.y+=o),e.modifiersData[H]=L}};var dc={name:"popperOffsets",enabled:!0,phase:"read",fn:function(C){var e=C.state,t=C.name;e.modifiersData[t]=Lc({reference:e.rects.reference,element:e.rects.popper,strategy:"absolute",placement:e.placement})},data:{}};var uc={name:"preventOverflow",enabled:!0,phase:"main",fn:function(C){var e=C.state,t=C.options,H=C.name,V=t.mainAxis,i=void 0===V||V,L=t.altAxis,n=void 0!==L&&L,r=t.boundary,o=t.rootBoundary,a=t.altBoundary,M=t.padding,s=t.tether,l=void 0===s||s,d=t.tetherOffset,u=void 0===d?0:d,c=nc(e,{boundary:r,rootBoundary:o,padding:M,altBoundary:a}),A=gu(e.placement),h=zu(e.placement),m=!h,f=Du(A),p="x"===f?"y":"x",g=e.modifiersData.popperOffsets,v=e.rects.reference,y=e.rects.popper,Z="function"==typeof u?u(Object.assign({},e.rects,{placement:e.placement})):u,S="number"==typeof Z?{mainAxis:Z,altAxis:Z}:Object.assign({mainAxis:0,altAxis:0},Z),b=e.modifiersData.offset?e.modifiersData.offset[e.placement]:null,w={x:0,y:0};if(g){if(i){var x,O="y"===f?Ud:Xd,k="y"===f?$d:Yd,E="y"===f?"height":"width",P=g[f],T=P+c[O],B=P-c[k],_=l?-y[E]/2:0,D=h===Kd?v[E]:y[E],R=h===Kd?-y[E]:-v[E],F=e.elements.arrow,N=l&&F?xu(F):{width:0,height:0},I=e.modifiersData["arrow#persistent"]?e.modifiersData["arrow#persistent"].padding:{top:0,right:0,bottom:0,left:0},z=I[O],j=I[k],G=Ru(0,v[E],N[E]),W=m?v[E]/2-_-G-z-S.mainAxis:D-G-z-S.mainAxis,U=m?-v[E]/2+_+G+j+S.mainAxis:R+G+j+S.mainAxis,$=e.elements.arrow&&_u(e.elements.arrow),Y=$?"y"===f?$.clientTop||0:$.clientLeft||0:0,X=null!=(x=null==b?void 0:b[f])?x:0,q=P+U-X,Q=Ru(l?yu(T,P+W-X-Y):T,P,l?vu(B,q):B);g[f]=Q,w[f]=Q-P}if(n){var K,J="x"===f?Ud:Xd,CC="x"===f?$d:Yd,eC=g[p],tC="y"===p?"height":"width",HC=eC+c[J],VC=eC-c[CC],iC=-1!==[Ud,Xd].indexOf(A),LC=null!=(K=null==b?void 0:b[p])?K:0,nC=iC?HC:eC-v[tC]-y[tC]-LC+S.altAxis,rC=iC?eC+v[tC]+y[tC]-LC-S.altAxis:VC,oC=l&&iC?function(C,e,t){var H=Ru(C,e,t);return H>t?t:H}(nC,eC,rC):Ru(l?nC:HC,eC,l?rC:VC);g[p]=oC,w[p]=oC-eC}e.modifiersData[H]=w}},requiresIfExists:["offset"]};function cc(C,e,t){void 0===t&&(t=!1);var H,V=mu(e),i=mu(e)&&function(C){var e=C.getBoundingClientRect(),t=Zu(e.width)/C.offsetWidth||1,H=Zu(e.height)/C.offsetHeight||1;return 1!==t||1!==H}(e),L=Pu(e),n=wu(C,i,t),r={scrollLeft:0,scrollTop:0},o={x:0,y:0};return(V||!V&&!t)&&(("body"!==cu(e)||Cc(L))&&(r=(H=e)!==Au(H)&&mu(H)?function(C){return{scrollLeft:C.scrollLeft,scrollTop:C.scrollTop}}(H):Ku(H)),mu(e)?((o=wu(e,!0)).x+=e.clientLeft,o.y+=e.clientTop):L&&(o.x=Ju(L))),{x:n.left+r.scrollLeft-o.x,y:n.top+r.scrollTop-o.y,width:n.width,height:n.height}}function Ac(C){var e=new Map,t=new Set,H=[];function V(C){t.add(C.name),[].concat(C.requires||[],C.requiresIfExists||[]).forEach((function(C){if(!t.has(C)){var H=e.get(C);H&&V(H)}})),H.push(C)}return C.forEach((function(C){e.set(C.name,C)})),C.forEach((function(C){t.has(C.name)||V(C)})),H}function hc(C){var e;return function(){return e||(e=new Promise((function(t){Promise.resolve().then((function(){e=void 0,t(C())}))}))),e}}var mc={placement:"bottom",modifiers:[],strategy:"absolute"};function fc(){for(var C=arguments.length,e=new Array(C),t=0;t1?e-1:0),H=1;H1&&(console.warn("Popper.js Extension should only be used on one element."),console.warn("Ignoring all subsequent elements"))}C.exports={popper:function(C){return n(this),V(this[0],L(this[0],C))},popperRef:function(C){return n(this),i(this[0],L(this[0],C))}}},function(C,e,t){var H=t(0),V=t(2).getPopper,i=t(1).getRef;function L(C,e){return H({},{boundingBox:{top:0,left:0,right:0,bottom:0,w:3,h:3},renderedDimensions:function(){return{w:3,h:3}},renderedPosition:function(){return{x:0,y:0}},popper:{},cy:C},e)}C.exports={popper:function(C){return V(this,L(this,C))},popperRef:function(C){return i(this,L(this,C))}}},function(C,e,t){C.exports={getBoundingBox:function(C,e){var t=e.renderedPosition,H=e.cy,V=e.renderedDimensions,i=H.container().getBoundingClientRect(),L=V(C),n=t(C);return{top:n.y+i.top,left:n.x+i.left,right:n.x+L.w+i.left,bottom:n.y+L.h+i.top,width:L.w,height:L.h}}}},function(C,e,t){C.exports={getContent:function(C,e){var t=null;if("function"!=typeof e){if(e instanceof HTMLElement)return e;throw new Error("Can not create popper from 'target' with unknown type")}if(null===(t=e(C)))throw new Error("No 'target' specified to create popper");return t}}},function(C,e,t){var H=t(4),V=t(3),i=function(C){C&&(C("core","popper",H.popper),C("collection","popper",V.popper),C("core","popperRef",H.popperRef),C("collection","popperRef",V.popperRef))};"undefined"!=typeof cytoscape&&i(cytoscape),C.exports=i},function(e,t){e.exports=C}])};var Sc,bc=BC(Wd.exports=gc(_C(Object.freeze({__proto__:null,afterMain:Mu,afterRead:ru,afterWrite:du,applyStyles:pu,arrow:Iu,auto:qd,basePlacements:Qd,beforeMain:ou,beforeRead:Lu,beforeWrite:su,bottom:$d,clippingParents:Cu,computeStyles:Wu,createPopper:Zc,createPopperBase:vc,createPopperLite:yc,detectOverflow:nc,end:Jd,eventListeners:$u,flip:oc,hide:sc,left:Xd,main:au,modifierPhases:uu,offset:lc,placements:iu,popper:tu,popperGenerator:pc,popperOffsets:dc,preventOverflow:uc,read:nu,reference:Hu,right:Yd,start:Kd,top:Ud,variationPlacements:Vu,viewport:eu,write:lu})))),wc={exports:{}},xc={},Oc={},kc={},Ec={};function Pc(){if(Sc)return Ec;Sc=1,Object.defineProperty(Ec,"__esModule",{value:!0});var C=function(C,e,t){this.source=C,this.target=e,this.type=t};Ec.PowerEdge=C;var e=function(){function e(C,e,t,i){var L=this;if(this.linkAccessor=t,this.modules=new Array(C),this.roots=[],i)this.initModulesFromGroup(i);else{this.roots.push(new V);for(var n=0;n=this.R))return this.merge(t.a,t.b,C),!0}},e.prototype.nEdges=function(C,e){var t=C.incoming.intersection(e.incoming),H=C.outgoing.intersection(e.outgoing);return this.R-t.count()-H.count()},e.prototype.getGroupHierarchy=function(e){var H=this,V=[];return t(this.roots[0],{},V),this.allEdges().forEach((function(t){var i=H.modules[t.source],L=H.modules[t.target];e.push(new C(void 0===i.gid?t.source:V[i.gid],void 0===L.gid?t.target:V[L.gid],t.type))})),V},e.prototype.allEdges=function(){var C=[];return e.getEdges(this.roots[0],C),C},e.getEdges=function(C,t){C.forAll((function(C){C.getEdges(t),e.getEdges(C.children,t)}))},e}();function t(C,e,H){C.forAll((function(C){if(C.isLeaf())e.leaves||(e.leaves=[]),e.leaves.push(C.id);else{var V=e;if(C.gid=H.length,!C.isIsland()||C.isPredefined()){if(V={id:C.gid},C.isPredefined())for(var i in C.definition)V[i]=C.definition[i];e.groups||(e.groups=[]),e.groups.push(C.gid),H.push(V)}t(C.children,V,H)}}))}Ec.Configuration=e;var H=function(){function e(C,e,t,H,L){void 0===e&&(e=new i),void 0===t&&(t=new i),void 0===H&&(H=new V),this.id=C,this.outgoing=e,this.incoming=t,this.children=H,this.definition=L}return e.prototype.getEdges=function(e){var t=this;this.outgoing.forAll((function(H,V){H.forAll((function(H){e.push(new C(t.id,H.id,V))}))}))},e.prototype.isLeaf=function(){return 0===this.children.count()},e.prototype.isIsland=function(){return 0===this.outgoing.count()&&0===this.incoming.count()},e.prototype.isPredefined=function(){return void 0!==this.definition},e}();Ec.Module=H;var V=function(){function C(){this.table={}}return C.prototype.count=function(){return Object.keys(this.table).length},C.prototype.intersection=function(e){var t=new C;return t.table=function(C,e){var t={};for(var H in C)H in e&&(t[H]=C[H]);return t}(this.table,e.table),t},C.prototype.intersectionCount=function(C){return this.intersection(C).count()},C.prototype.contains=function(C){return C in this.table},C.prototype.add=function(C){this.table[C.id]=C},C.prototype.remove=function(C){delete this.table[C.id]},C.prototype.forAll=function(C){for(var e in this.table)C(this.table[e])},C.prototype.modules=function(){var C=[];return this.forAll((function(e){e.isPredefined()||C.push(e)})),C},C}();Ec.ModuleSet=V;var i=function(){function C(){this.sets={},this.n=0}return C.prototype.count=function(){return this.n},C.prototype.contains=function(C){var e=!1;return this.forAllModules((function(t){e||t.id!=C||(e=!0)})),e},C.prototype.add=function(C,e){(C in this.sets?this.sets[C]:this.sets[C]=new V).add(e),++this.n},C.prototype.remove=function(C,e){var t=this.sets[C];t.remove(e),0===t.count()&&delete this.sets[C],--this.n},C.prototype.forAll=function(C){for(var e in this.sets)C(this.sets[e],Number(e))},C.prototype.forAllModules=function(C){this.forAll((function(e,t){return e.forAll(C)}))},C.prototype.intersection=function(e){var t=new C;return this.forAll((function(C,H){if(H in e.sets){var V=C.intersection(e.sets[H]),i=V.count();i>0&&(t.sets[H]=V,t.n+=i)}})),t},C}();return Ec.LinkSets=i,Ec.getGroups=function(C,t,H,V){for(var i=C.length,L=new e(i,t,H,V);L.greedyMerge(););var n=[],r=L.getGroupHierarchy(n);return n.forEach((function(e){var t=function(t){var H=e[t];"number"==typeof H&&(e[t]=C[H])};t("source"),t("target")})),{groups:r,powerEdges:n}},Ec}var Tc,Bc={};function _c(){if(Tc)return Bc;function C(C,e){var t={};for(var H in C)t[H]={};for(var H in e)t[H]={};return Object.keys(t).length}function e(C,e){var t=0;for(var H in C)void 0!==e[H]&&++t;return t}function t(C,e,t,H){var V=function(C,e){var t={},H=function(C,e){void 0===t[C]&&(t[C]={}),t[C][e]={}};return C.forEach((function(C){var t=e.getSourceIndex(C),V=e.getTargetIndex(C);H(t,V),H(V,t)})),t}(C,H);C.forEach((function(C){var i=V[H.getSourceIndex(C)],L=V[H.getTargetIndex(C)];H.setLength(C,1+e*t(i,L))}))}function H(C,e,t){var H=[],V=0,i=[],L=[];function n(C){C.index=C.lowlink=V++,i.push(C),C.onStack=!0;for(var e=0,t=C.out;en;){var r=H[n][L];r>0&&r1e-9)break;var l=this.offsetDir();for(H=0;H1&&d>u||!isFinite(u))for(H=0;H1&&(c=1);var A=u*u,h=2*c*(d-u)/(A*d),m=d*d*d,f=2*-c/(A*m);for(isFinite(h)||console.log(h),H=0;H0?Z-(w+1)*g:Z-(w-1)*g)&&s<=p&&(this.scaleSnapByMaxH?(this.g[H][r]+=n*v*s,this.H[H][r][r]+=n*v):(this.g[H][r]+=v*s,this.H[H][r][r]+=v))}this.locks.isEmpty()||this.locks.apply((function(t,V){for(H=0;H0;)for(var V=e;V-- >0;)t(H,V)},e.prototype.matrixApply=function(C){e.mApply(this.k,this.n,C)},e.prototype.computeNextPosition=function(C,e){var t=this;this.computeDerivatives(C);var H=this.computeStepSize(this.g);if(this.stepAndProject(C,e,this.g,H),this.project){this.matrixApply((function(H,V){return t.e[H][V]=C[H][V]-e[H][V]}));var V=this.computeStepSize(this.e);V=Math.max(.2,Math.min(V,1)),this.stepAndProject(C,e,this.e,V)}},e.prototype.run=function(C){for(var e=Number.MAX_VALUE,t=!1;!t&&C-- >0;){var H=this.rungeKutta();t=Math.abs(e/H-1)>16)/this.range},C.prototype.getNextBetween=function(C,e){return C+this.getNext()*(e-C)},C}();return Rc.PseudoRandom=t,Rc}var Nc,Ic={},zc={};function jc(){if(Nc)return zc;Nc=1,Object.defineProperty(zc,"__esModule",{value:!0});var C=function(){function C(C){this.scale=C,this.AB=0,this.AD=0,this.A2=0}return C.prototype.addVariable=function(C){var e=this.scale/C.scale,t=C.offset/C.scale,H=C.weight;this.AB+=H*e*t,this.AD+=H*e*C.desiredPosition,this.A2+=H*e*e},C.prototype.getPosn=function(){return(this.AD-this.AB)/this.A2},C}();zc.PositionStats=C;var e=function(){function C(C,e,t,H){void 0===H&&(H=!1),this.left=C,this.right=e,this.gap=t,this.equality=H,this.active=!1,this.unsatisfiable=!1,this.left=C,this.right=e,this.gap=t,this.equality=H}return C.prototype.slack=function(){return this.unsatisfiable?Number.MAX_VALUE:this.right.scale*this.right.position()-this.gap-this.left.scale*this.left.position()},C}();zc.Constraint=e;var t=function(){function C(C,e,t){void 0===e&&(e=1),void 0===t&&(t=1),this.desiredPosition=C,this.weight=e,this.scale=t,this.offset=0}return C.prototype.dfdv=function(){return 2*this.weight*(this.position()-this.desiredPosition)},C.prototype.position=function(){return(this.block.ps.scale*this.block.posn+this.offset)/this.scale},C.prototype.visitNeighbours=function(C,e){var t=function(t,H){return t.active&&C!==H&&e(t,H)};this.cOut.forEach((function(C){return t(C,C.right)})),this.cIn.forEach((function(C){return t(C,C.left)}))},C}();zc.Variable=t;var H=function(){function e(e){this.vars=[],e.offset=0,this.ps=new C(e.scale),this.addVariable(e)}return e.prototype.addVariable=function(C){C.block=this,this.vars.push(C),this.ps.addVariable(C),this.posn=this.ps.getPosn()},e.prototype.updateWeightedPosition=function(){this.ps.AB=this.ps.AD=this.ps.A2=0;for(var C=0,e=this.vars.length;C=0?this.inactive.push(e):this.bs.merge(e)}}},C.prototype.solve=function(){this.satisfy();for(var C=Number.MAX_VALUE,e=this.bs.cost();Math.abs(C-e)>1e-4;)this.satisfy(),C=e,e=this.bs.cost();return e},C.LAGRANGIAN_TOLERANCE=-1e-4,C.ZERO_UPPERBOUND=-1e-10,C}();return zc.Solver=i,zc.removeOverlapInOneDimension=function(C,H,V){for(var L=C.map((function(C){return new t(C.desiredCenter)})),n=[],r=C.length,o=0;o0)}return null}}return C.prototype.clear=function(){this._root=null,this.size=0},C.prototype.find=function(C){for(var e=this._root;null!==e;){var t=this._comparator(C,e.data);if(0===t)return e.data;e=e.get_child(t>0)}return null},C.prototype.lowerBound=function(C){return this._bound(C,this._comparator)},C.prototype.upperBound=function(C){var e=this._comparator;return this._bound(C,(function(C,t){return e(t,C)}))},C.prototype.min=function(){var C=this._root;if(null===C)return null;for(;null!==C.left;)C=C.left;return C.data},C.prototype.max=function(){var C=this._root;if(null===C)return null;for(;null!==C.right;)C=C.right;return C.data},C.prototype.iterator=function(){return new H(this)},C.prototype.each=function(C){for(var e,t=this.iterator();null!==(e=t.next());)C(e)},C.prototype.reach=function(C){for(var e,t=this.iterator();null!==(e=t.prev());)C(e)},C.prototype._bound=function(C,e){for(var t=this._root,H=this.iterator();null!==t;){var V=this._comparator(C,t.data);if(0===V)return H._cursor=t,H;H._ancestors.push(t),t=t.get_child(V>0)}for(var i=H._ancestors.length-1;i>=0;--i)if(e(C,(t=H._ancestors[i]).data)>0)return H._cursor=t,H._ancestors.length=i,H;return H._ancestors.length=0,H},C}();Uc.TreeBase=t;var H=function(){function C(C){this._tree=C,this._ancestors=[],this._cursor=null}return C.prototype.data=function(){return null!==this._cursor?this._cursor.data:null},C.prototype.next=function(){if(null===this._cursor){var C=this._tree._root;null!==C&&this._minNode(C)}else{var e;if(null===this._cursor.right)do{if(e=this._cursor,!this._ancestors.length){this._cursor=null;break}this._cursor=this._ancestors.pop()}while(this._cursor.right===e);else this._ancestors.push(this._cursor),this._minNode(this._cursor.right)}return null!==this._cursor?this._cursor.data:null},C.prototype.prev=function(){if(null===this._cursor){var C=this._tree._root;null!==C&&this._maxNode(C)}else{var e;if(null===this._cursor.left)do{if(e=this._cursor,!this._ancestors.length){this._cursor=null;break}this._cursor=this._ancestors.pop()}while(this._cursor.left===e);else this._ancestors.push(this._cursor),this._maxNode(this._cursor.left)}return null!==this._cursor?this._cursor.data:null},C.prototype._minNode=function(C){for(;null!==C.left;)this._ancestors.push(C),C=C.left;this._cursor=C},C.prototype._maxNode=function(C){for(;null!==C.right;)this._ancestors.push(C),C=C.right;this._cursor=C},C}();Uc.Iterator=H;var V=function(){function C(C){this.data=C,this.left=null,this.right=null,this.red=!0}return C.prototype.get_child=function(C){return C?this.right:this.left},C.prototype.set_child=function(C,e){C?this.right=e:this.left=e},C}(),i=function(C){function t(e){var t=C.call(this)||this;return t._root=null,t._comparator=e,t.size=0,t}return e(t,C),t.prototype.insert=function(C){var e=!1;if(null===this._root)this._root=new V(C),e=!0,this.size++;else{var H=new V(void 0),i=!1,L=!1,n=null,r=H,o=null,a=this._root;for(r.right=this._root;;){if(null===a?(a=new V(C),o.set_child(i,a),e=!0,this.size++):t.is_red(a.left)&&t.is_red(a.right)&&(a.red=!0,a.left.red=!1,a.right.red=!1),t.is_red(a)&&t.is_red(o)){var M=r.right===n;a===o.get_child(L)?r.set_child(M,t.single_rotate(n,!L)):r.set_child(M,t.double_rotate(n,!L))}var s=this._comparator(a.data,C);if(0===s)break;L=i,i=s<0,null!==n&&(r=n),n=o,o=a,a=a.get_child(i)}this._root=H.right}return this._root.red=!1,e},t.prototype.remove=function(C){if(null===this._root)return!1;var e=new V(void 0),H=e;H.right=this._root;for(var i=null,L=null,n=null,r=!0;null!==H.get_child(r);){var o=r;L=i,i=H,H=H.get_child(r);var a=this._comparator(C,H.data);if(r=a>0,0===a&&(n=H),!t.is_red(H)&&!t.is_red(H.get_child(r)))if(t.is_red(H.get_child(!r))){var M=t.single_rotate(H,r);i.set_child(o,M),i=M}else if(!t.is_red(H.get_child(!r))){var s=i.get_child(!o);if(null!==s)if(t.is_red(s.get_child(!o))||t.is_red(s.get_child(o))){var l=L.right===i;t.is_red(s.get_child(o))?L.set_child(l,t.double_rotate(i,o)):t.is_red(s.get_child(!o))&&L.set_child(l,t.single_rotate(i,o));var d=L.get_child(l);d.red=!0,H.red=!0,d.left.red=!1,d.right.red=!1}else i.red=!1,s.red=!0,H.red=!0}}return null!==n&&(n.data=H.data,i.set_child(i.right===H,H.get_child(null===H.left)),this.size--),this._root=e.right,null!==this._root&&(this._root.red=!1),null!==n},t.is_red=function(C){return null!==C&&C.red},t.single_rotate=function(C,e){var t=C.get_child(!e);return C.set_child(!e,t.get_child(e)),t.set_child(e,C),C.red=!0,t.red=!1,t},t.double_rotate=function(C,e){return C.set_child(!e,t.single_rotate(C.get_child(!e),!e)),t.single_rotate(C,e)},t}(t);return Uc.RBTree=i,Uc}function Yc(){if(Wc)return Ic;Wc=1;var C,e=TC&&TC.__extends||(C=function(e,t){return C=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(C,e){C.__proto__=e}||function(C,e){for(var t in e)e.hasOwnProperty(t)&&(C[t]=e[t])},C(e,t)},function(e,t){function H(){this.constructor=e}C(e,t),e.prototype=null===t?Object.create(t):(H.prototype=t.prototype,new H)});Object.defineProperty(Ic,"__esModule",{value:!0});var t=jc(),H=$c();function V(C){return C.bounds=void 0!==C.leaves?C.leaves.reduce((function(C,e){return e.bounds.union(C)}),i.empty()):i.empty(),void 0!==C.groups&&(C.bounds=C.groups.reduce((function(C,e){return V(e).union(C)}),C.bounds)),C.bounds=C.bounds.inflate(C.padding),C.bounds}Ic.computeGroupBounds=V;var i=function(){function C(C,e,t,H){this.x=C,this.X=e,this.y=t,this.Y=H}return C.empty=function(){return new C(Number.POSITIVE_INFINITY,Number.NEGATIVE_INFINITY,Number.POSITIVE_INFINITY,Number.NEGATIVE_INFINITY)},C.prototype.cx=function(){return(this.x+this.X)/2},C.prototype.cy=function(){return(this.y+this.Y)/2},C.prototype.overlapX=function(C){var e=this.cx(),t=C.cx();return e<=t&&C.x0?t[0]:null},C.prototype.vertices=function(){return[{x:this.x,y:this.y},{x:this.X,y:this.y},{x:this.X,y:this.Y},{x:this.x,y:this.Y}]},C.lineIntersection=function(C,e,t,H,V,i,L,n){var r=t-C,o=L-V,a=H-e,M=n-i,s=M*r-o*a;if(0==s)return null;var l=C-V,d=e-i,u=(o*d-M*l)/s,c=(r*d-a*l)/s;return u>=0&&u<=1&&c>=0&&c<=1?{x:C+u*r,y:e+u*a}:null},C.prototype.inflate=function(e){return new C(this.x-e,this.X+e,this.y-e,this.Y+e)},C}();Ic.Rectangle=i,Ic.makeEdgeBetween=function(C,e,t){var H=C.rayIntersection(e.cx(),e.cy())||{x:C.cx(),y:C.cy()},V=e.rayIntersection(C.cx(),C.cy())||{x:e.cx(),y:e.cy()},i=V.x-H.x,L=V.y-H.y,n=Math.sqrt(i*i+L*L),r=n-t;return{sourceIntersection:H,targetIntersection:V,arrowStart:{x:H.x+r*i/n,y:H.y+r*L/n}}},Ic.makeEdgeTo=function(C,e,t){var H=e.rayIntersection(C.x,C.y);H||(H={x:e.cx(),y:e.cy()});var V=H.x-C.x,i=H.y-C.y,L=Math.sqrt(V*V+i*i);return{x:H.x-t*V/L,y:H.y-t*i/L}};var L=function(C,e,t){this.v=C,this.r=e,this.pos=t,this.prev=o(),this.next=o()},n=function(C,e,t){this.isOpen=C,this.v=e,this.pos=t};function r(C,e){return C.pos>e.pos?1:C.pos0&&(C[t].insert(V),V[H].insert(C))};t("next","prev"),t("prev","next")}};function s(C,e,t,H){void 0===H&&(H=!1);var V=C.padding,i=void 0!==C.groups?C.groups.length:0,L=void 0!==C.leaves?C.leaves.length:0,n=i?C.groups.reduce((function(C,H){return C.concat(s(H,e,t,!0))}),[]):[],r=(H?2:0)+L+i,o=new Array(r),a=new Array(r),M=0,d=function(C,e){a[M]=C,o[M++]=e};if(H){var u=C.bounds,c=e.getCentre(u),A=e.getSize(u)/2,h=e.getOpen(u),m=e.getClose(u),f=c-A+V/2,p=c+A-V/2;C.minVar.desiredPosition=f,d(e.makeRect(h,m,f,V),C.minVar),C.maxVar.desiredPosition=p,d(e.makeRect(h,m,p,V),C.maxVar)}L&&C.leaves.forEach((function(C){return d(C.bounds,C.variable)})),i&&C.groups.forEach((function(C){var t=C.bounds;d(e.makeRect(e.getOpen(t),e.getClose(t),e.getCentre(t),e.getSize(t)),C.minVar)}));var g=l(a,o,e,t);return i&&(o.forEach((function(C){C.cOut=[],C.cIn=[]})),g.forEach((function(C){C.left.cOut.push(C),C.right.cIn.push(C)})),C.groups.forEach((function(C){var t=(C.padding-e.getSize(C.bounds))/2;C.minVar.cIn.forEach((function(C){return C.gap+=t})),C.minVar.cOut.forEach((function(e){e.left=C.maxVar,e.gap+=t}))}))),n.concat(g)}function l(C,e,H,V){var i,a=C.length,M=2*a;console.assert(e.length>=a);var s=new Array(M);for(i=0;iC[t]&&(C[t]=e)}i=C}))}},C.prototype.createAlignment=function(C){var e=this,H=this.nodes[C.offsets[0].node].variable;this.makeFeasible(C);var V="x"===C.axis?this.xConstraints:this.yConstraints;C.offsets.slice(1).forEach((function(C){var i=e.nodes[C.node].variable;V.push(new t.Constraint(H,i,C.offset,!0))}))},C.prototype.createConstraints=function(C){var e=this,t=function(C){return void 0===C.type||"separation"===C.type};this.xConstraints=C.filter((function(C){return"x"===C.axis&&t(C)})).map((function(C){return e.createSeparation(C)})),this.yConstraints=C.filter((function(C){return"y"===C.axis&&t(C)})).map((function(C){return e.createSeparation(C)})),C.filter((function(C){return"alignment"===C.type})).forEach((function(C){return e.createAlignment(C)}))},C.prototype.setupVariablesAndBounds=function(C,e,t,H){this.nodes.forEach((function(V,L){V.fixed?(V.variable.weight=V.fixedWeight?V.fixedWeight:1e3,t[L]=H(V)):V.variable.weight=1;var n=(V.width||0)/2,r=(V.height||0)/2,o=C[L],a=e[L];V.bounds=new i(o-n,o+n,a-r,a+r)}))},C.prototype.xProject=function(C,e,t){(this.rootGroup||this.avoidOverlaps||this.xConstraints)&&this.project(C,e,C,t,(function(C){return C.px}),this.xConstraints,c,(function(C){return C.bounds.setXCentre(t[C.variable.index]=C.variable.position())}),(function(C){var e=t[C.minVar.index]=C.minVar.position(),H=t[C.maxVar.index]=C.maxVar.position(),V=C.padding/2;C.bounds.x=e-V,C.bounds.X=H+V}))},C.prototype.yProject=function(C,e,t){(this.rootGroup||this.yConstraints)&&this.project(C,e,e,t,(function(C){return C.py}),this.yConstraints,A,(function(C){return C.bounds.setYCentre(t[C.variable.index]=C.variable.position())}),(function(C){var e=t[C.minVar.index]=C.minVar.position(),H=t[C.maxVar.index]=C.maxVar.position(),V=C.padding/2;C.bounds.y=e-V,C.bounds.Y=H+V}))},C.prototype.projectFunctions=function(){var C=this;return[function(e,t,H){return C.xProject(e,t,H)},function(e,t,H){return C.yProject(e,t,H)}]},C.prototype.project=function(C,e,t,H,i,L,n,r,o){this.setupVariablesAndBounds(C,e,H,i),this.rootGroup&&this.avoidOverlaps&&(V(this.rootGroup),L=L.concat(n(this.rootGroup))),this.solve(this.variables,L,t,H),this.nodes.forEach(r),this.rootGroup&&this.avoidOverlaps&&(this.groups.forEach(o),V(this.rootGroup))},C.prototype.solve=function(C,e,H,V){var i=new t.Solver(C,e);i.setStartingPositions(H),i.setDesiredPositions(V),i.solve()},C}();return Ic.Projection=m,Ic}var Xc,qc,Qc={},Kc={};function Jc(){if(Xc)return Kc;Xc=1,Object.defineProperty(Kc,"__esModule",{value:!0});var C=function(){function C(C){this.elem=C,this.subheaps=[]}return C.prototype.toString=function(C){for(var e="",t=!1,H=0;HM&&(o.d=M,o.prev=n,H.reduceKey(o.q,o,(function(C,e){return C.q=e})))}}return i},V}();return Qc.Calculator=V,Qc}var eA,tA={};function HA(){if(eA)return tA;eA=1;var C,e=TC&&TC.__extends||(C=function(e,t){return C=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(C,e){C.__proto__=e}||function(C,e){for(var t in e)e.hasOwnProperty(t)&&(C[t]=e[t])},C(e,t)},function(e,t){function H(){this.constructor=e}C(e,t),e.prototype=null===t?Object.create(t):(H.prototype=t.prototype,new H)});Object.defineProperty(tA,"__esModule",{value:!0});var t=Yc(),H=function(){};tA.Point=H;var V=function(C,e,t,H){this.x1=C,this.y1=e,this.x2=t,this.y2=H};tA.LineSegment=V;var i=function(C){function t(){return null!==C&&C.apply(this,arguments)||this}return e(t,C),t}(H);function L(C,e,t){return(e.x-C.x)*(t.y-C.y)-(t.x-C.x)*(e.y-C.y)}function n(C,e,t){return L(C,e,t)>0}function r(C,e,t){return L(C,e,t)<0}function o(C,e){var t,H,V,i,L=e.length-1;if(r(C,e[1],e[0])&&!n(C,e[L-1],e[0]))return 0;for(t=0,H=L;;){if(H-t==1)return n(C,e[t],e[H])?t:H;if((i=r(C,e[(V=Math.floor((t+H)/2))+1],e[V]))&&!n(C,e[V-1],e[V]))return V;n(C,e[t+1],e[t])?i||n(C,e[t],e[V])?H=V:t=V:i&&r(C,e[t],e[V])?H=V:t=V}}function a(C,e){var t,H,V,i,L=e.length-1;if(n(C,e[L-1],e[0])&&!r(C,e[1],e[0]))return 0;for(t=0,H=L;;){if(H-t==1)return r(C,e[t],e[H])?t:H;if(i=r(C,e[(V=Math.floor((t+H)/2))+1],e[V]),n(C,e[V-1],e[V])&&!i)return V;r(C,e[t+1],e[t])?i?r(C,e[t],e[V])?H=V:t=V:H=V:i?t=V:n(C,e[t],e[V])?H=V:t=V}}function M(C,e,t,H,V,i){var L,n;n=H(C[L=t(e[0],C)],e);for(var r=!1;!r;){for(r=!0;L===C.length-1&&(L=0),!V(e[n],C[L],C[L+1]);)++L;for(;0===n&&(n=e.length-1),!i(C[L],e[n],e[n-1]);)--n,r=!1}return{t1:L,t2:n}}function s(C,e){return M(C,e,o,a,n,r)}tA.PolyPoint=i,tA.isLeft=L,tA.ConvexHull=function(C){var e,t=C.slice(0).sort((function(C,e){return C.x!==e.x?e.x-C.x:e.y-C.y})),H=C.length,V=t[0].x;for(e=1;e=0&&t[e].x===a;e--);for(r=e+1,e=i;++e<=r;)if(!(L(t[0],t[r],t[e])>=0&&e1&&!(L(n[n.length-2],n[n.length-1],t[e])>0);)n.length-=1;0!=e&&n.push(t[e])}o!=r&&n.push(t[o]);var M=n.length;for(e=r;--e>=i;)if(!(L(t[o],t[i],t[e])>=0&&e>i)){for(;n.length>M&&!(L(n[n.length-2],n[n.length-1],t[e])>0);)n.length-=1;0!=e&&n.push(t[e])}}return n},tA.clockwiseRadialSweep=function(C,e,t){e.slice(0).sort((function(e,t){return Math.atan2(e.y-C.y,e.x-C.x)-Math.atan2(t.y-C.y,t.x-C.x)})).forEach(t)},tA.tangent_PolyPolyC=M,tA.LRtangent_PolyPolyC=function(C,e){var t=s(e,C);return{t1:t.t2,t2:t.t1}},tA.RLtangent_PolyPolyC=s,tA.LLtangent_PolyPolyC=function(C,e){return M(C,e,a,a,r,r)},tA.RRtangent_PolyPolyC=function(C,e){return M(C,e,o,o,n,n)};var l=function(C,e){this.t1=C,this.t2=e};tA.BiTangent=l;var d=function(){};tA.BiTangents=d;var u=function(C){function t(){return null!==C&&C.apply(this,arguments)||this}return e(t,C),t}(H);tA.TVGPoint=u;var c=function(C,e,t,H){this.id=C,this.polyid=e,this.polyvertid=t,this.p=H,H.vv=this};tA.VisibilityVertex=c;var A=function(){function C(C,e){this.source=C,this.target=e}return C.prototype.length=function(){var C=this.source.p.x-this.target.p.x,e=this.source.p.y-this.target.p.y;return Math.sqrt(C*C+e*e)},C}();tA.VisibilityEdge=A;var h=function(){function C(C,e){if(this.P=C,this.V=[],this.E=[],e)this.V=e.V.slice(0),this.E=e.E.slice(0);else{for(var t=C.length,H=0;H0&&this.E.push(new A(V[i-1].vv,n))}V.length>1&&this.E.push(new A(V[0].vv,V[V.length-1].vv))}for(H=0;H0)return!0;return!1},C}();function m(C,e){for(var H=[],V=1,i=e.length;V=0&&A>=0&&h<0&&m>=0&&f>=0&&p<0?V.ll=new l(i,n):c<=0&&A<=0&&h>0&&m<=0&&f<=0&&p>0?V.rr=new l(i,n):c<=0&&A>0&&h<=0&&m>=0&&f<0&&p>=0?V.rl=new l(i,n):c>=0&&A<0&&h>=0&&m<=0&&f>0&&p<=0&&(V.lr=new l(i,n))}return V}function p(C,e){return!C.every((function(C){return!function(C,e){for(var t=1,H=e.length;t0)return!0}return!1},tA}var VA,iA,LA,nA={};function rA(){if(VA)return nA;VA=1,Object.defineProperty(nA,"__esModule",{value:!0});var C=10,e=(1+Math.sqrt(5))/2,t=1e-4;return nA.applyPacking=function(H,V,i,L,n,r){void 0===n&&(n=1),void 0===r&&(r=!0);var o=0,a=0,M=V,s=i,l=(n=void 0!==n?n:1,L=void 0!==L?L:0,0),d=0,u=0,c=0,A=[];function h(C,e){A=[],l=0,d=0,c=a;for(var t=0;t=e.height&&A[i].x+A[i].width+e.width+C-H<=t){V=A[i];break}A.push(e),void 0!==V?(e.x=V.x+V.width+C,e.y=V.bottom,e.space_left=e.height,e.bottom=e.y,V.space_left-=e.height+C,V.bottom+=e.height+C):(e.y=c,c+=e.height+C,e.x=o,e.bottom=e.y,e.space_left=e.height),e.y+e.height-d>-t&&(d=e.y+e.height-a),e.x+e.width-l>-t&&(l=e.x+e.width-o)}0!=H.length&&(function(C){C.forEach((function(C){!function(C){var e=Number.MAX_VALUE,t=Number.MAX_VALUE,H=0,V=0;C.array.forEach((function(C){var i=void 0!==C.width?C.width:L,n=void 0!==C.height?C.height:L;i/=2,n/=2,H=Math.max(C.x+i,H),e=Math.min(C.x-i,e),V=Math.max(C.y+n,V),t=Math.min(C.y-n,t)})),C.width=H-e,C.height=V-t}(C)}))}(H),function(H,V){var i=Number.POSITIVE_INFINITY,L=0;H.sort((function(C,e){return e.height-C.height})),u=H.reduce((function(C,e){return C.widthu||d>t;){if(1!=s){var c=r-(r-n)/e;a=h(H,c)}if(0!=s){var A=n+(r-n)/e;M=h(H,A)}if(l=Math.abs(c-A),d=Math.abs(a-M),aM?(n=c,c=A,a=M,s=1):(r=A,A=c,M=a,s=0),o++>100)break}h(H,L)}(H),r&&function(C){C.forEach((function(C){var e={x:0,y:0};C.array.forEach((function(C){e.x+=C.x,e.y+=C.y})),e.x/=C.array.length,e.y/=C.array.length;var t={x:e.x-C.width/2,y:e.y-C.height/2},H={x:C.x-t.x+M/2-l/2,y:C.y-t.y+s/2-d/2};C.array.forEach((function(C){C.x+=H.x,C.y+=H.y}))}))}(H))},nA.separateGraphs=function(C,e){for(var t={},H={},V=[],i=0,L=0;L0){var e=0;this._links.forEach((function(C){e=Math.max(e,C.source,C.target)})),this._nodes=new Array(++e);for(var t=0;t0?C:0:C>0&&(this._running||(this._running=!0,this.trigger({type:e.start,alpha:this._alpha=C}),this.kick())),this):this._alpha},C.prototype.getLinkLength=function(C){return"function"==typeof this._linkDistance?+this._linkDistance(C):this._linkDistance},C.setLinkLength=function(C,e){C.length=e},C.prototype.getLinkType=function(C){return"function"==typeof this._linkType?this._linkType(C):0},C.prototype.symmetricDiffLinkLengths=function(C,e){var t=this;return void 0===e&&(e=1),this.linkDistance((function(e){return C*e.length})),this._linkLengthCalculator=function(){return H.symmetricDiffLinkLengths(t._links,t.linkAccessor,e)},this},C.prototype.jaccardLinkLengths=function(C,e){var t=this;return void 0===e&&(e=1),this.linkDistance((function(e){return C*e.length})),this._linkLengthCalculator=function(){return H.jaccardLinkLengths(t._links,t.linkAccessor,e)},this},C.prototype.start=function(e,t,n,r,o,a){var M=this;void 0===e&&(e=0),void 0===t&&(t=0),void 0===n&&(n=0),void 0===r&&(r=0),void 0===o&&(o=!0),void 0===a&&(a=!0);var s=this.nodes().length,l=s+2*this._groups.length;this._links.length;var d,u=this._canvasSize[0],c=this._canvasSize[1],A=new Array(l),h=new Array(l),m=null,f=this._avoidOverlaps;this._nodes.forEach((function(C,e){C.index=e,void 0===C.x&&(C.x=u/2,C.y=c/2),A[e]=C.x,h[e]=C.y})),this._linkLengthCalculator&&this._linkLengthCalculator(),this._distanceMatrix?d=this._distanceMatrix:(d=new L.Calculator(l,this._links,C.getSourceIndex,C.getTargetIndex,(function(C){return M.getLinkLength(C)})).DistanceMatrix(),m=V.Descent.createSquareMatrix(l,(function(){return 2})),this._links.forEach((function(C){"number"==typeof C.source&&(C.source=M._nodes[C.source]),"number"==typeof C.target&&(C.target=M._nodes[C.target])})),this._links.forEach((function(e){var t=C.getSourceIndex(e),H=C.getTargetIndex(e);m[t][H]=m[H][t]=e.weight||1})));var p=V.Descent.createSquareMatrix(l,(function(C,e){return d[C][e]}));if(this._rootGroup&&void 0!==this._rootGroup.groups){var g=s;this._groups.forEach((function(C){!function(C,e,t,H){m[C][e]=m[e][C]=t,p[C][e]=p[e][C]=H}(g,g+1,M._groupCompactness,.1),A[g]=0,h[g++]=0,A[g]=0,h[g++]=0}))}else this._rootGroup={leaves:this._nodes,groups:[]};var v=this._constraints||[];this._directedLinkConstraints&&(this.linkAccessor.getMinSeparation=this._directedLinkConstraints.getMinSeparation,v=v.concat(H.generateDirectedEdgeConstraints(s,this._links,this._directedLinkConstraints.axis,this.linkAccessor))),this.avoidOverlaps(!1),this._descent=new V.Descent([A,h],p),this._descent.locks.clear();for(g=0;g0&&(this._descent.project=new i.Projection(this._nodes,this._groups,this._rootGroup,v).projectFunctions()),this._descent.run(t),this.separateOverlappingComponents(u,c,a),this.avoidOverlaps(f),f&&(this._nodes.forEach((function(C,e){C.x=A[e],C.y=h[e]})),this._descent.project=new i.Projection(this._nodes,this._groups,this._rootGroup,v,!0).projectFunctions(),this._nodes.forEach((function(C,e){A[e]=C.x,h[e]=C.y}))),this._descent.G=m,this._descent.run(n),r){this._descent.snapStrength=1e3,this._descent.snapGridSize=this._nodes[0].width,this._descent.numGridSnapNodes=s,this._descent.scaleSnapByMaxH=s!=l;var S=V.Descent.createSquareMatrix(l,(function(C,e){return C>=s||e>=s?m[C][e]:0}));this._descent.G=S,this._descent.run(r)}return this.updateNodePositions(),this.separateOverlappingComponents(u,c,a),o?this.resume():this},C.prototype.initialLayout=function(e,t,H){if(this._groups.length>0&&e>0){var V=this._nodes.length,i=this._links.map((function(C){return{source:C.source.index,target:C.target.index}})),L=this._nodes.map((function(C){return{index:C.index}}));this._groups.forEach((function(C,e){L.push({index:C.index=V+e})})),this._groups.forEach((function(C,e){void 0!==C.leaves&&C.leaves.forEach((function(e){return i.push({source:C.index,target:e.index})})),void 0!==C.groups&&C.groups.forEach((function(e){return i.push({source:C.index,target:e.index})}))})),(new C).size(this.size()).nodes(L).links(i).avoidOverlaps(!1).linkDistance(this.linkDistance()).symmetricDiffLinkLengths(5).convergenceThreshold(1e-4).start(e,0,0,0,!1),this._nodes.forEach((function(C){t[C.index]=L[C.index].x,H[C.index]=L[C.index].y}))}else this._descent.run(e)},C.prototype.separateOverlappingComponents=function(C,e,t){var H=this;if(void 0===t&&(t=!0),!this._distanceMatrix&&this._handleDisconnected){var V=this._descent.x[0],i=this._descent.x[1];this._nodes.forEach((function(C,e){C.x=V[e],C.y=i[e]}));var L=r.separateGraphs(this._nodes,this._links);r.applyPacking(L,C,e,this._defaultNodeSize,1,t),this._nodes.forEach((function(C,e){H._descent.x[0][e]=C.x,H._descent.x[1][e]=C.y,C.bounds&&(C.bounds.setXCentre(C.x),C.bounds.setYCentre(C.y))}))}},C.prototype.resume=function(){return this.alpha(.1)},C.prototype.stop=function(){return this.alpha(0)},C.prototype.prepareEdgeRouting=function(C){void 0===C&&(C=0),this._visibilityGraph=new n.TangentVisibilityGraph(this._nodes.map((function(e){return e.bounds.inflate(-C).vertices()})))},C.prototype.routeEdge=function(C,e,t){void 0===e&&(e=5);var H=[],V=new n.TangentVisibilityGraph(this._visibilityGraph.P,{V:this._visibilityGraph.V,E:this._visibilityGraph.E}),r={x:C.source.x,y:C.source.y},o={x:C.target.x,y:C.target.y},a=V.addPoint(r,C.source.index),M=V.addPoint(o,C.target.index);V.addEdgeIfVisible(r,o,C.source.index,C.target.index),void 0!==t&&t(V);var s=new L.Calculator(V.V.length,V.E,(function(C){return C.source.id}),(function(C){return C.target.id}),(function(C){return C.length()})).PathFromNodeToNode(a.id,M.id);if(1===s.length||s.length===V.V.length){var l=i.makeEdgeBetween(C.source.innerBounds,C.target.innerBounds,e);H=[l.sourceIntersection,l.arrowStart]}else{for(var d=s.length-2,u=V.V[s[d]].p,c=V.V[s[0]].p,A=(H=[C.source.innerBounds.rayIntersection(u.x,u.y)],d);A>=0;--A)H.push(V.V[s[A]].p);H.push(i.makeEdgeTo(c,C.target.innerBounds,e))}return H},C.getSourceIndex=function(C){return"number"==typeof C.source?C.source:C.source.index},C.getTargetIndex=function(C){return"number"==typeof C.target?C.target:C.target.index},C.linkId=function(e){return C.getSourceIndex(e)+"-"+C.getTargetIndex(e)},C.dragStart=function(e){o(e)?C.storeOffset(e,C.dragOrigin(e)):(C.stopNode(e),e.fixed|=2)},C.stopNode=function(C){C.px=C.x,C.py=C.y},C.storeOffset=function(e,t){void 0!==e.leaves&&e.leaves.forEach((function(e){e.fixed|=2,C.stopNode(e),e._dragGroupOffsetX=e.x-t.x,e._dragGroupOffsetY=e.y-t.y})),void 0!==e.groups&&e.groups.forEach((function(e){return C.storeOffset(e,t)}))},C.dragOrigin=function(C){return o(C)?{x:C.bounds.cx(),y:C.bounds.cy()}:C},C.drag=function(e,t){o(e)?(void 0!==e.leaves&&e.leaves.forEach((function(C){e.bounds.setXCentre(t.x),e.bounds.setYCentre(t.y),C.px=C._dragGroupOffsetX+t.x,C.py=C._dragGroupOffsetY+t.y})),void 0!==e.groups&&e.groups.forEach((function(e){return C.drag(e,t)}))):(e.px=t.x,e.py=t.y)},C.dragEnd=function(e){o(e)?(void 0!==e.leaves&&e.leaves.forEach((function(e){C.dragEnd(e),delete e._dragGroupOffsetX,delete e._dragGroupOffsetY})),void 0!==e.groups&&e.groups.forEach(C.dragEnd)):e.fixed&=-7},C.mouseOver=function(C){C.fixed|=4,C.px=C.x,C.py=C.y},C.mouseOut=function(C){C.fixed&=-5},C}();C.Layout=a}(kc)),kc}var aA,MA={},sA={};var lA,dA,uA={};function cA(){if(dA)return MA;dA=1,Object.defineProperty(MA,"__esModule",{value:!0});var C=function(){if(aA)return sA;aA=1;var C,e=TC&&TC.__extends||(C=function(e,t){return C=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(C,e){C.__proto__=e}||function(C,e){for(var t in e)e.hasOwnProperty(t)&&(C[t]=e[t])},C(e,t)},function(e,t){function H(){this.constructor=e}C(e,t),e.prototype=null===t?Object.create(t):(H.prototype=t.prototype,new H)});Object.defineProperty(sA,"__esModule",{value:!0});var t=oA(),H=function(C){function H(){var e=C.call(this)||this;e.event=d3.dispatch(t.EventType[t.EventType.start],t.EventType[t.EventType.tick],t.EventType[t.EventType.end]);var H=e;return e.drag=function(){if(!C)var C=d3.behavior.drag().origin(t.Layout.dragOrigin).on("dragstart.d3adaptor",t.Layout.dragStart).on("drag.d3adaptor",(function(C){t.Layout.drag(C,d3.event),H.resume()})).on("dragend.d3adaptor",t.Layout.dragEnd);if(!arguments.length)return C;this.call(C)},e}return e(H,C),H.prototype.trigger=function(C){var e={type:t.EventType[C.type],alpha:C.alpha,stress:C.stress};this.event[e.type](e)},H.prototype.kick=function(){var e=this;d3.timer((function(){return C.prototype.tick.call(e)}))},H.prototype.on=function(C,e){return"string"==typeof C?this.event.on(C,e):this.event.on(t.EventType[C],e),this},H}(t.Layout);return sA.D3StyleLayoutAdaptor=H,sA.d3adaptor=function(){return new H},sA}(),e=function(){if(lA)return uA;lA=1;var C,e=TC&&TC.__extends||(C=function(e,t){return C=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(C,e){C.__proto__=e}||function(C,e){for(var t in e)e.hasOwnProperty(t)&&(C[t]=e[t])},C(e,t)},function(e,t){function H(){this.constructor=e}C(e,t),e.prototype=null===t?Object.create(t):(H.prototype=t.prototype,new H)});Object.defineProperty(uA,"__esModule",{value:!0});var t=oA(),H=function(C){function H(e){var H=C.call(this)||this;H.d3Context=e,H.event=e.dispatch(t.EventType[t.EventType.start],t.EventType[t.EventType.tick],t.EventType[t.EventType.end]);var V=H;return H.drag=function(){if(!C)var C=e.drag().subject(t.Layout.dragOrigin).on("start.d3adaptor",t.Layout.dragStart).on("drag.d3adaptor",(function(C){t.Layout.drag(C,e.event),V.resume()})).on("end.d3adaptor",t.Layout.dragEnd);if(!arguments.length)return C;arguments[0].call(C)},H}return e(H,C),H.prototype.trigger=function(C){var e={type:t.EventType[C.type],alpha:C.alpha,stress:C.stress};this.event.call(e.type,e)},H.prototype.kick=function(){var e=this,t=this.d3Context.timer((function(){return C.prototype.tick.call(e)&&t.stop()}))},H.prototype.on=function(C,e){return"string"==typeof C?this.event.on(C,e):this.event.on(t.EventType[C],e),this},H}(t.Layout);return uA.D3StyleLayoutAdaptor=H,uA}();return MA.d3adaptor=function(t){return!t||function(C){var e=/^3\./;return C.version&&null!==C.version.match(e)}(t)?new C.D3StyleLayoutAdaptor:new e.D3StyleLayoutAdaptor(t)},MA}var AA,hA={};function mA(){if(AA)return hA;AA=1,Object.defineProperty(hA,"__esModule",{value:!0});var C=Yc(),e=jc(),t=CA(),H=function(C,e,t){this.id=C,this.rect=e,this.children=t,this.leaf=void 0===t||0===t.length};hA.NodeWrapper=H;var V=function(C,e,t,H,V){void 0===H&&(H=null),void 0===V&&(V=null),this.id=C,this.x=e,this.y=t,this.node=H,this.line=V};hA.Vert=V;var i=function(){function C(e,t){this.s=e,this.t=t;var H=C.findMatch(e,t),V=t.slice(0).reverse(),i=C.findMatch(e,V);H.length>=i.length?(this.length=H.length,this.si=H.si,this.ti=H.ti,this.reversed=!1):(this.length=i.length,this.si=i.si,this.ti=t.length-i.ti-i.length,this.reversed=!0)}return C.findMatch=function(C,e){for(var t=C.length,H=e.length,V={length:0,si:-1,ti:-1},i=new Array(t),L=0;LV.length&&(V.length=r,V.si=L-r+1,V.ti=n-r+1)}else i[L][n]=0}return V},C.prototype.getSequence=function(){return this.length>=0?this.s.slice(this.si,this.si+this.length):[]},C}();hA.LongestCommonSubsequence=i;var L=function(){function L(e,t,i){var L=this;void 0===i&&(i=12),this.originalnodes=e,this.groupPadding=i,this.leaves=null,this.nodes=e.map((function(C,e){return new H(e,t.getBounds(C),t.getChildren(C))})),this.leaves=this.nodes.filter((function(C){return C.leaf})),this.groups=this.nodes.filter((function(C){return!C.leaf})),this.cols=this.getGridLines("x"),this.rows=this.getGridLines("y"),this.groups.forEach((function(C){return C.children.forEach((function(e){return L.nodes[e].parent=C}))})),this.root={children:[]},this.nodes.forEach((function(C){void 0===C.parent&&(C.parent=L.root,L.root.children.push(C.id)),C.ports=[]})),this.backToFront=this.nodes.slice(0),this.backToFront.sort((function(C,e){return L.getDepth(C)-L.getDepth(e)})),this.backToFront.slice(0).reverse().filter((function(C){return!C.leaf})).forEach((function(e){var t=C.Rectangle.empty();e.children.forEach((function(C){return t=t.union(L.nodes[C].rect)})),e.rect=t.inflate(L.groupPadding)}));var n=this.midPoints(this.cols.map((function(C){return C.pos}))),r=this.midPoints(this.rows.map((function(C){return C.pos}))),o=n[0],a=n[n.length-1],M=r[0],s=r[r.length-1],l=this.rows.map((function(C){return{x1:o,x2:a,y1:C.pos,y2:C.pos}})).concat(r.map((function(C){return{x1:o,x2:a,y1:C,y2:C}}))),d=this.cols.map((function(C){return{x1:C.pos,x2:C.pos,y1:M,y2:s}})).concat(n.map((function(C){return{x1:C,x2:C,y1:M,y2:s}}))),u=l.concat(d);u.forEach((function(C){return C.verts=[]})),this.verts=[],this.edges=[],l.forEach((function(C){return d.forEach((function(e){var t=new V(L.verts.length,e.x1,C.y1);C.verts.push(t),e.verts.push(t),L.verts.push(t);for(var H=L.backToFront.length;H-- >0;){var i=L.backToFront[H],n=i.rect,r=Math.abs(t.x-n.cx()),o=Math.abs(t.y-n.cy());if(r0;){var H=t.filter((function(e){return e.rect["overlap"+C.toUpperCase()](t[0].rect)})),V={nodes:H,pos:this.avg(H.map((function(e){return e.rect["c"+C]()})))};e.push(V),V.nodes.forEach((function(C){return t.splice(t.indexOf(C),1)}))}return e.sort((function(C,e){return C.pos-e.pos})),e},L.prototype.getDepth=function(C){for(var e=0;C.parent!==this.root;)e++,C=C.parent;return e},L.prototype.midPoints=function(C){for(var e=C[1]-C[0],t=[C[0]-e/2],H=1;H.1)&&(o={pos:M[0][e],segments:[]},r.push(o)),o.segments.push(M)}return r},L.nudgeSegs=function(C,t,H,V,i,L){var n=V.length;if(!(n<=1)){for(var r=V.map((function(t){return new e.Variable(t[0][C])})),o=[],a=0;a=0&&o.push(new e.Constraint(r[c],r[A],L))}new e.Solver(r,o).solve(),r.forEach((function(e,t){var i=V[t],L=e.position();i[0][C]=i[1][C]=L;var n=H[i.edgeid];i.i>0&&(n[i.i-1][1][C]=L),i.iMath.PI||V<-Math.PI)&&(V=H-t),V},L.isLeft=function(C,e,t){return(e.x-C.x)*(t.y-C.y)-(e.y-C.y)*(t.x-C.x)<=0},L.getOrder=function(C){for(var e={},t=0;t=o.length||M.ti+M.length>=a.length)?e.push({l:t,r:H}):(M.si+M.length>=o.length||M.ti+M.length>=a.length?(V=o[M.si+1],r=o[M.si-1],n=a[M.ti-1]):(V=o[M.si+M.length-2],n=o[M.si+M.length],r=a[M.ti+M.length]),L.isLeft(V,n,r)?e.push({l:H,r:t}):e.push({l:t,r:H})))}return L.getOrder(e)},L.makeSegments=function(C){function e(C){return{x:C.x,y:C.y}}for(var t=function(C,e,t){return Math.abs((e.x-C.x)*(t.y-C.y)-(e.y-C.y)*(t.x-C.x))<.001},H=[],V=e(C[0]),i=1;i1&&a>1?1e3:0})),M=a.reverse().map((function(C){return H.verts[C]}));return M.push(this.nodes[i.id].ports[0]),M.filter((function(C,e){return!(e0&&C.node===i&&M[e-1].node===i)}))},L.getRoutePath=function(C,e,t,H){var V={routepath:"M "+C[0][0].x+" "+C[0][0].y+" ",arrowpath:""};if(C.length>1)for(var i=0;i0?n-=o/Math.abs(o)*e:r-=a/Math.abs(a)*e,V.routepath+="L "+n+" "+r+" ";var M=C[i+1],s=M[0].x,l=M[0].y;o=M[1].x-s,a=M[1].y-l;var d,u,c=L.angleBetween2Lines(f,M)<0?1:0;Math.abs(o)>0?(d=s+o/Math.abs(o)*e,u=l):(d=s,u=l+a/Math.abs(a)*e);var A=Math.abs(d-n),h=Math.abs(u-r);V.routepath+="A "+A+" "+h+" 0 0 "+c+" "+d+" "+u+" "}else{var m=[n,r];Math.abs(o)>0?(p=[n-=o/Math.abs(o)*H,r+t],g=[n,r-t]):(p=[n+t,r-=a/Math.abs(a)*H],g=[n-t,r]),V.routepath+="L "+n+" "+r+" ",H>0&&(V.arrowpath="M "+m[0]+" "+m[1]+" L "+p[0]+" "+p[1]+" L "+g[0]+" "+g[1])}}else{var f,p,g;n=(f=C[0])[1].x,r=f[1].y,o=n-f[0].x,a=r-f[0].y,m=[n,r];Math.abs(o)>0?(p=[n-=o/Math.abs(o)*H,r+t],g=[n,r-t]):(p=[n+t,r-=a/Math.abs(a)*H],g=[n-t,r]),V.routepath+="L "+n+" "+r+" ",H>0&&(V.arrowpath="M "+m[0]+" "+m[1]+" L "+p[0]+" "+p[1]+" L "+g[0]+" "+g[1])}return V},L}();return hA.GridRouter=L,hA}var fA,pA={};var gA,vA,yA={};function ZA(){if(gA)return yA;gA=1,Object.defineProperty(yA,"__esModule",{value:!0});var C=oA(),e=mA();return yA.gridify=function(C,t,H,V){C.cola.start(0,0,0,10,!1);var i=function(C,t,H,V){C.forEach((function(C){C.routerNode={name:C.name,bounds:C.bounds.inflate(-H)}})),t.forEach((function(e){e.routerNode={bounds:e.bounds.inflate(-V),children:(void 0!==e.groups?e.groups.map((function(e){return C.length+e.id})):[]).concat(void 0!==e.leaves?e.leaves.map((function(C){return C.index})):[])}}));var i=C.concat(t).map((function(C,e){return C.routerNode.id=e,C.routerNode}));return new e.GridRouter(i,{getChildren:function(C){return C.children},getBounds:function(C){return C.bounds}},H-V)}(C.cola.nodes(),C.cola.groups(),H,V);return i.routeEdges(C.powerGraph.powerEdges,t,(function(C){return C.source.routerNode.id}),(function(C){return C.target.routerNode.id}))},yA.powerGraphGridLayout=function(e,t,H){var V;e.nodes.forEach((function(C,e){return C.index=e})),(new C.Layout).avoidOverlaps(!1).nodes(e.nodes).links(e.links).powerGraphGroups((function(C){(V=C).groups.forEach((function(C){return C.padding=H}))}));var i=e.nodes.length,L=[],n=e.nodes.slice(0);return n.forEach((function(C,e){return C.index=e})),V.groups.forEach((function(C){var e=C.index=C.id+i;n.push(C),void 0!==C.leaves&&C.leaves.forEach((function(C){return L.push({source:e,target:C.index})})),void 0!==C.groups&&C.groups.forEach((function(C){return L.push({source:e,target:C.id+i})}))})),V.powerEdges.forEach((function(C){L.push({source:C.source.index,target:C.target.index})})),(new C.Layout).size(t).nodes(n).links(L).avoidOverlaps(!1).linkDistance(30).symmetricDiffLinkLengths(5).convergenceThreshold(1e-4).start(100,0,0,0,!1),{cola:(new C.Layout).convergenceThreshold(.001).size(t).avoidOverlaps(!0).nodes(e.nodes).links(e.links).groupCompactness(1e-4).linkDistance(30).symmetricDiffLinkLengths(5).powerGraphGroups((function(C){(V=C).groups.forEach((function(C){C.padding=H}))})).start(50,0,100,0,!1),powerGraph:V}},yA}function SA(){return vA||(vA=1,function(C){function e(e){for(var t in e)C.hasOwnProperty(t)||(C[t]=e[t])}Object.defineProperty(C,"__esModule",{value:!0}),e(function(){if(LA)return Oc;LA=1;var C,e=TC&&TC.__extends||(C=function(e,t){return C=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(C,e){C.__proto__=e}||function(C,e){for(var t in e)e.hasOwnProperty(t)&&(C[t]=e[t])},C(e,t)},function(e,t){function H(){this.constructor=e}C(e,t),e.prototype=null===t?Object.create(t):(H.prototype=t.prototype,new H)});Object.defineProperty(Oc,"__esModule",{value:!0});var t=oA(),H=function(C){function H(e){var H=C.call(this)||this,V=e;return V.trigger&&(H.trigger=V.trigger),V.kick&&(H.kick=V.kick),V.drag&&(H.drag=V.drag),V.on&&(H.on=V.on),H.dragstart=H.dragStart=t.Layout.dragStart,H.dragend=H.dragEnd=t.Layout.dragEnd,H}return e(H,C),H.prototype.trigger=function(C){},H.prototype.kick=function(){},H.prototype.drag=function(){},H.prototype.on=function(C,e){return this},H}(t.Layout);return Oc.LayoutAdaptor=H,Oc.adaptor=function(C){return new H(C)},Oc}()),e(cA()),e(Fc()),e(HA()),e(mA()),e(rA()),e(oA()),e(function(){if(fA)return pA;fA=1,Object.defineProperty(pA,"__esModule",{value:!0});var C=CA(),e=Fc(),t=Yc(),H=_c(),V=function(){function C(C,e){this.source=C,this.target=e}return C.prototype.actualLength=function(C){var e=this;return Math.sqrt(C.reduce((function(C,t){var H=t[e.target]-t[e.source];return C+H*H}),0))},C}();pA.Link3D=V;var i=function(C,e,t){void 0===C&&(C=0),void 0===e&&(e=0),void 0===t&&(t=0),this.x=C,this.y=e,this.z=t};pA.Node3D=i;var L=function(){function V(C,e,t){var H=this;void 0===t&&(t=1),this.nodes=C,this.links=e,this.idealLinkLength=t,this.constraints=null,this.useJaccardLinkLengths=!0,this.result=new Array(V.k);for(var i=0;i0&&f.constraints(Z),f.groups(l.map((function(C,t){var H=a(e.nodeSpacing,C),V=function(e){return parseFloat(C.style("padding-"+e))},i=V("left")+H,L=V("right")+H,n=V("top")+H,r=V("bottom")+H;return C.scratch().cola={index:t,padding:Math.max(i,L,n,r),leaves:C.children().intersection(d).map((function(C){return C[0].scratch().cola.index})),fixed:C.locked()},C})).map((function(C){return C.scratch().cola.groups=C.children().intersection(l).map((function(C){return C.scratch().cola.index})),C.scratch().cola})));var S=void 0,b=void 0;null!=e.edgeLength?(S=e.edgeLength,b="linkDistance"):null!=e.edgeSymDiffLength?(S=e.edgeSymDiffLength,b="symmetricDiffLinkLengths"):null!=e.edgeJaccardLength?(S=e.edgeJaccardLength,b="jaccardLinkLengths"):(S=100,b="linkDistance");var w;if(f.links(M.stdFilter((function(C){return d.contains(C.source())&&d.contains(C.target())})).map((function(C){var e=C.scratch().cola={source:C.source()[0].scratch().cola.index,target:C.target()[0].scratch().cola.index};return null!=S&&(e.calcLength=a(S,C)),e}))),f.size([u.w,u.h]),null!=S&&f[b]((function(C){return C.calcLength})),e.flow){var x=void 0;(void 0===(w=e.flow)?"undefined":H(w))===H("")?x={axis:e.flow,minSeparation:50}:r(e.flow)?x={axis:"y",minSeparation:e.flow}:!function(C){return null!=C&&(void 0===C?"undefined":H(C))===H({})}(e.flow)?x={axis:"y",minSeparation:50}:((x=e.flow).axis=x.axis||"y",x.minSeparation=null!=x.minSeparation?x.minSeparation:50),f.flowLayout(x.axis,x.minSeparation)}return C.trigger({type:"layoutstart",layout:C}),f.avoidOverlaps(e.avoidOverlap).handleDisconnected(e.handleDisconnected).start(e.unconstrIter,e.userConstIter,e.allConstIter,void 0,void 0,e.centerGraph),e.infinite||setTimeout((function(){C.manuallyStopped||f.stop()}),e.maxSimulationTime),this},M.prototype.stop=function(){return this.adaptor&&(this.manuallyStopped=!0,this.adaptor.stop()),this},C.exports=M},function(C,e,t){C.exports=null!=Object.assign?Object.assign.bind(Object):function(C){for(var e=arguments.length,t=Array(e>1?e-1:0),H=1;He&&(this.rect.x-=(this.labelWidth-e)/2,this.setWidth(this.labelWidth)),this.labelHeight>t&&("center"==this.labelPos?this.rect.y-=(this.labelHeight-t)/2:"top"==this.labelPos&&(this.rect.y-=this.labelHeight-t),this.setHeight(this.labelHeight))}}},o.prototype.getInclusionTreeDepth=function(){if(this.inclusionTreeDepth==V.MAX_VALUE)throw"assert failed";return this.inclusionTreeDepth},o.prototype.transform=function(C){var e=this.rect.x;e>L.WORLD_BOUNDARY?e=L.WORLD_BOUNDARY:e<-L.WORLD_BOUNDARY&&(e=-L.WORLD_BOUNDARY);var t=this.rect.y;t>L.WORLD_BOUNDARY?t=L.WORLD_BOUNDARY:t<-L.WORLD_BOUNDARY&&(t=-L.WORLD_BOUNDARY);var H=new r(e,t),V=C.inverseTransformPoint(H);this.setLocation(V.x,V.y)},o.prototype.getLeft=function(){return this.rect.x},o.prototype.getRight=function(){return this.rect.x+this.rect.width},o.prototype.getTop=function(){return this.rect.y},o.prototype.getBottom=function(){return this.rect.y+this.rect.height},o.prototype.getParent=function(){return null==this.owner?null:this.owner.getParent()},C.exports=o},function(C,e,t){function H(C,e){null==C&&null==e?(this.x=0,this.y=0):(this.x=C,this.y=e)}H.prototype.getX=function(){return this.x},H.prototype.getY=function(){return this.y},H.prototype.setX=function(C){this.x=C},H.prototype.setY=function(C){this.y=C},H.prototype.getDifference=function(C){return new DimensionD(this.x-C.x,this.y-C.y)},H.prototype.getCopy=function(){return new H(this.x,this.y)},H.prototype.translate=function(C){return this.x+=C.width,this.y+=C.height,this},C.exports=H},function(C,e,t){var H=t(2),V=t(10),i=t(0),L=t(6),n=t(3),r=t(1),o=t(13),a=t(12),M=t(11);function s(C,e,t){H.call(this,t),this.estimatedSize=V.MIN_VALUE,this.margin=i.DEFAULT_GRAPH_MARGIN,this.edges=[],this.nodes=[],this.isConnected=!1,this.parent=C,null!=e&&e instanceof L?this.graphManager=e:null!=e&&e instanceof Layout&&(this.graphManager=e.graphManager)}for(var l in s.prototype=Object.create(H.prototype),H)s[l]=H[l];s.prototype.getNodes=function(){return this.nodes},s.prototype.getEdges=function(){return this.edges},s.prototype.getGraphManager=function(){return this.graphManager},s.prototype.getParent=function(){return this.parent},s.prototype.getLeft=function(){return this.left},s.prototype.getRight=function(){return this.right},s.prototype.getTop=function(){return this.top},s.prototype.getBottom=function(){return this.bottom},s.prototype.isConnected=function(){return this.isConnected},s.prototype.add=function(C,e,t){if(null==e&&null==t){var H=C;if(null==this.graphManager)throw"Graph has no graph mgr!";if(this.getNodes().indexOf(H)>-1)throw"Node already in graph!";return H.owner=this,this.getNodes().push(H),H}var V=C;if(!(this.getNodes().indexOf(e)>-1&&this.getNodes().indexOf(t)>-1))throw"Source or target not in graph!";if(e.owner!=t.owner||e.owner!=this)throw"Both owners must be this graph!";return e.owner!=t.owner?null:(V.source=e,V.target=t,V.isInterGraph=!1,this.getEdges().push(V),e.edges.push(V),t!=e&&t.edges.push(V),V)},s.prototype.remove=function(C){var e=C;if(C instanceof n){if(null==e)throw"Node is null!";if(null==e.owner||e.owner!=this)throw"Owner graph is invalid!";if(null==this.graphManager)throw"Owner graph manager is invalid!";for(var t=e.edges.slice(),H=t.length,V=0;V-1&&a>-1))throw"Source and/or target doesn't know this edge!";if(i.source.edges.splice(o,1),i.target!=i.source&&i.target.edges.splice(a,1),-1==(L=i.source.owner.getEdges().indexOf(i)))throw"Not in owner's edge list!";i.source.owner.getEdges().splice(L,1)}},s.prototype.updateLeftTop=function(){for(var C,e,t,H=V.MAX_VALUE,i=V.MAX_VALUE,L=this.getNodes(),n=L.length,r=0;r(C=o.getTop())&&(H=C),i>(e=o.getLeft())&&(i=e)}return H==V.MAX_VALUE?null:(t=null!=L[0].getParent().paddingLeft?L[0].getParent().paddingLeft:this.margin,this.left=i-t,this.top=H-t,new a(this.left,this.top))},s.prototype.updateBounds=function(C){for(var e,t,H,i,L,n=V.MAX_VALUE,r=-V.MAX_VALUE,a=V.MAX_VALUE,M=-V.MAX_VALUE,s=this.nodes,l=s.length,d=0;d(e=u.getLeft())&&(n=e),r<(t=u.getRight())&&(r=t),a>(H=u.getTop())&&(a=H),M<(i=u.getBottom())&&(M=i)}var c=new o(n,a,r-n,M-a);n==V.MAX_VALUE&&(this.left=this.parent.getLeft(),this.right=this.parent.getRight(),this.top=this.parent.getTop(),this.bottom=this.parent.getBottom()),L=null!=s[0].getParent().paddingLeft?s[0].getParent().paddingLeft:this.margin,this.left=c.x-L,this.right=c.x+c.width+L,this.top=c.y-L,this.bottom=c.y+c.height+L},s.calculateBounds=function(C){for(var e,t,H,i,L=V.MAX_VALUE,n=-V.MAX_VALUE,r=V.MAX_VALUE,a=-V.MAX_VALUE,M=C.length,s=0;s(e=l.getLeft())&&(L=e),n<(t=l.getRight())&&(n=t),r>(H=l.getTop())&&(r=H),a<(i=l.getBottom())&&(a=i)}return new o(L,r,n-L,a-r)},s.prototype.getInclusionTreeDepth=function(){return this==this.graphManager.getRoot()?1:this.parent.getInclusionTreeDepth()},s.prototype.getEstimatedSize=function(){if(this.estimatedSize==V.MIN_VALUE)throw"assert failed";return this.estimatedSize},s.prototype.calcEstimatedSize=function(){for(var C=0,e=this.nodes,t=e.length,H=0;H=this.nodes.length){var r=0;V.forEach((function(e){e.owner==C&&r++})),r==this.nodes.length&&(this.isConnected=!0)}}else this.isConnected=!0},C.exports=s},function(C,e,t){var H,V=t(1);function i(C){H=t(5),this.layout=C,this.graphs=[],this.edges=[]}i.prototype.addRoot=function(){var C=this.layout.newGraph(),e=this.layout.newNode(null),t=this.add(C,e);return this.setRootGraph(t),this.rootGraph},i.prototype.add=function(C,e,t,H,V){if(null==t&&null==H&&null==V){if(null==C)throw"Graph is null!";if(null==e)throw"Parent node is null!";if(this.graphs.indexOf(C)>-1)throw"Graph already in this graph mgr!";if(this.graphs.push(C),null!=C.parent)throw"Already has a parent!";if(null!=e.child)throw"Already has a child!";return C.parent=e,e.child=C,C}V=t,t=C;var i=(H=e).getOwner(),L=V.getOwner();if(null==i||i.getGraphManager()!=this)throw"Source not in this graph mgr!";if(null==L||L.getGraphManager()!=this)throw"Target not in this graph mgr!";if(i==L)return t.isInterGraph=!1,i.add(t,H,V);if(t.isInterGraph=!0,t.source=H,t.target=V,this.edges.indexOf(t)>-1)throw"Edge already in inter-graph edge list!";if(this.edges.push(t),null==t.source||null==t.target)throw"Edge source and/or target is null!";if(-1!=t.source.edges.indexOf(t)||-1!=t.target.edges.indexOf(t))throw"Edge already in source and/or target incidency list!";return t.source.edges.push(t),t.target.edges.push(t),t},i.prototype.remove=function(C){if(C instanceof H){var e=C;if(e.getGraphManager()!=this)throw"Graph not in this graph mgr";if(e!=this.rootGraph&&(null==e.parent||e.parent.graphManager!=this))throw"Invalid parent node!";for(var t,i=[],L=(i=i.concat(e.getEdges())).length,n=0;n=e.getRight()?t[0]+=Math.min(e.getX()-C.getX(),C.getRight()-e.getRight()):e.getX()<=C.getX()&&e.getRight()>=C.getRight()&&(t[0]+=Math.min(C.getX()-e.getX(),e.getRight()-C.getRight())),C.getY()<=e.getY()&&C.getBottom()>=e.getBottom()?t[1]+=Math.min(e.getY()-C.getY(),C.getBottom()-e.getBottom()):e.getY()<=C.getY()&&e.getBottom()>=C.getBottom()&&(t[1]+=Math.min(C.getY()-e.getY(),e.getBottom()-C.getBottom()));var i=Math.abs((e.getCenterY()-C.getCenterY())/(e.getCenterX()-C.getCenterX()));e.getCenterY()===C.getCenterY()&&e.getCenterX()===C.getCenterX()&&(i=1);var L=i*t[0],n=t[1]/i;t[0]L)return t[0]=H,t[1]=r,t[2]=i,t[3]=m,!1;if(Vi)return t[0]=n,t[1]=V,t[2]=A,t[3]=L,!1;if(Hi?(t[0]=a,t[1]=M,v=!0):(t[0]=o,t[1]=r,v=!0):Z===b&&(H>i?(t[0]=n,t[1]=r,v=!0):(t[0]=s,t[1]=M,v=!0)),-S===b?i>H?(t[2]=h,t[3]=m,y=!0):(t[2]=A,t[3]=c,y=!0):S===b&&(i>H?(t[2]=u,t[3]=c,y=!0):(t[2]=f,t[3]=m,y=!0)),v&&y)return!1;if(H>i?V>L?(w=this.getCardinalDirection(Z,b,4),x=this.getCardinalDirection(S,b,2)):(w=this.getCardinalDirection(-Z,b,3),x=this.getCardinalDirection(-S,b,1)):V>L?(w=this.getCardinalDirection(-Z,b,1),x=this.getCardinalDirection(-S,b,3)):(w=this.getCardinalDirection(Z,b,2),x=this.getCardinalDirection(S,b,4)),!v)switch(w){case 1:k=r,O=H+-d/b,t[0]=O,t[1]=k;break;case 2:O=s,k=V+l*b,t[0]=O,t[1]=k;break;case 3:k=M,O=H+d/b,t[0]=O,t[1]=k;break;case 4:O=a,k=V+-l*b,t[0]=O,t[1]=k}if(!y)switch(x){case 1:P=c,E=i+-g/b,t[2]=E,t[3]=P;break;case 2:E=f,P=L+p*b,t[2]=E,t[3]=P;break;case 3:P=m,E=i+g/b,t[2]=E,t[3]=P;break;case 4:E=h,P=L+-p*b,t[2]=E,t[3]=P}}return!1},V.getCardinalDirection=function(C,e,t){return C>e?t:1+t%4},V.getIntersection=function(C,e,t,V){if(null==V)return this.getIntersection2(C,e,t);var i,L,n,r,o,a,M,s=C.x,l=C.y,d=e.x,u=e.y,c=t.x,A=t.y,h=V.x,m=V.y;return 0===(M=(i=u-l)*(r=c-h)-(L=m-A)*(n=s-d))?null:new H((n*(a=h*A-c*m)-r*(o=d*l-s*u))/M,(L*o-i*a)/M)},V.angleOfVector=function(C,e,t,H){var V=void 0;return C!==t?(V=Math.atan((H-e)/(t-C)),t0?1:C<0?-1:0},H.floor=function(C){return C<0?Math.ceil(C):Math.floor(C)},H.ceil=function(C){return C<0?Math.floor(C):Math.ceil(C)},C.exports=H},function(C,e,t){function H(){}H.MAX_VALUE=2147483647,H.MIN_VALUE=-2147483648,C.exports=H},function(C,e,t){var H=function(){function C(C,e){for(var t=0;t0&&e;){for(n.push(o[0]);n.length>0&&e;){var a=n[0];n.splice(0,1),L.add(a);var M=a.getEdges();for(i=0;i-1&&o.splice(u,1)}L=new Set,r=new Map}else C=[]}return C},s.prototype.createDummyNodesForBendpoints=function(C){for(var e=[],t=C.source,H=this.graphManager.calcLowestCommonAncestor(C.source,C.target),V=0;V0){for(var V=this.edgeToDummyNodes.get(t),i=0;i=0&&e.splice(M,1),a.getNeighborsList().forEach((function(C){if(t.indexOf(C)<0){var e=H.get(C)-1;1==e&&r.push(C),H.set(C,e)}}))}t=t.concat(r),1!=e.length&&2!=e.length||(V=!0,i=e[0])}return i},s.prototype.setGraphManager=function(C){this.graphManager=C},C.exports=s},function(C,e,t){function H(){}H.seed=1,H.x=0,H.nextDouble=function(){return H.x=1e4*Math.sin(H.seed++),H.x-Math.floor(H.x)},C.exports=H},function(C,e,t){var H=t(4);function V(C,e){this.lworldOrgX=0,this.lworldOrgY=0,this.ldeviceOrgX=0,this.ldeviceOrgY=0,this.lworldExtX=1,this.lworldExtY=1,this.ldeviceExtX=1,this.ldeviceExtY=1}V.prototype.getWorldOrgX=function(){return this.lworldOrgX},V.prototype.setWorldOrgX=function(C){this.lworldOrgX=C},V.prototype.getWorldOrgY=function(){return this.lworldOrgY},V.prototype.setWorldOrgY=function(C){this.lworldOrgY=C},V.prototype.getWorldExtX=function(){return this.lworldExtX},V.prototype.setWorldExtX=function(C){this.lworldExtX=C},V.prototype.getWorldExtY=function(){return this.lworldExtY},V.prototype.setWorldExtY=function(C){this.lworldExtY=C},V.prototype.getDeviceOrgX=function(){return this.ldeviceOrgX},V.prototype.setDeviceOrgX=function(C){this.ldeviceOrgX=C},V.prototype.getDeviceOrgY=function(){return this.ldeviceOrgY},V.prototype.setDeviceOrgY=function(C){this.ldeviceOrgY=C},V.prototype.getDeviceExtX=function(){return this.ldeviceExtX},V.prototype.setDeviceExtX=function(C){this.ldeviceExtX=C},V.prototype.getDeviceExtY=function(){return this.ldeviceExtY},V.prototype.setDeviceExtY=function(C){this.ldeviceExtY=C},V.prototype.transformX=function(C){var e=0,t=this.lworldExtX;return 0!=t&&(e=this.ldeviceOrgX+(C-this.lworldOrgX)*this.ldeviceExtX/t),e},V.prototype.transformY=function(C){var e=0,t=this.lworldExtY;return 0!=t&&(e=this.ldeviceOrgY+(C-this.lworldOrgY)*this.ldeviceExtY/t),e},V.prototype.inverseTransformX=function(C){var e=0,t=this.ldeviceExtX;return 0!=t&&(e=this.lworldOrgX+(C-this.ldeviceOrgX)*this.lworldExtX/t),e},V.prototype.inverseTransformY=function(C){var e=0,t=this.ldeviceExtY;return 0!=t&&(e=this.lworldOrgY+(C-this.ldeviceOrgY)*this.lworldExtY/t),e},V.prototype.inverseTransformPoint=function(C){return new H(this.inverseTransformX(C.x),this.inverseTransformY(C.y))},C.exports=V},function(C,e,t){var H=t(15),V=t(7),i=t(0),L=t(8),n=t(9);function r(){H.call(this),this.useSmartIdealEdgeLengthCalculation=V.DEFAULT_USE_SMART_IDEAL_EDGE_LENGTH_CALCULATION,this.idealEdgeLength=V.DEFAULT_EDGE_LENGTH,this.springConstant=V.DEFAULT_SPRING_STRENGTH,this.repulsionConstant=V.DEFAULT_REPULSION_STRENGTH,this.gravityConstant=V.DEFAULT_GRAVITY_STRENGTH,this.compoundGravityConstant=V.DEFAULT_COMPOUND_GRAVITY_STRENGTH,this.gravityRangeFactor=V.DEFAULT_GRAVITY_RANGE_FACTOR,this.compoundGravityRangeFactor=V.DEFAULT_COMPOUND_GRAVITY_RANGE_FACTOR,this.displacementThresholdPerNode=3*V.DEFAULT_EDGE_LENGTH/100,this.coolingFactor=V.DEFAULT_COOLING_FACTOR_INCREMENTAL,this.initialCoolingFactor=V.DEFAULT_COOLING_FACTOR_INCREMENTAL,this.totalDisplacement=0,this.oldTotalDisplacement=0,this.maxIterations=V.MAX_ITERATIONS}for(var o in r.prototype=Object.create(H.prototype),H)r[o]=H[o];r.prototype.initParameters=function(){H.prototype.initParameters.call(this,arguments),this.totalIterations=0,this.notAnimatedIterations=0,this.useFRGridVariant=V.DEFAULT_USE_SMART_REPULSION_RANGE_CALCULATION,this.grid=[]},r.prototype.calcIdealEdgeLengths=function(){for(var C,e,t,H,L,n,r=this.getGraphManager().getAllEdges(),o=0;oV.ADAPTATION_LOWER_NODE_LIMIT&&(this.coolingFactor=Math.max(this.coolingFactor*V.COOLING_ADAPTATION_FACTOR,this.coolingFactor-(C-V.ADAPTATION_LOWER_NODE_LIMIT)/(V.ADAPTATION_UPPER_NODE_LIMIT-V.ADAPTATION_LOWER_NODE_LIMIT)*this.coolingFactor*(1-V.COOLING_ADAPTATION_FACTOR))),this.maxNodeDisplacement=V.MAX_NODE_DISPLACEMENT_INCREMENTAL):(C>V.ADAPTATION_LOWER_NODE_LIMIT?this.coolingFactor=Math.max(V.COOLING_ADAPTATION_FACTOR,1-(C-V.ADAPTATION_LOWER_NODE_LIMIT)/(V.ADAPTATION_UPPER_NODE_LIMIT-V.ADAPTATION_LOWER_NODE_LIMIT)*(1-V.COOLING_ADAPTATION_FACTOR)):this.coolingFactor=1,this.initialCoolingFactor=this.coolingFactor,this.maxNodeDisplacement=V.MAX_NODE_DISPLACEMENT),this.maxIterations=Math.max(5*this.getAllNodes().length,this.maxIterations),this.totalDisplacementThreshold=this.displacementThresholdPerNode*this.getAllNodes().length,this.repulsionRange=this.calcRepulsionRange()},r.prototype.calcSpringForces=function(){for(var C,e=this.getAllEdges(),t=0;t0&&void 0!==arguments[0])||arguments[0],n=arguments.length>1&&void 0!==arguments[1]&&arguments[1],r=this.getAllNodes();if(this.useFRGridVariant)for(this.totalIterations%V.GRID_CALCULATION_CHECK_PERIOD==1&&L&&this.updateGrid(),i=new Set,C=0;C(r=e.getEstimatedSize()*this.gravityRangeFactor)||n>r)&&(C.gravitationForceX=-this.gravityConstant*V,C.gravitationForceY=-this.gravityConstant*i):(L>(r=e.getEstimatedSize()*this.compoundGravityRangeFactor)||n>r)&&(C.gravitationForceX=-this.gravityConstant*V*this.compoundGravityConstant,C.gravitationForceY=-this.gravityConstant*i*this.compoundGravityConstant)},r.prototype.isConverged=function(){var C,e=!1;return this.totalIterations>this.maxIterations/3&&(e=Math.abs(this.totalDisplacement-this.oldTotalDisplacement)<2),C=this.totalDisplacement=n.length||o>=n[0].length))for(var a=0;aC}}]),C}();C.exports=i},function(C,e,t){var H=function(){function C(C,e){for(var t=0;t2&&void 0!==arguments[2]?arguments[2]:1,V=arguments.length>3&&void 0!==arguments[3]?arguments[3]:-1,i=arguments.length>4&&void 0!==arguments[4]?arguments[4]:-1;!function(C,e){if(!(C instanceof e))throw new TypeError("Cannot call a class as a function")}(this,C),this.sequence1=e,this.sequence2=t,this.match_score=H,this.mismatch_penalty=V,this.gap_penalty=i,this.iMax=e.length+1,this.jMax=t.length+1,this.grid=new Array(this.iMax);for(var L=0;L=0;t--){var H=this.listeners[t];H.event===C&&H.callback===e&&this.listeners.splice(t,1)}},V.emit=function(C,e){for(var t=0;t=0;V--){var i=H[V];i.isOrdered()||C.stack.push(i)}return e},V.prototype.calculateRadius=function(){var C=this,e=0;C.getNodes().forEach((function(C){return e+=Math.sqrt(C.getWidth()*C.getWidth()+C.getHeight()*C.getHeight())})),C.perimeter=e+C.getNodes().length*C.nodeSeparation;var t=C.perimeter/(2*Math.PI);C.getParent().setWidth(2*t),C.getParent().setHeight(2*t),C.getParent().setCenter(C.getParent().getWidth(),C.getParent().getHeight()),C.centerX=C.getParent().getCenterX(),C.centerY=C.getParent().getCenterY(),C.radius=C.getParent().getHeight()/2},V.prototype.calculateEdgeCrossingsOfNodes=function(){this.getNodes().forEach((function(C){return C.calculateTotalCrossing()}))},V.prototype.loadOldIndicesOfNodes=function(){for(var C=0;CMath.min(L,n)&&0!==n&&0!==L},V.prototype.crossingWithEdge=function(C){return this.crossesWithEdge(C)?1:0},V.prototype.calculateTotalCrossingWithList=function(C){var e=this,t=0;return C.forEach((function(C){return t+=e.crossingWithEdge(C)})),t},C.exports=V},function(C,e,t){var H=t(0).LNode;function V(C,e,t,V){void 0!==t&&void 0!==V?H.call(this,C,e,t,V):H.call(this,C,e),this.angle=0,this.circleIndex=-1,this.totalCrossingOfEdges=-1,this.isCrossingNumberValid=!1}for(var i in t(0).Quicksort,V.prototype=Object.create(H.prototype),H)V[i]=H[i];V.prototype.getCircle=function(){return this.getOwner()},V.prototype.setIndex=function(C){this.circleIndex=C,this.isCrossingNumberValid=!1},V.prototype.getIndex=function(){return this.circleIndex},V.prototype.getNeighborsSortedByDegree=function(){var C=Array.from(this.getNeighborsList());return(C=C.filter((function(C){return-1===C.getIndex()}))).sort((function(C,e){return C.getDegree()-e.getDegree()})),C},V.prototype.getDegree=function(){return this.getEdges().length},V.prototype.isOrdered=function(){return this.getIndex()>-1},V.prototype.setAngle=function(C){this.angle=C},V.prototype.getAngle=function(){return this.angle},V.prototype.getCircDistWithTheNode=function(C){var e=this,t=C.getIndex();if(-1===t||-1===e.getIndex())return-1;var H=e.getIndex()-t;return H<0&&(H+=e.getCircle().getSize()),H},V.prototype.getCrossingNumberWithNode=function(C){var e=0;return this.getEdges().forEach((function(t){C.getEdges().forEach((function(C){e+=t.crossingWithEdge(C)}))})),e},V.prototype.getTotalCrossingOfEdges=function(){var C=this;return C.isCrossingNumberValid||(C.calculateTotalCrossing(),C.isCrossingNumberValid=!0),C.totalCrossingOfEdges},V.prototype.calculateTotalCrossing=function(){var C=this,e=0,t=[];t.push.apply(t,C.getCircle().getEdges()),t=t.filter((function(e){return C.getEdges().indexOf(e)<0})),C.getEdges().forEach((function(C){return e+=C.calculateTotalCrossingWithList(t)})),C.totalCrossingOfEdges=e},C.exports=V},function(C,e,t){var H=t(0).Layout,V=t(2),i=t(1),L=t(4),n=t(3);function r(){H.call(this),this.nodeSeparation=V.DEFAULT_NODE_SEPARATION}for(var o in r.prototype=Object.create(H.prototype),H)r[o]=H[o];r.prototype.newGraph=function(C){return this.avsdfCircle=new i(null,this.graphManager,C),this.avsdfCircle},r.prototype.newNode=function(C){return new L(this.graphManager,C)},r.prototype.newEdge=function(C){return new n(null,null,C)},r.prototype.getPositionsData=function(){for(var C=this.graphManager.getAllNodes(),e={},t=0;t1)return!1;var C=this.avsdfCircle;for(C.setNodeSeparation(this.nodeSeparation),C.calculateRadius(),C.initOrdering();!C.hasFinishedOrdering();){var e=C.findNodeToPlace();C.putInOrder(e)}return!0},r.prototype.updateNodeAngles=function(){this.graphManager.getRoot().correctAngles()},r.prototype.updateNodeCoordinates=function(){var C=this.graphManager.getRoot();C.getNodes().forEach((function(e){e.setCenter(C.getCenterX()+C.getRadius()*Math.cos(e.getAngle()),C.getCenterY()+C.getRadius()*Math.sin(e.getAngle()))}))},r.prototype.initPostProcess=function(){this.avsdfCircle.calculateEdgeCrossingsOfNodes();var C=this.avsdfCircle.getNodes();return C.sort((function(C,e){return e.getTotalCrossingOfEdges()-C.getTotalCrossingOfEdges()})),C},r.prototype.oneStepPostProcess=function(C){for(var e=this,t=C.getTotalCrossingOfEdges(),H=void 0,V=Array.from(C.getNeighborsList()),i=0;i=t?e.avsdfCircle.loadOldIndicesOfNodes():(e.avsdfCircle.reOrderVertices(),t=H)}}},C.exports=r},function(C,e,t){var H={};H.layoutBase=t(0),H.AVSDFConstants=t(2),H.AVSDFEdge=t(3),H.AVSDFCircle=t(1),H.AVSDFLayout=t(5),H.AVSDFNode=t(4),C.exports=H}])}))}(kA)),kA.exports))}(0,(function(C){return function(C){var e={};function t(H){if(e[H])return e[H].exports;var V=e[H]={i:H,l:!1,exports:{}};return C[H].call(V.exports,V,V.exports,t),V.l=!0,V.exports}return t.m=C,t.c=e,t.i=function(C){return C},t.d=function(C,e,H){t.o(C,e)||Object.defineProperty(C,e,{configurable:!1,enumerable:!0,get:H})},t.n=function(C){var e=C&&C.__esModule?function(){return C.default}:function(){return C};return t.d(e,"a",e),e},t.o=function(C,e){return Object.prototype.hasOwnProperty.call(C,e)},t.p="",t(t.s=3)}([function(e,t){e.exports=C},function(C,e,t){C.exports=null!=Object.assign?Object.assign.bind(Object):function(C){for(var e=arguments.length,t=Array(e>1?e-1:0),H=1;H=e.nodes.size())return!0;this.avsdfLayout.oneStepPostProcess(this.sortedByDegreeList[e.tickIndex]),this.avsdfLayout.updateNodeAngles(),this.avsdfLayout.updateNodeCoordinates()}},{key:"postrun",value:function(){}},{key:"destroy",value:function(){return V(e.prototype.__proto__||Object.getPrototypeOf(e.prototype),"destroy",this).call(this),this}},{key:"processChildrenList",value:function(C,e,t){for(var H=e.length,V=0;V1&&void 0!==arguments[1]?arguments[1]:H,t=arguments.length>2&&void 0!==arguments[2]?arguments[2]:H,i=!1,L=C,n=0;n-1&&C%1==0&&C<=9007199254740991}}function fh(){if(ch)return uh;return ch=1,uh=function(C){return function(e){return C(e)}},uh}Ah.exports;var ph,gh,vh,yh,Zh,Sh,bh,wh,xh,Oh,kh,Eh,Ph,Th,Bh,_h,Dh,Rh,Fh,Nh,Ih,zh,jh,Gh,Wh,Uh,$h,Yh={exports:{}};function Xh(){return ph||(ph=1,function(C,e){var t=RC,H=e&&!e.nodeType&&e,V=H&&C&&!C.nodeType&&C,i=V&&V.exports===H&&t.process,L=function(){try{var C=V&&V.require&&V.require("util").types;return C||i&&i.binding&&i.binding("util")}catch(C){}}();C.exports=L}(Yh,Yh.exports)),Yh.exports}function qh(){if(vh)return gh;vh=1;var C=function(){if(dh)return lh;dh=1;var C=Le,e=mh(),t=ne,H={};return H["[object Float32Array]"]=H["[object Float64Array]"]=H["[object Int8Array]"]=H["[object Int16Array]"]=H["[object Int32Array]"]=H["[object Uint8Array]"]=H["[object Uint8ClampedArray]"]=H["[object Uint16Array]"]=H["[object Uint32Array]"]=!0,H["[object Arguments]"]=H["[object Array]"]=H["[object ArrayBuffer]"]=H["[object Boolean]"]=H["[object DataView]"]=H["[object Date]"]=H["[object Error]"]=H["[object Function]"]=H["[object Map]"]=H["[object Number]"]=H["[object Object]"]=H["[object RegExp]"]=H["[object Set]"]=H["[object String]"]=H["[object WeakMap]"]=!1,lh=function(V){return t(V)&&e(V.length)&&!!H[C(V)]}}(),e=fh(),t=Xh(),H=t&&t.isTypedArray,V=H?e(H):C;return gh=V}function Qh(){if(Zh)return yh;Zh=1;var C=(QA||(QA=1,qA=function(C,e){for(var t=-1,H=Array(C);++ta))return!1;var s=r.get(H),l=r.get(V);if(s&&l)return s==V&&l==H;var d=-1,u=!0,c=2&i?new C:void 0;for(r.set(H,V),r.set(V,H);++d0&&i(a)?V>1?t(a,V-1,i,L,n):C(n,a):L||(n[n.length]=a)}return n},Ag}function Zb(){if(gg)return pg;gg=1;var C=(fg||(fg=1,mg=function(C,e,t){switch(t.length){case 0:return C.call(e);case 1:return C.call(e,t[0]);case 2:return C.call(e,t[0],t[1]);case 3:return C.call(e,t[0],t[1],t[2])}return C.apply(e,t)}),mg),e=Math.max;return pg=function(t,H,V){return H=e(void 0===H?t.length-1:H,0),function(){for(var i=arguments,L=-1,n=e(i.length-H,0),r=Array(n);++L0){if(++t>=800)return arguments[0]}else t=0;return e.apply(void 0,arguments)}},Zg}(),t=e(C);return bg=t}function bb(){if(Og)return xg;Og=1;var C=XS(),e=Zb(),t=Sb();return xg=function(H,V){return t(e(H,V,C),H+"")},xg}function wb(){if(Eg)return kg;return Eg=1,kg=function(C,e,t,H){for(var V=C.length,i=t+(H?1:-1);H?i--:++i-1},Fg}(),t=(zg||(zg=1,Ig=function(C,e,t){for(var H=-1,V=null==C?0:C.length;++H=200){var u=n?null:V(L);if(u)return i(u);s=!1,a=H,d=new C}else d=n?[]:l;C:for(;++or){var o=n;n=r,r=o}return n+H+r+H+(C.isUndefined(L)?e:L)}function r(C,e){return n(C,e.v,e.w,e.name)}return V.prototype._nodeCount=0,V.prototype._edgeCount=0,V.prototype.isDirected=function(){return this._isDirected},V.prototype.isMultigraph=function(){return this._isMultigraph},V.prototype.isCompound=function(){return this._isCompound},V.prototype.setGraph=function(C){return this._label=C,this},V.prototype.graph=function(){return this._label},V.prototype.setDefaultNodeLabel=function(e){return C.isFunction(e)||(e=C.constant(e)),this._defaultNodeLabelFn=e,this},V.prototype.nodeCount=function(){return this._nodeCount},V.prototype.nodes=function(){return C.keys(this._nodes)},V.prototype.sources=function(){var e=this;return C.filter(this.nodes(),(function(t){return C.isEmpty(e._in[t])}))},V.prototype.sinks=function(){var e=this;return C.filter(this.nodes(),(function(t){return C.isEmpty(e._out[t])}))},V.prototype.setNodes=function(e,t){var H=arguments,V=this;return C.each(e,(function(C){H.length>1?V.setNode(C,t):V.setNode(C)})),this},V.prototype.setNode=function(e,H){return C.has(this._nodes,e)?(arguments.length>1&&(this._nodes[e]=H),this):(this._nodes[e]=arguments.length>1?H:this._defaultNodeLabelFn(e),this._isCompound&&(this._parent[e]=t,this._children[e]={},this._children[t][e]=!0),this._in[e]={},this._preds[e]={},this._out[e]={},this._sucs[e]={},++this._nodeCount,this)},V.prototype.node=function(C){return this._nodes[C]},V.prototype.hasNode=function(e){return C.has(this._nodes,e)},V.prototype.removeNode=function(e){var t=this;if(C.has(this._nodes,e)){var H=function(C){t.removeEdge(t._edgeObjs[C])};delete this._nodes[e],this._isCompound&&(this._removeFromParentsChildList(e),delete this._parent[e],C.each(this.children(e),(function(C){t.setParent(C)})),delete this._children[e]),C.each(C.keys(this._in[e]),H),delete this._in[e],delete this._preds[e],C.each(C.keys(this._out[e]),H),delete this._out[e],delete this._sucs[e],--this._nodeCount}return this},V.prototype.setParent=function(e,H){if(!this._isCompound)throw new Error("Cannot set parent in a non-compound graph");if(C.isUndefined(H))H=t;else{for(var V=H+="";!C.isUndefined(V);V=this.parent(V))if(V===e)throw new Error("Setting "+H+" as parent of "+e+" would create a cycle");this.setNode(H)}return this.setNode(e),this._removeFromParentsChildList(e),this._parent[e]=H,this._children[H][e]=!0,this},V.prototype._removeFromParentsChildList=function(C){delete this._children[this._parent[C]][C]},V.prototype.parent=function(C){if(this._isCompound){var e=this._parent[C];if(e!==t)return e}},V.prototype.children=function(e){if(C.isUndefined(e)&&(e=t),this._isCompound){var H=this._children[e];if(H)return C.keys(H)}else{if(e===t)return this.nodes();if(this.hasNode(e))return[]}},V.prototype.predecessors=function(e){var t=this._preds[e];if(t)return C.keys(t)},V.prototype.successors=function(e){var t=this._sucs[e];if(t)return C.keys(t)},V.prototype.neighbors=function(e){var t=this.predecessors(e);if(t)return C.union(t,this.successors(e))},V.prototype.isLeaf=function(C){return 0===(this.isDirected()?this.successors(C):this.neighbors(C)).length},V.prototype.filterNodes=function(e){var t=new this.constructor({directed:this._isDirected,multigraph:this._isMultigraph,compound:this._isCompound});t.setGraph(this.graph());var H=this;C.each(this._nodes,(function(C,H){e(H)&&t.setNode(H,C)})),C.each(this._edgeObjs,(function(C){t.hasNode(C.v)&&t.hasNode(C.w)&&t.setEdge(C,H.edge(C))}));var V={};function i(C){var e=H.parent(C);return void 0===e||t.hasNode(e)?(V[C]=e,e):e in V?V[e]:i(e)}return this._isCompound&&C.each(t.nodes(),(function(C){t.setParent(C,i(C))})),t},V.prototype.setDefaultEdgeLabel=function(e){return C.isFunction(e)||(e=C.constant(e)),this._defaultEdgeLabelFn=e,this},V.prototype.edgeCount=function(){return this._edgeCount},V.prototype.edges=function(){return C.values(this._edgeObjs)},V.prototype.setPath=function(e,t){var H=this,V=arguments;return C.reduce(e,(function(C,e){return V.length>1?H.setEdge(C,e,t):H.setEdge(C,e),e})),this},V.prototype.setEdge=function(){var e,t,H,V,L=!1,r=arguments[0];"object"==typeof r&&null!==r&&"v"in r?(e=r.v,t=r.w,H=r.name,2===arguments.length&&(V=arguments[1],L=!0)):(e=r,t=arguments[1],H=arguments[3],arguments.length>2&&(V=arguments[2],L=!0)),e=""+e,t=""+t,C.isUndefined(H)||(H=""+H);var o=n(this._isDirected,e,t,H);if(C.has(this._edgeLabels,o))return L&&(this._edgeLabels[o]=V),this;if(!C.isUndefined(H)&&!this._isMultigraph)throw new Error("Cannot set a named edge when isMultigraph = false");this.setNode(e),this.setNode(t),this._edgeLabels[o]=L?V:this._defaultEdgeLabelFn(e,t,H);var a=function(C,e,t,H){var V=""+e,i=""+t;if(!C&&V>i){var L=V;V=i,i=L}var n={v:V,w:i};H&&(n.name=H);return n}(this._isDirected,e,t,H);return e=a.v,t=a.w,Object.freeze(a),this._edgeObjs[o]=a,i(this._preds[t],e),i(this._sucs[e],t),this._in[t][o]=a,this._out[e][o]=a,this._edgeCount++,this},V.prototype.edge=function(C,e,t){var H=1===arguments.length?r(this._isDirected,arguments[0]):n(this._isDirected,C,e,t);return this._edgeLabels[H]},V.prototype.hasEdge=function(e,t,H){var V=1===arguments.length?r(this._isDirected,arguments[0]):n(this._isDirected,e,t,H);return C.has(this._edgeLabels,V)},V.prototype.removeEdge=function(C,e,t){var H=1===arguments.length?r(this._isDirected,arguments[0]):n(this._isDirected,C,e,t),V=this._edgeObjs[H];return V&&(C=V.v,e=V.w,delete this._edgeLabels[H],delete this._edgeObjs[H],L(this._preds[e],C),L(this._sucs[C],e),delete this._in[e][H],delete this._out[C][H],this._edgeCount--),this},V.prototype.inEdges=function(e,t){var H=this._in[e];if(H){var V=C.values(H);return t?C.filter(V,(function(C){return C.v===t})):V}},V.prototype.outEdges=function(e,t){var H=this._out[e];if(H){var V=C.values(H);return t?C.filter(V,(function(C){return C.w===t})):V}},V.prototype.nodeEdges=function(C,e){var t=this.inEdges(C,e);if(t)return t.concat(this.outEdges(C,e))},iv}function Db(){return av?ov:(av=1,ov={Graph:_b(),version:rv?nv:(rv=1,nv="2.1.8")})}function Rb(){if(sv)return Mv;sv=1;var C=Bb(),e=_b();function t(e){return C.map(e.nodes(),(function(t){var H=e.node(t),V=e.parent(t),i={v:t};return C.isUndefined(H)||(i.value=H),C.isUndefined(V)||(i.parent=V),i}))}function H(e){return C.map(e.edges(),(function(t){var H=e.edge(t),V={v:t.v,w:t.w};return C.isUndefined(t.name)||(V.name=t.name),C.isUndefined(H)||(V.value=H),V}))}return Mv={write:function(e){var V={options:{directed:e.isDirected(),multigraph:e.isMultigraph(),compound:e.isCompound()},nodes:t(e),edges:H(e)};C.isUndefined(e.graph())||(V.value=C.clone(e.graph()));return V},read:function(t){var H=new e(t.options).setGraph(t.value);return C.each(t.nodes,(function(C){H.setNode(C.v,C.value),C.parent&&H.setParent(C.v,C.parent)})),C.each(t.edges,(function(C){H.setEdge({v:C.v,w:C.w,name:C.name},C.value)})),H}}}function Fb(){if(dv)return lv;dv=1;var C=Bb();return lv=function(e){var t,H={},V=[];function i(V){C.has(H,V)||(H[V]=!0,t.push(V),C.each(e.successors(V),i),C.each(e.predecessors(V),i))}return C.each(e.nodes(),(function(C){t=[],i(C),t.length&&V.push(t)})),V}}function Nb(){if(cv)return uv;cv=1;var C=Bb();function e(){this._arr=[],this._keyIndices={}}return uv=e,e.prototype.size=function(){return this._arr.length},e.prototype.keys=function(){return this._arr.map((function(C){return C.key}))},e.prototype.has=function(e){return C.has(this._keyIndices,e)},e.prototype.priority=function(C){var e=this._keyIndices[C];if(void 0!==e)return this._arr[e].priority},e.prototype.min=function(){if(0===this.size())throw new Error("Queue underflow");return this._arr[0].key},e.prototype.add=function(e,t){var H=this._keyIndices;if(e=String(e),!C.has(H,e)){var V=this._arr,i=V.length;return H[e]=i,V.push({key:e,priority:t}),this._decrease(i),!0}return!1},e.prototype.removeMin=function(){this._swap(0,this._arr.length-1);var C=this._arr.pop();return delete this._keyIndices[C.key],this._heapify(0),C.key},e.prototype.decrease=function(C,e){var t=this._keyIndices[C];if(e>this._arr[t].priority)throw new Error("New priority is greater than current priority. Key: "+C+" Old: "+this._arr[t].priority+" New: "+e);this._arr[t].priority=e,this._decrease(t)},e.prototype._heapify=function(C){var e=this._arr,t=2*C,H=t+1,V=C;t>1].priority0&&(i=r.removeMin(),(L=n[i]).distance!==Number.POSITIVE_INFINITY);)V(i).forEach(o);return n}(C,String(H),V||t,i||function(e){return C.outEdges(e)})};var t=C.constant(1);return Av}function zb(){if(fv)return mv;fv=1;var C=Ib(),e=Bb();return mv=function(t,H,V){return e.transform(t.nodes(),(function(e,i){e[i]=C(t,i,H,V)}),{})}}function jb(){if(gv)return pv;gv=1;var C=Bb();return pv=function(e){var t=0,H=[],V={},i=[];function L(n){var r=V[n]={onStack:!0,lowlink:t,index:t++};if(H.push(n),e.successors(n).forEach((function(e){C.has(V,e)?V[e].onStack&&(r.lowlink=Math.min(r.lowlink,V[e].index)):(L(e),r.lowlink=Math.min(r.lowlink,V[e].lowlink))})),r.lowlink===r.index){var o,a=[];do{o=H.pop(),V[o].onStack=!1,a.push(o)}while(n!==o);i.push(a)}}return e.nodes().forEach((function(e){C.has(V,e)||L(e)})),i},pv}function Gb(){if(yv)return vv;yv=1;var C=Bb(),e=jb();return vv=function(t){return C.filter(e(t),(function(C){return C.length>1||1===C.length&&t.hasEdge(C[0],C[0])}))}}function Wb(){if(Sv)return Zv;Sv=1;var C=Bb();Zv=function(C,t,H){return function(C,e,t){var H={},V=C.nodes();return V.forEach((function(C){H[C]={},H[C][C]={distance:0},V.forEach((function(e){C!==e&&(H[C][e]={distance:Number.POSITIVE_INFINITY})})),t(C).forEach((function(t){var V=t.v===C?t.w:t.v,i=e(t);H[C][V]={distance:i,predecessor:C}}))})),V.forEach((function(C){var e=H[C];V.forEach((function(t){var i=H[t];V.forEach((function(t){var H=i[C],V=e[t],L=i[t],n=H.distance+V.distance;n0;){if(i=r.removeMin(),C.has(n,i))L.setEdge(i,n[i]);else{if(a)throw new Error("Input graph is not connected: "+H);a=!0}H.nodeEdges(i).forEach(o)}return L},Dv}function Kb(){if(zv)return Iv;zv=1;var C=Db();return Iv={Graph:C.Graph,json:Rb(),alg:Nv?Fv:(Nv=1,Fv={components:Fb(),dijkstra:Ib(),dijkstraAll:zb(),findCycles:Gb(),floydWarshall:Wb(),isAcyclic:$b(),postorder:Xb(),preorder:qb(),prim:Qb(),tarjan:jb(),topsort:Ub()}),version:C.version}}function Jb(){if(Gv)return jv;var C;Gv=1;try{C=Kb()}catch(C){}return C||(C=window.graphlib),jv=C}function Cw(){if(Uv)return Wv;Uv=1;var C=jS();return Wv=function(e){return C(e,5)}}function ew(){if(Yv)return $v;Yv=1;var C=gt,e=em(),t=jH,H=DC;return $v=function(V,i,L){if(!H(L))return!1;var n=typeof i;return!!("number"==n?e(L)&&t(i,L.length):"string"==n&&i in L)&&C(L[i],V)},$v}function tw(){if(qv)return Xv;qv=1;var C=bb(),e=gt,t=ew(),H=Vm(),V=Object.prototype,i=V.hasOwnProperty,L=C((function(C,L){C=Object(C);var n=-1,r=L.length,o=r>2?L[2]:void 0;for(o&&t(L[0],L[1],o)&&(r=1);++n-1?n[r?V[o]:o]:void 0}},Qv}(),e=C(Vw());return iy=e}function Lw(){if(ry)return ny;ry=1;var C=yb();return ny=function(e){return(null==e?0:e.length)?C(e,1):[]},ny}function nw(){if(ay)return oy;ay=1;var C=US(),e=qS(),t=Vm();return oy=function(H,V){return null==H?H:C(H,e(V),t)},oy}function rw(){if(sy)return My;return sy=1,My=function(C){var e=null==C?0:C.length;return e?C[e-1]:void 0},My}function ow(){if(dy)return ly;dy=1;var C=DH,e=$S(),t=lb();return ly=function(H,V){var i={};return V=t(V,3),e(H,(function(e,t,H){C(i,t,V(e,t,H))})),i},ly}function aw(){if(cy)return uy;cy=1;var C=ae;return uy=function(e,t,H){for(var V=-1,i=e.length;++Ve}),t=XS();return my=function(H){return H&&H.length?C(H,t,e):void 0},my}function sw(){if(gy)return py;gy=1;var C=DH,e=gt;return py=function(t,H,V){(void 0!==V&&!e(t[H],V)||void 0===V&&!(H in t))&&C(t,H,V)},py}function lw(){if(Sy)return Zy;return Sy=1,Zy=function(C,e){if(("constructor"!==e||"function"!=typeof C[e])&&"__proto__"!=e)return C[e]},Zy}function dw(){if(Oy)return xy;Oy=1;var C=sw(),e=yS(),t=DS(),H=KH,V=NS(),i=nh(),L=be,n=Eb(),r=hh(),o=_e,a=DC,M=function(){if(yy)return vy;yy=1;var C=Le,e=xS(),t=ne,H=Function.prototype,V=Object.prototype,i=H.toString,L=V.hasOwnProperty,n=i.call(Object);return vy=function(H){if(!t(H)||"[object Object]"!=C(H))return!1;var V=e(H);if(null===V)return!0;var r=L.call(V,"constructor")&&V.constructor;return"function"==typeof r&&r instanceof r&&i.call(r)==n}}(),s=qh(),l=lw(),d=function(){if(wy)return by;wy=1;var C=Lh(),e=Vm();return by=function(t){return C(t,e(t))}}();return xy=function(u,c,A,h,m,f,p){var g=l(u,A),v=l(c,A),y=p.get(v);if(y)C(u,A,y);else{var Z=f?f(g,v,A+"",u,c,p):void 0,S=void 0===Z;if(S){var b=L(v),w=!b&&r(v),x=!b&&!w&&s(v);Z=v,b||w||x?L(g)?Z=g:n(g)?Z=H(g):w?(S=!1,Z=e(v,!0)):x?(S=!1,Z=t(v,!0)):Z=[]:M(v)||i(v)?(Z=g,i(g)?Z=d(g):a(g)&&!o(g)||(Z=V(v))):S=!1}S&&(p.set(v,Z),m(Z,v,h,f,p),p.delete(v)),C(u,A,Z)}},xy}function uw(){if(_y)return By;_y=1;var C=function(){if(Ey)return ky;Ey=1;var C=Vh(),e=sw(),t=US(),H=dw(),V=DC,i=Vm(),L=lw();return ky=function n(r,o,a,M,s){r!==o&&t(o,(function(t,i){if(s||(s=new C),V(t))H(r,o,i,a,n,M,s);else{var l=M?M(L(r,i),t,i+"",r,o,s):void 0;void 0===l&&(l=t),e(r,i,l)}}),i)},ky}(),e=function(){if(Ty)return Py;Ty=1;var C=bb(),e=ew();return Py=function(t){return C((function(C,H){var V=-1,i=H.length,L=i>1?H[i-1]:void 0,n=i>2?H[2]:void 0;for(L=t.length>3&&"function"==typeof L?(i--,L):void 0,n&&e(H[0],H[1],n)&&(L=i<3?void 0:L,i=1),C=Object(C);++Vt||L&&n&&o&&!r&&!a||V&&n&&o||!H&&o||!i)return 1;if(!V&&!L&&!a&&e=r?o:o*("desc"==H[V]?-1:1)}return e.index-t.index},nZ}function yw(){if(aZ)return oZ;aZ=1;var C=sH,e=OH,t=lb(),H=hb(),V=(VZ||(VZ=1,HZ=function(C,e){var t=C.length;for(C.sort(e);t--;)C[t]=C[t].value;return C}),HZ),i=fh(),L=vw(),n=XS(),r=be;return oZ=function(o,a,M){a=a.length?C(a,(function(C){return r(C)?function(t){return e(t,1===C.length?C[0]:C)}:C})):[n];var s=-1;a=C(a,i(t));var l=H(o,(function(e,t,H){return{criteria:C(a,(function(C){return C(e)})),index:++s,value:e}}));return V(l,(function(C,e){return L(C,e,M)}))},oZ}function Zw(){if(sZ)return MZ;sZ=1;var C=yb(),e=yw(),t=bb(),H=ew(),V=t((function(t,V){if(null==t)return[];var i=V.length;return i>1&&H(t,V[0],V[1])?V=[]:i>2&&H(V[0],V[1],V[2])&&(V=[V[0]]),e(t,C(V,1),[])}));return MZ=V}function Sw(){if(dZ)return lZ;dZ=1;var C=fH,e=0;return lZ=function(t){var H=++e;return C(t)+H}}function bw(){if(hZ)return AZ;hZ=1;var C=IH,e=(cZ||(cZ=1,uZ=function(C,e,t){for(var H=-1,V=C.length,i=e.length,L={};++H0;--r)if(H=e[r].dequeue()){i=i.concat(V(C,e,t,H,!0));break}}return i}(r.graph,r.buckets,r.zeroIdx);return C.flatten(C.map(o,(function(C){return L.outEdges(C.v,C.w)})),!0)};var H=C.constant(1);function V(e,t,H,V,L){var n=L?[]:void 0;return C.forEach(e.inEdges(V.v),(function(C){var V=e.edge(C),r=e.node(C.v);L&&n.push({v:C.v,w:C.w}),r.out-=V,i(t,H,r)})),C.forEach(e.outEdges(V.v),(function(C){var V=e.edge(C),L=C.w,n=e.node(L);n.in-=V,i(t,H,n)})),e.removeNode(V.v),n}function i(C,e,t){t.out?t.in?C[t.out-t.in+e].enqueue(t):C[C.length-1].enqueue(t):C[0].enqueue(t)}return vZ}function Ow(){if(SZ)return ZZ;SZ=1;var C=ww(),e=xw();return ZZ={run:function(t){var H="greedy"===t.graph().acyclicer?e(t,function(C){return function(e){return C.edge(e).weight}}(t)):function(e){var t=[],H={},V={};function i(L){C.has(V,L)||(V[L]=!0,H[L]=!0,C.forEach(e.outEdges(L),(function(e){C.has(H,e.w)?t.push(e):i(e.w)})),delete H[L])}return C.forEach(e.nodes(),i),t}(t);C.forEach(H,(function(e){var H=t.edge(e);t.removeEdge(e),H.forwardName=e.name,H.reversed=!0,t.setEdge(e.w,e.v,H,C.uniqueId("rev"))}))},undo:function(e){C.forEach(e.edges(),(function(C){var t=e.edge(C);if(t.reversed){e.removeEdge(C);var H=t.forwardName;delete t.reversed,delete t.forwardName,e.setEdge(C.w,C.v,t,H)}}))}}}function kw(){if(wZ)return bZ;wZ=1;var C=ww(),e=Jb().Graph;function t(e,t,H,V){var i;do{i=C.uniqueId(V)}while(e.hasNode(i));return H.dummy=t,e.setNode(i,H),i}function H(e){return C.max(C.map(e.nodes(),(function(t){var H=e.node(t).rank;if(!C.isUndefined(H))return H})))}return bZ={addDummyNode:t,simplify:function(t){var H=(new e).setGraph(t.graph());return C.forEach(t.nodes(),(function(C){H.setNode(C,t.node(C))})),C.forEach(t.edges(),(function(C){var e=H.edge(C.v,C.w)||{weight:0,minlen:1},V=t.edge(C);H.setEdge(C.v,C.w,{weight:e.weight+V.weight,minlen:Math.max(e.minlen,V.minlen)})})),H},asNonCompoundGraph:function(t){var H=new e({multigraph:t.isMultigraph()}).setGraph(t.graph());return C.forEach(t.nodes(),(function(C){t.children(C).length||H.setNode(C,t.node(C))})),C.forEach(t.edges(),(function(C){H.setEdge(C,t.edge(C))})),H},successorWeights:function(e){var t=C.map(e.nodes(),(function(t){var H={};return C.forEach(e.outEdges(t),(function(C){H[C.w]=(H[C.w]||0)+e.edge(C).weight})),H}));return C.zipObject(e.nodes(),t)},predecessorWeights:function(e){var t=C.map(e.nodes(),(function(t){var H={};return C.forEach(e.inEdges(t),(function(C){H[C.v]=(H[C.v]||0)+e.edge(C).weight})),H}));return C.zipObject(e.nodes(),t)},intersectRect:function(C,e){var t,H,V=C.x,i=C.y,L=e.x-V,n=e.y-i,r=C.width/2,o=C.height/2;if(!L&&!n)throw new Error("Not possible to find intersection inside of the rectangle");Math.abs(n)*r>Math.abs(L)*o?(n<0&&(o=-o),t=o*L/n,H=o):(L<0&&(r=-r),t=r,H=r*n/L);return{x:V+t,y:i+H}},buildLayerMatrix:function(e){var t=C.map(C.range(H(e)+1),(function(){return[]}));return C.forEach(e.nodes(),(function(H){var V=e.node(H),i=V.rank;C.isUndefined(i)||(t[i][V.order]=H)})),t},normalizeRanks:function(e){var t=C.min(C.map(e.nodes(),(function(C){return e.node(C).rank})));C.forEach(e.nodes(),(function(H){var V=e.node(H);C.has(V,"rank")&&(V.rank-=t)}))},removeEmptyRanks:function(e){var t=C.min(C.map(e.nodes(),(function(C){return e.node(C).rank}))),H=[];C.forEach(e.nodes(),(function(C){var V=e.node(C).rank-t;H[V]||(H[V]=[]),H[V].push(C)}));var V=0,i=e.graph().nodeRankFactor;C.forEach(H,(function(t,H){C.isUndefined(t)&&H%i!=0?--V:V&&C.forEach(t,(function(C){e.node(C).rank+=V}))}))},addBorderNode:function(C,e,H,V){var i={width:0,height:0};arguments.length>=4&&(i.rank=H,i.order=V);return t(C,"border",i,e)},maxRank:H,partition:function(e,t){var H={lhs:[],rhs:[]};return C.forEach(e,(function(C){t(C)?H.lhs.push(C):H.rhs.push(C)})),H},time:function(e,t){var H=C.now();try{return t()}finally{console.log(e+" time: "+(C.now()-H)+"ms")}},notime:function(C,e){return e()}},bZ}function Ew(){if(OZ)return xZ;OZ=1;var C=ww(),e=kw();return xZ={run:function(t){t.graph().dummyChains=[],C.forEach(t.edges(),(function(C){!function(C,t){var H,V,i,L=t.v,n=C.node(L).rank,r=t.w,o=C.node(r).rank,a=t.name,M=C.edge(t),s=M.labelRank;if(o===n+1)return;for(C.removeEdge(t),i=0,++n;nr.lim&&(o=r,a=!0);var M=C.filter(H.edges(),(function(C){return a===u(e,e.node(C.v),o)&&a!==u(e,e.node(C.w),o)}));return C.minBy(M,(function(C){return t(H,C)}))}function d(e,t,H,i){var L=H.v,n=H.w;e.removeEdge(L,n),e.setEdge(i.v,i.w,{}),a(e),r(e,t),function(e,t){var H=C.find(e.nodes(),(function(C){return!t.node(C).parent})),i=V(e,H);i=i.slice(1),C.forEach(i,(function(C){var H=e.node(C).parent,V=t.edge(C,H),i=!1;V||(V=t.edge(H,C),i=!0),t.node(C).rank=t.node(H).rank+(i?V.minlen:-V.minlen)}))}(e,t)}function u(C,e,t){return t.low<=e.lim&&e.lim<=t.lim}return BZ=n,n.initLowLimValues=a,n.initCutValues=r,n.calcCutValue=o,n.leaveEdge=s,n.enterEdge=l,n.exchangeEdges=d,BZ}function _w(){if(RZ)return DZ;RZ=1;var C=Pw().longestPath,e=Tw(),t=Bw();DZ=function(t){if("function"==typeof t.graph().ranker)t.graph().ranker(t);else switch(t.graph().ranker){case"network-simplex":default:V(t);break;case"tight-tree":!function(t){C(t),e(t)}(t);break;case"longest-path":H(t)}};var H=C;function V(C){t(C)}return DZ}function Dw(){if(NZ)return FZ;NZ=1;var C=ww();return FZ=function(e){var t=function(e){var t={},H=0;function V(i){var L=H;C.forEach(e.children(i),V),t[i]={low:L,lim:H++}}return C.forEach(e.children(),V),t}(e);C.forEach(e.graph().dummyChains,(function(C){for(var H=e.node(C),V=H.edgeObj,i=function(C,e,t,H){var V,i,L=[],n=[],r=Math.min(e[t].low,e[H].low),o=Math.max(e[t].lim,e[H].lim);V=t;do{V=C.parent(V),L.push(V)}while(V&&(e[V].low>r||o>e[V].lim));i=V,V=H;for(;(V=C.parent(V))!==i;)n.push(V);return{path:L.concat(n.reverse()),lca:i}}(e,t,V.v,V.w),L=i.path,n=i.lca,r=0,o=L[r],a=!0;C!==V.w;){if(H=e.node(C),a){for(;(o=L[r])!==n&&e.node(o).maxRank=e.barycenter)&&function(C,e){var t=0,H=0;C.weight&&(t+=C.barycenter*C.weight,H+=C.weight);e.weight&&(t+=e.barycenter*e.weight,H+=e.weight);C.vs=e.vs.concat(C.vs),C.barycenter=t/H,C.weight=H,C.i=Math.min(e.i,C.i),e.merged=!0}(e,t)}}function V(C){return function(t){t.in.push(C),0==--t.indegree&&e.push(t)}}for(;e.length;){var i=e.pop();t.push(i),C.forEach(i.in.reverse(),H(i)),C.forEach(i.out,V(i))}return C.map(C.filter(t,(function(C){return!C.merged})),(function(e){return C.pick(e,["vs","i","barycenter","weight"])}))}(C.filter(H,(function(C){return!C.indegree})))},JZ}function Iw(){if(VS)return HS;VS=1;var C=ww(),e=function(){if(KZ)return QZ;KZ=1;var C=ww();return QZ=function(e,t){return C.map(t,(function(t){var H=e.inEdges(t);if(H.length){var V=C.reduce(H,(function(C,t){var H=e.edge(t),V=e.node(t.v);return{sum:C.sum+H.weight*V.order,weight:C.weight+H.weight}}),{sum:0,weight:0});return{v:t,barycenter:V.sum/V.weight,weight:V.weight}}return{v:t}}))}}(),t=Nw(),H=function(){if(tS)return eS;tS=1;var C=ww(),e=kw();function t(e,t,H){for(var V;t.length&&(V=C.last(t)).i<=H;)t.pop(),e.push(V.vs),H++;return H}return eS=function(H,V){var i,L=e.partition(H,(function(e){return C.has(e,"barycenter")})),n=L.lhs,r=C.sortBy(L.rhs,(function(C){return-C.i})),o=[],a=0,M=0,s=0;n.sort((i=!!V,function(C,e){return C.barycentere.barycenter?1:i?e.i-C.i:C.i-e.i})),s=t(o,r,s),C.forEach(n,(function(C){s+=C.vs.length,o.push(C.vs),a+=C.barycenter*C.weight,M+=C.weight,s=t(o,r,s)}));var l={vs:C.flatten(o,!0)};return M&&(l.barycenter=a/M,l.weight=M),l}}();return HS=function V(i,L,n,r){var o=i.children(L),a=i.node(L),M=a?a.borderLeft:void 0,s=a?a.borderRight:void 0,l={};M&&(o=C.filter(o,(function(C){return C!==M&&C!==s})));var d=e(i,o);C.forEach(d,(function(e){if(i.children(e.v).length){var t=V(i,e.v,n,r);l[e.v]=t,C.has(t,"barycenter")&&(H=e,L=t,C.isUndefined(H.barycenter)?(H.barycenter=L.barycenter,H.weight=L.weight):(H.barycenter=(H.barycenter*H.weight+L.barycenter*L.weight)/(H.weight+L.weight),H.weight+=L.weight))}var H,L}));var u=t(d,n);!function(e,t){C.forEach(e,(function(e){e.vs=C.flatten(e.vs.map((function(C){return t[C]?t[C].vs:C})),!0)}))}(u,l);var c=H(u,r);if(M&&(c.vs=C.flatten([M,c.vs,s],!0),i.predecessors(M).length)){var A=i.node(i.predecessors(M)[0]),h=i.node(i.predecessors(s)[0]);C.has(c,"barycenter")||(c.barycenter=0,c.weight=0),c.barycenter=(c.barycenter*c.weight+A.order+h.order)/(c.weight+2),c.weight+=2}return c},HS}function zw(){if(LS)return iS;LS=1;var C=ww(),e=Jb().Graph;return iS=function(t,H,V){var i=function(e){var t;for(;e.hasNode(t=C.uniqueId("_root")););return t}(t),L=new e({compound:!0}).setGraph({root:i}).setDefaultNodeLabel((function(C){return t.node(C)}));return C.forEach(t.nodes(),(function(e){var n=t.node(e),r=t.parent(e);(n.rank===H||n.minRank<=H&&H<=n.maxRank)&&(L.setNode(e),L.setParent(e,r||i),C.forEach(t[V](e),(function(H){var V=H.v===e?H.w:H.v,i=L.edge(V,e),n=C.isUndefined(i)?0:i.weight;L.setEdge(V,e,{weight:t.edge(H).weight+n})})),C.has(n,"minRank")&&L.setNode(e,{borderLeft:n.borderLeft[H],borderRight:n.borderRight[H]}))})),L},iS}function jw(){if(aS)return oS;aS=1;var C=ww(),e=function(){if(YZ)return $Z;YZ=1;var C=ww();return $Z=function(e){var t={},H=C.filter(e.nodes(),(function(C){return!e.children(C).length})),V=C.max(C.map(H,(function(C){return e.node(C).rank}))),i=C.map(C.range(V+1),(function(){return[]})),L=C.sortBy(H,(function(C){return e.node(C).rank}));return C.forEach(L,(function H(V){if(!C.has(t,V)){t[V]=!0;var L=e.node(V);i[L.rank].push(V),C.forEach(e.successors(V),H)}})),i}}(),t=function(){if(qZ)return XZ;qZ=1;var C=ww();function e(e,t,H){for(var V=C.zipObject(H,C.map(H,(function(C,e){return e}))),i=C.flatten(C.map(t,(function(t){return C.sortBy(C.map(e.outEdges(t),(function(C){return{pos:V[C.w],weight:e.edge(C).weight}})),"pos")})),!0),L=1;L0;)e%2&&(t+=r[e+1]),r[e=e-1>>1]+=C.weight;o+=C.weight*t}))),o}return XZ=function(C,t){for(var H=0,V=1;V=2),M=n.buildLayerMatrix(H);var c=t(H,M);cr)&&i(H,C,o)}))}))}return C.reduce(t,(function(t,H){var i,L=-1,n=0;return C.forEach(H,(function(C,r){if("border"===e.node(C).dummy){var o=e.predecessors(C);o.length&&(i=e.node(o[0]).order,V(H,n,r,L,i),n=r,L=i)}V(H,n,H.length,i,t.length)})),H})),H}function i(C,e,t){if(e>t){var H=e;e=t,t=H}var V=C[e];V||(C[e]=V={}),V[t]=!0}function L(e,t,H){if(t>H){var V=t;t=H,H=V}return C.has(e[t],H)}function n(e,t,H,V){var i={},n={},r={};return C.forEach(t,(function(e){C.forEach(e,(function(C,e){i[C]=C,n[C]=C,r[C]=e}))})),C.forEach(t,(function(e){var t=-1;C.forEach(e,(function(e){var o=V(e);if(o.length){o=C.sortBy(o,(function(C){return r[C]}));for(var a=(o.length-1)/2,M=Math.floor(a),s=Math.ceil(a);M<=s;++M){var l=o[M];n[e]===e&&t1?e-1:0),H=1;H=(i=(u+A)/2))?u=i:A=i,(a=t>=(L=(c+h)/2))?c=L:h=L,V=l,!(l=l[M=a<<1|o]))return V[M]=d,C;if(n=+C._x.call(null,l.data),r=+C._y.call(null,l.data),e===n&&t===r)return d.next=l,V?V[M]=d:C._root=d,C;do{V=V?V[M]=new Array(4):C._root=new Array(4),(o=e>=(i=(u+A)/2))?u=i:A=i,(a=t>=(L=(c+h)/2))?c=L:h=L}while((M=a<<1|o)==(s=(r>=L)<<1|n>=i));return V[s]=l,V[M]=d,C}function Qw(C,e,t,H,V){this.node=C,this.x0=e,this.y0=t,this.x1=H,this.y1=V}function Kw(C){return C[0]}function Jw(C){return C[1]}function Cx(C,e,t){var H=new ex(null==e?Kw:e,null==t?Jw:t,NaN,NaN,NaN,NaN);return null==C?H:H.addAll(C)}function ex(C,e,t,H,V,i){this._x=C,this._y=e,this._x0=t,this._y0=H,this._x1=V,this._y1=i,this._root=void 0}function tx(C){for(var e={data:C.data},t=e;C=C.next;)t=t.next={data:C.data};return e}var Hx=Cx.prototype=ex.prototype;function Vx(C){return function(){return C}}function ix(C){return 1e-6*(C()-.5)}function Lx(C){return C.x+C.vx}function nx(C){return C.y+C.vy}function rx(C){return C.index}function ox(C,e){var t=C.get(e);if(!t)throw new Error("node not found: "+e);return t}Hx.copy=function(){var C,e,t=new ex(this._x,this._y,this._x0,this._y0,this._x1,this._y1),H=this._root;if(!H)return t;if(!H.length)return t._root=tx(H),t;for(C=[{source:H,target:t._root=new Array(4)}];H=C.pop();)for(var V=0;V<4;++V)(e=H.source[V])&&(e.length?C.push({source:e,target:H.target[V]=new Array(4)}):H.target[V]=tx(e));return t},Hx.add=function(C){const e=+this._x.call(null,C),t=+this._y.call(null,C);return qw(this.cover(e,t),e,t,C)},Hx.addAll=function(C){var e,t,H,V,i=C.length,L=new Array(i),n=new Array(i),r=1/0,o=1/0,a=-1/0,M=-1/0;for(t=0;ta&&(a=H),VM&&(M=V));if(r>a||o>M)return this;for(this.cover(r,o).cover(a,M),t=0;tC||C>=V||H>e||e>=i;)switch(n=(es||(i=r.y0)>l||(L=r.x1)=A)<<1|C>=c)&&(r=d[d.length-1],d[d.length-1]=d[d.length-1-o],d[d.length-1-o]=r)}else{var h=C-+this._x.call(null,u.data),m=e-+this._y.call(null,u.data),f=h*h+m*m;if(f=(n=(d+c)/2))?d=n:c=n,(a=L>=(r=(u+A)/2))?u=r:A=r,e=l,!(l=l[M=a<<1|o]))return this;if(!l.length)break;(e[M+1&3]||e[M+2&3]||e[M+3&3])&&(t=e,s=M)}for(;l.data!==C;)if(H=l,!(l=l.next))return this;return(V=l.next)&&delete l.next,H?(V?H.next=V:delete H.next,this):e?(V?e[M]=V:delete e[M],(l=e[0]||e[1]||e[2]||e[3])&&l===(e[3]||e[2]||e[1]||e[0])&&!l.length&&(t?t[s]=l:this._root=l),this):(this._root=V,this)},Hx.removeAll=function(C){for(var e=0,t=C.length;e{}};function Mx(){for(var C,e=0,t=arguments.length,H={};e=0&&(e=C.slice(t+1),C=C.slice(0,t)),C&&!H.hasOwnProperty(C))throw new Error("unknown type: "+C);return{type:C,name:e}}))),L=-1,n=i.length;if(!(arguments.length<2)){if(null!=e&&"function"!=typeof e)throw new Error("invalid callback: "+e);for(;++L0)for(var t,H,V=new Array(t),i=0;i=0&&e._call.call(null,C),e=e._next;--Ax}()}finally{Ax=0,function(){var C,e,t=ux,H=1/0;for(;t;)t._call?(H>t._time&&(H=t._time),C=t,t=t._next):(e=t._next,t._next=null,t=C?C._next=e:ux=e);cx=C,Ex(H)}(),gx=0}}function kx(){var C=yx.now(),e=C-px;e>fx&&(vx-=e,px=C)}function Ex(C){Ax||(hx&&(hx=clearTimeout(hx)),C-gx>24?(C<1/0&&(hx=setTimeout(Ox,C-yx.now()-vx)),mx&&(mx=clearInterval(mx))):(mx||(px=yx.now(),mx=setInterval(kx,fx)),Ax=1,Zx(Ox)))}wx.prototype=xx.prototype={constructor:wx,restart:function(C,e,t){if("function"!=typeof C)throw new TypeError("callback is not a function");t=(null==t?Sx():+t)+(null==e?0:+e),this._next||cx===this||(cx?cx._next=this:ux=this,cx=this),this._call=C,this._time=t,Ex()},stop:function(){this._call&&(this._call=null,this._time=1/0,Ex())}};const Px=1664525,Tx=1013904223,Bx=4294967296;function _x(C){return C.x}function Dx(C){return C.y}var Rx=Math.PI*(3-Math.sqrt(5));var Fx=Object.freeze({__proto__:null,forceCenter:function(C,e){var t,H=1;function V(){var V,i,L=t.length,n=0,r=0;for(V=0;Vo+d||ia+d||Lr.index){var u=o-n.x-n.vx,c=a-n.y-n.vy,A=u*u+c*c;AC.r&&(C.r=C[e].r)}function r(){if(e){var H,V,i=e.length;for(t=new Array(i),H=0;H[n(C,e,H),C])));for(L=0,V=new Array(o);L=n)){(C.data!==e||C.next)&&(0===M&&(d+=(M=ix(t))*M),0===s&&(d+=(s=ix(t))*s),d(C=(Px*C+Tx)%Bx)/Bx}();function M(){s(),o.call("tick",e),t1?(null==t?n.delete(C):n.set(C,d(t)),e):n.get(C)},find:function(e,t,H){var V,i,L,n,r,o=0,a=C.length;for(null==H?H=1/0:H*=H,o=0;o1?(o.on(C,t),e):o.on(C)}}},forceX:function(C){var e,t,H,V=Vx(.1);function i(C){for(var V,i=0,L=e.length;i1?1:V)>=1?this.end(!C.infinite):(C.tick&&C.tick(V),C.animate&&this.refreshPositions(C.nodes,C,C.fit))}},{key:"end",value:function(C){var e=this.state;this.refreshPositions(e.nodes,e,e.fit),this.emit("layoutstop",e.cy),this.reset(C)}},{key:"reset",value:function(C){this.simulation&&this.simulation.stop();var e=this.state;return this.destroyedEvent&&this.destroyedEvent(),(C||!e.infinite)&&this.removeCytoscapeEvents&&this.removeCytoscapeEvents(),e.animate&&this.regrabify(e.nodes),this}},{key:"run",value:function(){var C=this;this.reset();var e=this,t=this.state,H=!1;if(t.currentBoundingBox=this.makeBoundingBox(t.boundingBox,t.cy),t.ready&&e.one("layoutready",t.ready),t.stop&&e.one("layoutstop",t.stop),t.nodes.forEach((function(e){return C.setInitialPositionState(e,t)})),H||(H=!0,e.emit("layoutready")),!e.simulation){var V=t.nodes.map((function(C){return L(e.getScratch(C),C.data())})),n=t.edges.map((function(C){return L({},C.data())}));e.simulation=i.forceSimulation(V),t.alpha&&e.simulation.alpha(t.alpha),t.alphaMin&&e.simulation.alphaMin(t.alphaMin),t.alphaDecay&&e.simulation.alphaDecay(t.alphaDecay),t.alphaTarget&&e.simulation.alphaTarget(t.alphaTarget),t.velocityDecay&&e.simulation.velocityDecay(t.velocityDecay);var r=i.forceCollide();t.collideRadius&&r.radius(t.collideRadius),t.collideStrength&&r.strength(t.collideStrength),t.collideIterations&&r.iterations(t.collideIterations);var o=i.forceLink(n);t.linkId&&o.id(t.linkId),t.linkDistance&&o.distance(t.linkDistance),t.linkStrength&&o.strength(t.linkStrength),t.linkIterations&&o.iterations(t.linkIterations);var a=i.forceManyBody();t.manyBodyStrength&&a.strength(t.manyBodyStrength),t.manyBodyTheta&&a.theta(t.manyBodyTheta),t.manyBodyDistanceMin&&a.distanceMin(t.manyBodyDistanceMin),t.manyBodyDistanceMax&&a.distanceMax(t.manyBodyDistanceMax);var M=i.forceX();t.xX&&M.x(t.xX),t.xStrength&&M.strength(t.xStrength);var s=i.forceY();t.yY&&s.y(t.yY),t.yStrength&&s.strength(t.yStrength);var l=null;(t.radialRadius||t.radialStrength||t.radialX||t.radialY)&&(l=i.forceRadial(),t.radialRadius&&l.radius(t.radialRadius),t.radialStrength&&l.strength(t.radialStrength),t.radialX&&l.x(t.radialX),t.radialY&&l.y(t.radialY));var d=i.forceCenter(t.currentBoundingBox.w/2,t.currentBoundingBox.h/2);e.simulation.force("collide",r).force("link",o).force("many-body",a).force("x",M).force("y",s).force("center",d),l&&e.simulation.force("radius",l),e.simulation.on("tick",(function(){e.tick()})).on("end",(function(){e.end()}))}if(!e.destroyedEvent){var u;t.cy.one("destroy",u=function(){e.stop()}),e.destroyedEvent=function(){t.cy.off("destroy",u),e.destroyedEvent=null}}if(e.prerun(t),e.emit("layoutstart"),t.progress=0,t.iterations=0,t.startTime=Date.now(),t.animate){var c=Math.abs((t.alpha||1)-(t.alphaTarget||0))/3;if(!e.removeCytoscapeEvents){var A=function(C){var H=this,V=H.position();if(C.cyTarget===H||C.target===H){var i=e.getScratch(H);t.progress=0,t.iterations=0,t.startTime=Date.now(),i.x=V.x,i.y=V.y,"grab"===C.type?e.simulation.alphaTarget(c).restart():"unlock"===C.type||"free"===C.type?(t.fixedAfterDragging?(i.fx=V.x,i.fy=V.y):(delete i.fx,delete i.fy),e.simulation.alphaTarget(c).restart()):(i.fx=V.x,i.fy=V.y)}};e.removeCytoscapeEvents=function(){t.nodes.off("grab free drag lock unlock",A),e.removeCytoscapeEvents=null},t.nodes.on("grab free drag lock unlock",A)}e.ungrabify(t.nodes)}return e.postrun(t),this}},{key:"prerun",value:function(){}},{key:"postrun",value:function(){}},{key:"stop",value:function(){return this.reset(!0)}}]),C}();C.exports=n},function(C,e,t){C.exports=null!=Object.assign?Object.assign.bind(Object):function(C){for(var e=arguments.length,t=Array(e>1?e-1:0),H=1;Hi+e.spotlightPadding?i+e.spotlightPadding:e.indicatorSize;A.beginPath(),A.fillRect(-s/2,-s/2,s,s),A.closePath(),A.fill(),A.rotate(-M),A.translate(-o,-a),A.beginPath(),A.arc(H+e.activePadding,H+e.activePadding,i+e.spotlightPadding,0,2*Math.PI,!0),A.closePath(),A.fill(),A.globalCompositeOperation="source-over"}function Z(){var C=o(),e=m,t=m;u.width=e*C,u.height=t*C,u.style.width=e+"px",u.style.height=t+"px",A.setTransform(1,0,0,1,0,0),A.scale(C,C)}i.insertBefore(l,i.firstChild),l.appendChild(d),d.appendChild(u),n(l,{position:"absolute",zIndex:e.zIndex,userSelect:"none",pointerEvents:"none"}),["mousedown","mousemove","mouseup","contextmenu"].forEach((function(C){l.addEventListener(C,(function(C){return C.preventDefault(),!1}))})),n(d,{display:"none",width:m+"px",height:m+"px",position:"absolute",zIndex:1,marginLeft:-e.activePadding+"px",marginTop:-e.activePadding+"px",userSelect:"none"}),u.width=m,u.height=m;var S=!0,b={},w=window.requestAnimationFrame||window.webkitRequestAnimationFrame||window.mozRequestAnimationFrame||window.msRequestAnimationFrame||function(C){return setTimeout(C,16)};Z(),function C(){b.drawBg&&v.apply(null,b.drawBg),b.drawCommands&&y.apply(null,b.drawCommands),b={},S&&w(C)}();var x,O,k,E,P,T,B,_,D=void 0,R=void 0,F=void 0,N={on:function(C,e,H){var V=H;return"core"===e&&(V=function(C){if(C.cyTarget===t||C.target===t)return H.apply(this,[C])}),s.handlers.push({events:C,selector:e,fn:V}),"core"===e?t.on(C,V):t.on(C,e,V),this}};function I(){S=!1,function(){for(var C=s.handlers,e=0;e0,V=(H?t.touches[0].pageX:t.pageX)-window.pageXOffset,i=(H?t.touches[0].pageY:t.pageY)-window.pageYOffset;f=void 0;var L=V-p.left-D,n=i-p.top-R;0===L&&(L=.01);var r=Math.sqrt(L*L+n*n),o=(n*n-r*r-L*L)/(-2*r*L),a=Math.acos(o),s=void 0;if(M&&M.isNode instanceof Function&&M.isNode()&&!M.isParent()&&!e.atMouse?(s=M.renderedOuterWidth(),F=s/2,F=!e.adaptativeNodeSpotlightRadius&&e.minSpotlightRadius?Math.max(F,e.minSpotlightRadius):F,F=!e.adaptativeNodeSpotlightRadius&&e.maxSpotlightRadius?Math.min(F,e.maxSpotlightRadius):F):(F=(s=1)/2,F=e.minSpotlightRadius?Math.max(F,e.minSpotlightRadius):F,F=e.maxSpotlightRadius?Math.min(F,e.maxSpotlightRadius):F),h=s/2+(e.menuRadius instanceof Function?e.menuRadius(M):Number(e.menuRadius)),rh+e.activePadding+e.outsideMenuCancel)g(h,F);else{g(h,F);var l=L*h/r,d=n*h/r;n>0&&(a=Math.PI+Math.abs(a-Math.PI));for(var u=2*Math.PI/c.length,A=Math.PI/2,m=A+u,v=0;v1?e-1:0),H=1;H1&&void 0!==arguments[1]?arguments[1]:document).querySelectorAll(C),t=0;tC.data("name").localeCompare(e.data("name"));function CO(C,e,t){let{name:H}=e,{nodes:V}=e,{onClickText:i}=e,{onClickButton:L}=e,{icon:n=null}=e,{icon_tooltip:r=null}=e,{ctxmenu:o}=e,a=!0;return C.$$set=C=>{"name"in C&&t(0,H=C.name),"nodes"in C&&t(1,V=C.nodes),"onClickText"in C&&t(2,i=C.onClickText),"onClickButton"in C&&t(3,L=C.onClickButton),"icon"in C&&t(4,n=C.icon),"icon_tooltip"in C&&t(5,r=C.icon_tooltip),"ctxmenu"in C&&t(6,o=C.ctxmenu)},[H,V,i,L,n,r,o,a,function(){t(7,a=!a)},(C,e)=>i(C,e),(C,e)=>o(C,e)]}class eO extends hC{constructor(C){super(),AC(this,C,CO,Kx,E,{name:0,nodes:1,onClickText:2,onClickButton:3,icon:4,icon_tooltip:5,ctxmenu:6})}}function tO(C){let e,t,H,V,i;return t=new eO({props:{nodes:C[0],name:"Nodes in graph",ctxmenu:C[2],onClickText:C[3]}}),V=new eO({props:{nodes:C[1],name:"Hidden nodes",ctxmenu:C[2],onClickText:C[3],icon:td.ag_unhide,icon_tooltip:"Show in graph",onClickButton:C[4]}}),{c(){e=F("div"),lC(t.$$.fragment),H=z(),lC(V.$$.fragment),W(e,"class","juggl-nodes-pane")},m(C,L){_(C,e,L),dC(t,e,null),B(e,H),dC(V,e,null),i=!0},p(C,[e]){const H={};1&e&&(H.nodes=C[0]),t.$set(H);const i={};2&e&&(i.nodes=C[1]),V.$set(i)},i(C){i||(aC(t.$$.fragment,C),aC(V.$$.fragment,C),i=!0)},o(C){MC(t.$$.fragment,C),MC(V.$$.fragment,C),i=!1},d(C){C&&D(e),uC(t),uC(V)}}}function HO(e,t,H){let V=null,i=Ol().collection(),L=Ol().collection();return[i,L,function(e,t){const H=new C.Menu,i=c.fromNode(e),L=V.plugin.metadata.getFirstLinkpathDest(i.id,"");void 0!==L&&V.plugin.app.workspace.trigger("file-menu",H,L,"my-context-menu",null),V.mode.fillMenu(H,e),H.showAtPosition({x:t.x,y:t.y})},function(C,e){V.plugin.openFileFromNode(C,e.metaKey)},function(C){C.removeClass(s),V.onGraphChanged(!0,!0)},function(C){if(!C)return V=null,H(0,i=Ol().collection()),void H(1,L=Ol().collection());V=C,H(0,i=V.viz.nodes(":visible")),H(1,L=V.viz.nodes(`.${s}`))}]}class VO extends hC{constructor(C){super(),AC(this,C,HO,tO,E,{setViz:5})}get setViz(){return this.$$.ctx[5]}}class iO extends C.FuzzySuggestModal{constructor(C,e,t){super(C),this.callback=e,this.resultContainerEl.addClass("juggl-icon-picker"),this.color=t}getItemText(C){return C.name}getItems(){const C=[{name:"No icon",path:"",color:this.color}];return C.push(...Object.keys(Cd).map((C=>({name:C.slice(3).replace(/([A-Z])/g," $1").trim(),path:Cd[C],color:this.color})))),C}onChooseItem(C,e){this.callback(C)}renderSuggestion(C,e){e.empty();const t=ed(C.item.path);e.createEl("span",{cls:"react-icon "}).innerHTML=t,super.renderSuggestion(C,e)}}function LO(C,e,t){const H=C.slice();return H[15]=e[t],H[16]=e,H[17]=t,H}function nO(C,e,t){const H=C.slice();return H[18]=e[t],H}function rO(C){let e,t,H,V,i,L,n,r,o=C[15].filter+"";return{c(){e=F("div"),t=F("div"),t.innerHTML='',H=z(),V=I(o),i=z(),L=F("br"),W(t,"class","clickable-icon"),Y(t,"display","inline"),W(t,"aria-label","Show group options"),W(e,"class","juggl-style-group-hidden")},m(o,a){_(o,e,a),B(e,t),B(e,H),B(e,V),_(o,i,a),_(o,L,a),n||(r=G(t,"click",(function(){k(C[7](C[15],!0))&&C[7](C[15],!0).apply(this,arguments)})),n=!0)},p(e,t){C=e,1&t&&o!==(o=C[15].filter+"")&&U(V,o)},d(C){C&&(D(e),D(i),D(L)),n=!1,r()}}}function oO(C){let e,t,H,V,i,L,n,r,o,a,M,s,l,d,u,c,A,h,m,f,p,g,v,y,Z,S,b,w,x,E,P,T,j,Y,q,Q=Math.round(100*C[15].size)/100+"";function K(){C[10].call(M,C[16],C[17])}function J(){C[11].call(h,C[16],C[17])}let CC=sC(fC),eC=[];for(let e=0;e',V=z(),i=F("div"),L=N("svg"),n=N("path"),a=z(),M=F("input"),s=z(),l=F("div"),l.innerHTML='',d=z(),u=F("div"),c=z(),A=F("div"),h=F("input"),m=z(),f=F("select");for(let C=0;CNew group',W(e,"class","juggl-list-header"),W(L,"class","graph-color-button-container"),W(V,"class","juggl-style-group-container")},m(o,M){_(o,e,M),B(e,t),_(o,H,M),_(o,V,M);for(let C=0;C{"groups"in C&&t(0,H=C.groups),"title"in C&&t(1,V=C.title),"onChangeFilter"in C&&t(2,i=C.onChangeFilter),"onChangeGroups"in C&&t(3,L=C.onChangeGroups),"plugin"in C&&t(9,n=C.plugin)},[H,V,i,L,function(){H.push({...kC}),t(0,H),L()},function(C){H.remove(C),t(0,H),i(),L()},function(C){new iO(n.app,(function(e){C.icon=e,L(),t(0,H)}),C.icon.color).open()},function(C,e){C.showInPane=e,t(0,H)},function(C){C.show=!C.show,L(),t(0,H)},n,function(C,e){C[e].filter=this.value,t(0,H)},function(C,e){C[e].color=this.value,t(0,H)},function(C,e){C[e].shape=function(C){const e=C.querySelector(":checked");return e&&e.__value}(this),t(0,H)},function(C,e){C[e].icon.color=this.value,t(0,H)},function(C,e){var V;C[e].size=""===(V=this.value)?null:+V,t(0,H)}]}class AO extends hC{constructor(C){super(),AC(this,C,cO,uO,E,{groups:0,title:1,onChangeFilter:2,onChangeGroups:3,plugin:9})}}function hO(C){let e,t,H,V,i;return t=new AO({props:{groups:C[1],title:"Local style groups",onChangeGroups:C[3],onChangeFilter:C[5],plugin:C[0]}}),V=new AO({props:{groups:C[2],title:"Global style groups",onChangeGroups:C[4],onChangeFilter:C[6],plugin:C[0]}}),{c(){e=F("div"),lC(t.$$.fragment),H=z(),lC(V.$$.fragment),W(e,"class","juggl-style-pane")},m(C,L){_(C,e,L),dC(t,e,null),B(e,H),dC(V,e,null),i=!0},p(C,[e]){const H={};2&e&&(H.groups=C[1]),1&e&&(H.plugin=C[0]),t.$set(H);const i={};1&e&&(i.plugin=C[0]),V.$set(i)},i(C){i||(aC(t.$$.fragment,C),aC(V.$$.fragment,C),i=!0)},o(C){MC(t.$$.fragment,C),MC(V.$$.fragment,C),i=!1},d(C){C&&D(e),uC(t),uC(V)}}}function mO(C,e,t){let{viz:H}=e,{plugin:V}=e,i=V?.settings;let L=[],n=i.globalStyleGroups;return C.$$set=C=>{"viz"in C&&t(7,H=C.viz),"plugin"in C&&t(0,V=C.plugin)},[V,L,n,function(){H&&H.updateStylesheet()},function(){V.saveData(i),V.activeGraphs().forEach((C=>C.updateStylesheet()))},function(){H&&H.assignStyleGroups()},function(){V.saveData(i),V.activeGraphs().forEach((C=>C.assignStyleGroups()))},H,function(C){t(7,H=C),t(1,L=H?H.settings.styleGroups:[])}]}class fO extends hC{constructor(C){super(),AC(this,C,mO,hO,E,{viz:7,plugin:0,setViz:8})}get setViz(){return this.$$.ctx[8]}}class pO extends C.ItemView{constructor(C,e){super(C),this.activeViz=null,this.changeRef=null,this.plugin=e;const t=this;this.registerEvent(this.plugin.app.workspace.on("active-leaf-change",(C=>{if(this.changeRef&&(this.activeViz.offref(this.changeRef),this.changeRef=null),C)if(C.view.getViewType()===g){const e=C.view.juggl;if(this.changeRef=e.on("elementsChange",(()=>{t.onActiveVizChange()})),e===this.activeViz)return;this.activeViz=e}else C.view instanceof pO||(this.activeViz=null);else this.activeViz=null;this.onActiveVizChange()})))}setViz(C){this.activeViz=C,this.onActiveVizChange()}}class gO extends pO{constructor(C,e){super(C,e),this.icon="ag-node-list"}onload(){super.onload(),this.pane=new VO({target:this.contentEl})}getDisplayText(){return"Juggl nodes"}getViewType(){return v}onActiveVizChange(){this.pane&&this.pane.setViz.bind(this.pane)(this.activeViz)}}class vO extends pO{constructor(C,e){super(C,e),this.icon="ag-style"}onload(){super.onload(),this.pane=new fO({target:this.contentEl,props:{plugin:this.plugin}})}getDisplayText(){return"Juggl style"}getViewType(){return y}onActiveVizChange(){this.pane&&this.pane.setViz.bind(this.pane)(this.activeViz)}}class yO extends C.Component{constructor(C){super(),this.graphs=[],this.plugin=C,this.adapter=this.plugin.app.vault.adapter}async onload(){super.onload();try{await this.adapter.mkdir(d(this.plugin.vault));const C=require("path");this.graphs=(await this.adapter.list(d(this.plugin.vault))).folders.map((e=>C.basename(e)))}catch(C){console.log(C)}}async saveGraph(C,e){try{const t=d(e.vault)+C;await this.adapter.mkdir(t);const H=e.viz.json();await this.adapter.write(t+"/graph.json",JSON.stringify(H));const V=e.settings;await this.adapter.write(t+"/settings.json",JSON.stringify(V)),this.graphs.contains(C)||this.graphs.push(C)}catch(C){console.log(C)}}async loadGraph(C,e){try{const t=d(e.vault)+C,H=JSON.parse(await this.adapter.read(t+"/graph.json")),V=JSON.parse(await this.adapter.read(t+"/settings.json"));e.viz.json(H),e.settings=V;const i=e.viz.nodes();for(let C=1;C{"cancelCallback"in C&&t(0,H=C.cancelCallback),"continueCallback"in C&&t(1,V=C.continueCallback)},[H,V]}class bO extends hC{constructor(C){super(),AC(this,C,SO,ZO,E,{cancelCallback:0,continueCallback:1})}}class wO extends C.Modal{constructor(C,e){super(C);new bO({target:this.modalEl,props:{cancelCallback:this.close.bind(this),continueCallback:e}})}}class xO extends C.Plugin{constructor(){super(...arguments),this.coreStores={},this.stores=[],this.eventHandlers=[]}async onload(){super.onload(),console.log("Loading Juggl"),Gd(Ol),Ol.use(bc),Ol.use(xA),Ol.use(Yw),Ol.use(th),Ol.use(Ix),Ol.use(Gx),Ol.use(Ux),Object.keys(td).forEach((e=>{C.addIcon(e.replace("_","-").replace("_","-"),ed(td[e]))})),this.vault=this.app.vault,this.metadata=this.app.metadataCache,this.path=this.vault.getRoot().path;const e=new S(this);this.addChild(e),this.workspaceManager=new yO(this),this.addChild(this.workspaceManager),this.registerCoreStore(e,Z),EC.globalStyleGroups=function(C){const e={},t=[["#0089BA","#2C73D2","#008E9B","#0081CF","#008F7A","#008E9B"],["#D65DB1","#0082C1","#9270D3","#007F93","#007ED9","#007660"],["#FF9671","#A36AAA","#F27D88","#6967A9","#D26F9D","#1b6299"],["#FFC75F","#4C9A52","#C3BB4E","#00855B","#88AC4B","#006F61"],["#FF6F91","#6F7F22","#E07250","#257A3E","#AC7C26","#006F5F"],["#F9F871","#2FAB63","#B8E067","#008E63","#78C664","#007160"]],H=[];for(const C of Array(6).keys())for(const e of Array(6).keys())H.push(t[e][C]);let V=0;for(const t of C.vault.getMarkdownFiles()){const i=C.metadata.getFileCache(t);i?.tags&&i.tags.forEach((C=>{const t=C.tag.slice(1).split("/"),i=[];for(const C in t){const e=t.slice(0,parseInt(C)+1).join("-");i.push(e)}for(const C of i)C in e||(e[C]=H[V],V+=1,V>=H.length&&(V=0))}))}const i=[{filter:"class:dangling",color:gC("color-fill-unresolved"),shape:"ellipse",icon:{name:"No icon",path:"",color:"white"},showInPane:!0,show:!0,size:1},{filter:"class:file -class:image",color:gC("color-fill"),shape:"ellipse",icon:{name:"No icon",path:"",color:"white"},showInPane:!0,show:!0,size:1}];for(const C of Object.keys(e))i.push({filter:`tag:#${C}`,color:e[C],shape:"ellipse",icon:{name:"No icon",path:"",color:"white"},showInPane:!0,show:!0,size:1});return i}(this),this.settings=Object.assign({},EC,await this.loadData()),this.settings.globalStyleGroups=this.settings.globalStyleGroups.map((C=>Object.assign({},kC,C))),this.settings.graphSettings=Object.assign({},EC.graphSettings,this.settings.graphSettings),this.settings.embedSettings=Object.assign({},EC.embedSettings,this.settings.embedSettings),this.registerHoverLinkSource("juggl-plugin",{display:"Juggl",defaultMod:!0}),this.addCommand({id:"open-vis",name:"Open local graph of note",callback:()=>{const C=this.app.workspace.getActiveFile().name;this.openLocalGraph(C)}}),this.addCommand({id:"open-vis-global",name:"Open global graph",callback:()=>{this.openGlobalGraph()}}),this.addSettingTab(new PC(this.app,this)),this.registerEvent(this.app.workspace.on("file-menu",((C,e)=>{e&&C.addItem((C=>{C.setTitle("Open Juggl").setIcon("dot-network").onClick((C=>{"md"===e.extension?this.openLocalGraph(e.basename):this.openLocalGraph(e.name)}))}))}))),this.registerMarkdownCodeBlockProcessor("juggl",(async(e,t,H)=>{setTimeout((async()=>{const H=C.parseYaml(e);try{const C=Object.assign({},this.settings.embedSettings,H);if(!OC.contains(C.layout))throw new Error(`Invalid layout. Choose one from ${OC}`);const e={dataStores:[this.coreStores[C.coreStore]].concat(this.stores),coreStore:this.coreStores[C.coreStore]};if(t.style.width=C.width,t.style.height=C.height,Object.keys(H).contains("local"))this.addChild(new Id(t,this,e,C,[H.local]));else if(Object.keys(H).contains("workspace")){const V=new Id(t,this,e,C,null);if(!this.workspaceManager.graphs.contains(H.workspace))throw new Error("Did not recognize workspace. Did you misspell its name?");this.addChild(V),await this.workspaceManager.loadGraph(H.workspace,V)}else{if(!Object.keys(H).contains("oql"))throw new Error("Invalid query. Specify either the local property or the workspace property.");if(!("obsidian-query-language"in this.app.plugins.plugins))throw new Error("The Obsidian Query Language plugin isn't loaded, so cannot query using oql!");{const V=await this.app.plugins.plugins["obsidian-query-language"].search(H.oql);C.expandInitial=!1,this.addChild(new Id(t,this,e,C,V.map((C=>C.title))))}}}catch(C){const e=activeDocument.createElement("div");e.addClass("juggl-error"),e.innerText=C.message,t.appendChild(e)}}),200)}));const t=this;this.registerView(v,(C=>new gO(C,t))),this.registerView(y,(C=>new vO(C,t)));const H=function(){if(0===t.app.workspace.getLeavesOfType(v).length){t.app.workspace.getRightLeaf(!1).setViewState({type:v})}},V=function(){if(0===t.app.workspace.getLeavesOfType(y).length){t.app.workspace.getRightLeaf(!1).setViewState({type:y})}};this.app.workspace.onLayoutReady(H),this.app.workspace.onLayoutReady(V),this.addCommand({id:"show-nodes-pane",name:"Open Nodes Pane",checkCallback:C=>{if(C)return 0===this.app.workspace.getLeavesOfType(v).length;H()}}),this.addCommand({id:"show-style-pane",name:"Open Style Pane",checkCallback:C=>{if(C)return 0===this.app.workspace.getLeavesOfType(y).length;V()}});const i=mC(this.vault);this.registerEvent(this.vault.on("raw",(C=>{if(C===i){console.log(`Updating stylesheet from ${i}`);for(const C of this.activeGraphs())C.updateStylesheet().then()}}))),this.setGlobalIcon(),this.addChild(new zd(this))}setGlobalIcon(){this.ribbonIcon&&this.ribbonIcon.detach(),this.settings.globalGraphRibbon&&(this.ribbonIcon=this.addRibbonIcon("ag-concentric","Juggl global graph",(()=>{this.openGlobalGraph()})))}async openFileFromNode(C,e=!1){const t=c.fromNode(C);if("core"!==t.storeId)return null;let H=this.app.metadataCache.getFirstLinkpathDest(t.id,"");if(H)await this.openFile(H);else{const C=t.id+".md";H=await this.vault.create(C,""),await this.openFile(H)}return H}async openFile(C,e=!1){await this.app.workspace.getLeaf(e).openFile(C)}async openLocalGraph(C){const e=this.app.workspace.splitActiveLeaf(this.settings.splitDirection),t=new $x(e,this.settings.graphSettings,this,[C]);await e.open(t)}async openGlobalGraph(){const C=this.app.workspace.getLeaf(!1),e=this.app.vault.getFiles().map((C=>"md"===C.extension?C.basename:C.name));if(e.length>250){const t=new wO(this.app,(async()=>{const H=new $x(C,this.settings.globalGraphSettings,this,e);await C.open(H),t.close()}));t.open()}else{const t=new $x(C,this.settings.globalGraphSettings,this,e);await C.open(t)}}activeGraphs(){return this.app.workspace.getLeavesOfType(g).map((C=>C.view.juggl))}async onunload(){super.onunload(),console.log("Unloading Juggl"),this.app.workspace.detachLeavesOfType(v),this.app.workspace.detachLeavesOfType(y),this.watcher&&this.watcher.close()}registerStore(C){this.stores.push(C)}removeStore(C){this.stores.remove(C)}registerCoreStore(C,e){if("core"!==C.storeId())throw new Error("Can only register IDataStores as core if their storeId is core");this.coreStores[e]=C}createJuggl(C,e,t,H){return e||(e=Object.assign({},EC.embedSettings),H&&(e.expandInitial=!1)),t||(t=this.defaultStores()),new Id(C,this,t,e,H)}defaultStores(){return{dataStores:[this.coreStores[Z]].concat(this.stores),coreStore:this.coreStores[Z]}}registerEvents(C){this.eventHandlers.push(C)}removeEvents(C){this.eventHandlers.remove(C)}}xO.CAT_DANGLING="dangling",module.exports=xO;