worker-De2MZRr5.js 304 KB

12345678910111213
  1. 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<n.length;i++)r.indexOf(n[i])<0&&Object.prototype.propertyIsEnumerable.call(e,n[i])&&(t[n[i]]=e[n[i]]);return t}function fe(e,r,t,n){function i(s){return s instanceof t?s:new t(function(a){a(s)})}return new(t||(t=Promise))(function(s,a){function o(l){try{f(n.next(l))}catch(p){a(p)}}function c(l){try{f(n.throw(l))}catch(p){a(p)}}function f(l){l.done?s(l.value):i(l.value).then(o,c)}f((n=n.apply(e,r||[])).next())})}typeof SuppressedError=="function"&&SuppressedError;var Fe="*",br=function(){function e(){this._events={}}return e.prototype.on=function(r,t,n){return this._events[r]||(this._events[r]=[]),this._events[r].push({callback:t,once:!!n}),this},e.prototype.once=function(r,t){return this.on(r,t,!0)},e.prototype.emit=function(r){for(var t=this,n=[],i=1;i<arguments.length;i++)n[i-1]=arguments[i];var s=this._events[r]||[],a=this._events[Fe]||[],o=function(c){for(var f=c.length,l=0;l<f;l++)if(c[l]){var p=c[l],m=p.callback,y=p.once;y&&(c.splice(l,1),c.length===0&&delete t._events[r],f--,l--),m.apply(t,n)}};o(s),o(a)},e.prototype.off=function(r,t){if(!r)this._events={};else if(!t)delete this._events[r];else{for(var n=this._events[r]||[],i=n.length,s=0;s<i;s++)n[s].callback===t&&(n.splice(s,1),i--,s--);n.length===0&&delete this._events[r]}return this},e.prototype.getEvents=function(){return this._events},e}();function ln(e,r,t,n){for(;e.length;){const i=e.shift();if(t(i))return!0;r.add(i.id),n(i.id).forEach(a=>{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})}}/**
  2. * @license
  3. * Copyright 2019 Google LLC
  4. * SPDX-License-Identifier: Apache-2.0
  5. */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<i&&(t=r(e[n],n),t!==!1);n++);else if(Ut(e)){for(var s in e)if(e.hasOwnProperty(s)&&(t=r(e[s],s),t===!1))break}}}var F0=function(e){return typeof e=="object"&&e!==null},B0={}.toString,$0=function(e,r){return B0.call(e)==="[object "+r+"]"},vn=function(e){if(!F0(e)||!$0(e,"Object"))return!1;if(Object.getPrototypeOf(e)===null)return!0;for(var r=e;Object.getPrototypeOf(r)!==null;)r=Object.getPrototypeOf(r);return Object.getPrototypeOf(e)===r};function nr(e){return typeof e=="string"}function me(e){return typeof e=="number"}var qr=function(e){if(typeof e!="object"||e===null)return e;var r;if(pn(e)){r=[];for(var t=0,n=e.length;t<n;t++)typeof e[t]=="object"&&e[t]!=null?r[t]=qr(e[t]):r[t]=e[t]}else{r={};for(var i in e)typeof e[i]=="object"&&e[i]!=null?r[i]=qr(e[i]):r[i]=e[i]}return r},G0=5;function U0(e,r){if(Object.hasOwn)return Object.hasOwn(e,r);if(e==null)throw new TypeError("Cannot convert undefined or null to object");return Object.prototype.hasOwnProperty.call(Object(e),r)}function zc(e,r,t,n){t=t||0,n=n||G0;for(var i in r)if(U0(r,i)){var s=r[i];s!==null&&vn(s)?(vn(e[i])||(e[i]={}),t<n?zc(e[i],s,t+1,n):e[i]=r[i]):pn(s)?(e[i]=[],e[i]=e[i].concat(s)):s!==void 0&&(e[i]=s)}}var Fc=function(e){for(var r=[],t=1;t<arguments.length;t++)r[t-1]=arguments[t];for(var n=0;n<r.length;n+=1)zc(e,r[n]);return e},V0=Object.prototype.hasOwnProperty,Bc=function(e,r){if(e===null||!vn(e))return{};var t={};return z0(r,function(n){V0.call(e,n)&&(t[n]=e[n])}),t};const W0=(e,r)=>{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<a;c++)s.push(new K0);const o=n+1;return t.getAllNodes().forEach(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<t;n++)r.push([]);e.getAllNodes().forEach(n=>{const i=n.data.rank;i!==void 0&&r[i]&&r[i].push(n.id)});for(let n=0;n<t;n++)r[n]=r[n].sort((i,s)=>tm(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<s.length;o++){const c=s[o];c===void 0?o%r!==0&&(a-=1):a&&(c==null||c.forEach(f=>{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;s<a;s+=1)Xc(e,"borderLeft","_bl",t,i,s),Xc(e,"borderRight","_br",t,i,s)}};e.getRoots().forEach(t=>r(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<a;++l,++i)r.data.points=[],f={originalEdge:r,width:0,height:0,rank:i},c=Vt(e,vm,f,"_d"),i===o&&(f.width=r.data.width,f.height=r.data.height,f.dummy=Hc,f.labelpos=r.data.labelpos),e.addEdge({id:`e${Math.random()}`,source:n,target:c,data:{weight:r.data.weight}}),l===0&&t.push(c),n=c;e.addEdge({id:`e${Math.random()}`,source:n,target:s,data:{weight:r.data.weight}})},wm=(e,r)=>{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<t.length;)a<<=1;const o=2*a-1;a-=1;const c=Array(o).fill(0,0,o);let f=0;return s==null||s.forEach(l=>{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;f<i+1;f++)s.push([]);const a=t.sort((f,l)=>e.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.barycenter<n.barycenter)return-1;if(t.barycenter>n.barycenter)return 1;if(r&&t.order!==void 0&&n.order!==void 0){if(t.order<n.order)return-1;if(t.order>n.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<t+1;l++)n.push(l);for(let l=t-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<c&&(p=0,f=qr(o),c=m)}o=tf(e),En(e,o);for(let l=0,p=0;p<4;++l,++p){of(l%2?s:a,l%4>=2,!0,r),o=ir(e);const m=ef(e,o);m<c&&(p=0,f=qr(o),c=m)}En(e,f)},sf=(e,r,t)=>r.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<i+1;a++)s[a]=[];r==null||r.forEach(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)<o.data.rank;)m++,y=l[m];y===p&&(x=!1)}if(!x){for(;m<l.length-1&&((s=e.getNode(l[m+1]))===null||s===void 0?void 0:s.data.minRank)<=o.data.rank;)m++;y=l[m]}e.hasNode(y)&&e.setParent(a,y),a=e.getSuccessors(a)[0].id}})},Lm=(e,r)=>{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<a||x<S)&&!(N.data.dummy&&(!((E=e.getNode(_))===null||E===void 0)&&E.data.dummy))&&af(t,w.id,_)})}),o=p+1,a=x)}),s};return r!=null&&r.length&&r.reduce(n),t},Dm=(e,r)=>{const t={};function n(o,c,f,l,p){var m,y;let x;for(let _=c;_<f;_++)x=o[_],!((m=e.getNode(x))===null||m===void 0)&&m.data.dummy&&((y=e.getPredecessors(x))===null||y===void 0||y.forEach(b=>{const w=e.getNode(b.id);w.data.dummy&&(w.data.order<l||w.data.order>p)&&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<a[x]&&!Fm(t,f,x)&&(s[x]=f,s[f]=i[f]=i[x],c=a[x])}}})}),{root:i,align:s}},$m=(e,r,t,n,i,s,a)=>{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||l<a)&&(a=l)}),a||(a=0),s.data.rank=a,a};e.getAllNodes().filter(n=>e.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||y<f)&&(f=y)}),f||(f=0),(t===void 0||f<t)&&(t=f),c.data.rank=f,f};e.getAllNodes().filter(a=>e.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<l)&&(f.data.rank=l),!i[a]&&(i[a]=!0,(c=e.getRelatedEdges(a,"out"))===null||c===void 0||c.forEach(p=>{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)<n;)i=cf(r,e),s=r.hasNode(i.source)?Ot(e,i):-Ot(e,i),ff(r,e,s);return r},ey=(e,r)=>{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)<n;)i=cf(r,e),s=r.hasNode(i.source)?Ot(e,i):-Ot(e,i),ff(r,e,s);return r},ry=(e,r)=>{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:
  6. `,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;n<t;n+=1){r[n]=[];for(let i=0;i<t;i+=1)n===i?r[n][i]=0:e[n][i]===0||!e[n][i]?r[n][i]=1/0:r[n][i]=e[n][i]}for(let n=0;n<t;n+=1)for(let i=0;i<t;i+=1)for(let s=0;s<t;s+=1)r[i][s]>r[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),n<f&&(n=f),i<p&&(i=p)}),{minX:r,minY:t,maxX:n,maxY:i}},bf=(e,r)=>Math.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<r.length;c++){const f=r[c];if(e.hasNode(f.id)&&!(a!=null&&a(f))){if(o!=null&&o(f))return;n==="TB"&&t(f),Nn(e,e.getChildren(f.id,i),t,n,i,s),n!=="TB"&&t(f)}}},Mn=e=>{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&&(ae=ue)});let be=0;b.forEach((Z,ue)=>{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<R;++ee){let J=j;!J&&I!==null&&D!==null&&(J=I+ee*(D-I)/(R-1)),J||(J=10+ee*100/(R-1));let ae=f+ee%V*z+2*Math.PI/c*Math.floor(ee/V);y||(ae=l-ee%V*z-2*Math.PI/c*Math.floor(ee/V)),$[ee].data.x=S[0]+Math.cos(ae)*J,$[ee].data.y=S[1]+Math.sin(ae)*J}return r&&$.forEach(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<f.length;m++){const y=f[m];if(e.getDegree(y.id)===e.getDegree(o.id)&&!i[y.id]){n.push(it(y)),i[y.id]=!0,l=!0;break}}let p=0;for(;!l&&(i[r[p].id]||(n.push(it(r[p])),i[r[p].id]=!0,l=!0),p++,p!==s););}}),n};function $y(e,r){const t=[];return r.forEach((n,i)=>{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<Y.length;pe++){const ie=(Y[pe].r||0)-ue;Z=Math.max(Z,ie)}ue=0,Y.forEach((pe,he)=>{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;t<n;++t)isNaN(i=+this._x.call(null,r=e[t]))||isNaN(s=+this._y.call(null,r))||(a[t]=i,o[t]=s,i<c&&(c=i),i>l&&(l=i),s<f&&(f=s),s>p&&(p=s));if(c>l||f>p)return this;for(this.cover(c,f).cover(l,p),t=0;t<n;++t)Ef(this,a[t],o[t],e[t]);return this}function Yy(e,r){if(isNaN(e=+e)||isNaN(r=+r))return this;var t=this._x0,n=this._y0,i=this._x1,s=this._y1;if(isNaN(t))i=(t=Math.floor(e))+1,s=(n=Math.floor(r))+1;else{for(var a=i-t||1,o=this._root,c,f;t>e||e>=i||n>r||r>=s;)switch(f=(r<n)<<1|e<t,c=new Array(4),c[f]=o,o=c,a*=2,f){case 0:i=t+a,s=n+a;break;case 1:t=i-a,s=n+a;break;case 2:i=t+a,n=s-a;break;case 3:t=i-a,n=s-a;break}this._root&&this._root.length&&(this._root=o)}return this._x0=t,this._y0=n,this._x1=i,this._y1=s,this}function Ky(){var e=[];return this.visit(function(r){if(!r.length)do e.push(r.data);while(r=r.next)}),e}function Xy(e){return arguments.length?this.cover(+e[0][0],+e[0][1]).cover(+e[1][0],+e[1][1]):isNaN(this._x0)?void 0:[[this._x0,this._y0],[this._x1,this._y1]]}function et(e,r,t,n,i){this.node=e,this.x0=r,this.y0=t,this.x1=n,this.y1=i}function Zy(e,r,t){var n,i=this._x0,s=this._y0,a,o,c,f,l=this._x1,p=this._y1,m=[],y=this._root,x,_;for(y&&m.push(new et(y,i,s,l,p)),t==null?t=1/0:(i=e-t,s=r-t,l=e+t,p=r+t,t*=t);x=m.pop();)if(!(!(y=x.node)||(a=x.x0)>l||(o=x.y0)>p||(c=x.x1)<i||(f=x.y1)<s))if(y.length){var b=(a+c)/2,w=(o+f)/2;m.push(new et(y[3],b,w,c,f),new et(y[2],a,w,b,f),new et(y[1],b,o,c,w),new et(y[0],a,o,b,w)),(_=(r>=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<t){var R=Math.sqrt(t=S);i=e-R,s=r-R,l=e+R,p=r+R,n=y.data}}return n}function Jy(e){if(isNaN(l=+this._x.call(null,e))||isNaN(p=+this._y.call(null,e)))return this;var r,t=this._root,n,i,s,a=this._x0,o=this._y0,c=this._x1,f=this._y1,l,p,m,y,x,_,b,w;if(!t)return this;if(t.length)for(;;){if((x=l>=(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<t;++r)this.remove(e[r]);return this}function Hy(){return this._root}function ew(){var e=0;return this.visit(function(r){if(!r.length)do++e;while(r=r.next)}),e}function tw(e){var r=[],t,n=this._root,i,s,a,o,c;for(n&&r.push(new et(n,this._x0,this._y0,this._x1,this._y1));t=r.pop();)if(!e(n=t.node,s=t.x0,a=t.y0,o=t.x1,c=t.y1)&&n.length){var f=(s+o)/2,l=(a+c)/2;(i=n[3])&&r.push(new et(i,f,l,o,c)),(i=n[2])&&r.push(new et(i,s,l,f,c)),(i=n[1])&&r.push(new et(i,f,a,o,l)),(i=n[0])&&r.push(new et(i,s,a,f,l))}return this}function rw(e){var r=[],t=[],n;for(this._root&&r.push(new et(this._root,this._x0,this._y0,this._x1,this._y1));n=r.pop();){var i=n.node;if(i.length){var s,a=n.x0,o=n.y0,c=n.x1,f=n.y1,l=(a+c)/2,p=(o+f)/2;(s=i[0])&&r.push(new et(s,a,o,l,p)),(s=i[1])&&r.push(new et(s,l,o,c,p)),(s=i[2])&&r.push(new et(s,a,p,l,f)),(s=i[3])&&r.push(new et(s,l,p,c,f))}t.push(n)}for(;n=t.pop();)e(n.node,n.x0,n.y0,n.x1,n.y1);return this}function nw(e){return e[0]}function iw(e){return arguments.length?(this._x=e,this):this._x}function sw(e){return e[1]}function ow(e){return arguments.length?(this._y=e,this):this._y}function Wt(e,r,t){var n=new On(r??nw,t??sw,NaN,NaN,NaN,NaN);return e==null?n:n.addAll(e)}function On(e,r,t,n,i,s){this._x=e,this._y=r,this._x0=t,this._y0=n,this._x1=i,this._y1=s,this._root=void 0}function xf(e){for(var r={data:e.data},t=r;e=e.next;)t=t.next={data:e.data};return r}var tt=Wt.prototype=On.prototype;tt.copy=function(){var e=new On(this._x,this._y,this._x0,this._y0,this._x1,this._y1),r=this._root,t,n;if(!r)return e;if(!r.length)return e._root=xf(r),e;for(t=[{source:r,target:e._root=new Array(4)}];r=t.pop();)for(var i=0;i<4;++i)(n=r.source[i])&&(n.length?t.push({source:n,target:r.target[i]=new Array(4)}):r.target[i]=xf(n));return e},tt.add=Vy,tt.addAll=Wy,tt.cover=Yy,tt.data=Ky,tt.extent=Xy,tt.find=Zy,tt.remove=Jy,tt.removeAll=Qy,tt.root=Hy,tt.size=ew,tt.visit=tw,tt.visitAfter=rw,tt.x=iw,tt.y=ow;function aw(e){const r=+this._x.call(null,e),t=+this._y.call(null,e),n=+this._z.call(null,e);return Nf(this.cover(r,t,n),r,t,n,e)}function Nf(e,r,t,n,i){if(isNaN(r)||isNaN(t)||isNaN(n))return e;var s,a=e._root,o={data:i},c=e._x0,f=e._y0,l=e._z0,p=e._x1,m=e._y1,y=e._z1,x,_,b,w,E,N,S,R,A,j,I;if(!a)return e._root=o,e;for(;a.length;)if((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,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,_;p<r;++p)isNaN(y=+this._x.call(null,m=e[p]))||isNaN(x=+this._y.call(null,m))||isNaN(_=+this._z.call(null,m))||(t[p]=y,n[p]=x,i[p]=_,y<s&&(s=y),y>c&&(c=y),x<a&&(a=x),x>f&&(f=x),_<o&&(o=_),_>l&&(l=_));if(s>c||a>f||o>l)return this;this.cover(s,a,o).cover(c,f,l);for(let p=0;p<r;++p)Nf(this,t[p],n[p],i[p],e[p]);return this}function cw(e,r,t){if(isNaN(e=+e)||isNaN(r=+r)||isNaN(t=+t))return this;var n=this._x0,i=this._y0,s=this._z0,a=this._x1,o=this._y1,c=this._z1;if(isNaN(n))a=(n=Math.floor(e))+1,o=(i=Math.floor(r))+1,c=(s=Math.floor(t))+1;else{for(var f=a-n||1,l=this._root,p,m;n>e||e>=a||i>r||r>=o||s>t||t>=c;)switch(m=(t<s)<<2|(r<i)<<1|e<n,p=new Array(8),p[m]=l,l=p,f*=2,m){case 0:a=n+f,o=i+f,c=s+f;break;case 1:n=a-f,o=i+f,c=s+f;break;case 2:a=n+f,i=o-f,c=s+f;break;case 3:n=a-f,i=o-f,c=s+f;break;case 4:a=n+f,o=i+f,s=c-f;break;case 5:n=a-f,o=i+f,s=c-f;break;case 6:a=n+f,i=o-f,s=c-f;break;case 7:n=a-f,i=o-f,s=c-f;break}this._root&&this._root.length&&(this._root=l)}return this._x0=n,this._y0=i,this._z0=s,this._x1=a,this._y1=o,this._z1=c,this}function fw(){var e=[];return this.visit(function(r){if(!r.length)do e.push(r.data);while(r=r.next)}),e}function lw(e){return arguments.length?this.cover(+e[0][0],+e[0][1],+e[0][2]).cover(+e[1][0],+e[1][1],+e[1][2]):isNaN(this._x0)?void 0:[[this._x0,this._y0,this._z0],[this._x1,this._y1,this._z1]]}function qe(e,r,t,n,i,s,a){this.node=e,this.x0=r,this.y0=t,this.z0=n,this.x1=i,this.y1=s,this.z1=a}function hw(e,r,t,n){var i,s=this._x0,a=this._y0,o=this._z0,c,f,l,p,m,y,x=this._x1,_=this._y1,b=this._z1,w=[],E=this._root,N,S;for(E&&w.push(new qe(E,s,a,o,x,_,b)),n==null?n=1/0:(s=e-n,a=r-n,o=t-n,x=e+n,_=r+n,b=t+n,n*=n);N=w.pop();)if(!(!(E=N.node)||(c=N.x0)>x||(f=N.y0)>_||(l=N.z0)>b||(p=N.x1)<s||(m=N.y1)<a||(y=N.z1)<o))if(E.length){var R=(c+p)/2,A=(f+m)/2,j=(l+y)/2;w.push(new qe(E[7],R,A,j,p,m,y),new qe(E[6],c,A,j,R,m,y),new qe(E[5],R,f,j,p,A,y),new qe(E[4],c,f,j,R,A,y),new qe(E[3],R,A,l,p,m,j),new qe(E[2],c,A,l,R,m,j),new qe(E[1],R,f,l,p,A,j),new qe(E[0],c,f,l,R,A,j)),(S=(t>=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($<n){var V=Math.sqrt(n=$);s=e-V,a=r-V,o=t-V,x=e+V,_=r+V,b=t+V,i=E.data}}return i}const dw=(e,r,t,n,i,s)=>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||_<s||b<a||w<o}),i}function pw(e){if(isNaN(m=+this._x.call(null,e))||isNaN(y=+this._y.call(null,e))||isNaN(x=+this._z.call(null,e)))return this;var r,t=this._root,n,i,s,a=this._x0,o=this._y0,c=this._z0,f=this._x1,l=this._y1,p=this._z1,m,y,x,_,b,w,E,N,S,R,A;if(!t)return this;if(t.length)for(;;){if((E=m>=(_=(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<t;++r)this.remove(e[r]);return this}function mw(){return this._root}function yw(){var e=0;return this.visit(function(r){if(!r.length)do++e;while(r=r.next)}),e}function ww(e){var r=[],t,n=this._root,i,s,a,o,c,f,l;for(n&&r.push(new qe(n,this._x0,this._y0,this._z0,this._x1,this._y1,this._z1));t=r.pop();)if(!e(n=t.node,s=t.x0,a=t.y0,o=t.z0,c=t.x1,f=t.y1,l=t.z1)&&n.length){var p=(s+c)/2,m=(a+f)/2,y=(o+l)/2;(i=n[7])&&r.push(new qe(i,p,m,y,c,f,l)),(i=n[6])&&r.push(new qe(i,s,m,y,p,f,l)),(i=n[5])&&r.push(new qe(i,p,a,y,c,m,l)),(i=n[4])&&r.push(new qe(i,s,a,y,p,m,l)),(i=n[3])&&r.push(new qe(i,p,m,o,c,f,y)),(i=n[2])&&r.push(new qe(i,s,m,o,p,f,y)),(i=n[1])&&r.push(new qe(i,p,a,o,c,m,y)),(i=n[0])&&r.push(new qe(i,s,a,o,p,m,y))}return this}function bw(e){var r=[],t=[],n;for(this._root&&r.push(new qe(this._root,this._x0,this._y0,this._z0,this._x1,this._y1,this._z1));n=r.pop();){var i=n.node;if(i.length){var s,a=n.x0,o=n.y0,c=n.z0,f=n.x1,l=n.y1,p=n.z1,m=(a+f)/2,y=(o+l)/2,x=(c+p)/2;(s=i[0])&&r.push(new qe(s,a,o,c,m,y,x)),(s=i[1])&&r.push(new qe(s,m,o,c,f,y,x)),(s=i[2])&&r.push(new qe(s,a,y,c,m,l,x)),(s=i[3])&&r.push(new qe(s,m,y,c,f,l,x)),(s=i[4])&&r.push(new qe(s,a,o,x,m,y,p)),(s=i[5])&&r.push(new qe(s,m,o,x,f,y,p)),(s=i[6])&&r.push(new qe(s,a,y,x,m,l,p)),(s=i[7])&&r.push(new qe(s,m,y,x,f,l,p))}t.push(n)}for(;n=t.pop();)e(n.node,n.x0,n.y0,n.z0,n.x1,n.y1,n.z1);return this}function _w(e){return e[0]}function Ew(e){return arguments.length?(this._x=e,this):this._x}function xw(e){return e[1]}function Nw(e){return arguments.length?(this._y=e,this):this._y}function Mw(e){return e[2]}function Sw(e){return arguments.length?(this._z=e,this):this._z}function Rr(e,r,t,n){var i=new An(r??_w,t??xw,n??Mw,NaN,NaN,NaN,NaN,NaN,NaN);return e==null?i:i.addAll(e)}function An(e,r,t,n,i,s,a,o,c){this._x=e,this._y=r,this._z=t,this._x0=n,this._y0=i,this._z0=s,this._x1=a,this._y1=o,this._z1=c,this._root=void 0}function Mf(e){for(var r={data:e.data},t=r;e=e.next;)t=t.next={data:e.data};return r}var Ke=Rr.prototype=An.prototype;Ke.copy=function(){var e=new An(this._x,this._y,this._z,this._x0,this._y0,this._z0,this._x1,this._y1,this._z1),r=this._root,t,n;if(!r)return e;if(!r.length)return e._root=Mf(r),e;for(t=[{source:r,target:e._root=new Array(8)}];r=t.pop();)for(var i=0;i<8;++i)(n=r.source[i])&&(n.length?t.push({source:n,target:r.target[i]=new Array(8)}):r.target[i]=Mf(n));return e},Ke.add=aw,Ke.addAll=uw,Ke.cover=cw,Ke.data=fw,Ke.extent=lw,Ke.find=hw,Ke.findAllWithinRadius=gw,Ke.remove=pw,Ke.removeAll=vw,Ke.root=mw,Ke.size=yw,Ke.visit=ww,Ke.visitAfter=bw,Ke.x=Ew,Ke.y=Nw,Ke.z=Sw;const qw=.81,In=.1;function Rw(e,r,t,n,i=2){const s=r/t,a=e.getAllNodes(),o=a.map((l,p)=>{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<a;o++){const c=e[o];c&&c.weight&&(r+=c.weight,t+=c.x*c.weight,n+=c.y*c.weight,i+=c.z*c.weight,s+=c.size*c.weight)}e.x=t/r,e.y=n/r,e.z=i/r,e.size=s/r,e.weight=r}else{const o=e;e.x=o.data.x,e.y=o.data.y,e.z=o.data.z,e.size=o.data.size,e.weight=o.data.weight}}const Aw=(e,r,t,n,i,s,a)=>{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;w<a;w++)x+=m[w]*m[w];const b=Math.sqrt(x)*x;if(y*y*qw<x){const w=e.weight/b;return s.vx+=f*w,s.vy+=l*w,s.vz+=p*w,!0}if(e.length)return!1;if(e.data!==s){const w=e.data.weight/b;s.vx+=f*w,s.vy+=l*w,s.vz+=p*w}};function Iw(e,r,t){r.visit((n,i,s,a,o)=>Aw(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)&&n<r;n++)this.runOneStep(this.lastCalcGraph,this.lastGraph,n,this.lastVelMap,this.lastOptions),this.updatePosition(this.lastGraph,this.lastCalcGraph,this.lastVelMap,this.lastOptions);const t={nodes:this.lastLayoutNodes,edges:this.lastLayoutEdges};return this.lastAssign&&t.nodes.forEach(n=>this.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<R)&&(window.clearInterval(this.timeInterval),I({nodes:Tn(t,b),edges:a}))},0),this.running=!0})})}formatOptions(r,t){const n=Object.assign({},r),{width:i,height:s,getMass:a}=r;n.width=!i&&typeof window<"u"?window.innerWidth:i,n.height=!s&&typeof window<"u"?window.innerHeight:s,r.center||(n.center=[n.width/2,n.height/2]),a||(n.getMass=c=>{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(_<s(l)+s(p))return;const b=m/_,w=y/_,E=x/_,{linkDistance:N=200,edgeStrength:S=200}=a.data||{},A=(N-_)*S,j=l.data.mass||1,I=p.data.mass||1,D=1/j,z=1/I,$=b*A,V=w*A,Y=E*A;t[c].x-=$*D,t[c].y-=V*D,t[c].z-=Y*D,t[f].x+=$*z,t[f].y+=V*z,t[f].z+=Y*z})}calGravity(r,t,n,i){const{getCenter:s}=i,a=r.getAllNodes(),o=t.getAllNodes(),c=t.getAllEdges(),{width:f,height:l,center:p,gravity:m,centripetalOptions:y}=i;a&&a.forEach(x=>{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.judgingDistance<b&&(this.judgingDistance=b);break;case"min":this.judgingDistance>b&&(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;o<s;o++)e[o]>a&&(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;o<s;o++)e[o]<a&&(a=e[o]);return a}function Fw(e){var r=arguments.length>1&&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<e.length;l++)t[l]=(e[l]-n)*f+a;return t}var Bw=Object.freeze({__proto__:null,default:Fw}),$w=Af(Bw),If;function Gw(){var wr,Ac,He;if(If)return we;If=1,Object.defineProperty(we,"__esModule",{value:!0});var e=Lw,r=$w;const t=" ".repeat(2),n=" ".repeat(4);function i(){return s(this)}function s(M,g={}){const{maxRows:h=15,maxColumns:u=10,maxNumSize:d=8,padMinus:v="auto"}=g;return`${M.constructor.name} {
  7. ${t}[
  8. ${n}${a(M,h,u,d,v)}
  9. ${t}]
  10. ${t}rows: ${M.rows}
  11. ${t}columns: ${M.columns}
  12. }`}function a(M,g,h,u,d){const{rows:v,columns:q}=M,O=Math.min(v,g),T=Math.min(q,h),k=[];if(d==="auto"){d=!1;e:for(let B=0;B<O;B++)for(let C=0;C<T;C++)if(M.get(B,C)<0){d=!0;break e}}for(let B=0;B<O;B++){let C=[];for(let W=0;W<T;W++)C.push(o(M.get(B,W),u,d));k.push(`${C.join(" ")}`)}return T!==q&&(k[k.length-1]+=` ... ${q-h} more columns`),O!==v&&k.push(`... ${v-g} more rows`),k.join(`
  13. ${n}`)}function o(M,g,h){return(M>=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<this.rows;d++)for(let v=0;v<this.columns;v++)this.set(d,v,this.get(d,v)+u);return this},M.prototype.addM=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<this.rows;d++)for(let v=0;v<this.columns;v++)this.set(d,v,this.get(d,v)+u.get(d,v));return this},M.add=function(u,d){return new g(u).add(d)},M.prototype.sub=function(u){return typeof u=="number"?this.subS(u):this.subM(u)},M.prototype.subS=function(u){for(let d=0;d<this.rows;d++)for(let v=0;v<this.columns;v++)this.set(d,v,this.get(d,v)-u);return this},M.prototype.subM=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<this.rows;d++)for(let v=0;v<this.columns;v++)this.set(d,v,this.get(d,v)-u.get(d,v));return this},M.sub=function(u,d){return new g(u).sub(d)},M.prototype.subtract=M.prototype.sub,M.prototype.subtractS=M.prototype.subS,M.prototype.subtractM=M.prototype.subM,M.subtract=M.sub,M.prototype.mul=function(u){return typeof u=="number"?this.mulS(u):this.mulM(u)},M.prototype.mulS=function(u){for(let d=0;d<this.rows;d++)for(let v=0;v<this.columns;v++)this.set(d,v,this.get(d,v)*u);return this},M.prototype.mulM=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<this.rows;d++)for(let v=0;v<this.columns;v++)this.set(d,v,this.get(d,v)*u.get(d,v));return this},M.mul=function(u,d){return new g(u).mul(d)},M.prototype.multiply=M.prototype.mul,M.prototype.multiplyS=M.prototype.mulS,M.prototype.multiplyM=M.prototype.mulM,M.multiply=M.mul,M.prototype.div=function(u){return typeof u=="number"?this.divS(u):this.divM(u)},M.prototype.divS=function(u){for(let d=0;d<this.rows;d++)for(let v=0;v<this.columns;v++)this.set(d,v,this.get(d,v)/u);return this},M.prototype.divM=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<this.rows;d++)for(let v=0;v<this.columns;v++)this.set(d,v,this.get(d,v)/u.get(d,v));return this},M.div=function(u,d){return new g(u).div(d)},M.prototype.divide=M.prototype.div,M.prototype.divideS=M.prototype.divS,M.prototype.divideM=M.prototype.divM,M.divide=M.div,M.prototype.mod=function(u){return typeof u=="number"?this.modS(u):this.modM(u)},M.prototype.modS=function(u){for(let d=0;d<this.rows;d++)for(let v=0;v<this.columns;v++)this.set(d,v,this.get(d,v)%u);return this},M.prototype.modM=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<this.rows;d++)for(let v=0;v<this.columns;v++)this.set(d,v,this.get(d,v)%u.get(d,v));return this},M.mod=function(u,d){return new g(u).mod(d)},M.prototype.modulus=M.prototype.mod,M.prototype.modulusS=M.prototype.modS,M.prototype.modulusM=M.prototype.modM,M.modulus=M.mod,M.prototype.and=function(u){return typeof u=="number"?this.andS(u):this.andM(u)},M.prototype.andS=function(u){for(let d=0;d<this.rows;d++)for(let v=0;v<this.columns;v++)this.set(d,v,this.get(d,v)&u);return this},M.prototype.andM=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<this.rows;d++)for(let v=0;v<this.columns;v++)this.set(d,v,this.get(d,v)&u.get(d,v));return this},M.and=function(u,d){return new g(u).and(d)},M.prototype.or=function(u){return typeof u=="number"?this.orS(u):this.orM(u)},M.prototype.orS=function(u){for(let d=0;d<this.rows;d++)for(let v=0;v<this.columns;v++)this.set(d,v,this.get(d,v)|u);return this},M.prototype.orM=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<this.rows;d++)for(let v=0;v<this.columns;v++)this.set(d,v,this.get(d,v)|u.get(d,v));return this},M.or=function(u,d){return new g(u).or(d)},M.prototype.xor=function(u){return typeof u=="number"?this.xorS(u):this.xorM(u)},M.prototype.xorS=function(u){for(let d=0;d<this.rows;d++)for(let v=0;v<this.columns;v++)this.set(d,v,this.get(d,v)^u);return this},M.prototype.xorM=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<this.rows;d++)for(let v=0;v<this.columns;v++)this.set(d,v,this.get(d,v)^u.get(d,v));return this},M.xor=function(u,d){return new g(u).xor(d)},M.prototype.leftShift=function(u){return typeof u=="number"?this.leftShiftS(u):this.leftShiftM(u)},M.prototype.leftShiftS=function(u){for(let d=0;d<this.rows;d++)for(let v=0;v<this.columns;v++)this.set(d,v,this.get(d,v)<<u);return this},M.prototype.leftShiftM=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<this.rows;d++)for(let v=0;v<this.columns;v++)this.set(d,v,this.get(d,v)<<u.get(d,v));return this},M.leftShift=function(u,d){return new g(u).leftShift(d)},M.prototype.signPropagatingRightShift=function(u){return typeof u=="number"?this.signPropagatingRightShiftS(u):this.signPropagatingRightShiftM(u)},M.prototype.signPropagatingRightShiftS=function(u){for(let d=0;d<this.rows;d++)for(let v=0;v<this.columns;v++)this.set(d,v,this.get(d,v)>>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<this.rows;d++)for(let v=0;v<this.columns;v++)this.set(d,v,this.get(d,v)>>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<this.rows;d++)for(let v=0;v<this.columns;v++)this.set(d,v,this.get(d,v)>>>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<this.rows;d++)for(let v=0;v<this.columns;v++)this.set(d,v,this.get(d,v)>>>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;u<this.rows;u++)for(let d=0;d<this.columns;d++)this.set(u,d,~this.get(u,d));return this},M.not=function(u){return new g(u).not()},M.prototype.abs=function(){for(let u=0;u<this.rows;u++)for(let d=0;d<this.columns;d++)this.set(u,d,Math.abs(this.get(u,d)));return this},M.abs=function(u){return new g(u).abs()},M.prototype.acos=function(){for(let u=0;u<this.rows;u++)for(let d=0;d<this.columns;d++)this.set(u,d,Math.acos(this.get(u,d)));return this},M.acos=function(u){return new g(u).acos()},M.prototype.acosh=function(){for(let u=0;u<this.rows;u++)for(let d=0;d<this.columns;d++)this.set(u,d,Math.acosh(this.get(u,d)));return this},M.acosh=function(u){return new g(u).acosh()},M.prototype.asin=function(){for(let u=0;u<this.rows;u++)for(let d=0;d<this.columns;d++)this.set(u,d,Math.asin(this.get(u,d)));return this},M.asin=function(u){return new g(u).asin()},M.prototype.asinh=function(){for(let u=0;u<this.rows;u++)for(let d=0;d<this.columns;d++)this.set(u,d,Math.asinh(this.get(u,d)));return this},M.asinh=function(u){return new g(u).asinh()},M.prototype.atan=function(){for(let u=0;u<this.rows;u++)for(let d=0;d<this.columns;d++)this.set(u,d,Math.atan(this.get(u,d)));return this},M.atan=function(u){return new g(u).atan()},M.prototype.atanh=function(){for(let u=0;u<this.rows;u++)for(let d=0;d<this.columns;d++)this.set(u,d,Math.atanh(this.get(u,d)));return this},M.atanh=function(u){return new g(u).atanh()},M.prototype.cbrt=function(){for(let u=0;u<this.rows;u++)for(let d=0;d<this.columns;d++)this.set(u,d,Math.cbrt(this.get(u,d)));return this},M.cbrt=function(u){return new g(u).cbrt()},M.prototype.ceil=function(){for(let u=0;u<this.rows;u++)for(let d=0;d<this.columns;d++)this.set(u,d,Math.ceil(this.get(u,d)));return this},M.ceil=function(u){return new g(u).ceil()},M.prototype.clz32=function(){for(let u=0;u<this.rows;u++)for(let d=0;d<this.columns;d++)this.set(u,d,Math.clz32(this.get(u,d)));return this},M.clz32=function(u){return new g(u).clz32()},M.prototype.cos=function(){for(let u=0;u<this.rows;u++)for(let d=0;d<this.columns;d++)this.set(u,d,Math.cos(this.get(u,d)));return this},M.cos=function(u){return new g(u).cos()},M.prototype.cosh=function(){for(let u=0;u<this.rows;u++)for(let d=0;d<this.columns;d++)this.set(u,d,Math.cosh(this.get(u,d)));return this},M.cosh=function(u){return new g(u).cosh()},M.prototype.exp=function(){for(let u=0;u<this.rows;u++)for(let d=0;d<this.columns;d++)this.set(u,d,Math.exp(this.get(u,d)));return this},M.exp=function(u){return new g(u).exp()},M.prototype.expm1=function(){for(let u=0;u<this.rows;u++)for(let d=0;d<this.columns;d++)this.set(u,d,Math.expm1(this.get(u,d)));return this},M.expm1=function(u){return new g(u).expm1()},M.prototype.floor=function(){for(let u=0;u<this.rows;u++)for(let d=0;d<this.columns;d++)this.set(u,d,Math.floor(this.get(u,d)));return this},M.floor=function(u){return new g(u).floor()},M.prototype.fround=function(){for(let u=0;u<this.rows;u++)for(let d=0;d<this.columns;d++)this.set(u,d,Math.fround(this.get(u,d)));return this},M.fround=function(u){return new g(u).fround()},M.prototype.log=function(){for(let u=0;u<this.rows;u++)for(let d=0;d<this.columns;d++)this.set(u,d,Math.log(this.get(u,d)));return this},M.log=function(u){return new g(u).log()},M.prototype.log1p=function(){for(let u=0;u<this.rows;u++)for(let d=0;d<this.columns;d++)this.set(u,d,Math.log1p(this.get(u,d)));return this},M.log1p=function(u){return new g(u).log1p()},M.prototype.log10=function(){for(let u=0;u<this.rows;u++)for(let d=0;d<this.columns;d++)this.set(u,d,Math.log10(this.get(u,d)));return this},M.log10=function(u){return new g(u).log10()},M.prototype.log2=function(){for(let u=0;u<this.rows;u++)for(let d=0;d<this.columns;d++)this.set(u,d,Math.log2(this.get(u,d)));return this},M.log2=function(u){return new g(u).log2()},M.prototype.round=function(){for(let u=0;u<this.rows;u++)for(let d=0;d<this.columns;d++)this.set(u,d,Math.round(this.get(u,d)));return this},M.round=function(u){return new g(u).round()},M.prototype.sign=function(){for(let u=0;u<this.rows;u++)for(let d=0;d<this.columns;d++)this.set(u,d,Math.sign(this.get(u,d)));return this},M.sign=function(u){return new g(u).sign()},M.prototype.sin=function(){for(let u=0;u<this.rows;u++)for(let d=0;d<this.columns;d++)this.set(u,d,Math.sin(this.get(u,d)));return this},M.sin=function(u){return new g(u).sin()},M.prototype.sinh=function(){for(let u=0;u<this.rows;u++)for(let d=0;d<this.columns;d++)this.set(u,d,Math.sinh(this.get(u,d)));return this},M.sinh=function(u){return new g(u).sinh()},M.prototype.sqrt=function(){for(let u=0;u<this.rows;u++)for(let d=0;d<this.columns;d++)this.set(u,d,Math.sqrt(this.get(u,d)));return this},M.sqrt=function(u){return new g(u).sqrt()},M.prototype.tan=function(){for(let u=0;u<this.rows;u++)for(let d=0;d<this.columns;d++)this.set(u,d,Math.tan(this.get(u,d)));return this},M.tan=function(u){return new g(u).tan()},M.prototype.tanh=function(){for(let u=0;u<this.rows;u++)for(let d=0;d<this.columns;d++)this.set(u,d,Math.tanh(this.get(u,d)));return this},M.tanh=function(u){return new g(u).tanh()},M.prototype.trunc=function(){for(let u=0;u<this.rows;u++)for(let d=0;d<this.columns;d++)this.set(u,d,Math.trunc(this.get(u,d)));return this},M.trunc=function(u){return new g(u).trunc()},M.pow=function(u,d){return new g(u).pow(d)},M.prototype.pow=function(u){return typeof u=="number"?this.powS(u):this.powM(u)},M.prototype.powS=function(u){for(let d=0;d<this.rows;d++)for(let v=0;v<this.columns;v++)this.set(d,v,this.get(d,v)**u);return this},M.prototype.powM=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<this.rows;d++)for(let v=0;v<this.columns;v++)this.set(d,v,this.get(d,v)**u.get(d,v));return this}}function l(M,g,h){let u=h?M.rows:M.rows-1;if(g<0||g>u)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<g.length;h++)if(g[h]<0||g[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<g.length;h++)if(g[h]<0||g[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<M;u++)h.push(g);return h}function E(M,g){if(typeof g!="number")throw new TypeError(`${M} must be a number`)}function N(M){if(M.isEmpty())throw new Error("Empty matrix has no elements to index")}function S(M){let g=w(M.rows);for(let h=0;h<M.rows;++h)for(let u=0;u<M.columns;++u)g[h]+=M.get(h,u);return g}function R(M){let g=w(M.columns);for(let h=0;h<M.rows;++h)for(let u=0;u<M.columns;++u)g[u]+=M.get(h,u);return g}function A(M){let g=0;for(let h=0;h<M.rows;h++)for(let u=0;u<M.columns;u++)g+=M.get(h,u);return g}function j(M){let g=w(M.rows,1);for(let h=0;h<M.rows;++h)for(let u=0;u<M.columns;++u)g[h]*=M.get(h,u);return g}function I(M){let g=w(M.columns,1);for(let h=0;h<M.rows;++h)for(let u=0;u<M.columns;++u)g[u]*=M.get(h,u);return g}function D(M){let g=1;for(let h=0;h<M.rows;h++)for(let u=0;u<M.columns;u++)g*=M.get(h,u);return g}function z(M,g,h){const u=M.rows,d=M.columns,v=[];for(let q=0;q<u;q++){let O=0,T=0,k=0;for(let B=0;B<d;B++)k=M.get(q,B)-h[q],O+=k,T+=k*k;g?v.push((T-O*O/d)/(d-1)):v.push((T-O*O/d)/d)}return v}function $(M,g,h){const u=M.rows,d=M.columns,v=[];for(let q=0;q<d;q++){let O=0,T=0,k=0;for(let B=0;B<u;B++)k=M.get(B,q)-h[q],O+=k,T+=k*k;g?v.push((T-O*O/u)/(u-1)):v.push((T-O*O/u)/u)}return v}function V(M,g,h){const u=M.rows,d=M.columns,v=u*d;let q=0,O=0,T=0;for(let k=0;k<u;k++)for(let B=0;B<d;B++)T=M.get(k,B)-h,q+=T,O+=T*T;return g?(O-q*q/v)/(v-1):(O-q*q/v)/v}function Y(M,g){for(let h=0;h<M.rows;h++)for(let u=0;u<M.columns;u++)M.set(h,u,M.get(h,u)-g[h])}function ee(M,g){for(let h=0;h<M.rows;h++)for(let u=0;u<M.columns;u++)M.set(h,u,M.get(h,u)-g[u])}function J(M,g){for(let h=0;h<M.rows;h++)for(let u=0;u<M.columns;u++)M.set(h,u,M.get(h,u)-g)}function ae(M){const g=[];for(let h=0;h<M.rows;h++){let u=0;for(let d=0;d<M.columns;d++)u+=M.get(h,d)**2/(M.columns-1);g.push(Math.sqrt(u))}return g}function be(M,g){for(let h=0;h<M.rows;h++)for(let u=0;u<M.columns;u++)M.set(h,u,M.get(h,u)/g[h])}function Z(M){const g=[];for(let h=0;h<M.columns;h++){let u=0;for(let d=0;d<M.rows;d++)u+=M.get(d,h)**2/(M.rows-1);g.push(Math.sqrt(u))}return g}function ue(M,g){for(let h=0;h<M.rows;h++)for(let u=0;u<M.columns;u++)M.set(h,u,M.get(h,u)/g[u])}function pe(M){const g=M.size-1;let h=0;for(let u=0;u<M.columns;u++)for(let d=0;d<M.rows;d++)h+=M.get(d,u)**2/g;return Math.sqrt(h)}function he(M,g){for(let h=0;h<M.rows;h++)for(let u=0;u<M.columns;u++)M.set(h,u,M.get(h,u)/g)}class ie{static from1DArray(g,h,u){if(g*h!==u.length)throw new RangeError("data length does not match given dimensions");let v=new P(g,h);for(let q=0;q<g;q++)for(let O=0;O<h;O++)v.set(q,O,u[q*h+O]);return v}static rowVector(g){let h=new P(1,g.length);for(let u=0;u<g.length;u++)h.set(0,u,g[u]);return h}static columnVector(g){let h=new P(g.length,1);for(let u=0;u<g.length;u++)h.set(u,0,g[u]);return h}static zeros(g,h){return new P(g,h)}static ones(g,h){return new P(g,h).fill(1)}static rand(g,h,u={}){if(typeof u!="object")throw new TypeError("options must be an object");const{random:d=Math.random}=u;let v=new P(g,h);for(let q=0;q<g;q++)for(let O=0;O<h;O++)v.set(q,O,d());return v}static randInt(g,h,u={}){if(typeof u!="object")throw new TypeError("options must be an object");const{min:d=0,max:v=1e3,random:q=Math.random}=u;if(!Number.isInteger(d))throw new TypeError("min must be an integer");if(!Number.isInteger(v))throw new TypeError("max must be an integer");if(d>=v)throw new RangeError("min must be smaller than max");let O=v-d,T=new P(g,h);for(let k=0;k<g;k++)for(let B=0;B<h;B++){let C=d+Math.round(q()*O);T.set(k,B,C)}return T}static eye(g,h,u){h===void 0&&(h=g),u===void 0&&(u=1);let d=Math.min(g,h),v=this.zeros(g,h);for(let q=0;q<d;q++)v.set(q,q,u);return v}static diag(g,h,u){let d=g.length;h===void 0&&(h=d),u===void 0&&(u=h);let v=Math.min(d,h,u),q=this.zeros(h,u);for(let O=0;O<v;O++)q.set(O,O,g[O]);return q}static min(g,h){g=this.checkMatrix(g),h=this.checkMatrix(h);let u=g.rows,d=g.columns,v=new P(u,d);for(let q=0;q<u;q++)for(let O=0;O<d;O++)v.set(q,O,Math.min(g.get(q,O),h.get(q,O)));return v}static max(g,h){g=this.checkMatrix(g),h=this.checkMatrix(h);let u=g.rows,d=g.columns,v=new this(u,d);for(let q=0;q<u;q++)for(let O=0;O<d;O++)v.set(q,O,Math.max(g.get(q,O),h.get(q,O)));return v}static checkMatrix(g){return ie.isMatrix(g)?g:new P(g)}static isMatrix(g){return g!=null&&g.klass==="Matrix"}get size(){return this.rows*this.columns}apply(g){if(typeof g!="function")throw new TypeError("callback must be a function");for(let h=0;h<this.rows;h++)for(let u=0;u<this.columns;u++)g.call(this,h,u);return this}to1DArray(){let g=[];for(let h=0;h<this.rows;h++)for(let u=0;u<this.columns;u++)g.push(this.get(h,u));return g}to2DArray(){let g=[];for(let h=0;h<this.rows;h++){g.push([]);for(let u=0;u<this.columns;u++)g[h].push(this.get(h,u))}return g}toJSON(){return this.to2DArray()}isRowVector(){return this.rows===1}isColumnVector(){return this.columns===1}isVector(){return this.rows===1||this.columns===1}isSquare(){return this.rows===this.columns}isEmpty(){return this.rows===0||this.columns===0}isSymmetric(){if(this.isSquare()){for(let g=0;g<this.rows;g++)for(let h=0;h<=g;h++)if(this.get(g,h)!==this.get(h,g))return!1;return!0}return!1}isDistance(){if(!this.isSymmetric())return!1;for(let g=0;g<this.rows;g++)if(this.get(g,g)!==0)return!1;return!0}isEchelonForm(){let g=0,h=0,u=-1,d=!0,v=!1;for(;g<this.rows&&d;){for(h=0,v=!1;h<this.columns&&v===!1;)this.get(g,h)===0?h++:this.get(g,h)===1&&h>u?(v=!0,u=h):(d=!1,v=!0);g++}return d}isReducedEchelonForm(){let g=0,h=0,u=-1,d=!0,v=!1;for(;g<this.rows&&d;){for(h=0,v=!1;h<this.columns&&v===!1;)this.get(g,h)===0?h++:this.get(g,h)===1&&h>u?(v=!0,u=h):(d=!1,v=!0);for(let q=h+1;q<this.rows;q++)this.get(g,q)!==0&&(d=!1);g++}return d}echelonForm(){let g=this.clone(),h=0,u=0;for(;h<g.rows&&u<g.columns;){let d=h;for(let v=h;v<g.rows;v++)g.get(v,u)>g.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<g.columns;q++)g.set(h,q,g.get(h,q)/v);for(let q=h+1;q<g.rows;q++){let O=g.get(q,u)/g.get(h,u);g.set(q,u,0);for(let T=u+1;T<g.columns;T++)g.set(q,T,g.get(q,T)-g.get(h,T)*O)}h++,u++}}return g}reducedEchelonForm(){let g=this.echelonForm(),h=g.columns,u=g.rows,d=u-1;for(;d>=0;)if(g.maxRow(d)===0)d--;else{let v=0,q=!1;for(;v<u&&q===!1;)g.get(d,v)===1?q=!0:v++;for(let O=0;O<d;O++){let T=g.get(O,v);for(let k=v;k<h;k++){let B=g.get(O,k)-T*g.get(d,k);g.set(O,k,B)}}d--}return g}set(){throw new Error("set method is unimplemented")}get(){throw new Error("get method is unimplemented")}repeat(g={}){if(typeof g!="object")throw new TypeError("options must be an object");const{rows:h=1,columns:u=1}=g;if(!Number.isInteger(h)||h<=0)throw new TypeError("rows must be a positive integer");if(!Number.isInteger(u)||u<=0)throw new TypeError("columns must be a positive integer");let d=new P(this.rows*h,this.columns*u);for(let v=0;v<h;v++)for(let q=0;q<u;q++)d.setSubMatrix(this,this.rows*v,this.columns*q);return d}fill(g){for(let h=0;h<this.rows;h++)for(let u=0;u<this.columns;u++)this.set(h,u,g);return this}neg(){return this.mulS(-1)}getRow(g){l(this,g);let h=[];for(let u=0;u<this.columns;u++)h.push(this.get(g,u));return h}getRowVector(g){return P.rowVector(this.getRow(g))}setRow(g,h){l(this,g),h=m(this,h);for(let u=0;u<this.columns;u++)this.set(g,u,h[u]);return this}swapRows(g,h){l(this,g),l(this,h);for(let u=0;u<this.columns;u++){let d=this.get(g,u);this.set(g,u,this.get(h,u)),this.set(h,u,d)}return this}getColumn(g){p(this,g);let h=[];for(let u=0;u<this.rows;u++)h.push(this.get(u,g));return h}getColumnVector(g){return P.columnVector(this.getColumn(g))}setColumn(g,h){p(this,g),h=y(this,h);for(let u=0;u<this.rows;u++)this.set(u,g,h[u]);return this}swapColumns(g,h){p(this,g),p(this,h);for(let u=0;u<this.rows;u++){let d=this.get(u,g);this.set(u,g,this.get(u,h)),this.set(u,h,d)}return this}addRowVector(g){g=m(this,g);for(let h=0;h<this.rows;h++)for(let u=0;u<this.columns;u++)this.set(h,u,this.get(h,u)+g[u]);return this}subRowVector(g){g=m(this,g);for(let h=0;h<this.rows;h++)for(let u=0;u<this.columns;u++)this.set(h,u,this.get(h,u)-g[u]);return this}mulRowVector(g){g=m(this,g);for(let h=0;h<this.rows;h++)for(let u=0;u<this.columns;u++)this.set(h,u,this.get(h,u)*g[u]);return this}divRowVector(g){g=m(this,g);for(let h=0;h<this.rows;h++)for(let u=0;u<this.columns;u++)this.set(h,u,this.get(h,u)/g[u]);return this}addColumnVector(g){g=y(this,g);for(let h=0;h<this.rows;h++)for(let u=0;u<this.columns;u++)this.set(h,u,this.get(h,u)+g[h]);return this}subColumnVector(g){g=y(this,g);for(let h=0;h<this.rows;h++)for(let u=0;u<this.columns;u++)this.set(h,u,this.get(h,u)-g[h]);return this}mulColumnVector(g){g=y(this,g);for(let h=0;h<this.rows;h++)for(let u=0;u<this.columns;u++)this.set(h,u,this.get(h,u)*g[h]);return this}divColumnVector(g){g=y(this,g);for(let h=0;h<this.rows;h++)for(let u=0;u<this.columns;u++)this.set(h,u,this.get(h,u)/g[h]);return this}mulRow(g,h){l(this,g);for(let u=0;u<this.columns;u++)this.set(g,u,this.get(g,u)*h);return this}mulColumn(g,h){p(this,g);for(let u=0;u<this.rows;u++)this.set(u,g,this.get(u,g)*h);return this}max(g){if(this.isEmpty())return NaN;switch(g){case"row":{const h=new Array(this.rows).fill(Number.NEGATIVE_INFINITY);for(let u=0;u<this.rows;u++)for(let d=0;d<this.columns;d++)this.get(u,d)>h[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;u<this.rows;u++)for(let d=0;d<this.columns;d++)this.get(u,d)>h[d]&&(h[d]=this.get(u,d));return h}case void 0:{let h=this.get(0,0);for(let u=0;u<this.rows;u++)for(let d=0;d<this.columns;d++)this.get(u,d)>h&&(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;u<this.rows;u++)for(let d=0;d<this.columns;d++)this.get(u,d)>g&&(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;u<this.rows;u++)for(let d=0;d<this.columns;d++)this.get(u,d)<h[u]&&(h[u]=this.get(u,d));return h}case"column":{const h=new Array(this.columns).fill(Number.POSITIVE_INFINITY);for(let u=0;u<this.rows;u++)for(let d=0;d<this.columns;d++)this.get(u,d)<h[d]&&(h[d]=this.get(u,d));return h}case void 0:{let h=this.get(0,0);for(let u=0;u<this.rows;u++)for(let d=0;d<this.columns;d++)this.get(u,d)<h&&(h=this.get(u,d));return h}default:throw new Error(`invalid option: ${g}`)}}minIndex(){N(this);let g=this.get(0,0),h=[0,0];for(let u=0;u<this.rows;u++)for(let d=0;d<this.columns;d++)this.get(u,d)<g&&(g=this.get(u,d),h[0]=u,h[1]=d);return h}maxRow(g){if(l(this,g),this.isEmpty())return NaN;let h=this.get(g,0);for(let u=1;u<this.columns;u++)this.get(g,u)>h&&(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;d<this.columns;d++)this.get(g,d)>h&&(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;u<this.columns;u++)this.get(g,u)<h&&(h=this.get(g,u));return h}minRowIndex(g){l(this,g),N(this);let h=this.get(g,0),u=[g,0];for(let d=1;d<this.columns;d++)this.get(g,d)<h&&(h=this.get(g,d),u[1]=d);return u}maxColumn(g){if(p(this,g),this.isEmpty())return NaN;let h=this.get(0,g);for(let u=1;u<this.rows;u++)this.get(u,g)>h&&(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;d<this.rows;d++)this.get(d,g)>h&&(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<this.rows;u++)this.get(u,g)<h&&(h=this.get(u,g));return h}minColumnIndex(g){p(this,g),N(this);let h=this.get(0,g),u=[0,g];for(let d=1;d<this.rows;d++)this.get(d,g)<h&&(h=this.get(d,g),u[0]=d);return u}diag(){let g=Math.min(this.rows,this.columns),h=[];for(let u=0;u<g;u++)h.push(this.get(u,u));return h}norm(g="frobenius"){switch(g){case"max":return this.max();case"frobenius":return Math.sqrt(this.dot(this));default:throw new RangeError(`unknown norm type: ${g}`)}}cumulativeSum(){let g=0;for(let h=0;h<this.rows;h++)for(let u=0;u<this.columns;u++)g+=this.get(h,u),this.set(h,u,g);return this}dot(g){ie.isMatrix(g)&&(g=g.to1DArray());let h=this.to1DArray();if(h.length!==g.length)throw new RangeError("vectors do not have the same size");let u=0;for(let d=0;d<h.length;d++)u+=h[d]*g[d];return u}mmul(g){g=P.checkMatrix(g);let h=this.rows,u=this.columns,d=g.columns,v=new P(h,d),q=new Float64Array(u);for(let O=0;O<d;O++){for(let T=0;T<u;T++)q[T]=g.get(T,O);for(let T=0;T<h;T++){let k=0;for(let B=0;B<u;B++)k+=this.get(T,B)*q[B];v.set(T,O,k)}}return v}mpow(g){if(!this.isSquare())throw new RangeError("Matrix must be square");if(!Number.isInteger(g)||g<0)throw new RangeError("Exponent must be a non-negative integer");let h=P.eye(this.rows),u=this;for(let d=g;d>=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;v<this.rows;v++){const q=this.getRow(v);q.length>0&&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;v<this.columns;v++){const q=this.getColumn(v);q.length&&r(q,{min:h,max:u,output:q}),d.setColumn(v,q)}return d}flipRows(){const g=Math.ceil(this.columns/2);for(let h=0;h<this.rows;h++)for(let u=0;u<g;u++){let d=this.get(h,u),v=this.get(h,this.columns-1-u);this.set(h,u,v),this.set(h,this.columns-1-u,d)}return this}flipColumns(){const g=Math.ceil(this.rows/2);for(let h=0;h<this.columns;h++)for(let u=0;u<g;u++){let d=this.get(u,h),v=this.get(this.rows-1-u,h);this.set(u,h,v),this.set(this.rows-1-u,h,d)}return this}kroneckerProduct(g){g=P.checkMatrix(g);let h=this.rows,u=this.columns,d=g.rows,v=g.columns,q=new P(h*d,u*v);for(let O=0;O<h;O++)for(let T=0;T<u;T++)for(let k=0;k<d;k++)for(let B=0;B<v;B++)q.set(d*O+k,v*T+B,this.get(O,T)*g.get(k,B));return q}kroneckerSum(g){if(g=P.checkMatrix(g),!this.isSquare()||!g.isSquare())throw new Error("Kronecker Sum needs two Square Matrices");let h=this.rows,u=g.rows,d=this.kroneckerProduct(P.eye(u,u)),v=P.eye(h,h).kroneckerProduct(g);return d.add(v)}transpose(){let g=new P(this.columns,this.rows);for(let h=0;h<this.rows;h++)for(let u=0;u<this.columns;u++)g.set(u,h,this.get(h,u));return g}sortRows(g=_e){for(let h=0;h<this.rows;h++)this.setRow(h,this.getRow(h).sort(g));return this}sortColumns(g=_e){for(let h=0;h<this.columns;h++)this.setColumn(h,this.getColumn(h).sort(g));return this}subMatrix(g,h,u,d){b(this,g,h,u,d);let v=new P(h-g+1,d-u+1);for(let q=g;q<=h;q++)for(let O=u;O<=d;O++)v.set(q-g,O-u,this.get(q,O));return v}subMatrixRow(g,h,u){if(h===void 0&&(h=0),u===void 0&&(u=this.columns-1),h>u||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<g.length;v++)for(let q=h;q<=u;q++){if(g[v]<0||g[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<g.length;v++)for(let q=h;q<=u;q++){if(g[v]<0||g[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;q<g.rows;q++)for(let O=0;O<g.columns;O++)this.set(h+q,u+O,g.get(q,O));return this}selection(g,h){x(this,g),_(this,h);let u=new P(g.length,h.length);for(let d=0;d<g.length;d++){let v=g[d];for(let q=0;q<h.length;q++){let O=h[q];u.set(d,q,this.get(v,O))}}return u}trace(){let g=Math.min(this.rows,this.columns),h=0;for(let u=0;u<g;u++)h+=this.get(u,u);return h}clone(){return this.constructor.copy(this,new P(this.rows,this.columns))}static copy(g,h){for(const[u,d,v]of g.entries())h.set(u,d,v);return h}sum(g){switch(g){case"row":return S(this);case"column":return R(this);case void 0:return A(this);default:throw new Error(`invalid option: ${g}`)}}product(g){switch(g){case"row":return j(this);case"column":return I(this);case void 0:return D(this);default:throw new Error(`invalid option: ${g}`)}}mean(g){const h=this.sum(g);switch(g){case"row":{for(let u=0;u<this.rows;u++)h[u]/=this.columns;return h}case"column":{for(let u=0;u<this.columns;u++)h[u]/=this.rows;return h}case void 0:return h/this.size;default:throw new Error(`invalid option: ${g}`)}}variance(g,h={}){if(typeof g=="object"&&(h=g,g=void 0),typeof h!="object")throw new TypeError("options must be an object");const{unbiased:u=!0,mean:d=this.mean(g)}=h;if(typeof u!="boolean")throw new TypeError("unbiased must be a boolean");switch(g){case"row":{if(!e.isAnyArray(d))throw new TypeError("mean must be an array");return z(this,u,d)}case"column":{if(!e.isAnyArray(d))throw new TypeError("mean must be an array");return $(this,u,d)}case void 0:{if(typeof d!="number")throw new TypeError("mean must be a number");return V(this,u,d)}default:throw new Error(`invalid option: ${g}`)}}standardDeviation(g,h){typeof g=="object"&&(h=g,g=void 0);const u=this.variance(g,h);if(g===void 0)return Math.sqrt(u);for(let d=0;d<u.length;d++)u[d]=Math.sqrt(u[d]);return u}center(g,h={}){if(typeof g=="object"&&(h=g,g=void 0),typeof h!="object")throw new TypeError("options must be an object");const{center:u=this.mean(g)}=h;switch(g){case"row":{if(!e.isAnyArray(u))throw new TypeError("center must be an array");return Y(this,u),this}case"column":{if(!e.isAnyArray(u))throw new TypeError("center must be an array");return ee(this,u),this}case void 0:{if(typeof u!="number")throw new TypeError("center must be a number");return J(this,u),this}default:throw new Error(`invalid option: ${g}`)}}scale(g,h={}){if(typeof g=="object"&&(h=g,g=void 0),typeof h!="object")throw new TypeError("options must be an object");let u=h.scale;switch(g){case"row":{if(u===void 0)u=ae(this);else if(!e.isAnyArray(u))throw new TypeError("scale must be an array");return be(this,u),this}case"column":{if(u===void 0)u=Z(this);else if(!e.isAnyArray(u))throw new TypeError("scale must be an array");return ue(this,u),this}case void 0:{if(u===void 0)u=pe(this);else if(typeof u!="number")throw new TypeError("scale must be a number");return he(this,u),this}default:throw new Error(`invalid option: ${g}`)}}toString(g){return s(this,g)}[Symbol.iterator](){return this.entries()}*entries(){for(let g=0;g<this.rows;g++)for(let h=0;h<this.columns;h++)yield[g,h,this.get(g,h)]}*values(){for(let g=0;g<this.rows;g++)for(let h=0;h<this.columns;h++)yield this.get(g,h)}}ie.prototype.klass="Matrix",typeof Symbol<"u"&&(ie.prototype[Symbol.for("nodejs.util.inspect.custom")]=i);function _e(M,g){return M-g}function G(M){return M.every(g=>typeof 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<h;v++){if(d[v].length!==u)throw new RangeError("Inconsistent array dimensions");if(!G(d[v]))throw new TypeError("Input data contains non-numeric values");this.data.push(Float64Array.from(d[v]))}this.rows=h,this.columns=u}else throw new TypeError("First argument must be a positive number or an array")}set(h,u,d){return this.data[h][u]=d,this}get(h,u){return this.data[h][u]}removeRow(h){return l(this,h),this.data.splice(h,1),this.rows-=1,this}addRow(h,u){return u===void 0&&(u=h,h=this.rows),l(this,h,!0),u=Float64Array.from(m(this,u)),this.data.splice(h,0,u),this.rows+=1,this}removeColumn(h){p(this,h);for(let u=0;u<this.rows;u++){const d=new Float64Array(this.columns-1);for(let v=0;v<h;v++)d[v]=this.data[u][v];for(let v=h+1;v<this.columns;v++)d[v-1]=this.data[u][v];this.data[u]=d}return this.columns-=1,this}addColumn(h,u){typeof u>"u"&&(u=h,h=this.columns),p(this,h,!0),u=y(this,u);for(let d=0;d<this.rows;d++){const v=new Float64Array(this.columns+1);let q=0;for(;q<h;q++)v[q]=this.data[d][q];for(v[q++]=u[d];q<this.columns+1;q++)v[q]=this.data[d][q-1];this.data[d]=v}return this.columns+=1,this}};wr=new WeakSet,Ac=function(h,u){if(this.data=[],Number.isInteger(u)&&u>=0)for(let d=0;d<h;d++)this.data.push(new Float64Array(u));else throw new TypeError("nColumns must be a positive integer");this.rows=h,this.columns=u};let P=un;f(ie,P);const cn=class cn extends ie{constructor(h){super();Rc(this,He);if(P.isMatrix(h)){if(!h.isSymmetric())throw new TypeError("not symmetric data");fn(this,He,P.copy(h,new P(h.rows,h.rows)))}else if(Number.isInteger(h)&&h>=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<u.length;q++)u[q]=this.get(v,d),++d>=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<u;T++)v.set(q,O,h[T]),++q>=d&&(q=++O);return v}*upperRightEntries(){for(let h=0,u=0;h<this.diagonalSize;void 0){const d=this.get(h,u);yield[h,u,d],++u>=this.diagonalSize&&(u=++h)}}*upperRightValues(){for(let h=0,u=0;h<this.diagonalSize;void 0)yield this.get(h,u),++u>=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<u.length;q++)u[q]=this.get(v,d),++d>=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<h;O++)d.set(v,q,g[O]),++v>=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;O<u;O++)v[O]=O;for(U=new Float64Array(u),T=0;T<d;T++){for(O=0;O<u;O++)U[O]=h.get(O,T);for(O=0;O<u;O++){for(K=Math.min(O,T),C=0,k=0;k<K;k++)C+=h.get(O,k)*U[k];U[O]-=C,h.set(O,T,U[O])}for(B=T,O=T+1;O<u;O++)Math.abs(U[O])>Math.abs(U[B])&&(B=O);if(B!==T){for(k=0;k<d;k++)W=h.get(B,k),h.set(B,k,h.get(T,k)),h.set(T,k,W);ne=v[B],v[B]=v[T],v[T]=ne,q=-q}if(T<u&&h.get(T,T)!==0)for(O=T+1;O<u;O++)h.set(O,T,h.get(O,T)/h.get(T,T))}this.LU=h,this.pivotVector=v,this.pivotSign=q}isSingular(){let g=this.LU,h=g.columns;for(let u=0;u<h;u++)if(g.get(u,u)===0)return!0;return!1}solve(g){g=P.checkMatrix(g);let h=this.LU;if(h.rows!==g.rows)throw new Error("Invalid matrix dimensions");if(this.isSingular())throw new Error("LU matrix is singular");let d=g.columns,v=g.subMatrixRow(this.pivotVector,0,d-1),q=h.columns,O,T,k;for(k=0;k<q;k++)for(O=k+1;O<q;O++)for(T=0;T<d;T++)v.set(O,T,v.get(O,T)-v.get(k,T)*h.get(O,k));for(k=q-1;k>=0;k--){for(T=0;T<d;T++)v.set(k,T,v.get(k,T)/h.get(k,k));for(O=0;O<k;O++)for(T=0;T<d;T++)v.set(O,T,v.get(O,T)-v.get(k,T)*h.get(O,k))}return v}get determinant(){let g=this.LU;if(!g.isSquare())throw new Error("Matrix must be square");let h=this.pivotSign,u=g.columns;for(let d=0;d<u;d++)h*=g.get(d,d);return h}get lowerTriangularMatrix(){let g=this.LU,h=g.rows,u=g.columns,d=new P(h,u);for(let v=0;v<h;v++)for(let q=0;q<u;q++)v>q?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;v<h;v++)for(let q=0;q<u;q++)v<=q?d.set(v,q,g.get(v,q)):d.set(v,q,0);return d}get pivotPermutationVector(){return Array.from(this.pivotVector)}}function We(M,g){let h=0;return Math.abs(M)>Math.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<d;T++){let B=0;for(q=T;q<u;q++)B=We(B,h.get(q,T));if(B!==0){for(h.get(T,T)<0&&(B=-B),q=T;q<u;q++)h.set(q,T,h.get(q,T)/B);for(h.set(T,T,h.get(T,T)+1),O=T+1;O<d;O++){for(k=0,q=T;q<u;q++)k+=h.get(q,T)*h.get(q,O);for(k=-k/h.get(T,T),q=T;q<u;q++)h.set(q,O,h.get(q,O)+k*h.get(q,T))}}v[T]=-B}this.QR=h,this.Rdiag=v}solve(g){g=P.checkMatrix(g);let h=this.QR,u=h.rows;if(g.rows!==u)throw new Error("Matrix row dimensions must agree");if(!this.isFullRank())throw new Error("Matrix is rank deficient");let d=g.columns,v=g.clone(),q=h.columns,O,T,k,B;for(k=0;k<q;k++)for(T=0;T<d;T++){for(B=0,O=k;O<u;O++)B+=h.get(O,k)*v.get(O,T);for(B=-B/h.get(k,k),O=k;O<u;O++)v.set(O,T,v.get(O,T)+B*h.get(O,k))}for(k=q-1;k>=0;k--){for(T=0;T<d;T++)v.set(k,T,v.get(k,T)/this.Rdiag[k]);for(O=0;O<k;O++)for(T=0;T<d;T++)v.set(O,T,v.get(O,T)-v.get(k,T)*h.get(O,k))}return v.subMatrix(0,q-1,0,d-1)}isFullRank(){let g=this.QR.columns;for(let h=0;h<g;h++)if(this.Rdiag[h]===0)return!1;return!0}get upperTriangularMatrix(){let g=this.QR,h=g.columns,u=new P(h,h),d,v;for(d=0;d<h;d++)for(v=0;v<h;v++)d<v?u.set(d,v,g.get(d,v)):d===v?u.set(d,v,this.Rdiag[d]):u.set(d,v,0);return u}get orthogonalMatrix(){let g=this.QR,h=g.rows,u=g.columns,d=new P(h,u),v,q,O,T;for(O=u-1;O>=0;O--){for(v=0;v<h;v++)d.set(v,O,0);for(d.set(O,O,1),q=O;q<u;q++)if(g.get(O,O)!==0){for(T=0,v=O;v<h;v++)T+=g.get(v,O)*d.get(v,q);for(T=-T/g.get(O,O),v=O;v<h;v++)d.set(v,q,d.get(v,q)+T*g.get(v,O))}}return d}}class ht{constructor(g,h={}){if(g=ze.checkMatrix(g),g.isEmpty())throw new Error("Matrix must be non-empty");let u=g.rows,d=g.columns;const{computeLeftSingularVectors:v=!0,computeRightSingularVectors:q=!0,autoTranspose:O=!1}=h;let T=!!v,k=!!q,B=!1,C;if(u<d)if(!O)C=g.clone(),console.warn("Computing SVD on a matrix with more columns than rows. Consider enabling autoTranspose");else{C=g.transpose(),u=C.rows,d=C.columns,B=!0;let F=T;T=k,k=F}else C=g.clone();let W=Math.min(u,d),ne=Math.min(u+1,d),U=new Float64Array(ne),K=new P(u,W),se=new P(d,d),L=new Float64Array(d),re=new Float64Array(u),ce=new Float64Array(ne);for(let F=0;F<ne;F++)ce[F]=F;let ve=Math.min(u-1,d),ye=Math.max(0,Math.min(d-2,u)),ke=Math.max(ve,ye);for(let F=0;F<ke;F++){if(F<ve){U[F]=0;for(let Q=F;Q<u;Q++)U[F]=We(U[F],C.get(Q,F));if(U[F]!==0){C.get(F,F)<0&&(U[F]=-U[F]);for(let Q=F;Q<u;Q++)C.set(Q,F,C.get(Q,F)/U[F]);C.set(F,F,C.get(F,F)+1)}U[F]=-U[F]}for(let Q=F+1;Q<d;Q++){if(F<ve&&U[F]!==0){let oe=0;for(let H=F;H<u;H++)oe+=C.get(H,F)*C.get(H,Q);oe=-oe/C.get(F,F);for(let H=F;H<u;H++)C.set(H,Q,C.get(H,Q)+oe*C.get(H,F))}L[Q]=C.get(F,Q)}if(T&&F<ve)for(let Q=F;Q<u;Q++)K.set(Q,F,C.get(Q,F));if(F<ye){L[F]=0;for(let Q=F+1;Q<d;Q++)L[F]=We(L[F],L[Q]);if(L[F]!==0){L[F+1]<0&&(L[F]=0-L[F]);for(let Q=F+1;Q<d;Q++)L[Q]/=L[F];L[F+1]+=1}if(L[F]=-L[F],F+1<u&&L[F]!==0){for(let Q=F+1;Q<u;Q++)re[Q]=0;for(let Q=F+1;Q<u;Q++)for(let oe=F+1;oe<d;oe++)re[Q]+=L[oe]*C.get(Q,oe);for(let Q=F+1;Q<d;Q++){let oe=-L[Q]/L[F+1];for(let H=F+1;H<u;H++)C.set(H,Q,C.get(H,Q)+oe*re[H])}}if(k)for(let Q=F+1;Q<d;Q++)se.set(Q,F,L[Q])}}let de=Math.min(d,u+1);if(ve<d&&(U[ve]=C.get(ve,ve)),u<de&&(U[de-1]=0),ye+1<de&&(L[ye]=C.get(ye,de-1)),L[de-1]=0,T){for(let F=ve;F<W;F++){for(let Q=0;Q<u;Q++)K.set(Q,F,0);K.set(F,F,1)}for(let F=ve-1;F>=0;F--)if(U[F]!==0){for(let Q=F+1;Q<W;Q++){let oe=0;for(let H=F;H<u;H++)oe+=K.get(H,F)*K.get(H,Q);oe=-oe/K.get(F,F);for(let H=F;H<u;H++)K.set(H,Q,K.get(H,Q)+oe*K.get(H,F))}for(let Q=F;Q<u;Q++)K.set(Q,F,-K.get(Q,F));K.set(F,F,1+K.get(F,F));for(let Q=0;Q<F-1;Q++)K.set(Q,F,0)}else{for(let Q=0;Q<u;Q++)K.set(Q,F,0);K.set(F,F,1)}}if(k)for(let F=d-1;F>=0;F--){if(F<ye&&L[F]!==0)for(let Q=F+1;Q<d;Q++){let oe=0;for(let H=F+1;H<d;H++)oe+=se.get(H,F)*se.get(H,Q);oe=-oe/se.get(F+1,F);for(let H=F+1;H<d;H++)se.set(H,Q,se.get(H,Q)+oe*se.get(H,F))}for(let Q=0;Q<d;Q++)se.set(Q,F,0);se.set(F,F,1)}let ge=de-1,Re=Number.EPSILON;for(;de>0;){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<d;Ce++)je=Se*se.get(Ce,H)+Ae*se.get(Ce,de-1),se.set(Ce,de-1,-Ae*se.get(Ce,H)+Se*se.get(Ce,de-1)),se.set(Ce,H,je)}break}case 2:{let oe=L[F-1];L[F-1]=0;for(let H=F;H<de;H++){let je=We(U[H],oe),Se=U[H]/je,Ae=oe/je;if(U[H]=je,oe=-Ae*L[H],L[H]=Se*L[H],T)for(let Ce=0;Ce<u;Ce++)je=Se*K.get(Ce,H)+Ae*K.get(Ce,F-1),K.set(Ce,F-1,-Ae*K.get(Ce,H)+Se*K.get(Ce,F-1)),K.set(Ce,H,je)}break}case 3:{const oe=Math.max(Math.abs(U[de-1]),Math.abs(U[de-2]),Math.abs(L[de-2]),Math.abs(U[F]),Math.abs(L[F])),H=U[de-1]/oe,je=U[de-2]/oe,Se=L[de-2]/oe,Ae=U[F]/oe,Ce=L[F]/oe,Xe=((je+H)*(je-H)+Se*Se)/2,dt=H*Se*(H*Se);let Ge=0;(Xe!==0||dt!==0)&&(Xe<0?Ge=0-Math.sqrt(Xe*Xe+dt):Ge=Math.sqrt(Xe*Xe+dt),Ge=dt/(Xe+Ge));let yt=(Ae+H)*(Ae-H)+Ge,Rt=Ae*Ce;for(let Ne=F;Ne<de-1;Ne++){let Ze=We(yt,Rt);Ze===0&&(Ze=Number.MIN_VALUE);let st=yt/Ze,ot=Rt/Ze;if(Ne!==F&&(L[Ne-1]=Ze),yt=st*U[Ne]+ot*L[Ne],L[Ne]=st*L[Ne]-ot*U[Ne],Rt=ot*U[Ne+1],U[Ne+1]=st*U[Ne+1],k)for(let Ue=0;Ue<d;Ue++)Ze=st*se.get(Ue,Ne)+ot*se.get(Ue,Ne+1),se.set(Ue,Ne+1,-ot*se.get(Ue,Ne)+st*se.get(Ue,Ne+1)),se.set(Ue,Ne,Ze);if(Ze=We(yt,Rt),Ze===0&&(Ze=Number.MIN_VALUE),st=yt/Ze,ot=Rt/Ze,U[Ne]=Ze,yt=st*L[Ne]+ot*U[Ne+1],U[Ne+1]=-ot*L[Ne]+st*U[Ne+1],Rt=ot*L[Ne+1],L[Ne+1]=st*L[Ne+1],T&&Ne<u-1)for(let Ue=0;Ue<u;Ue++)Ze=st*K.get(Ue,Ne)+ot*K.get(Ue,Ne+1),K.set(Ue,Ne+1,-ot*K.get(Ue,Ne)+st*K.get(Ue,Ne+1)),K.set(Ue,Ne,Ze)}L[de-2]=yt;break}case 4:{if(U[F]<=0&&(U[F]=U[F]<0?-U[F]:0,k))for(let oe=0;oe<=ge;oe++)se.set(oe,F,-se.get(oe,F));for(;F<ge&&!(U[F]>=U[F+1]);){let oe=U[F];if(U[F]=U[F+1],U[F+1]=oe,k&&F<d-1)for(let H=0;H<d;H++)oe=se.get(H,F+1),se.set(H,F+1,se.get(H,F)),se.set(H,F,oe);if(T&&F<u-1)for(let H=0;H<u;H++)oe=K.get(H,F+1),K.set(H,F+1,K.get(H,F)),K.set(H,F,oe);F++}de--;break}}}if(B){let F=se;se=K,K=F}this.m=u,this.n=d,this.s=U,this.U=K,this.V=se}solve(g){let h=g,u=this.threshold,d=this.s.length,v=P.zeros(d,d);for(let W=0;W<d;W++)Math.abs(this.s[W])<=u?v.set(W,W,0):v.set(W,W,1/this.s[W]);let q=this.U,O=this.rightSingularVectors,T=O.mmul(v),k=O.rows,B=q.rows,C=P.zeros(k,B);for(let W=0;W<k;W++)for(let ne=0;ne<B;ne++){let U=0;for(let K=0;K<d;K++)U+=T.get(W,K)*q.get(ne,K);C.set(W,ne,U)}return C.mmul(h)}solveForDiagonal(g){return this.solve(P.diag(g))}inverse(){let g=this.V,h=this.threshold,u=g.rows,d=g.columns,v=new P(u,this.s.length);for(let B=0;B<u;B++)for(let C=0;C<d;C++)Math.abs(this.s[C])>h&&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;B<u;B++)for(let C=0;C<O;C++){let W=0;for(let ne=0;ne<T;ne++)W+=v.get(B,ne)*q.get(C,ne);k.set(B,C,W)}return k}get condition(){return this.s[0]/this.s[Math.min(this.m,this.n)-1]}get norm2(){return this.s[0]}get rank(){let g=Math.max(this.m,this.n)*this.s[0]*Number.EPSILON,h=0,u=this.s;for(let d=0,v=u.length;d<v;d++)u[d]>g&&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;u<M;u++)u!==g&&h.push(u);return h}function nn(M,g,h,u=1e-9,d=1e-9){if(M>d)return new Array(g.rows+1).fill(0);{let v=g.addRow(h,[0]);for(let q=0;q<v.rows;q++)Math.abs(v.get(q,0))<u&&v.set(q,0,0);return v.to1DArray()}}function sn(M,g={}){const{thresholdValue:h=1e-9,thresholdError:u=1e-9}=g;M=P.checkMatrix(M);let d=M.rows,v=new P(d,d);for(let q=0;q<d;q++){let O=P.columnVector(M.getRow(q)),T=M.subMatrixRow(kt(d,q)).transpose(),B=new ht(T).solve(O),C=P.sub(O,T.mmul(B)).abs().max();v.setRow(q,nn(C,B,q,h,u))}return v}function Sc(M,g=Number.EPSILON){if(M=P.checkMatrix(M),M.isEmpty())return M.transpose();let h=new ht(M,{autoTranspose:!0}),u=h.leftSingularVectors,d=h.rightSingularVectors,v=h.diagonal;for(let q=0;q<v.length;q++)Math.abs(v[q])>g?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;q<v.rows;q++)for(let O=0;O<v.columns;O++)v.set(q,O,v.get(q,O)*(1/(M.rows-1)));return v}function vt(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,scale:v=!0}=h;d&&(M.center("column"),u||g.center("column")),v&&(M.scale("column"),u||g.scale("column"));const q=M.standardDeviation("column",{unbiased:!0}),O=u?q:g.standardDeviation("column",{unbiased:!0}),T=M.transpose().mmul(g);for(let k=0;k<T.rows;k++)for(let B=0;B<T.columns;B++)T.set(k,B,T.get(k,B)*(1/(q[k]*O[B]))*(1/(M.rows-1)));return T}class mt{constructor(g,h={}){const{assumeSymmetric:u=!1}=h;if(g=ze.checkMatrix(g),!g.isSquare())throw new Error("Matrix is not a square matrix");if(g.isEmpty())throw new Error("Matrix must be non-empty");let d=g.columns,v=new P(d,d),q=new Float64Array(d),O=new Float64Array(d),T=g,k,B,C=!1;if(u?C=!0:C=g.isSymmetric(),C){for(k=0;k<d;k++)for(B=0;B<d;B++)v.set(k,B,T.get(k,B));Fx(d,O,q,v),Bx(d,O,q,v)}else{let W=new P(d,d),ne=new Float64Array(d);for(B=0;B<d;B++)for(k=0;k<d;k++)W.set(k,B,T.get(k,B));$x(d,W,ne,v),Gx(d,O,q,v,W)}this.n=d,this.e=O,this.d=q,this.V=v}get realEigenvalues(){return Array.from(this.d)}get imaginaryEigenvalues(){return Array.from(this.e)}get eigenvectorMatrix(){return this.V}get diagonalMatrix(){let g=this.n,h=this.e,u=this.d,d=new P(g,g),v,q;for(v=0;v<g;v++){for(q=0;q<g;q++)d.set(v,q,0);d.set(v,v,u[v]),h[v]>0?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;T<M;T++)h[T]=u.get(M-1,T);for(O=M-1;O>0;O--){for(C=0,q=0,k=0;k<O;k++)C=C+Math.abs(h[k]);if(C===0)for(g[O]=h[O-1],T=0;T<O;T++)h[T]=u.get(O-1,T),u.set(O,T,0),u.set(T,O,0);else{for(k=0;k<O;k++)h[k]/=C,q+=h[k]*h[k];for(d=h[O-1],v=Math.sqrt(q),d>0&&(v=-v),g[O]=C*v,q=q-d*v,h[O-1]=d-v,T=0;T<O;T++)g[T]=0;for(T=0;T<O;T++){for(d=h[T],u.set(T,O,d),v=g[T]+u.get(T,T)*d,k=T+1;k<=O-1;k++)v+=u.get(k,T)*h[k],g[k]+=u.get(k,T)*d;g[T]=v}for(d=0,T=0;T<O;T++)g[T]/=q,d+=g[T]*h[T];for(B=d/(q+q),T=0;T<O;T++)g[T]-=B*h[T];for(T=0;T<O;T++){for(d=h[T],v=g[T],k=T;k<=O-1;k++)u.set(k,T,u.get(k,T)-(d*g[k]+v*h[k]));h[T]=u.get(O-1,T),u.set(O,T,0)}}h[O]=q}for(O=0;O<M-1;O++){if(u.set(M-1,O,u.get(O,O)),u.set(O,O,1),q=h[O+1],q!==0){for(k=0;k<=O;k++)h[k]=u.get(k,O+1)/q;for(T=0;T<=O;T++){for(v=0,k=0;k<=O;k++)v+=u.get(k,O+1)*u.get(k,T);for(k=0;k<=O;k++)u.set(k,T,u.get(k,T)-v*h[k])}}for(k=0;k<=O;k++)u.set(k,O+1,0)}for(T=0;T<M;T++)h[T]=u.get(M-1,T),u.set(M-1,T,0);u.set(M-1,M-1,1),g[0]=0}function Bx(M,g,h,u){let d,v,q,O,T,k,B,C,W,ne,U,K,se,L,re,ce;for(q=1;q<M;q++)g[q-1]=g[q];g[M-1]=0;let ve=0,ye=0,ke=Number.EPSILON;for(k=0;k<M;k++){for(ye=Math.max(ye,Math.abs(h[k])+Math.abs(g[k])),B=k;B<M&&!(Math.abs(g[B])<=ke*ye);)B++;if(B>k)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<M;q++)h[q]-=v;for(ve=ve+v,C=h[B],U=1,K=U,se=U,L=g[k+1],re=0,ce=0,q=B-1;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;T<M;T++)v=u.get(T,q+1),u.set(T,q+1,re*u.get(T,q)+U*v),u.set(T,q,U*u.get(T,q)-re*v);C=-re*ce*se*L*g[k]/ne,g[k]=re*C,h[k]=U*C}while(Math.abs(g[k])>ke*ye);h[k]=h[k]+ve,g[k]=0}for(q=0;q<M-1;q++){for(T=q,C=h[q],O=q+1;O<M;O++)h[O]<C&&(T=O,C=h[O]);if(T!==q)for(h[T]=h[q],h[q]=C,O=0;O<M;O++)C=u.get(O,q),u.set(O,q,u.get(O,T)),u.set(O,T,C)}}function $x(M,g,h,u){let d=0,v=M-1,q,O,T,k,B,C,W;for(C=d+1;C<=v-1;C++){for(W=0,k=C;k<=v;k++)W=W+Math.abs(g.get(k,C-1));if(W!==0){for(T=0,k=v;k>=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<M;B++){for(q=0,k=v;k>=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<M;k++)for(B=0;B<M;B++)u.set(k,B,k===B?1:0);for(C=v-1;C>=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;L<M;L++)for((L<q||L>O)&&(h[L]=d.get(L,L),g[L]=0),re=Math.max(L-1,0);re<M;re++)B=B+Math.abs(d.get(L,re));for(;v>=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))<T*U));)ve--;if(ve===v)d.set(v,v,d.get(v,v)+k),h[v]=d.get(v,v),g[v]=0,v--,se=0;else if(ve===v-1){if(de=d.get(v,v-1)*d.get(v-1,v),C=(d.get(v-1,v-1)-d.get(v,v))/2,W=C*C+de,K=Math.sqrt(Math.abs(W)),d.set(v,v,d.get(v,v)+k),d.set(v-1,v-1,d.get(v-1,v-1)+k),ge=d.get(v,v),W>=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;re<M;re++)K=d.get(v-1,re),d.set(v-1,re,W*K+C*d.get(v,re)),d.set(v,re,W*d.get(v,re)-C*K);for(L=0;L<=v;L++)K=d.get(L,v-1),d.set(L,v-1,W*K+C*d.get(L,v)),d.set(L,v,W*d.get(L,v)-C*K);for(L=q;L<=O;L++)K=u.get(L,v-1),u.set(L,v-1,W*K+C*u.get(L,v)),u.set(L,v,W*u.get(L,v)-C*K)}else h[v-1]=ge+C,h[v]=ge+C,g[v-1]=K,g[v]=-K;v=v-2,se=0}else{if(ge=d.get(v,v),Re=0,de=0,ve<v&&(Re=d.get(v-1,v-1),de=d.get(v,v-1)*d.get(v-1,v)),se===10){for(k+=ge,L=q;L<=v;L++)d.set(L,L,d.get(L,L)-ge);U=Math.abs(d.get(v,v-1))+Math.abs(d.get(v-1,v-2)),ge=Re=.75*U,de=-.4375*U*U}if(se===30&&(U=(Re-ge)/2,U=U*U+de,U>0)){for(U=Math.sqrt(U),Re<ge&&(U=-U),U=ge-de/((Re-ge)/2+U),L=q;L<=v;L++)d.set(L,L,d.get(L,L)-U);k+=U,ge=Re=de=.964}for(se=se+1,ye=v-2;ye>=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))<T*(Math.abs(C)*(Math.abs(d.get(ye-1,ye-1))+Math.abs(K)+Math.abs(d.get(ye+1,ye+1))))));)ye--;for(L=ye+2;L<=v;L++)d.set(L,L-2,0),L>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<M;re++)C=d.get(ce,re)+W*d.get(ce+1,re),je&&(C=C+ne*d.get(ce+2,re),d.set(ce+2,re,d.get(ce+2,re)-C*K)),d.set(ce,re,d.get(ce,re)-C*ge),d.set(ce+1,re,d.get(ce+1,re)-C*Re);for(L=0;L<=Math.min(v,ce+3);L++)C=ge*d.get(L,ce)+Re*d.get(L,ce+1),je&&(C=C+K*d.get(L,ce+2),d.set(L,ce+2,d.get(L,ce+2)-C*ne)),d.set(L,ce,d.get(L,ce)-C),d.set(L,ce+1,d.get(L,ce+1)-C*W);for(L=q;L<=O;L++)C=ge*u.get(L,ce)+Re*u.get(L,ce+1),je&&(C=C+K*u.get(L,ce+2),u.set(L,ce+2,u.get(L,ce+2)-C*ne)),u.set(L,ce,u.get(L,ce)-C),u.set(L,ce+1,u.get(L,ce+1)-C*W)}}}if(B!==0){for(v=M-1;v>=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;L<M;L++)if(L<q||L>O)for(re=L;re<M;re++)u.set(L,re,d.get(L,re));for(re=M-1;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;O<u;O++){let k=0;for(T=0;T<O;T++){let B=0;for(q=0;q<T;q++)B+=d.get(T,q)*d.get(O,q);B=(h.get(O,T)-B)/d.get(T,T),d.set(O,T,B),k=k+B*B}for(k=h.get(O,O)-k,v&&(v=k>0),d.set(O,O,Math.sqrt(Math.max(k,0))),T=O+1;T<u;T++)d.set(O,T,0)}this.L=d,this.positiveDefinite=v}isPositiveDefinite(){return this.positiveDefinite}solve(g){g=ze.checkMatrix(g);let h=this.L,u=h.rows;if(g.rows!==u)throw new Error("Matrix dimensions do not match");if(this.isPositiveDefinite()===!1)throw new Error("Matrix is not positive definite");let d=g.columns,v=g.clone(),q,O,T;for(T=0;T<u;T++)for(O=0;O<d;O++){for(q=0;q<T;q++)v.set(T,O,v.get(T,O)-v.get(q,O)*h.get(T,q));v.set(T,O,v.get(T,O)/h.get(T,T))}for(T=u-1;T>=0;T--)for(O=0;O<d;O++){for(q=T+1;q<u;q++)v.set(T,O,v.get(T,O)-v.get(q,O)*h.get(q,T));v.set(T,O,v.get(T,O)/h.get(T,T))}return v}get lowerTriangularMatrix(){return this.L}}class E0{constructor(g,h={}){g=ze.checkMatrix(g);let{Y:u}=h;const{scaleScores:d=!1,maxIterations:v=1e3,terminationCriteria:q=1e-10}=h;let O;if(u){if(e.isAnyArray(u)&&typeof u[0]=="number"?u=P.columnVector(u):u=ze.checkMatrix(u),u.rows!==g.rows)throw new Error("Y should have the same number of rows as X");O=u.getColumnVector(0)}else O=g.getColumnVector(0);let T=1,k,B,C,W;for(let ne=0;ne<v&&T>q;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<n&&(r=n)})}),e.forEach((t,n)=>{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;s<a;++s)o=t[s],c+=o.x,f+=o.y;for(c=(c/a-e)*n,f=(f/a-r)*n,s=0;s<a;++s)o=t[s],o.x-=c,o.y-=f}return i.initialize=function(s){t=s},i.x=function(s){return arguments.length?(e=+s,i):e},i.y=function(s){return arguments.length?(r=+s,i):r},i.strength=function(s){return arguments.length?(n=+s,i):n},i}function $e(e){return function(){return e}}function It(e){return(e()-.5)*1e-6}function Jw(e){return e.x+e.vx}function Qw(e){return e.y+e.vy}function Hw(e){var r,t,n,i=1,s=1;typeof e!="function"&&(e=$e(e==null?1:+e));function a(){for(var f,l=r.length,p,m,y,x,_,b,w=0;w<s;++w)for(p=Wt(r,Jw,Qw).visitAfter(o),f=0;f<l;++f)m=r[f],_=t[m.index],b=_*_,y=m.x+m.vx,x=m.y+m.vy,p.visit(E);function E(N,S,R,A,j){var I=N.data,D=N.r,z=_+D;if(I){if(I.index>m.index){var $=y-I.x-I.vx,V=x-I.y-I.vy,Y=$*$+V*V;Y<z*z&&($===0&&($=It(n),Y+=$*$),V===0&&(V=It(n),Y+=V*V),Y=(z-(Y=Math.sqrt(Y)))/Y*i,m.vx+=($*=Y)*(z=(D*=D)/(b+D)),m.vy+=(V*=Y)*z,I.vx-=$*(z=1-z),I.vy-=V*z)}return}return S>y+z||A<y-z||R>x+z||j<x-z}}function o(f){if(f.data)return f.r=t[f.data.index];for(var l=f.r=0;l<4;++l)f[l]&&f[l].r>f.r&&(f.r=f[l].r)}function c(){if(r){var f,l=r.length,p;for(t=new Array(l),f=0;f<l;++f)p=r[f],t[p.index]=+e(p,f,r)}}return a.initialize=function(f,l){r=f,n=l,c()},a.iterations=function(f){return arguments.length?(s=+f,a):s},a.strength=function(f){return arguments.length?(i=+f,a):i},a.radius=function(f){return arguments.length?(e=typeof f=="function"?f:$e(+f),c(),a):e},a}function e1(e){return e.index}function Lf(e,r){var t=e.get(r);if(!t)throw new Error("node not found: "+r);return t}function t1(e){var r=e1,t=p,n,i=$e(30),s,a,o,c,f,l=1;e==null&&(e=[]);function p(b){return 1/Math.min(o[b.source.index],o[b.target.index])}function m(b){for(var w=0,E=e.length;w<l;++w)for(var N=0,S,R,A,j,I,D,z;N<E;++N)S=e[N],R=S.source,A=S.target,j=A.x+A.vx-R.x-R.vx||It(f),I=A.y+A.vy-R.y-R.vy||It(f),D=Math.sqrt(j*j+I*I),D=(D-s[N])/D*b*n[N],j*=D,I*=D,A.vx-=j*(z=c[N]),A.vy-=I*z,R.vx+=j*(z=1-z),R.vy+=I*z}function y(){if(a){var b,w=a.length,E=e.length,N=new Map(a.map((R,A)=>[r(R,A,a),R])),S;for(b=0,o=new Array(w);b<E;++b)S=e[b],S.index=b,typeof S.source!="object"&&(S.source=Lf(N,S.source)),typeof S.target!="object"&&(S.target=Lf(N,S.target)),o[S.source.index]=(o[S.source.index]||0)+1,o[S.target.index]=(o[S.target.index]||0)+1;for(b=0,c=new Array(E);b<E;++b)S=e[b],c[b]=o[S.source.index]/(o[S.source.index]+o[S.target.index]);n=new Array(E),x(),s=new Array(E),_()}}function x(){if(a)for(var b=0,w=e.length;b<w;++b)n[b]=+t(e[b],b,e)}function _(){if(a)for(var b=0,w=e.length;b<w;++b)s[b]=+i(e[b],b,e)}return m.initialize=function(b,w){a=b,f=w,y()},m.links=function(b){return arguments.length?(e=b,y(),m):e},m.id=function(b){return arguments.length?(r=b,m):r},m.iterations=function(b){return arguments.length?(l=+b,m):l},m.strength=function(b){return arguments.length?(t=typeof b=="function"?b:$e(+b),x(),m):t},m.distance=function(b){return arguments.length?(i=typeof b=="function"?b:$e(+b),_(),m):i},m}var r1={value:()=>{}};function kn(){for(var e=0,r=arguments.length,t={},n;e<r;++e){if(!(n=arguments[e]+"")||n in t||/[\s.]/.test(n))throw new Error("illegal type: "+n);t[n]=[]}return new Ir(t)}function Ir(e){this._=e}function n1(e,r){return e.trim().split(/^|\s+/).map(function(t){var n="",i=t.indexOf(".");if(i>=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(;++s<a;)if((i=(e=n[s]).type)&&(i=i1(t[i],e.name)))return i;return}if(r!=null&&typeof r!="function")throw new Error("invalid callback: "+r);for(;++s<a;)if(i=(e=n[s]).type)t[i]=Df(t[i],e.name,r);else if(r==null)for(i in t)t[i]=Df(t[i],e.name,null);return this},copy:function(){var e={},r=this._;for(var t in r)e[t]=r[t].slice();return new Ir(e)},call:function(e,r){if((i=arguments.length-2)>0)for(var t=new Array(i),n=0,i,s;n<i;++n)t[n]=arguments[n+2];if(!this._.hasOwnProperty(e))throw new Error("unknown type: "+e);for(s=this._[e],n=0,i=s.length;n<i;++n)s[n].value.apply(r,t)},apply:function(e,r,t){if(!this._.hasOwnProperty(e))throw new Error("unknown type: "+e);for(var n=this._[e],i=0,s=n.length;i<s;++i)n[i].value.apply(r,t)}};function i1(e,r){for(var t=0,n=e.length,i;t<n;++t)if((i=e[t]).name===r)return i.value}function Df(e,r,t){for(var n=0,i=e.length;n<i;++n)if(e[n].name===r){e[n]=r1,e=e.slice(0,n).concat(e.slice(n+1));break}return t!=null&&e.push({name:r,value:t}),e}var Yt=0,ar=0,ur=0,zf=1e3,Tr,cr,kr=0,Lt=0,jr=0,fr=typeof performance=="object"&&performance.now?performance:Date,Ff=typeof window=="object"&&window.requestAnimationFrame?window.requestAnimationFrame.bind(window):function(e){setTimeout(e,17)};function Bf(){return Lt||(Ff(s1),Lt=fr.now()+jr)}function s1(){Lt=0}function jn(){this._call=this._time=this._next=null}jn.prototype=Cn.prototype={constructor:jn,restart:function(e,r,t){if(typeof e!="function")throw new TypeError("callback is not a function");t=(t==null?Bf():+t)+(r==null?0:+r),!this._next&&cr!==this&&(cr?cr._next=this:Tr=this,cr=this),this._call=e,this._time=t,Pn()},stop:function(){this._call&&(this._call=null,this._time=1/0,Pn())}};function Cn(e,r,t){var n=new jn;return n.restart(e,r,t),n}function o1(){Bf(),++Yt;for(var e=Tr,r;e;)(r=Lt-e._time)>=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),t<n&&(c.stop(),f.call("end",r))}function m(_){var b,w=e.length,E;_===void 0&&(_=1);for(var N=0;N<_;++N)for(t+=(s-t)*i,o.forEach(function(S){S(t)}),b=0;b<w;++b)E=e[b],E.fx==null?E.x+=E.vx*=a:(E.x=E.fx,E.vx=0),E.fy==null?E.y+=E.vy*=a:(E.y=E.fy,E.vy=0);return r}function y(){for(var _=0,b=e.length,w;_<b;++_){if(w=e[_],w.index=_,w.fx!=null&&(w.x=w.fx),w.fy!=null&&(w.y=w.fy),isNaN(w.x)||isNaN(w.y)){var E=g1*Math.sqrt(.5+_),N=_*p1;w.x=E*Math.cos(N),w.y=E*Math.sin(N)}(isNaN(w.vx)||isNaN(w.vy))&&(w.vx=w.vy=0)}}function x(_){return _.initialize&&_.initialize(e,l),_}return y(),r={tick:m,restart:function(){return c.restart(p),r},stop:function(){return c.stop(),r},nodes:function(_){return arguments.length?(e=_,y(),o.forEach(x),r):e},alpha:function(_){return arguments.length?(t=+_,r):t},alphaMin:function(_){return arguments.length?(n=+_,r):n},alphaDecay:function(_){return arguments.length?(i=+_,r):+i},alphaTarget:function(_){return arguments.length?(s=+_,r):s},velocityDecay:function(_){return arguments.length?(a=1-_,r):1-a},randomSource:function(_){return arguments.length?(l=_,o.forEach(x),r):l},force:function(_,b){return arguments.length>1?(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;E<N;++E)j=e[E],S=_-j.x,R=b-j.y,A=S*S+R*R,A<w&&(I=j,w=A);return I},on:function(_,b){return arguments.length>1?(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<x;++y)_=e[y],s[_.index]=+i(_,y,e)}}function p(y){var x=0,_,b,w=0,E,N,S;if(y.length){for(E=N=S=0;S<4;++S)(_=y[S])&&(b=Math.abs(_.value))&&(x+=_.value,w+=b,E+=b*_.x,N+=b*_.y);y.x=E/w,y.y=N/w}else{_=y,_.x=_.data.x,_.y=_.data.y;do x+=s[_.data.index];while(_=_.next)}y.value=x}function m(y,x,_,b){if(!y.value)return!0;var w=y.x-r.x,E=y.y-r.y,N=b-x,S=w*w+E*E;if(N*N/c<S)return S<o&&(w===0&&(w=It(t),S+=w*w),E===0&&(E=It(t),S+=E*E),S<a&&(S=Math.sqrt(a*S)),r.vx+=w*y.value*n/S,r.vy+=E*y.value*n/S),!0;if(y.length||S>=o)return;(y.data!==r||y.next)&&(w===0&&(w=It(t),S+=w*w),E===0&&(E=It(t),S+=E*E),S<a&&(S=Math.sqrt(a*S)));do y.data!==r&&(N=s[y.data.index]*n/S,r.vx+=w*N,r.vy+=E*N);while(y=y.next)}return f.initialize=function(y,x){e=y,t=x,l()},f.strength=function(y){return arguments.length?(i=typeof y=="function"?y:$e(+y),l(),f):i},f.distanceMin=function(y){return arguments.length?(a=y*y,f):Math.sqrt(a)},f.distanceMax=function(y){return arguments.length?(o=y*y,f):Math.sqrt(o)},f.theta=function(y){return arguments.length?(c=y*y,f):Math.sqrt(c)},f}function y1(e,r,t){var n,i=$e(.1),s,a;typeof e!="function"&&(e=$e(+e)),r==null&&(r=0),t==null&&(t=0);function o(f){for(var l=0,p=n.length;l<p;++l){var m=n[l],y=m.x-r||1e-6,x=m.y-t||1e-6,_=Math.sqrt(y*y+x*x),b=(a[l]-_)*s[l]*f/_;m.vx+=y*b,m.vy+=x*b}}function c(){if(n){var f,l=n.length;for(s=new Array(l),a=new Array(l),f=0;f<l;++f)a[f]=+e(n[f],f,n),s[f]=isNaN(a[f])?0:+i(n[f],f,n)}}return o.initialize=function(f){n=f,c()},o.strength=function(f){return arguments.length?(i=typeof f=="function"?f:$e(+f),c(),o):i},o.radius=function(f){return arguments.length?(e=typeof f=="function"?f:$e(+f),c(),o):e},o.x=function(f){return arguments.length?(r=+f,o):r},o.y=function(f){return arguments.length?(t=+f,o):t},o}function w1(e){var r=$e(.1),t,n,i;typeof e!="function"&&(e=$e(e==null?0:+e));function s(o){for(var c=0,f=t.length,l;c<f;++c)l=t[c],l.vx+=(i[c]-l.x)*n[c]*o}function a(){if(t){var o,c=t.length;for(n=new Array(c),i=new Array(c),o=0;o<c;++o)n[o]=isNaN(i[o]=+e(t[o],o,t))?0:+r(t[o],o,t)}}return s.initialize=function(o){t=o,a()},s.strength=function(o){return arguments.length?(r=typeof o=="function"?o:$e(+o),a(),s):r},s.x=function(o){return arguments.length?(e=typeof o=="function"?o:$e(+o),a(),s):e},s}function b1(e){var r=$e(.1),t,n,i;typeof e!="function"&&(e=$e(e==null?0:+e));function s(o){for(var c=0,f=t.length,l;c<f;++c)l=t[c],l.vy+=(i[c]-l.y)*n[c]*o}function a(){if(t){var o,c=t.length;for(n=new Array(c),i=new Array(c),o=0;o<c;++o)n[o]=isNaN(i[o]=+e(t[o],o,t))?0:+r(t[o],o,t)}}return s.initialize=function(o){t=o,a()},s.strength=function(o){return arguments.length?(r=typeof o=="function"?o:$e(+o),a(),s):r},s.y=function(o){return arguments.length?(e=typeof o=="function"?o:$e(+o),a(),s):e},s}class Uf{constructor(r){this.id="d3-force",this.config={inputNodeAttrs:["x","y","vx","vy","fx","fy"],outputNodeAttrs:["x","y","vx","vy"],simulationAttrs:["alpha","alphaMin","alphaDecay","alphaTarget","velocityDecay","randomSource"]},this.forceMap={link:t1,manyBody:m1,center:Zw,collide:Hw,radial:y1,x:w1,y:b1},this.options={link:{id:t=>t.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<o;++a)c=n[a],f+=c.x||0,l+=c.y||0,p+=c.z||0;for(f=(f/o-e)*i,l=(l/o-r)*i,p=(p/o-t)*i,a=0;a<o;++a)c=n[a],f&&(c.x-=f),l&&(c.y-=l),p&&(c.z-=p)}return s.initialize=function(a){n=a},s.x=function(a){return arguments.length?(e=+a,s):e},s.y=function(a){return arguments.length?(r=+a,s):r},s.z=function(a){return arguments.length?(t=+a,s):t},s.strength=function(a){return arguments.length?(i=+a,s):i},s}function E1(e){const r=+this._x.call(null,e);return Wf(this.cover(r),r,e)}function Wf(e,r,t){if(isNaN(r))return e;var n,i=e._root,s={data:t},a=e._x0,o=e._x1,c,f,l,p,m;if(!i)return e._root=s,e;for(;i.length;)if((l=r>=(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;s<r;++s)isNaN(a=+this._x.call(null,e[s]))||(t[s]=a,a<n&&(n=a),a>i&&(i=a));if(n>i)return this;this.cover(n).cover(i);for(let s=0;s<r;++s)Wf(this,t[s],e[s]);return this}function N1(e){if(isNaN(e=+e))return this;var r=this._x0,t=this._x1;if(isNaN(r))t=(r=Math.floor(e))+1;else{for(var n=t-r||1,i=this._root,s,a;r>e||e>=t;)switch(a=+(e<r),s=new Array(2),s[a]=i,i=s,n*=2,a){case 0:t=r+n;break;case 1:r=t-n;break}this._root&&this._root.length&&(this._root=i)}return this._x0=r,this._x1=t,this}function M1(){var e=[];return this.visit(function(r){if(!r.length)do e.push(r.data);while(r=r.next)}),e}function S1(e){return arguments.length?this.cover(+e[0][0]).cover(+e[1][0]):isNaN(this._x0)?void 0:[[this._x0],[this._x1]]}function _t(e,r,t){this.node=e,this.x0=r,this.x1=t}function q1(e,r){var t,n=this._x0,i,s,a=this._x1,o=[],c=this._root,f,l;for(c&&o.push(new _t(c,n,a)),r==null?r=1/0:(n=e-r,a=e+r);f=o.pop();)if(!(!(c=f.node)||(i=f.x0)>a||(s=f.x1)<n))if(c.length){var p=(i+s)/2;o.push(new _t(c[1],p,s),new _t(c[0],i,p)),(l=+(e>=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<r&&(r=m,n=e-m,a=e+m,t=c.data)}return t}function R1(e){if(isNaN(c=+this._x.call(null,e)))return this;var r,t=this._root,n,i,s,a=this._x0,o=this._x1,c,f,l,p,m;if(!t)return this;if(t.length)for(;;){if((l=c>=(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;r<t;++r)this.remove(e[r]);return this}function A1(){return this._root}function I1(){var e=0;return this.visit(function(r){if(!r.length)do++e;while(r=r.next)}),e}function T1(e){var r=[],t,n=this._root,i,s,a;for(n&&r.push(new _t(n,this._x0,this._x1));t=r.pop();)if(!e(n=t.node,s=t.x0,a=t.x1)&&n.length){var o=(s+a)/2;(i=n[1])&&r.push(new _t(i,o,a)),(i=n[0])&&r.push(new _t(i,s,o))}return this}function k1(e){var r=[],t=[],n;for(this._root&&r.push(new _t(this._root,this._x0,this._x1));n=r.pop();){var i=n.node;if(i.length){var s,a=n.x0,o=n.x1,c=(a+o)/2;(s=i[0])&&r.push(new _t(s,a,c)),(s=i[1])&&r.push(new _t(s,c,o))}t.push(n)}for(;n=t.pop();)e(n.node,n.x0,n.x1);return this}function j1(e){return e[0]}function C1(e){return arguments.length?(this._x=e,this):this._x}function Ln(e,r){var t=new Dn(r??j1,NaN,NaN);return e==null?t:t.addAll(e)}function Dn(e,r,t){this._x=e,this._x0=r,this._x1=t,this._root=void 0}function Yf(e){for(var r={data:e.data},t=r;e=e.next;)t=t.next={data:e.data};return r}var rt=Ln.prototype=Dn.prototype;rt.copy=function(){var e=new Dn(this._x,this._x0,this._x1),r=this._root,t,n;if(!r)return e;if(!r.length)return e._root=Yf(r),e;for(t=[{source:r,target:e._root=new Array(2)}];r=t.pop();)for(var i=0;i<2;++i)(n=r.source[i])&&(n.length?t.push({source:n,target:r.target[i]=new Array(2)}):r.target[i]=Yf(n));return e},rt.add=E1,rt.addAll=x1,rt.cover=N1,rt.data=M1,rt.extent=S1,rt.find=q1,rt.remove=R1,rt.removeAll=O1,rt.root=A1,rt.size=I1,rt.visit=T1,rt.visitAfter=k1,rt.x=C1;function Pe(e){return function(){return e}}function at(e){return(e()-.5)*1e-6}function zn(e){return e.x+e.vx}function Kf(e){return e.y+e.vy}function P1(e){return e.z+e.vz}function L1(e){var r,t,n,i,s=1,a=1;typeof e!="function"&&(e=Pe(e==null?1:+e));function o(){for(var l,p=r.length,m,y,x,_,b,w,E,N=0;N<a;++N)for(m=(t===1?Ln(r,zn):t===2?Wt(r,zn,Kf):t===3?Rr(r,zn,Kf,P1):null).visitAfter(c),l=0;l<p;++l)y=r[l],w=n[y.index],E=w*w,x=y.x+y.vx,t>1&&(_=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;P<he*he&&(ie===0&&(ie=at(i),P+=ie*ie),t>1&&_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||ae<x-he||t>1&&(ee>_+he||be<_-he)||t>2&&(J>b+he||Z<b-he)}}function c(l){if(l.data)return l.r=n[l.data.index];for(var p=l.r=0;p<Math.pow(2,t);++p)l[p]&&l[p].r>l.r&&(l.r=l[p].r)}function f(){if(r){var l,p=r.length,m;for(n=new Array(p),l=0;l<p;++l)m=r[l],n[m.index]=+e(m,l,r)}}return o.initialize=function(l,...p){r=l,i=p.find(m=>typeof 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;E<p;++E)for(var S=0,R,A,j,I=0,D=0,z=0,$,V;S<N;++S)R=e[S],A=R.source,j=R.target,I=j.x+j.vx-A.x-A.vx||at(l),o>1&&(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);w<N;++w)R=e[w],R.index=w,typeof R.source!="object"&&(R.source=Xf(S,R.source)),typeof R.target!="object"&&(R.target=Xf(S,R.target)),c[R.source.index]=(c[R.source.index]||0)+1,c[R.target.index]=(c[R.target.index]||0)+1;for(w=0,f=new Array(N);w<N;++w)R=e[w],f[w]=c[R.source.index]/(c[R.source.index]+c[R.target.index]);n=new Array(N),_(),s=new Array(N),b()}}function _(){if(a)for(var w=0,E=e.length;w<E;++w)n[w]=+t(e[w],w,e)}function b(){if(a)for(var w=0,E=e.length;w<E;++w)s[w]=+i(e[w],w,e)}return y.initialize=function(w,...E){a=w,l=E.find(N=>typeof 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),i<s&&(l.stop(),p.call("end",n))}function x(w){var E,N=e.length,S;w===void 0&&(w=1);for(var R=0;R<w;++R)for(i+=(o-i)*a,f.forEach(function(A){A(i)}),E=0;E<N;++E)S=e[E],S.fx==null?S.x+=S.vx*=c:(S.x=S.fx,S.vx=0),t>1&&(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;w<E;++w){if(N=e[w],N.index=w,N.fx!=null&&(N.x=N.fx),N.fy!=null&&(N.y=N.fy),N.fz!=null&&(N.z=N.fz),isNaN(N.x)||t>1&&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;A<j;++A)V=e[A],I=E-V.x,D=N-(V.y||0),z=S-(V.z||0),$=I*I+D*D+z*z,$<R&&(Y=V,R=$);return Y},on:function(w,E){return arguments.length>1?(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;_<b;++_)t=e[_],w.visit(y)}function p(){if(e){var x,_=e.length,b;for(a=new Array(_),x=0;x<_;++x)b=e[x],a[b.index]=+s(b,x,e)}}function m(x){var _=0,b,w,E=0,N,S,R,A,j=x.length;if(j){for(N=S=R=A=0;A<j;++A)(b=x[A])&&(w=Math.abs(b.value))&&(_+=b.value,E+=w,N+=w*(b.x||0),S+=w*(b.y||0),R+=w*(b.z||0));_*=Math.sqrt(4/j),x.x=N/E,r>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/f<I)return I<c&&(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),I<o&&(I=Math.sqrt(o*I)),t.vx+=S*x.value*i/I,r>1&&(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),I<o&&(I=Math.sqrt(o*I)));do x.data!==t&&(j=a[x.data.index]*i/I,t.vx+=S*j,r>1&&(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;m<y;++m){var x=i[m],_=x.x-r||1e-6,b=(x.y||0)-t||1e-6,w=(x.z||0)-n||1e-6,E=Math.sqrt(_*_+b*b+w*w),N=(c[m]-E)*o[m]*p/E;x.vx+=_*N,s>1&&(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<m;++p)c[p]=+e(i[p],p,i),o[p]=isNaN(c[p])?0:+a(i[p],p,i)}}return f.initialize=function(p,...m){i=p,s=m.find(y=>[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;c<f;++c)l=t[c],l.vx+=(i[c]-l.x)*n[c]*o}function a(){if(t){var o,c=t.length;for(n=new Array(c),i=new Array(c),o=0;o<c;++o)n[o]=isNaN(i[o]=+e(t[o],o,t))?0:+r(t[o],o,t)}}return s.initialize=function(o){t=o,a()},s.strength=function(o){return arguments.length?(r=typeof o=="function"?o:Pe(+o),a(),s):r},s.x=function(o){return arguments.length?(e=typeof o=="function"?o:Pe(+o),a(),s):e},s}function J1(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;c<f;++c)l=t[c],l.vy+=(i[c]-l.y)*n[c]*o}function a(){if(t){var o,c=t.length;for(n=new Array(c),i=new Array(c),o=0;o<c;++o)n[o]=isNaN(i[o]=+e(t[o],o,t))?0:+r(t[o],o,t)}}return s.initialize=function(o){t=o,a()},s.strength=function(o){return arguments.length?(r=typeof o=="function"?o:Pe(+o),a(),s):r},s.y=function(o){return arguments.length?(e=typeof o=="function"?o:Pe(+o),a(),s):e},s}function Q1(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;c<f;++c)l=t[c],l.vz+=(i[c]-l.z)*n[c]*o}function a(){if(t){var o,c=t.length;for(n=new Array(c),i=new Array(c),o=0;o<c;++o)n[o]=isNaN(i[o]=+e(t[o],o,t))?0:+r(t[o],o,t)}}return s.initialize=function(o){t=o,a()},s.strength=function(o){return arguments.length?(r=typeof o=="function"?o:Pe(+o),a(),s):r},s.z=function(o){return arguments.length?(e=typeof o=="function"?o:Pe(+o),a(),s):e},s}class H1 extends Uf{constructor(){super(...arguments),this.id="d3-force-3d",this.config={inputNodeAttrs:["x","y","z","vx","vy","vz","fx","fy","fz"],outputNodeAttrs:["x","y","z","vx","vy","vz"],simulationAttrs:["alpha","alphaMin","alphaDecay","alphaTarget","velocityDecay","randomSource","numDimensions"]},this.forceMap={link:z1,manyBody:K1,center:_1,collide:L1,radial:X1,x:Z1,y:J1,z:Q1},this.options={numDimensions:3,link:{id:r=>r.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<c;){var f=a[o];this.set(f[0],f[1])}}return s.prototype.clear=e,s.prototype.delete=r,s.prototype.get=t,s.prototype.has=n,s.prototype.set=i,Xn=s,Xn}var Zn,al;function sb(){if(al)return Zn;al=1;var e=Pr();function r(){this.__data__=new e,this.size=0}return Zn=r,Zn}var Jn,ul;function ob(){if(ul)return Jn;ul=1;function e(r){var t=this.__data__,n=t.delete(r);return this.size=t.size,n}return Jn=e,Jn}var Qn,cl;function ab(){if(cl)return Qn;cl=1;function e(r){return this.__data__.get(r)}return Qn=e,Qn}var Hn,fl;function ub(){if(fl)return Hn;fl=1;function e(r){return this.__data__.has(r)}return Hn=e,Hn}var ei,ll;function hl(){if(ll)return ei;ll=1;var e=typeof Or=="object"&&Or&&Or.Object===Object&&Or;return ei=e,ei}var ti,dl;function ft(){if(dl)return ti;dl=1;var e=hl(),r=typeof self=="object"&&self&&self.Object===Object&&self,t=e||r||Function("return this")();return ti=t,ti}var ri,gl;function Xt(){if(gl)return ri;gl=1;var e=ft(),r=e.Symbol;return ri=r,ri}var ni,pl;function cb(){if(pl)return ni;pl=1;var e=Xt(),r=Object.prototype,t=r.hasOwnProperty,n=r.toString,i=e?e.toStringTag:void 0;function s(a){var o=t.call(a,i),c=a[i];try{a[i]=void 0;var f=!0}catch{}var l=n.call(a);return f&&(o?a[i]=c:delete a[i]),l}return ni=s,ni}var ii,vl;function fb(){if(vl)return ii;vl=1;var e=Object.prototype,r=e.toString;function t(n){return r.call(n)}return ii=t,ii}var si,ml;function Dt(){if(ml)return si;ml=1;var e=Xt(),r=cb(),t=fb(),n="[object Null]",i="[object Undefined]",s=e?e.toStringTag:void 0;function a(o){return o==null?o===void 0?i:n:s&&s in Object(o)?r(o):t(o)}return si=a,si}var oi,yl;function ut(){if(yl)return oi;yl=1;function e(r){var t=typeof r;return r!=null&&(t=="object"||t=="function")}return oi=e,oi}var ai,wl;function lr(){if(wl)return ai;wl=1;var e=Dt(),r=ut(),t="[object AsyncFunction]",n="[object Function]",i="[object GeneratorFunction]",s="[object Proxy]";function a(o){if(!r(o))return!1;var c=e(o);return c==n||c==i||c==t||c==s}return ai=a,ai}var ui,bl;function lb(){if(bl)return ui;bl=1;var e=ft(),r=e["__core-js_shared__"];return ui=r,ui}var ci,_l;function hb(){if(_l)return ci;_l=1;var e=lb(),r=function(){var n=/[^.]+$/.exec(e&&e.keys&&e.keys.IE_PROTO||"");return n?"Symbol(src)_1."+n:""}();function t(n){return!!r&&r in n}return ci=t,ci}var fi,El;function xl(){if(El)return fi;El=1;var e=Function.prototype,r=e.toString;function t(n){if(n!=null){try{return r.call(n)}catch{}try{return n+""}catch{}}return""}return fi=t,fi}var li,Nl;function db(){if(Nl)return li;Nl=1;var e=lr(),r=hb(),t=ut(),n=xl(),i=/[\\^$.*+?()[\]{}|]/g,s=/^\[object .+?Constructor\]$/,a=Function.prototype,o=Object.prototype,c=a.toString,f=o.hasOwnProperty,l=RegExp("^"+c.call(f).replace(i,"\\$&").replace(/hasOwnProperty|(function).*?(?=\\\()| for .+?(?=\\\])/g,"$1.*?")+"$");function p(m){if(!t(m)||r(m))return!1;var y=e(m)?l:s;return y.test(n(m))}return li=p,li}var hi,Ml;function gb(){if(Ml)return hi;Ml=1;function e(r,t){return r==null?void 0:r[t]}return hi=e,hi}var di,Sl;function zt(){if(Sl)return di;Sl=1;var e=db(),r=gb();function t(n,i){var s=r(n,i);return e(s)?s:void 0}return di=t,di}var gi,ql;function pi(){if(ql)return gi;ql=1;var e=zt(),r=ft(),t=e(r,"Map");return gi=t,gi}var vi,Rl;function Lr(){if(Rl)return vi;Rl=1;var e=zt(),r=e(Object,"create");return vi=r,vi}var mi,Ol;function pb(){if(Ol)return mi;Ol=1;var e=Lr();function r(){this.__data__=e?e(null):{},this.size=0}return mi=r,mi}var yi,Al;function vb(){if(Al)return yi;Al=1;function e(r){var t=this.has(r)&&delete this.__data__[r];return this.size-=t?1:0,t}return yi=e,yi}var wi,Il;function mb(){if(Il)return wi;Il=1;var e=Lr(),r="__lodash_hash_undefined__",t=Object.prototype,n=t.hasOwnProperty;function i(s){var a=this.__data__;if(e){var o=a[s];return o===r?void 0:o}return n.call(a,s)?a[s]:void 0}return wi=i,wi}var bi,Tl;function yb(){if(Tl)return bi;Tl=1;var e=Lr(),r=Object.prototype,t=r.hasOwnProperty;function n(i){var s=this.__data__;return e?s[i]!==void 0:t.call(s,i)}return bi=n,bi}var _i,kl;function wb(){if(kl)return _i;kl=1;var e=Lr(),r="__lodash_hash_undefined__";function t(n,i){var s=this.__data__;return this.size+=this.has(n)?0:1,s[n]=e&&i===void 0?r:i,this}return _i=t,_i}var Ei,jl;function bb(){if(jl)return Ei;jl=1;var e=pb(),r=vb(),t=mb(),n=yb(),i=wb();function s(a){var o=-1,c=a==null?0:a.length;for(this.clear();++o<c;){var f=a[o];this.set(f[0],f[1])}}return s.prototype.clear=e,s.prototype.delete=r,s.prototype.get=t,s.prototype.has=n,s.prototype.set=i,Ei=s,Ei}var xi,Cl;function _b(){if(Cl)return xi;Cl=1;var e=bb(),r=Pr(),t=pi();function n(){this.size=0,this.__data__={hash:new e,map:new(t||r),string:new e}}return xi=n,xi}var Ni,Pl;function Eb(){if(Pl)return Ni;Pl=1;function e(r){var t=typeof r;return t=="string"||t=="number"||t=="symbol"||t=="boolean"?r!=="__proto__":r===null}return Ni=e,Ni}var Mi,Ll;function Dr(){if(Ll)return Mi;Ll=1;var e=Eb();function r(t,n){var i=t.__data__;return e(n)?i[typeof n=="string"?"string":"hash"]:i.map}return Mi=r,Mi}var Si,Dl;function xb(){if(Dl)return Si;Dl=1;var e=Dr();function r(t){var n=e(this,t).delete(t);return this.size-=n?1:0,n}return Si=r,Si}var qi,zl;function Nb(){if(zl)return qi;zl=1;var e=Dr();function r(t){return e(this,t).get(t)}return qi=r,qi}var Ri,Fl;function Mb(){if(Fl)return Ri;Fl=1;var e=Dr();function r(t){return e(this,t).has(t)}return Ri=r,Ri}var Oi,Bl;function Sb(){if(Bl)return Oi;Bl=1;var e=Dr();function r(t,n){var i=e(this,t),s=i.size;return i.set(t,n),this.size+=i.size==s?0:1,this}return Oi=r,Oi}var Ai,$l;function Ii(){if($l)return Ai;$l=1;var e=_b(),r=xb(),t=Nb(),n=Mb(),i=Sb();function s(a){var o=-1,c=a==null?0:a.length;for(this.clear();++o<c;){var f=a[o];this.set(f[0],f[1])}}return s.prototype.clear=e,s.prototype.delete=r,s.prototype.get=t,s.prototype.has=n,s.prototype.set=i,Ai=s,Ai}var Ti,Gl;function qb(){if(Gl)return Ti;Gl=1;var e=Pr(),r=pi(),t=Ii(),n=200;function i(s,a){var o=this.__data__;if(o instanceof e){var c=o.__data__;if(!r||c.length<n-1)return c.push([s,a]),this.size=++o.size,this;o=this.__data__=new t(c)}return o.set(s,a),this.size=o.size,this}return Ti=i,Ti}var ki,Ul;function zr(){if(Ul)return ki;Ul=1;var e=Pr(),r=sb(),t=ob(),n=ab(),i=ub(),s=qb();function a(o){var c=this.__data__=new e(o);this.size=c.size}return a.prototype.clear=r,a.prototype.delete=t,a.prototype.get=n,a.prototype.has=i,a.prototype.set=s,ki=a,ki}var ji,Vl;function Ci(){if(Vl)return ji;Vl=1;function e(r,t){for(var n=-1,i=r==null?0:r.length;++n<i&&t(r[n],n,r)!==!1;);return r}return ji=e,ji}var Pi,Wl;function Yl(){if(Wl)return Pi;Wl=1;var e=zt(),r=function(){try{var t=e(Object,"defineProperty");return t({},"",{}),t}catch{}}();return Pi=r,Pi}var Li,Kl;function Fr(){if(Kl)return Li;Kl=1;var e=Yl();function r(t,n,i){n=="__proto__"&&e?e(t,n,{configurable:!0,enumerable:!0,value:i,writable:!0}):t[n]=i}return Li=r,Li}var Di,Xl;function Br(){if(Xl)return Di;Xl=1;var e=Fr(),r=Kt(),t=Object.prototype,n=t.hasOwnProperty;function i(s,a,o){var c=s[a];(!(n.call(s,a)&&r(c,o))||o===void 0&&!(a in s))&&e(s,a,o)}return Di=i,Di}var zi,Zl;function hr(){if(Zl)return zi;Zl=1;var e=Br(),r=Fr();function t(n,i,s,a){var o=!s;s||(s={});for(var c=-1,f=i.length;++c<f;){var l=i[c],p=a?a(s[l],n[l],l,s,n):void 0;p===void 0&&(p=n[l]),o?r(s,l,p):e(s,l,p)}return s}return zi=t,zi}var Fi,Jl;function Rb(){if(Jl)return Fi;Jl=1;function e(r,t){for(var n=-1,i=Array(r);++n<r;)i[n]=t(n);return i}return Fi=e,Fi}var Bi,Ql;function pt(){if(Ql)return Bi;Ql=1;function e(r){return r!=null&&typeof r=="object"}return Bi=e,Bi}var $i,Hl;function Ob(){if(Hl)return $i;Hl=1;var e=Dt(),r=pt(),t="[object Arguments]";function n(i){return r(i)&&e(i)==t}return $i=n,$i}var Gi,eh;function dr(){if(eh)return Gi;eh=1;var e=Ob(),r=pt(),t=Object.prototype,n=t.hasOwnProperty,i=t.propertyIsEnumerable,s=e(function(){return arguments}())?e:function(a){return r(a)&&n.call(a,"callee")&&!i.call(a,"callee")};return Gi=s,Gi}var Ui,th;function De(){if(th)return Ui;th=1;var e=Array.isArray;return Ui=e,Ui}var gr={exports:{}},Vi,rh;function Ab(){if(rh)return Vi;rh=1;function e(){return!1}return Vi=e,Vi}gr.exports;var nh;function Zt(){return nh||(nh=1,function(e,r){var t=ft(),n=Ab(),i=r&&!r.nodeType&&r,s=i&&!0&&e&&!e.nodeType&&e,a=s&&s.exports===i,o=a?t.Buffer:void 0,c=o?o.isBuffer:void 0,f=c||n;e.exports=f}(gr,gr.exports)),gr.exports}var Wi,ih;function $r(){if(ih)return Wi;ih=1;var e=9007199254740991,r=/^(?:0|[1-9]\d*)$/;function t(n,i){var s=typeof n;return i=i??e,!!i&&(s=="number"||s!="symbol"&&r.test(n))&&n>-1&&n%1==0&&n<i}return Wi=t,Wi}var Yi,sh;function Ki(){if(sh)return Yi;sh=1;var e=9007199254740991;function r(t){return typeof t=="number"&&t>-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));++n<i;)t[n]=r[n];return t}return hs=e,hs}var ds,Rh;function Oh(){if(Rh)return ds;Rh=1;function e(r,t){for(var n=-1,i=r==null?0:r.length,s=0,a=[];++n<i;){var o=r[n];t(o,n,r)&&(a[s++]=o)}return a}return ds=e,ds}var gs,Ah;function Ih(){if(Ah)return gs;Ah=1;function e(){return[]}return gs=e,gs}var ps,Th;function vs(){if(Th)return ps;Th=1;var e=Oh(),r=Ih(),t=Object.prototype,n=t.propertyIsEnumerable,i=Object.getOwnPropertySymbols,s=i?function(a){return a==null?[]:(a=Object(a),e(i(a),function(o){return n.call(a,o)}))}:r;return ps=s,ps}var ms,kh;function Lb(){if(kh)return ms;kh=1;var e=hr(),r=vs();function t(n,i){return e(n,r(n),i)}return ms=t,ms}var ys,jh;function ws(){if(jh)return ys;jh=1;function e(r,t){for(var n=-1,i=t.length,s=r.length;++n<i;)r[s+n]=t[n];return r}return ys=e,ys}var bs,Ch;function Vr(){if(Ch)return bs;Ch=1;var e=gh(),r=e(Object.getPrototypeOf,Object);return bs=r,bs}var _s,Ph;function Lh(){if(Ph)return _s;Ph=1;var e=ws(),r=Vr(),t=vs(),n=Ih(),i=Object.getOwnPropertySymbols,s=i?function(a){for(var o=[];a;)e(o,t(a)),a=r(a);return o}:n;return _s=s,_s}var Es,Dh;function Db(){if(Dh)return Es;Dh=1;var e=hr(),r=Lh();function t(n,i){return e(n,r(n),i)}return Es=t,Es}var xs,zh;function Fh(){if(zh)return xs;zh=1;var e=ws(),r=De();function t(n,i,s){var a=i(n);return r(n)?a:e(a,s(n))}return xs=t,xs}var Ns,Bh;function $h(){if(Bh)return Ns;Bh=1;var e=Fh(),r=vs(),t=Tt();function n(i){return e(i,t,r)}return Ns=n,Ns}var Ms,Gh;function zb(){if(Gh)return Ms;Gh=1;var e=Fh(),r=Lh(),t=Ft();function n(i){return e(i,t,r)}return Ms=n,Ms}var Ss,Uh;function Fb(){if(Uh)return Ss;Uh=1;var e=zt(),r=ft(),t=e(r,"DataView");return Ss=t,Ss}var qs,Vh;function Bb(){if(Vh)return qs;Vh=1;var e=zt(),r=ft(),t=e(r,"Promise");return qs=t,qs}var Rs,Wh;function Yh(){if(Wh)return Rs;Wh=1;var e=zt(),r=ft(),t=e(r,"Set");return Rs=t,Rs}var Os,Kh;function $b(){if(Kh)return Os;Kh=1;var e=zt(),r=ft(),t=e(r,"WeakMap");return Os=t,Os}var As,Xh;function Jt(){if(Xh)return As;Xh=1;var e=Fb(),r=pi(),t=Bb(),n=Yh(),i=$b(),s=Dt(),a=xl(),o="[object Map]",c="[object Object]",f="[object Promise]",l="[object Set]",p="[object WeakMap]",m="[object DataView]",y=a(e),x=a(r),_=a(t),b=a(n),w=a(i),E=s;return(e&&E(new e(new ArrayBuffer(1)))!=m||r&&E(new r)!=o||t&&E(t.resolve())!=f||n&&E(new n)!=l||i&&E(new i)!=p)&&(E=function(N){var S=s(N),R=S==c?N.constructor:void 0,A=R?a(R):"";if(A)switch(A){case y:return m;case x:return o;case _:return f;case b:return l;case w:return p}return S}),As=E,As}var Is,Zh;function Gb(){if(Zh)return Is;Zh=1;var e=Object.prototype,r=e.hasOwnProperty;function t(n){var i=n.length,s=new n.constructor(i);return i&&typeof n[0]=="string"&&r.call(n,"index")&&(s.index=n.index,s.input=n.input),s}return Is=t,Is}var Ts,Jh;function Qh(){if(Jh)return Ts;Jh=1;var e=ft(),r=e.Uint8Array;return Ts=r,Ts}var ks,Hh;function js(){if(Hh)return ks;Hh=1;var e=Qh();function r(t){var n=new t.constructor(t.byteLength);return new e(n).set(new e(t)),n}return ks=r,ks}var Cs,ed;function Ub(){if(ed)return Cs;ed=1;var e=js();function r(t,n){var i=n?e(t.buffer):t.buffer;return new t.constructor(i,t.byteOffset,t.byteLength)}return Cs=r,Cs}var Ps,td;function Vb(){if(td)return Ps;td=1;var e=/\w*$/;function r(t){var n=new t.constructor(t.source,e.exec(t));return n.lastIndex=t.lastIndex,n}return Ps=r,Ps}var Ls,rd;function Wb(){if(rd)return Ls;rd=1;var e=Xt(),r=e?e.prototype:void 0,t=r?r.valueOf:void 0;function n(i){return t?Object(t.call(i)):{}}return Ls=n,Ls}var Ds,nd;function id(){if(nd)return Ds;nd=1;var e=js();function r(t,n){var i=n?e(t.buffer):t.buffer;return new t.constructor(i,t.byteOffset,t.length)}return Ds=r,Ds}var zs,sd;function Yb(){if(sd)return zs;sd=1;var e=js(),r=Ub(),t=Vb(),n=Wb(),i=id(),s="[object Boolean]",a="[object Date]",o="[object Map]",c="[object Number]",f="[object RegExp]",l="[object Set]",p="[object String]",m="[object Symbol]",y="[object ArrayBuffer]",x="[object DataView]",_="[object Float32Array]",b="[object Float64Array]",w="[object Int8Array]",E="[object Int16Array]",N="[object Int32Array]",S="[object Uint8Array]",R="[object Uint8ClampedArray]",A="[object Uint16Array]",j="[object Uint32Array]";function I(D,z,$){var V=D.constructor;switch(z){case y:return e(D);case s:case a:return new V(+D);case x:return r(D,$);case _:case b:case w:case E:case N:case S:case R:case A:case j:return i(D,$);case o:return new V;case c:case p:return new V(D);case f:return t(D);case l:return new V;case m:return n(D)}}return zs=I,zs}var Fs,od;function ad(){if(od)return Fs;od=1;var e=ut(),r=Object.create,t=function(){function n(){}return function(i){if(!e(i))return{};if(r)return r(i);n.prototype=i;var s=new n;return n.prototype=void 0,s}}();return Fs=t,Fs}var Bs,ud;function cd(){if(ud)return Bs;ud=1;var e=ad(),r=Vr(),t=Ur();function n(i){return typeof i.constructor=="function"&&!t(i)?e(r(i)):{}}return Bs=n,Bs}var $s,fd;function Kb(){if(fd)return $s;fd=1;var e=Jt(),r=pt(),t="[object Map]";function n(i){return r(i)&&e(i)==t}return $s=n,$s}var Gs,ld;function Xb(){if(ld)return Gs;ld=1;var e=Kb(),r=Gr(),t=Ji(),n=t&&t.isMap,i=n?r(n):e;return Gs=i,Gs}var Us,hd;function Zb(){if(hd)return Us;hd=1;var e=Jt(),r=pt(),t="[object Set]";function n(i){return r(i)&&e(i)==t}return Us=n,Us}var Vs,dd;function Jb(){if(dd)return Vs;dd=1;var e=Zb(),r=Gr(),t=Ji(),n=t&&t.isSet,i=n?r(n):e;return Vs=i,Vs}var Ws,gd;function pd(){if(gd)return Ws;gd=1;var e=zr(),r=Ci(),t=Br(),n=kb(),i=Pb(),s=Mh(),a=qh(),o=Lb(),c=Db(),f=$h(),l=zb(),p=Jt(),m=Gb(),y=Yb(),x=cd(),_=De(),b=Zt(),w=Xb(),E=ut(),N=Jb(),S=Tt(),R=Ft(),A=1,j=2,I=4,D="[object Arguments]",z="[object Array]",$="[object Boolean]",V="[object Date]",Y="[object Error]",ee="[object Function]",J="[object GeneratorFunction]",ae="[object Map]",be="[object Number]",Z="[object Object]",ue="[object RegExp]",pe="[object Set]",he="[object String]",ie="[object Symbol]",_e="[object WeakMap]",G="[object ArrayBuffer]",P="[object DataView]",X="[object Float32Array]",te="[object Float64Array]",le="[object Int8Array]",xe="[object Int16Array]",Le="[object Int32Array]",Je="[object Uint8Array]",tr="[object Uint8ClampedArray]",Qe="[object Uint16Array]",Ve="[object Uint32Array]",Ee={};Ee[D]=Ee[z]=Ee[G]=Ee[P]=Ee[$]=Ee[V]=Ee[X]=Ee[te]=Ee[le]=Ee[xe]=Ee[Le]=Ee[ae]=Ee[be]=Ee[Z]=Ee[ue]=Ee[pe]=Ee[he]=Ee[ie]=Ee[Je]=Ee[tr]=Ee[Qe]=Ee[Ve]=!0,Ee[Y]=Ee[ee]=Ee[_e]=!1;function Mt(Me,St,ze,Mc,qt,We){var Ye,ht=St&A,rr=St&j,rn=St&I;if(ze&&(Ye=qt?ze(Me,Mc,qt,We):ze(Me)),Ye!==void 0)return Ye;if(!E(Me))return Me;var $t=_(Me);if($t){if(Ye=m(Me),!ht)return a(Me,Ye)}else{var kt=p(Me),nn=kt==ee||kt==J;if(b(Me))return s(Me,ht);if(kt==Z||kt==D||nn&&!qt){if(Ye=rr||nn?{}:x(Me),!ht)return rr?c(Me,i(Ye,Me)):o(Me,n(Ye,Me))}else{if(!Ee[kt])return qt?Me:{};Ye=y(Me,kt,ht)}}We||(We=new e);var sn=We.get(Me);if(sn)return sn;We.set(Me,Ye),N(Me)?Me.forEach(function(vt){Ye.add(Mt(vt,St,ze,vt,Me,We))}):w(Me)&&Me.forEach(function(vt,mt){Ye.set(mt,Mt(vt,St,ze,mt,Me,We))});var Sc=rn?rr?l:f:rr?R:S,on=$t?void 0:Sc(Me);return r(on||Me,function(vt,mt){on&&(mt=vt,vt=Me[mt]),t(Ye,mt,Mt(vt,St,ze,mt,Me,We))}),Ye}return Ws=Mt,Ws}var Ys,vd;function Qb(){if(vd)return Ys;vd=1;var e=pd(),r=4;function t(n){return e(n,r)}return Ys=t,Ys}var Ks,md;function Xs(){if(md)return Ks;md=1;function e(r){return function(){return r}}return Ks=e,Ks}var Zs,yd;function Hb(){if(yd)return Zs;yd=1;function e(r){return function(t,n,i){for(var s=-1,a=Object(t),o=i(t),c=o.length;c--;){var f=o[r?c:++s];if(n(a[f],f,a)===!1)break}return t}}return Zs=e,Zs}var Js,wd;function Qs(){if(wd)return Js;wd=1;var e=Hb(),r=e();return Js=r,Js}var Hs,bd;function eo(){if(bd)return Hs;bd=1;var e=Qs(),r=Tt();function t(n,i){return n&&e(n,i,r)}return Hs=t,Hs}var to,_d;function e_(){if(_d)return to;_d=1;var e=Et();function r(t,n){return function(i,s){if(i==null)return i;if(!e(i))return t(i,s);for(var a=i.length,o=n?a:-1,c=Object(i);(n?o--:++o<a)&&s(c[o],o,c)!==!1;);return i}}return to=r,to}var ro,Ed;function Wr(){if(Ed)return ro;Ed=1;var e=eo(),r=e_(),t=r(e);return ro=t,ro}var no,xd;function Bt(){if(xd)return no;xd=1;function e(r){return r}return no=e,no}var io,Nd;function Md(){if(Nd)return io;Nd=1;var e=Bt();function r(t){return typeof t=="function"?t:e}return io=r,io}var so,Sd;function qd(){if(Sd)return so;Sd=1;var e=Ci(),r=Wr(),t=Md(),n=De();function i(s,a){var o=n(s)?e:r;return o(s,t(a))}return so=i,so}var oo,Rd;function Od(){return Rd||(Rd=1,oo=qd()),oo}var ao,Ad;function t_(){if(Ad)return ao;Ad=1;var e=Wr();function r(t,n){var i=[];return e(t,function(s,a,o){n(s,a,o)&&i.push(s)}),i}return ao=r,ao}var uo,Id;function r_(){if(Id)return uo;Id=1;var e="__lodash_hash_undefined__";function r(t){return this.__data__.set(t,e),this}return uo=r,uo}var co,Td;function n_(){if(Td)return co;Td=1;function e(r){return this.__data__.has(r)}return co=e,co}var fo,kd;function jd(){if(kd)return fo;kd=1;var e=Ii(),r=r_(),t=n_();function n(i){var s=-1,a=i==null?0:i.length;for(this.__data__=new e;++s<a;)this.add(i[s])}return n.prototype.add=n.prototype.push=r,n.prototype.has=t,fo=n,fo}var lo,Cd;function i_(){if(Cd)return lo;Cd=1;function e(r,t){for(var n=-1,i=r==null?0:r.length;++n<i;)if(t(r[n],n,r))return!0;return!1}return lo=e,lo}var ho,Pd;function Ld(){if(Pd)return ho;Pd=1;function e(r,t){return r.has(t)}return ho=e,ho}var go,Dd;function zd(){if(Dd)return go;Dd=1;var e=jd(),r=i_(),t=Ld(),n=1,i=2;function s(a,o,c,f,l,p){var m=c&n,y=a.length,x=o.length;if(y!=x&&!(m&&x>y))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);++w<y;){var S=a[w],R=o[w];if(f)var A=m?f(R,S,w,o,a,p):f(S,R,w,a,o,p);if(A!==void 0){if(A)continue;E=!1;break}if(N){if(!r(o,function(j,I){if(!t(N,I)&&(S===j||l(S,j,c,f,p)))return N.push(I)})){E=!1;break}}else if(!(S===R||l(S,R,c,f,p))){E=!1;break}}return p.delete(a),p.delete(o),E}return go=s,go}var po,Fd;function s_(){if(Fd)return po;Fd=1;function e(r){var t=-1,n=Array(r.size);return r.forEach(function(i,s){n[++t]=[s,i]}),n}return po=e,po}var vo,Bd;function mo(){if(Bd)return vo;Bd=1;function e(r){var t=-1,n=Array(r.size);return r.forEach(function(i){n[++t]=i}),n}return vo=e,vo}var yo,$d;function o_(){if($d)return yo;$d=1;var e=Xt(),r=Qh(),t=Kt(),n=zd(),i=s_(),s=mo(),a=1,o=2,c="[object Boolean]",f="[object Date]",l="[object Error]",p="[object Map]",m="[object Number]",y="[object RegExp]",x="[object Set]",_="[object String]",b="[object Symbol]",w="[object ArrayBuffer]",E="[object DataView]",N=e?e.prototype:void 0,S=N?N.valueOf:void 0;function R(A,j,I,D,z,$,V){switch(I){case E:if(A.byteLength!=j.byteLength||A.byteOffset!=j.byteOffset)return!1;A=A.buffer,j=j.buffer;case w:return!(A.byteLength!=j.byteLength||!$(new r(A),new r(j)));case c:case f:case m:return t(+A,+j);case l:return A.name==j.name&&A.message==j.message;case y:case _:return A==j+"";case p:var Y=i;case x:var ee=D&a;if(Y||(Y=s),A.size!=j.size&&!ee)return!1;var J=V.get(A);if(J)return J==j;D|=o,V.set(A,j);var ae=n(Y(A),Y(j),D,z,$,V);return V.delete(A),ae;case b:if(S)return S.call(A)==S.call(j)}return!1}return yo=R,yo}var wo,Gd;function a_(){if(Gd)return wo;Gd=1;var e=$h(),r=1,t=Object.prototype,n=t.hasOwnProperty;function i(s,a,o,c,f,l){var p=o&r,m=e(s),y=m.length,x=e(a),_=x.length;if(y!=_&&!p)return!1;for(var b=y;b--;){var w=m[b];if(!(p?w in a:n.call(a,w)))return!1}var E=l.get(s),N=l.get(a);if(E&&N)return E==a&&N==s;var S=!0;l.set(s,a),l.set(a,s);for(var R=p;++b<y;){w=m[b];var A=s[w],j=a[w];if(c)var I=p?c(j,A,w,a,s,l):c(A,j,w,s,a,l);if(!(I===void 0?A===j||f(A,j,o,c,l):I)){S=!1;break}R||(R=w=="constructor")}if(S&&!R){var D=s.constructor,z=a.constructor;D!=z&&"constructor"in s&&"constructor"in a&&!(typeof D=="function"&&D instanceof D&&typeof z=="function"&&z instanceof z)&&(S=!1)}return l.delete(s),l.delete(a),S}return wo=i,wo}var bo,Ud;function u_(){if(Ud)return bo;Ud=1;var e=zr(),r=zd(),t=o_(),n=a_(),i=Jt(),s=De(),a=Zt(),o=vr(),c=1,f="[object Arguments]",l="[object Array]",p="[object Object]",m=Object.prototype,y=m.hasOwnProperty;function x(_,b,w,E,N,S){var R=s(_),A=s(b),j=R?l:i(_),I=A?l:i(b);j=j==f?p:j,I=I==f?p:I;var D=j==p,z=I==p,$=j==I;if($&&a(_)){if(!a(b))return!1;R=!0,D=!1}if($&&!D)return S||(S=new e),R||o(_)?r(_,b,w,E,N,S):t(_,b,j,w,E,N,S);if(!(w&c)){var V=D&&y.call(_,"__wrapped__"),Y=z&&y.call(b,"__wrapped__");if(V||Y){var ee=V?_.value():_,J=Y?b.value():b;return S||(S=new e),N(ee,J,w,E,S)}}return $?(S||(S=new e),n(_,b,w,E,N,S)):!1}return bo=x,bo}var _o,Vd;function Wd(){if(Vd)return _o;Vd=1;var e=u_(),r=pt();function t(n,i,s,a,o){return n===i?!0:n==null||i==null||!r(n)&&!r(i)?n!==n&&i!==i:e(n,i,s,a,t,o)}return _o=t,_o}var Eo,Yd;function c_(){if(Yd)return Eo;Yd=1;var e=zr(),r=Wd(),t=1,n=2;function i(s,a,o,c){var f=o.length,l=f,p=!c;if(s==null)return!l;for(s=Object(s);f--;){var m=o[f];if(p&&m[2]?m[1]!==s[m[0]]:!(m[0]in s))return!1}for(;++f<l;){m=o[f];var y=m[0],x=s[y],_=m[1];if(p&&m[2]){if(x===void 0&&!(y in s))return!1}else{var b=new e;if(c)var w=c(x,_,y,s,a,b);if(!(w===void 0?r(_,x,t|n,c,b):w))return!1}}return!0}return Eo=i,Eo}var xo,Kd;function Xd(){if(Kd)return xo;Kd=1;var e=ut();function r(t){return t===t&&!e(t)}return xo=r,xo}var No,Zd;function f_(){if(Zd)return No;Zd=1;var e=Xd(),r=Tt();function t(n){for(var i=r(n),s=i.length;s--;){var a=i[s],o=n[a];i[s]=[a,o,e(o)]}return i}return No=t,No}var Mo,Jd;function Qd(){if(Jd)return Mo;Jd=1;function e(r,t){return function(n){return n==null?!1:n[r]===t&&(t!==void 0||r in Object(n))}}return Mo=e,Mo}var So,Hd;function l_(){if(Hd)return So;Hd=1;var e=c_(),r=f_(),t=Qd();function n(i){var s=r(i);return s.length==1&&s[0][2]?t(s[0][0],s[0][1]):function(a){return a===i||e(a,i,s)}}return So=n,So}var qo,eg;function Qt(){if(eg)return qo;eg=1;var e=Dt(),r=pt(),t="[object Symbol]";function n(i){return typeof i=="symbol"||r(i)&&e(i)==t}return qo=n,qo}var Ro,tg;function Oo(){if(tg)return Ro;tg=1;var e=De(),r=Qt(),t=/\.|\[(?:[^[\]]*|(["'])(?:(?!\1)[^\\]|\\.)*?\1)\]/,n=/^\w*$/;function i(s,a){if(e(s))return!1;var o=typeof s;return o=="number"||o=="symbol"||o=="boolean"||s==null||r(s)?!0:n.test(s)||!t.test(s)||a!=null&&s in Object(a)}return Ro=i,Ro}var Ao,rg;function h_(){if(rg)return Ao;rg=1;var e=Ii(),r="Expected a function";function t(n,i){if(typeof n!="function"||i!=null&&typeof i!="function")throw new TypeError(r);var s=function(){var a=arguments,o=i?i.apply(this,a):a[0],c=s.cache;if(c.has(o))return c.get(o);var f=n.apply(this,a);return s.cache=c.set(o,f)||c,f};return s.cache=new(t.Cache||e),s}return t.Cache=e,Ao=t,Ao}var Io,ng;function d_(){if(ng)return Io;ng=1;var e=h_(),r=500;function t(n){var i=e(n,function(a){return s.size===r&&s.clear(),a}),s=i.cache;return i}return Io=t,Io}var To,ig;function g_(){if(ig)return To;ig=1;var e=d_(),r=/[^.[\]]+|\[(?:(-?\d+(?:\.\d+)?)|(["'])((?:(?!\2)[^\\]|\\.)*?)\2)\]|(?=(?:\.|\[\])(?:\.|\[\]|$))/g,t=/\\(\\)?/g,n=e(function(i){var s=[];return i.charCodeAt(0)===46&&s.push(""),i.replace(r,function(a,o,c,f){s.push(c?f.replace(t,"$1"):o||a)}),s});return To=n,To}var ko,sg;function Yr(){if(sg)return ko;sg=1;function e(r,t){for(var n=-1,i=r==null?0:r.length,s=Array(i);++n<i;)s[n]=t(r[n],n,r);return s}return ko=e,ko}var jo,og;function p_(){if(og)return jo;og=1;var e=Xt(),r=Yr(),t=De(),n=Qt(),i=1/0,s=e?e.prototype:void 0,a=s?s.toString:void 0;function o(c){if(typeof c=="string")return c;if(t(c))return r(c,o)+"";if(n(c))return a?a.call(c):"";var f=c+"";return f=="0"&&1/c==-i?"-0":f}return jo=o,jo}var Co,ag;function ug(){if(ag)return Co;ag=1;var e=p_();function r(t){return t==null?"":e(t)}return Co=r,Co}var Po,cg;function Kr(){if(cg)return Po;cg=1;var e=De(),r=Oo(),t=g_(),n=ug();function i(s,a){return e(s)?s:r(s,a)?[s]:t(n(s))}return Po=i,Po}var Lo,fg;function yr(){if(fg)return Lo;fg=1;var e=Qt(),r=1/0;function t(n){if(typeof n=="string"||e(n))return n;var i=n+"";return i=="0"&&1/n==-r?"-0":i}return Lo=t,Lo}var Do,lg;function Xr(){if(lg)return Do;lg=1;var e=Kr(),r=yr();function t(n,i){i=e(i,n);for(var s=0,a=i.length;n!=null&&s<a;)n=n[r(i[s++])];return s&&s==a?n:void 0}return Do=t,Do}var zo,hg;function v_(){if(hg)return zo;hg=1;var e=Xr();function r(t,n,i){var s=t==null?void 0:e(t,n);return s===void 0?i:s}return zo=r,zo}var Fo,dg;function m_(){if(dg)return Fo;dg=1;function e(r,t){return r!=null&&t in Object(r)}return Fo=e,Fo}var Bo,gg;function pg(){if(gg)return Bo;gg=1;var e=Kr(),r=dr(),t=De(),n=$r(),i=Ki(),s=yr();function a(o,c,f){c=e(c,o);for(var l=-1,p=c.length,m=!1;++l<p;){var y=s(c[l]);if(!(m=o!=null&&f(o,y)))break;o=o[y]}return m||++l!=p?m:(p=o==null?0:o.length,!!p&&i(p)&&n(y,p)&&(t(o)||r(o)))}return Bo=a,Bo}var $o,vg;function mg(){if(vg)return $o;vg=1;var e=m_(),r=pg();function t(n,i){return n!=null&&r(n,i,e)}return $o=t,$o}var Go,yg;function y_(){if(yg)return Go;yg=1;var e=Wd(),r=v_(),t=mg(),n=Oo(),i=Xd(),s=Qd(),a=yr(),o=1,c=2;function f(l,p){return n(l)&&i(p)?s(a(l),p):function(m){var y=r(m,l);return y===void 0&&y===p?t(m,l):e(p,y,o|c)}}return Go=f,Go}var Uo,wg;function bg(){if(wg)return Uo;wg=1;function e(r){return function(t){return t==null?void 0:t[r]}}return Uo=e,Uo}var Vo,_g;function w_(){if(_g)return Vo;_g=1;var e=Xr();function r(t){return function(n){return e(n,t)}}return Vo=r,Vo}var Wo,Eg;function b_(){if(Eg)return Wo;Eg=1;var e=bg(),r=w_(),t=Oo(),n=yr();function i(s){return t(s)?e(n(s)):r(s)}return Wo=i,Wo}var Yo,xg;function xt(){if(xg)return Yo;xg=1;var e=l_(),r=y_(),t=Bt(),n=De(),i=b_();function s(a){return typeof a=="function"?a:a==null?t:typeof a=="object"?n(a)?r(a[0],a[1]):e(a):i(a)}return Yo=s,Yo}var Ko,Ng;function Mg(){if(Ng)return Ko;Ng=1;var e=Oh(),r=t_(),t=xt(),n=De();function i(s,a){var o=n(s)?e:r;return o(s,t(a,3))}return Ko=i,Ko}var Xo,Sg;function __(){if(Sg)return Xo;Sg=1;var e=Object.prototype,r=e.hasOwnProperty;function t(n,i){return n!=null&&r.call(n,i)}return Xo=t,Xo}var Zo,qg;function Rg(){if(qg)return Zo;qg=1;var e=__(),r=pg();function t(n,i){return n!=null&&r(n,i,e)}return Zo=t,Zo}var Jo,Og;function E_(){if(Og)return Jo;Og=1;var e=is(),r=Jt(),t=dr(),n=De(),i=Et(),s=Zt(),a=Ur(),o=vr(),c="[object Map]",f="[object Set]",l=Object.prototype,p=l.hasOwnProperty;function m(y){if(y==null)return!0;if(i(y)&&(n(y)||typeof y=="string"||typeof y.splice=="function"||s(y)||o(y)||t(y)))return!y.length;var x=r(y);if(x==c||x==f)return!y.size;if(a(y))return!e(y).length;for(var _ in y)if(p.call(y,_))return!1;return!0}return Jo=m,Jo}var Qo,Ag;function Ig(){if(Ag)return Qo;Ag=1;function e(r){return r===void 0}return Qo=e,Qo}var Ho,Tg;function kg(){if(Tg)return Ho;Tg=1;var e=Wr(),r=Et();function t(n,i){var s=-1,a=r(n)?Array(n.length):[];return e(n,function(o,c,f){a[++s]=i(o,c,f)}),a}return Ho=t,Ho}var ea,jg;function Cg(){if(jg)return ea;jg=1;var e=Yr(),r=xt(),t=kg(),n=De();function i(s,a){var o=n(s)?e:t;return o(s,r(a,3))}return ea=i,ea}var ta,Pg;function x_(){if(Pg)return ta;Pg=1;function e(r,t,n,i){var s=-1,a=r==null?0:r.length;for(i&&a&&(n=r[++s]);++s<a;)n=t(n,r[s],s,r);return n}return ta=e,ta}var ra,Lg;function N_(){if(Lg)return ra;Lg=1;function e(r,t,n,i,s){return s(r,function(a,o,c){n=i?(i=!1,a):t(n,a,o,c)}),n}return ra=e,ra}var na,Dg;function zg(){if(Dg)return na;Dg=1;var e=x_(),r=Wr(),t=xt(),n=N_(),i=De();function s(a,o,c){var f=i(a)?e:n,l=arguments.length<3;return f(a,t(o,4),c,l,r)}return na=s,na}var ia,Fg;function M_(){if(Fg)return ia;Fg=1;var e=Dt(),r=De(),t=pt(),n="[object String]";function i(s){return typeof s=="string"||!r(s)&&t(s)&&e(s)==n}return ia=i,ia}var sa,Bg;function S_(){if(Bg)return sa;Bg=1;var e=bg(),r=e("length");return sa=r,sa}var oa,$g;function q_(){if($g)return oa;$g=1;var e="\\ud800-\\udfff",r="\\u0300-\\u036f",t="\\ufe20-\\ufe2f",n="\\u20d0-\\u20ff",i=r+t+n,s="\\ufe0e\\ufe0f",a="\\u200d",o=RegExp("["+a+e+i+s+"]");function c(f){return o.test(f)}return oa=c,oa}var aa,Gg;function R_(){if(Gg)return aa;Gg=1;var e="\\ud800-\\udfff",r="\\u0300-\\u036f",t="\\ufe20-\\ufe2f",n="\\u20d0-\\u20ff",i=r+t+n,s="\\ufe0e\\ufe0f",a="["+e+"]",o="["+i+"]",c="\\ud83c[\\udffb-\\udfff]",f="(?:"+o+"|"+c+")",l="[^"+e+"]",p="(?:\\ud83c[\\udde6-\\uddff]){2}",m="[\\ud800-\\udbff][\\udc00-\\udfff]",y="\\u200d",x=f+"?",_="["+s+"]?",b="(?:"+y+"(?:"+[l,p,m].join("|")+")"+_+x+")*",w=_+x+b,E="(?:"+[l+o+"?",o,p,m,a].join("|")+")",N=RegExp(c+"(?="+c+")|"+E+w,"g");function S(R){for(var A=N.lastIndex=0;N.test(R);)++A;return A}return aa=S,aa}var ua,Ug;function O_(){if(Ug)return ua;Ug=1;var e=S_(),r=q_(),t=R_();function n(i){return r(i)?t(i):e(i)}return ua=n,ua}var ca,Vg;function A_(){if(Vg)return ca;Vg=1;var e=is(),r=Jt(),t=Et(),n=M_(),i=O_(),s="[object Map]",a="[object Set]";function o(c){if(c==null)return 0;if(t(c))return n(c)?i(c):c.length;var f=r(c);return f==s||f==a?c.size:e(c).length}return ca=o,ca}var fa,Wg;function I_(){if(Wg)return fa;Wg=1;var e=Ci(),r=ad(),t=eo(),n=xt(),i=Vr(),s=De(),a=Zt(),o=lr(),c=ut(),f=vr();function l(p,m,y){var x=s(p),_=x||a(p)||f(p);if(m=n(m,4),y==null){var b=p&&p.constructor;_?y=x?new b:[]:c(p)?y=o(b)?r(i(p)):{}:y={}}return(_?e:t)(p,function(w,E,N){return m(y,w,E,N)}),y}return fa=l,fa}var la,Yg;function T_(){if(Yg)return la;Yg=1;var e=Xt(),r=dr(),t=De(),n=e?e.isConcatSpreadable:void 0;function i(s){return t(s)||r(s)||!!(n&&s&&s[n])}return la=i,la}var ha,Kg;function da(){if(Kg)return ha;Kg=1;var e=ws(),r=T_();function t(n,i,s,a,o){var c=-1,f=n.length;for(s||(s=r),o||(o=[]);++c<f;){var l=n[c];i>0&&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);++o<c;)f[o]=a[i+o];o=-1;for(var l=Array(i+1);++o<i;)l[o]=a[o];return l[i]=s(f),e(n,this,l)}}return pa=t,pa}var va,Qg;function j_(){if(Qg)return va;Qg=1;var e=Xs(),r=Yl(),t=Bt(),n=r?function(i,s){return r(i,"toString",{configurable:!0,enumerable:!1,value:e(s),writable:!0})}:t;return va=n,va}var ma,Hg;function C_(){if(Hg)return ma;Hg=1;var e=800,r=16,t=Date.now;function n(i){var s=0,a=0;return function(){var o=t(),c=r-(o-a);if(a=o,c>0){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<s;)if(t(r[a],a,r))return a;return-1}return ba=e,ba}var _a,sp;function P_(){if(sp)return _a;sp=1;function e(r){return r!==r}return _a=e,_a}var Ea,op;function L_(){if(op)return Ea;op=1;function e(r,t,n){for(var i=n-1,s=r.length;++i<s;)if(r[i]===t)return i;return-1}return Ea=e,Ea}var xa,ap;function D_(){if(ap)return xa;ap=1;var e=ip(),r=P_(),t=L_();function n(i,s,a){return s===s?t(i,s,a):e(i,r,a)}return xa=n,xa}var Na,up;function z_(){if(up)return Na;up=1;var e=D_();function r(t,n){var i=t==null?0:t.length;return!!i&&e(t,n,0)>-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<s;)if(n(t,r[i]))return!0;return!1}return Ma=e,Ma}var Sa,fp;function B_(){if(fp)return Sa;fp=1;function e(){}return Sa=e,Sa}var qa,lp;function $_(){if(lp)return qa;lp=1;var e=Yh(),r=B_(),t=mo(),n=1/0,i=e&&1/t(new e([,-0]))[1]==n?function(s){return new e(s)}:r;return qa=i,qa}var Ra,hp;function G_(){if(hp)return Ra;hp=1;var e=jd(),r=z_(),t=F_(),n=Ld(),i=$_(),s=mo(),a=200;function o(c,f,l){var p=-1,m=r,y=c.length,x=!0,_=[],b=_;if(l)x=!1,m=t;else if(y>=a){var w=f?null:i(c);if(w)return s(w);x=!1,m=n,b=new e}else b=f?[]:_;e:for(;++p<y;){var E=c[p],N=f?f(E):E;if(E=l||E!==0?E:0,x&&N===N){for(var S=b.length;S--;)if(b[S]===N)continue e;f&&b.push(N),_.push(E)}else m(b,N,l)||(b!==_&&b.push(N),_.push(E))}return _}return Ra=o,Ra}var Oa,dp;function gp(){if(dp)return Oa;dp=1;var e=Et(),r=pt();function t(n){return r(n)&&e(n)}return Oa=t,Oa}var Aa,pp;function U_(){if(pp)return Aa;pp=1;var e=da(),r=Zr(),t=G_(),n=gp(),i=r(function(s){return t(e(s,1,n,!0))});return Aa=i,Aa}var Ia,vp;function V_(){if(vp)return Ia;vp=1;var e=Yr();function r(t,n){return e(n,function(i){return t[i]})}return Ia=r,Ia}var Ta,mp;function yp(){if(mp)return Ta;mp=1;var e=V_(),r=Tt();function t(n){return n==null?[]:e(n,r(n))}return Ta=t,Ta}var ka,wp;function ct(){if(wp)return ka;wp=1;var e;if(typeof Bn=="function")try{e={clone:Qb(),constant:Xs(),each:Od(),filter:Mg(),has:Rg(),isArray:De(),isEmpty:E_(),isFunction:lr(),isUndefined:Ig(),keys:Tt(),map:Cg(),reduce:zg(),size:A_(),transform:I_(),union:U_(),values:yp()}}catch{}return e||(e=window._),ka=e,ka}var ja,bp;function Ca(){if(bp)return ja;bp=1;var e=ct();ja=i;var r="\0",t="\0",n="";function i(l){this._isDirected=e.has(l,"directed")?l.directed:!0,this._isMultigraph=e.has(l,"multigraph")?l.multigraph:!1,this._isCompound=e.has(l,"compound")?l.compound:!1,this._label=void 0,this._defaultNodeLabelFn=e.constant(void 0),this._defaultEdgeLabelFn=e.constant(void 0),this._nodes={},this._isCompound&&(this._parent={},this._children={},this._children[t]={}),this._in={},this._preds={},this._out={},this._sucs={},this._edgeObjs={},this._edgeLabels={}}i.prototype._nodeCount=0,i.prototype._edgeCount=0,i.prototype.isDirected=function(){return this._isDirected},i.prototype.isMultigraph=function(){return this._isMultigraph},i.prototype.isCompound=function(){return this._isCompound},i.prototype.setGraph=function(l){return this._label=l,this},i.prototype.graph=function(){return this._label},i.prototype.setDefaultNodeLabel=function(l){return e.isFunction(l)||(l=e.constant(l)),this._defaultNodeLabelFn=l,this},i.prototype.nodeCount=function(){return this._nodeCount},i.prototype.nodes=function(){return e.keys(this._nodes)},i.prototype.sources=function(){var l=this;return e.filter(this.nodes(),function(p){return e.isEmpty(l._in[p])})},i.prototype.sinks=function(){var l=this;return e.filter(this.nodes(),function(p){return e.isEmpty(l._out[p])})},i.prototype.setNodes=function(l,p){var m=arguments,y=this;return e.each(l,function(x){m.length>1?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<n.length&&(a=n[i].priority<n[a].priority?i:a,s<n.length&&(a=n[s].priority<n[a].priority?s:a),a!==t&&(this._swap(t,a),this._heapify(a)))},r.prototype._decrease=function(t){for(var n=this._arr,i=n[t].priority,s;t!==0&&(s=t>>1,!(n[s].priority<i));)this._swap(t,s),t=s},r.prototype._swap=function(t,n){var i=this._arr,s=this._keyIndices,a=i[t],o=i[n];i[t]=o,i[n]=a,s[o.key]=t,s[a.key]=n},Fa}var Ba,qp;function Rp(){if(qp)return Ba;qp=1;var e=ct(),r=Sp();Ba=n;var t=e.constant(1);function n(s,a,o,c){return i(s,String(a),o||t,c||function(f){return s.outEdges(f)})}function i(s,a,o,c){var f={},l=new r,p,m,y=function(x){var _=x.v!==p?x.v:x.w,b=f[_],w=o(x),E=m.distance+w;if(w<0)throw new Error("dijkstra does not allow negative edge weights. Bad edge: "+x+" Weight: "+w);E<b.distance&&(b.distance=E,b.predecessor=p,l.decrease(_,E))};for(s.nodes().forEach(function(x){var _=x===a?0:Number.POSITIVE_INFINITY;f[x]={distance:_},l.add(x,_)});l.size()>0&&(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;w<b.distance&&(b.distance=w,b.predecessor=_.predecessor)})})}),o}return Va}var Wa,jp;function Cp(){if(jp)return Wa;jp=1;var e=ct();Wa=r,r.CycleException=t;function r(n){var i={},s={},a=[];function o(c){if(e.has(s,c))throw new t;e.has(i,c)||(s[c]=!0,i[c]=!0,e.each(n.predecessors(c),o),delete s[c],a.push(c))}if(e.each(n.sinks(),o),e.size(i)!==n.nodeCount())throw new t;return a}function t(){}return t.prototype=new Error,Wa}var Ya,Pp;function H_(){if(Pp)return Ya;Pp=1;var e=Cp();Ya=r;function r(t){try{e(t)}catch(n){if(n instanceof e.CycleException)return!1;throw n}return!0}return Ya}var Ka,Lp;function Dp(){if(Lp)return Ka;Lp=1;var e=ct();Ka=r;function r(n,i,s){e.isArray(i)||(i=[i]);var a=(n.isDirected()?n.successors:n.neighbors).bind(n),o=[],c={};return e.each(i,function(f){if(!n.hasNode(f))throw new Error("Graph does not have node: "+f);t(n,f,s==="post",c,a,o)}),o}function t(n,i,s,a,o,c){e.has(a,i)||(a[i]=!0,s||c.push(i),e.each(o(i),function(f){t(n,f,s,a,o,c)}),s&&c.push(i))}return Ka}var Xa,zp;function eE(){if(zp)return Xa;zp=1;var e=Dp();Xa=r;function r(t,n){return e(t,n,"post")}return Xa}var Za,Fp;function tE(){if(Fp)return Za;Fp=1;var e=Dp();Za=r;function r(t,n){return e(t,n,"pre")}return Za}var Ja,Bp;function rE(){if(Bp)return Ja;Bp=1;var e=ct(),r=Ca(),t=Sp();Ja=n;function n(i,s){var a=new r,o={},c=new t,f;function l(m){var y=m.v===f?m.w:m.v,x=c.priority(y);if(x!==void 0){var _=s(m);_<x&&(o[y]=f,c.decrease(y,_))}}if(i.nodeCount()===0)return a;e.each(i.nodes(),function(m){c.add(m,Number.POSITIVE_INFINITY),a.setNode(m)}),c.decrease(i.nodes()[0],0);for(var p=!1;c.size()>0;){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<l;)for(var m=c[f],y=n(m),x=-1,_=y.length;++x<_;){var b=y[x],w=o[b];(w===void 0||r(w,i[b])&&!s.call(o,b))&&(o[b]=m[b])}return o});return nu=a,nu}var iu,Kp;function aE(){if(Kp)return iu;Kp=1;var e=xt(),r=Et(),t=Tt();function n(i){return function(s,a,o){var c=Object(s);if(!r(s)){var f=e(a,3);s=t(s),a=function(p){return f(c[p],p,c)}}var l=i(s,a,o);return l>-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;++s<a;){var o=t[s],c=n(o);if(c!=null&&(f===void 0?c===c&&!e(c):i(c,f)))var f=c,l=o}return l}return vu=r,vu}var yu,cv;function mE(){if(cv)return yu;cv=1;function e(r,t){return r>t}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);++a<o;){var l=s[a];l&&n(i,l,a,c)}return i})}return Su=t,Su}var qu,bv;function NE(){if(bv)return qu;bv=1;var e=EE(),r=xE(),t=r(function(n,i,s){e(n,i,s)});return qu=t,qu}var Ru,_v;function Ev(){if(_v)return Ru;_v=1;function e(r,t){return r<t}return Ru=e,Ru}var Ou,xv;function ME(){if(xv)return Ou;xv=1;var e=mu(),r=Ev(),t=Bt();function n(i){return i&&i.length?e(i,t,r):void 0}return Ou=n,Ou}var Au,Nv;function SE(){if(Nv)return Au;Nv=1;var e=mu(),r=xt(),t=Ev();function n(i,s){return i&&i.length?e(i,r(s,2),t):void 0}return Au=n,Au}var Iu,Mv;function qE(){if(Mv)return Iu;Mv=1;var e=ft(),r=function(){return e.Date.now()};return Iu=r,Iu}var Tu,Sv;function RE(){if(Sv)return Tu;Sv=1;var e=Br(),r=Kr(),t=$r(),n=ut(),i=yr();function s(a,o,c,f){if(!n(a))return a;o=r(o,a);for(var l=-1,p=o.length,m=p-1,y=a;y!=null&&++l<p;){var x=i(o[l]),_=c;if(x==="__proto__"||x==="constructor"||x==="prototype")return a;if(l!=m){var b=y[x];_=f?f(b,x,y):void 0,_===void 0&&(_=n(b)?b:t(o[l+1])?[]:{})}e(y,x,_),y=y[x]}return a}return Tu=s,Tu}var ku,qv;function OE(){if(qv)return ku;qv=1;var e=Xr(),r=RE(),t=Kr();function n(i,s,a){for(var o=-1,c=s.length,f={};++o<c;){var l=s[o],p=e(i,l);a(p,l)&&r(f,t(l,i),p)}return f}return ku=n,ku}var ju,Rv;function AE(){if(Rv)return ju;Rv=1;var e=OE(),r=mg();function t(n,i){return e(n,i,function(s,a){return r(n,a)})}return ju=t,ju}var Cu,Ov;function IE(){if(Ov)return Cu;Ov=1;var e=iv(),r=Jg(),t=tp();function n(i){return t(r(i,void 0,e),i+"")}return Cu=n,Cu}var Pu,Av;function TE(){if(Av)return Pu;Av=1;var e=AE(),r=IE(),t=r(function(n,i){return n==null?{}:e(n,i)});return Pu=t,Pu}var Lu,Iv;function kE(){if(Iv)return Lu;Iv=1;var e=Math.ceil,r=Math.max;function t(n,i,s,a){for(var o=-1,c=r(e((i-n)/(s||1)),0),f=Array(c);c--;)f[a?c:++o]=n,n+=s;return f}return Lu=t,Lu}var Du,Tv;function jE(){if(Tv)return Du;Tv=1;var e=kE(),r=Jr(),t=Hp();function n(i){return function(s,a,o){return o&&typeof o!="number"&&r(s,a,o)&&(a=o=void 0),s=t(s),a===void 0?(a=s,s=0):a=t(a),o=o===void 0?s<a?1:-1:t(o),e(s,a,o,i)}}return Du=n,Du}var zu,kv;function CE(){if(kv)return zu;kv=1;var e=jE(),r=e();return zu=r,zu}var Fu,jv;function PE(){if(jv)return Fu;jv=1;function e(r,t){var n=r.length;for(r.sort(t);n--;)r[n]=r[n].value;return r}return Fu=e,Fu}var Bu,Cv;function LE(){if(Cv)return Bu;Cv=1;var e=Qt();function r(t,n){if(t!==n){var i=t!==void 0,s=t===null,a=t===t,o=e(t),c=n!==void 0,f=n===null,l=n===n,p=e(n);if(!f&&!p&&!o&&t>n||o&&c&&l&&!f&&!p||s&&c&&l||!i&&l||!a)return 1;if(!s&&!o&&!p&&t<n||p&&i&&a&&!s&&!o||f&&i&&a||!c&&a||!l)return-1}return 0}return Bu=r,Bu}var $u,Pv;function DE(){if(Pv)return $u;Pv=1;var e=LE();function r(t,n,i){for(var s=-1,a=t.criteria,o=n.criteria,c=a.length,f=i.length;++s<c;){var l=e(a[s],o[s]);if(l){if(s>=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={};++i<s;){var c=i<a?t[i]:void 0;n(o,r[i],c)}return o}return Wu=e,Wu}var Yu,Bv;function GE(){if(Bv)return Yu;Bv=1;var e=Br(),r=$E();function t(n,i){return r(n||[],i||[],e)}return Yu=t,Yu}var Ku,$v;function Te(){if($v)return Ku;$v=1;var e;if(typeof Bn=="function")try{e={cloneDeep:sE(),constant:Xs(),defaults:oE(),each:Od(),filter:Mg(),find:dE(),flatten:iv(),forEach:qd(),forIn:gE(),has:Rg(),isUndefined:Ig(),last:pE(),map:Cg(),mapValues:vE(),max:yE(),merge:NE(),min:ME(),minBy:SE(),now:qE(),pick:TE(),range:CE(),reduce:zg(),sortBy:FE(),uniqueId:BE(),values:yp(),zipObject:GE()}}catch{}return e||(e=window._),Ku=e,Ku}var Xu,Gv;function UE(){if(Gv)return Xu;Gv=1,Xu=e;function e(){var n={};n._next=n._prev=n,this._sentinel=n}e.prototype.dequeue=function(){var n=this._sentinel,i=n._prev;if(i!==n)return r(i),i},e.prototype.enqueue=function(n){var i=this._sentinel;n._prev&&n._next&&r(n),n._next=i._next,i._next._prev=n,i._next=n,n._prev=i},e.prototype.toString=function(){for(var n=[],i=this._sentinel,s=i._prev;s!==i;)n.push(JSON.stringify(s,t)),s=s._prev;return"["+n.join(", ")+"]"};function r(n){n._prev._next=n._next,n._next._prev=n._prev,delete n._next,delete n._prev}function t(n,i){if(n!=="_next"&&n!=="_prev")return i}return Xu}var Zu,Uv;function VE(){if(Uv)return Zu;Uv=1;var e=Te(),r=lt().Graph,t=UE();Zu=i;var n=e.constant(1);function i(f,l){if(f.nodeCount()<=1)return[];var p=o(f,l||n),m=s(p.graph,p.buckets,p.zeroIdx);return e.flatten(e.map(m,function(y){return f.outEdges(y.v,y.w)}),!0)}function s(f,l,p){for(var m=[],y=l[l.length-1],x=l[0],_;f.nodeCount();){for(;_=x.dequeue();)a(f,l,p,_);for(;_=y.dequeue();)a(f,l,p,_);if(f.nodeCount()){for(var b=l.length-2;b>0;--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;c<l;++b,++c)m.points=[],_={width:0,height:0,edgeLabel:m,edgeObj:a,rank:c},x=r.addDummyNode(s,"edge",_,"_d"),c===y&&(_.width=m.width,_.height=m.height,_.dummy="edge-label",_.labelpos=m.labelpos),s.setEdge(o,x,{weight:m.weight},p),b===0&&s.graph().dummyChains.push(x),o=x;s.setEdge(o,f,{weight:m.weight},p)}}function i(s){e.forEach(s.graph().dummyChains,function(a){var o=s.node(a),c=o.edgeLabel,f;for(s.setEdge(o.edgeObj,c);o.dummy;)f=s.successors(a)[0],s.removeNode(a),c.points.push({x:o.x,y:o.y}),o.dummy==="edge-label"&&(c.x=o.x,c.y=o.y,c.width=o.width,c.height=o.height),a=f,o=s.node(a)})}return Hu}var ec,Kv;function Qr(){if(Kv)return ec;Kv=1;var e=Te();ec={longestPath:r,slack:t};function r(n){var i={};function s(a){var o=n.node(a);if(e.has(i,a))return o.rank;i[a]=!0;var c=e.min(e.map(n.outEdges(a),function(f){return s(f.w)-n.edge(f).minlen}));return(c===Number.POSITIVE_INFINITY||c===void 0||c===null)&&(c=0),o.rank=c}e.forEach(n.sources(),s)}function t(n,i){return n.node(i.w).rank-n.node(i.v).rank-n.edge(i).minlen}return ec}var tc,Xv;function Zv(){if(Xv)return tc;Xv=1;var e=Te(),r=lt().Graph,t=Qr().slack;tc=n;function n(o){var c=new r({directed:!1}),f=o.nodes()[0],l=o.nodeCount();c.setNode(f,{});for(var p,m;i(c,o)<l;)p=s(c,o),m=c.hasNode(p.v)?t(o,p):-t(o,p),a(c,o,m);return c}function i(o,c){function f(l){e.forEach(c.nodeEdges(l),function(p){var m=p.v,y=l===m?p.w:m;!o.hasNode(y)&&!t(c,p)&&(o.setNode(y,{}),o.setEdge(l,y,{}),f(y))})}return e.forEach(o.nodes(),f),o.nodeCount()}function s(o,c){return e.minBy(c.edges(),function(f){if(o.hasNode(f.v)!==o.hasNode(f.w))return t(c,f)})}function a(o,c,f){e.forEach(o.nodes(),function(l){c.node(l).rank+=f})}return tc}var rc,Jv;function KE(){if(Jv)return rc;Jv=1;var e=Te(),r=Zv(),t=Qr().slack,n=Qr().longestPath,i=lt().alg.preorder,s=lt().alg.postorder,a=nt().simplify;rc=o,o.initLowLimValues=p,o.initCutValues=c,o.calcCutValue=l,o.leaveEdge=y,o.enterEdge=x,o.exchangeEdges=_;function o(N){N=a(N),n(N);var S=r(N);p(S),c(S,N);for(var R,A;R=y(S);)A=x(S,N,R),_(S,N,R,A)}function c(N,S){var R=s(N,N.nodes());R=R.slice(0,R.length-1),e.forEach(R,function(A){f(N,S,A)})}function f(N,S,R){var A=N.node(R),j=A.parent;N.edge(R,j).cutvalue=l(N,S,R)}function l(N,S,R){var A=N.node(R),j=A.parent,I=!0,D=S.edge(R,j),z=0;return D||(I=!1,D=S.edge(j,R)),z=D.weight,e.forEach(S.nodeEdges(R),function($){var V=$.v===R,Y=V?$.w:$.v;if(Y!==j){var ee=V===I,J=S.edge($).weight;if(z+=ee?J:-J,w(N,R,Y)){var ae=N.edge(R,Y).cutvalue;z+=ee?-ae:ae}}}),z}function p(N,S){arguments.length<2&&(S=N.nodes()[0]),m(N,{},1,S)}function m(N,S,R,A,j){var I=R,D=N.node(A);return S[A]=!0,e.forEach(N.neighbors(A),function(z){e.has(S,z)||(R=m(N,S,R,z,A))}),D.low=I,D.lim=R++,j?D.parent=j:delete D.parent,R}function y(N){return e.find(N.edges(),function(S){return N.edge(S).cutvalue<0})}function x(N,S,R){var A=R.v,j=R.w;S.hasEdge(A,j)||(A=R.w,j=R.v);var I=N.node(A),D=N.node(j),z=I,$=!1;I.lim>D.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).maxRank<o.rank;)m++;y===p&&(x=!1)}if(!x){for(;m<l.length-1&&i.node(y=l[m+1]).minRank<=o.rank;)m++;y=l[m]}i.setParent(a,y),a=i.successors(a)[0]}})}function t(i,s,a,o){var c=[],f=[],l=Math.min(s[a].low,s[o].low),p=Math.max(s[a].lim,s[o].lim),m,y;m=a;do m=i.parent(m),c.push(m);while(m&&(s[m].low>l||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;f<l;++f)n(i,"borderLeft","_bl",a,c,f),n(i,"borderRight","_br",a,c,f)}}e.forEach(i.children(),s)}function n(i,s,a,o,c,f){var l={width:0,height:0,rank:f,borderType:s},p=c[s][f-1],m=r.addDummyNode(i,"border",l,a);c[s][f]=m,i.setParent(m,o),p&&i.setEdge(p,m,{weight:1})}return oc}var ac,r0;function HE(){if(r0)return ac;r0=1;var e=Te();ac={adjust:r,undo:t};function r(f){var l=f.graph().rankdir.toLowerCase();(l==="lr"||l==="rl")&&n(f)}function t(f){var l=f.graph().rankdir.toLowerCase();(l==="bt"||l==="rl")&&s(f),(l==="lr"||l==="rl")&&(o(f),n(f))}function n(f){e.forEach(f.nodes(),function(l){i(f.node(l))}),e.forEach(f.edges(),function(l){i(f.edge(l))})}function i(f){var l=f.width;f.width=f.height,f.height=l}function s(f){e.forEach(f.nodes(),function(l){a(f.node(l))}),e.forEach(f.edges(),function(l){var p=f.edge(l);e.forEach(p.points,a),e.has(p,"y")&&a(p)})}function a(f){f.y=-f.y}function o(f){e.forEach(f.nodes(),function(l){c(f.node(l))}),e.forEach(f.edges(),function(l){var p=f.edge(l);e.forEach(p.points,c),e.has(p,"x")&&c(p)})}function c(f){var l=f.x;f.x=f.y,f.y=l}return ac}var uc,n0;function ex(){if(n0)return uc;n0=1;var e=Te();uc=r;function r(t){var n={},i=e.filter(t.nodes(),function(f){return!t.children(f).length}),s=e.max(e.map(i,function(f){return t.node(f).rank})),a=e.map(e.range(s+1),function(){return[]});function o(f){if(!e.has(n,f)){n[f]=!0;var l=t.node(f);a[l.rank].push(f),e.forEach(t.successors(f),o)}}var c=e.sortBy(i,function(f){return t.node(f).rank});return e.forEach(c,o),a}return uc}var cc,i0;function tx(){if(i0)return cc;i0=1;var e=Te();cc=r;function r(n,i){for(var s=0,a=1;a<i.length;++a)s+=t(n,i[a-1],i[a]);return s}function t(n,i,s){for(var a=e.zipObject(s,e.map(s,function(m,y){return y})),o=e.flatten(e.map(i,function(m){return e.sortBy(e.map(n.outEdges(m),function(y){return{pos:a[y.w],weight:n.edge(y).weight}}),"pos")}),!0),c=1;c<s.length;)c<<=1;var f=2*c-1;c-=1;var l=e.map(new Array(f),function(){return 0}),p=0;return e.forEach(o.forEach(function(m){var y=m.pos+c;l[y]+=m.weight;for(var x=0;y>0;)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.barycenter<o.barycenter?-1:a.barycenter>o.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);R<w&&(S=0,E=e.cloneDeep(b),w=R)}p(m,E)}function f(m,y,x){return e.map(y,function(_){return i(m,_,x)})}function l(m,y){var x=new a;e.forEach(m,function(_){var b=_.graph().root,w=n(_,b,x,y);e.forEach(w.vs,function(E,N){_.node(E).order=N}),s(_,x,w.vs)})}function p(m,y){e.forEach(y,function(x){e.forEach(x,function(_,b){m.node(_).order=b})})}return vc}var mc,h0;function cx(){if(h0)return mc;h0=1;var e=Te(),r=lt().Graph,t=nt();mc={positionX:x,findType1Conflicts:n,findType2Conflicts:i,addConflict:a,hasConflict:o,verticalAlignment:c,horizontalCompaction:f,alignCoordinates:m,findSmallestWidthAlignment:p,balance:y};function n(w,E){var N={};function S(R,A){var j=0,I=0,D=R.length,z=e.last(A);return e.forEach(A,function($,V){var Y=s(w,$),ee=Y?w.node(Y).order:D;(Y||$===z)&&(e.forEach(A.slice(I,V+1),function(J){e.forEach(w.predecessors(J),function(ae){var be=w.node(ae),Z=be.order;(Z<j||ee<Z)&&!(be.dummy&&w.node(J).dummy)&&a(N,ae,J)})}),I=V+1,j=ee)}),A}return e.reduce(E,S),N}function i(w,E){var N={};function S(A,j,I,D,z){var $;e.forEach(e.range(j,I),function(V){$=A[V],w.node($).dummy&&e.forEach(w.predecessors($),function(Y){var ee=w.node(Y);ee.dummy&&(ee.order<D||ee.order>z)&&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<j[J]&&!o(N,z,J)&&(A[J]=z,A[z]=R[z]=R[J],D=j[J])}}})}),{root:R,align:A}}function f(w,E,N,S,R){var A={},j=l(w,E,N,R),I=R?"borderLeft":"borderRight";function D(V,Y){for(var ee=j.nodes(),J=ee.pop(),ae={};J;)ae[J]?V(J):(ae[J]=!0,ee.push(J),ee=ee.concat(Y(J))),J=ee.pop()}function z(V){A[V]=j.inEdges(V).reduce(function(Y,ee){return Math.max(Y,A[ee.v]+j.edge(ee))},0)}function $(V){var Y=j.outEdges(V).reduce(function(J,ae){return Math.min(J,A[ae.w]-j.edge(ae))},Number.POSITIVE_INFINITY),ee=w.node(V);Y!==Number.POSITIVE_INFINITY&&ee.borderType!==I&&(A[V]=Math.max(A[V],Y))}return D(z,j.predecessors.bind(j)),D($,j.successors.bind(j)),e.forEach(S,function(V){A[V]=A[N[V]]}),A}function l(w,E,N,S){var R=new r,A=w.graph(),j=_(A.nodesep,A.edgesep,S);return e.forEach(E,function(I){var D;e.forEach(I,function(z){var $=N[z];if(R.setNode($),D){var V=N[D],Y=R.edge(V,$);R.setEdge(V,$,Math.max(j(w,z,D),Y||0))}D=z})}),R}function p(w,E){return e.minBy(e.values(E),function(N){var S=Number.NEGATIVE_INFINITY,R=Number.POSITIVE_INFINITY;return e.forIn(N,function(A,j){var I=b(w,j)/2;S=Math.max(A+I,S),R=Math.min(A-I,R)}),S-R})}function m(w,E){var N=e.values(E),S=e.min(N),R=e.max(N);e.forEach(["u","d"],function(A){e.forEach(["l","r"],function(j){var I=A+j,D=w[I],z;if(D!==E){var $=e.values(D);z=j==="l"?S-e.min($):R-e.max($),z&&(w[I]=e.mapValues(D,function(V){return V+z}))}})})}function y(w,E){return e.mapValues(w.ul,function(N,S){if(E)return w[E.toLowerCase()][S];var R=e.sortBy(e.map(w,S));return(R[1]+R[2])/2})}function x(w){var E=t.buildLayerMatrix(w),N=e.merge(n(w,E),i(w,E)),S={},R;e.forEach(["u","d"],function(j){R=j==="u"?E:e.values(E).reverse(),e.forEach(["l","r"],function(I){I==="r"&&(R=e.map(R,function(V){return e.values(V).reverse()}));var D=(j==="u"?w.predecessors:w.successors).bind(w),z=c(w,R,N,D),$=f(w,R,z.root,z.align,I==="r");I==="r"&&($=e.mapValues($,function(V){return-V})),S[j+I]=$})});var A=p(w,S);return m(S,A),y(S,w.graph().align)}function _(w,E,N){return function(S,R,A){var j=S.node(R),I=S.node(A),D=0,z;if(D+=j.width/2,e.has(j,"labelpos"))switch(j.labelpos.toLowerCase()){case"l":z=-j.width/2;break;case"r":z=j.width/2;break}if(z&&(D+=N?z:-z),z=0,D+=(j.dummy?E:w)/2,D+=(I.dummy?E:w)/2,D+=I.width/2,e.has(I,"labelpos"))switch(I.labelpos.toLowerCase()){case"l":z=I.width/2;break;case"r":z=-I.width/2;break}return z&&(D+=N?z:-z),z=0,D}}function b(w,E){return w.node(E).width}return mc}var yc,d0;function fx(){if(d0)return yc;d0=1;var e=Te(),r=nt(),t=cx().positionX;yc=n;function n(s){s=r.asNonCompoundGraph(s),i(s),e.forEach(t(s),function(a,o){s.node(o).x=a})}function i(s){var a=r.buildLayerMatrix(s),o=s.graph().ranksep,c=0;e.forEach(a,function(f){var l=e.max(e.map(f,function(p){return s.node(p).height}));e.forEach(f,function(p){s.node(p).y=c+l/2}),c+=l+o})}return yc}var wc,g0;function lx(){if(g0)return wc;g0=1;var e=Te(),r=WE(),t=YE(),n=XE(),i=nt().normalizeRanks,s=ZE(),a=nt().removeEmptyRanks,o=JE(),c=QE(),f=HE(),l=ux(),p=fx(),m=nt(),y=lt().Graph;wc=x;function x(G,P){var X=P&&P.debugTiming?m.time:m.notime;X("layout",function(){var te=X(" buildLayoutGraph",function(){return D(G)});X(" runLayout",function(){_(te,X)}),X(" updateInputGraph",function(){b(G,te)})})}function _(G,P){P(" makeSpaceForEdgeLabels",function(){z(G)}),P(" removeSelfEdges",function(){ue(G)}),P(" acyclic",function(){r.run(G)}),P(" nestingGraph.run",function(){o.run(G)}),P(" rank",function(){n(m.asNonCompoundGraph(G))}),P(" injectEdgeLabelProxies",function(){$(G)}),P(" removeEmptyRanks",function(){a(G)}),P(" nestingGraph.cleanup",function(){o.cleanup(G)}),P(" normalizeRanks",function(){i(G)}),P(" assignRankMinMax",function(){V(G)}),P(" removeEdgeLabelProxies",function(){Y(G)}),P(" normalize.run",function(){t.run(G)}),P(" parentDummyChains",function(){s(G)}),P(" addBorderSegments",function(){c(G)}),P(" order",function(){l(G)}),P(" insertSelfEdges",function(){pe(G)}),P(" adjustCoordinateSystem",function(){f.adjust(G)}),P(" position",function(){p(G)}),P(" positionSelfEdges",function(){he(G)}),P(" removeBorderNodes",function(){Z(G)}),P(" normalize.undo",function(){t.undo(G)}),P(" fixupEdgeLabelCoords",function(){ae(G)}),P(" undoCoordinateSystem",function(){f.undo(G)}),P(" translateGraph",function(){ee(G)}),P(" assignNodeIntersects",function(){J(G)}),P(" reversePoints",function(){be(G)}),P(" acyclic.undo",function(){r.undo(G)})}function b(G,P){e.forEach(G.nodes(),function(X){var te=G.node(X),le=P.node(X);te&&(te.x=le.x,te.y=le.y,P.children(X).length&&(te.width=le.width,te.height=le.height))}),e.forEach(G.edges(),function(X){var te=G.edge(X),le=P.edge(X);te.points=le.points,e.has(le,"x")&&(te.x=le.x,te.y=le.y)}),G.graph().width=P.graph().width,G.graph().height=P.graph().height}var w=["nodesep","edgesep","ranksep","marginx","marginy"],E={ranksep:50,edgesep:20,nodesep:50,rankdir:"tb"},N=["acyclicer","ranker","rankdir","align"],S=["width","height"],R={width:0,height:0},A=["minlen","weight","width","height","labeloffset"],j={minlen:1,weight:1,width:0,height:0,labeloffset:10,labelpos:"r"},I=["labelpos"];function D(G){var P=new y({multigraph:!0,compound:!0}),X=_e(G.graph());return P.setGraph(e.merge({},E,ie(X,w),e.pick(X,N))),e.forEach(G.nodes(),function(te){var le=_e(G.node(te));P.setNode(te,e.defaults(ie(le,S),R)),P.setParent(te,G.parent(te))}),e.forEach(G.edges(),function(te){var le=_e(G.edge(te));P.setEdge(te,e.merge({},j,ie(le,A),e.pick(le,I)))}),P}function z(G){var P=G.graph();P.ranksep/=2,e.forEach(G.edges(),function(X){var te=G.edge(X);te.minlen*=2,te.labelpos.toLowerCase()!=="c"&&(P.rankdir==="TB"||P.rankdir==="BT"?te.width+=te.labeloffset:te.height+=te.labeloffset)})}function $(G){e.forEach(G.edges(),function(P){var X=G.edge(P);if(X.width&&X.height){var te=G.node(P.v),le=G.node(P.w),xe={rank:(le.rank-te.rank)/2+te.rank,e:P};m.addDummyNode(G,"edge-proxy",xe,"_ep")}})}function V(G){var P=0;e.forEach(G.nodes(),function(X){var te=G.node(X);te.borderTop&&(te.minRank=G.node(te.borderTop).rank,te.maxRank=G.node(te.borderBottom).rank,P=e.max(P,te.maxRank))}),G.graph().maxRank=P}function Y(G){e.forEach(G.nodes(),function(P){var X=G.node(P);X.dummy==="edge-proxy"&&(G.edge(X.e).labelRank=X.rank,G.removeNode(P))})}function ee(G){var P=Number.POSITIVE_INFINITY,X=0,te=Number.POSITIVE_INFINITY,le=0,xe=G.graph(),Le=xe.marginx||0,Je=xe.marginy||0;function tr(Qe){var Ve=Qe.x,Ee=Qe.y,Mt=Qe.width,Me=Qe.height;P=Math.min(P,Ve-Mt/2),X=Math.max(X,Ve+Mt/2),te=Math.min(te,Ee-Me/2),le=Math.max(le,Ee+Me/2)}e.forEach(G.nodes(),function(Qe){tr(G.node(Qe))}),e.forEach(G.edges(),function(Qe){var Ve=G.edge(Qe);e.has(Ve,"x")&&tr(Ve)}),P-=Le,te-=Je,e.forEach(G.nodes(),function(Qe){var Ve=G.node(Qe);Ve.x-=P,Ve.y-=te}),e.forEach(G.edges(),function(Qe){var Ve=G.edge(Qe);e.forEach(Ve.points,function(Ee){Ee.x-=P,Ee.y-=te}),e.has(Ve,"x")&&(Ve.x-=P),e.has(Ve,"y")&&(Ve.y-=te)}),xe.width=X-P+Le,xe.height=le-te+Je}function J(G){e.forEach(G.edges(),function(P){var X=G.edge(P),te=G.node(P.v),le=G.node(P.w),xe,Le;X.points?(xe=X.points[0],Le=X.points[X.points.length-1]):(X.points=[],xe=le,Le=te),X.points.unshift(m.intersectRect(te,xe)),X.points.push(m.intersectRect(le,Le))})}function ae(G){e.forEach(G.edges(),function(P){var X=G.edge(P);if(e.has(X,"x"))switch((X.labelpos==="l"||X.labelpos==="r")&&(X.width-=X.labeloffset),X.labelpos){case"l":X.x-=X.width/2+X.labeloffset;break;case"r":X.x+=X.width/2+X.labeloffset;break}})}function be(G){e.forEach(G.edges(),function(P){var X=G.edge(P);X.reversed&&X.points.reverse()})}function Z(G){e.forEach(G.nodes(),function(P){if(G.children(P).length){var X=G.node(P),te=G.node(X.borderTop),le=G.node(X.borderBottom),xe=G.node(e.last(X.borderLeft)),Le=G.node(e.last(X.borderRight));X.width=Math.abs(Le.x-xe.x),X.height=Math.abs(le.y-te.y),X.x=xe.x+X.width/2,X.y=te.y+X.height/2}}),e.forEach(G.nodes(),function(P){G.node(P).dummy==="border"&&G.removeNode(P)})}function ue(G){e.forEach(G.edges(),function(P){if(P.v===P.w){var X=G.node(P.v);X.selfEdges||(X.selfEdges=[]),X.selfEdges.push({e:P,label:G.edge(P)}),G.removeEdge(P)}})}function pe(G){var P=m.buildLayerMatrix(G);e.forEach(P,function(X){var te=0;e.forEach(X,function(le,xe){var Le=G.node(le);Le.order=xe+te,e.forEach(Le.selfEdges,function(Je){m.addDummyNode(G,"selfedge",{width:Je.label.width,height:Je.label.height,rank:Le.rank,order:xe+ ++te,e:Je.e,label:Je.label},"_se")}),delete Le.selfEdges})})}function he(G){e.forEach(G.nodes(),function(P){var X=G.node(P);if(X.dummy==="selfedge"){var te=G.node(X.e.v),le=te.x+te.width/2,xe=te.y,Le=X.x-le,Je=te.height/2;G.setEdge(X.e,X.label),G.removeNode(P),X.label.points=[{x:le+2*Le/3,y:xe-Je},{x:le+5*Le/6,y:xe-Je},{x:le+Le,y:xe},{x:le+5*Le/6,y:xe+Je},{x:le+2*Le/3,y:xe+Je}],X.label.x=X.x,X.label.y=X.y}})}function ie(G,P){return e.mapValues(e.pick(G,P),Number)}function _e(G){var P={};return e.forEach(G,function(X,te){P[te.toLowerCase()]=X}),P}return wc}var bc,p0;function hx(){if(p0)return bc;p0=1;var e=Te(),r=nt(),t=lt().Graph;bc={debugOrdering:n};function n(i){var s=r.buildLayerMatrix(i),a=new t({compound:!0,multigraph:!0}).setGraph({});return e.forEach(i.nodes(),function(o){a.setNode(o,{label:o}),a.setParent(o,"layer"+i.node(o).rank)}),e.forEach(i.edges(),function(o){a.setEdge(o.v,o.w,{},o.name)}),e.forEach(s,function(o,c){var f="layer"+c;a.setNode(f,{rank:"same"}),e.reduce(o,function(l,p){return a.setEdge(l,p,{style:"invis"}),p})}),a}return bc}var _c,v0;function dx(){return v0||(v0=1,_c="0.8.5"),_c}var Ec,m0;function gx(){return m0||(m0=1,Ec={graphlib:lt(),layout:lx(),debug:hx(),util:{time:nt().time,notime:nt().notime},version:dx()}),Ec}var y0=gx(),px=Of(y0);class Hr{constructor(r){this.id="dagre",this.options={},Object.assign(this.options,Hr.defaultOptions,r)}execute(r,t){return fe(this,void 0,void 0,function*(){return this.genericDagreLayout(!1,r,Object.assign(Object.assign({},this.options),t))})}assign(r,t){return fe(this,void 0,void 0,function*(){yield this.genericDagreLayout(!0,r,Object.assign(Object.assign({},this.options),t))})}genericDagreLayout(r,t,n){return fe(this,void 0,void 0,function*(){const{nodeSize:i}=n,s=new y0.graphlib.Graph;s.setGraph(n),s.setDefaultEdgeLabel(()=>({}));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/n<this.theta?r.addForce(this.body):(this.NW&&this.NW.updateForce(r),this.NE&&this.NE.updateForce(r),this.SW&&this.SW.updateForce(r),this.SE&&this.SE.updateForce(r))}}}const vx={center:[0,0],width:300,height:300,kr:5,kg:1,mode:"normal",preventOverlap:!1,dissuadeHubs:!1,maxIteration:0,ks:.1,ksmax:10,tao:.1};class mx{constructor(r={}){this.options=r,this.id="forceAtlas2",this.options=Object.assign(Object.assign({},vx),r)}execute(r,t){return fe(this,void 0,void 0,function*(){return this.genericForceAtlas2Layout(!1,r,t)})}assign(r,t){return fe(this,void 0,void 0,function*(){yield this.genericForceAtlas2Layout(!0,r,t)})}genericForceAtlas2Layout(r,t,n){return fe(this,void 0,void 0,function*(){const i=t.getAllEdges(),s=t.getAllNodes(),a=this.formatOptions(n,s.length),{width:o,height:c,prune:f,maxIteration:l,nodeSize:p,center:m}=a;if(!(s!=null&&s.length)||s.length===1)return Pt(t,r,m);const y=s.map(w=>it(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;E<x.length;E+=1){const{source:N,target:S}=x[E],R=_.getDegree(N),A=_.getDegree(N);if(R<=1){const j=_.getNode(S);_.mergeNodeData(N,{x:j.data.x,y:j.data.y})}else if(A<=1){const j=_.getNode(N);_.mergeNodeData(S,{x:j.data.x,y:j.data.y})}}const w=Object.assign(Object.assign({},a),{prune:!1,barnesHut:!1});this.run(_,t,100,b,r,w)}return{nodes:y,edges:i}})}getSizes(r,t){const n=r.getAllNodes(),i={};for(let s=0;s<n.length;s+=1){const a=n[s];i[a.id]=qn(t,void 0)(a)}return i}formatOptions(r={},t){const n=Object.assign(Object.assign({},this.options),r),{center:i,width:s,height:a,barnesHut:o,prune:c,maxIteration:f,kr:l,kg:p}=n;return n.width=!s&&typeof window<"u"?window.innerWidth:s,n.height=!a&&typeof window<"u"?window.innerHeight:a,n.center=i||[n.width/2,n.height/2],o===void 0&&t>250&&(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;b<l.length;b+=1){const{data:w,id:E}=l[b];if(y[E]=[0,0],c){const N={id:b,rx:w.x,ry:w.y,mass:1,g:o,degree:r.getDegree(E)};_[E]=new xc(N)}}for(;m>0;)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;_<x.length;_+=1){const{id:b}=x[_];c[b]=[...p[b]],p[b]=[0,0]}return p=this.getAttrForces(r,i,s,l,p,n),y&&(m&&i>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;m<p.length;m+=1){const{source:y,target:x}=p[m],_=r.getNode(y),b=r.getNode(x),w=r.getDegree(y),E=r.getDegree(x);if(l&&(w<=1||E<=1))continue;const N=[b.data.x-_.data.x,b.data.y-_.data.y];let S=Math.hypot(N[0],N[1]);S=S<1e-4?1e-4:S,N[0]=N[0]/S,N[1]=N[1]/S,o&&t<n&&(S=S-i[y]-i[x]);let R=S,A=R;f==="linlog"&&(R=Math.log(1+S),A=R),c&&(R=S/w,A=S/E),o&&t<n&&S<=0?(R=0,A=0):o&&t<n&&S>0&&(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<f;E+=1){const{id:N,data:S}=c[E];o&&r.getDegree(N)<=1||(n[N].setPos(S.x,S.y),S.x>=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;E<f;E+=1){const{id:N}=c[E];o&&r.getDegree(N)<=1||n[N].in(b)&&w.insert(n[N])}for(let E=0;E<f;E+=1){const{id:N,data:S}=c[E],R=r.getDegree(N);if(o&&R<=1)continue;n[N].resetForce(),w.updateForce(n[N]),t[N][0]-=n[N].fx,t[N][1]-=n[N].fy;const A=[S.x-a[0],S.y-a[1]];let j=Math.hypot(A[0],A[1]);j=j<1e-4?1e-4:j,A[0]=A[0]/j,A[1]=A[1]/j;const I=s*(R+1);t[N][0]-=I*A[0],t[N][1]-=I*A[1]}return t}getRepGraForces(r,t,n,i,s,a,o){const{preventOverlap:c,kr:f,kg:l,center:p,prune:m}=o,y=r.getAllNodes(),x=y.length;for(let _=0;_<x;_+=1){const b=y[_],w=r.getDegree(b.id);for(let R=_+1;R<x;R+=1){const A=y[R],j=r.getDegree(A.id);if(m&&(w<=1||j<=1))continue;const I=[A.data.x-b.data.x,A.data.y-b.data.y];let D=Math.hypot(I[0],I[1]);D=D<1e-4?1e-4:D,I[0]=I[0]/D,I[1]=I[1]/D,c&&t<n&&(D=D-a[b.id]-a[A.id]);let z=f*(w+1)*(j+1)/D;c&&t<n&&D<0?z=s*(w+1)*(j+1):c&&t<n&&D===0?z=0:c&&t<n&&D>0&&(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;E<p;E+=1){const{id:N}=l[E],S=r.getDegree(N);if(c&&S<=1)continue;const R=[t[N][0]-n[N][0],t[N][1]-n[N][1]],A=Math.hypot(R[0],R[1]),j=[t[N][0]+n[N][0],t[N][1]+n[N][1]],I=Math.hypot(j[0],j[1]);m[E]=A,y[E]=I/2,x+=(S+1)*m[E],_+=(S+1)*y[E]}const w=b;b=o*_/x,w!==0&&(b=b>1.5*w?1.5*w:b);for(let E=0;E<p;E+=1){const{id:N,data:S}=l[E],R=r.getDegree(N);if(c&&R<=1||me(S.fx)&&me(S.fy))continue;let A=a*b/(1+b*Math.sqrt(m[E])),j=Math.hypot(t[N][0],t[N][1]);j=j<1e-4?1e-4:j;const I=f/j;A=A>I?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;n<r;n++)this.runOneStep(this.lastGraph,this.lastClusterMap,this.lastOptions);const t={nodes:this.lastLayoutNodes,edges:this.lastLayoutEdges};return this.lastAssign&&t.nodes.forEach(n=>this.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;){const J=en(I),ae=tn(I);(ae+1)*J>=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<S.length;J++){const ae=S[J];let be;if(_&&(be=_(t.getNode(ae.id))),be&&(be.row!==void 0||be.col!==void 0)){const Z={row:be.row,col:be.col};if(Z.col===void 0)for(Z.col=0;Nc($,Z);)Z.col++;else if(Z.row===void 0)for(Z.row=0;Nc($,Z);)Z.row++;Y[ae.id]=Z,w0($,Z)}xx(ae,s,D,z,Y,I,V,$)}const ee={nodes:S,edges:E};return r&&S.forEach(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<r.length;s++){const a=Math.random()*t,o=Math.random()*t;i.push([a,o])}return i}},Mx=800,Sx={iterations:10,height:10,width:10,speed:100,gravity:10,k:5},qx=(e,r)=>{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;_<i;_++)n.forEach((b,w)=>{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<s(e[o])/2+s(e[f])/2){const y=n*n/m;t[o].x+=l/m*y,t[o].y+=p/m*y}})})},Ox=(e,r,t,n,i,s,a,o)=>{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;te<N.length;te++)if(N[te].id===c){I=N[te];break}}else I=c||N[0];const D=jx(N,I.id),z=wf({nodes:N,edges:S}),$=yf(z),V=Px($,D);Cx($,D,V+1);const Y=$[D];let ee=R-j[0]>j[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<r;i++){const s=[];for(let a=0;a<t;a++)e[i][a]!==0?s.push(1/(e[i][a]*e[i][a])):s.push(0);n.push(s)}return n},jx=(e,r)=>{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<n;i++)if(e[r][i]===1/0){e[r][i]=t,e[i][r]=t;for(let s=0;s<n;s++)e[i][s]!==1/0&&e[r][s]===1/0&&(e[r][s]=t+e[i][s],e[s][r]=t+e[i][s])}for(let i=0;i<n;i++)if(i!==r){for(let s=0;s<n;s++)if(e[i][s]===1/0){let a=Math.abs(e[r][i]-e[r][s]);a=a===0?1:a,e[i][s]=a}}},Px=(e,r)=>{let t=0;for(let n=0;n<e[r].length;n++)e[r][n]!==1/0&&(t=e[r][n]>t?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]})}})})();