var Hx=Object.defineProperty;var x0=Oe=>{throw TypeError(Oe)};var eN=(Oe,fe,Fe)=>fe in Oe?Hx(Oe,fe,{enumerable:!0,configurable:!0,writable:!0,value:Fe}):Oe[fe]=Fe;var Ie=(Oe,fe,Fe)=>eN(Oe,typeof fe!="symbol"?fe+"":fe,Fe),qc=(Oe,fe,Fe)=>fe.has(Oe)||x0("Cannot "+Fe);var gt=(Oe,fe,Fe)=>(qc(Oe,fe,"read from private field"),Fe?Fe.call(Oe):fe.get(Oe)),Rc=(Oe,fe,Fe)=>fe.has(Oe)?x0("Cannot add the same private member more than once"):fe instanceof WeakSet?fe.add(Oe):fe.set(Oe,Fe),fn=(Oe,fe,Fe,br)=>(qc(Oe,fe,"write to private field"),br?br.call(Oe,Fe):fe.set(Oe,Fe),Fe),Oc=(Oe,fe,Fe)=>(qc(Oe,fe,"access private method"),Fe);(function(){"use strict";function Oe(e,r){var t={};for(var n in e)Object.prototype.hasOwnProperty.call(e,n)&&r.indexOf(n)<0&&(t[n]=e[n]);if(e!=null&&typeof Object.getOwnPropertySymbols=="function")for(var i=0,n=Object.getOwnPropertySymbols(e);i{r.has(a.id)||(r.add(a.id),e.push(a))})}return!1}function _r(e,r,t,n){if(t(e))return!0;r.add(e.id);for(const s of n(e.id))if(!r.has(s.id)&&_r(s,r,t,n))return!0;return!1}const Ic=()=>!0;class N0{constructor(r){Ie(this,"graph");Ie(this,"nodeFilter");Ie(this,"edgeFilter");Ie(this,"cacheEnabled");Ie(this,"inEdgesMap",new Map);Ie(this,"outEdgesMap",new Map);Ie(this,"bothEdgesMap",new Map);Ie(this,"allNodesMap",new Map);Ie(this,"allEdgesMap",new Map);Ie(this,"clearCache",()=>{this.inEdgesMap.clear(),this.outEdgesMap.clear(),this.bothEdgesMap.clear(),this.allNodesMap.clear(),this.allEdgesMap.clear()});Ie(this,"refreshCache",()=>{this.clearCache(),this.updateCache(this.graph.getAllNodes().map(r=>r.id))});Ie(this,"updateCache",r=>{const t=new Set;r.forEach(n=>{const i=this.bothEdgesMap.get(n);if(i&&i.forEach(s=>t.add(s.id)),!this.hasNode(n))this.inEdgesMap.delete(n),this.outEdgesMap.delete(n),this.bothEdgesMap.delete(n),this.allNodesMap.delete(n);else{const s=this.graph.getRelatedEdges(n,"in").filter(this.edgeFilter),a=this.graph.getRelatedEdges(n,"out").filter(this.edgeFilter),o=Array.from(new Set([...s,...a]));o.forEach(c=>t.add(c.id)),this.inEdgesMap.set(n,s),this.outEdgesMap.set(n,a),this.bothEdgesMap.set(n,o),this.allNodesMap.set(n,this.graph.getNode(n))}}),t.forEach(n=>{this.hasEdge(n)?this.allEdgesMap.set(n,this.graph.getEdge(n)):this.allEdgesMap.delete(n)})});Ie(this,"handleGraphChanged",r=>{const t=new Set;r.changes.forEach(n=>{switch(n.type){case"NodeAdded":t.add(n.value.id);break;case"NodeDataUpdated":t.add(n.id);break;case"EdgeAdded":t.add(n.value.source),t.add(n.value.target);break;case"EdgeUpdated":(n.propertyName==="source"||n.propertyName==="target")&&(t.add(n.oldValue),t.add(n.newValue));break;case"EdgeDataUpdated":if(r.graph.hasEdge(n.id)){const i=r.graph.getEdge(n.id);t.add(i.source),t.add(i.target)}break;case"EdgeRemoved":t.add(n.value.source),t.add(n.value.target);break;case"NodeRemoved":t.add(n.value.id);break}}),this.updateCache(t)});this.graph=r.graph;const t=r.nodeFilter||Ic,n=r.edgeFilter||Ic;this.nodeFilter=t,this.edgeFilter=i=>{const{source:s,target:a}=this.graph.getEdgeDetail(i.id);return!t(s)||!t(a)?!1:n(i,s,a)},r.cache==="auto"?(this.cacheEnabled=!0,this.startAutoCache()):r.cache==="manual"?this.cacheEnabled=!0:this.cacheEnabled=!1}startAutoCache(){this.refreshCache(),this.graph.on("changed",this.handleGraphChanged)}stopAutoCache(){this.graph.off("changed",this.handleGraphChanged)}checkNodeExistence(r){this.getNode(r)}hasNode(r){if(!this.graph.hasNode(r))return!1;const t=this.graph.getNode(r);return this.nodeFilter(t)}areNeighbors(r,t){return this.checkNodeExistence(r),this.getNeighbors(t).some(n=>n.id===r)}getNode(r){const t=this.graph.getNode(r);if(!this.nodeFilter(t))throw new Error("Node not found for id: "+r);return t}getRelatedEdges(r,t){return this.checkNodeExistence(r),this.cacheEnabled?t==="in"?this.inEdgesMap.get(r):t==="out"?this.outEdgesMap.get(r):this.bothEdgesMap.get(r):this.graph.getRelatedEdges(r,t).filter(this.edgeFilter)}getDegree(r,t){return this.getRelatedEdges(r,t).length}getSuccessors(r){const n=this.getRelatedEdges(r,"out").map(i=>this.getNode(i.target));return Array.from(new Set(n))}getPredecessors(r){const n=this.getRelatedEdges(r,"in").map(i=>this.getNode(i.source));return Array.from(new Set(n))}getNeighbors(r){const t=this.getPredecessors(r),n=this.getSuccessors(r);return Array.from(new Set([...t,...n]))}hasEdge(r){if(!this.graph.hasEdge(r))return!1;const t=this.graph.getEdge(r);return this.edgeFilter(t)}getEdge(r){const t=this.graph.getEdge(r);if(!this.edgeFilter(t))throw new Error("Edge not found for id: "+r);return t}getEdgeDetail(r){const t=this.getEdge(r);return{edge:t,source:this.getNode(t.source),target:this.getNode(t.target)}}hasTreeStructure(r){return this.graph.hasTreeStructure(r)}getRoots(r){return this.graph.getRoots(r).filter(this.nodeFilter)}getChildren(r,t){return this.checkNodeExistence(r),this.graph.getChildren(r,t).filter(this.nodeFilter)}getParent(r,t){this.checkNodeExistence(r);const n=this.graph.getParent(r,t);return!n||!this.nodeFilter(n)?null:n}getAllNodes(){return this.cacheEnabled?Array.from(this.allNodesMap.values()):this.graph.getAllNodes().filter(this.nodeFilter)}getAllEdges(){return this.cacheEnabled?Array.from(this.allEdgesMap.values()):this.graph.getAllEdges().filter(this.edgeFilter)}bfs(r,t,n="out"){const i={in:this.getPredecessors.bind(this),out:this.getSuccessors.bind(this),both:this.getNeighbors.bind(this)}[n];ln([this.getNode(r)],new Set,t,i)}dfs(r,t,n="out"){const i={in:this.getPredecessors.bind(this),out:this.getSuccessors.bind(this),both:this.getNeighbors.bind(this)}[n];_r(this.getNode(r),new Set,t,i)}}class Be extends br{constructor(t){super();Ie(this,"nodeMap",new Map);Ie(this,"edgeMap",new Map);Ie(this,"inEdgesMap",new Map);Ie(this,"outEdgesMap",new Map);Ie(this,"bothEdgesMap",new Map);Ie(this,"treeIndices",new Map);Ie(this,"changes",[]);Ie(this,"batchCount",0);Ie(this,"onChanged",()=>{});Ie(this,"batch",t=>{this.batchCount+=1,t(),this.batchCount-=1,this.batchCount||this.commit()});t&&(t.nodes&&this.addNodes(t.nodes),t.edges&&this.addEdges(t.edges),t.tree&&this.addTree(t.tree),t.onChanged&&(this.onChanged=t.onChanged))}commit(){const t=this.changes;this.changes=[];const n={graph:this,changes:t};this.emit("changed",n),this.onChanged(n)}reduceChanges(t){let n=[];return t.forEach(i=>{switch(i.type){case"NodeRemoved":{let s=!1;n=n.filter(a=>{if(a.type==="NodeAdded"){const o=a.value.id===i.value.id;return o&&(s=!0),!o}else{if(a.type==="NodeDataUpdated")return a.id!==i.value.id;if(a.type==="TreeStructureChanged")return a.nodeId!==i.value.id}return!0}),s||n.push(i);break}case"EdgeRemoved":{let s=!1;n=n.filter(a=>{if(a.type==="EdgeAdded"){const o=a.value.id===i.value.id;return o&&(s=!0),!o}else if(a.type==="EdgeDataUpdated"||a.type==="EdgeUpdated")return a.id!==i.value.id;return!0}),s||n.push(i);break}case"NodeDataUpdated":case"EdgeDataUpdated":case"EdgeUpdated":{const s=n.findIndex(o=>o.type===i.type&&o.id===i.id&&(i.propertyName===void 0||o.propertyName===i.propertyName)),a=n[s];a?i.propertyName!==void 0?a.newValue=i.newValue:(n.splice(s,1),n.push(i)):n.push(i);break}case"TreeStructureDetached":{n=n.filter(s=>s.type==="TreeStructureAttached"||s.type==="TreeStructureChanged"?s.treeKey!==i.treeKey:!0),n.push(i);break}case"TreeStructureChanged":{const s=n.find(a=>a.type==="TreeStructureChanged"&&a.treeKey===i.treeKey&&a.nodeId===i.nodeId);s?s.newParentId=i.newParentId:n.push(i);break}default:n.push(i);break}}),n}checkNodeExistence(t){this.getNode(t)}hasNode(t){return this.nodeMap.has(t)}areNeighbors(t,n){return this.getNeighbors(n).some(i=>i.id===t)}getNode(t){const n=this.nodeMap.get(t);if(!n)throw new Error("Node not found for id: "+t);return n}getRelatedEdges(t,n){if(this.checkNodeExistence(t),n==="in"){const i=this.inEdgesMap.get(t);return Array.from(i)}else if(n==="out"){const i=this.outEdgesMap.get(t);return Array.from(i)}else{const i=this.bothEdgesMap.get(t);return Array.from(i)}}getDegree(t,n){return this.getRelatedEdges(t,n).length}getSuccessors(t){const i=this.getRelatedEdges(t,"out").map(s=>this.getNode(s.target));return Array.from(new Set(i))}getPredecessors(t){const i=this.getRelatedEdges(t,"in").map(s=>this.getNode(s.source));return Array.from(new Set(i))}getNeighbors(t){const n=this.getPredecessors(t),i=this.getSuccessors(t);return Array.from(new Set([...n,...i]))}doAddNode(t){if(this.hasNode(t.id))throw new Error("Node already exists: "+t.id);this.nodeMap.set(t.id,t),this.inEdgesMap.set(t.id,new Set),this.outEdgesMap.set(t.id,new Set),this.bothEdgesMap.set(t.id,new Set),this.treeIndices.forEach(n=>{n.childrenMap.set(t.id,new Set)}),this.changes.push({type:"NodeAdded",value:t})}addNodes(t){this.batch(()=>{for(const n of t)this.doAddNode(n)})}addNode(t){this.addNodes([t])}doRemoveNode(t){const n=this.getNode(t),i=this.bothEdgesMap.get(t);i==null||i.forEach(s=>this.doRemoveEdge(s.id)),this.nodeMap.delete(t),this.treeIndices.forEach(s=>{var o,c;(o=s.childrenMap.get(t))==null||o.forEach(f=>{s.parentMap.delete(f.id)});const a=s.parentMap.get(t);a&&((c=s.childrenMap.get(a.id))==null||c.delete(n)),s.parentMap.delete(t),s.childrenMap.delete(t)}),this.bothEdgesMap.delete(t),this.inEdgesMap.delete(t),this.outEdgesMap.delete(t),this.changes.push({type:"NodeRemoved",value:n})}removeNodes(t){this.batch(()=>{t.forEach(n=>this.doRemoveNode(n))})}removeNode(t){this.removeNodes([t])}updateNodeDataProperty(t,n,i){const s=this.getNode(t);this.batch(()=>{const a=s.data[n],o=i;s.data[n]=o,this.changes.push({type:"NodeDataUpdated",id:t,propertyName:n,oldValue:a,newValue:o})})}mergeNodeData(t,n){this.batch(()=>{Object.entries(n).forEach(([i,s])=>{this.updateNodeDataProperty(t,i,s)})})}updateNodeData(...t){const n=t[0],i=this.getNode(n);if(typeof t[1]=="string"){this.updateNodeDataProperty(n,t[1],t[2]);return}let s;if(typeof t[1]=="function"){const a=t[1];s=a(i.data)}else typeof t[1]=="object"&&(s=t[1]);this.batch(()=>{const a=i.data,o=s;i.data=s,this.changes.push({type:"NodeDataUpdated",id:n,oldValue:a,newValue:o})})}checkEdgeExistence(t){if(!this.hasEdge(t))throw new Error("Edge not found for id: "+t)}hasEdge(t){return this.edgeMap.has(t)}getEdge(t){return this.checkEdgeExistence(t),this.edgeMap.get(t)}getEdgeDetail(t){const n=this.getEdge(t);return{edge:n,source:this.getNode(n.source),target:this.getNode(n.target)}}doAddEdge(t){if(this.hasEdge(t.id))throw new Error("Edge already exists: "+t.id);this.checkNodeExistence(t.source),this.checkNodeExistence(t.target),this.edgeMap.set(t.id,t);const n=this.inEdgesMap.get(t.target),i=this.outEdgesMap.get(t.source),s=this.bothEdgesMap.get(t.source),a=this.bothEdgesMap.get(t.target);n.add(t),i.add(t),s.add(t),a.add(t),this.changes.push({type:"EdgeAdded",value:t})}addEdges(t){this.batch(()=>{for(const n of t)this.doAddEdge(n)})}addEdge(t){this.addEdges([t])}doRemoveEdge(t){const n=this.getEdge(t),i=this.outEdgesMap.get(n.source),s=this.inEdgesMap.get(n.target),a=this.bothEdgesMap.get(n.source),o=this.bothEdgesMap.get(n.target);i.delete(n),s.delete(n),a.delete(n),o.delete(n),this.edgeMap.delete(t),this.changes.push({type:"EdgeRemoved",value:n})}removeEdges(t){this.batch(()=>{t.forEach(n=>this.doRemoveEdge(n))})}removeEdge(t){this.removeEdges([t])}updateEdgeSource(t,n){const i=this.getEdge(t);this.checkNodeExistence(n);const s=i.source,a=n;this.outEdgesMap.get(s).delete(i),this.bothEdgesMap.get(s).delete(i),this.outEdgesMap.get(a).add(i),this.bothEdgesMap.get(a).add(i),i.source=n,this.batch(()=>{this.changes.push({type:"EdgeUpdated",id:t,propertyName:"source",oldValue:s,newValue:a})})}updateEdgeTarget(t,n){const i=this.getEdge(t);this.checkNodeExistence(n);const s=i.target,a=n;this.inEdgesMap.get(s).delete(i),this.bothEdgesMap.get(s).delete(i),this.inEdgesMap.get(a).add(i),this.bothEdgesMap.get(a).add(i),i.target=n,this.batch(()=>{this.changes.push({type:"EdgeUpdated",id:t,propertyName:"target",oldValue:s,newValue:a})})}updateEdgeDataProperty(t,n,i){const s=this.getEdge(t);this.batch(()=>{const a=s.data[n],o=i;s.data[n]=o,this.changes.push({type:"EdgeDataUpdated",id:t,propertyName:n,oldValue:a,newValue:o})})}updateEdgeData(...t){const n=t[0],i=this.getEdge(n);if(typeof t[1]=="string"){this.updateEdgeDataProperty(n,t[1],t[2]);return}let s;if(typeof t[1]=="function"){const a=t[1];s=a(i.data)}else typeof t[1]=="object"&&(s=t[1]);this.batch(()=>{const a=i.data,o=s;i.data=s,this.changes.push({type:"EdgeDataUpdated",id:n,oldValue:a,newValue:o})})}mergeEdgeData(t,n){this.batch(()=>{Object.entries(n).forEach(([i,s])=>{this.updateEdgeDataProperty(t,i,s)})})}checkTreeExistence(t){if(!this.hasTreeStructure(t))throw new Error("Tree structure not found for treeKey: "+t)}hasTreeStructure(t){return this.treeIndices.has(t)}attachTreeStructure(t){this.treeIndices.has(t)||(this.treeIndices.set(t,{parentMap:new Map,childrenMap:new Map}),this.batch(()=>{this.changes.push({type:"TreeStructureAttached",treeKey:t})}))}detachTreeStructure(t){this.checkTreeExistence(t),this.treeIndices.delete(t),this.batch(()=>{this.changes.push({type:"TreeStructureDetached",treeKey:t})})}addTree(t,n){this.batch(()=>{this.attachTreeStructure(n);const i=[],s=Array.isArray(t)?t:[t];for(;s.length;){const a=s.shift();i.push(a),a.children&&s.push(...a.children)}this.addNodes(i),i.forEach(a=>{var o;(o=a.children)==null||o.forEach(c=>{this.setParent(c.id,a.id,n)})})})}getRoots(t){return this.checkTreeExistence(t),this.getAllNodes().filter(n=>!this.getParent(n.id,t))}getChildren(t,n){this.checkNodeExistence(t),this.checkTreeExistence(n);const s=this.treeIndices.get(n).childrenMap.get(t);return Array.from(s||[])}getParent(t,n){return this.checkNodeExistence(t),this.checkTreeExistence(n),this.treeIndices.get(n).parentMap.get(t)||null}getAncestors(t,n){const i=[];let s=this.getNode(t),a;for(;a=this.getParent(s.id,n);)i.push(a),s=a;return i}setParent(t,n,i){var l,p;this.checkTreeExistence(i);const s=this.treeIndices.get(i);if(!s)return;const a=this.getNode(t),o=s.parentMap.get(t);if((o==null?void 0:o.id)===n)return;if(n==null){o&&((l=s.childrenMap.get(o.id))==null||l.delete(a)),s.parentMap.delete(t);return}const c=this.getNode(n);s.parentMap.set(t,c),o&&((p=s.childrenMap.get(o.id))==null||p.delete(a));let f=s.childrenMap.get(c.id);f||(f=new Set,s.childrenMap.set(c.id,f)),f.add(a),this.batch(()=>{this.changes.push({type:"TreeStructureChanged",treeKey:i,nodeId:t,oldParentId:o==null?void 0:o.id,newParentId:c.id})})}dfsTree(t,n,i){const s=a=>this.getChildren(a,i);return _r(this.getNode(t),new Set,n,s)}bfsTree(t,n,i){const s=a=>this.getChildren(a,i);return ln([this.getNode(t)],new Set,n,s)}getAllNodes(){return Array.from(this.nodeMap.values())}getAllEdges(){return Array.from(this.edgeMap.values())}bfs(t,n,i="out"){const s={in:this.getPredecessors.bind(this),out:this.getSuccessors.bind(this),both:this.getNeighbors.bind(this)}[i];return ln([this.getNode(t)],new Set,n,s)}dfs(t,n,i="out"){const s={in:this.getPredecessors.bind(this),out:this.getSuccessors.bind(this),both:this.getNeighbors.bind(this)}[i];return _r(this.getNode(t),new Set,n,s)}clone(){const t=this.getAllNodes().map(s=>({...s,data:{...s.data}})),n=this.getAllEdges().map(s=>({...s,data:{...s.data}})),i=new Be({nodes:t,edges:n});return this.treeIndices.forEach(({parentMap:s,childrenMap:a},o)=>{const c=new Map;s.forEach((l,p)=>{c.set(p,i.getNode(l.id))});const f=new Map;a.forEach((l,p)=>{f.set(p,new Set(Array.from(l).map(m=>i.getNode(m.id))))}),i.treeIndices.set(o,{parentMap:c,childrenMap:f})}),i}toJSON(){return JSON.stringify({nodes:this.getAllNodes(),edges:this.getAllEdges()})}createView(t){return new N0({graph:this,...t})}}/** * @license * Copyright 2019 Google LLC * SPDX-License-Identifier: Apache-2.0 */const Tc=Symbol("Comlink.proxy"),M0=Symbol("Comlink.endpoint"),S0=Symbol("Comlink.releaseProxy"),hn=Symbol("Comlink.finalizer"),Er=Symbol("Comlink.thrown"),kc=e=>typeof e=="object"&&e!==null||typeof e=="function",q0={canHandle:e=>kc(e)&&e[Tc],serialize(e){const{port1:r,port2:t}=new MessageChannel;return dn(e,r),[t,[t]]},deserialize(e){return e.start(),I0(e)}},R0={canHandle:e=>kc(e)&&Er in e,serialize({value:e}){let r;return e instanceof Error?r={isError:!0,value:{message:e.message,name:e.name,stack:e.stack}}:r={isError:!1,value:e},[r,[]]},deserialize(e){throw e.isError?Object.assign(new Error(e.value.message),e.value):e.value}},jc=new Map([["proxy",q0],["throw",R0]]);function O0(e,r){for(const t of e)if(r===t||t==="*"||t instanceof RegExp&&t.test(r))return!0;return!1}function dn(e,r=globalThis,t=["*"]){r.addEventListener("message",function n(i){if(!i||!i.data)return;if(!O0(t,i.origin)){console.warn(`Invalid origin '${i.origin}' for comlink proxy`);return}const{id:s,type:a,path:o}=Object.assign({path:[]},i.data),c=(i.data.argumentList||[]).map(jt);let f;try{const l=o.slice(0,-1).reduce((m,y)=>m[y],e),p=o.reduce((m,y)=>m[y],e);switch(a){case"GET":f=p;break;case"SET":l[o.slice(-1)[0]]=jt(i.data.value),f=!0;break;case"APPLY":f=p.apply(l,c);break;case"CONSTRUCT":{const m=new p(...c);f=P0(m)}break;case"ENDPOINT":{const{port1:m,port2:y}=new MessageChannel;dn(e,y),f=C0(m,[m])}break;case"RELEASE":f=void 0;break;default:return}}catch(l){f={value:l,[Er]:0}}Promise.resolve(f).catch(l=>({value:l,[Er]:0})).then(l=>{const[p,m]=Sr(l);r.postMessage(Object.assign(Object.assign({},p),{id:s}),m),a==="RELEASE"&&(r.removeEventListener("message",n),Cc(r),hn in e&&typeof e[hn]=="function"&&e[hn]())}).catch(l=>{const[p,m]=Sr({value:new TypeError("Unserializable return value"),[Er]:0});r.postMessage(Object.assign(Object.assign({},p),{id:s}),m)})}),r.start&&r.start()}function A0(e){return e.constructor.name==="MessagePort"}function Cc(e){A0(e)&&e.close()}function I0(e,r){const t=new Map;return e.addEventListener("message",function(i){const{data:s}=i;if(!s||!s.id)return;const a=t.get(s.id);if(a)try{a(s)}finally{t.delete(s.id)}}),gn(e,t,[],r)}function xr(e){if(e)throw new Error("Proxy has been released and is not useable")}function Pc(e){return Gt(e,new Map,{type:"RELEASE"}).then(()=>{Cc(e)})}const Nr=new WeakMap,Mr="FinalizationRegistry"in globalThis&&new FinalizationRegistry(e=>{const r=(Nr.get(e)||0)-1;Nr.set(e,r),r===0&&Pc(e)});function T0(e,r){const t=(Nr.get(r)||0)+1;Nr.set(r,t),Mr&&Mr.register(e,r,e)}function k0(e){Mr&&Mr.unregister(e)}function gn(e,r,t=[],n=function(){}){let i=!1;const s=new Proxy(n,{get(a,o){if(xr(i),o===S0)return()=>{k0(s),Pc(e),r.clear(),i=!0};if(o==="then"){if(t.length===0)return{then:()=>s};const c=Gt(e,r,{type:"GET",path:t.map(f=>f.toString())}).then(jt);return c.then.bind(c)}return gn(e,r,[...t,o])},set(a,o,c){xr(i);const[f,l]=Sr(c);return Gt(e,r,{type:"SET",path:[...t,o].map(p=>p.toString()),value:f},l).then(jt)},apply(a,o,c){xr(i);const f=t[t.length-1];if(f===M0)return Gt(e,r,{type:"ENDPOINT"}).then(jt);if(f==="bind")return gn(e,r,t.slice(0,-1));const[l,p]=Lc(c);return Gt(e,r,{type:"APPLY",path:t.map(m=>m.toString()),argumentList:l},p).then(jt)},construct(a,o){xr(i);const[c,f]=Lc(o);return Gt(e,r,{type:"CONSTRUCT",path:t.map(l=>l.toString()),argumentList:c},f).then(jt)}});return T0(s,e),s}function j0(e){return Array.prototype.concat.apply([],e)}function Lc(e){const r=e.map(Sr);return[r.map(t=>t[0]),j0(r.map(t=>t[1]))]}const Dc=new WeakMap;function C0(e,r){return Dc.set(e,r),e}function P0(e){return Object.assign(e,{[Tc]:!0})}function Sr(e){for(const[r,t]of jc)if(t.canHandle(e)){const[n,i]=t.serialize(e);return[{type:"HANDLER",name:r,value:n},i]}return[{type:"RAW",value:e},Dc.get(e)||[]]}function jt(e){switch(e.type){case"HANDLER":return jc.get(e.name).deserialize(e.value);case"RAW":return e.value}}function Gt(e,r,t,n){return new Promise(i=>{const s=L0();r.set(s,i),e.start&&e.start(),e.postMessage(Object.assign({id:s},t),n)})}function L0(){return new Array(4).fill(0).map(()=>Math.floor(Math.random()*Number.MAX_SAFE_INTEGER).toString(16)).join("-")}function wt(e){return typeof e=="function"}function D0(e){return e==null}function pn(e){return Array.isArray(e)}var Ut=function(e){var r=typeof e;return e!==null&&r==="object"||r==="function"};function z0(e,r){if(e){var t;if(pn(e))for(var n=0,i=e.length;n{if(e!=="next"&&e!=="prev")return r},$c=e=>{e.prev.next=e.next,e.next.prev=e.prev,delete e.next,delete e.prev};let Y0=class{constructor(){const r={};r.prev=r,r.next=r.prev,this.shortcut=r}dequeue(){const r=this.shortcut,t=r.prev;if(t&&t!==r)return $c(t),t}enqueue(r){const t=this.shortcut;r.prev&&r.next&&$c(r),r.next=t.next,t.next.prev=r,t.next=r,r.prev=t}toString(){const r=[],t=this.shortcut;let n=t.prev;for(;n!==t;)r.push(JSON.stringify(n,W0)),n=n==null?void 0:n.prev;return`[${r.join(", ")}]`}};class K0 extends Y0{}const X0=(e,r)=>{var t;if(e.getAllNodes().length<=1)return[];const n=J0(e,r);return(t=Z0(n.graph,n.buckets,n.zeroIdx).map(s=>e.getRelatedEdges(s.v,"out").filter(({target:a})=>a===s.w)))===null||t===void 0?void 0:t.flat()},Z0=(e,r,t)=>{let n=[];const i=r[r.length-1],s=r[0];let a;for(;e.getAllNodes().length;){for(;a=s.dequeue();)mn(e,r,t,a);for(;a=i.dequeue();)mn(e,r,t,a);if(e.getAllNodes().length){for(let o=r.length-2;o>0;--o)if(a=r[o].dequeue(),a){n=n.concat(mn(e,r,t,a,!0));break}}}return n},mn=(e,r,t,n,i)=>{var s,a;const o=[];return e.hasNode(n.v)&&((s=e.getRelatedEdges(n.v,"in"))===null||s===void 0||s.forEach(c=>{const f=c.data.weight,l=e.getNode(c.source);i&&o.push({v:c.source,w:c.target,in:0,out:0}),l.data.out===void 0&&(l.data.out=0),l.data.out-=f,yn(r,t,Object.assign({v:l.id},l.data))}),(a=e.getRelatedEdges(n.v,"out"))===null||a===void 0||a.forEach(c=>{const f=c.data.weight,l=c.target,p=e.getNode(l);p.data.in===void 0&&(p.data.in=0),p.data.in-=f,yn(r,t,Object.assign({v:p.id},p.data))}),e.removeNode(n.v)),i?o:void 0},J0=(e,r)=>{const t=new Be;let n=0,i=0;e.getAllNodes().forEach(c=>{t.addNode({id:c.id,data:{v:c.id,in:0,out:0}})}),e.getAllEdges().forEach(c=>{const f=t.getRelatedEdges(c.source,"out").find(p=>p.target===c.target),l=(r==null?void 0:r(c))||1;f?t.updateEdgeData(f==null?void 0:f.id,Object.assign(Object.assign({},f.data),{weight:f.data.weight+l})):t.addEdge({id:c.id,source:c.source,target:c.target,data:{weight:l}}),i=Math.max(i,t.getNode(c.source).data.out+=l),n=Math.max(n,t.getNode(c.target).data.in+=l)});const s=[],a=i+n+3;for(let c=0;c{yn(s,o,Object.assign({v:c.id},t.getNode(c.id).data))}),{buckets:s,zeroIdx:o,graph:t}},yn=(e,r,t)=>{t.out?t.in?e[t.out-t.in+r].enqueue(t):e[e.length-1].enqueue(t):e[0].enqueue(t)},Q0=(e,r)=>{const n=r==="greedy"?X0(e,(i=>s=>s.data.weight||1)()):H0(e);n==null||n.forEach(i=>{const s=i.data;e.removeEdge(i.id),s.forwardName=i.data.name,s.reversed=!0,e.addEdge({id:i.id,source:i.target,target:i.source,data:Object.assign({},s)})})},H0=e=>{const r=[],t={},n={},i=s=>{n[s]||(n[s]=!0,t[s]=!0,e.getRelatedEdges(s,"out").forEach(a=>{t[a.target]?r.push(a):i(a.target)}),delete t[s])};return e.getAllNodes().forEach(s=>i(s.id)),r},em=e=>{e.getAllEdges().forEach(r=>{const t=r.data;if(t.reversed){e.removeEdge(r.id);const n=t.forwardName;delete t.reversed,delete t.forwardName,e.addEdge({id:r.id,source:r.target,target:r.source,data:Object.assign(Object.assign({},t),{forwardName:n})})}})},tm=(e,r)=>Number(e)-Number(r),Vt=(e,r,t,n)=>{let i;do i=`${n}${Math.random()}`;while(e.hasNode(i));return t.dummy=r,e.addNode({id:i,data:t}),i},rm=e=>{const r=new Be;return e.getAllNodes().forEach(t=>{r.addNode(Object.assign({},t))}),e.getAllEdges().forEach(t=>{const n=r.getRelatedEdges(t.source,"out").find(i=>i.target===t.target);n?r.updateEdgeData(n==null?void 0:n.id,Object.assign(Object.assign({},n.data),{weight:n.data.weight+t.data.weight||0,minlen:Math.max(n.data.minlen,t.data.minlen||1)})):r.addEdge({id:t.id,source:t.source,target:t.target,data:{weight:t.data.weight||0,minlen:t.data.minlen||1}})}),r},Gc=e=>{const r=new Be;return e.getAllNodes().forEach(t=>{e.getChildren(t.id).length||r.addNode(Object.assign({},t))}),e.getAllEdges().forEach(t=>{r.addEdge(t)}),r},nm=(e,r)=>e==null?void 0:e.reduce((t,n,i)=>(t[n]=r[i],t),{}),Uc=(e,r)=>{const t=Number(e.x),n=Number(e.y),i=Number(r.x)-t,s=Number(r.y)-n;let a=Number(e.width)/2,o=Number(e.height)/2;if(!i&&!s)return{x:0,y:0};let c,f;return Math.abs(s)*a>Math.abs(i)*o?(s<0&&(o=-o),c=o*i/s,f=o):(i<0&&(a=-a),c=a,f=a*s/i),{x:t+c,y:n+f}},ir=e=>{const r=[],t=Wc(e)+1;for(let n=0;n{const i=n.data.rank;i!==void 0&&r[i]&&r[i].push(n.id)});for(let n=0;ntm(e.getNode(i).data.order,e.getNode(s).data.order));return r},im=e=>{const r=e.getAllNodes().filter(n=>n.data.rank!==void 0).map(n=>n.data.rank),t=Math.min(...r);e.getAllNodes().forEach(n=>{n.data.hasOwnProperty("rank")&&t!==1/0&&(n.data.rank-=t)})},sm=(e,r=0)=>{const t=e.getAllNodes(),n=t.filter(o=>o.data.rank!==void 0).map(o=>o.data.rank),i=Math.min(...n),s=[];t.forEach(o=>{const c=(o.data.rank||0)-i;s[c]||(s[c]=[]),s[c].push(o.id)});let a=0;for(let o=0;o{const l=e.getNode(f);l&&(l.data.rank=l.data.rank||0,l.data.rank+=a)}))}},Vc=(e,r,t,n)=>{const i={width:0,height:0};return me(t)&&me(n)&&(i.rank=t,i.order=n),Vt(e,"border",i,r)},Wc=e=>{let r;return e.getAllNodes().forEach(t=>{const n=t.data.rank;n!==void 0&&(r===void 0||n>r)&&(r=n)}),r||(r=0),r},om=(e,r)=>{const t={lhs:[],rhs:[]};return e==null||e.forEach(n=>{r(n)?t.lhs.push(n):t.rhs.push(n)}),t},wn=(e,r)=>e.reduce((t,n)=>{const i=r(t),s=r(n);return i>s?n:t}),Yc=(e,r,t,n,i,s)=>{n.includes(r.id)||(n.push(r.id),t||s.push(r.id),i(r.id).forEach(a=>Yc(e,a,t,n,i,s)),t&&s.push(r.id))},Kc=(e,r,t,n)=>{const i=Array.isArray(r)?r:[r],s=c=>e.getNeighbors(c),a=[],o=[];return i.forEach(c=>{if(e.hasNode(c.id))Yc(e,c,t==="post",o,s,a);else throw new Error(`Graph does not have node: ${c}`)}),a},am=e=>{const r=t=>{const n=e.getChildren(t),i=e.getNode(t);if(n!=null&&n.length&&n.forEach(s=>r(s.id)),i.data.hasOwnProperty("minRank")){i.data.borderLeft=[],i.data.borderRight=[];for(let s=i.data.minRank,a=i.data.maxRank+1;sr(t.id))},Xc=(e,r,t,n,i,s)=>{const a={rank:s,borderType:r,width:0,height:0},o=i.data[r][s-1],c=Vt(e,"border",a,t);i.data[r][s]=c,e.setParent(c,n),o&&e.addEdge({id:`e${Math.random()}`,source:o,target:c,data:{weight:1}})},um=(e,r)=>{const t=r.toLowerCase();(t==="lr"||t==="rl")&&Zc(e)},cm=(e,r)=>{const t=r.toLowerCase();(t==="bt"||t==="rl")&&fm(e),(t==="lr"||t==="rl")&&(lm(e),Zc(e))},Zc=e=>{e.getAllNodes().forEach(r=>{Jc(r)}),e.getAllEdges().forEach(r=>{Jc(r)})},Jc=e=>{const r=e.data.width;e.data.width=e.data.height,e.data.height=r},fm=e=>{e.getAllNodes().forEach(r=>{bn(r.data)}),e.getAllEdges().forEach(r=>{var t;(t=r.data.points)===null||t===void 0||t.forEach(n=>bn(n)),r.data.hasOwnProperty("y")&&bn(r.data)})},bn=e=>{e!=null&&e.y&&(e.y=-e.y)},lm=e=>{e.getAllNodes().forEach(r=>{_n(r.data)}),e.getAllEdges().forEach(r=>{var t;(t=r.data.points)===null||t===void 0||t.forEach(n=>_n(n)),r.data.hasOwnProperty("x")&&_n(r.data)})},_n=e=>{const r=e.x;e.x=e.y,e.y=r},hm=e=>{const r=Vt(e,"root",{},"_root"),t=dm(e);let n=Math.max(...Object.values(t));Math.abs(n)===1/0&&(n=1);const i=n-1,s=2*i+1;e.getAllEdges().forEach(o=>{o.data.minlen*=s});const a=gm(e)+1;return e.getRoots().forEach(o=>{Qc(e,r,s,a,i,t,o.id)}),{nestingRoot:r,nodeRankFactor:s}},Qc=(e,r,t,n,i,s,a)=>{const o=e.getChildren(a);if(!(o!=null&&o.length)){a!==r&&e.addEdge({id:`e${Math.random()}`,source:r,target:a,data:{weight:0,minlen:t}});return}const c=Vc(e,"_bt"),f=Vc(e,"_bb"),l=e.getNode(a);e.setParent(c,a),l.data.borderTop=c,e.setParent(f,a),l.data.borderBottom=f,o==null||o.forEach(p=>{Qc(e,r,t,n,i,s,p.id);const m=p.data.borderTop?p.data.borderTop:p.id,y=p.data.borderBottom?p.data.borderBottom:p.id,x=p.data.borderTop?n:2*n,_=m!==y?1:i-s[a]+1;e.addEdge({id:`e${Math.random()}`,source:c,target:m,data:{minlen:_,weight:x,nestingEdge:!0}}),e.addEdge({id:`e${Math.random()}`,source:y,target:f,data:{minlen:_,weight:x,nestingEdge:!0}})}),e.getParent(a)||e.addEdge({id:`e${Math.random()}`,source:r,target:c,data:{weight:0,minlen:i+s[a]}})},dm=e=>{const r={},t=(n,i)=>{const s=e.getChildren(n);s==null||s.forEach(a=>t(a.id,i+1)),r[n]=i};return e.getRoots().forEach(n=>t(n.id,1)),r},gm=e=>{let r=0;return e.getAllEdges().forEach(t=>{r+=t.data.weight}),r},pm=(e,r)=>{r&&e.removeNode(r),e.getAllEdges().forEach(t=>{t.data.nestingEdge&&e.removeEdge(t.id)})},vm="edge",Hc="edge-label",mm=(e,r)=>{e.getAllEdges().forEach(t=>ym(e,t,r))},ym=(e,r,t)=>{let n=r.source,i=e.getNode(n).data.rank;const s=r.target,a=e.getNode(s).data.rank,o=r.data.labelRank;if(a===i+1)return;e.removeEdge(r.id);let c,f,l;for(l=0,++i;i{r.forEach(t=>{let n=e.getNode(t);const{data:i}=n,s=i.originalEdge;let a;s&&e.addEdge(s);let o=t;for(;n.data.dummy;)a=e.getSuccessors(o)[0],e.removeNode(o),s.data.points.push({x:n.data.x,y:n.data.y}),n.data.dummy===Hc&&(s.data.x=n.data.x,s.data.y=n.data.y,s.data.width=n.data.width,s.data.height=n.data.height),o=a.id,n=e.getNode(o)})},bm=(e,r,t)=>{const n={};let i;t==null||t.forEach(s=>{let a=e.getParent(s),o,c;for(;a;){if(o=e.getParent(a.id),o?(c=n[o.id],n[o.id]=a.id):(c=i,i=a.id),c&&c!==a.id){r.hasNode(c)||r.addNode({id:c,data:{}}),r.hasNode(a.id)||r.addNode({id:a.id,data:{}}),r.hasEdge(`e${c}-${a.id}`)||r.addEdge({id:`e${c}-${a.id}`,source:c,target:a.id,data:{}});return}a=o}})},_m=(e,r,t)=>{const n=Em(e),i=new Be({tree:[{id:n,children:[],data:{}}]});return e.getAllNodes().forEach(s=>{const a=e.getParent(s.id);(s.data.rank===r||s.data.minRank<=r&&r<=s.data.maxRank)&&(i.hasNode(s.id)||i.addNode(Object.assign({},s)),a!=null&&a.id&&!i.hasNode(a==null?void 0:a.id)&&i.addNode(Object.assign({},a)),i.setParent(s.id,(a==null?void 0:a.id)||n),e.getRelatedEdges(s.id,t).forEach(o=>{const c=o.source===s.id?o.target:o.source;i.hasNode(c)||i.addNode(Object.assign({},e.getNode(c)));const f=i.getRelatedEdges(c,"out").find(({target:p})=>p===s.id),l=f!==void 0?f.data.weight:0;f?i.updateEdgeData(f.id,Object.assign(Object.assign({},f.data),{weight:o.data.weight+l})):i.addEdge({id:o.id,source:c,target:s.id,data:{weight:o.data.weight+l}})}),s.data.hasOwnProperty("minRank")&&i.updateNodeData(s.id,Object.assign(Object.assign({},s.data),{borderLeft:s.data.borderLeft[r],borderRight:s.data.borderRight[r]})))}),i},Em=e=>{let r;for(;e.hasNode(r=`_root${Math.random()}`););return r},xm=(e,r,t)=>{const n=nm(t,t.map((l,p)=>p)),s=r.map(l=>{const p=e.getRelatedEdges(l,"out").map(m=>({pos:n[m.target]||0,weight:m.data.weight}));return p==null?void 0:p.sort((m,y)=>m.pos-y.pos)}).flat().filter(l=>l!==void 0);let a=1;for(;a{if(l){let p=l.pos+a;c[p]+=l.weight;let m=0;for(;p>0;)p%2&&(m+=c[p+1]),p=p-1>>1,c[p]+=l.weight;f+=l.weight*m}}),f},ef=(e,r)=>{let t=0;for(let n=1;n<(r==null?void 0:r.length);n+=1)t+=xm(e,r[n-1],r[n]);return t},tf=e=>{const r={},t=e.getAllNodes(),n=t.map(f=>{var l;return(l=f.data.rank)!==null&&l!==void 0?l:-1/0}),i=Math.max(...n),s=[];for(let f=0;fe.getNode(f.id).data.rank-e.getNode(l.id).data.rank),c=a.filter(f=>e.getNode(f.id).data.fixorder!==void 0).sort((f,l)=>e.getNode(f.id).data.fixorder-e.getNode(l.id).data.fixorder);return c==null||c.forEach(f=>{isNaN(e.getNode(f.id).data.rank)||s[e.getNode(f.id).data.rank].push(f.id),r[f.id]=!0}),a==null||a.forEach(f=>e.dfsTree(f.id,l=>{if(r.hasOwnProperty(l.id))return!0;r[l.id]=!0,isNaN(l.data.rank)||s[l.data.rank].push(l.id)})),s},Nm=(e,r)=>r.map(t=>{const n=e.getRelatedEdges(t,"in");if(!(n!=null&&n.length))return{v:t};const i={sum:0,weight:0};return n==null||n.forEach(s=>{const a=e.getNode(s.source);i.sum+=s.data.weight*a.data.order,i.weight+=s.data.weight}),{v:t,barycenter:i.sum/i.weight,weight:i.weight}}),Mm=(e,r)=>{var t,n,i;const s={};e==null||e.forEach((o,c)=>{s[o.v]={i:c,indegree:0,in:[],out:[],vs:[o.v]};const f=s[o.v];o.barycenter!==void 0&&(f.barycenter=o.barycenter,f.weight=o.weight)}),(t=r.getAllEdges())===null||t===void 0||t.forEach(o=>{const c=s[o.source],f=s[o.target];c!==void 0&&f!==void 0&&(f.indegree++,c.out.push(s[o.target]))});const a=(i=(n=Object.values(s)).filter)===null||i===void 0?void 0:i.call(n,o=>!o.indegree);return Sm(a)},Sm=e=>{var r,t;const n=[],i=c=>f=>{f.merged||(f.barycenter===void 0||c.barycenter===void 0||f.barycenter>=c.barycenter)&&qm(c,f)},s=c=>f=>{f.in.push(c),--f.indegree===0&&e.push(f)};for(;e!=null&&e.length;){const c=e.pop();n.push(c),(r=c.in.reverse())===null||r===void 0||r.forEach(f=>i(c)(f)),(t=c.out)===null||t===void 0||t.forEach(f=>s(c)(f))}const a=n.filter(c=>!c.merged),o=["vs","i","barycenter","weight"];return a.map(c=>{const f={};return o==null||o.forEach(l=>{c[l]!==void 0&&(f[l]=c[l])}),f})},qm=(e,r)=>{var t;let n=0,i=0;e.weight&&(n+=e.barycenter*e.weight,i+=e.weight),r.weight&&(n+=r.barycenter*r.weight,i+=r.weight),e.vs=(t=r.vs)===null||t===void 0?void 0:t.concat(e.vs),e.barycenter=n/i,e.weight=i,e.i=Math.min(r.i,e.i),r.merged=!0},Rm=(e,r,t,n)=>{const i=om(e,m=>{const y=m.hasOwnProperty("fixorder")&&!isNaN(m.fixorder);return n?!y&&m.hasOwnProperty("barycenter"):y||m.hasOwnProperty("barycenter")}),s=i.lhs,a=i.rhs.sort((m,y)=>-m.i- -y.i),o=[];let c=0,f=0,l=0;s==null||s.sort(Om(!!r,!!t)),l=rf(o,a,l),s==null||s.forEach(m=>{var y;l+=(y=m.vs)===null||y===void 0?void 0:y.length,o.push(m.vs),c+=m.barycenter*m.weight,f+=m.weight,l=rf(o,a,l)});const p={vs:o.flat()};return f&&(p.barycenter=c/f,p.weight=f),p},rf=(e,r,t)=>{let n=t,i;for(;r.length&&(i=r[r.length-1]).i<=n;)r.pop(),e==null||e.push(i.vs),n++;return n},Om=(e,r)=>(t,n)=>{if(t.fixorder!==void 0&&n.fixorder!==void 0)return t.fixorder-n.fixorder;if(t.barycentern.barycenter)return 1;if(r&&t.order!==void 0&&n.order!==void 0){if(t.ordern.order)return 1}return e?n.i-t.i:t.i-n.i},nf=(e,r,t,n,i,s)=>{var a,o,c,f;let l=e.getChildren(r).map(E=>E.id);const p=e.getNode(r),m=p?p.data.borderLeft:void 0,y=p?p.data.borderRight:void 0,x={};m&&(l=l==null?void 0:l.filter(E=>E!==m&&E!==y));const _=Nm(e,l||[]);_==null||_.forEach(E=>{var N;if(!((N=e.getChildren(E.v))===null||N===void 0)&&N.length){const S=nf(e,E.v,t,n,s);x[E.v]=S,S.hasOwnProperty("barycenter")&&Im(E,S)}});const b=Mm(_,t);Am(b,x),(a=b.filter(E=>E.vs.length>0))===null||a===void 0||a.forEach(E=>{const N=e.getNode(E.vs[0]);N&&(E.fixorder=N.data.fixorder,E.order=N.data.order)});const w=Rm(b,n,i,s);if(m&&(w.vs=[m,w.vs,y].flat(),!((o=e.getPredecessors(m))===null||o===void 0)&&o.length)){const E=e.getNode(((c=e.getPredecessors(m))===null||c===void 0?void 0:c[0].id)||""),N=e.getNode(((f=e.getPredecessors(y))===null||f===void 0?void 0:f[0].id)||"");w.hasOwnProperty("barycenter")||(w.barycenter=0,w.weight=0),w.barycenter=(w.barycenter*w.weight+E.data.order+N.data.order)/(w.weight+2),w.weight+=2}return w},Am=(e,r)=>{e==null||e.forEach(t=>{var n;const i=(n=t.vs)===null||n===void 0?void 0:n.map(s=>r[s]?r[s].vs:s);t.vs=i.flat()})},Im=(e,r)=>{e.barycenter!==void 0?(e.barycenter=(e.barycenter*e.weight+r.barycenter*r.weight)/(e.weight+r.weight),e.weight+=r.weight):(e.barycenter=r.barycenter,e.weight=r.weight)},Tm=(e,r)=>{const t=Wc(e),n=[],i=[];for(let l=1;l-1;l--)i.push(l);const s=sf(e,n,"in"),a=sf(e,i,"out");let o=tf(e);En(e,o);let c=Number.POSITIVE_INFINITY,f;for(let l=0,p=0;p<4;++l,++p){of(l%2?s:a,l%4>=2,!1,r),o=ir(e);const m=ef(e,o);m=2,!0,r),o=ir(e);const m=ef(e,o);mr.map(n=>_m(e,n,t)),of=(e,r,t,n)=>{const i=new Be;e==null||e.forEach(s=>{var a;const o=s.getRoots()[0].id,c=nf(s,o,i,r,t,n);for(let f=0;f<((a=c.vs)===null||a===void 0?void 0:a.length);f++){const l=s.getNode(c.vs[f]);l&&(l.data.order=f)}bm(s,i,c.vs)})},En=(e,r)=>{r==null||r.forEach(t=>{t==null||t.forEach((n,i)=>{e.getNode(n).data.order=i})})},km=(e,r)=>{const n=e.getAllNodes().filter(a=>{var o;return!(!((o=e.getChildren(a.id))===null||o===void 0)&&o.length)}).map(a=>a.data.rank),i=Math.max(...n),s=[];for(let a=0;a{const o=e.getNode(a);!o||o.data.dummy||isNaN(o.data.rank)||(o.data.fixorder=s[o.data.rank].length,s[o.data.rank].push(a))})},jm=e=>{const r={};let t=0;const n=i=>{const s=t;e.getChildren(i).forEach(a=>n(a.id)),r[i]={low:s,lim:t++}};return e.getRoots().forEach(i=>n(i.id)),r},Cm=(e,r,t,n)=>{var i,s;const a=[],o=[],c=Math.min(r[t].low,r[n].low),f=Math.max(r[t].lim,r[n].lim);let l,p;l=t;do l=(i=e.getParent(l))===null||i===void 0?void 0:i.id,a.push(l);while(l&&(r[l].low>c||f>r[l].lim));for(p=l,l=n;l&&l!==p;)o.push(l),l=(s=e.getParent(l))===null||s===void 0?void 0:s.id;return{lca:p,path:a.concat(o.reverse())}},Pm=(e,r)=>{const t=jm(e);r.forEach(n=>{var i,s;let a=n,o=e.getNode(a);const c=o.data.originalEdge;if(!c)return;const f=Cm(e,t,c.source,c.target),l=f.path,p=f.lca;let m=0,y=l[m],x=!0;for(;a!==c.target;){if(o=e.getNode(a),x){for(;y!==p&&((i=e.getNode(y))===null||i===void 0?void 0:i.data.maxRank){const t={},n=(i,s)=>{let a=0,o=0;const c=i.length,f=s==null?void 0:s[(s==null?void 0:s.length)-1];return s==null||s.forEach((l,p)=>{var m;const y=zm(e,l),x=y?e.getNode(y.id).data.order:c;(y||l===f)&&((m=s.slice(o,p+1))===null||m===void 0||m.forEach(_=>{var b;(b=e.getPredecessors(_))===null||b===void 0||b.forEach(w=>{var E;const N=e.getNode(w.id),S=N.data.order;(S{const t={};function n(o,c,f,l,p){var m,y;let x;for(let _=c;_{const w=e.getNode(b.id);w.data.dummy&&(w.data.orderp)&&af(t,b.id,x)}))}function i(o){return JSON.stringify(o.slice(1))}function s(o,c){const f=i(o);c.get(f)||(n(...o),c.set(f,!0))}const a=(o,c)=>{let f=-1,l,p=0;const m=new Map;return c==null||c.forEach((y,x)=>{var _;if(((_=e.getNode(y))===null||_===void 0?void 0:_.data.dummy)==="border"){const b=e.getPredecessors(y)||[];b.length&&(l=e.getNode(b[0].id).data.order,s([c,p,x,f,l],m),p=x,f=l)}s([c,p,c.length,l,o.length],m)}),c};return r!=null&&r.length&&r.reduce(a),t},zm=(e,r)=>{var t,n;if(!((t=e.getNode(r))===null||t===void 0)&&t.data.dummy)return(n=e.getPredecessors(r))===null||n===void 0?void 0:n.find(i=>e.getNode(i.id).data.dummy)},af=(e,r,t)=>{let n=r,i=t;if(n>i){const a=n;n=i,i=a}let s=e[n];s||(e[n]=s={}),s[i]=!0},Fm=(e,r,t)=>{let n=r,i=t;if(n>i){const s=r;n=i,i=s}return!!e[n]},Bm=(e,r,t,n)=>{const i={},s={},a={};return r==null||r.forEach(o=>{o==null||o.forEach((c,f)=>{i[c]=c,s[c]=c,a[c]=f})}),r==null||r.forEach(o=>{let c=-1;o==null||o.forEach(f=>{let l=n(f).map(p=>p.id);if(l.length){l=l.sort((m,y)=>a[m]-a[y]);const p=(l.length-1)/2;for(let m=Math.floor(p),y=Math.ceil(p);m<=y;++m){const x=l[m];s[f]===f&&c{var o;const c={},f=Gm(e,r,t,i,s,a),l=a?"borderLeft":"borderRight",p=(x,_)=>{let b=f.getAllNodes(),w=b.pop();const E={};for(;w;)E[w.id]?x(w.id):(E[w.id]=!0,b.push(w),b=b.concat(_(w.id))),w=b.pop()},m=x=>{c[x]=(f.getRelatedEdges(x,"in")||[]).reduce((_,b)=>Math.max(_,(c[b.source]||0)+b.data.weight),0)},y=x=>{const _=(f.getRelatedEdges(x,"out")||[]).reduce((w,E)=>Math.min(w,(c[E.target]||0)-E.data.weight),Number.POSITIVE_INFINITY),b=e.getNode(x);_!==Number.POSITIVE_INFINITY&&b.data.borderType!==l&&(c[x]=Math.max(c[x],_))};return p(m,f.getPredecessors.bind(f)),p(y,f.getSuccessors.bind(f)),(o=Object.values(n))===null||o===void 0||o.forEach(x=>{c[x]=c[t[x]]}),c},Gm=(e,r,t,n,i,s)=>{const a=new Be,o=Ym(n,i,s);return r==null||r.forEach(c=>{let f;c==null||c.forEach(l=>{const p=t[l];if(a.hasNode(p)||a.addNode({id:p,data:{}}),f){const m=t[f],y=a.getRelatedEdges(m,"out").find(x=>x.target===p);y?a.updateEdgeData(y.id,Object.assign(Object.assign({},y.data),{weight:Math.max(o(e,l,f),y.data.weight||0)})):a.addEdge({id:`e${Math.random()}`,source:m,target:p,data:{weight:Math.max(o(e,l,f),0)}})}f=l})}),a},Um=(e,r)=>wn(Object.values(r),t=>{var n;let i=Number.NEGATIVE_INFINITY,s=Number.POSITIVE_INFINITY;return(n=Object.keys(t))===null||n===void 0||n.forEach(a=>{const o=t[a],c=Km(e,a)/2;i=Math.max(o+c,i),s=Math.min(o-c,s)}),i-s});function Vm(e,r){const t=Object.values(r),n=Math.min(...t),i=Math.max(...t);["u","d"].forEach(s=>{["l","r"].forEach(a=>{const o=s+a,c=e[o];let f;if(c===r)return;const l=Object.values(c);f=a==="l"?n-Math.min(...l):i-Math.max(...l),f&&(e[o]={},Object.keys(c).forEach(p=>{e[o][p]=c[p]+f}))})})}const Wm=(e,r)=>{const t={};return Object.keys(e.ul).forEach(n=>{if(r)t[n]=e[r.toLowerCase()][n];else{const i=Object.values(e).map(s=>s[n]);t[n]=(i[0]+i[1])/2}}),t},Ym=(e,r,t)=>(n,i,s)=>{const a=n.getNode(i),o=n.getNode(s);let c=0,f=0;if(c+=a.data.width/2,a.data.hasOwnProperty("labelpos"))switch((a.data.labelpos||"").toLowerCase()){case"l":f=-a.data.width/2;break;case"r":f=a.data.width/2;break}if(f&&(c+=t?f:-f),f=0,c+=(a.data.dummy?r:e)/2,c+=(o.data.dummy?r:e)/2,c+=o.data.width/2,o.data.labelpos)switch((o.data.labelpos||"").toLowerCase()){case"l":f=o.data.width/2;break;case"r":f=-o.data.width/2;break}return f&&(c+=t?f:-f),f=0,c},Km=(e,r)=>e.getNode(r).data.width||0,Xm=(e,r)=>{const{ranksep:t=0}=r,n=ir(e);let i=0;n==null||n.forEach(s=>{const a=s.map(c=>e.getNode(c).data.height),o=Math.max(...a,0);s==null||s.forEach(c=>{e.getNode(c).data.y=i+o/2}),i+=o+t})},Zm=(e,r)=>{const{align:t,nodesep:n=0,edgesep:i=0}=r,s=ir(e),a=Object.assign(Lm(e,s),Dm(e,s)),o={};let c=[];["u","d"].forEach(l=>{c=l==="u"?s:Object.values(s).reverse(),["l","r"].forEach(p=>{p==="r"&&(c=c.map(_=>Object.values(_).reverse()));const m=(l==="u"?e.getPredecessors:e.getSuccessors).bind(e),y=Bm(e,c,a,m),x=$m(e,c,y.root,y.align,n,i,p==="r");p==="r"&&Object.keys(x).forEach(_=>x[_]=-x[_]),o[l+p]=x})});const f=Um(e,o);return f&&Vm(o,f),Wm(o,t)},Jm=(e,r)=>{var t;const n=Gc(e);Xm(n,r);const i=Zm(n,r);(t=Object.keys(i))===null||t===void 0||t.forEach(s=>{n.getNode(s).data.x=i[s]})},uf=e=>{const r={},t=n=>{var i;const s=e.getNode(n);if(!s)return 0;if(r[n])return s.data.rank;r[n]=!0;let a;return(i=e.getRelatedEdges(n,"out"))===null||i===void 0||i.forEach(o=>{const c=t(o.target),f=o.data.minlen,l=c-f;l&&(a===void 0||le.getRelatedEdges(n.id,"in").length===0).forEach(n=>t(n.id))},Qm=e=>{const r={};let t;const n=a=>{var o;const c=e.getNode(a);if(!c)return 0;if(r[a])return c.data.rank;r[a]=!0;let f;return(o=e.getRelatedEdges(a,"out"))===null||o===void 0||o.forEach(l=>{const p=n(l.target),m=l.data.minlen,y=p-m;y&&(f===void 0||ye.getRelatedEdges(a.id,"in").length===0).forEach(a=>{a&&n(a.id)}),t===void 0&&(t=0);const i={},s=(a,o)=>{var c;const f=e.getNode(a),l=isNaN(f.data.layer)?o:f.data.layer;(f.data.rank===void 0||f.data.rank{s(p.target,l+p.data.minlen)}))};e.getAllNodes().forEach(a=>{const o=a.data;o&&(isNaN(o.layer)?o.rank-=t:s(a.id,o.layer))})},Ot=(e,r)=>e.getNode(r.target).data.rank-e.getNode(r.source).data.rank-r.data.minlen,Hm=e=>{const r=new Be({tree:[]}),t=e.getAllNodes()[0],n=e.getAllNodes().length;r.addNode(t);let i,s;for(;ey(r,e){const t=n=>{r.getRelatedEdges(n,"both").forEach(i=>{const s=i.source,a=n===s?i.target:s;!e.hasNode(a)&&!Ot(r,i)&&(e.addNode({id:a,data:{}}),e.addEdge({id:i.id,source:n,target:a,data:{}}),t(a))})};return e.getAllNodes().forEach(n=>t(n.id)),e.getAllNodes().length},ty=e=>{const r=new Be({tree:[]}),t=e.getAllNodes()[0],n=e.getAllNodes().length;r.addNode(t);let i,s;for(;ry(r,e){const t=n=>{var i;(i=r.getRelatedEdges(n,"both"))===null||i===void 0||i.forEach(s=>{const a=s.source,o=n===a?s.target:a;!e.hasNode(o)&&(r.getNode(o).data.layer!==void 0||!Ot(r,s))&&(e.addNode({id:o,data:{}}),e.addEdge({id:s.id,source:n,target:o,data:{}}),t(o))})};return e.getAllNodes().forEach(n=>t(n.id)),e.getAllNodes().length},cf=(e,r)=>wn(r.getAllEdges(),t=>e.hasNode(t.source)!==e.hasNode(t.target)?Ot(r,t):1/0),ff=(e,r,t)=>{e.getAllNodes().forEach(n=>{const i=r.getNode(n.id);i.data.rank||(i.data.rank=0),i.data.rank+=t})},ny=e=>{const r=rm(e);uf(r);const t=Hm(r);hf(t),lf(t,r);let n,i;for(;n=oy(t);)i=ay(t,r,n),uy(t,r,n,i)},lf=(e,r)=>{let t=Kc(e,e.getAllNodes(),"post");t=t.slice(0,(t==null?void 0:t.length)-1),t.forEach(n=>{iy(e,r,n)})},iy=(e,r,t)=>{const i=e.getNode(t).data.parent,s=e.getRelatedEdges(t,"both").find(a=>a.target===i||a.source===i);s.data.cutvalue=sy(e,r,t)},sy=(e,r,t)=>{const i=e.getNode(t).data.parent;let s=!0,a=r.getRelatedEdges(t,"out").find(c=>c.target===i),o=0;return a||(s=!1,a=r.getRelatedEdges(i,"out").find(c=>c.target===t)),o=a.data.weight,r.getRelatedEdges(t,"both").forEach(c=>{const f=c.source===t,l=f?c.target:c.source;if(l!==i){const p=f===s,m=c.data.weight;if(o+=p?m:-m,fy(e,t,l)){const y=e.getRelatedEdges(t,"both").find(x=>x.source===l||x.target===l).data.cutvalue;o+=p?-y:y}}}),o},hf=(e,r=e.getAllNodes()[0].id)=>{df(e,{},1,r)},df=(e,r,t,n,i)=>{var s;const a=t;let o=t;const c=e.getNode(n);return r[n]=!0,(s=e.getNeighbors(n))===null||s===void 0||s.forEach(f=>{r[f.id]||(o=df(e,r,o,f.id,n))}),c.data.low=a,c.data.lim=o++,i?c.data.parent=i:delete c.data.parent,o},oy=e=>e.getAllEdges().find(r=>r.data.cutvalue<0),ay=(e,r,t)=>{let n=t.source,i=t.target;r.getRelatedEdges(n,"out").find(l=>l.target===i)||(n=t.target,i=t.source);const s=e.getNode(n),a=e.getNode(i);let o=s,c=!1;s.data.lim>a.data.lim&&(o=a,c=!0);const f=r.getAllEdges().filter(l=>c===gf(e.getNode(l.source),o)&&c!==gf(e.getNode(l.target),o));return wn(f,l=>Ot(r,l))},uy=(e,r,t,n)=>{const i=e.getRelatedEdges(t.source,"both").find(s=>s.source===t.target||s.target===t.target);i&&e.removeEdge(i.id),e.addEdge({id:`e${Math.random()}`,source:n.source,target:n.target,data:{}}),hf(e),lf(e,r),cy(e,r)},cy=(e,r)=>{const t=e.getAllNodes().find(i=>!i.data.parent);let n=Kc(e,t,"pre");n=n.slice(1),n.forEach(i=>{const s=e.getNode(i).data.parent;let a=r.getRelatedEdges(i,"out").find(c=>c.target===s),o=!1;!a&&r.hasNode(s)&&(a=r.getRelatedEdges(s,"out").find(c=>c.target===i),o=!0),r.getNode(i).data.rank=(r.hasNode(s)&&r.getNode(s).data.rank||0)+(o?a==null?void 0:a.data.minlen:-(a==null?void 0:a.data.minlen))})},fy=(e,r,t)=>e.getRelatedEdges(r,"both").find(n=>n.source===t||n.target===t),gf=(e,r)=>r.data.low<=e.data.lim&&e.data.lim<=r.data.lim,ly=(e,r)=>{switch(r){case"network-simplex":dy(e);break;case"tight-tree":pf(e);break;case"longest-path":hy(e);break;default:pf(e)}},hy=uf,pf=e=>{Qm(e),ty(e)},dy=e=>{ny(e)},gy=(e,r)=>{const{edgeLabelSpace:t,keepNodeOrder:n,prevGraph:i,rankdir:s,ranksep:a}=r;!n&&i&&vy(e,i);const o=Ey(e);t&&(r.ranksep=xy(o,{rankdir:s,ranksep:a}));let c;try{c=py(o,r)}catch(f){if(f.message==="Not possible to find intersection inside of the rectangle"){console.error(`The following error may be caused by improper layer setting, please make sure your manual layer setting does not violate the graph's structure: `,f);return}throw f}return my(e,o),c},py=(e,r)=>{const{acyclicer:t,ranker:n,rankdir:i="tb",nodeOrder:s,keepNodeOrder:a,align:o,nodesep:c=50,edgesep:f=20,ranksep:l=50}=r;Ty(e),Q0(e,t);const{nestingRoot:p,nodeRankFactor:m}=hm(e);ly(Gc(e),n),Ny(e),sm(e,m),pm(e,p),im(e),My(e),Sy(e);const y=[];mm(e,y),Pm(e,y),am(e),a&&km(e,s),Tm(e,a),ky(e),um(e,i),Jm(e,{align:o,nodesep:c,edgesep:f,ranksep:l}),jy(e),Iy(e),wm(e,y),Oy(e),cm(e,i);const{width:x,height:_}=qy(e);return Ry(e),Ay(e),em(e),{width:x,height:_}},vy=(e,r)=>{e.getAllNodes().forEach(t=>{const n=e.getNode(t.id);if(r.hasNode(t.id)){const i=r.getNode(t.id);n.data.fixorder=i.data._order,delete i.data._order}else delete n.data.fixorder})},my=(e,r)=>{e.getAllNodes().forEach(t=>{var n;const i=e.getNode(t.id);if(i){const s=r.getNode(t.id);i.data.x=s.data.x,i.data.y=s.data.y,i.data._order=s.data.order,i.data._rank=s.data.rank,!((n=r.getChildren(t.id))===null||n===void 0)&&n.length&&(i.data.width=s.data.width,i.data.height=s.data.height)}}),e.getAllEdges().forEach(t=>{const n=e.getEdge(t.id),i=r.getEdge(t.id);n.data.points=i?i.data.points:[],i&&i.data.hasOwnProperty("x")&&(n.data.x=i.data.x,n.data.y=i.data.y)})},yy=["width","height","layer","fixorder"],wy={width:0,height:0},by=["minlen","weight","width","height","labeloffset"],_y={minlen:1,weight:1,width:0,height:0,labeloffset:10,labelpos:"r"},xn=["labelpos"],Ey=e=>{const r=new Be({tree:[]});return e.getAllNodes().forEach(t=>{const n=mf(e.getNode(t.id).data),i=Object.assign(Object.assign({},wy),n),s=vf(i,yy);r.hasNode(t.id)||r.addNode({id:t.id,data:Object.assign({},s)});const a=e.hasTreeStructure("combo")?e.getParent(t.id,"combo"):e.getParent(t.id);D0(a)||(r.hasNode(a.id)||r.addNode(Object.assign({},a)),r.setParent(t.id,a.id))}),e.getAllEdges().forEach(t=>{const n=mf(e.getEdge(t.id).data),i={};xn==null||xn.forEach(s=>{n[s]!==void 0&&(i[s]=n[s])}),r.addEdge({id:t.id,source:t.source,target:t.target,data:Object.assign({},_y,vf(n,by),i)})}),r},xy=(e,r)=>{const{ranksep:t=0,rankdir:n}=r;return e.getAllNodes().forEach(i=>{isNaN(i.data.layer)||i.data.layer||(i.data.layer=0)}),e.getAllEdges().forEach(i=>{var s;i.data.minlen*=2,((s=i.data.labelpos)===null||s===void 0?void 0:s.toLowerCase())!=="c"&&(n==="TB"||n==="BT"?i.data.width+=i.data.labeloffset:i.data.height+=i.data.labeloffset)}),t/2},Ny=e=>{e.getAllEdges().forEach(r=>{if(r.data.width&&r.data.height){const t=e.getNode(r.source),n=e.getNode(r.target),i={e:r,rank:(n.data.rank-t.data.rank)/2+t.data.rank};Vt(e,"edge-proxy",i,"_ep")}})},My=e=>{let r=0;return e.getAllNodes().forEach(t=>{var n,i;t.data.borderTop&&(t.data.minRank=(n=e.getNode(t.data.borderTop))===null||n===void 0?void 0:n.data.rank,t.data.maxRank=(i=e.getNode(t.data.borderBottom))===null||i===void 0?void 0:i.data.rank,r=Math.max(r,t.data.maxRank||-1/0))}),r},Sy=e=>{e.getAllNodes().forEach(r=>{r.data.dummy==="edge-proxy"&&(e.getEdge(r.data.e.id).data.labelRank=r.data.rank,e.removeNode(r.id))})},qy=(e,r)=>{let t,n=0,i,s=0;const{marginx:a=0,marginy:o=0}={},c=f=>{if(!f.data)return;const l=f.data.x,p=f.data.y,m=f.data.width,y=f.data.height;!isNaN(l)&&!isNaN(m)&&(t===void 0&&(t=l-m/2),t=Math.min(t,l-m/2),n=Math.max(n,l+m/2)),!isNaN(p)&&!isNaN(y)&&(i===void 0&&(i=p-y/2),i=Math.min(i,p-y/2),s=Math.max(s,p+y/2))};return e.getAllNodes().forEach(f=>{c(f)}),e.getAllEdges().forEach(f=>{f!=null&&f.data.hasOwnProperty("x")&&c(f)}),t-=a,i-=o,e.getAllNodes().forEach(f=>{f.data.x-=t,f.data.y-=i}),e.getAllEdges().forEach(f=>{var l;(l=f.data.points)===null||l===void 0||l.forEach(p=>{p.x-=t,p.y-=i}),f.data.hasOwnProperty("x")&&(f.data.x-=t),f.data.hasOwnProperty("y")&&(f.data.y-=i)}),{width:n-t+a,height:s-i+o}},Ry=e=>{e.getAllEdges().forEach(r=>{const t=e.getNode(r.source),n=e.getNode(r.target);let i,s;r.data.points?(i=r.data.points[0],s=r.data.points[r.data.points.length-1]):(r.data.points=[],i={x:n.data.x,y:n.data.y},s={x:t.data.x,y:t.data.y}),r.data.points.unshift(Uc(t.data,i)),r.data.points.push(Uc(n.data,s))})},Oy=e=>{e.getAllEdges().forEach(r=>{if(r.data.hasOwnProperty("x"))switch((r.data.labelpos==="l"||r.data.labelpos==="r")&&(r.data.width-=r.data.labeloffset),r.data.labelpos){case"l":r.data.x-=r.data.width/2+r.data.labeloffset;break;case"r":r.data.x+=r.data.width/2+r.data.labeloffset;break}})},Ay=e=>{e.getAllEdges().forEach(r=>{var t;r.data.reversed&&((t=r.data.points)===null||t===void 0||t.reverse())})},Iy=e=>{e.getAllNodes().forEach(r=>{var t,n,i;if(!((t=e.getChildren(r.id))===null||t===void 0)&&t.length){const s=e.getNode(r.id),a=e.getNode(s.data.borderTop),o=e.getNode(s.data.borderBottom),c=e.getNode(s.data.borderLeft[((n=s.data.borderLeft)===null||n===void 0?void 0:n.length)-1]),f=e.getNode(s.data.borderRight[((i=s.data.borderRight)===null||i===void 0?void 0:i.length)-1]);s.data.width=Math.abs((f==null?void 0:f.data.x)-(c==null?void 0:c.data.x))||10,s.data.height=Math.abs((o==null?void 0:o.data.y)-(a==null?void 0:a.data.y))||10,s.data.x=((c==null?void 0:c.data.x)||0)+s.data.width/2,s.data.y=((a==null?void 0:a.data.y)||0)+s.data.height/2}}),e.getAllNodes().forEach(r=>{r.data.dummy==="border"&&e.removeNode(r.id)})},Ty=e=>{e.getAllEdges().forEach(r=>{if(r.source===r.target){const t=e.getNode(r.source);t.data.selfEdges||(t.data.selfEdges=[]),t.data.selfEdges.push(r),e.removeEdge(r.id)}})},ky=e=>{const r=ir(e);r==null||r.forEach(t=>{let n=0;t==null||t.forEach((i,s)=>{var a;const o=e.getNode(i);o.data.order=s+n,(a=o.data.selfEdges)===null||a===void 0||a.forEach(c=>{Vt(e,"selfedge",{width:c.data.width,height:c.data.height,rank:o.data.rank,order:s+ ++n,e:c},"_se")}),delete o.data.selfEdges})})},jy=e=>{e.getAllNodes().forEach(r=>{const t=e.getNode(r.id);if(t.data.dummy==="selfedge"){const n=e.getNode(t.data.e.source),i=n.data.x+n.data.width/2,s=n.data.y,a=t.data.x-i,o=n.data.height/2;e.hasEdge(t.data.e.id)?e.updateEdgeData(t.data.e.id,t.data.e.data):e.addEdge({id:t.data.e.id,source:t.data.e.source,target:t.data.e.target,data:t.data.e.data}),e.removeNode(r.id),t.data.e.data.points=[{x:i+2*a/3,y:s-o},{x:i+5*a/6,y:s-o},{y:s,x:i+a},{x:i+5*a/6,y:s+o},{x:i+2*a/3,y:s+o}],t.data.e.data.x=t.data.x,t.data.e.data.y=t.data.y}})},vf=(e,r)=>{const t={};return r==null||r.forEach(n=>{e[n]!==void 0&&(t[n]=+e[n])}),t},mf=(e={})=>{const r={};return Object.keys(e).forEach(t=>{r[t.toLowerCase()]=e[t]}),r},bt=Array.isArray,yf=e=>{const r=[],t=e.length;for(let n=0;nr[i][n]+r[n][s]&&(r[i][s]=r[i][n]+r[n][s]);return r},wf=(e,r)=>{const{nodes:t,edges:n}=e,i=[],s={};if(!t)throw new Error("invalid nodes data!");return t&&t.forEach((a,o)=>{s[a.id]=o;const c=[];i.push(c)}),n==null||n.forEach(a=>{const{source:o,target:c}=a,f=s[o],l=s[c];f===void 0||l===void 0||(i[f][l]=1,i[l][f]=1)}),i},Cy=(e,r)=>{const t=[];return e.forEach(n=>{const i=[];n.forEach(s=>{i.push(s*r)}),t.push(i)}),t},Py=e=>{let r=1/0,t=1/0,n=-1/0,i=-1/0;return e.forEach(s=>{let a=s.data.size;bt(a)?a.length===1&&(a=[a[0],a[0]]):me(a)?a=[a,a]:(a===void 0||isNaN(a))&&(a=[30,30]);const o=[a[0]/2,a[1]/2],c=s.data.x-o[0],f=s.data.x+o[0],l=s.data.y-o[1],p=s.data.y+o[1];r>c&&(r=c),t>l&&(t=l),nMath.sqrt((e.x-r.x)*(e.x-r.x)+(e.y-r.y)*(e.y-r.y)),Nn=(e,r,t,n="TB",i,s={})=>{if(!(r!=null&&r.length))return;const{stopBranchFn:a,stopAllFn:o}=s;for(let c=0;c{if(e===null)return e;if(e instanceof Date)return new Date(e.getTime());if(e instanceof Array){const r=[];return e.forEach(t=>{r.push(t)}),r.map(t=>Mn(t))}if(typeof e=="object"){const r={};return Object.keys(e).forEach(t=>{r[t]=Mn(e[t])}),r}return e},it=(e,r)=>{const t=Mn(e);return t.data=t.data||{},r&&(me(t.data.x)||(t.data.x=Math.random()*r[0]),me(t.data.y)||(t.data.y=Math.random()*r[1])),t};function sr(e){if(!e)return[0,0,0];if(me(e))return[e,e,e];if(e.length===0)return[0,0,0];const[r,t=r,n=r]=e;return[r,t,n]}function Ct(e,r){let t;return wt(r)?t=r:me(r)?t=()=>r:t=()=>e,t}function Sn(e,r,t=!0){return!r&&r!==0?n=>{const{size:i}=n.data||{};return i?Array.isArray(i)?t?Math.max(...i)||e:i:Ut(i)&&i.width&&i.height?t?Math.max(i.width,i.height)||e:[i.width,i.height]:i:e}:wt(r)?r:me(r)?()=>r:Array.isArray(r)?()=>t?Math.max(...r)||e:r:Ut(r)&&r.width&&r.height?()=>t?Math.max(r.width,r.height)||e:[r.width,r.height]:()=>e}const qn=(e,r,t=10)=>{let n;const i=typeof r=="function"?r:()=>r||0;return e?Array.isArray(e)?n=a=>e:wt(e)?n=e:n=a=>e:n=a=>{var o,c,f;if(!((o=a.data)===null||o===void 0)&&o.bboxSize)return(c=a.data)===null||c===void 0?void 0:c.bboxSize;if(!((f=a.data)===null||f===void 0)&&f.size){const l=a.data.size;return Array.isArray(l)?l:Ut(l)?[l.width,l.height]:l}return t},a=>{const o=n(a),c=i(a);return Math.max(...sr(o))+c}},Ly={rankdir:"TB",nodesep:50,ranksep:50,edgeLabelSpace:!0,ranker:"tight-tree",controlPoints:!1,radial:!1,focusNode:null};class Dy{constructor(r={}){this.options=r,this.id="antv-dagre",this.options=Object.assign(Object.assign({},Ly),r)}execute(r,t){return fe(this,void 0,void 0,function*(){return this.genericDagreLayout(!1,r,t)})}assign(r,t){return fe(this,void 0,void 0,function*(){yield this.genericDagreLayout(!0,r,t)})}genericDagreLayout(r,t,n){return fe(this,void 0,void 0,function*(){const i=Object.assign(Object.assign({},this.options),n),{nodeSize:s,align:a,rankdir:o="TB",ranksep:c,nodesep:f,ranksepFunc:l,nodesepFunc:p,edgeLabelSpace:m,ranker:y,nodeOrder:x,begin:_,controlPoints:b,radial:w,sortByCombo:E,preset:N}=i,S=new Be({tree:[]}),R=Ct(c||50,l),A=Ct(f||50,p);let j=A,I=R;(o==="LR"||o==="RL")&&(j=R,I=A);const D=Sn(10,s,!1),z=t.getAllNodes(),$=t.getAllEdges();z.forEach(Z=>{const ue=sr(D(Z)),pe=I(Z),he=j(Z),ie=ue[0]+2*he,_e=ue[1]+2*pe,G=Z.data.layer;me(G)?S.addNode({id:Z.id,data:{width:ie,height:_e,layer:G}}):S.addNode({id:Z.id,data:{width:ie,height:_e}})}),E&&(S.attachTreeStructure("combo"),z.forEach(Z=>{const{parentId:ue}=Z.data;ue!==void 0&&S.hasNode(ue)&&S.setParent(Z.id,ue,"combo")})),$.forEach(Z=>{S.addEdge({id:Z.id,source:Z.source,target:Z.target,data:{weight:Z.data.weight||1}})});let V;N!=null&&N.length&&(V=new Be({nodes:N})),gy(S,{prevGraph:V,edgeLabelSpace:m,keepNodeOrder:!!x,nodeOrder:x||[],acyclicer:"greedy",ranker:y,rankdir:o,nodesep:f,align:a});const Y=[0,0];if(_){let Z=1/0,ue=1/0;S.getAllNodes().forEach(pe=>{Z>pe.data.x&&(Z=pe.data.x),ue>pe.data.y&&(ue=pe.data.y)}),S.getAllEdges().forEach(pe=>{var he;(he=pe.data.points)===null||he===void 0||he.forEach(ie=>{Z>ie.x&&(Z=ie.x),ue>ie.y&&(ue=ie.y)})}),Y[0]=_[0]-Z,Y[1]=_[1]-ue}const ee=o==="LR"||o==="RL";if(!w){const Z=new Set,pe=o==="BT"||o==="RL"?(G,P)=>P-G:(G,P)=>G-P;S.getAllNodes().forEach(G=>{G.data.x=G.data.x+Y[0],G.data.y=G.data.y+Y[1],Z.add(ee?G.data.x:G.data.y)});const he=Array.from(Z).sort(pe),ie=ee?(G,P)=>G.x!==P.x:(G,P)=>G.y!==P.y,_e=ee?(G,P,X)=>{const te=Math.max(P.y,X.y),le=Math.min(P.y,X.y);return G.filter(xe=>xe.y<=te&&xe.y>=le)}:(G,P,X)=>{const te=Math.max(P.x,X.x),le=Math.min(P.x,X.x);return G.filter(xe=>xe.x<=te&&xe.x>=le)};S.getAllEdges().forEach((G,P)=>{var X;m&&b&&G.data.type!=="loop"&&(G.data.controlPoints=zy((X=G.data.points)===null||X===void 0?void 0:X.map(({x:te,y:le})=>({x:te+Y[0],y:le+Y[1]})),S.getNode(G.source),S.getNode(G.target),he,ee,ie,_e))})}let J=[];J=S.getAllNodes().map(Z=>it(Z));const ae=S.getAllEdges();return r&&(J.forEach(Z=>{t.mergeNodeData(Z.id,{x:Z.data.x,y:Z.data.y})}),ae.forEach(Z=>{t.mergeEdgeData(Z.id,{controlPoints:Z.data.controlPoints})})),{nodes:J,edges:ae}})}}const zy=(e,r,t,n,i,s,a)=>{let o=(e==null?void 0:e.slice(1,e.length-1))||[];if(r&&t){let{x:c,y:f}=r.data,{x:l,y:p}=t.data;if(i&&(c=r.data.y,f=r.data.x,l=t.data.y,p=t.data.x),p!==f&&c!==l){const m=n.indexOf(f),y=n[m+1];if(y){const b=o[0],w=i?{x:(f+y)/2,y:(b==null?void 0:b.y)||l}:{x:(b==null?void 0:b.x)||l,y:(f+y)/2};(!b||s(b,w))&&o.unshift(w)}const x=n.indexOf(p),_=Math.abs(x-m);if(_===1)o=a(o,r.data,t.data),o.length||o.push(i?{x:(f+p)/2,y:c}:{x:c,y:(f+p)/2});else if(_>1){const b=n[x-1];if(b){const w=o[o.length-1],E=i?{x:(p+b)/2,y:(w==null?void 0:w.y)||l}:{x:(w==null?void 0:w.x)||c,y:(p+b)/2};(!w||s(w,E))&&o.push(E)}}}}return o},Pt=(e,r,t)=>{const n=e.getAllNodes(),i=e.getAllEdges();if(!(n!=null&&n.length))return{nodes:[],edges:i};if(n.length===1)return r&&e.mergeNodeData(n[0].id,{x:t[0],y:t[1]}),{nodes:[Object.assign(Object.assign({},n[0]),{data:Object.assign(Object.assign({},n[0].data),{x:t[0],y:t[1]})})],edges:i}},Fy={radius:null,startRadius:null,endRadius:null,startAngle:0,endAngle:2*Math.PI,clockwise:!0,divisions:1,ordering:null,angleRatio:1};class By{constructor(r={}){this.options=r,this.id="circular",this.options=Object.assign(Object.assign({},Fy),r)}execute(r,t){return fe(this,void 0,void 0,function*(){return this.genericCircularLayout(!1,r,t)})}assign(r,t){return fe(this,void 0,void 0,function*(){yield this.genericCircularLayout(!0,r,t)})}genericCircularLayout(r,t,n){return fe(this,void 0,void 0,function*(){const i=Object.assign(Object.assign({},this.options),n),{width:s,height:a,center:o,divisions:c,startAngle:f=0,endAngle:l=2*Math.PI,angleRatio:p,ordering:m,clockwise:y,nodeSpacing:x,nodeSize:_}=i,b=t.getAllNodes(),w=t.getAllEdges(),[E,N,S]=Gy(s,a,o),R=b==null?void 0:b.length;if(!R||R===1)return Pt(t,r,S);const A=(l-f)/R;let{radius:j,startRadius:I,endRadius:D}=i;if(x){const ee=Ct(10,x),J=Sn(10,_);let ae=-1/0;b.forEach(Z=>{const ue=J(Z);ae{ue===0?be+=ae||10:be+=(ee(Z)||0)+(ae||10)}),j=be/(2*Math.PI)}else!j&&!I&&!D?j=Math.min(N,E)/2:!I&&D?I=D:I&&!D&&(D=I);const z=A*p;let $=[];m==="topology"?$=_f(t,b):m==="topology-directed"?$=_f(t,b,!0):m==="degree"?$=$y(t,b):$=b.map(ee=>it(ee));const V=Math.ceil(R/c);for(let ee=0;ee{t.mergeNodeData(ee.id,{x:ee.data.x,y:ee.data.y})}),{nodes:$,edges:w}})}}const _f=(e,r,t=!1)=>{const n=[it(r[0])],i={},s=r.length;i[r[0].id]=!0;let a=0;return r.forEach((o,c)=>{if(c!==0)if((c===s-1||e.getDegree(o.id,"both")!==e.getDegree(r[c+1].id,"both")||e.areNeighbors(n[a].id,o.id))&&!i[o.id])n.push(it(o)),i[o.id]=!0,a++;else{const f=t?e.getSuccessors(n[a].id):e.getNeighbors(n[a].id);let l=!1;for(let m=0;m{t.push(it(n))}),t.sort((n,i)=>e.getDegree(n.id,"both")-e.getDegree(i.id,"both")),t}const Gy=(e,r,t)=>{let n=e,i=r,s=t;return!n&&typeof window<"u"&&(n=window.innerWidth),!i&&typeof window<"u"&&(i=window.innerHeight),s||(s=[n/2,i/2]),[n,i,s]},Uy={nodeSize:30,nodeSpacing:10,preventOverlap:!1,sweep:void 0,equidistant:!1,startAngle:3/2*Math.PI,clockwise:!0,maxLevelDiff:void 0,sortBy:"degree"};class Rn{constructor(r={}){this.options=r,this.id="concentric",this.options=Object.assign(Object.assign({},Uy),r)}execute(r,t){return fe(this,void 0,void 0,function*(){return this.genericConcentricLayout(!1,r,t)})}assign(r,t){return fe(this,void 0,void 0,function*(){yield this.genericConcentricLayout(!0,r,t)})}genericConcentricLayout(r,t,n){return fe(this,void 0,void 0,function*(){const i=Object.assign(Object.assign({},this.options),n),{center:s,width:a,height:o,sortBy:c,maxLevelDiff:f,sweep:l,clockwise:p,equidistant:m,preventOverlap:y,startAngle:x=3/2*Math.PI,nodeSize:_,nodeSpacing:b}=i,w=t.getAllNodes(),E=t.getAllEdges(),N=!a&&typeof window<"u"?window.innerWidth:a,S=!o&&typeof window<"u"?window.innerHeight:o,R=s||[N/2,S/2];if(!(w!=null&&w.length)||w.length===1)return Pt(t,r,R);const A=[];let j,I=0;bt(_)?j=Math.max(_[0],_[1]):wt(_)?(j=-1/0,w.forEach(Z=>{const ue=Math.max(...sr(_(Z)));ue>j&&(j=ue)})):j=_,bt(b)?I=Math.max(b[0],b[1]):me(b)&&(I=b),w.forEach(Z=>{const ue=it(Z);A.push(ue);let pe=j;const{data:he}=ue;bt(he.size)?pe=Math.max(he.size[0],he.size[1]):me(he.size)?pe=he.size:Ut(he.size)&&(pe=Math.max(he.size.width,he.size.height)),j=Math.max(j,pe),wt(b)&&(I=Math.max(b(Z),I))});const D={};A.forEach((Z,ue)=>{D[Z.id]=ue});let z=c;(!nr(z)||A[0].data[z]===void 0)&&(z="degree"),z==="degree"?A.sort((Z,ue)=>t.getDegree(ue.id,"both")-t.getDegree(Z.id,"both")):A.sort((Z,ue)=>ue.data[z]-Z.data[z]);const $=A[0],V=(f||(z==="degree"?t.getDegree($.id,"both"):$.data[z]))/4,Y=[{nodes:[]}];let ee=Y[0];A.forEach(Z=>{if(ee.nodes.length>0){const ue=Math.abs(z==="degree"?t.getDegree(ee.nodes[0].id,"both")-t.getDegree(Z.id,"both"):ee.nodes[0].data[z]-Z.data[z]);V&&ue>=V&&(ee={nodes:[]},Y.push(ee))}ee.nodes.push(Z)});let J=j+I;if(!y){const Z=Y.length>0&&Y[0].nodes.length>1,pe=(Math.min(N,S)/2-J)/(Y.length+(Z?1:0));J=Math.min(J,pe)}let ae=0;if(Y.forEach(Z=>{const ue=l===void 0?2*Math.PI-2*Math.PI/Z.nodes.length:l;if(Z.dTheta=ue/Math.max(1,Z.nodes.length-1),Z.nodes.length>1&&y){const pe=Math.cos(Z.dTheta)-Math.cos(0),he=Math.sin(Z.dTheta)-Math.sin(0),ie=Math.sqrt(J*J/(pe*pe+he*he));ae=Math.max(ie,ae)}Z.r=ae,ae+=J}),m){let Z=0,ue=0;for(let pe=0;pe{he===0&&(ue=pe.r||0),pe.r=ue,ue+=Z})}return Y.forEach(Z=>{const ue=Z.dTheta||0,pe=Z.r||0;Z.nodes.forEach((he,ie)=>{const _e=x+(p?1:-1)*ue*ie;he.data.x=R[0]+pe*Math.cos(_e),he.data.y=R[1]+pe*Math.sin(_e)})}),r&&A.forEach(Z=>t.mergeNodeData(Z.id,{x:Z.data.x,y:Z.data.y})),{nodes:A,edges:E}})}}function Vy(e){const r=+this._x.call(null,e),t=+this._y.call(null,e);return Ef(this.cover(r,t),r,t,e)}function Ef(e,r,t,n){if(isNaN(r)||isNaN(t))return e;var i,s=e._root,a={data:n},o=e._x0,c=e._y0,f=e._x1,l=e._y1,p,m,y,x,_,b,w,E;if(!s)return e._root=a,e;for(;s.length;)if((_=r>=(p=(o+f)/2))?o=p:f=p,(b=t>=(m=(c+l)/2))?c=m:l=m,i=s,!(s=s[w=b<<1|_]))return i[w]=a,e;if(y=+e._x.call(null,s.data),x=+e._y.call(null,s.data),r===y&&t===x)return a.next=s,i?i[w]=a:e._root=a,e;do i=i?i[w]=new Array(4):e._root=new Array(4),(_=r>=(p=(o+f)/2))?o=p:f=p,(b=t>=(m=(c+l)/2))?c=m:l=m;while((w=b<<1|_)===(E=(x>=m)<<1|y>=p));return i[E]=s,i[w]=a,e}function Wy(e){var r,t,n=e.length,i,s,a=new Array(n),o=new Array(n),c=1/0,f=1/0,l=-1/0,p=-1/0;for(t=0;tl&&(l=i),sp&&(p=s));if(c>l||f>p)return this;for(this.cover(c,f).cover(l,p),t=0;te||e>=i||n>r||r>=s;)switch(f=(rl||(o=x.y0)>p||(c=x.x1)=w)<<1|e>=b)&&(x=m[m.length-1],m[m.length-1]=m[m.length-1-_],m[m.length-1-_]=x)}else{var E=e-+this._x.call(null,y.data),N=r-+this._y.call(null,y.data),S=E*E+N*N;if(S=(m=(a+c)/2))?a=m:c=m,(_=p>=(y=(o+f)/2))?o=y:f=y,r=t,!(t=t[b=_<<1|x]))return this;if(!t.length)break;(r[b+1&3]||r[b+2&3]||r[b+3&3])&&(n=r,w=b)}for(;t.data!==e;)if(i=t,!(t=t.next))return this;return(s=t.next)&&delete t.next,i?(s?i.next=s:delete i.next,this):r?(s?r[b]=s:delete r[b],(t=r[0]||r[1]||r[2]||r[3])&&t===(r[3]||r[2]||r[1]||r[0])&&!t.length&&(n?n[w]=t:this._root=t),this):(this._root=s,this)}function Qy(e){for(var r=0,t=e.length;r=(x=(c+p)/2))?c=x:p=x,(R=t>=(_=(f+m)/2))?f=_:m=_,(A=n>=(b=(l+y)/2))?l=b:y=b,s=a,!(a=a[j=A<<2|R<<1|S]))return s[j]=o,e;if(w=+e._x.call(null,a.data),E=+e._y.call(null,a.data),N=+e._z.call(null,a.data),r===w&&t===E&&n===N)return o.next=a,s?s[j]=o:e._root=o,e;do s=s?s[j]=new Array(8):e._root=new Array(8),(S=r>=(x=(c+p)/2))?c=x:p=x,(R=t>=(_=(f+m)/2))?f=_:m=_,(A=n>=(b=(l+y)/2))?l=b:y=b;while((j=A<<2|R<<1|S)===(I=(N>=b)<<2|(E>=_)<<1|w>=x));return s[I]=a,s[j]=o,e}function uw(e){Array.isArray(e)||(e=Array.from(e));const r=e.length,t=new Float64Array(r),n=new Float64Array(r),i=new Float64Array(r);let s=1/0,a=1/0,o=1/0,c=-1/0,f=-1/0,l=-1/0;for(let p=0,m,y,x,_;pc&&(c=y),xf&&(f=x),_l&&(l=_));if(s>c||a>f||o>l)return this;this.cover(s,a,o).cover(c,f,l);for(let p=0;pe||e>=a||i>r||r>=o||s>t||t>=c;)switch(m=(tx||(f=N.y0)>_||(l=N.z0)>b||(p=N.x1)=j)<<2|(r>=A)<<1|e>=R)&&(N=w[w.length-1],w[w.length-1]=w[w.length-1-S],w[w.length-1-S]=N)}else{var I=e-+this._x.call(null,E.data),D=r-+this._y.call(null,E.data),z=t-+this._z.call(null,E.data),$=I*I+D*D+z*z;if($Math.sqrt((e-n)**2+(r-i)**2+(t-s)**2);function gw(e,r,t,n){const i=[],s=e-n,a=r-n,o=t-n,c=e+n,f=r+n,l=t+n;return this.visit((p,m,y,x,_,b,w)=>{if(!p.length)do{const E=p.data;dw(e,r,t,this._x(E),this._y(E),this._z(E))<=n&&i.push(E)}while(p=p.next);return m>c||y>f||x>l||_=(_=(a+f)/2))?a=_:f=_,(N=y>=(b=(o+l)/2))?o=b:l=b,(S=x>=(w=(c+p)/2))?c=w:p=w,r=t,!(t=t[R=S<<2|N<<1|E]))return this;if(!t.length)break;(r[R+1&7]||r[R+2&7]||r[R+3&7]||r[R+4&7]||r[R+5&7]||r[R+6&7]||r[R+7&7])&&(n=r,A=R)}for(;t.data!==e;)if(i=t,!(t=t.next))return this;return(s=t.next)&&delete t.next,i?(s?i.next=s:delete i.next,this):r?(s?r[R]=s:delete r[R],(t=r[0]||r[1]||r[2]||r[3]||r[4]||r[5]||r[6]||r[7])&&t===(r[7]||r[6]||r[5]||r[4]||r[3]||r[2]||r[1]||r[0])&&!t.length&&(n?n[A]=t:this._root=t),this):(this._root=s,this)}function vw(e){for(var r=0,t=e.length;r{const{nodeStrength:m,x:y,y:x,z:_,size:b}=l.data;return{x:y,y:x,z:_,size:b,index:p,id:l.id,vx:0,vy:0,vz:0,weight:s*m}}),c=(i===2?Wt(o,l=>l.x,l=>l.y):Rr(o,l=>l.x,l=>l.y,l=>l.z)).visitAfter(Ow),f=new Map;return o.forEach(l=>{f.set(l.id,l),Iw(l,c,i)}),o.map((l,p)=>{const{id:m,data:y}=a[p],{mass:x=1}=y;n[m]={x:l.vx/x,y:l.vy/x,z:l.vz/x}}),n}function Ow(e){let r=0,t=0,n=0,i=0,s=0;const a=e.length;if(a){for(let o=0;o{var o;if(((o=e.data)===null||o===void 0?void 0:o.id)===s.id)return;const c=[t,n,i][a-1],f=s.x-e.x||In,l=s.y-e.y||In,p=s.z-e.z||In,m=[f,l,p],y=c-r;let x=0;for(let w=0;wAw(n,i,s,a,o,e,t))}const Tw={dimensions:2,maxIteration:500,gravity:10,factor:1,edgeStrength:50,nodeStrength:1e3,coulombDisScale:.005,damping:.9,maxSpeed:200,minMovement:.4,interval:.02,linkDistance:200,clusterNodeStrength:20,preventOverlap:!0,distanceThresholdMode:"mean"};class Sf{constructor(r={}){this.options=r,this.id="force",this.timeInterval=0,this.judgingDistance=0,this.running=!1,this.options=Object.assign(Object.assign({},Tw),r)}execute(r,t){return fe(this,void 0,void 0,function*(){return this.genericForceLayout(!1,r,t)})}assign(r,t){return fe(this,void 0,void 0,function*(){yield this.genericForceLayout(!0,r,t)})}stop(){this.timeInterval&&typeof window<"u"&&window.clearInterval(this.timeInterval),this.running=!1}tick(r=this.options.maxIteration||1){if(this.lastResult)return this.lastResult;for(let n=0;(this.judgingDistance>this.lastOptions.minMovement||n<1)&&nthis.lastGraph.mergeNodeData(n.id,{x:n.data.x,y:n.data.y,z:this.options.dimensions===3?n.data.z:void 0})),t}genericForceLayout(r,t,n){return fe(this,void 0,void 0,function*(){const i=Object.assign(Object.assign({},this.options),n),s=t.getAllNodes(),a=t.getAllEdges(),o=this.formatOptions(i,t),{dimensions:c,width:f,height:l,nodeSize:p,getMass:m,nodeStrength:y,edgeStrength:x,linkDistance:_}=o,b=s.map((I,D)=>Object.assign(Object.assign({},I),{data:Object.assign(Object.assign({},I.data),{x:me(I.data.x)?I.data.x:Math.random()*f,y:me(I.data.y)?I.data.y:Math.random()*l,z:me(I.data.z)?I.data.z:Math.random()*Math.sqrt(f*l),size:p(I)||30,mass:m(I),nodeStrength:y(I)})})),w=a.map(I=>Object.assign(Object.assign({},I),{data:Object.assign(Object.assign({},I.data),{edgeStrength:x(I),linkDistance:_(I,t.getNode(I.source),t.getNode(I.target))})}));if(!(s!=null&&s.length))return this.lastResult={nodes:[],edges:a},{nodes:[],edges:a};const E={};s.forEach((I,D)=>{E[I.id]={x:0,y:0,z:0}});const N=new Be({nodes:b,edges:w});this.formatCentripetal(o,N);const{maxIteration:S,minMovement:R,onTick:A}=o;if(this.lastLayoutNodes=b,this.lastLayoutEdges=w,this.lastAssign=r,this.lastGraph=t,this.lastCalcGraph=N,this.lastOptions=o,this.lastVelMap=E,typeof window>"u")return;let j=0;return new Promise(I=>{this.timeInterval=window.setInterval(()=>{(!s||!this.running)&&I({nodes:Tn(t,b),edges:a}),this.runOneStep(N,t,j,E,o),this.updatePosition(t,N,E,o),r&&b.forEach(D=>t.mergeNodeData(D.id,{x:D.data.x,y:D.data.y,z:c===3?D.data.z:void 0})),A==null||A({nodes:Tn(t,b),edges:a}),j++,(j>=S||this.judgingDistance{let f=1;me(c==null?void 0:c.data.mass)&&(f=c==null?void 0:c.data.mass);const l=t.getDegree(c.id,"both");return!l||l<5?f:l*5*f}),n.nodeSize=qn(r.nodeSize,r.nodeSpacing);const o=r.linkDistance?Ct(1,r.linkDistance):c=>1+n.nodeSize(t.getNode(c.source))+n.nodeSize(t.getNode(c.target));return n.linkDistance=o,n.nodeStrength=Ct(1,r.nodeStrength),n.edgeStrength=Ct(1,r.edgeStrength),n}formatCentripetal(r,t){const{dimensions:n,centripetalOptions:i,center:s,clusterNodeStrength:a,leafCluster:o,clustering:c,nodeClusterBy:f}=r,l=t.getAllNodes(),p=i||{leaf:2,single:2,others:1,center:w=>({x:s[0],y:s[1],z:n===3?s[2]:void 0})};typeof a!="function"&&(r.clusterNodeStrength=w=>a);let m,y;if(o&&f&&(m=qf(t,f),y=Array.from(new Set(l==null?void 0:l.map(w=>w.data[f])))||[],r.centripetalOptions=Object.assign(p,{single:100,leaf:w=>{const{siblingLeaves:E,sameTypeLeaves:N}=m[w.id]||{};return(N==null?void 0:N.length)===(E==null?void 0:E.length)||(y==null?void 0:y.length)===1?1:r.clusterNodeStrength(w)},others:1,center:w=>{const E=t.getDegree(w.id,"both");if(!E)return{x:100,y:100,z:0};let N;if(E===1){const{sameTypeLeaves:S=[]}=m[w.id]||{};S.length===1?N=void 0:S.length>1&&(N=Rf(S))}else N=void 0;return{x:N==null?void 0:N.x,y:N==null?void 0:N.y,z:N==null?void 0:N.z}}})),c&&f){m||(m=qf(t,f)),y||(y=Array.from(new Set(l.map(E=>E.data[f])))),y=y.filter(E=>E!==void 0);const w={};y.forEach(E=>{const N=l.filter(S=>S.data[f]===E).map(S=>t.getNode(S.id));w[E]=Rf(N)}),r.centripetalOptions=Object.assign(p,{single:E=>r.clusterNodeStrength(E),leaf:E=>r.clusterNodeStrength(E),others:E=>r.clusterNodeStrength(E),center:E=>{const N=w[E.data[f]];return{x:N==null?void 0:N.x,y:N==null?void 0:N.y,z:N==null?void 0:N.z}}})}const{leaf:x,single:_,others:b}=r.centripetalOptions||{};x&&typeof x!="function"&&(r.centripetalOptions.leaf=()=>x),_&&typeof _!="function"&&(r.centripetalOptions.single=()=>_),b&&typeof b!="function"&&(r.centripetalOptions.others=()=>b)}runOneStep(r,t,n,i,s){const a={},o=r.getAllNodes(),c=r.getAllEdges();if(!(o!=null&&o.length))return;const{monitor:f}=s;if(this.calRepulsive(r,a,s),c&&this.calAttractive(r,a,s),this.calGravity(r,t,a,s),this.updateVelocity(r,a,i,s),f){const l=this.calTotalEnergy(a,o);f({energy:l,nodes:t.getAllNodes(),edges:t.getAllEdges(),iterations:n})}}calTotalEnergy(r,t){if(!(t!=null&&t.length))return 0;let n=0;return t.forEach((i,s)=>{const a=r[i.id].x,o=r[i.id].y,c=this.options.dimensions===3?r[i.id].z:0,f=a*a+o*o+c*c,{mass:l=1}=i.data;n+=l*f*.5}),n}calRepulsive(r,t,n){const{dimensions:i,factor:s,coulombDisScale:a}=n;Rw(r,s,a*a,t,i)}calAttractive(r,t,n){const{dimensions:i,nodeSize:s}=n;r.getAllEdges().forEach((a,o)=>{const{source:c,target:f}=a,l=r.getNode(c),p=r.getNode(f);if(!l||!p)return;let m=p.data.x-l.data.x,y=p.data.y-l.data.y,x=i===3?p.data.z-l.data.z:0;!m&&!y&&(m=Math.random()*.01,y=Math.random()*.01,i===3&&!x&&(x=Math.random()*.01));const _=Math.sqrt(m*m+y*y+x*x);if(_{const{id:_,data:b}=x,{mass:w,x:E,y:N,z:S}=b,R=t.getNode(_);let A=0,j=0,I=0,D=m;const z=r.getDegree(_,"in"),$=r.getDegree(_,"out"),V=r.getDegree(_,"both"),Y=s==null?void 0:s(R,V);if(Y){const[ee,J,ae]=Y;A=E-ee,j=N-J,D=ae}else A=E-p[0],j=N-p[1],I=S-p[2];if(D&&(n[_].x-=D*A/w,n[_].y-=D*j/w,n[_].z-=D*I/w),y){const{leaf:ee,single:J,others:ae,center:be}=y,{x:Z,y:ue,z:pe,centerStrength:he}=(be==null?void 0:be(R,o,c,f,l))||{x:0,y:0,z:0,centerStrength:0};if(!me(Z)||!me(ue))return;const ie=(E-Z)/w,_e=(N-ue)/w,G=(S-pe)/w;if(he&&(n[_].x-=he*ie,n[_].y-=he*_e,n[_].z-=he*G),V===0){const X=J(R);if(!X)return;n[_].x-=X*ie,n[_].y-=X*_e,n[_].z-=X*G;return}if(z===0||$===0){const X=ee(R,o,c);if(!X)return;n[_].x-=X*ie,n[_].y-=X*_e,n[_].z-=X*G;return}const P=ae(R);if(!P)return;n[_].x-=P*ie,n[_].y-=P*_e,n[_].z-=P*G}})}updateVelocity(r,t,n,i){const{damping:s,maxSpeed:a,interval:o,dimensions:c}=i,f=r.getAllNodes();f!=null&&f.length&&f.forEach(l=>{const{id:p}=l;let m=(n[p].x+t[p].x*o)*s||.01,y=(n[p].y+t[p].y*o)*s||.01,x=c===3?(n[p].z+t[p].z*o)*s||.01:0;const _=Math.sqrt(m*m+y*y+x*x);if(_>a){const b=a/_;m=b*m,y=b*y,x=b*x}n[p]={x:m,y,z:x}})}updatePosition(r,t,n,i){const{distanceThresholdMode:s,interval:a,dimensions:o}=i,c=t.getAllNodes();if(!(c!=null&&c.length)){this.judgingDistance=0;return}let f=0;s==="max"?this.judgingDistance=-1/0:s==="min"&&(this.judgingDistance=1/0),c.forEach(l=>{const{id:p}=l,m=r.getNode(p);if(me(m.data.fx)&&me(m.data.fy)){t.mergeNodeData(p,{x:m.data.fx,y:m.data.fy,z:o===3?m.data.fz:void 0});return}const y=n[p].x*a,x=n[p].y*a,_=o===3?n[p].z*a:0;t.mergeNodeData(p,{x:l.data.x+y,y:l.data.y+x,z:l.data.z+_});const b=Math.sqrt(y*y+x*x+_*_);switch(s){case"max":this.judgingDistanceb&&(this.judgingDistance=b);break;default:f=f+b;break}}),(!s||s==="mean")&&(this.judgingDistance=f/c.length)}}const qf=(e,r)=>{const t=e.getAllNodes();if(!(t!=null&&t.length))return{};const n={};return t.forEach((i,s)=>{e.getDegree(i.id,"both")===1&&(n[i.id]=kw(e,"leaf",i,r))}),n},kw=(e,r,t,n)=>{const i=e.getDegree(t.id,"in"),s=e.getDegree(t.id,"out");let a=t,o=[];i===0?(a=e.getSuccessors(t.id)[0],o=e.getNeighbors(a.id)):s===0&&(a=e.getPredecessors(t.id)[0],o=e.getNeighbors(a.id)),o=o.filter(f=>e.getDegree(f.id,"in")===0||e.getDegree(f.id,"out")===0);const c=jw(e,r,n,t,o);return{coreNode:a,siblingLeaves:o,sameTypeLeaves:c}},jw=(e,r,t,n,i)=>{const s=n.data[t]||"";let a=(i==null?void 0:i.filter(o=>o.data[t]===s))||[];return a=a.filter(o=>e.getDegree(o.id,"in")===0||e.getDegree(o.id,"out")===0),a},Rf=e=>{const r={x:0,y:0};e.forEach(n=>{const{x:i,y:s}=n.data;r.x+=i||0,r.y+=s||0});const t=e.length||1;return{x:r.x/t,y:r.y/t}},Tn=(e,r)=>r.map(t=>{const{id:n,data:i}=t,s=e.getNode(n);return Object.assign(Object.assign({},s),{data:Object.assign(Object.assign({},s.data),{x:i.x,y:i.y,z:i.z})})});var Or=typeof globalThis<"u"?globalThis:typeof window<"u"?window:typeof global<"u"?global:typeof self<"u"?self:{};function Of(e){return e&&e.__esModule&&Object.prototype.hasOwnProperty.call(e,"default")?e.default:e}function Af(e){if(e.__esModule)return e;var r=e.default;if(typeof r=="function"){var t=function n(){return this instanceof n?Reflect.construct(r,arguments,this.constructor):r.apply(this,arguments)};t.prototype=r.prototype}else t={};return Object.defineProperty(t,"__esModule",{value:!0}),Object.keys(e).forEach(function(n){var i=Object.getOwnPropertyDescriptor(e,n);Object.defineProperty(t,n,i.get?i:{enumerable:!0,get:function(){return e[n]}})}),t}var we={};const Cw=Object.prototype.toString;function or(e){const r=Cw.call(e);return r.endsWith("Array]")&&!r.includes("Big")}var Pw=Object.freeze({__proto__:null,isAnyArray:or}),Lw=Af(Pw);function Dw(e){var r=arguments.length>1&&arguments[1]!==void 0?arguments[1]:{};if(!or(e))throw new TypeError("input must be an array");if(e.length===0)throw new TypeError("input must not be empty");var t=r.fromIndex,n=t===void 0?0:t,i=r.toIndex,s=i===void 0?e.length:i;if(n<0||n>=e.length||!Number.isInteger(n))throw new Error("fromIndex must be a positive integer smaller than length");if(s<=n||s>e.length||!Number.isInteger(s))throw new Error("toIndex must be an integer greater than fromIndex and at most equal to length");for(var a=e[n],o=n+1;oa&&(a=e[o]);return a}function zw(e){var r=arguments.length>1&&arguments[1]!==void 0?arguments[1]:{};if(!or(e))throw new TypeError("input must be an array");if(e.length===0)throw new TypeError("input must not be empty");var t=r.fromIndex,n=t===void 0?0:t,i=r.toIndex,s=i===void 0?e.length:i;if(n<0||n>=e.length||!Number.isInteger(n))throw new Error("fromIndex must be a positive integer smaller than length");if(s<=n||s>e.length||!Number.isInteger(s))throw new Error("toIndex must be an integer greater than fromIndex and at most equal to length");for(var a=e[n],o=n+1;o1&&arguments[1]!==void 0?arguments[1]:{};if(or(e)){if(e.length===0)throw new TypeError("input must not be empty")}else throw new TypeError("input must be an array");var t;if(r.output!==void 0){if(!or(r.output))throw new TypeError("output option must be an array if specified");t=r.output}else t=new Array(e.length);var n=zw(e),i=Dw(e);if(n===i)throw new RangeError("minimum and maximum input values are equal. Cannot rescale a constant array");var s=r.min,a=s===void 0?r.autoMinMax?n:0:s,o=r.max,c=o===void 0?r.autoMinMax?i:1:o;if(a>=c)throw new RangeError("min option must be smaller than max option");for(var f=(c-a)/(i-n),l=0;l=0&&h?` ${c(M,g-1)}`:c(M,g)).padEnd(g)}function c(M,g){let h=M.toString();if(h.length<=g)return h;let u=M.toFixed(g);if(u.length>g&&(u=M.toFixed(Math.max(0,g-(u.length-g)))),u.length<=g&&!u.startsWith("0.000")&&!u.startsWith("-0.000"))return u;let d=M.toExponential(g);return d.length>g&&(d=M.toExponential(Math.max(0,g-(d.length-g)))),d.slice(0)}function f(M,g){M.prototype.add=function(u){return typeof u=="number"?this.addS(u):this.addM(u)},M.prototype.addS=function(u){for(let d=0;d>u);return this},M.prototype.signPropagatingRightShiftM=function(u){if(u=g.checkMatrix(u),this.rows!==u.rows||this.columns!==u.columns)throw new RangeError("Matrices dimensions must be equal");for(let d=0;d>u.get(d,v));return this},M.signPropagatingRightShift=function(u,d){return new g(u).signPropagatingRightShift(d)},M.prototype.rightShift=function(u){return typeof u=="number"?this.rightShiftS(u):this.rightShiftM(u)},M.prototype.rightShiftS=function(u){for(let d=0;d>>u);return this},M.prototype.rightShiftM=function(u){if(u=g.checkMatrix(u),this.rows!==u.rows||this.columns!==u.columns)throw new RangeError("Matrices dimensions must be equal");for(let d=0;d>>u.get(d,v));return this},M.rightShift=function(u,d){return new g(u).rightShift(d)},M.prototype.zeroFillRightShift=M.prototype.rightShift,M.prototype.zeroFillRightShiftS=M.prototype.rightShiftS,M.prototype.zeroFillRightShiftM=M.prototype.rightShiftM,M.zeroFillRightShift=M.rightShift,M.prototype.not=function(){for(let u=0;uu)throw new RangeError("Row index out of range")}function p(M,g,h){let u=h?M.columns:M.columns-1;if(g<0||g>u)throw new RangeError("Column index out of range")}function m(M,g){if(g.to1DArray&&(g=g.to1DArray()),g.length!==M.columns)throw new RangeError("vector size must be the same as the number of columns");return g}function y(M,g){if(g.to1DArray&&(g=g.to1DArray()),g.length!==M.rows)throw new RangeError("vector size must be the same as the number of rows");return g}function x(M,g){if(!e.isAnyArray(g))throw new TypeError("row indices must be an array");for(let h=0;h=M.rows)throw new RangeError("row indices are out of range")}function _(M,g){if(!e.isAnyArray(g))throw new TypeError("column indices must be an array");for(let h=0;h=M.columns)throw new RangeError("column indices are out of range")}function b(M,g,h,u,d){if(arguments.length!==5)throw new RangeError("expected 4 arguments");if(E("startRow",g),E("endRow",h),E("startColumn",u),E("endColumn",d),g>h||u>d||g<0||g>=M.rows||h<0||h>=M.rows||u<0||u>=M.columns||d<0||d>=M.columns)throw new RangeError("Submatrix indices are out of range")}function w(M,g=0){let h=[];for(let u=0;u=v)throw new RangeError("min must be smaller than max");let O=v-d,T=new P(g,h);for(let k=0;ku?(v=!0,u=h):(d=!1,v=!0);g++}return d}isReducedEchelonForm(){let g=0,h=0,u=-1,d=!0,v=!1;for(;gu?(v=!0,u=h):(d=!1,v=!0);for(let q=h+1;qg.get(d,u)&&(d=v);if(g.get(d,u)===0)u++;else{g.swapRows(h,d);let v=g.get(h,u);for(let q=u;q=0;)if(g.maxRow(d)===0)d--;else{let v=0,q=!1;for(;vh[u]&&(h[u]=this.get(u,d));return h}case"column":{const h=new Array(this.columns).fill(Number.NEGATIVE_INFINITY);for(let u=0;uh[d]&&(h[d]=this.get(u,d));return h}case void 0:{let h=this.get(0,0);for(let u=0;uh&&(h=this.get(u,d));return h}default:throw new Error(`invalid option: ${g}`)}}maxIndex(){N(this);let g=this.get(0,0),h=[0,0];for(let u=0;ug&&(g=this.get(u,d),h[0]=u,h[1]=d);return h}min(g){if(this.isEmpty())return NaN;switch(g){case"row":{const h=new Array(this.rows).fill(Number.POSITIVE_INFINITY);for(let u=0;uh&&(h=this.get(g,u));return h}maxRowIndex(g){l(this,g),N(this);let h=this.get(g,0),u=[g,0];for(let d=1;dh&&(h=this.get(g,d),u[1]=d);return u}minRow(g){if(l(this,g),this.isEmpty())return NaN;let h=this.get(g,0);for(let u=1;uh&&(h=this.get(u,g));return h}maxColumnIndex(g){p(this,g),N(this);let h=this.get(0,g),u=[0,g];for(let d=1;dh&&(h=this.get(d,g),u[0]=d);return u}minColumn(g){if(p(this,g),this.isEmpty())return NaN;let h=this.get(0,g);for(let u=1;u=1;d/=2)d&1&&(h=h.mmul(u)),u=u.mmul(u);return h}strassen2x2(g){g=P.checkMatrix(g);let h=new P(2,2);const u=this.get(0,0),d=g.get(0,0),v=this.get(0,1),q=g.get(0,1),O=this.get(1,0),T=g.get(1,0),k=this.get(1,1),B=g.get(1,1),C=(u+k)*(d+B),W=(O+k)*d,ne=u*(q-B),U=k*(T-d),K=(u+v)*B,se=(O-u)*(d+q),L=(v-k)*(T+B),re=C+U-K+L,ce=ne+K,ve=W+U,ye=C-W+ne+se;return h.set(0,0,re),h.set(0,1,ce),h.set(1,0,ve),h.set(1,1,ye),h}strassen3x3(g){g=P.checkMatrix(g);let h=new P(3,3);const u=this.get(0,0),d=this.get(0,1),v=this.get(0,2),q=this.get(1,0),O=this.get(1,1),T=this.get(1,2),k=this.get(2,0),B=this.get(2,1),C=this.get(2,2),W=g.get(0,0),ne=g.get(0,1),U=g.get(0,2),K=g.get(1,0),se=g.get(1,1),L=g.get(1,2),re=g.get(2,0),ce=g.get(2,1),ve=g.get(2,2),ye=(u+d+v-q-O-B-C)*se,ke=(u-q)*(-ne+se),de=O*(-W+ne+K-se-L-re+ve),ge=(-u+q+O)*(W-ne+se),Re=(q+O)*(-W+ne),F=u*W,Q=(-u+k+B)*(W-U+L),oe=(-u+k)*(U-L),H=(k+B)*(-W+U),je=(u+d+v-O-T-k-B)*L,Se=B*(-W+U+K-se-L-re+ce),Ae=(-v+B+C)*(se+re-ce),Ce=(v-C)*(se-ce),Xe=v*re,dt=(B+C)*(-re+ce),Ge=(-v+O+T)*(L+re-ve),yt=(v-T)*(L-ve),Rt=(O+T)*(-re+ve),Ne=d*K,Ze=T*ce,st=q*U,ot=k*ne,Ue=C*ve,Ux=F+Xe+Ne,Vx=ye+ge+Re+F+Ae+Xe+dt,Wx=F+Q+H+je+Xe+Ge+Rt,Yx=ke+de+ge+F+Xe+Ge+yt,Kx=ke+ge+Re+F+Ze,Xx=Xe+Ge+yt+Rt+st,Zx=F+Q+oe+Se+Ae+Ce+Xe,Jx=Ae+Ce+Xe+dt+ot,Qx=F+Q+oe+H+Ue;return h.set(0,0,Ux),h.set(0,1,Vx),h.set(0,2,Wx),h.set(1,0,Yx),h.set(1,1,Kx),h.set(1,2,Xx),h.set(2,0,Zx),h.set(2,1,Jx),h.set(2,2,Qx),h}mmulStrassen(g){g=P.checkMatrix(g);let h=this.clone(),u=h.rows,d=h.columns,v=g.rows,q=g.columns;d!==v&&console.warn(`Multiplying ${u} x ${d} and ${v} x ${q} matrix: dimensions do not match.`);function O(C,W,ne){let U=C.rows,K=C.columns;if(U===W&&K===ne)return C;{let se=ie.zeros(W,ne);return se=se.setSubMatrix(C,0,0),se}}let T=Math.max(u,v),k=Math.max(d,q);h=O(h,T,k),g=O(g,T,k);function B(C,W,ne,U){if(ne<=512||U<=512)return C.mmul(W);ne%2===1&&U%2===1?(C=O(C,ne+1,U+1),W=O(W,ne+1,U+1)):ne%2===1?(C=O(C,ne+1,U),W=O(W,ne+1,U)):U%2===1&&(C=O(C,ne,U+1),W=O(W,ne,U+1));let K=parseInt(C.rows/2,10),se=parseInt(C.columns/2,10),L=C.subMatrix(0,K-1,0,se-1),re=W.subMatrix(0,K-1,0,se-1),ce=C.subMatrix(0,K-1,se,C.columns-1),ve=W.subMatrix(0,K-1,se,W.columns-1),ye=C.subMatrix(K,C.rows-1,0,se-1),ke=W.subMatrix(K,W.rows-1,0,se-1),de=C.subMatrix(K,C.rows-1,se,C.columns-1),ge=W.subMatrix(K,W.rows-1,se,W.columns-1),Re=B(ie.add(L,de),ie.add(re,ge),K,se),F=B(ie.add(ye,de),re,K,se),Q=B(L,ie.sub(ve,ge),K,se),oe=B(de,ie.sub(ke,re),K,se),H=B(ie.add(L,ce),ge,K,se),je=B(ie.sub(ye,L),ie.add(re,ve),K,se),Se=B(ie.sub(ce,de),ie.add(ke,ge),K,se),Ae=ie.add(Re,oe);Ae.sub(H),Ae.add(Se);let Ce=ie.add(Q,H),Xe=ie.add(F,oe),dt=ie.sub(Re,F);dt.add(Q),dt.add(je);let Ge=ie.zeros(2*Ae.rows,2*Ae.columns);return Ge=Ge.setSubMatrix(Ae,0,0),Ge=Ge.setSubMatrix(Ce,Ae.rows,0),Ge=Ge.setSubMatrix(Xe,0,Ae.columns),Ge=Ge.setSubMatrix(dt,Ae.rows,Ae.columns),Ge.subMatrix(0,ne-1,0,U-1)}return B(h,g,T,k)}scaleRows(g={}){if(typeof g!="object")throw new TypeError("options must be an object");const{min:h=0,max:u=1}=g;if(!Number.isFinite(h))throw new TypeError("min must be a number");if(!Number.isFinite(u))throw new TypeError("max must be a number");if(h>=u)throw new RangeError("min must be smaller than max");let d=new P(this.rows,this.columns);for(let v=0;v0&&r(q,{min:h,max:u,output:q}),d.setRow(v,q)}return d}scaleColumns(g={}){if(typeof g!="object")throw new TypeError("options must be an object");const{min:h=0,max:u=1}=g;if(!Number.isFinite(h))throw new TypeError("min must be a number");if(!Number.isFinite(u))throw new TypeError("max must be a number");if(h>=u)throw new RangeError("min must be smaller than max");let d=new P(this.rows,this.columns);for(let v=0;vu||h<0||h>=this.columns||u<0||u>=this.columns)throw new RangeError("Argument out of range");let d=new P(g.length,u-h+1);for(let v=0;v=this.rows)throw new RangeError(`Row index out of range: ${g[v]}`);d.set(v,q-h,this.get(g[v],q))}return d}subMatrixColumn(g,h,u){if(h===void 0&&(h=0),u===void 0&&(u=this.rows-1),h>u||h<0||h>=this.rows||u<0||u>=this.rows)throw new RangeError("Argument out of range");let d=new P(u-h+1,g.length);for(let v=0;v=this.columns)throw new RangeError(`Column index out of range: ${g[v]}`);d.set(q-h,v,this.get(q,g[v]))}return d}setSubMatrix(g,h,u){if(g=P.checkMatrix(g),g.isEmpty())return this;let d=h+g.rows-1,v=u+g.columns-1;b(this,h,d,u,v);for(let q=0;qtypeof g=="number")}ie.random=ie.rand,ie.randomInt=ie.randInt,ie.diagonal=ie.diag,ie.prototype.diagonal=ie.prototype.diag,ie.identity=ie.eye,ie.prototype.negate=ie.prototype.neg,ie.prototype.tensorProduct=ie.prototype.kroneckerProduct;const un=class un extends ie{constructor(h,u){super();Rc(this,wr);Ie(this,"data");if(un.isMatrix(h))Oc(this,wr,Ac).call(this,h.rows,h.columns),un.copy(h,this);else if(Number.isInteger(h)&&h>=0)Oc(this,wr,Ac).call(this,h,u);else if(e.isAnyArray(h)){const d=h;if(h=d.length,u=h?d[0].length:0,typeof u!="number")throw new TypeError("Data must be a 2D array with at least one element");this.data=[];for(let v=0;v"u"&&(u=h,h=this.columns),p(this,h,!0),u=y(this,u);for(let d=0;d=0)for(let d=0;d=0)fn(this,He,new P(h,h));else if(fn(this,He,new P(h)),!this.isSymmetric())throw new TypeError("not symmetric data")}get size(){return gt(this,He).size}get rows(){return gt(this,He).rows}get columns(){return gt(this,He).columns}get diagonalSize(){return this.rows}static isSymmetricMatrix(h){return P.isMatrix(h)&&h.klassType==="SymmetricMatrix"}static zeros(h){return new this(h)}static ones(h){return new this(h).fill(1)}clone(){const h=new cn(this.diagonalSize);for(const[u,d,v]of this.upperRightEntries())h.set(u,d,v);return h}toMatrix(){return new P(this)}get(h,u){return gt(this,He).get(h,u)}set(h,u,d){return gt(this,He).set(h,u,d),gt(this,He).set(u,h,d),this}removeCross(h){return gt(this,He).removeRow(h),gt(this,He).removeColumn(h),this}addCross(h,u){u===void 0&&(u=h,h=this.diagonalSize);const d=u.slice();return d.splice(h,1),gt(this,He).addRow(h,d),gt(this,He).addColumn(h,u),this}applyMask(h){if(h.length!==this.diagonalSize)throw new RangeError("Mask size do not match with matrix size");const u=[];for(const[d,v]of h.entries())v||u.push(d);u.reverse();for(const d of u)this.removeCross(d);return this}toCompact(){const{diagonalSize:h}=this,u=new Array(h*(h+1)/2);for(let d=0,v=0,q=0;q=h&&(d=++v);return u}static fromCompact(h){const u=h.length,d=(Math.sqrt(8*u+1)-1)/2;if(!Number.isInteger(d))throw new TypeError(`This array is not a compact representation of a Symmetric Matrix, ${JSON.stringify(h)}`);const v=new cn(d);for(let q=0,O=0,T=0;T=d&&(q=++O);return v}*upperRightEntries(){for(let h=0,u=0;h=this.diagonalSize&&(u=++h)}}*upperRightValues(){for(let h=0,u=0;h=this.diagonalSize&&(u=++h)}};He=new WeakMap;let X=cn;X.prototype.klassType="SymmetricMatrix";class te extends X{static isDistanceMatrix(g){return X.isSymmetricMatrix(g)&&g.klassSubType==="DistanceMatrix"}constructor(g){if(super(g),!this.isDistance())throw new TypeError("Provided arguments do no produce a distance matrix")}set(g,h,u){return g===h&&(u=0),super.set(g,h,u)}addCross(g,h){return h===void 0&&(h=g,g=this.diagonalSize),h=h.slice(),h[g]=0,super.addCross(g,h)}toSymmetricMatrix(){return new X(this)}clone(){const g=new te(this.diagonalSize);for(const[h,u,d]of this.upperRightEntries())h!==u&&g.set(h,u,d);return g}toCompact(){const{diagonalSize:g}=this,h=(g-1)*g/2,u=new Array(h);for(let d=1,v=0,q=0;q=g&&(d=++v+1);return u}static fromCompact(g){const h=g.length;if(h===0)return new this(0);const u=(Math.sqrt(8*h+1)+1)/2;if(!Number.isInteger(u))throw new TypeError(`This array is not a compact representation of a DistanceMatrix, ${JSON.stringify(g)}`);const d=new this(u);for(let v=1,q=0,O=0;O=u&&(v=++q+1);return d}}te.prototype.klassSubType="DistanceMatrix";class le extends ie{constructor(g,h,u){super(),this.matrix=g,this.rows=h,this.columns=u}}class xe extends le{constructor(g,h){p(g,h),super(g,g.rows,1),this.column=h}set(g,h,u){return this.matrix.set(g,this.column,u),this}get(g){return this.matrix.get(g,this.column)}}class Le extends le{constructor(g,h){_(g,h),super(g,g.rows,h.length),this.columnIndices=h}set(g,h,u){return this.matrix.set(g,this.columnIndices[h],u),this}get(g,h){return this.matrix.get(g,this.columnIndices[h])}}class Je extends le{constructor(g){super(g,g.rows,g.columns)}set(g,h,u){return this.matrix.set(g,this.columns-h-1,u),this}get(g,h){return this.matrix.get(g,this.columns-h-1)}}class tr extends le{constructor(g){super(g,g.rows,g.columns)}set(g,h,u){return this.matrix.set(this.rows-g-1,h,u),this}get(g,h){return this.matrix.get(this.rows-g-1,h)}}class Qe extends le{constructor(g,h){l(g,h),super(g,1,g.columns),this.row=h}set(g,h,u){return this.matrix.set(this.row,h,u),this}get(g,h){return this.matrix.get(this.row,h)}}class Ve extends le{constructor(g,h){x(g,h),super(g,h.length,g.columns),this.rowIndices=h}set(g,h,u){return this.matrix.set(this.rowIndices[g],h,u),this}get(g,h){return this.matrix.get(this.rowIndices[g],h)}}class Ee extends le{constructor(g,h,u){x(g,h),_(g,u),super(g,h.length,u.length),this.rowIndices=h,this.columnIndices=u}set(g,h,u){return this.matrix.set(this.rowIndices[g],this.columnIndices[h],u),this}get(g,h){return this.matrix.get(this.rowIndices[g],this.columnIndices[h])}}class Mt extends le{constructor(g,h,u,d,v){b(g,h,u,d,v),super(g,u-h+1,v-d+1),this.startRow=h,this.startColumn=d}set(g,h,u){return this.matrix.set(this.startRow+g,this.startColumn+h,u),this}get(g,h){return this.matrix.get(this.startRow+g,this.startColumn+h)}}class Me extends le{constructor(g){super(g,g.columns,g.rows)}set(g,h,u){return this.matrix.set(h,g,u),this}get(g,h){return this.matrix.get(h,g)}}class St extends ie{constructor(g,h={}){const{rows:u=1}=h;if(g.length%u!==0)throw new Error("the data length is not divisible by the number of rows");super(),this.rows=u,this.columns=g.length/u,this.data=g}set(g,h,u){let d=this._calculateIndex(g,h);return this.data[d]=u,this}get(g,h){let u=this._calculateIndex(g,h);return this.data[u]}_calculateIndex(g,h){return g*this.columns+h}}class ze extends ie{constructor(g){super(),this.data=g,this.rows=g.length,this.columns=g[0].length}set(g,h,u){return this.data[g][h]=u,this}get(g,h){return this.data[g][h]}}function Mc(M,g){if(e.isAnyArray(M))return M[0]&&e.isAnyArray(M[0])?new ze(M):new St(M,g);throw new Error("the argument is not an array")}class qt{constructor(g){g=ze.checkMatrix(g);let h=g.clone(),u=h.rows,d=h.columns,v=new Float64Array(u),q=1,O,T,k,B,C,W,ne,U,K;for(O=0;OMath.abs(U[B])&&(B=O);if(B!==T){for(k=0;k=0;k--){for(T=0;Tq?d.set(v,q,g.get(v,q)):v===q?d.set(v,q,1):d.set(v,q,0);return d}get upperTriangularMatrix(){let g=this.LU,h=g.rows,u=g.columns,d=new P(h,u);for(let v=0;vMath.abs(g)?(h=g/M,Math.abs(M)*Math.sqrt(1+h*h)):g!==0?(h=M/g,Math.abs(g)*Math.sqrt(1+h*h)):0}class Ye{constructor(g){g=ze.checkMatrix(g);let h=g.clone(),u=g.rows,d=g.columns,v=new Float64Array(d),q,O,T,k;for(T=0;T=0;k--){for(T=0;T=0;O--){for(v=0;v=0;F--)if(U[F]!==0){for(let Q=F+1;Q=0;F--){if(F0;){let F,Q;for(F=de-2;F>=-1&&F!==-1;F--){const oe=Number.MIN_VALUE+Re*Math.abs(U[F]+Math.abs(U[F+1]));if(Math.abs(L[F])<=oe||Number.isNaN(L[F])){L[F]=0;break}}if(F===de-2)Q=4;else{let oe;for(oe=de-1;oe>=F&&oe!==F;oe--){let H=(oe!==de?Math.abs(L[oe]):0)+(oe!==F+1?Math.abs(L[oe-1]):0);if(Math.abs(U[oe])<=Re*H){U[oe]=0;break}}oe===F?Q=3:oe===de-1?Q=1:(Q=2,F=oe)}switch(F++,Q){case 1:{let oe=L[de-2];L[de-2]=0;for(let H=de-2;H>=F;H--){let je=We(U[H],oe),Se=U[H]/je,Ae=oe/je;if(U[H]=je,H!==F&&(oe=-Ae*L[H-1],L[H-1]=Se*L[H-1]),k)for(let Ce=0;Ce=U[F+1]);){let oe=U[F];if(U[F]=U[F+1],U[F+1]=oe,k&&Fh&&v.set(B,C,g.get(B,C)/this.s[C]);let q=this.U,O=q.rows,T=q.columns,k=new P(u,O);for(let B=0;Bg&&h++;return h}get diagonal(){return Array.from(this.s)}get threshold(){return Number.EPSILON/2*Math.max(this.m,this.n)*this.s[0]}get leftSingularVectors(){return this.U}get rightSingularVectors(){return this.V}get diagonalMatrix(){return P.diag(this.s)}}function rr(M,g=!1){return M=ze.checkMatrix(M),g?new ht(M).inverse():rn(M,P.eye(M.rows))}function rn(M,g,h=!1){return M=ze.checkMatrix(M),g=ze.checkMatrix(g),h?new ht(M).solve(g):M.isSquare()?new qt(M).solve(g):new Ye(M).solve(g)}function $t(M){if(M=P.checkMatrix(M),M.isSquare()){if(M.columns===0)return 1;let g,h,u,d;if(M.columns===2)return g=M.get(0,0),h=M.get(0,1),u=M.get(1,0),d=M.get(1,1),g*d-h*u;if(M.columns===3){let v,q,O;return v=new Ee(M,[1,2],[1,2]),q=new Ee(M,[1,2],[0,2]),O=new Ee(M,[1,2],[0,1]),g=M.get(0,0),h=M.get(0,1),u=M.get(0,2),g*$t(v)-h*$t(q)+u*$t(O)}else return new qt(M).determinant}else throw Error("determinant can only be calculated for a square matrix")}function kt(M,g){let h=[];for(let u=0;ud)return new Array(g.rows+1).fill(0);{let v=g.addRow(h,[0]);for(let q=0;qg?v[q]=1/v[q]:v[q]=0;return d.mmul(P.diag(v).mmul(u.transpose()))}function on(M,g=M,h={}){M=new P(M);let u=!1;if(typeof g=="object"&&!P.isMatrix(g)&&!e.isAnyArray(g)?(h=g,g=M,u=!0):g=new P(g),M.rows!==g.rows)throw new TypeError("Both matrices must have the same number of rows");const{center:d=!0}=h;d&&(M=M.center("column"),u||(g=g.center("column")));const v=M.transpose().mmul(g);for(let q=0;q0?d.set(v,v+1,h[v]):h[v]<0&&d.set(v,v-1,h[v])}return d}}function Fx(M,g,h,u){let d,v,q,O,T,k,B,C;for(T=0;T0;O--){for(C=0,q=0,k=0;k0&&(v=-v),g[O]=C*v,q=q-d*v,h[O-1]=d-v,T=0;Tk)do{for(d=h[k],C=(h[k+1]-d)/(2*g[k]),W=We(C,1),C<0&&(W=-W),h[k]=g[k]/(C+W),h[k+1]=g[k]*(C+W),ne=h[k+1],v=d-h[k],q=k+2;q=k;q--)for(se=K,K=U,ce=re,d=U*g[q],v=U*C,W=We(C,g[q]),g[q+1]=re*W,re=g[q]/W,U=C/W,C=U*h[q]-re*d,h[q+1]=v+re*(U*d+re*h[q]),T=0;Tke*ye);h[k]=h[k]+ve,g[k]=0}for(q=0;q=C;k--)h[k]=g.get(k,C-1)/W,T+=h[k]*h[k];for(O=Math.sqrt(T),h[C]>0&&(O=-O),T=T-h[C]*O,h[C]=h[C]-O,B=C;B=C;k--)q+=h[k]*g.get(k,B);for(q=q/T,k=C;k<=v;k++)g.set(k,B,g.get(k,B)-q*h[k])}for(k=0;k<=v;k++){for(q=0,B=v;B>=C;B--)q+=h[B]*g.get(k,B);for(q=q/T,B=C;B<=v;B++)g.set(k,B,g.get(k,B)-q*h[B])}h[C]=W*h[C],g.set(C,C-1,W*O)}}for(k=0;k=d+1;C--)if(g.get(C,C-1)!==0){for(k=C+1;k<=v;k++)h[k]=g.get(k,C-1);for(B=C;B<=v;B++){for(O=0,k=C;k<=v;k++)O+=h[k]*u.get(k,B);for(O=O/h[C]/g.get(C,C-1),k=C;k<=v;k++)u.set(k,B,u.get(k,B)+O*h[k])}}}function Gx(M,g,h,u,d){let v=M-1,q=0,O=M-1,T=Number.EPSILON,k=0,B=0,C=0,W=0,ne=0,U=0,K=0,se=0,L,re,ce,ve,ye,ke,de,ge,Re,F,Q,oe,H,je,Se;for(L=0;LO)&&(h[L]=d.get(L,L),g[L]=0),re=Math.max(L-1,0);re=q;){for(ve=v;ve>q&&(U=Math.abs(d.get(ve-1,ve-1))+Math.abs(d.get(ve,ve)),U===0&&(U=B),!(Math.abs(d.get(ve,ve-1))=0){for(K=C>=0?C+K:C-K,h[v-1]=ge+K,h[v]=h[v-1],K!==0&&(h[v]=ge-de/K),g[v-1]=0,g[v]=0,ge=d.get(v,v-1),U=Math.abs(ge)+Math.abs(K),C=ge/U,W=K/U,ne=Math.sqrt(C*C+W*W),C=C/ne,W=W/ne,re=v-1;re0)){for(U=Math.sqrt(U),Re=ve&&(K=d.get(ye,ye),ne=ge-K,U=Re-K,C=(ne*U-de)/d.get(ye+1,ye)+d.get(ye,ye+1),W=d.get(ye+1,ye+1)-K-ne-U,ne=d.get(ye+2,ye+1),U=Math.abs(C)+Math.abs(W)+Math.abs(ne),C=C/U,W=W/U,ne=ne/U,!(ye===ve||Math.abs(d.get(ye,ye-1))*(Math.abs(W)+Math.abs(ne))ye+2&&d.set(L,L-3,0);for(ce=ye;ce<=v-1&&(je=ce!==v-1,ce!==ye&&(C=d.get(ce,ce-1),W=d.get(ce+1,ce-1),ne=je?d.get(ce+2,ce-1):0,ge=Math.abs(C)+Math.abs(W)+Math.abs(ne),ge!==0&&(C=C/ge,W=W/ge,ne=ne/ge)),ge!==0);ce++)if(U=Math.sqrt(C*C+W*W+ne*ne),C<0&&(U=-U),U!==0){for(ce!==ye?d.set(ce,ce-1,-U*ge):ve!==ye&&d.set(ce,ce-1,-d.get(ce,ce-1)),C=C+U,ge=C/U,Re=W/U,K=ne/U,W=W/C,ne=ne/C,re=ce;re=0;v--)if(C=h[v],W=g[v],W===0)for(ve=v,d.set(v,v,1),L=v-1;L>=0;L--){for(de=d.get(L,L)-C,ne=0,re=ve;re<=v;re++)ne=ne+d.get(L,re)*d.get(re,v);if(g[L]<0)K=de,U=ne;else if(ve=L,g[L]===0?d.set(L,v,de!==0?-ne/de:-ne/(T*B)):(ge=d.get(L,L+1),Re=d.get(L+1,L),W=(h[L]-C)*(h[L]-C)+g[L]*g[L],ke=(ge*U-K*ne)/W,d.set(L,v,ke),d.set(L+1,v,Math.abs(ge)>Math.abs(K)?(-ne-de*ke)/ge:(-U-Re*ke)/K)),ke=Math.abs(d.get(L,v)),T*ke*ke>1)for(re=L;re<=v;re++)d.set(re,v,d.get(re,v)/ke)}else if(W<0)for(ve=v-1,Math.abs(d.get(v,v-1))>Math.abs(d.get(v-1,v))?(d.set(v-1,v-1,W/d.get(v,v-1)),d.set(v-1,v,-(d.get(v,v)-C)/d.get(v,v-1))):(Se=an(0,-d.get(v-1,v),d.get(v-1,v-1)-C,W),d.set(v-1,v-1,Se[0]),d.set(v-1,v,Se[1])),d.set(v,v-1,0),d.set(v,v,1),L=v-2;L>=0;L--){for(F=0,Q=0,re=ve;re<=v;re++)F=F+d.get(L,re)*d.get(re,v-1),Q=Q+d.get(L,re)*d.get(re,v);if(de=d.get(L,L)-C,g[L]<0)K=de,ne=F,U=Q;else if(ve=L,g[L]===0?(Se=an(-F,-Q,de,W),d.set(L,v-1,Se[0]),d.set(L,v,Se[1])):(ge=d.get(L,L+1),Re=d.get(L+1,L),oe=(h[L]-C)*(h[L]-C)+g[L]*g[L]-W*W,H=(h[L]-C)*2*W,oe===0&&H===0&&(oe=T*B*(Math.abs(de)+Math.abs(W)+Math.abs(ge)+Math.abs(Re)+Math.abs(K))),Se=an(ge*ne-K*F+W*Q,ge*U-K*Q-W*F,oe,H),d.set(L,v-1,Se[0]),d.set(L,v,Se[1]),Math.abs(ge)>Math.abs(K)+Math.abs(W)?(d.set(L+1,v-1,(-F-de*d.get(L,v-1)+W*d.get(L,v))/ge),d.set(L+1,v,(-Q-de*d.get(L,v)-W*d.get(L,v-1))/ge)):(Se=an(-ne-Re*d.get(L,v-1),-U-Re*d.get(L,v),K,W),d.set(L+1,v-1,Se[0]),d.set(L+1,v,Se[1]))),ke=Math.max(Math.abs(d.get(L,v-1)),Math.abs(d.get(L,v))),T*ke*ke>1)for(re=L;re<=v;re++)d.set(re,v-1,d.get(re,v-1)/ke),d.set(re,v,d.get(re,v)/ke)}for(L=0;LO)for(re=L;re=q;re--)for(L=q;L<=O;L++){for(K=0,ce=q;ce<=Math.min(re,O);ce++)K=K+u.get(L,ce)*d.get(ce,re);u.set(L,re,K)}}}function an(M,g,h,u){let d,v;return Math.abs(h)>Math.abs(u)?(d=u/h,v=h+d*u,[(M+d*g)/v,(g-d*M)/v]):(d=h/u,v=u+d*h,[(d*M+g)/v,(d*g-M)/v])}class _0{constructor(g){if(g=ze.checkMatrix(g),!g.isSymmetric())throw new Error("Matrix is not symmetric");let h=g,u=h.rows,d=new P(u,u),v=!0,q,O,T;for(O=0;O0),d.set(O,O,Math.sqrt(Math.max(k,0))),T=O+1;T=0;T--)for(O=0;Oq;ne++)C=g.transpose().mmul(O).div(O.transpose().mmul(O).get(0,0)),C=C.div(C.norm()),k=g.mmul(C).div(C.transpose().mmul(C).get(0,0)),ne>0&&(T=k.clone().sub(W).pow(2).sum()),W=k.clone(),u?(B=u.transpose().mmul(k).div(k.transpose().mmul(k).get(0,0)),B=B.div(B.norm()),O=u.mmul(B).div(B.transpose().mmul(B).get(0,0))):O=k;if(u){let ne=g.transpose().mmul(k).div(k.transpose().mmul(k).get(0,0));ne=ne.div(ne.norm());let U=g.clone().sub(k.clone().mmul(ne.transpose())),K=O.transpose().mmul(k).div(k.transpose().mmul(k).get(0,0)),se=u.clone().sub(k.clone().mulS(K.get(0,0)).mmul(B.transpose()));this.t=k,this.p=ne.transpose(),this.w=C.transpose(),this.q=B,this.u=O,this.s=k.transpose().mmul(k),this.xResidual=U,this.yResidual=se,this.betas=K}else this.w=C.transpose(),this.s=k.transpose().mmul(k).sqrt(),d?this.t=k.clone().div(this.s.get(0,0)):this.t=k,this.xResidual=g.sub(k.mmul(C.transpose()))}}return we.AbstractMatrix=ie,we.CHO=_0,we.CholeskyDecomposition=_0,we.DistanceMatrix=te,we.EVD=mt,we.EigenvalueDecomposition=mt,we.LU=qt,we.LuDecomposition=qt,we.Matrix=P,we.MatrixColumnSelectionView=Le,we.MatrixColumnView=xe,we.MatrixFlipColumnView=Je,we.MatrixFlipRowView=tr,we.MatrixRowSelectionView=Ve,we.MatrixRowView=Qe,we.MatrixSelectionView=Ee,we.MatrixSubView=Mt,we.MatrixTransposeView=Me,we.NIPALS=E0,we.Nipals=E0,we.QR=Ye,we.QrDecomposition=Ye,we.SVD=ht,we.SingularValueDecomposition=ht,we.SymmetricMatrix=X,we.WrapperMatrix1D=St,we.WrapperMatrix2D=ze,we.correlation=vt,we.covariance=on,we.default=P,we.determinant=$t,we.inverse=rr,we.linearDependencies=sn,we.pseudoInverse=Sc,we.solve=rn,we.wrap=Mc,we}var Ar=Gw(),Tf=Of(Ar);const At=Ar.Matrix,kf=Ar.SingularValueDecomposition;Tf.Matrix?Tf.Matrix:Ar.Matrix;const Uw={center:[0,0],linkDistance:50};class jf{constructor(r={}){this.options=r,this.id="mds",this.options=Object.assign(Object.assign({},Uw),r)}execute(r,t){return fe(this,void 0,void 0,function*(){return this.genericMDSLayout(!1,r,t)})}assign(r,t){return fe(this,void 0,void 0,function*(){yield this.genericMDSLayout(!0,r,t)})}genericMDSLayout(r,t,n){return fe(this,void 0,void 0,function*(){const i=Object.assign(Object.assign({},this.options),n),{center:s=[0,0],linkDistance:a=50}=i,o=t.getAllNodes(),c=t.getAllEdges();if(!(o!=null&&o.length)||o.length===1)return Pt(t,r,s);const f=wf({nodes:o,edges:c}),l=yf(f);Vw(l);const p=Cy(l,a),m=Ww(p),y=[];return m.forEach((_,b)=>{const w=it(o[b]);w.data.x=_[0]+s[0],w.data.y=_[1]+s[1],y.push(w)}),r&&y.forEach(_=>t.mergeNodeData(_.id,{x:_.data.x,y:_.data.y})),{nodes:y,edges:c}})}}const Vw=e=>{let r=-999999;e.forEach(t=>{t.forEach(n=>{n!==1/0&&r{t.forEach((i,s)=>{i===1/0&&(e[n][s]=r)})})},Ww=e=>{const t=At.mul(At.pow(e,2),-.5),n=t.mean("row"),i=t.mean("column"),s=t.mean();t.add(s).subRowVector(n).subColumnVector(i);const a=new kf(t),o=At.sqrt(a.diagonalMatrix).diagonal();return a.leftSingularVectors.toJSON().map(c=>At.mul([c],[o]).toJSON()[0].splice(0,2))};function Cf(e){return!!e.tick&&!!e.stop}const Yw={gForce:!0,force2:!0,d3force:!0,fruchterman:!0,forceAtlas2:!0,force:!0,"graphin-force":!0},Kw={center:[0,0],comboPadding:10,treeKey:"combo"};class Xw{constructor(r={}){this.options=r,this.id="comboCombined",this.options=Object.assign(Object.assign({},Kw),r)}execute(r,t){return fe(this,void 0,void 0,function*(){return this.genericComboCombinedLayout(!1,r,t)})}assign(r,t){return fe(this,void 0,void 0,function*(){yield this.genericComboCombinedLayout(!0,r,t)})}genericComboCombinedLayout(r,t,n){return fe(this,void 0,void 0,function*(){const i=this.initVals(Object.assign(Object.assign({},this.options),n)),{center:s,treeKey:a,outerLayout:o}=i,c=t.getAllNodes().filter(I=>!I.data._isCombo),f=t.getAllNodes().filter(I=>I.data._isCombo),l=t.getAllEdges(),p=c==null?void 0:c.length;if(!p||p===1)return Pt(t,r,s);const m=[],y=new Map;c.forEach(I=>{y.set(I.id,I)});const x=new Map;f.forEach(I=>{x.set(I.id,I)});const _=new Map,b=this.getInnerGraphs(t,a,y,x,l,i,_);yield Promise.all(b);const w=new Map,E=[],N=new Map;let S=!0;t.getRoots(a).forEach(I=>{const D=_.get(I.id),z=x.get(I.id)||y.get(I.id),$={id:I.id,data:Object.assign(Object.assign({},I.data),{x:D.data.x||z.data.x,y:D.data.y||z.data.y,fx:D.data.fx||z.data.fx,fy:D.data.fy||z.data.fy,mass:D.data.mass||z.data.mass,size:D.data.size})};E.push($),w.set(I.id,!0),!isNaN($.data.x)&&$.data.x!==0&&!isNaN($.data.y)&&$.data.y!==0?S=!1:($.data.x=Math.random()*100,$.data.y=Math.random()*100),Nn(t,[I],V=>{V.id!==I.id&&N.set(V.id,I.id)},"TB",a)});const R=[];l.forEach(I=>{const D=N.get(I.source)||I.source,z=N.get(I.target)||I.target;D!==z&&w.has(D)&&w.has(z)&&R.push({id:I.id,source:D,target:z,data:{}})});let A;if(E!=null&&E.length){if(E.length===1)E[0].data.x=s[0],E[0].data.y=s[1];else{const I=new Be({nodes:E,edges:R}),D=o||new Sf;S&&Yw[D.id]&&(yield(E.length<100?new jf:new Rn).assign(I));const z=Object.assign({center:s,kg:5,preventOverlap:!0,animate:!1},D.id==="force"?{gravity:1,factor:4,linkDistance:($,V,Y)=>{const ee=Math.max(...V.data.size)||32,J=Math.max(...Y.data.size)||32;return ee/2+J/2+200}}:{});A=yield Pf(D,I,z)}_.forEach(I=>{var D;const z=A.nodes.find(Y=>Y.id===I.id);if(z){const{x:Y,y:ee}=z.data;I.data.visited=!0,I.data.x=Y,I.data.y=ee,m.push({id:I.id,data:{x:Y,y:ee}})}const{x:$,y:V}=I.data;(D=I.data.nodes)===null||D===void 0||D.forEach(Y=>{m.push({id:Y.id,data:{x:Y.data.x+$,y:Y.data.y+V}})})}),_.forEach(({data:I})=>{const{x:D,y:z,visited:$,nodes:V}=I;V==null||V.forEach(Y=>{if(!$){const ee=m.find(J=>J.id===Y.id);ee.data.x+=D||0,ee.data.y+=z||0}})})}return r&&m.forEach(I=>{t.mergeNodeData(I.id,{x:I.data.x,y:I.data.y})}),{nodes:m,edges:l}})}initVals(r){const t=Object.assign({},r),{nodeSize:n,spacing:i,comboPadding:s}=r;let a,o;if(me(i)?o=()=>i:wt(i)?o=i:o=()=>0,t.spacing=o,!n)a=f=>{const l=o(f);return f.size?bt(f.size)?((f.size[0]>f.size[1]?f.size[0]:f.size[1])+l)/2:Ut(f.size)?((f.size.width>f.size.height?f.size.width:f.size.height)+l)/2:(f.size+l)/2:32+l/2};else if(wt(n))a=f=>{const l=n(f),p=o(f);return bt(f.size)?((f.size[0]>f.size[1]?f.size[0]:f.size[1])+p)/2:((l||32)+p)/2};else if(bt(n)){const l=(n[0]>n[1]?n[0]:n[1])/2;a=p=>l+o(p)/2}else{const f=n/2;a=l=>f+o(l)/2}t.nodeSize=a;let c;return me(s)?c=()=>s:bt(s)?c=()=>Math.max.apply(null,s):wt(s)?c=s:c=()=>0,t.comboPadding=c,t}getInnerGraphs(r,t,n,i,s,a,o){const{nodeSize:c,comboPadding:f,spacing:l,innerLayout:p}=a,m=p||new Rn({}),y={center:[0,0],preventOverlap:!0,nodeSpacing:l},x=[],_=b=>{let w=(f==null?void 0:f(b))||10;return bt(w)&&(w=Math.max(...w)),{size:w?[w*2,w*2]:[30,30],padding:w}};return r.getRoots(t).forEach(b=>{o.set(b.id,{id:b.id,data:{nodes:[],size:_(b).size}});let w=Promise.resolve();Nn(r,[b],E=>{var N;if(!E.data._isCombo)return;const{size:S,padding:R}=_(E);if(!(!((N=r.getChildren(E.id,t))===null||N===void 0)&&N.length))o.set(E.id,{id:E.id,data:Object.assign(Object.assign({},E.data),{size:S})});else{const A=o.get(E.id);o.set(E.id,{id:E.id,data:Object.assign({nodes:[]},A==null?void 0:A.data)});const j=new Map,I=r.getChildren(E.id,t).map($=>{if($.data._isCombo)return o.has($.id)||o.set($.id,{id:$.id,data:Object.assign({},$.data)}),j.set($.id,!0),o.get($.id);const V=n.get($.id)||i.get($.id);return j.set($.id,!0),{id:$.id,data:Object.assign(Object.assign({},V.data),$.data)}}),D={nodes:I,edges:s.filter($=>j.has($.source)&&j.has($.target))};let z=1/0;I.forEach($=>{var V;let{size:Y}=$.data;Y||(Y=((V=o.get($.id))===null||V===void 0?void 0:V.data.size)||(c==null?void 0:c($))||[30,30]),me(Y)&&(Y=[Y,Y]);const[ee,J]=Y;z>ee&&(z=ee),z>J&&(z=J),$.data.size=Y}),w=w.then(()=>fe(this,void 0,void 0,function*(){const $=new Be(D);yield Pf(m,$,y,!0);const{minX:V,minY:Y,maxX:ee,maxY:J}=Py(I),ae={x:(ee+V)/2,y:(J+Y)/2};D.nodes.forEach(Z=>{Z.data.x-=ae.x,Z.data.y-=ae.y});const be=[Math.max(ee-V,z)+R*2,Math.max(J-Y,z)+R*2];o.get(E.id).data.size=be,o.get(E.id).data.nodes=I}))}return!0},"BT",t),x.push(w)}),x}}function Pf(e,r,t,n){var i;return fe(this,void 0,void 0,function*(){return Cf(e)?(e.execute(r,t),e.stop(),e.tick((i=t.iterations)!==null&&i!==void 0?i:300)):n?yield e.assign(r,t):yield e.execute(r,t)})}function Zw(e,r){var t,n=1;e==null&&(e=0),r==null&&(r=0);function i(){var s,a=t.length,o,c=0,f=0;for(s=0;sm.index){var $=y-I.x-I.vx,V=x-I.y-I.vy,Y=$*$+V*V;Yy+z||Ax+z||jf.r&&(f.r=f[l].r)}function c(){if(r){var f,l=r.length,p;for(t=new Array(l),f=0;f[r(R,A,a),R])),S;for(b=0,o=new Array(w);b{}};function kn(){for(var e=0,r=arguments.length,t={},n;e=0&&(n=t.slice(i+1),t=t.slice(0,i)),t&&!r.hasOwnProperty(t))throw new Error("unknown type: "+t);return{type:t,name:n}})}Ir.prototype=kn.prototype={constructor:Ir,on:function(e,r){var t=this._,n=n1(e+"",t),i,s=-1,a=n.length;if(arguments.length<2){for(;++s0)for(var t=new Array(i),n=0,i,s;n=0&&e._call.call(void 0,r),e=e._next;--Yt}function $f(){Lt=(kr=fr.now())+jr,Yt=ar=0;try{o1()}finally{Yt=0,u1(),Lt=0}}function a1(){var e=fr.now(),r=e-kr;r>zf&&(jr-=r,kr=e)}function u1(){for(var e,r=Tr,t,n=1/0;r;)r._call?(n>r._time&&(n=r._time),e=r,r=r._next):(t=r._next,r._next=null,r=e?e._next=t:Tr=t);cr=e,Pn(n)}function Pn(e){if(!Yt){ar&&(ar=clearTimeout(ar));var r=e-Lt;r>24?(e<1/0&&(ar=setTimeout($f,e-fr.now()-jr)),ur&&(ur=clearInterval(ur))):(ur||(kr=fr.now(),ur=setInterval(a1,zf)),Yt=1,Ff($f))}}const c1=1664525,f1=1013904223,Gf=4294967296;function l1(){let e=1;return()=>(e=(c1*e+f1)%Gf)/Gf}function h1(e){return e.x}function d1(e){return e.y}var g1=10,p1=Math.PI*(3-Math.sqrt(5));function v1(e){var r,t=1,n=.001,i=1-Math.pow(n,1/300),s=0,a=.6,o=new Map,c=Cn(p),f=kn("tick","end"),l=l1();e==null&&(e=[]);function p(){m(),f.call("tick",r),t1?(b==null?o.delete(_):o.set(_,x(b)),r):o.get(_)},find:function(_,b,w){var E=0,N=e.length,S,R,A,j,I;for(w==null?w=1/0:w*=w,E=0;E1?(f.on(_,b),r):f.on(_)}}}function m1(){var e,r,t,n,i=$e(-30),s,a=1,o=1/0,c=.81;function f(y){var x,_=e.length,b=Wt(e,h1,d1).visitAfter(p);for(n=y,x=0;x<_;++x)r=e[x],b.visit(m)}function l(){if(e){var y,x=e.length,_;for(s=new Array(x),y=0;y=o)return;(y.data!==r||y.next)&&(w===0&&(w=It(t),S+=w*w),E===0&&(E=It(t),S+=E*E),St.id},manyBody:{},center:{x:0,y:0}},this.context={options:{},assign:!1,nodes:[],edges:[]},Fc(this.options,r),this.options.forceSimulation&&(this.simulation=this.options.forceSimulation)}execute(r,t){return fe(this,void 0,void 0,function*(){return this.genericLayout(!1,r,t)})}assign(r,t){return fe(this,void 0,void 0,function*(){yield this.genericLayout(!0,r,t)})}stop(){this.simulation.stop()}tick(r){return this.simulation.tick(r),this.getResult()}restart(){this.simulation.restart()}setFixedPosition(r,t){const n=this.context.nodes.find(i=>i.id===r);n&&t.forEach((i,s)=>{if(typeof i=="number"||i===null){const a=["fx","fy","fz"][s];n[a]=i}})}getOptions(r){var t,n;const i=Fc({},this.options,r);return i.collide&&((t=i.collide)===null||t===void 0?void 0:t.radius)===void 0&&(i.collide=i.collide||{},i.collide.radius=(n=i.nodeSize)!==null&&n!==void 0?n:10),i.iterations===void 0&&(i.link&&i.link.iterations===void 0&&(i.iterations=i.link.iterations),i.collide&&i.collide.iterations===void 0&&(i.iterations=i.collide.iterations)),this.context.options=i,i}genericLayout(r,t,n){var i;return fe(this,void 0,void 0,function*(){const s=this.getOptions(n),a=t.getAllNodes().map(({id:l,data:p})=>Object.assign(Object.assign({id:l},p),Bc(p.data,this.config.inputNodeAttrs))),o=t.getAllEdges().map(l=>Object.assign({},l));Object.assign(this.context,{assign:r,nodes:a,edges:o,graph:t});const c=new Promise(l=>{this.resolver=l}),f=this.setSimulation(s);return f.nodes(a),(i=f.force("link"))===null||i===void 0||i.links(o),c})}getResult(){const{assign:r,nodes:t,edges:n,graph:i}=this.context,s=t.map(o=>({id:o.id,data:Object.assign(Object.assign({},o.data),Bc(o,this.config.outputNodeAttrs))})),a=n.map(({id:o,source:c,target:f,data:l})=>({id:o,source:typeof c=="object"?c.id:c,target:typeof f=="object"?f.id:f,data:l}));return r&&s.forEach(o=>i.mergeNodeData(o.id,o.data)),{nodes:s,edges:a}}initSimulation(){return v1()}setSimulation(r){const t=this.simulation||this.options.forceSimulation||this.initSimulation();return this.simulation||(this.simulation=t.on("tick",()=>{var n;return(n=r.onTick)===null||n===void 0?void 0:n.call(r,this.getResult())}).on("end",()=>{var n;return(n=this.resolver)===null||n===void 0?void 0:n.call(this,this.getResult())})),Vf(t,this.config.simulationAttrs.map(n=>[n,r[n]])),Object.entries(this.forceMap).forEach(([n,i])=>{const s=n;if(r[n]){let a=t.force(s);a||(a=i(),t.force(s,a)),Vf(a,Object.entries(r[s]))}else t.force(s,null)}),t}}const Vf=(e,r)=>r.reduce((t,[n,i])=>!t[n]||i===void 0?t:t[n].call(e,i),e);function _1(e,r,t){var n,i=1;e==null&&(e=0),r==null&&(r=0),t==null&&(t=0);function s(){var a,o=n.length,c,f=0,l=0,p=0;for(a=0;a=(c=(a+o)/2))?a=c:o=c,n=i,!(i=i[p=+l]))return n[p]=s,e;if(f=+e._x.call(null,i.data),r===f)return s.next=i,n?n[p]=s:e._root=s,e;do n=n?n[p]=new Array(2):e._root=new Array(2),(l=r>=(c=(a+o)/2))?a=c:o=c;while((p=+l)==(m=+(f>=c)));return n[m]=i,n[p]=s,e}function x1(e){Array.isArray(e)||(e=Array.from(e));const r=e.length,t=new Float64Array(r);let n=1/0,i=-1/0;for(let s=0,a;si&&(i=a));if(n>i)return this;this.cover(n).cover(i);for(let s=0;se||e>=t;)switch(a=+(ea||(s=f.x1)=p))&&(f=o[o.length-1],o[o.length-1]=o[o.length-1-l],o[o.length-1-l]=f)}else{var m=Math.abs(e-+this._x.call(null,c.data));m=(f=(a+o)/2))?a=f:o=f,r=t,!(t=t[p=+l]))return this;if(!t.length)break;r[p+1&1]&&(n=r,m=p)}for(;t.data!==e;)if(i=t,!(t=t.next))return this;return(s=t.next)&&delete t.next,i?(s?i.next=s:delete i.next,this):r?(s?r[p]=s:delete r[p],(t=r[0]||r[1])&&t===(r[1]||r[0])&&!t.length&&(n?n[m]=t:this._root=t),this):(this._root=s,this)}function O1(e){for(var r=0,t=e.length;r1&&(_=y.y+y.vy),t>2&&(b=y.z+y.vz),m.visit(S);function S(R,A,j,I,D,z,$){var V=[A,j,I,D,z,$],Y=V[0],ee=V[1],J=V[2],ae=V[t],be=V[t+1],Z=V[t+2],ue=R.data,pe=R.r,he=w+pe;if(ue){if(ue.index>y.index){var ie=x-ue.x-ue.vx,_e=t>1?_-ue.y-ue.vy:0,G=t>2?b-ue.z-ue.vz:0,P=ie*ie+_e*_e+G*G;P1&&_e===0&&(_e=at(i),P+=_e*_e),t>2&&G===0&&(G=at(i),P+=G*G),P=(he-(P=Math.sqrt(P)))/P*s,y.vx+=(ie*=P)*(he=(pe*=pe)/(E+pe)),t>1&&(y.vy+=(_e*=P)*he),t>2&&(y.vz+=(G*=P)*he),ue.vx-=ie*(he=1-he),t>1&&(ue.vy-=_e*he),t>2&&(ue.vz-=G*he))}return}return Y>x+he||ae1&&(ee>_+he||be<_-he)||t>2&&(J>b+he||Zl.r&&(l.r=l[p].r)}function f(){if(r){var l,p=r.length,m;for(n=new Array(p),l=0;ltypeof m=="function")||Math.random,t=p.find(m=>[1,2,3].includes(m))||2,f()},o.iterations=function(l){return arguments.length?(a=+l,o):a},o.strength=function(l){return arguments.length?(s=+l,o):s},o.radius=function(l){return arguments.length?(e=typeof l=="function"?l:Pe(+l),f(),o):e},o}function D1(e){return e.index}function Xf(e,r){var t=e.get(r);if(!t)throw new Error("node not found: "+r);return t}function z1(e){var r=D1,t=m,n,i=Pe(30),s,a,o,c,f,l,p=1;e==null&&(e=[]);function m(w){return 1/Math.min(c[w.source.index],c[w.target.index])}function y(w){for(var E=0,N=e.length;E1&&(D=j.y+j.vy-A.y-A.vy||at(l)),o>2&&(z=j.z+j.vz-A.z-A.vz||at(l)),$=Math.sqrt(I*I+D*D+z*z),$=($-s[S])/$*w*n[S],I*=$,D*=$,z*=$,j.vx-=I*(V=f[S]),o>1&&(j.vy-=D*V),o>2&&(j.vz-=z*V),A.vx+=I*(V=1-V),o>1&&(A.vy+=D*V),o>2&&(A.vz+=z*V)}function x(){if(a){var w,E=a.length,N=e.length,S=new Map(a.map((A,j)=>[r(A,j,a),A])),R;for(w=0,c=new Array(E);wtypeof N=="function")||Math.random,o=E.find(N=>[1,2,3].includes(N))||2,x()},y.links=function(w){return arguments.length?(e=w,x(),y):e},y.id=function(w){return arguments.length?(r=w,y):r},y.iterations=function(w){return arguments.length?(p=+w,y):p},y.strength=function(w){return arguments.length?(t=typeof w=="function"?w:Pe(+w),_(),y):t},y.distance=function(w){return arguments.length?(i=typeof w=="function"?w:Pe(+w),b(),y):i},y}const F1=1664525,B1=1013904223,Zf=4294967296;function $1(){let e=1;return()=>(e=(F1*e+B1)%Zf)/Zf}var Jf=3;function Fn(e){return e.x}function Qf(e){return e.y}function G1(e){return e.z}var U1=10,V1=Math.PI*(3-Math.sqrt(5)),W1=Math.PI*20/(9+Math.sqrt(221));function Y1(e,r){r=r||2;var t=Math.min(Jf,Math.max(1,Math.round(r))),n,i=1,s=.001,a=1-Math.pow(s,1/300),o=0,c=.6,f=new Map,l=Cn(y),p=kn("tick","end"),m=$1();e==null&&(e=[]);function y(){x(),p.call("tick",n),i1&&(S.fy==null?S.y+=S.vy*=c:(S.y=S.fy,S.vy=0)),t>2&&(S.fz==null?S.z+=S.vz*=c:(S.z=S.fz,S.vz=0));return n}function _(){for(var w=0,E=e.length,N;w1&&isNaN(N.y)||t>2&&isNaN(N.z)){var S=U1*(t>2?Math.cbrt(.5+w):t>1?Math.sqrt(.5+w):w),R=w*V1,A=w*W1;t===1?N.x=S:t===2?(N.x=S*Math.cos(R),N.y=S*Math.sin(R)):(N.x=S*Math.sin(R)*Math.cos(A),N.y=S*Math.cos(R),N.z=S*Math.sin(R)*Math.sin(A))}(isNaN(N.vx)||t>1&&isNaN(N.vy)||t>2&&isNaN(N.vz))&&(N.vx=0,t>1&&(N.vy=0),t>2&&(N.vz=0))}}function b(w){return w.initialize&&w.initialize(e,m,t),w}return _(),n={tick:x,restart:function(){return l.restart(y),n},stop:function(){return l.stop(),n},numDimensions:function(w){return arguments.length?(t=Math.min(Jf,Math.max(1,Math.round(w))),f.forEach(b),n):t},nodes:function(w){return arguments.length?(e=w,_(),f.forEach(b),n):e},alpha:function(w){return arguments.length?(i=+w,n):i},alphaMin:function(w){return arguments.length?(s=+w,n):s},alphaDecay:function(w){return arguments.length?(a=+w,n):+a},alphaTarget:function(w){return arguments.length?(o=+w,n):o},velocityDecay:function(w){return arguments.length?(c=1-w,n):1-c},randomSource:function(w){return arguments.length?(m=w,f.forEach(b),n):m},force:function(w,E){return arguments.length>1?(E==null?f.delete(w):f.set(w,b(E)),n):f.get(w)},find:function(){var w=Array.prototype.slice.call(arguments),E=w.shift()||0,N=(t>1?w.shift():null)||0,S=(t>2?w.shift():null)||0,R=w.shift()||1/0,A=0,j=e.length,I,D,z,$,V,Y;for(R*=R,A=0;A1?(p.on(w,E),n):p.on(w)}}}function K1(){var e,r,t,n,i,s=Pe(-30),a,o=1,c=1/0,f=.81;function l(x){var _,b=e.length,w=(r===1?Ln(e,Fn):r===2?Wt(e,Fn,Qf):r===3?Rr(e,Fn,Qf,G1):null).visitAfter(m);for(i=x,_=0;_1&&(x.y=S/E),r>2&&(x.z=R/E)}else{b=x,b.x=b.data.x,r>1&&(b.y=b.data.y),r>2&&(b.z=b.data.z);do _+=a[b.data.index];while(b=b.next)}x.value=_}function y(x,_,b,w,E){if(!x.value)return!0;var N=[b,w,E][r-1],S=x.x-t.x,R=r>1?x.y-t.y:0,A=r>2?x.z-t.z:0,j=N-_,I=S*S+R*R+A*A;if(j*j/f1&&R===0&&(R=at(n),I+=R*R),r>2&&A===0&&(A=at(n),I+=A*A),I1&&(t.vy+=R*x.value*i/I),r>2&&(t.vz+=A*x.value*i/I)),!0;if(x.length||I>=c)return;(x.data!==t||x.next)&&(S===0&&(S=at(n),I+=S*S),r>1&&R===0&&(R=at(n),I+=R*R),r>2&&A===0&&(A=at(n),I+=A*A),I1&&(t.vy+=R*j),r>2&&(t.vz+=A*j));while(x=x.next)}return l.initialize=function(x,..._){e=x,n=_.find(b=>typeof b=="function")||Math.random,r=_.find(b=>[1,2,3].includes(b))||2,p()},l.strength=function(x){return arguments.length?(s=typeof x=="function"?x:Pe(+x),p(),l):s},l.distanceMin=function(x){return arguments.length?(o=x*x,l):Math.sqrt(o)},l.distanceMax=function(x){return arguments.length?(c=x*x,l):Math.sqrt(c)},l.theta=function(x){return arguments.length?(f=x*x,l):Math.sqrt(f)},l}function X1(e,r,t,n){var i,s,a=Pe(.1),o,c;typeof e!="function"&&(e=Pe(+e)),r==null&&(r=0),t==null&&(t=0),n==null&&(n=0);function f(p){for(var m=0,y=i.length;m1&&(x.vy+=b*N),s>2&&(x.vz+=w*N)}}function l(){if(i){var p,m=i.length;for(o=new Array(m),c=new Array(m),p=0;p[1,2,3].includes(y))||2,l()},f.strength=function(p){return arguments.length?(a=typeof p=="function"?p:Pe(+p),l(),f):a},f.radius=function(p){return arguments.length?(e=typeof p=="function"?p:Pe(+p),l(),f):e},f.x=function(p){return arguments.length?(r=+p,f):r},f.y=function(p){return arguments.length?(t=+p,f):t},f.z=function(p){return arguments.length?(n=+p,f):n},f}function Z1(e){var r=Pe(.1),t,n,i;typeof e!="function"&&(e=Pe(e==null?0:+e));function s(o){for(var c=0,f=t.length,l;cr.id},manyBody:{},center:{x:0,y:0,z:0}}}initSimulation(){return Y1()}}function Bn(e){throw new Error('Could not dynamically require "'+e+'". Please configure the dynamicRequireTargets or/and ignoreDynamicRequires option of @rollup/plugin-commonjs appropriately for this require call to work.')}var $n,Hf;function eb(){if(Hf)return $n;Hf=1;function e(){this.__data__=[],this.size=0}return $n=e,$n}var Gn,el;function Kt(){if(el)return Gn;el=1;function e(r,t){return r===t||r!==r&&t!==t}return Gn=e,Gn}var Un,tl;function Cr(){if(tl)return Un;tl=1;var e=Kt();function r(t,n){for(var i=t.length;i--;)if(e(t[i][0],n))return i;return-1}return Un=r,Un}var Vn,rl;function tb(){if(rl)return Vn;rl=1;var e=Cr(),r=Array.prototype,t=r.splice;function n(i){var s=this.__data__,a=e(s,i);if(a<0)return!1;var o=s.length-1;return a==o?s.pop():t.call(s,a,1),--this.size,!0}return Vn=n,Vn}var Wn,nl;function rb(){if(nl)return Wn;nl=1;var e=Cr();function r(t){var n=this.__data__,i=e(n,t);return i<0?void 0:n[i][1]}return Wn=r,Wn}var Yn,il;function nb(){if(il)return Yn;il=1;var e=Cr();function r(t){return e(this.__data__,t)>-1}return Yn=r,Yn}var Kn,sl;function ib(){if(sl)return Kn;sl=1;var e=Cr();function r(t,n){var i=this.__data__,s=e(i,t);return s<0?(++this.size,i.push([t,n])):i[s][1]=n,this}return Kn=r,Kn}var Xn,ol;function Pr(){if(ol)return Xn;ol=1;var e=eb(),r=tb(),t=rb(),n=nb(),i=ib();function s(a){var o=-1,c=a==null?0:a.length;for(this.clear();++o-1&&n%1==0&&n-1&&t%1==0&&t<=e}return Yi=r,Yi}var Xi,oh;function Ib(){if(oh)return Xi;oh=1;var e=Dt(),r=Ki(),t=pt(),n="[object Arguments]",i="[object Array]",s="[object Boolean]",a="[object Date]",o="[object Error]",c="[object Function]",f="[object Map]",l="[object Number]",p="[object Object]",m="[object RegExp]",y="[object Set]",x="[object String]",_="[object WeakMap]",b="[object ArrayBuffer]",w="[object DataView]",E="[object Float32Array]",N="[object Float64Array]",S="[object Int8Array]",R="[object Int16Array]",A="[object Int32Array]",j="[object Uint8Array]",I="[object Uint8ClampedArray]",D="[object Uint16Array]",z="[object Uint32Array]",$={};$[E]=$[N]=$[S]=$[R]=$[A]=$[j]=$[I]=$[D]=$[z]=!0,$[n]=$[i]=$[b]=$[s]=$[w]=$[a]=$[o]=$[c]=$[f]=$[l]=$[p]=$[m]=$[y]=$[x]=$[_]=!1;function V(Y){return t(Y)&&r(Y.length)&&!!$[e(Y)]}return Xi=V,Xi}var Zi,ah;function Gr(){if(ah)return Zi;ah=1;function e(r){return function(t){return r(t)}}return Zi=e,Zi}var pr={exports:{}};pr.exports;var uh;function Ji(){return uh||(uh=1,function(e,r){var t=hl(),n=r&&!r.nodeType&&r,i=n&&!0&&e&&!e.nodeType&&e,s=i&&i.exports===n,a=s&&t.process,o=function(){try{var c=i&&i.require&&i.require("util").types;return c||a&&a.binding&&a.binding("util")}catch{}}();e.exports=o}(pr,pr.exports)),pr.exports}var Qi,ch;function vr(){if(ch)return Qi;ch=1;var e=Ib(),r=Gr(),t=Ji(),n=t&&t.isTypedArray,i=n?r(n):e;return Qi=i,Qi}var Hi,fh;function lh(){if(fh)return Hi;fh=1;var e=Rb(),r=dr(),t=De(),n=Zt(),i=$r(),s=vr(),a=Object.prototype,o=a.hasOwnProperty;function c(f,l){var p=t(f),m=!p&&r(f),y=!p&&!m&&n(f),x=!p&&!m&&!y&&s(f),_=p||m||y||x,b=_?e(f.length,String):[],w=b.length;for(var E in f)(l||o.call(f,E))&&!(_&&(E=="length"||y&&(E=="offset"||E=="parent")||x&&(E=="buffer"||E=="byteLength"||E=="byteOffset")||i(E,w)))&&b.push(E);return b}return Hi=c,Hi}var es,hh;function Ur(){if(hh)return es;hh=1;var e=Object.prototype;function r(t){var n=t&&t.constructor,i=typeof n=="function"&&n.prototype||e;return t===i}return es=r,es}var ts,dh;function gh(){if(dh)return ts;dh=1;function e(r,t){return function(n){return r(t(n))}}return ts=e,ts}var rs,ph;function Tb(){if(ph)return rs;ph=1;var e=gh(),r=e(Object.keys,Object);return rs=r,rs}var ns,vh;function is(){if(vh)return ns;vh=1;var e=Ur(),r=Tb(),t=Object.prototype,n=t.hasOwnProperty;function i(s){if(!e(s))return r(s);var a=[];for(var o in Object(s))n.call(s,o)&&o!="constructor"&&a.push(o);return a}return ns=i,ns}var ss,mh;function Et(){if(mh)return ss;mh=1;var e=lr(),r=Ki();function t(n){return n!=null&&r(n.length)&&!e(n)}return ss=t,ss}var os,yh;function Tt(){if(yh)return os;yh=1;var e=lh(),r=is(),t=Et();function n(i){return t(i)?e(i):r(i)}return os=n,os}var as,wh;function kb(){if(wh)return as;wh=1;var e=hr(),r=Tt();function t(n,i){return n&&e(i,r(i),n)}return as=t,as}var us,bh;function jb(){if(bh)return us;bh=1;function e(r){var t=[];if(r!=null)for(var n in Object(r))t.push(n);return t}return us=e,us}var cs,_h;function Cb(){if(_h)return cs;_h=1;var e=ut(),r=Ur(),t=jb(),n=Object.prototype,i=n.hasOwnProperty;function s(a){if(!e(a))return t(a);var o=r(a),c=[];for(var f in a)f=="constructor"&&(o||!i.call(a,f))||c.push(f);return c}return cs=s,cs}var fs,Eh;function Ft(){if(Eh)return fs;Eh=1;var e=lh(),r=Cb(),t=Et();function n(i){return t(i)?e(i,!0):r(i)}return fs=n,fs}var ls,xh;function Pb(){if(xh)return ls;xh=1;var e=hr(),r=Ft();function t(n,i){return n&&e(i,r(i),n)}return ls=t,ls}var mr={exports:{}};mr.exports;var Nh;function Mh(){return Nh||(Nh=1,function(e,r){var t=ft(),n=r&&!r.nodeType&&r,i=n&&!0&&e&&!e.nodeType&&e,s=i&&i.exports===n,a=s?t.Buffer:void 0,o=a?a.allocUnsafe:void 0;function c(f,l){if(l)return f.slice();var p=f.length,m=o?o(p):new f.constructor(p);return f.copy(m),m}e.exports=c}(mr,mr.exports)),mr.exports}var hs,Sh;function qh(){if(Sh)return hs;Sh=1;function e(r,t){var n=-1,i=r.length;for(t||(t=Array(i));++ny))return!1;var _=p.get(a),b=p.get(o);if(_&&b)return _==o&&b==a;var w=-1,E=!0,N=c&i?new e:void 0;for(p.set(a,o),p.set(o,a);++w0&&s(l)?i>1?t(l,i-1,s,a,o):e(o,l):a||(o[o.length]=l)}return o}return ha=t,ha}var ga,Xg;function k_(){if(Xg)return ga;Xg=1;function e(r,t,n){switch(n.length){case 0:return r.call(t);case 1:return r.call(t,n[0]);case 2:return r.call(t,n[0],n[1]);case 3:return r.call(t,n[0],n[1],n[2])}return r.apply(t,n)}return ga=e,ga}var pa,Zg;function Jg(){if(Zg)return pa;Zg=1;var e=k_(),r=Math.max;function t(n,i,s){return i=r(i===void 0?n.length-1:i,0),function(){for(var a=arguments,o=-1,c=r(a.length-i,0),f=Array(c);++o0){if(++s>=e)return arguments[0]}else s=0;return i.apply(void 0,arguments)}}return ma=n,ma}var ya,ep;function tp(){if(ep)return ya;ep=1;var e=j_(),r=C_(),t=r(e);return ya=t,ya}var wa,rp;function Zr(){if(rp)return wa;rp=1;var e=Bt(),r=Jg(),t=tp();function n(i,s){return t(r(i,s,e),i+"")}return wa=n,wa}var ba,np;function ip(){if(np)return ba;np=1;function e(r,t,n,i){for(var s=r.length,a=n+(i?1:-1);i?a--:++a-1}return Na=r,Na}var Ma,cp;function F_(){if(cp)return Ma;cp=1;function e(r,t,n){for(var i=-1,s=r==null?0:r.length;++i=a){var w=f?null:i(c);if(w)return s(w);x=!1,m=n,b=new e}else b=f?[]:_;e:for(;++p1?y.setNode(x,p):y.setNode(x)}),this},i.prototype.setNode=function(l,p){return e.has(this._nodes,l)?(arguments.length>1&&(this._nodes[l]=p),this):(this._nodes[l]=arguments.length>1?p:this._defaultNodeLabelFn(l),this._isCompound&&(this._parent[l]=t,this._children[l]={},this._children[t][l]=!0),this._in[l]={},this._preds[l]={},this._out[l]={},this._sucs[l]={},++this._nodeCount,this)},i.prototype.node=function(l){return this._nodes[l]},i.prototype.hasNode=function(l){return e.has(this._nodes,l)},i.prototype.removeNode=function(l){var p=this;if(e.has(this._nodes,l)){var m=function(y){p.removeEdge(p._edgeObjs[y])};delete this._nodes[l],this._isCompound&&(this._removeFromParentsChildList(l),delete this._parent[l],e.each(this.children(l),function(y){p.setParent(y)}),delete this._children[l]),e.each(e.keys(this._in[l]),m),delete this._in[l],delete this._preds[l],e.each(e.keys(this._out[l]),m),delete this._out[l],delete this._sucs[l],--this._nodeCount}return this},i.prototype.setParent=function(l,p){if(!this._isCompound)throw new Error("Cannot set parent in a non-compound graph");if(e.isUndefined(p))p=t;else{p+="";for(var m=p;!e.isUndefined(m);m=this.parent(m))if(m===l)throw new Error("Setting "+p+" as parent of "+l+" would create a cycle");this.setNode(p)}return this.setNode(l),this._removeFromParentsChildList(l),this._parent[l]=p,this._children[p][l]=!0,this},i.prototype._removeFromParentsChildList=function(l){delete this._children[this._parent[l]][l]},i.prototype.parent=function(l){if(this._isCompound){var p=this._parent[l];if(p!==t)return p}},i.prototype.children=function(l){if(e.isUndefined(l)&&(l=t),this._isCompound){var p=this._children[l];if(p)return e.keys(p)}else{if(l===t)return this.nodes();if(this.hasNode(l))return[]}},i.prototype.predecessors=function(l){var p=this._preds[l];if(p)return e.keys(p)},i.prototype.successors=function(l){var p=this._sucs[l];if(p)return e.keys(p)},i.prototype.neighbors=function(l){var p=this.predecessors(l);if(p)return e.union(p,this.successors(l))},i.prototype.isLeaf=function(l){var p;return this.isDirected()?p=this.successors(l):p=this.neighbors(l),p.length===0},i.prototype.filterNodes=function(l){var p=new this.constructor({directed:this._isDirected,multigraph:this._isMultigraph,compound:this._isCompound});p.setGraph(this.graph());var m=this;e.each(this._nodes,function(_,b){l(b)&&p.setNode(b,_)}),e.each(this._edgeObjs,function(_){p.hasNode(_.v)&&p.hasNode(_.w)&&p.setEdge(_,m.edge(_))});var y={};function x(_){var b=m.parent(_);return b===void 0||p.hasNode(b)?(y[_]=b,b):b in y?y[b]:x(b)}return this._isCompound&&e.each(p.nodes(),function(_){p.setParent(_,x(_))}),p},i.prototype.setDefaultEdgeLabel=function(l){return e.isFunction(l)||(l=e.constant(l)),this._defaultEdgeLabelFn=l,this},i.prototype.edgeCount=function(){return this._edgeCount},i.prototype.edges=function(){return e.values(this._edgeObjs)},i.prototype.setPath=function(l,p){var m=this,y=arguments;return e.reduce(l,function(x,_){return y.length>1?m.setEdge(x,_,p):m.setEdge(x,_),_}),this},i.prototype.setEdge=function(){var l,p,m,y,x=!1,_=arguments[0];typeof _=="object"&&_!==null&&"v"in _?(l=_.v,p=_.w,m=_.name,arguments.length===2&&(y=arguments[1],x=!0)):(l=_,p=arguments[1],m=arguments[3],arguments.length>2&&(y=arguments[2],x=!0)),l=""+l,p=""+p,e.isUndefined(m)||(m=""+m);var b=o(this._isDirected,l,p,m);if(e.has(this._edgeLabels,b))return x&&(this._edgeLabels[b]=y),this;if(!e.isUndefined(m)&&!this._isMultigraph)throw new Error("Cannot set a named edge when isMultigraph = false");this.setNode(l),this.setNode(p),this._edgeLabels[b]=x?y:this._defaultEdgeLabelFn(l,p,m);var w=c(this._isDirected,l,p,m);return l=w.v,p=w.w,Object.freeze(w),this._edgeObjs[b]=w,s(this._preds[p],l),s(this._sucs[l],p),this._in[p][b]=w,this._out[l][b]=w,this._edgeCount++,this},i.prototype.edge=function(l,p,m){var y=arguments.length===1?f(this._isDirected,arguments[0]):o(this._isDirected,l,p,m);return this._edgeLabels[y]},i.prototype.hasEdge=function(l,p,m){var y=arguments.length===1?f(this._isDirected,arguments[0]):o(this._isDirected,l,p,m);return e.has(this._edgeLabels,y)},i.prototype.removeEdge=function(l,p,m){var y=arguments.length===1?f(this._isDirected,arguments[0]):o(this._isDirected,l,p,m),x=this._edgeObjs[y];return x&&(l=x.v,p=x.w,delete this._edgeLabels[y],delete this._edgeObjs[y],a(this._preds[p],l),a(this._sucs[l],p),delete this._in[p][y],delete this._out[l][y],this._edgeCount--),this},i.prototype.inEdges=function(l,p){var m=this._in[l];if(m){var y=e.values(m);return p?e.filter(y,function(x){return x.v===p}):y}},i.prototype.outEdges=function(l,p){var m=this._out[l];if(m){var y=e.values(m);return p?e.filter(y,function(x){return x.w===p}):y}},i.prototype.nodeEdges=function(l,p){var m=this.inEdges(l,p);if(m)return m.concat(this.outEdges(l,p))};function s(l,p){l[p]?l[p]++:l[p]=1}function a(l,p){--l[p]||delete l[p]}function o(l,p,m,y){var x=""+p,_=""+m;if(!l&&x>_){var b=x;x=_,_=b}return x+n+_+n+(e.isUndefined(y)?r:y)}function c(l,p,m,y){var x=""+p,_=""+m;if(!l&&x>_){var b=x;x=_,_=b}var w={v:x,w:_};return y&&(w.name=y),w}function f(l,p){return o(l,p.v,p.w,p.name)}return ja}var Pa,_p;function W_(){return _p||(_p=1,Pa="2.1.8"),Pa}var La,Ep;function Y_(){return Ep||(Ep=1,La={Graph:Ca(),version:W_()}),La}var Da,xp;function K_(){if(xp)return Da;xp=1;var e=ct(),r=Ca();Da={write:t,read:s};function t(a){var o={options:{directed:a.isDirected(),multigraph:a.isMultigraph(),compound:a.isCompound()},nodes:n(a),edges:i(a)};return e.isUndefined(a.graph())||(o.value=e.clone(a.graph())),o}function n(a){return e.map(a.nodes(),function(o){var c=a.node(o),f=a.parent(o),l={v:o};return e.isUndefined(c)||(l.value=c),e.isUndefined(f)||(l.parent=f),l})}function i(a){return e.map(a.edges(),function(o){var c=a.edge(o),f={v:o.v,w:o.w};return e.isUndefined(o.name)||(f.name=o.name),e.isUndefined(c)||(f.value=c),f})}function s(a){var o=new r(a.options).setGraph(a.value);return e.each(a.nodes,function(c){o.setNode(c.v,c.value),c.parent&&o.setParent(c.v,c.parent)}),e.each(a.edges,function(c){o.setEdge({v:c.v,w:c.w,name:c.name},c.value)}),o}return Da}var za,Np;function X_(){if(Np)return za;Np=1;var e=ct();za=r;function r(t){var n={},i=[],s;function a(o){e.has(n,o)||(n[o]=!0,s.push(o),e.each(t.successors(o),a),e.each(t.predecessors(o),a))}return e.each(t.nodes(),function(o){s=[],a(o),s.length&&i.push(s)}),i}return za}var Fa,Mp;function Sp(){if(Mp)return Fa;Mp=1;var e=ct();Fa=r;function r(){this._arr=[],this._keyIndices={}}return r.prototype.size=function(){return this._arr.length},r.prototype.keys=function(){return this._arr.map(function(t){return t.key})},r.prototype.has=function(t){return e.has(this._keyIndices,t)},r.prototype.priority=function(t){var n=this._keyIndices[t];if(n!==void 0)return this._arr[n].priority},r.prototype.min=function(){if(this.size()===0)throw new Error("Queue underflow");return this._arr[0].key},r.prototype.add=function(t,n){var i=this._keyIndices;if(t=String(t),!e.has(i,t)){var s=this._arr,a=s.length;return i[t]=a,s.push({key:t,priority:n}),this._decrease(a),!0}return!1},r.prototype.removeMin=function(){this._swap(0,this._arr.length-1);var t=this._arr.pop();return delete this._keyIndices[t.key],this._heapify(0),t.key},r.prototype.decrease=function(t,n){var i=this._keyIndices[t];if(n>this._arr[i].priority)throw new Error("New priority is greater than current priority. Key: "+t+" Old: "+this._arr[i].priority+" New: "+n);this._arr[i].priority=n,this._decrease(i)},r.prototype._heapify=function(t){var n=this._arr,i=2*t,s=i+1,a=t;i>1,!(n[s].priority0&&(p=l.removeMin(),m=f[p],m.distance!==Number.POSITIVE_INFINITY);)c(p).forEach(y);return f}return Ba}var $a,Op;function Z_(){if(Op)return $a;Op=1;var e=Rp(),r=ct();$a=t;function t(n,i,s){return r.transform(n.nodes(),function(a,o){a[o]=e(n,o,i,s)},{})}return $a}var Ga,Ap;function Ip(){if(Ap)return Ga;Ap=1;var e=ct();Ga=r;function r(t){var n=0,i=[],s={},a=[];function o(c){var f=s[c]={onStack:!0,lowlink:n,index:n++};if(i.push(c),t.successors(c).forEach(function(m){e.has(s,m)?s[m].onStack&&(f.lowlink=Math.min(f.lowlink,s[m].index)):(o(m),f.lowlink=Math.min(f.lowlink,s[m].lowlink))}),f.lowlink===f.index){var l=[],p;do p=i.pop(),s[p].onStack=!1,l.push(p);while(c!==p);a.push(l)}}return t.nodes().forEach(function(c){e.has(s,c)||o(c)}),a}return Ga}var Ua,Tp;function J_(){if(Tp)return Ua;Tp=1;var e=ct(),r=Ip();Ua=t;function t(n){return e.filter(r(n),function(i){return i.length>1||i.length===1&&n.hasEdge(i[0],i[0])})}return Ua}var Va,kp;function Q_(){if(kp)return Va;kp=1;var e=ct();Va=t;var r=e.constant(1);function t(i,s,a){return n(i,s||r,a||function(o){return i.outEdges(o)})}function n(i,s,a){var o={},c=i.nodes();return c.forEach(function(f){o[f]={},o[f][f]={distance:0},c.forEach(function(l){f!==l&&(o[f][l]={distance:Number.POSITIVE_INFINITY})}),a(f).forEach(function(l){var p=l.v===f?l.w:l.v,m=s(l);o[f][p]={distance:m,predecessor:f}})}),c.forEach(function(f){var l=o[f];c.forEach(function(p){var m=o[p];c.forEach(function(y){var x=m[f],_=l[y],b=m[y],w=x.distance+_.distance;w0;){if(f=c.removeMin(),e.has(o,f))a.setEdge(f,o[f]);else{if(p)throw new Error("Input graph is not connected: "+i);p=!0}i.nodeEdges(f).forEach(l)}return a}return Ja}var Qa,$p;function nE(){return $p||($p=1,Qa={components:X_(),dijkstra:Rp(),dijkstraAll:Z_(),findCycles:J_(),floydWarshall:Q_(),isAcyclic:H_(),postorder:eE(),preorder:tE(),prim:rE(),tarjan:Ip(),topsort:Cp()}),Qa}var Ha,Gp;function iE(){if(Gp)return Ha;Gp=1;var e=Y_();return Ha={Graph:e.Graph,json:K_(),alg:nE(),version:e.version},Ha}var eu,Up;function lt(){if(Up)return eu;Up=1;var e;if(typeof Bn=="function")try{e=iE()}catch{}return e||(e=window.graphlib),eu=e,eu}var tu,Vp;function sE(){if(Vp)return tu;Vp=1;var e=pd(),r=1,t=4;function n(i){return e(i,r|t)}return tu=n,tu}var ru,Wp;function Jr(){if(Wp)return ru;Wp=1;var e=Kt(),r=Et(),t=$r(),n=ut();function i(s,a,o){if(!n(o))return!1;var c=typeof a;return(c=="number"?r(o)&&t(a,o.length):c=="string"&&a in o)?e(o[a],s):!1}return ru=i,ru}var nu,Yp;function oE(){if(Yp)return nu;Yp=1;var e=Zr(),r=Kt(),t=Jr(),n=Ft(),i=Object.prototype,s=i.hasOwnProperty,a=e(function(o,c){o=Object(o);var f=-1,l=c.length,p=l>2?c[2]:void 0;for(p&&t(c[0],c[1],p)&&(l=1);++f-1?c[f?s[l]:l]:void 0}}return iu=n,iu}var su,Xp;function uE(){if(Xp)return su;Xp=1;var e=/\s/;function r(t){for(var n=t.length;n--&&e.test(t.charAt(n)););return n}return su=r,su}var ou,Zp;function cE(){if(Zp)return ou;Zp=1;var e=uE(),r=/^\s+/;function t(n){return n&&n.slice(0,e(n)+1).replace(r,"")}return ou=t,ou}var au,Jp;function fE(){if(Jp)return au;Jp=1;var e=cE(),r=ut(),t=Qt(),n=NaN,i=/^[-+]0x[0-9a-f]+$/i,s=/^0b[01]+$/i,a=/^0o[0-7]+$/i,o=parseInt;function c(f){if(typeof f=="number")return f;if(t(f))return n;if(r(f)){var l=typeof f.valueOf=="function"?f.valueOf():f;f=r(l)?l+"":l}if(typeof f!="string")return f===0?f:+f;f=e(f);var p=s.test(f);return p||a.test(f)?o(f.slice(2),p?2:8):i.test(f)?n:+f}return au=c,au}var uu,Qp;function Hp(){if(Qp)return uu;Qp=1;var e=fE(),r=1/0,t=17976931348623157e292;function n(i){if(!i)return i===0?i:0;if(i=e(i),i===r||i===-r){var s=i<0?-1:1;return s*t}return i===i?i:0}return uu=n,uu}var cu,ev;function lE(){if(ev)return cu;ev=1;var e=Hp();function r(t){var n=e(t),i=n%1;return n===n?i?n-i:n:0}return cu=r,cu}var fu,tv;function hE(){if(tv)return fu;tv=1;var e=ip(),r=xt(),t=lE(),n=Math.max;function i(s,a,o){var c=s==null?0:s.length;if(!c)return-1;var f=o==null?0:t(o);return f<0&&(f=n(c+f,0)),e(s,r(a,3),f)}return fu=i,fu}var lu,rv;function dE(){if(rv)return lu;rv=1;var e=aE(),r=hE(),t=e(r);return lu=t,lu}var hu,nv;function iv(){if(nv)return hu;nv=1;var e=da();function r(t){var n=t==null?0:t.length;return n?e(t,1):[]}return hu=r,hu}var du,sv;function gE(){if(sv)return du;sv=1;var e=Qs(),r=Md(),t=Ft();function n(i,s){return i==null?i:e(i,r(s),t)}return du=n,du}var gu,ov;function pE(){if(ov)return gu;ov=1;function e(r){var t=r==null?0:r.length;return t?r[t-1]:void 0}return gu=e,gu}var pu,av;function vE(){if(av)return pu;av=1;var e=Fr(),r=eo(),t=xt();function n(i,s){var a={};return s=t(s,3),r(i,function(o,c,f){e(a,c,s(o,c,f))}),a}return pu=n,pu}var vu,uv;function mu(){if(uv)return vu;uv=1;var e=Qt();function r(t,n,i){for(var s=-1,a=t.length;++st}return yu=e,yu}var wu,fv;function yE(){if(fv)return wu;fv=1;var e=mu(),r=mE(),t=Bt();function n(i){return i&&i.length?e(i,t,r):void 0}return wu=n,wu}var bu,lv;function hv(){if(lv)return bu;lv=1;var e=Fr(),r=Kt();function t(n,i,s){(s!==void 0&&!r(n[i],s)||s===void 0&&!(i in n))&&e(n,i,s)}return bu=t,bu}var _u,dv;function wE(){if(dv)return _u;dv=1;var e=Dt(),r=Vr(),t=pt(),n="[object Object]",i=Function.prototype,s=Object.prototype,a=i.toString,o=s.hasOwnProperty,c=a.call(Object);function f(l){if(!t(l)||e(l)!=n)return!1;var p=r(l);if(p===null)return!0;var m=o.call(p,"constructor")&&p.constructor;return typeof m=="function"&&m instanceof m&&a.call(m)==c}return _u=f,_u}var Eu,gv;function pv(){if(gv)return Eu;gv=1;function e(r,t){if(!(t==="constructor"&&typeof r[t]=="function")&&t!="__proto__")return r[t]}return Eu=e,Eu}var xu,vv;function bE(){if(vv)return xu;vv=1;var e=hr(),r=Ft();function t(n){return e(n,r(n))}return xu=t,xu}var Nu,mv;function _E(){if(mv)return Nu;mv=1;var e=hv(),r=Mh(),t=id(),n=qh(),i=cd(),s=dr(),a=De(),o=gp(),c=Zt(),f=lr(),l=ut(),p=wE(),m=vr(),y=pv(),x=bE();function _(b,w,E,N,S,R,A){var j=y(b,E),I=y(w,E),D=A.get(I);if(D){e(b,E,D);return}var z=R?R(j,I,E+"",b,w,A):void 0,$=z===void 0;if($){var V=a(I),Y=!V&&c(I),ee=!V&&!Y&&m(I);z=I,V||Y||ee?a(j)?z=j:o(j)?z=n(j):Y?($=!1,z=r(I,!0)):ee?($=!1,z=t(I,!0)):z=[]:p(I)||s(I)?(z=j,s(j)?z=x(j):(!l(j)||f(j))&&(z=i(I))):$=!1}$&&(A.set(I,z),S(z,I,N,R,A),A.delete(I)),e(b,E,z)}return Nu=_,Nu}var Mu,yv;function EE(){if(yv)return Mu;yv=1;var e=zr(),r=hv(),t=Qs(),n=_E(),i=ut(),s=Ft(),a=pv();function o(c,f,l,p,m){c!==f&&t(f,function(y,x){if(m||(m=new e),i(y))n(c,f,x,l,o,p,m);else{var _=p?p(a(c,x),y,x+"",c,f,m):void 0;_===void 0&&(_=y),r(c,x,_)}},s)}return Mu=o,Mu}var Su,wv;function xE(){if(wv)return Su;wv=1;var e=Zr(),r=Jr();function t(n){return e(function(i,s){var a=-1,o=s.length,c=o>1?s[o-1]:void 0,f=o>2?s[2]:void 0;for(c=n.length>3&&typeof c=="function"?(o--,c):void 0,f&&r(s[0],s[1],f)&&(c=o<3?void 0:c,o=1),i=Object(i);++an||o&&c&&l&&!f&&!p||s&&c&&l||!i&&l||!a)return 1;if(!s&&!o&&!p&&t=f)return l;var p=i[s];return l*(p=="desc"?-1:1)}}return t.index-n.index}return $u=r,$u}var Gu,Lv;function zE(){if(Lv)return Gu;Lv=1;var e=Yr(),r=Xr(),t=xt(),n=kg(),i=PE(),s=Gr(),a=DE(),o=Bt(),c=De();function f(l,p,m){p.length?p=e(p,function(_){return c(_)?function(b){return r(b,_.length===1?_[0]:_)}:_}):p=[o];var y=-1;p=e(p,s(t));var x=n(l,function(_,b,w){var E=e(p,function(N){return N(_)});return{criteria:E,index:++y,value:_}});return i(x,function(_,b){return a(_,b,m)})}return Gu=f,Gu}var Uu,Dv;function FE(){if(Dv)return Uu;Dv=1;var e=da(),r=zE(),t=Zr(),n=Jr(),i=t(function(s,a){if(s==null)return[];var o=a.length;return o>1&&n(s,a[0],a[1])?a=[]:o>2&&n(a[0],a[1],a[2])&&(a=[a[0]]),r(s,e(a,1),[])});return Uu=i,Uu}var Vu,zv;function BE(){if(zv)return Vu;zv=1;var e=ug(),r=0;function t(n){var i=++r;return e(n)+i}return Vu=t,Vu}var Wu,Fv;function $E(){if(Fv)return Wu;Fv=1;function e(r,t,n){for(var i=-1,s=r.length,a=t.length,o={};++i0;--b)if(_=l[b].dequeue(),_){m=m.concat(a(f,l,p,_,!0));break}}}return m}function a(f,l,p,m,y){var x=y?[]:void 0;return e.forEach(f.inEdges(m.v),function(_){var b=f.edge(_),w=f.node(_.v);y&&x.push({v:_.v,w:_.w}),w.out-=b,c(l,p,w)}),e.forEach(f.outEdges(m.v),function(_){var b=f.edge(_),w=_.w,E=f.node(w);E.in-=b,c(l,p,E)}),f.removeNode(m.v),x}function o(f,l){var p=new r,m=0,y=0;e.forEach(f.nodes(),function(b){p.setNode(b,{v:b,in:0,out:0})}),e.forEach(f.edges(),function(b){var w=p.edge(b.v,b.w)||0,E=l(b),N=w+E;p.setEdge(b.v,b.w,N),y=Math.max(y,p.node(b.v).out+=E),m=Math.max(m,p.node(b.w).in+=E)});var x=e.range(y+m+3).map(function(){return new t}),_=m+1;return e.forEach(p.nodes(),function(b){c(x,_,p.node(b))}),{graph:p,buckets:x,zeroIdx:_}}function c(f,l,p){p.out?p.in?f[p.out-p.in+l].enqueue(p):f[f.length-1].enqueue(p):f[0].enqueue(p)}return Zu}var Ju,Vv;function WE(){if(Vv)return Ju;Vv=1;var e=Te(),r=VE();Ju={run:t,undo:i};function t(s){var a=s.graph().acyclicer==="greedy"?r(s,o(s)):n(s);e.forEach(a,function(c){var f=s.edge(c);s.removeEdge(c),f.forwardName=c.name,f.reversed=!0,s.setEdge(c.w,c.v,f,e.uniqueId("rev"))});function o(c){return function(f){return c.edge(f).weight}}}function n(s){var a=[],o={},c={};function f(l){e.has(c,l)||(c[l]=!0,o[l]=!0,e.forEach(s.outEdges(l),function(p){e.has(o,p.w)?a.push(p):f(p.w)}),delete o[l])}return e.forEach(s.nodes(),f),a}function i(s){e.forEach(s.edges(),function(a){var o=s.edge(a);if(o.reversed){s.removeEdge(a);var c=o.forwardName;delete o.reversed,delete o.forwardName,s.setEdge(a.w,a.v,o,c)}})}return Ju}var Qu,Wv;function nt(){if(Wv)return Qu;Wv=1;var e=Te(),r=lt().Graph;Qu={addDummyNode:t,simplify:n,asNonCompoundGraph:i,successorWeights:s,predecessorWeights:a,intersectRect:o,buildLayerMatrix:c,normalizeRanks:f,removeEmptyRanks:l,addBorderNode:p,maxRank:m,partition:y,time:x,notime:_};function t(b,w,E,N){var S;do S=e.uniqueId(N);while(b.hasNode(S));return E.dummy=w,b.setNode(S,E),S}function n(b){var w=new r().setGraph(b.graph());return e.forEach(b.nodes(),function(E){w.setNode(E,b.node(E))}),e.forEach(b.edges(),function(E){var N=w.edge(E.v,E.w)||{weight:0,minlen:1},S=b.edge(E);w.setEdge(E.v,E.w,{weight:N.weight+S.weight,minlen:Math.max(N.minlen,S.minlen)})}),w}function i(b){var w=new r({multigraph:b.isMultigraph()}).setGraph(b.graph());return e.forEach(b.nodes(),function(E){b.children(E).length||w.setNode(E,b.node(E))}),e.forEach(b.edges(),function(E){w.setEdge(E,b.edge(E))}),w}function s(b){var w=e.map(b.nodes(),function(E){var N={};return e.forEach(b.outEdges(E),function(S){N[S.w]=(N[S.w]||0)+b.edge(S).weight}),N});return e.zipObject(b.nodes(),w)}function a(b){var w=e.map(b.nodes(),function(E){var N={};return e.forEach(b.inEdges(E),function(S){N[S.v]=(N[S.v]||0)+b.edge(S).weight}),N});return e.zipObject(b.nodes(),w)}function o(b,w){var E=b.x,N=b.y,S=w.x-E,R=w.y-N,A=b.width/2,j=b.height/2;if(!S&&!R)throw new Error("Not possible to find intersection inside of the rectangle");var I,D;return Math.abs(R)*A>Math.abs(S)*j?(R<0&&(j=-j),I=j*S/R,D=j):(S<0&&(A=-A),I=A,D=A*R/S),{x:E+I,y:N+D}}function c(b){var w=e.map(e.range(m(b)+1),function(){return[]});return e.forEach(b.nodes(),function(E){var N=b.node(E),S=N.rank;e.isUndefined(S)||(w[S][N.order]=E)}),w}function f(b){var w=e.min(e.map(b.nodes(),function(E){return b.node(E).rank}));e.forEach(b.nodes(),function(E){var N=b.node(E);e.has(N,"rank")&&(N.rank-=w)})}function l(b){var w=e.min(e.map(b.nodes(),function(R){return b.node(R).rank})),E=[];e.forEach(b.nodes(),function(R){var A=b.node(R).rank-w;E[A]||(E[A]=[]),E[A].push(R)});var N=0,S=b.graph().nodeRankFactor;e.forEach(E,function(R,A){e.isUndefined(R)&&A%S!==0?--N:N&&e.forEach(R,function(j){b.node(j).rank+=N})})}function p(b,w,E,N){var S={width:0,height:0};return arguments.length>=4&&(S.rank=E,S.order=N),t(b,"border",S,w)}function m(b){return e.max(e.map(b.nodes(),function(w){var E=b.node(w).rank;if(!e.isUndefined(E))return E}))}function y(b,w){var E={lhs:[],rhs:[]};return e.forEach(b,function(N){w(N)?E.lhs.push(N):E.rhs.push(N)}),E}function x(b,w){var E=e.now();try{return w()}finally{console.log(b+" time: "+(e.now()-E)+"ms")}}function _(b,w){return w()}return Qu}var Hu,Yv;function YE(){if(Yv)return Hu;Yv=1;var e=Te(),r=nt();Hu={run:t,undo:i};function t(s){s.graph().dummyChains=[],e.forEach(s.edges(),function(a){n(s,a)})}function n(s,a){var o=a.v,c=s.node(o).rank,f=a.w,l=s.node(f).rank,p=a.name,m=s.edge(a),y=m.labelRank;if(l!==c+1){s.removeEdge(a);var x,_,b;for(b=0,++c;cD.lim&&(z=D,$=!0);var V=e.filter(S.edges(),function(Y){return $===E(N,N.node(Y.v),z)&&$!==E(N,N.node(Y.w),z)});return e.minBy(V,function(Y){return t(S,Y)})}function _(N,S,R,A){var j=R.v,I=R.w;N.removeEdge(j,I),N.setEdge(A.v,A.w,{}),p(N),c(N,S),b(N,S)}function b(N,S){var R=e.find(N.nodes(),function(j){return!S.node(j).parent}),A=i(N,R);A=A.slice(1),e.forEach(A,function(j){var I=N.node(j).parent,D=S.edge(j,I),z=!1;D||(D=S.edge(I,j),z=!0),S.node(j).rank=S.node(I).rank+(z?D.minlen:-D.minlen)})}function w(N,S,R){return N.hasEdge(S,R)}function E(N,S,R){return R.low<=S.lim&&S.lim<=R.lim}return rc}var nc,Qv;function XE(){if(Qv)return nc;Qv=1;var e=Qr(),r=e.longestPath,t=Zv(),n=KE();nc=i;function i(c){switch(c.graph().ranker){case"network-simplex":o(c);break;case"tight-tree":a(c);break;case"longest-path":s(c);break;default:o(c)}}var s=r;function a(c){r(c),t(c)}function o(c){n(c)}return nc}var ic,Hv;function ZE(){if(Hv)return ic;Hv=1;var e=Te();ic=r;function r(i){var s=n(i);e.forEach(i.graph().dummyChains,function(a){for(var o=i.node(a),c=o.edgeObj,f=t(i,s,c.v,c.w),l=f.path,p=f.lca,m=0,y=l[m],x=!0;a!==c.w;){if(o=i.node(a),x){for(;(y=l[m])!==p&&i.node(y).maxRankl||p>s[m].lim));for(y=m,m=o;(m=i.parent(m))!==y;)f.push(m);return{path:c.concat(f.reverse()),lca:y}}function n(i){var s={},a=0;function o(c){var f=a;e.forEach(i.children(c),o),s[c]={low:f,lim:a++}}return e.forEach(i.children(),o),s}return ic}var sc,e0;function JE(){if(e0)return sc;e0=1;var e=Te(),r=nt();sc={run:t,cleanup:a};function t(o){var c=r.addDummyNode(o,"root",{},"_root"),f=i(o),l=e.max(e.values(f))-1,p=2*l+1;o.graph().nestingRoot=c,e.forEach(o.edges(),function(y){o.edge(y).minlen*=p});var m=s(o)+1;e.forEach(o.children(),function(y){n(o,c,p,m,l,f,y)}),o.graph().nodeRankFactor=p}function n(o,c,f,l,p,m,y){var x=o.children(y);if(!x.length){y!==c&&o.setEdge(c,y,{weight:0,minlen:f});return}var _=r.addBorderNode(o,"_bt"),b=r.addBorderNode(o,"_bb"),w=o.node(y);o.setParent(_,y),w.borderTop=_,o.setParent(b,y),w.borderBottom=b,e.forEach(x,function(E){n(o,c,f,l,p,m,E);var N=o.node(E),S=N.borderTop?N.borderTop:E,R=N.borderBottom?N.borderBottom:E,A=N.borderTop?l:2*l,j=S!==R?1:p-m[y]+1;o.setEdge(_,S,{weight:A,minlen:j,nestingEdge:!0}),o.setEdge(R,b,{weight:A,minlen:j,nestingEdge:!0})}),o.parent(y)||o.setEdge(c,_,{weight:0,minlen:p+m[y]})}function i(o){var c={};function f(l,p){var m=o.children(l);m&&m.length&&e.forEach(m,function(y){f(y,p+1)}),c[l]=p}return e.forEach(o.children(),function(l){f(l,1)}),c}function s(o){return e.reduce(o.edges(),function(c,f){return c+o.edge(f).weight},0)}function a(o){var c=o.graph();o.removeNode(c.nestingRoot),delete c.nestingRoot,e.forEach(o.edges(),function(f){var l=o.edge(f);l.nestingEdge&&o.removeEdge(f)})}return sc}var oc,t0;function QE(){if(t0)return oc;t0=1;var e=Te(),r=nt();oc=t;function t(i){function s(a){var o=i.children(a),c=i.node(a);if(o.length&&e.forEach(o,s),e.has(c,"minRank")){c.borderLeft=[],c.borderRight=[];for(var f=c.minRank,l=c.maxRank+1;f0;)y%2&&(x+=l[y+1]),y=y-1>>1,l[y]+=m.weight;p+=m.weight*x})),p}return cc}var fc,s0;function rx(){if(s0)return fc;s0=1;var e=Te();fc=r;function r(t,n){return e.map(n,function(i){var s=t.inEdges(i);if(s.length){var a=e.reduce(s,function(o,c){var f=t.edge(c),l=t.node(c.v);return{sum:o.sum+f.weight*l.order,weight:o.weight+f.weight}},{sum:0,weight:0});return{v:i,barycenter:a.sum/a.weight,weight:a.weight}}else return{v:i}})}return fc}var lc,o0;function nx(){if(o0)return lc;o0=1;var e=Te();lc=r;function r(i,s){var a={};e.forEach(i,function(c,f){var l=a[c.v]={indegree:0,in:[],out:[],vs:[c.v],i:f};e.isUndefined(c.barycenter)||(l.barycenter=c.barycenter,l.weight=c.weight)}),e.forEach(s.edges(),function(c){var f=a[c.v],l=a[c.w];!e.isUndefined(f)&&!e.isUndefined(l)&&(l.indegree++,f.out.push(a[c.w]))});var o=e.filter(a,function(c){return!c.indegree});return t(o)}function t(i){var s=[];function a(f){return function(l){l.merged||(e.isUndefined(l.barycenter)||e.isUndefined(f.barycenter)||l.barycenter>=f.barycenter)&&n(f,l)}}function o(f){return function(l){l.in.push(f),--l.indegree===0&&i.push(l)}}for(;i.length;){var c=i.pop();s.push(c),e.forEach(c.in.reverse(),a(c)),e.forEach(c.out,o(c))}return e.map(e.filter(s,function(f){return!f.merged}),function(f){return e.pick(f,["vs","i","barycenter","weight"])})}function n(i,s){var a=0,o=0;i.weight&&(a+=i.barycenter*i.weight,o+=i.weight),s.weight&&(a+=s.barycenter*s.weight,o+=s.weight),i.vs=s.vs.concat(i.vs),i.barycenter=a/o,i.weight=o,i.i=Math.min(s.i,i.i),s.merged=!0}return lc}var hc,a0;function ix(){if(a0)return hc;a0=1;var e=Te(),r=nt();hc=t;function t(s,a){var o=r.partition(s,function(_){return e.has(_,"barycenter")}),c=o.lhs,f=e.sortBy(o.rhs,function(_){return-_.i}),l=[],p=0,m=0,y=0;c.sort(i(!!a)),y=n(l,f,y),e.forEach(c,function(_){y+=_.vs.length,l.push(_.vs),p+=_.barycenter*_.weight,m+=_.weight,y=n(l,f,y)});var x={vs:e.flatten(l,!0)};return m&&(x.barycenter=p/m,x.weight=m),x}function n(s,a,o){for(var c;a.length&&(c=e.last(a)).i<=o;)a.pop(),s.push(c.vs),o++;return o}function i(s){return function(a,o){return a.barycentero.barycenter?1:s?o.i-a.i:a.i-o.i}}return hc}var dc,u0;function sx(){if(u0)return dc;u0=1;var e=Te(),r=rx(),t=nx(),n=ix();dc=i;function i(o,c,f,l){var p=o.children(c),m=o.node(c),y=m?m.borderLeft:void 0,x=m?m.borderRight:void 0,_={};y&&(p=e.filter(p,function(R){return R!==y&&R!==x}));var b=r(o,p);e.forEach(b,function(R){if(o.children(R.v).length){var A=i(o,R.v,f,l);_[R.v]=A,e.has(A,"barycenter")&&a(R,A)}});var w=t(b,f);s(w,_);var E=n(w,l);if(y&&(E.vs=e.flatten([y,E.vs,x],!0),o.predecessors(y).length)){var N=o.node(o.predecessors(y)[0]),S=o.node(o.predecessors(x)[0]);e.has(E,"barycenter")||(E.barycenter=0,E.weight=0),E.barycenter=(E.barycenter*E.weight+N.order+S.order)/(E.weight+2),E.weight+=2}return E}function s(o,c){e.forEach(o,function(f){f.vs=e.flatten(f.vs.map(function(l){return c[l]?c[l].vs:l}),!0)})}function a(o,c){e.isUndefined(o.barycenter)?(o.barycenter=c.barycenter,o.weight=c.weight):(o.barycenter=(o.barycenter*o.weight+c.barycenter*c.weight)/(o.weight+c.weight),o.weight+=c.weight)}return dc}var gc,c0;function ox(){if(c0)return gc;c0=1;var e=Te(),r=lt().Graph;gc=t;function t(i,s,a){var o=n(i),c=new r({compound:!0}).setGraph({root:o}).setDefaultNodeLabel(function(f){return i.node(f)});return e.forEach(i.nodes(),function(f){var l=i.node(f),p=i.parent(f);(l.rank===s||l.minRank<=s&&s<=l.maxRank)&&(c.setNode(f),c.setParent(f,p||o),e.forEach(i[a](f),function(m){var y=m.v===f?m.w:m.v,x=c.edge(y,f),_=e.isUndefined(x)?0:x.weight;c.setEdge(y,f,{weight:i.edge(m).weight+_})}),e.has(l,"minRank")&&c.setNode(f,{borderLeft:l.borderLeft[s],borderRight:l.borderRight[s]}))}),c}function n(i){for(var s;i.hasNode(s=e.uniqueId("_root")););return s}return gc}var pc,f0;function ax(){if(f0)return pc;f0=1;var e=Te();pc=r;function r(t,n,i){var s={},a;e.forEach(i,function(o){for(var c=t.parent(o),f,l;c;){if(f=t.parent(c),f?(l=s[f],s[f]=c):(l=a,a=c),l&&l!==c){n.setEdge(l,c);return}c=f}})}return pc}var vc,l0;function ux(){if(l0)return vc;l0=1;var e=Te(),r=ex(),t=tx(),n=sx(),i=ox(),s=ax(),a=lt().Graph,o=nt();vc=c;function c(m){var y=o.maxRank(m),x=f(m,e.range(1,y+1),"inEdges"),_=f(m,e.range(y-1,-1,-1),"outEdges"),b=r(m);p(m,b);for(var w=Number.POSITIVE_INFINITY,E,N=0,S=0;S<4;++N,++S){l(N%2?x:_,N%4>=2),b=o.buildLayerMatrix(m);var R=t(m,b);Rz)&&a(N,Y,$)})})}function R(A,j){var I=-1,D,z=0;return e.forEach(j,function($,V){if(w.node($).dummy==="border"){var Y=w.predecessors($);Y.length&&(D=w.node(Y[0]).order,S(j,z,V,I,D),z=V,I=D)}S(j,z,j.length,D,A.length)}),j}return e.reduce(E,R),N}function s(w,E){if(w.node(E).dummy)return e.find(w.predecessors(E),function(N){return w.node(N).dummy})}function a(w,E,N){if(E>N){var S=E;E=N,N=S}var R=w[E];R||(w[E]=R={}),R[N]=!0}function o(w,E,N){if(E>N){var S=E;E=N,N=S}return e.has(w[E],N)}function c(w,E,N,S){var R={},A={},j={};return e.forEach(E,function(I){e.forEach(I,function(D,z){R[D]=D,A[D]=D,j[D]=z})}),e.forEach(E,function(I){var D=-1;e.forEach(I,function(z){var $=S(z);if($.length){$=e.sortBy($,function(ae){return j[ae]});for(var V=($.length-1)/2,Y=Math.floor(V),ee=Math.ceil(V);Y<=ee;++Y){var J=$[Y];A[z]===z&&D({}));const a=t.getAllNodes(),o=t.getAllEdges();[...a,...o].some(({id:f})=>me(f))&&console.error("Dagre layout only support string id, it will convert number to string."),t.getAllNodes().forEach(f=>{const{id:l}=f,p=Object.assign({},f.data);if(i!==void 0){const[m,y]=sr(wt(i)?i(f):i);Object.assign(p,{width:m,height:y})}s.setNode(l.toString(),p)}),t.getAllEdges().forEach(({id:f,source:l,target:p})=>{s.setEdge(l.toString(),p.toString(),{id:f})}),px.layout(s);const c={nodes:[],edges:[]};return s.nodes().forEach(f=>{const l=s.node(f);c.nodes.push({id:f,data:l}),r&&t.mergeNodeData(f,l)}),s.edges().forEach(f=>{const l=s.edge(f),{id:p}=l,m=Oe(l,["id"]),{v:y,w:x}=f;c.edges.push({id:p,source:y,target:x,data:m}),r&&t.mergeEdgeData(p,m)}),c})}}Hr.defaultOptions={};class xc{constructor(r){this.id=r.id||0,this.rx=r.rx,this.ry=r.ry,this.fx=0,this.fy=0,this.mass=r.mass,this.degree=r.degree,this.g=r.g||0}distanceTo(r){const t=this.rx-r.rx,n=this.ry-r.ry;return Math.hypot(t,n)}setPos(r,t){this.rx=r,this.ry=t}resetForce(){this.fx=0,this.fy=0}addForce(r){const t=r.rx-this.rx,n=r.ry-this.ry;let i=Math.hypot(t,n);i=i<1e-4?1e-4:i;const s=this.g*(this.degree+1)*(r.degree+1)/i;this.fx+=s*t/i,this.fy+=s*n/i}in(r){return r.contains(this.rx,this.ry)}add(r){const t=this.mass+r.mass,n=(this.rx*this.mass+r.rx*r.mass)/t,i=(this.ry*this.mass+r.ry*r.mass)/t,s=this.degree+r.degree,a={rx:n,ry:i,mass:t,degree:s};return new xc(a)}}class Ht{constructor(r){this.xmid=r.xmid,this.ymid=r.ymid,this.length=r.length,this.massCenter=r.massCenter||[0,0],this.mass=r.mass||1}getLength(){return this.length}contains(r,t){const n=this.length/2;return r<=this.xmid+n&&r>=this.xmid-n&&t<=this.ymid+n&&t>=this.ymid-n}NW(){const r=this.xmid-this.length/4,t=this.ymid+this.length/4,n=this.length/2,i={xmid:r,ymid:t,length:n};return new Ht(i)}NE(){const r=this.xmid+this.length/4,t=this.ymid+this.length/4,n=this.length/2,i={xmid:r,ymid:t,length:n};return new Ht(i)}SW(){const r=this.xmid-this.length/4,t=this.ymid-this.length/4,n=this.length/2,i={xmid:r,ymid:t,length:n};return new Ht(i)}SE(){const r=this.xmid+this.length/4,t=this.ymid-this.length/4,n=this.length/2,i={xmid:r,ymid:t,length:n};return new Ht(i)}}class er{constructor(r){this.body=null,this.quad=null,this.NW=null,this.NE=null,this.SW=null,this.SE=null,this.theta=.5,r!=null&&(this.quad=r)}insert(r){if(this.body==null){this.body=r;return}this._isExternal()?(this.quad&&(this.NW=new er(this.quad.NW()),this.NE=new er(this.quad.NE()),this.SW=new er(this.quad.SW()),this.SE=new er(this.quad.SE())),this._putBody(this.body),this._putBody(r),this.body=this.body.add(r)):(this.body=this.body.add(r),this._putBody(r))}_putBody(r){this.quad&&(r.in(this.quad.NW())&&this.NW?this.NW.insert(r):r.in(this.quad.NE())&&this.NE?this.NE.insert(r):r.in(this.quad.SW())&&this.SW?this.SW.insert(r):r.in(this.quad.SE())&&this.SE&&this.SE.insert(r))}_isExternal(){return this.NW==null&&this.NE==null&&this.SW==null&&this.SE==null}updateForce(r){if(!(this.body==null||r===this.body))if(this._isExternal())r.addForce(this.body);else{const t=this.quad?this.quad.getLength():0,n=this.body.distanceTo(r);t/nit(w,[o,c])),x=i.filter(w=>{const{source:E,target:N}=w;return E!==N}),_=new Be({nodes:y,edges:x}),b=this.getSizes(_,p);if(this.run(_,t,l,b,r,a),f){for(let E=0;E250&&(n.barnesHut=!0),c===void 0&&t>100&&(n.prune=!0),f===0&&!c?(n.maxIteration=250,t<=200&&t>100?n.maxIteration=1e3:t>200&&(n.maxIteration=1200)):f===0&&c&&(n.maxIteration=100,t<=200&&t>100?n.maxIteration=500:t>200&&(n.maxIteration=950)),l||(n.kr=50,t>100&&t<=500?n.kr=20:t>500&&(n.kr=1)),p||(n.kg=20,t>100&&t<=500?n.kg=10:t>500&&(n.kg=1)),n}run(r,t,n,i,s,a){const{kr:o,barnesHut:c,onTick:f}=a,l=r.getAllNodes();let p=0,m=n;const y={},x={},_={};for(let b=0;b0;)p=this.oneStep(r,{iter:m,preventOverlapIters:50,krPrime:100,sg:p,forces:y,preForces:x,bodies:_,sizes:i},a),m--,f==null||f({nodes:l,edges:t.getAllEdges()});return r}oneStep(r,t,n){const{iter:i,preventOverlapIters:s,krPrime:a,sg:o,preForces:c,bodies:f,sizes:l}=t;let{forces:p}=t;const{preventOverlap:m,barnesHut:y}=n,x=r.getAllNodes();for(let _=0;_s||!m)?p=this.getOptRepGraForces(r,p,f,n):p=this.getRepGraForces(r,i,s,p,a,l,n),this.updatePos(r,p,c,o,n)}getAttrForces(r,t,n,i,s,a){const{preventOverlap:o,dissuadeHubs:c,mode:f,prune:l}=a,p=r.getAllEdges();for(let m=0;m0&&(R=S,A=S),s[y][0]+=R*N[0],s[x][0]-=A*N[0],s[y][1]+=R*N[1],s[x][1]-=A*N[1]}return s}getOptRepGraForces(r,t,n,i){const{kg:s,center:a,prune:o}=i,c=r.getAllNodes(),f=c.length;let l=9e10,p=-9e10,m=9e10,y=-9e10;for(let E=0;E=p&&(p=S.x),S.x<=l&&(l=S.x),S.y>=y&&(y=S.y),S.y<=m&&(m=S.y))}const x=Math.max(p-l,y-m),_={xmid:(p+l)/2,ymid:(y+m)/2,length:x,massCenter:a,mass:f},b=new Ht(_),w=new er(b);for(let E=0;E0&&(z=f*(w+1)*(j+1)/D),i[b.id][0]-=z*I[0],i[A.id][0]+=z*I[0],i[b.id][1]-=z*I[1],i[A.id][1]+=z*I[1]}const E=[b.data.x-p[0],b.data.y-p[1]],N=Math.hypot(E[0],E[1]);E[0]=E[0]/N,E[1]=E[1]/N;const S=l*(w+1);i[b.id][0]-=S*E[0],i[b.id][1]-=S*E[1]}return i}updatePos(r,t,n,i,s){const{ks:a,tao:o,prune:c,ksmax:f}=s,l=r.getAllNodes(),p=l.length,m=[],y=[];let x=0,_=0,b=i;for(let E=0;E1.5*w?1.5*w:b);for(let E=0;EI?I:A;const D=A*t[N][0],z=A*t[N][1];r.mergeNodeData(N,{x:S.x+D,y:S.y+z})}return b}}const yx={maxIteration:1e3,gravity:10,speed:5,clustering:!1,clusterGravity:10,width:300,height:300,nodeClusterBy:"cluster"},wx=800;class bx{constructor(r={}){this.options=r,this.id="fruchterman",this.timeInterval=0,this.running=!1,this.options=Object.assign(Object.assign({},yx),r)}execute(r,t){return fe(this,void 0,void 0,function*(){return this.genericFruchtermanLayout(!1,r,t)})}assign(r,t){return fe(this,void 0,void 0,function*(){yield this.genericFruchtermanLayout(!0,r,t)})}stop(){this.timeInterval&&typeof window<"u"&&window.clearInterval(this.timeInterval),this.running=!1}tick(r=this.options.maxIteration||1){if(this.lastResult)return this.lastResult;for(let n=0;nthis.lastGraph.mergeNodeData(n.id,{x:n.data.x,y:n.data.y,z:this.options.dimensions===3?n.data.z:void 0})),t}genericFruchtermanLayout(r,t,n){return fe(this,void 0,void 0,function*(){if(this.running)return;const i=this.formatOptions(n),{dimensions:s,width:a,height:o,center:c,clustering:f,nodeClusterBy:l,maxIteration:p,onTick:m}=i,y=t.getAllNodes(),x=t.getAllEdges();if(!(y!=null&&y.length)){const N={nodes:[],edges:x};return this.lastResult=N,N}if(y.length===1){r&&t.mergeNodeData(y[0].id,{x:c[0],y:c[1],z:s===3?c[2]:void 0});const N={nodes:[Object.assign(Object.assign({},y[0]),{data:Object.assign(Object.assign({},y[0].data),{x:c[0],y:c[1],z:s===3?c[2]:void 0})})],edges:x};return this.lastResult=N,N}const _=y.map(N=>it(N,[a,o])),b=new Be({nodes:_,edges:x}),w={};if(f&&_.forEach(N=>{const S=N.data[l];w[S]||(w[S]={name:S,cx:0,cy:0,count:0})}),this.lastLayoutNodes=_,this.lastLayoutEdges=x,this.lastAssign=r,this.lastGraph=b,this.lastOptions=i,this.lastClusterMap=w,typeof window>"u")return;let E=0;return new Promise(N=>{this.timeInterval=window.setInterval(()=>{if(!this.running){N({nodes:_,edges:x});return}this.runOneStep(b,w,i),r&&_.forEach(({id:S,data:R})=>t.mergeNodeData(S,{x:R.x,y:R.y,z:s===3?R.z:void 0})),m==null||m({nodes:_,edges:x}),E++,E>=p&&(window.clearInterval(this.timeInterval),N({nodes:_,edges:x}))},0),this.running=!0})})}formatOptions(r={}){const t=Object.assign(Object.assign({},this.options),r),{clustering:n,nodeClusterBy:i}=t,{center:s,width:a,height:o}=t;return t.width=!a&&typeof window<"u"?window.innerWidth:a,t.height=!o&&typeof window<"u"?window.innerHeight:o,t.center=s||[t.width/2,t.height/2],t.clustering=n&&!!i,t}runOneStep(r,t,n){const{dimensions:i,height:s,width:a,gravity:o,center:c,speed:f,clustering:l,nodeClusterBy:p,clusterGravity:m}=n,y=s*a,x=Math.sqrt(y)/10,_=r.getAllNodes(),b=y/(_.length+1),w=Math.sqrt(b),E={};if(this.applyCalculate(r,E,w,b),l){for(const S in t)t[S].cx=0,t[S].cy=0,t[S].count=0;_.forEach(S=>{const{data:R}=S,A=t[R[p]];me(R.x)&&(A.cx+=R.x),me(R.y)&&(A.cy+=R.y),A.count++});for(const S in t)t[S].cx/=t[S].count,t[S].cy/=t[S].count;const N=m||o;_.forEach((S,R)=>{const{id:A,data:j}=S;if(!me(j.x)||!me(j.y))return;const I=t[j[p]],D=Math.sqrt((j.x-I.cx)*(j.x-I.cx)+(j.y-I.cy)*(j.y-I.cy)),z=w*N;E[A].x-=z*(j.x-I.cx)/D,E[A].y-=z*(j.y-I.cy)/D})}_.forEach((N,S)=>{const{id:R,data:A}=N;if(!me(A.x)||!me(A.y))return;const j=.01*w*o;E[R].x-=j*(A.x-c[0]),E[R].y-=j*(A.y-c[1]),i===3&&(E[R].z-=j*(A.z-c[2]))}),_.forEach((N,S)=>{const{id:R,data:A}=N;if(me(A.fx)&&me(A.fy)){A.x=A.fx,A.y=A.fy,i===3&&(A.z=A.fz);return}if(!me(A.x)||!me(A.y))return;const j=Math.sqrt(E[R].x*E[R].x+E[R].y*E[R].y+(i===3?E[R].z*E[R].z:0));if(j>0){const I=Math.min(x*(f/wx),j);r.mergeNodeData(R,{x:A.x+E[R].x/j*I,y:A.y+E[R].y/j*I,z:i===3?A.z+E[R].z/j*I:void 0})}})}applyCalculate(r,t,n,i){this.calRepulsive(r,t,i),this.calAttractive(r,t,n)}calRepulsive(r,t,n){const i=r.getAllNodes();i.forEach(({data:s,id:a},o)=>{t[a]={x:0,y:0,z:0},i.forEach(({data:c,id:f},l)=>{if(o<=l||!me(s.x)||!me(c.x)||!me(s.y)||!me(c.y))return;let p=s.x-c.x,m=s.y-c.y,y=this.options.dimensions===3?s.z-c.z:0,x=p*p+m*m+y*y;x===0&&(x=1,p=.01,m=.01,y=.01);const _=n/x,b=p*_,w=m*_,E=y*_;t[a].x+=b,t[a].y+=w,t[f].x-=b,t[f].y-=w,this.options.dimensions===3&&(t[a].z+=E,t[f].z-=E)})})}calAttractive(r,t,n){r.getAllEdges().forEach(s=>{const{source:a,target:o}=s;if(!a||!o||a===o)return;const{data:c}=r.getNode(a),{data:f}=r.getNode(o);if(!me(f.x)||!me(c.x)||!me(f.y)||!me(c.y))return;const l=f.x-c.x,p=f.y-c.y,m=this.options.dimensions===3?f.z-c.z:0,y=Math.sqrt(l*l+p*p+m*m)/n,x=l*y,_=p*y,b=m*y;t[a].x+=x,t[a].y+=_,t[o].x-=x,t[o].y-=_,this.options.dimensions===3&&(t[a].z+=b,t[o].z-=b)})}}const _x={begin:[0,0],preventOverlap:!0,preventOverlapPadding:10,condense:!1,rows:void 0,cols:void 0,position:void 0,sortBy:"degree",nodeSize:30,width:300,height:300};class Ex{constructor(r={}){this.options=r,this.id="grid",this.options=Object.assign(Object.assign({},_x),r)}execute(r,t){return fe(this,void 0,void 0,function*(){return this.genericGridLayout(!1,r,t)})}assign(r,t){return fe(this,void 0,void 0,function*(){yield this.genericGridLayout(!0,r,t)})}genericGridLayout(r,t,n){return fe(this,void 0,void 0,function*(){const i=Object.assign(Object.assign({},this.options),n),{begin:s=[0,0],condense:a,preventOverlapPadding:o,preventOverlap:c,rows:f,cols:l,nodeSpacing:p,nodeSize:m,width:y,height:x,position:_}=i;let{sortBy:b}=i;const w=t.getAllNodes(),E=t.getAllEdges(),N=w==null?void 0:w.length;if(!N||N===1)return Pt(t,r,s);const S=w.map(J=>it(J));b!=="id"&&(!nr(b)||S[0].data[b]===void 0)&&(b="degree"),b==="degree"?S.sort((J,ae)=>t.getDegree(ae.id,"both")-t.getDegree(J.id,"both")):b==="id"?S.sort((J,ae)=>me(ae.id)&&me(J.id)?ae.id-J.id:`${J.id}`.localeCompare(`${ae.id}`)):S.sort((J,ae)=>ae.data[b]-J.data[b]);const R=!y&&typeof window<"u"?window.innerWidth:y,A=!x&&typeof window<"u"?window.innerHeight:x,j=N,I={rows:f,cols:l};if(f!=null&&l!=null)I.rows=f,I.cols=l;else if(f!=null&&l==null)I.rows=f,I.cols=Math.ceil(j/I.rows);else if(f==null&&l!=null)I.cols=l,I.rows=Math.ceil(j/I.cols);else{const J=Math.sqrt(j*A/R);I.rows=Math.round(J),I.cols=Math.round(R/A*J)}if(I.rows=Math.max(I.rows,1),I.cols=Math.max(I.cols,1),I.cols*I.rows>j){const J=en(I),ae=tn(I);(J-1)*ae>=j?en(I,J-1):(ae-1)*J>=j&&tn(I,ae-1)}else for(;I.cols*I.rows=j?tn(I,ae+1):en(I,J+1)}let D=a?0:R/I.cols,z=a?0:A/I.rows;if(c||p){const J=Ct(10,p),ae=Sn(30,m,!1);S.forEach(be=>{(!be.data.x||!be.data.y)&&(be.data.x=0,be.data.y=0);const Z=t.getNode(be.id),[ue,pe]=sr(ae(Z)||30),he=J!==void 0?J(be):o,ie=ue+he,_e=pe+he;D=Math.max(D,ie),z=Math.max(z,_e)})}const $={},V={row:0,col:0},Y={};for(let J=0;J{t.mergeNodeData(J.id,{x:J.data.x,y:J.data.y})}),ee})}}const en=(e,r)=>{let t;const n=e.rows||5,i=e.cols||5;return r==null?t=Math.min(n,i):Math.min(n,i)===e.rows?e.rows=r:e.cols=r,t},tn=(e,r)=>{let t;const n=e.rows||5,i=e.cols||5;return r==null?t=Math.max(n,i):Math.max(n,i)===e.rows?e.rows=r:e.cols=r,t},Nc=(e,r)=>e[`c-${r.row}-${r.col}`]||!1,w0=(e,r)=>e[`c-${r.row}-${r.col}`]=!0,b0=(e,r)=>{const t=e.cols||5;r.col++,r.col>=t&&(r.col=0,r.row++)},xx=(e,r,t,n,i,s,a,o)=>{let c,f;const l=i[e.id];if(l)c=l.col*t+t/2+r[0],f=l.row*n+n/2+r[1];else{for(;Nc(o,a);)b0(s,a);c=a.col*t+t/2+r[0],f=a.row*n+n/2+r[1],w0(o,a),b0(s,a)}e.data.x=c,e.data.y=f},Nx=(e,r,t)=>{try{const n=At.mul(At.pow(r,2),-.5),i=n.mean("row"),s=n.mean("column"),a=n.mean();n.add(a).subRowVector(i).subColumnVector(s);const o=new kf(n),c=At.sqrt(o.diagonalMatrix).diagonal();return o.leftSingularVectors.toJSON().map(f=>At.mul([f],[c]).toJSON()[0].splice(0,e))}catch{const i=[];for(let s=0;s{const t=Object.assign(Object.assign({},Sx),r),{positions:n,iterations:i,width:s,k:a,speed:o=100,strictRadial:c,focusIdx:f,radii:l=[],nodeSizeFunc:p}=t,m=e.getAllNodes(),y=[],x=s/10;for(let _=0;_{y[w]={x:0,y:0}}),Rx(m,n,y,a,l,p),Ox(n,y,o,c,f,x,s,l);return n},Rx=(e,r,t,n,i,s)=>{r.forEach((a,o)=>{t[o]={x:0,y:0},r.forEach((c,f)=>{if(o===f||i[o]!==i[f])return;let l=a.x-c.x,p=a.y-c.y,m=Math.sqrt(l*l+p*p);if(m===0){m=1;const y=o>f?1:-1;l=.01*y,p=.01*y}if(m{const c=s||a/10;return n&&r.forEach((f,l)=>{const p=e[l].x-e[i].x,m=e[l].y-e[i].y,y=Math.sqrt(p*p+m*m);let x=m/y,_=-p/y;const b=Math.sqrt(f.x*f.x+f.y*f.y);let w=Math.acos((x*f.x+_*f.y)/b);w>Math.PI/2&&(w-=Math.PI/2,x*=-1,_*=-1);const E=Math.cos(w)*b;f.x=x*E,f.y=_*E}),e.forEach((f,l)=>{if(l===i)return;const p=Math.sqrt(r[l].x*r[l].x+r[l].y*r[l].y);if(p>0&&l!==i){const m=Math.min(c*(t/Mx),p);if(f.x+=r[l].x/p*m,f.y+=r[l].y/p*m,n){let y=f.x-e[i].x,x=f.y-e[i].y;const _=Math.sqrt(y*y+x*x);y=y/_*o[l],x=x/_*o[l],f.x=e[i].x+y,f.y=e[i].y+x}}}),e},Ax={maxIteration:1e3,focusNode:null,unitRadius:null,linkDistance:50,preventOverlap:!1,strictRadial:!0,maxPreventOverlapIteration:200,sortStrength:10};class Ix{constructor(r={}){this.options=r,this.id="radial",this.options=Object.assign(Object.assign({},Ax),r)}execute(r,t){return fe(this,void 0,void 0,function*(){return this.genericRadialLayout(!1,r,t)})}assign(r,t){return fe(this,void 0,void 0,function*(){yield this.genericRadialLayout(!0,r,t)})}genericRadialLayout(r,t,n){return fe(this,void 0,void 0,function*(){const i=Object.assign(Object.assign({},this.options),n),{width:s,height:a,center:o,focusNode:c,unitRadius:f,nodeSize:l,nodeSpacing:p,strictRadial:m,preventOverlap:y,maxPreventOverlapIteration:x,sortBy:_,linkDistance:b=50,sortStrength:w=10,maxIteration:E=1e3}=i,N=t.getAllNodes(),S=t.getAllEdges(),R=!s&&typeof window<"u"?window.innerWidth:s,A=!a&&typeof window<"u"?window.innerHeight:a,j=o||[R/2,A/2];if(!(N!=null&&N.length)||N.length===1)return Pt(t,r,j);let I=N[0];if(nr(c)){for(let te=0;tej[0]?j[0]:R-j[0],J=A-j[1]>j[1]?j[1]:A-j[1];ee===0&&(ee=R/2),J===0&&(J=A/2);const ae=Math.min(ee,J),be=Math.max(...Y),Z=[],ue=f||ae/be;Y.forEach((te,le)=>{Z[le]=te*ue});const pe=Tx(N,$,b,Z,ue,_,w),he=kx(pe),ie=Nx(b,pe,b);let _e=ie.map(([te,le])=>({x:(isNaN(te)?Math.random()*b:te)-ie[D][0],y:(isNaN(le)?Math.random()*b:le)-ie[D][1]}));this.run(E,_e,he,pe,Z,D);let G;if(y){G=qn(l,p);const te={nodes:N,nodeSizeFunc:G,positions:_e,radii:Z,height:A,width:R,strictRadial:!!m,focusIdx:D,iterations:x||200,k:_e.length/4.5};_e=qx(t,te)}const P=[];return _e.forEach((te,le)=>{const xe=it(N[le]);xe.data.x=te.x+j[0],xe.data.y=te.y+j[1],P.push(xe)}),r&&P.forEach(te=>t.mergeNodeData(te.id,{x:te.data.x,y:te.data.y})),{nodes:P,edges:S}})}run(r,t,n,i,s,a){for(let o=0;o<=r;o++){const c=o/r;this.oneIteration(c,t,s,i,n,a)}}oneIteration(r,t,n,i,s,a){const o=1-r;t.forEach((c,f)=>{const l=bf(c,{x:0,y:0}),p=l===0?0:1/l;if(f===a)return;let m=0,y=0,x=0;t.forEach((b,w)=>{if(f===w)return;const E=bf(c,b),N=E===0?0:1/E,S=i[w][f];x+=s[f][w],m+=s[f][w]*(b.x+S*(c.x-b.x)*N),y+=s[f][w]*(b.y+S*(c.y-b.y)*N)});const _=n[f]===0?0:1/n[f];x*=o,x+=r*_*_,m*=o,m+=r*_*c.x*p,c.x=m/x,y*=o,y+=r*_*c.y*p,c.y=y/x})}}const Tx=(e,r,t,n,i,s,a)=>{if(!e)return[];const o=[];{const c={};r.forEach((f,l)=>{const p=[];f.forEach((m,y)=>{var x,_;if(l===y)p.push(0);else if(n[l]===n[y])if(s==="data")p.push(m*(Math.abs(l-y)*a)/(n[l]/i));else if(s){let b,w;if(c[e[l].id])b=c[e[l].id];else{const E=(s==="id"?e[l].id:(x=e[l].data)===null||x===void 0?void 0:x[s])||0;nr(E)?b=E.charCodeAt(0):b=E,c[e[l].id]=b}if(c[e[y].id])w=c[e[y].id];else{const E=(s==="id"?e[y].id:(_=e[y].data)===null||_===void 0?void 0:_[s])||0;nr(E)?w=E.charCodeAt(0):w=E,c[e[y].id]=w}p.push(m*(Math.abs(b-w)*a)/(n[l]/i))}else p.push(m*t/(n[l]/i));else{const b=(t+i)/2;p.push(m*b)}}),o.push(p)})}return o},kx=e=>{const r=e.length,t=e[0].length,n=[];for(let i=0;i{let t=-1;return e.forEach((n,i)=>{n.id===r&&(t=i)}),Math.max(t,0)},Cx=(e,r,t)=>{const n=e.length;for(let i=0;i{let t=0;for(let n=0;nt?e[r][n]:t);return t},Lx={center:[0,0],width:300,height:300};class Dx{constructor(r={}){this.options=r,this.id="random",this.options=Object.assign(Object.assign({},Lx),r)}execute(r,t){return fe(this,void 0,void 0,function*(){return this.genericRandomLayout(!1,r,t)})}assign(r,t){return fe(this,void 0,void 0,function*(){yield this.genericRandomLayout(!0,r,t)})}genericRandomLayout(r,t,n){return fe(this,void 0,void 0,function*(){const i=Object.assign(Object.assign({},this.options),n),{center:s,width:a,height:o}=i,c=t.getAllNodes(),f=.9,l=!a&&typeof window<"u"?window.innerWidth:a,p=!o&&typeof window<"u"?window.innerHeight:o,m=s||[l/2,p/2],y=[];return c&&c.forEach(_=>{y.push({id:_.id,data:{x:(Math.random()-.5)*f*l+m[0],y:(Math.random()-.5)*f*p+m[1]}})}),r&&y.forEach(_=>t.mergeNodeData(_.id,{x:_.data.x,y:_.data.y})),{nodes:y,edges:t.getAllEdges()}})}}const zx={circular:By,concentric:Rn,mds:jf,random:Dx,grid:Ex,radial:Ix,force:Sf,d3force:Uf,"d3-force-3d":H1,fruchterman:bx,forceAtlas2:mx,dagre:Hr,antvDagre:Dy,comboCombined:Xw};let Nt;dn({stopLayout(){Nt!=null&&Nt.stop&&Nt.stop()},calculateLayout(e,r){return fe(this,void 0,void 0,function*(){const{layout:{id:t,options:n,iterations:i},nodes:s,edges:a}=e,o=new Be({nodes:s,edges:a}),c=zx[t];if(c)Nt=new c(n);else throw new Error(`Unknown layout id: ${t}`);let f=yield Nt.execute(o);return Cf(Nt)&&(Nt.stop(),f=Nt.tick(i)),[f,r]})}})})();