@antv/layout 1.0.0-alpha.17 → 1.0.0-alpha.18
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/5eff5240d48719e2c5a3.worker.js +2 -0
- package/dist/5eff5240d48719e2c5a3.worker.js.map +1 -0
- package/dist/index.min.js +1 -1
- package/dist/index.min.js.map +1 -1
- package/esm/5eff5240d48719e2c5a3.worker.js +2 -0
- package/esm/5eff5240d48719e2c5a3.worker.js.map +1 -0
- package/esm/index.esm.js +1 -1
- package/esm/index.esm.js.map +1 -1
- package/lib/dagre/acyclic.d.ts +4 -0
- package/lib/dagre/add-border-segments.d.ts +2 -0
- package/lib/dagre/coordinate-system.d.ts +4 -0
- package/lib/dagre/data/list.d.ts +12 -0
- package/lib/dagre/greedy-fas.d.ts +3 -0
- package/lib/dagre/layout.d.ts +18 -0
- package/lib/dagre/nesting-graph.d.ts +8 -0
- package/lib/dagre/normalize.d.ts +5 -0
- package/lib/dagre/order/add-subgraph-constraints.d.ts +3 -0
- package/lib/dagre/order/barycenter.d.ts +14 -0
- package/lib/dagre/order/build-layer-graph.d.ts +3 -0
- package/lib/dagre/order/cross-count.d.ts +3 -0
- package/lib/dagre/order/index.d.ts +2 -0
- package/lib/dagre/order/init-data-order.d.ts +6 -0
- package/lib/dagre/order/init-order.d.ts +3 -0
- package/lib/dagre/order/resolve-conflicts.d.ts +20 -0
- package/lib/dagre/order/sort-subgraph.d.ts +7 -0
- package/lib/dagre/order/sort.d.ts +7 -0
- package/lib/dagre/parent-dummy-chains.d.ts +3 -0
- package/lib/dagre/position/bk.d.ts +25 -0
- package/lib/dagre/position/index.d.ts +7 -0
- package/lib/dagre/rank/feasible-tree.d.ts +5 -0
- package/lib/dagre/rank/index.d.ts +2 -0
- package/lib/dagre/rank/network-simplex.d.ts +16 -0
- package/lib/dagre/rank/util.d.ts +6 -0
- package/lib/dagre/util.d.ts +35 -0
- package/lib/dagre.d.ts +31 -0
- package/lib/index.d.ts +1 -0
- package/lib/types.d.ts +24 -3
- package/lib/util/common.d.ts +11 -0
- package/lib/util/function.d.ts +7 -0
- package/package.json +1 -1
- package/dist/6b692814699bee26e220.worker.js +0 -2
- package/dist/6b692814699bee26e220.worker.js.map +0 -1
- package/esm/6b692814699bee26e220.worker.js +0 -2
- package/esm/6b692814699bee26e220.worker.js.map +0 -1
package/esm/index.esm.js
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
var t={161:t=>{var e=Object.prototype.hasOwnProperty,r="~";function n(){}function o(t,e,r){this.fn=t,this.context=e,this.once=r||!1}function i(t,e,n,i,s){if("function"!=typeof n)throw new TypeError("The listener must be a function");var a=new o(n,i||t,s),u=r?r+e:e;return t._events[u]?t._events[u].fn?t._events[u]=[t._events[u],a]:t._events[u].push(a):(t._events[u]=a,t._eventsCount++),t}function s(t,e){0==--t._eventsCount?t._events=new n:delete t._events[e]}function a(){this._events=new n,this._eventsCount=0}Object.create&&(n.prototype=Object.create(null),(new n).__proto__||(r=!1)),a.prototype.eventNames=function(){var t,n,o=[];if(0===this._eventsCount)return o;for(n in t=this._events)e.call(t,n)&&o.push(r?n.slice(1):n);return Object.getOwnPropertySymbols?o.concat(Object.getOwnPropertySymbols(t)):o},a.prototype.listeners=function(t){var e=r?r+t:t,n=this._events[e];if(!n)return[];if(n.fn)return[n.fn];for(var o=0,i=n.length,s=new Array(i);o<i;o++)s[o]=n[o].fn;return s},a.prototype.listenerCount=function(t){var e=r?r+t:t,n=this._events[e];return n?n.fn?1:n.length:0},a.prototype.emit=function(t,e,n,o,i,s){var a=r?r+t:t;if(!this._events[a])return!1;var u,h,c=this._events[a],l=arguments.length;if(c.fn){switch(c.once&&this.removeListener(t,c.fn,void 0,!0),l){case 1:return c.fn.call(c.context),!0;case 2:return c.fn.call(c.context,e),!0;case 3:return c.fn.call(c.context,e,n),!0;case 4:return c.fn.call(c.context,e,n,o),!0;case 5:return c.fn.call(c.context,e,n,o,i),!0;case 6:return c.fn.call(c.context,e,n,o,i,s),!0}for(h=1,u=new Array(l-1);h<l;h++)u[h-1]=arguments[h];c.fn.apply(c.context,u)}else{var f,d=c.length;for(h=0;h<d;h++)switch(c[h].once&&this.removeListener(t,c[h].fn,void 0,!0),l){case 1:c[h].fn.call(c[h].context);break;case 2:c[h].fn.call(c[h].context,e);break;case 3:c[h].fn.call(c[h].context,e,n);break;case 4:c[h].fn.call(c[h].context,e,n,o);break;default:if(!u)for(f=1,u=new Array(l-1);f<l;f++)u[f-1]=arguments[f];c[h].fn.apply(c[h].context,u)}}return!0},a.prototype.on=function(t,e,r){return i(this,t,e,r,!1)},a.prototype.once=function(t,e,r){return i(this,t,e,r,!0)},a.prototype.removeListener=function(t,e,n,o){var i=r?r+t:t;if(!this._events[i])return this;if(!e)return s(this,i),this;var a=this._events[i];if(a.fn)a.fn!==e||o&&!a.once||n&&a.context!==n||s(this,i);else{for(var u=0,h=[],c=a.length;u<c;u++)(a[u].fn!==e||o&&!a[u].once||n&&a[u].context!==n)&&h.push(a[u]);h.length?this._events[i]=1===h.length?h[0]:h:s(this,i)}return this},a.prototype.removeAllListeners=function(t){var e;return t?(e=r?r+t:t,this._events[e]&&s(this,e)):(this._events=new n,this._eventsCount=0),this},a.prototype.off=a.prototype.removeListener,a.prototype.addListener=a.prototype.on,a.prefixed=r,a.EventEmitter=a,t.exports=a},825:(t,e,r)=>{var n=r(475),o=["stopLayout","calculateLayout"];t.exports=function(){var t=new Worker(URL.createObjectURL(new Blob(['var t={d:(e,r)=>{for(var n in r)t.o(r,n)&&!t.o(e,n)&&Object.defineProperty(e,n,{enumerable:!0,get:r[n]})},o:(t,e)=>Object.prototype.hasOwnProperty.call(t,e)},e={};t.d(e,{calculateLayout:()=>Je,stopLayout:()=>Ke});var r=function(){return r=Object.assign||function(t){for(var e,r=1,n=arguments.length;r<n;r++)for(var o in e=arguments[r])Object.prototype.hasOwnProperty.call(e,o)&&(t[o]=e[o]);return t},r.apply(this,arguments)};function n(t,e){var r={};for(var n in t)Object.prototype.hasOwnProperty.call(t,n)&&e.indexOf(n)<0&&(r[n]=t[n]);if(null!=t&&"function"==typeof Object.getOwnPropertySymbols){var o=0;for(n=Object.getOwnPropertySymbols(t);o<n.length;o++)e.indexOf(n[o])<0&&Object.prototype.propertyIsEnumerable.call(t,n[o])&&(r[n[o]]=t[n[o]])}return r}function o(t,e,r,n){return new(r||(r=Promise))((function(o,i){function s(t){try{h(n.next(t))}catch(t){i(t)}}function a(t){try{h(n.throw(t))}catch(t){i(t)}}function h(t){var e;t.done?o(t.value):(e=t.value,e instanceof r?e:new r((function(t){t(e)}))).then(s,a)}h((n=n.apply(t,e||[])).next())}))}function i(t,e){var r,n,o,i,s={label:0,sent:function(){if(1&o[0])throw o[1];return o[1]},trys:[],ops:[]};return i={next:a(0),throw:a(1),return:a(2)},"function"==typeof Symbol&&(i[Symbol.iterator]=function(){return this}),i;function a(a){return function(h){return function(a){if(r)throw new TypeError("Generator is already executing.");for(;i&&(i=0,a[0]&&(s=0)),s;)try{if(r=1,n&&(o=2&a[0]?n.return:a[0]?n.throw||((o=n.return)&&o.call(n),0):n.next)&&!(o=o.call(n,a[1])).done)return o;switch(n=0,o&&(a=[2&a[0],o.value]),a[0]){case 0:case 1:o=a;break;case 4:return s.label++,{value:a[1],done:!1};case 5:s.label++,n=a[1],a=[0];continue;case 7:a=s.ops.pop(),s.trys.pop();continue;default:if(!((o=(o=s.trys).length>0&&o[o.length-1])||6!==a[0]&&2!==a[0])){s=0;continue}if(3===a[0]&&(!o||a[1]>o[0]&&a[1]<o[3])){s.label=a[1];break}if(6===a[0]&&s.label<o[1]){s.label=o[1],o=a;break}if(o&&s.label<o[2]){s.label=o[2],s.ops.push(a);break}o[2]&&s.ops.pop(),s.trys.pop();continue}a=e.call(t,s)}catch(t){a=[6,t],n=0}finally{r=o=0}if(5&a[0])throw a[1];return{value:a[0]?a[1]:void 0,done:!0}}([a,h])}}}function s(t,e){var r="function"==typeof Symbol&&t[Symbol.iterator];if(!r)return t;var n,o,i=r.call(t),s=[];try{for(;(void 0===e||e-- >0)&&!(n=i.next()).done;)s.push(n.value)}catch(t){o={error:t}}finally{try{n&&!n.done&&(r=i.return)&&r.call(i)}finally{if(o)throw o.error}}return s}function a(t,e,r){if(r||2===arguments.length)for(var n,o=0,i=e.length;o<i;o++)!n&&o in e||(n||(n=Array.prototype.slice.call(e,0,o)),n[o]=e[o]);return t.concat(n||Array.prototype.slice.call(e))}Object.create,Object.create;var h="*";const u=function(){function t(){this._events={}}return t.prototype.on=function(t,e,r){return this._events[t]||(this._events[t]=[]),this._events[t].push({callback:e,once:!!r}),this},t.prototype.once=function(t,e){return this.on(t,e,!0)},t.prototype.emit=function(t){for(var e=this,r=[],n=1;n<arguments.length;n++)r[n-1]=arguments[n];var o=this._events[t]||[],i=this._events[h]||[],s=function(n){for(var o=n.length,i=0;i<o;i++)if(n[i]){var s=n[i],a=s.callback;s.once&&(n.splice(i,1),0===n.length&&delete e._events[t],o--,i--),a.apply(e,r)}};s(o),s(i)},t.prototype.off=function(t,e){if(t)if(e){for(var r=this._events[t]||[],n=r.length,o=0;o<n;o++)r[o].callback===e&&(r.splice(o,1),n--,o--);0===r.length&&delete this._events[t]}else delete this._events[t];else this._events={};return this},t.prototype.getEvents=function(){return this._events},t}();function c(t,e,r,n){for(;t.length;){const o=t.shift();if(r(o))return!0;e.add(o.id),n(o.id).forEach((r=>{e.has(r.id)||(e.add(r.id),t.push(r))}))}return!1}function l(t,e,r,n){if(r(t))return!0;e.add(t.id);for(const o of n(t.id))if(!e.has(o.id)&&l(o,e,r,n))return!0;return!1}class f extends u{nodeMap=new Map;edgeMap=new Map;inEdgesMap=new Map;outEdgesMap=new Map;bothEdgesMap=new Map;treeIndices=new Map;changes=[];batchCount=0;onChanged=()=>{};constructor(t){super(),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))}batch=t=>{this.batchCount+=1,t(),this.batchCount-=1,this.batchCount||this.commit()};commit(){const t=this.changes;this.changes=[];const e={graph:this,changes:t};this.emit("changed",e),this.onChanged(e)}reduceChanges(t){let e=[];return t.forEach((t=>{switch(t.type){case"NodeRemoved":{let r=!1;e=e.filter((e=>{if("NodeAdded"===e.type){const n=e.value.id===t.value.id;return n&&(r=!0),!n}return"NodeDataUpdated"===e.type?e.id!==t.value.id:"TreeStructureChanged"!==e.type||e.nodeId!==t.value.id})),r||e.push(t);break}case"EdgeRemoved":{let r=!1;e=e.filter((e=>{if("EdgeAdded"===e.type){const n=e.value.id===t.value.id;return n&&(r=!0),!n}return"EdgeDataUpdated"!==e.type&&"EdgeUpdated"!==e.type||e.id!==t.value.id})),r||e.push(t);break}case"NodeDataUpdated":case"EdgeDataUpdated":case"EdgeUpdated":{const r=e.find((e=>e.type===t.type&&e.id===t.id&&e.propertyName===t.propertyName));r?r.newValue=t.newValue:e.push(t);break}case"TreeStructureDetached":e=e.filter((e=>"TreeStructureAttached"===e.type?e.treeKey!==t.treeKey:"TreeStructureChanged"!==e.type||e.treeKey!==t.treeKey)),e.push(t);break;case"TreeStructureChanged":{const r=e.find((e=>"TreeStructureChanged"===e.type&&e.treeKey===t.treeKey&&e.nodeId===t.nodeId));r?r.newParentId=t.newParentId:e.push(t);break}default:e.push(t)}})),e}checkNodeExistence(t){this.getNode(t)}hasNode(t){return this.nodeMap.has(t)}areNeighbors(t,e){return this.getNeighbors(e).some((e=>e.id===t))}getNode(t){const e=this.nodeMap.get(t);if(!e)throw new Error("Node not found for id: "+t);return e}getRelatedEdges(t,e){if(this.checkNodeExistence(t),"in"===e){const e=this.inEdgesMap.get(t);return Array.from(e)}if("out"===e){const e=this.outEdgesMap.get(t);return Array.from(e)}{const e=this.bothEdgesMap.get(t);return Array.from(e)}}getDegree(t,e){return this.getRelatedEdges(t,e).length}getSuccessors(t){const e=this.getRelatedEdges(t,"out").map((t=>this.getNode(t.target)));return Array.from(new Set(e))}getPredecessors(t){const e=this.getRelatedEdges(t,"in").map((t=>this.getNode(t.source)));return Array.from(new Set(e))}getNeighbors(t){const e=this.getPredecessors(t),r=this.getSuccessors(t);return Array.from(new Set([...e,...r]))}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((e=>{e.childrenMap.set(t.id,new Set)})),this.changes.push({type:"NodeAdded",value:t})}addNodes(t){this.batch((()=>{for(const e of t)this.doAddNode(e)}))}addNode(t){this.addNodes([t])}doRemoveNode(t){const e=this.getNode(t);this.bothEdgesMap.get(t)?.forEach((t=>this.doRemoveEdge(t.id))),this.nodeMap.delete(t),this.treeIndices.forEach((e=>{e.childrenMap.get(t)?.forEach((t=>{e.parentMap.delete(t.id)})),e.parentMap.delete(t),e.childrenMap.delete(t)})),this.changes.push({type:"NodeRemoved",value:e})}removeNodes(t){this.batch((()=>{t.forEach((t=>this.doRemoveNode(t)))}))}removeNode(t){this.removeNodes([t])}updateNodeDataProperty(t,e,r){const n=this.getNode(t);this.batch((()=>{const o=n.data[e],i=r;n.data[e]=i,this.changes.push({type:"NodeDataUpdated",id:t,propertyName:e,oldValue:o,newValue:i})}))}mergeNodeData(t,e){this.batch((()=>{Object.entries(e).forEach((([e,r])=>{this.updateNodeDataProperty(t,e,r)}))}))}updateNodeData(...t){const e=t[0],r=this.getNode(e);if("string"==typeof t[1])return void this.updateNodeDataProperty(e,t[1],t[2]);let n;if("function"==typeof t[1]){const e=t[1];n=e(r.data)}else"object"==typeof t[1]&&(n=t[1]);this.batch((()=>{const t=r.data,o=n;r.data=n,this.changes.push({type:"NodeDataUpdated",id:e,oldValue:t,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 e=this.getEdge(t);return{edge:e,source:this.getNode(e.source),target:this.getNode(e.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 e=this.inEdgesMap.get(t.target),r=this.outEdgesMap.get(t.source),n=this.bothEdgesMap.get(t.source),o=this.bothEdgesMap.get(t.target);e.add(t),r.add(t),n.add(t),o.add(t),this.changes.push({type:"EdgeAdded",value:t})}addEdges(t){this.batch((()=>{for(const e of t)this.doAddEdge(e)}))}addEdge(t){this.addEdges([t])}doRemoveEdge(t){const e=this.getEdge(t),r=this.outEdgesMap.get(e.source),n=this.inEdgesMap.get(e.target),o=this.bothEdgesMap.get(e.source),i=this.bothEdgesMap.get(e.target);r.delete(e),n.delete(e),o.delete(e),i.delete(e),this.edgeMap.delete(t),this.changes.push({type:"EdgeRemoved",value:e})}removeEdges(t){this.batch((()=>{t.forEach((t=>this.doRemoveEdge(t)))}))}removeEdge(t){this.removeEdges([t])}updateEdgeSource(t,e){const r=this.getEdge(t);this.checkNodeExistence(e);const n=r.source,o=e;this.outEdgesMap.get(n).delete(r),this.bothEdgesMap.get(n).delete(r),this.outEdgesMap.get(o).add(r),this.bothEdgesMap.get(o).add(r),r.source=e,this.batch((()=>{this.changes.push({type:"EdgeUpdated",id:t,propertyName:"source",oldValue:n,newValue:o})}))}updateEdgeTarget(t,e){const r=this.getEdge(t);this.checkNodeExistence(e);const n=r.target,o=e;this.inEdgesMap.get(n).delete(r),this.bothEdgesMap.get(n).delete(r),this.inEdgesMap.get(o).add(r),this.bothEdgesMap.get(o).add(r),r.target=e,this.batch((()=>{this.changes.push({type:"EdgeUpdated",id:t,propertyName:"target",oldValue:n,newValue:o})}))}updateEdgeDataProperty(t,e,r){const n=this.getEdge(t);this.batch((()=>{const o=n.data[e],i=r;n.data[e]=i,this.changes.push({type:"EdgeDataUpdated",id:t,propertyName:e,oldValue:o,newValue:i})}))}updateEdgeData(...t){const e=t[0],r=this.getEdge(e);if("string"==typeof t[1])return void this.updateEdgeDataProperty(e,t[1],t[2]);let n;if("function"==typeof t[1]){const e=t[1];n=e(r.data)}else"object"==typeof t[1]&&(n=t[1]);this.batch((()=>{const t=r.data,o=n;r.data=n,this.changes.push({type:"EdgeDataUpdated",id:e,oldValue:t,newValue:o})}))}mergeEdgeData(t,e){this.batch((()=>{Object.entries(e).forEach((([e,r])=>{this.updateEdgeDataProperty(t,e,r)}))}))}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,e){this.batch((()=>{this.attachTreeStructure(e);const r=[],n=Array.isArray(t)?t:[t];for(;n.length;){const t=n.shift();r.push(t),t.children&&n.push(...t.children)}this.addNodes(r),r.forEach((t=>{t.children?.forEach((r=>{this.setParent(r.id,t.id,e)}))}))}))}getRoots(t){return this.checkTreeExistence(t),this.getAllNodes().filter((e=>!this.getParent(e.id,t)))}getChildren(t,e){this.checkNodeExistence(t),this.checkTreeExistence(e);const r=this.treeIndices.get(e).childrenMap.get(t);return Array.from(r||[])}getParent(t,e){return this.checkNodeExistence(t),this.checkTreeExistence(e),this.treeIndices.get(e).parentMap.get(t)||null}getAncestors(t,e){const r=[];let n,o=this.getNode(t);for(;n=this.getParent(o.id,e);)r.push(n),o=n;return r}setParent(t,e,r){this.checkTreeExistence(r);const n=this.treeIndices.get(r),o=this.getNode(t),i=n.parentMap.get(t),s=this.getNode(e);n.parentMap.set(t,s),i&&n.childrenMap.get(i.id)?.delete(o);let a=n.childrenMap.get(s.id);a||(a=new Set,n.childrenMap.set(s.id,a)),a.add(o),this.batch((()=>{this.changes.push({type:"TreeStructureChanged",treeKey:r,nodeId:t,oldParentId:i?.id,newParentId:s.id})}))}dfsTree(t,e,r){return l(this.getNode(t),new Set,e,(t=>this.getChildren(t,r)))}bfsTree(t,e,r){return c([this.getNode(t)],new Set,e,(t=>this.getChildren(t,r)))}getAllNodes(){return Array.from(this.nodeMap.values())}getAllEdges(){return Array.from(this.edgeMap.values())}bfs(t,e,r="out"){const n={in:this.getPredecessors.bind(this),out:this.getSuccessors.bind(this),both:this.getNeighbors.bind(this)}[r];return c([this.getNode(t)],new Set,e,n)}dfs(t,e,r="out"){const n={in:this.getPredecessors.bind(this),out:this.getSuccessors.bind(this),both:this.getNeighbors.bind(this)}[r];return l(this.getNode(t),new Set,e,n)}clone(){const t=this.getAllNodes().map((t=>({...t,data:{...t.data}}))),e=this.getAllEdges().map((t=>({...t,data:{...t.data}}))),r=new f({nodes:t,edges:e});return this.treeIndices.forEach((({parentMap:t,childrenMap:e},n)=>{const o=new Map;t.forEach(((t,e)=>{o.set(e,r.getNode(t.id))}));const i=new Map;e.forEach(((t,e)=>{i.set(e,new Set(Array.from(t).map((t=>r.getNode(t.id)))))})),r.treeIndices.set(n,{parentMap:o,childrenMap:i})})),r}toJSON(){return JSON.stringify({nodes:this.getAllNodes(),edges:this.getAllEdges()})}}var d=/-(\\w)/g,g=(function(t){return t.replace(d,(function(t,e){return e?e.toUpperCase():""}))},Object.create(null),Array.isArray),p=function(t){for(var e=[],r=t.length,n=0;n<r;n+=1){e[n]=[];for(var o=0;o<r;o+=1)n===o?e[n][o]=0:0!==t[n][o]&&t[n][o]?e[n][o]=t[n][o]:e[n][o]=1/0}for(var i=0;i<r;i+=1)for(n=0;n<r;n+=1)for(o=0;o<r;o+=1)e[n][o]>e[n][i]+e[i][o]&&(e[n][o]=e[n][i]+e[i][o]);return e},y=function(t,e){var r=t.nodes,n=t.edges,o=[],i={};if(!r)throw new Error("invalid nodes data!");return r&&r.forEach((function(t,e){i[t.id]=e,o.push([])})),null==n||n.forEach((function(t){var r=t.source,n=t.target,s=i[r],a=i[n];void 0!==s&&void 0!==a&&(o[s][a]=1,e||(o[a][s]=1))})),o},m=function(t,e){return Math.sqrt((t.x-e.x)*(t.x-e.x)+(t.y-e.y)*(t.y-e.y))},w={}.toString;const v=function(t,e){return w.call(t)==="[object "+e+"]"},x=function(t){return v(t,"Number")};var M=function(t){if(null===t)return t;if(t instanceof Date)return new Date(t.getTime());if(t instanceof Array){var e=[];return t.forEach((function(t){e.push(t)})),e.map((function(t){return M(t)}))}if("object"==typeof t){var r={};return Object.keys(t).forEach((function(e){r[e]=M(t[e])})),r}return t},b=function(t,e){var r=M(t);return r.data=r.data||{},e&&(x(r.data.x)||(r.data.x=Math.random()*e[0]),x(r.data.y)||(r.data.y=Math.random()*e[1])),r};const E=function(t){return"function"==typeof t},N=function(t){var e=typeof t;return null!==t&&"object"===e||"function"===e};function S(t,e){return E(e)?e:x(e)?function(){return e}:function(){return t}}function A(t,e,r){return void 0===r&&(r=!0),e||0===e?E(e)?e:x(e)?function(){return e}:g(e)?function(){if(r){var n=Math.max.apply(Math,a([],s(e),!1));return isNaN(n)?t:n}return e}:N(e)?function(){if(r){var n=Math.max(e.width,e.height);return isNaN(n)?t:n}return[e.width,e.height]}:function(){return t}:function(e){var r=(e.data||{}).size;return r?g(r)?r[0]>r[1]?r[0]:r[1]:N(r)?r.width>r.height?r.width:r.height:r:t}}var k=function(t,e,n){var o=t.getAllNodes(),i=t.getAllEdges();return(null==o?void 0:o.length)?1===o.length?(e&&t.mergeNodeData(o[0].id,{x:n[0],y:n[1]}),{nodes:[r(r({},o[0]),{data:r(r({},o[0].data),{x:n[0],y:n[1]})})],edges:i}):void 0:{nodes:[],edges:i}},D={radius:null,startRadius:null,endRadius:null,startAngle:0,endAngle:2*Math.PI,clockwise:!0,divisions:1,ordering:null,angleRatio:1},I=function(){function t(t){void 0===t&&(t={}),this.options=t,this.id="circular",this.options=r(r({},D),t)}return t.prototype.execute=function(t,e){return o(this,void 0,void 0,(function(){return i(this,(function(r){return[2,this.genericCircularLayout(!1,t,e)]}))}))},t.prototype.assign=function(t,e){return o(this,void 0,void 0,(function(){return i(this,(function(r){switch(r.label){case 0:return[4,this.genericCircularLayout(!0,t,e)];case 1:return r.sent(),[2]}}))}))},t.prototype.genericCircularLayout=function(t,e,n){return o(this,void 0,void 0,(function(){var o,a,h,u,c,l,f,d,g,p,y,m,w,v,x,M,E,N,D,I,z,T,C,O,P,q,F,L,j,V,W,$,G,U,B;return i(this,(function(i){if(o=r(r({},this.options),n),a=o.width,h=o.height,u=o.center,c=o.divisions,l=o.startAngle,f=void 0===l?0:l,d=o.endAngle,g=void 0===d?2*Math.PI:d,p=o.angleRatio,y=o.ordering,m=o.clockwise,w=o.nodeSpacing,v=o.nodeSize,x=e.getAllNodes(),M=e.getAllEdges(),E=s(R(a,h,u),3),N=E[0],D=E[1],I=E[2],!(z=null==x?void 0:x.length)||1===z)return[2,k(e,t,I)];for(T=(g-f)/z,C=o.radius,O=o.startRadius,P=o.endRadius,w?(q=S(10,w),F=A(10,v),L=-1/0,x.forEach((function(t){var e=F(t);L<e&&(L=e)})),j=0,x.forEach((function(t,e){j+=0===e?L||10:(q(t)||0)+(L||10)})),C=j/(2*Math.PI)):C||O||P?!O&&P?O=P:O&&!P&&(P=O):C=Math.min(D,N)/2,V=T*p,W=[],W="topology"===y?_(e,x):"topology-directed"===y?_(e,x,!0):"degree"===y?function(t,e){var r=[];return e.forEach((function(t,e){r.push(b(t))})),r.sort((function(e,r){return t.getDegree(e.id,"both")-t.getDegree(r.id,"both")})),r}(e,x):x.map((function(t){return b(t)})),$=Math.ceil(z/c),G=0;G<z;++G)(U=C)||null===O||null===P||(U=O+G*(P-O)/(z-1)),U||(U=10+100*G/(z-1)),B=f+G%$*V+2*Math.PI/c*Math.floor(G/$),m||(B=g-G%$*V-2*Math.PI/c*Math.floor(G/$)),W[G].data.x=I[0]+Math.cos(B)*U,W[G].data.y=I[1]+Math.sin(B)*U;return t&&W.forEach((function(t){e.mergeNodeData(t.id,{x:t.data.x,y:t.data.y})})),[2,{nodes:W,edges:M}]}))}))},t}(),_=function(t,e,r){void 0===r&&(r=!1);var n=[b(e[0])],o={},i=e.length;o[e[0].id]=!0;var s=0;return e.forEach((function(a,h){if(0!==h)if(h!==i-1&&t.getDegree(a.id,"both")===t.getDegree(e[h+1].id,"both")&&!t.areNeighbors(n[s].id,a.id)||o[a.id]){for(var u=r?t.getSuccessors(n[s].id):t.getNeighbors(n[s].id),c=!1,l=0;l<u.length;l++){var f=u[l];if(t.getDegree(f.id)===t.getDegree(a.id)&&!o[f.id]){n.push(b(f)),o[f.id]=!0,c=!0;break}}for(var d=0;!c&&(o[e[d].id]||(n.push(b(e[d])),o[e[d].id]=!0,c=!0),++d!==i););}else n.push(b(a)),o[a.id]=!0,s++})),n},R=function(t,e,r){var n=t,o=e,i=r;return n||"undefined"==typeof window||(n=window.innerWidth),o||"undefined"==typeof window||(o=window.innerHeight),i||(i=[n/2,o/2]),[n,o,i]};const z=function(t){return v(t,"String")};var T={nodeSize:30,nodeSpacing:10,preventOverlap:!1,sweep:void 0,equidistant:!1,startAngle:1.5*Math.PI,clockwise:!0,maxLevelDiff:void 0,sortBy:"degree"},C=function(){function t(t){void 0===t&&(t={}),this.options=t,this.id="concentric",this.options=r(r({},T),t)}return t.prototype.execute=function(t,e){return o(this,void 0,void 0,(function(){return i(this,(function(r){return[2,this.genericConcentricLayout(!1,t,e)]}))}))},t.prototype.assign=function(t,e){return o(this,void 0,void 0,(function(){return i(this,(function(r){return this.genericConcentricLayout(!0,t,e),[2]}))}))},t.prototype.genericConcentricLayout=function(t,e,n){return o(this,void 0,void 0,(function(){var o,s,a,h,u,c,l,f,d,p,y,m,w,v,M,S,A,D,I,_,R,T,C,O,P,q,F,L,j,V,W,$,G,U,B,H,K,J;return i(this,(function(i){if(o=r(r({},this.options),n),s=o.center,a=o.width,h=o.height,u=o.sortBy,c=o.maxLevelDiff,l=o.sweep,f=o.clockwise,d=o.equidistant,p=o.preventOverlap,y=o.startAngle,m=void 0===y?1.5*Math.PI:y,w=o.nodeSize,v=o.nodeSpacing,M=e.getAllNodes(),S=e.getAllEdges(),A=a||"undefined"==typeof window?a:window.innerWidth,D=h||"undefined"==typeof window?h:window.innerHeight,I=s||[A/2,D/2],!(null==M?void 0:M.length)||1===M.length)return[2,k(e,t,I)];if(_=[],T=0,R=g(w)?Math.max(w[0],w[1]):w,g(v)?T=Math.max(v[0],v[1]):x(v)&&(T=v),M.forEach((function(t){var e=b(t);_.push(e);var r=R,n=e.data;g(n.size)?r=Math.max(n.size[0],n.size[1]):x(n.size)?r=n.size:N(n.size)&&(r=Math.max(n.size.width,n.size.height)),R=Math.max(R,r),E(v)&&(T=Math.max(v(t),T))})),C={},_.forEach((function(t,e){C[t.id]=e})),z(O=u)&&void 0!==_[0].data[O]||(O="degree"),"degree"===O?_.sort((function(t,r){return e.getDegree(r.id,"both")-e.getDegree(t.id,"both")})):_.sort((function(t,e){return e.data[O]-t.data[O]})),P=_[0],q=(c||("degree"===O?e.getDegree(P.id,"both"):P.data[O]))/4,L=(F=[{nodes:[]}])[0],_.forEach((function(t){if(L.nodes.length>0){var r="degree"===O?Math.abs(e.getDegree(L.nodes[0].id,"both")-e.getDegree(t.id,"both")):Math.abs(L.nodes[0].data[O]-t.data[O]);q&&r>=q&&(L={nodes:[]},F.push(L))}L.nodes.push(t)})),j=R+T,p||(V=F.length>0&&F[0].nodes.length>1,W=Math.min(A,D)/2-j,$=W/(F.length+(V?1:0)),j=Math.min(j,$)),G=0,F.forEach((function(t){var e=void 0===l?2*Math.PI-2*Math.PI/t.nodes.length:l;if(t.dTheta=e/Math.max(1,t.nodes.length-1),t.nodes.length>1&&p){var r=Math.cos(t.dTheta)-Math.cos(0),n=Math.sin(t.dTheta)-Math.sin(0),o=Math.sqrt(j*j/(r*r+n*n));G=Math.max(o,G)}t.r=G,G+=j})),d){for(U=0,B=0,H=0;H<F.length;H++)K=F[H],J=(K.r||0)-B,U=Math.max(U,J);B=0,F.forEach((function(t,e){0===e&&(B=t.r||0),t.r=B,B+=U}))}return F.forEach((function(t){var e=t.dTheta||0,r=t.r||0;t.nodes.forEach((function(t,n){var o=m+(f?1:-1)*e*n;t.data.x=I[0]+r*Math.cos(o),t.data.y=I[1]+r*Math.sin(o)}))})),t&&_.forEach((function(t){return e.mergeNodeData(t.id,{x:t.data.x,y:t.data.y})})),[2,{nodes:_,edges:S}]}))}))},t}();function O(t,e,r,n){if(isNaN(e)||isNaN(r))return t;var o,i,s,a,h,u,c,l,f,d=t._root,g={data:n},p=t._x0,y=t._y0,m=t._x1,w=t._y1;if(!d)return t._root=g,t;for(;d.length;)if((u=e>=(i=(p+m)/2))?p=i:m=i,(c=r>=(s=(y+w)/2))?y=s:w=s,o=d,!(d=d[l=c<<1|u]))return o[l]=g,t;if(a=+t._x.call(null,d.data),h=+t._y.call(null,d.data),e===a&&r===h)return g.next=d,o?o[l]=g:t._root=g,t;do{o=o?o[l]=new Array(4):t._root=new Array(4),(u=e>=(i=(p+m)/2))?p=i:m=i,(c=r>=(s=(y+w)/2))?y=s:w=s}while((l=c<<1|u)==(f=(h>=s)<<1|a>=i));return o[f]=d,o[l]=g,t}function P(t,e,r,n,o){this.node=t,this.x0=e,this.y0=r,this.x1=n,this.y1=o}function q(t){return t[0]}function F(t){return t[1]}function L(t,e,r){var n=new j(null==e?q:e,null==r?F:r,NaN,NaN,NaN,NaN);return null==t?n:n.addAll(t)}function j(t,e,r,n,o,i){this._x=t,this._y=e,this._x0=r,this._y0=n,this._x1=o,this._y1=i,this._root=void 0}function V(t){for(var e={data:t.data},r=e;t=t.next;)r=r.next={data:t.data};return e}var W=L.prototype=j.prototype;function $(t){return function(){return t}}function G(t){return 1e-6*(t()-.5)}W.copy=function(){var t,e,r=new j(this._x,this._y,this._x0,this._y0,this._x1,this._y1),n=this._root;if(!n)return r;if(!n.length)return r._root=V(n),r;for(t=[{source:n,target:r._root=new Array(4)}];n=t.pop();)for(var o=0;o<4;++o)(e=n.source[o])&&(e.length?t.push({source:e,target:n.target[o]=new Array(4)}):n.target[o]=V(e));return r},W.add=function(t){const e=+this._x.call(null,t),r=+this._y.call(null,t);return O(this.cover(e,r),e,r,t)},W.addAll=function(t){var e,r,n,o,i=t.length,s=new Array(i),a=new Array(i),h=1/0,u=1/0,c=-1/0,l=-1/0;for(r=0;r<i;++r)isNaN(n=+this._x.call(null,e=t[r]))||isNaN(o=+this._y.call(null,e))||(s[r]=n,a[r]=o,n<h&&(h=n),n>c&&(c=n),o<u&&(u=o),o>l&&(l=o));if(h>c||u>l)return this;for(this.cover(h,u).cover(c,l),r=0;r<i;++r)O(this,s[r],a[r],t[r]);return this},W.cover=function(t,e){if(isNaN(t=+t)||isNaN(e=+e))return this;var r=this._x0,n=this._y0,o=this._x1,i=this._y1;if(isNaN(r))o=(r=Math.floor(t))+1,i=(n=Math.floor(e))+1;else{for(var s,a,h=o-r||1,u=this._root;r>t||t>=o||n>e||e>=i;)switch(a=(e<n)<<1|t<r,(s=new Array(4))[a]=u,u=s,h*=2,a){case 0:o=r+h,i=n+h;break;case 1:r=o-h,i=n+h;break;case 2:o=r+h,n=i-h;break;case 3:r=o-h,n=i-h}this._root&&this._root.length&&(this._root=u)}return this._x0=r,this._y0=n,this._x1=o,this._y1=i,this},W.data=function(){var t=[];return this.visit((function(e){if(!e.length)do{t.push(e.data)}while(e=e.next)})),t},W.extent=function(t){return arguments.length?this.cover(+t[0][0],+t[0][1]).cover(+t[1][0],+t[1][1]):isNaN(this._x0)?void 0:[[this._x0,this._y0],[this._x1,this._y1]]},W.find=function(t,e,r){var n,o,i,s,a,h,u,c=this._x0,l=this._y0,f=this._x1,d=this._y1,g=[],p=this._root;for(p&&g.push(new P(p,c,l,f,d)),null==r?r=1/0:(c=t-r,l=e-r,f=t+r,d=e+r,r*=r);h=g.pop();)if(!(!(p=h.node)||(o=h.x0)>f||(i=h.y0)>d||(s=h.x1)<c||(a=h.y1)<l))if(p.length){var y=(o+s)/2,m=(i+a)/2;g.push(new P(p[3],y,m,s,a),new P(p[2],o,m,y,a),new P(p[1],y,i,s,m),new P(p[0],o,i,y,m)),(u=(e>=m)<<1|t>=y)&&(h=g[g.length-1],g[g.length-1]=g[g.length-1-u],g[g.length-1-u]=h)}else{var w=t-+this._x.call(null,p.data),v=e-+this._y.call(null,p.data),x=w*w+v*v;if(x<r){var M=Math.sqrt(r=x);c=t-M,l=e-M,f=t+M,d=e+M,n=p.data}}return n},W.remove=function(t){if(isNaN(i=+this._x.call(null,t))||isNaN(s=+this._y.call(null,t)))return this;var e,r,n,o,i,s,a,h,u,c,l,f,d=this._root,g=this._x0,p=this._y0,y=this._x1,m=this._y1;if(!d)return this;if(d.length)for(;;){if((u=i>=(a=(g+y)/2))?g=a:y=a,(c=s>=(h=(p+m)/2))?p=h:m=h,e=d,!(d=d[l=c<<1|u]))return this;if(!d.length)break;(e[l+1&3]||e[l+2&3]||e[l+3&3])&&(r=e,f=l)}for(;d.data!==t;)if(n=d,!(d=d.next))return this;return(o=d.next)&&delete d.next,n?(o?n.next=o:delete n.next,this):e?(o?e[l]=o:delete e[l],(d=e[0]||e[1]||e[2]||e[3])&&d===(e[3]||e[2]||e[1]||e[0])&&!d.length&&(r?r[f]=d:this._root=d),this):(this._root=o,this)},W.removeAll=function(t){for(var e=0,r=t.length;e<r;++e)this.remove(t[e]);return this},W.root=function(){return this._root},W.size=function(){var t=0;return this.visit((function(e){if(!e.length)do{++t}while(e=e.next)})),t},W.visit=function(t){var e,r,n,o,i,s,a=[],h=this._root;for(h&&a.push(new P(h,this._x0,this._y0,this._x1,this._y1));e=a.pop();)if(!t(h=e.node,n=e.x0,o=e.y0,i=e.x1,s=e.y1)&&h.length){var u=(n+i)/2,c=(o+s)/2;(r=h[3])&&a.push(new P(r,u,c,i,s)),(r=h[2])&&a.push(new P(r,n,c,u,s)),(r=h[1])&&a.push(new P(r,u,o,i,c)),(r=h[0])&&a.push(new P(r,n,o,u,c))}return this},W.visitAfter=function(t){var e,r=[],n=[];for(this._root&&r.push(new P(this._root,this._x0,this._y0,this._x1,this._y1));e=r.pop();){var o=e.node;if(o.length){var i,s=e.x0,a=e.y0,h=e.x1,u=e.y1,c=(s+h)/2,l=(a+u)/2;(i=o[0])&&r.push(new P(i,s,a,c,l)),(i=o[1])&&r.push(new P(i,c,a,h,l)),(i=o[2])&&r.push(new P(i,s,l,c,u)),(i=o[3])&&r.push(new P(i,c,l,h,u))}n.push(e)}for(;e=n.pop();)t(e.node,e.x0,e.y0,e.x1,e.y1);return this},W.x=function(t){return arguments.length?(this._x=t,this):this._x},W.y=function(t){return arguments.length?(this._y=t,this):this._y};var U={value:()=>{}};function B(){for(var t,e=0,r=arguments.length,n={};e<r;++e){if(!(t=arguments[e]+"")||t in n||/[\\s.]/.test(t))throw new Error("illegal type: "+t);n[t]=[]}return new H(n)}function H(t){this._=t}function K(t,e){for(var r,n=0,o=t.length;n<o;++n)if((r=t[n]).name===e)return r.value}function J(t,e,r){for(var n=0,o=t.length;n<o;++n)if(t[n].name===e){t[n]=U,t=t.slice(0,n).concat(t.slice(n+1));break}return null!=r&&t.push({name:e,value:r}),t}H.prototype=B.prototype={constructor:H,on:function(t,e){var r,n,o=this._,i=(n=o,(t+"").trim().split(/^|\\s+/).map((function(t){var e="",r=t.indexOf(".");if(r>=0&&(e=t.slice(r+1),t=t.slice(0,r)),t&&!n.hasOwnProperty(t))throw new Error("unknown type: "+t);return{type:t,name:e}}))),s=-1,a=i.length;if(!(arguments.length<2)){if(null!=e&&"function"!=typeof e)throw new Error("invalid callback: "+e);for(;++s<a;)if(r=(t=i[s]).type)o[r]=J(o[r],t.name,e);else if(null==e)for(r in o)o[r]=J(o[r],t.name,null);return this}for(;++s<a;)if((r=(t=i[s]).type)&&(r=K(o[r],t.name)))return r},copy:function(){var t={},e=this._;for(var r in e)t[r]=e[r].slice();return new H(t)},call:function(t,e){if((r=arguments.length-2)>0)for(var r,n,o=new Array(r),i=0;i<r;++i)o[i]=arguments[i+2];if(!this._.hasOwnProperty(t))throw new Error("unknown type: "+t);for(i=0,r=(n=this._[t]).length;i<r;++i)n[i].value.apply(e,o)},apply:function(t,e,r){if(!this._.hasOwnProperty(t))throw new Error("unknown type: "+t);for(var n=this._[t],o=0,i=n.length;o<i;++o)n[o].value.apply(e,r)}};const Y=B;var X,Q,Z=0,tt=0,et=0,rt=1e3,nt=0,ot=0,it=0,st="object"==typeof performance&&performance.now?performance:Date,at="object"==typeof window&&window.requestAnimationFrame?window.requestAnimationFrame.bind(window):function(t){setTimeout(t,17)};function ht(){return ot||(at(ut),ot=st.now()+it)}function ut(){ot=0}function ct(){this._call=this._time=this._next=null}function lt(t,e,r){var n=new ct;return n.restart(t,e,r),n}function ft(){ot=(nt=st.now())+it,Z=tt=0;try{!function(){ht(),++Z;for(var t,e=X;e;)(t=ot-e._time)>=0&&e._call.call(void 0,t),e=e._next;--Z}()}finally{Z=0,function(){for(var t,e,r=X,n=1/0;r;)r._call?(n>r._time&&(n=r._time),t=r,r=r._next):(e=r._next,r._next=null,r=t?t._next=e:X=e);Q=t,gt(n)}(),ot=0}}function dt(){var t=st.now(),e=t-nt;e>rt&&(it-=e,nt=t)}function gt(t){Z||(tt&&(tt=clearTimeout(tt)),t-ot>24?(t<1/0&&(tt=setTimeout(ft,t-st.now()-it)),et&&(et=clearInterval(et))):(et||(nt=st.now(),et=setInterval(dt,rt)),Z=1,at(ft)))}ct.prototype=lt.prototype={constructor:ct,restart:function(t,e,r){if("function"!=typeof t)throw new TypeError("callback is not a function");r=(null==r?ht():+r)+(null==e?0:+e),this._next||Q===this||(Q?Q._next=this:X=this,Q=this),this._call=t,this._time=r,gt()},stop:function(){this._call&&(this._call=null,this._time=1/0,gt())}};const pt=1664525,yt=1013904223,mt=4294967296;function wt(t){return t.x}function vt(t){return t.y}var xt=10,Mt=Math.PI*(3-Math.sqrt(5));function bt(t){var e,r=1,n=.001,o=1-Math.pow(n,1/300),i=0,s=.6,a=new Map,h=lt(l),u=Y("tick","end"),c=function(){let t=1;return()=>(t=(pt*t+yt)%mt)/mt}();function l(){f(),u.call("tick",e),r<n&&(h.stop(),u.call("end",e))}function f(n){var h,u,c=t.length;void 0===n&&(n=1);for(var l=0;l<n;++l)for(r+=(i-r)*o,a.forEach((function(t){t(r)})),h=0;h<c;++h)null==(u=t[h]).fx?u.x+=u.vx*=s:(u.x=u.fx,u.vx=0),null==u.fy?u.y+=u.vy*=s:(u.y=u.fy,u.vy=0);return e}function d(){for(var e,r=0,n=t.length;r<n;++r){if((e=t[r]).index=r,null!=e.fx&&(e.x=e.fx),null!=e.fy&&(e.y=e.fy),isNaN(e.x)||isNaN(e.y)){var o=xt*Math.sqrt(.5+r),i=r*Mt;e.x=o*Math.cos(i),e.y=o*Math.sin(i)}(isNaN(e.vx)||isNaN(e.vy))&&(e.vx=e.vy=0)}}function g(e){return e.initialize&&e.initialize(t,c),e}return null==t&&(t=[]),d(),e={tick:f,restart:function(){return h.restart(l),e},stop:function(){return h.stop(),e},nodes:function(r){return arguments.length?(t=r,d(),a.forEach(g),e):t},alpha:function(t){return arguments.length?(r=+t,e):r},alphaMin:function(t){return arguments.length?(n=+t,e):n},alphaDecay:function(t){return arguments.length?(o=+t,e):+o},alphaTarget:function(t){return arguments.length?(i=+t,e):i},velocityDecay:function(t){return arguments.length?(s=1-t,e):1-s},randomSource:function(t){return arguments.length?(c=t,a.forEach(g),e):c},force:function(t,r){return arguments.length>1?(null==r?a.delete(t):a.set(t,g(r)),e):a.get(t)},find:function(e,r,n){var o,i,s,a,h,u=0,c=t.length;for(null==n?n=1/0:n*=n,u=0;u<c;++u)(s=(o=e-(a=t[u]).x)*o+(i=r-a.y)*i)<n&&(h=a,n=s);return h},on:function(t,r){return arguments.length>1?(u.on(t,r),e):u.on(t)}}}function Et(){var t,e,r,n,o,i=$(-30),s=1,a=1/0,h=.81;function u(r){var o,i=t.length,s=L(t,wt,vt).visitAfter(l);for(n=r,o=0;o<i;++o)e=t[o],s.visit(f)}function c(){if(t){var e,r,n=t.length;for(o=new Array(n),e=0;e<n;++e)r=t[e],o[r.index]=+i(r,e,t)}}function l(t){var e,r,n,i,s,a=0,h=0;if(t.length){for(n=i=s=0;s<4;++s)(e=t[s])&&(r=Math.abs(e.value))&&(a+=e.value,h+=r,n+=r*e.x,i+=r*e.y);t.x=n/h,t.y=i/h}else{(e=t).x=e.data.x,e.y=e.data.y;do{a+=o[e.data.index]}while(e=e.next)}t.value=a}function f(t,i,u,c){if(!t.value)return!0;var l=t.x-e.x,f=t.y-e.y,d=c-i,g=l*l+f*f;if(d*d/h<g)return g<a&&(0===l&&(g+=(l=G(r))*l),0===f&&(g+=(f=G(r))*f),g<s&&(g=Math.sqrt(s*g)),e.vx+=l*t.value*n/g,e.vy+=f*t.value*n/g),!0;if(!(t.length||g>=a)){(t.data!==e||t.next)&&(0===l&&(g+=(l=G(r))*l),0===f&&(g+=(f=G(r))*f),g<s&&(g=Math.sqrt(s*g)));do{t.data!==e&&(d=o[t.data.index]*n/g,e.vx+=l*d,e.vy+=f*d)}while(t=t.next)}}return u.initialize=function(e,n){t=e,r=n,c()},u.strength=function(t){return arguments.length?(i="function"==typeof t?t:$(+t),c(),u):i},u.distanceMin=function(t){return arguments.length?(s=t*t,u):Math.sqrt(s)},u.distanceMax=function(t){return arguments.length?(a=t*t,u):Math.sqrt(a)},u.theta=function(t){return arguments.length?(h=t*t,u):Math.sqrt(h)},u}function Nt(t){return t.index}function St(t,e){var r=t.get(e);if(!r)throw new Error("node not found: "+e);return r}function At(t){var e,r,n,o,i,s,a=Nt,h=function(t){return 1/Math.min(o[t.source.index],o[t.target.index])},u=$(30),c=1;function l(n){for(var o=0,a=t.length;o<c;++o)for(var h,u,l,f,d,g,p,y=0;y<a;++y)u=(h=t[y]).source,f=(l=h.target).x+l.vx-u.x-u.vx||G(s),d=l.y+l.vy-u.y-u.vy||G(s),f*=g=((g=Math.sqrt(f*f+d*d))-r[y])/g*n*e[y],d*=g,l.vx-=f*(p=i[y]),l.vy-=d*p,u.vx+=f*(p=1-p),u.vy+=d*p}function f(){if(n){var s,h,u=n.length,c=t.length,l=new Map(n.map(((t,e)=>[a(t,e,n),t])));for(s=0,o=new Array(u);s<c;++s)(h=t[s]).index=s,"object"!=typeof h.source&&(h.source=St(l,h.source)),"object"!=typeof h.target&&(h.target=St(l,h.target)),o[h.source.index]=(o[h.source.index]||0)+1,o[h.target.index]=(o[h.target.index]||0)+1;for(s=0,i=new Array(c);s<c;++s)h=t[s],i[s]=o[h.source.index]/(o[h.source.index]+o[h.target.index]);e=new Array(c),d(),r=new Array(c),g()}}function d(){if(n)for(var r=0,o=t.length;r<o;++r)e[r]=+h(t[r],r,t)}function g(){if(n)for(var e=0,o=t.length;e<o;++e)r[e]=+u(t[e],e,t)}return null==t&&(t=[]),l.initialize=function(t,e){n=t,s=e,f()},l.links=function(e){return arguments.length?(t=e,f(),l):t},l.id=function(t){return arguments.length?(a=t,l):a},l.iterations=function(t){return arguments.length?(c=+t,l):c},l.strength=function(t){return arguments.length?(h="function"==typeof t?t:$(+t),d(),l):h},l.distance=function(t){return arguments.length?(u="function"==typeof t?t:$(+t),g(),l):u},l}function kt(t){return t.x+t.vx}function Dt(t){return t.y+t.vy}function It(t){var e,r,n,o=1,i=1;function s(){for(var t,s,h,u,c,l,f,d=e.length,g=0;g<i;++g)for(s=L(e,kt,Dt).visitAfter(a),t=0;t<d;++t)h=e[t],l=r[h.index],f=l*l,u=h.x+h.vx,c=h.y+h.vy,s.visit(p);function p(t,e,r,i,s){var a=t.data,d=t.r,g=l+d;if(!a)return e>u+g||i<u-g||r>c+g||s<c-g;if(a.index>h.index){var p=u-a.x-a.vx,y=c-a.y-a.vy,m=p*p+y*y;m<g*g&&(0===p&&(m+=(p=G(n))*p),0===y&&(m+=(y=G(n))*y),m=(g-(m=Math.sqrt(m)))/m*o,h.vx+=(p*=m)*(g=(d*=d)/(f+d)),h.vy+=(y*=m)*g,a.vx-=p*(g=1-g),a.vy-=y*g)}}}function a(t){if(t.data)return t.r=r[t.data.index];for(var e=t.r=0;e<4;++e)t[e]&&t[e].r>t.r&&(t.r=t[e].r)}function h(){if(e){var n,o,i=e.length;for(r=new Array(i),n=0;n<i;++n)o=e[n],r[o.index]=+t(o,n,e)}}return"function"!=typeof t&&(t=$(null==t?1:+t)),s.initialize=function(t,r){e=t,n=r,h()},s.iterations=function(t){return arguments.length?(i=+t,s):i},s.strength=function(t){return arguments.length?(o=+t,s):o},s.radius=function(e){return arguments.length?(t="function"==typeof e?e:$(+e),h(),s):t},s}function _t(t){var e,r,n,o=$(.1);function i(t){for(var o,i=0,s=e.length;i<s;++i)(o=e[i]).vx+=(n[i]-o.x)*r[i]*t}function s(){if(e){var i,s=e.length;for(r=new Array(s),n=new Array(s),i=0;i<s;++i)r[i]=isNaN(n[i]=+t(e[i],i,e))?0:+o(e[i],i,e)}}return"function"!=typeof t&&(t=$(null==t?0:+t)),i.initialize=function(t){e=t,s()},i.strength=function(t){return arguments.length?(o="function"==typeof t?t:$(+t),s(),i):o},i.x=function(e){return arguments.length?(t="function"==typeof e?e:$(+e),s(),i):t},i}function Rt(t){var e,r,n,o=$(.1);function i(t){for(var o,i=0,s=e.length;i<s;++i)(o=e[i]).vy+=(n[i]-o.y)*r[i]*t}function s(){if(e){var i,s=e.length;for(r=new Array(s),n=new Array(s),i=0;i<s;++i)r[i]=isNaN(n[i]=+t(e[i],i,e))?0:+o(e[i],i,e)}}return"function"!=typeof t&&(t=$(null==t?0:+t)),i.initialize=function(t){e=t,s()},i.strength=function(t){return arguments.length?(o="function"==typeof t?t:$(+t),s(),i):o},i.y=function(e){return arguments.length?(t="function"==typeof e?e:$(+e),s(),i):t},i}function zt(){function t(t){return function(){return t}}var e,r=function(t){return t.cluster},n=t(1),o=t(-1),i=t(100),a=t(.1),h=[0,0],u=[],c={},l=[],f=100,d=100,g={none:{x:0,y:0}},p=[],y="force",m=!0,w=.1;function v(t){if(!m)return v;e.tick(),M();for(var n=0,o=u.length,i=void 0,s=t*w;n<o;++n)(i=u[n]).vx+=(g[r(i)].x-i.x)*s,i.vy+=(g[r(i)].y-i.y)*s}function x(){u&&function(){if(u&&u.length){if(void 0===r(u[0]))throw Error("Couldnt find the grouping attribute for the nodes. Make sure to set it up with forceInBox.groupBy(\'clusterAttr\') before calling .links()");var t,h,g,y,m,w=(t=[],h=[],g={},{},m=[],y=function(t){var e={};return t.forEach((function(t){var n=r(t);e[n]||(e[n]={count:0,sumforceNodeSize:0})})),t.forEach((function(t){var o=r(t),i=n(t),s=e[o];s.count=s.count+1,s.sumforceNodeSize=s.sumforceNodeSize+Math.PI*(i*i)*1.3,e[o]=s})),e}(u),m=function(t){var e={},n=[];return t.forEach((function(t){var n,o,i,s,a,h=(o=(n=t).source,i=n.target,(s=r(c[o]))<=(a=r(c[i]))?"".concat(s,"~").concat(a):"".concat(a,"~").concat(s)),u=0;void 0!==e[h]&&(u=e[h]),u+=1,e[h]=u})),Object.entries(e).forEach((function(t){var e=s(t,2),r=e[0],o=e[1],i=r.split("~")[0],a=r.split("~")[1];void 0!==i&&void 0!==a&&n.push({source:i,target:a,count:o})})),n}(l),Object.keys(y).forEach((function(e,r){var n=y[e];t.push({id:e,size:n.count,r:Math.sqrt(n.sumforceNodeSize/Math.PI)}),g[e]=r})),m.forEach((function(t){var e=t.source,r=t.target,n=g[e],o=g[r];void 0!==n&&void 0!==o&&h.push({source:n,target:o,count:t.count})})),{nodes:t,links:h});e=bt(w.nodes).force("x",_t(f).strength(.1)).force("y",Rt(d).strength(.1)).force("collide",It((function(t){return t.r})).iterations(4)).force("charge",Et().strength(o)).force("links",At(w.nodes.length?w.links:[]).distance(i).strength(a)),p=e.nodes(),M()}}()}function M(){return g={none:{x:0,y:0}},p.forEach((function(t){g[t.id]={x:t.x-h[0],y:t.y-h[1]}})),g}return v.initialize=function(t){u=t,x()},v.template=function(t){return arguments.length?(y=t,x(),v):y},v.groupBy=function(t){return arguments.length?"string"==typeof t?(r=function(e){return e[t]},v):(r=t,v):r},v.enableGrouping=function(t){return arguments.length?(m=t,v):m},v.strength=function(t){return arguments.length?(w=t,v):w},v.centerX=function(t){return arguments.length?(f=t,v):f},v.centerY=function(t){return arguments.length?(d=t,v):d},v.nodes=function(t){return arguments.length?(function(t){c={},t.forEach((function(t){c[t.id]=t}))}(t||[]),u=t||[],v):u},v.links=function(t){return arguments.length?(l=t||[],x(),v):l},v.forceNodeSize=function(e){return arguments.length?(n="function"==typeof e?e:t(+e),x(),v):n},v.nodeSize=v.forceNodeSize,v.forceCharge=function(e){return arguments.length?(o="function"==typeof e?e:t(+e),x(),v):o},v.forceLinkDistance=function(e){return arguments.length?(i="function"==typeof e?e:t(+e),x(),v):i},v.forceLinkStrength=function(e){return arguments.length?(a="function"==typeof e?e:t(+e),x(),v):a},v.offset=function(t){return arguments.length?(h=t,v):h},v.getFocis=M,v}var Tt={center:[0,0],preventOverlap:!1,nodeSize:void 0,nodeSpacing:void 0,linkDistance:50,forceSimulation:null,alphaDecay:.028,alphaMin:.001,alpha:.3,collideStrength:1,clustering:!1,clusterNodeStrength:-1,clusterEdgeStrength:.1,clusterEdgeDistance:100,clusterFociStrength:.8,clusterNodeSize:10},Ct=function(){function t(t){void 0===t&&(t={}),this.options=t,this.id="d3force",this.options=r(r({},Tt),t)}return t.prototype.execute=function(t,e){return o(this,void 0,void 0,(function(){return i(this,(function(r){return[2,this.genericForceLayout(!1,t,e)]}))}))},t.prototype.assign=function(t,e){return o(this,void 0,void 0,(function(){return i(this,(function(r){return this.genericForceLayout(!0,t,e),[2]}))}))},t.prototype.stop=function(){var t;null===(t=this.forceSimulation)||void 0===t||t.stop()},t.prototype.tick=function(t){var e=this;void 0===t&&(t=1),this.forceSimulation.tick(t);var r={nodes:Ot(this.lastLayoutNodes),edges:Pt(this.lastLayoutEdges)};return this.lastAssign&&r.nodes.forEach((function(t){return e.lastGraph.mergeNodeData(t.id,{x:t.data.x,y:t.data.y})})),r},t.prototype.genericForceLayout=function(t,e,n){return o(this,void 0,void 0,(function(){var o,s,a,h,u,c,l,f,d,g,p,y,m,w,v,x,M,E,N,S,A,k,D,I,_,R,z=this;return i(this,(function(i){return o=r(r({},this.options),n),s=e.getAllNodes(),a=e.getAllEdges(),h=s.map((function(t){var e,n;return r(r({},b(t)),{x:null===(e=t.data)||void 0===e?void 0:e.x,y:null===(n=t.data)||void 0===n?void 0:n.y})})),u=a.map((function(t){return b(t)})),this.lastLayoutNodes=h,this.lastLayoutEdges=u,this.lastAssign=t,this.lastGraph=e,c=o.alphaMin,l=o.alphaDecay,f=o.alpha,d=o.nodeStrength,g=o.edgeStrength,p=o.linkDistance,y=o.clustering,m=o.clusterFociStrength,w=o.clusterEdgeDistance,v=o.clusterEdgeStrength,x=o.clusterNodeStrength,M=o.clusterNodeSize,E=o.collideStrength,N=void 0===E?1:E,S=o.center,A=void 0===S?[0,0]:S,k=o.preventOverlap,D=o.nodeSize,I=o.nodeSpacing,_=o.onTick,R=o.forceSimulation,[2,new Promise((function(r){if(R){y&&((i=zt()).nodes(h),i.links(u)),R.nodes(h),u&&(a=At().id((function(t){return t.id})).links(u),g&&a.strength(g),p&&a.distance(p),R.force("link",a)),k&&z.overlapProcess(R,{nodeSize:D,nodeSpacing:I,collideStrength:N}),R.alpha(f).restart();var n=Ot(h),o=Pt(u);t&&n.forEach((function(t){return e.mergeNodeData(t.id,{x:t.data.x,y:t.data.y})})),r({nodes:n,edges:o})}else try{var i,s=Et();if(d&&s.strength(d),R=bt().nodes(h),y&&((i=zt()).centerX(A[0]).centerY(A[1]).template("force").strength(m),u&&i.links(u),h&&i.nodes(h),i.forceLinkDistance(w).forceLinkStrength(v).forceCharge(x).forceNodeSize(M),R.force("group",i)),R.force("center",function(t,e){var r,n=1;function o(){var o,i,s=r.length,a=0,h=0;for(o=0;o<s;++o)a+=(i=r[o]).x,h+=i.y;for(a=(a/s-t)*n,h=(h/s-e)*n,o=0;o<s;++o)(i=r[o]).x-=a,i.y-=h}return null==t&&(t=0),null==e&&(e=0),o.initialize=function(t){r=t},o.x=function(e){return arguments.length?(t=+e,o):t},o.y=function(t){return arguments.length?(e=+t,o):e},o.strength=function(t){return arguments.length?(n=+t,o):n},o}(A[0],A[1])).force("charge",s).alpha(f).alphaDecay(l).alphaMin(c),k&&z.overlapProcess(R,{nodeSize:D,nodeSpacing:I,collideStrength:N}),u){var a=At().id((function(t){return t.id})).links(u);g&&a.strength(g),p&&a.distance(p),R.force("link",a)}R.on("tick",(function(){var r=Ot(h);null==_||_({nodes:r,edges:Pt(u)}),t&&r.forEach((function(t){return e.mergeNodeData(t.id,{x:t.data.x,y:t.data.y})}))})).on("end",(function(){var n=Ot(h);t&&n.forEach((function(t){return e.mergeNodeData(t.id,{x:t.data.x,y:t.data.y})})),r({nodes:n,edges:Pt(u)})}))}catch(t){console.warn(t)}z.forceSimulation=R}))]}))}))},t.prototype.overlapProcess=function(t,e){var r,n,o=e.nodeSize,i=e.nodeSpacing,s=e.collideStrength;if(n=x(i)?function(){return i}:E(i)?i:function(){return 0},o)if(E(o))r=function(t){return o(t)+n(t)};else if(g(o)){var a=(o[0]>o[1]?o[0]:o[1])/2;r=function(t){return a+n(t)}}else if(x(o)){var h=o/2;r=function(t){return h+n(t)}}else r=function(){return 10};else r=function(t){return t.size?g(t.size)?(t.size[0]>t.size[1]?t.size[0]:t.size[1])/2+n(t):N(t.size)?(t.size.width>t.size.height?t.size.width:t.size.height)/2+n(t):t.size/2+n(t):10+n(t)};t.force("collisionForce",It(r).strength(s))},t}(),Ot=function(t){return t.map((function(t){var e=t.x,o=t.y,i=n(t,["x","y"]);return r(r({},i),{data:r(r({},i.data),{x:e,y:o})})}))},Pt=function(t){return t.map((function(t){var e=t.source,o=t.target,i=n(t,["source","target"]);return r(r({},i),{source:e.id,target:o.id})}))};function qt(t){var e=0,r=0,n=0;if(t.length){for(var o=0;o<4;o++)(i=t[o])&&i.weight&&(e+=i.weight,r+=i.x*i.weight,n+=i.y*i.weight);t.x=r/e,t.y=n/e,t.weight=e}else{var i=t;t.x=i.data.x,t.y=i.data.y,t.weight=i.data.weight}}var Ft=function(t,e,r,n,o,i){var s=i.x-t.x||.1,a=i.y-t.y||.1,h=n-e,u=s*s+a*a,c=Math.sqrt(u)*u;if(h*h*.81<u){var l=t.weight/c;return i.vx+=s*l,i.vy+=a*l,!0}if(t.length)return!1;t.data!==i&&(l=t.data.weight/c,i.vx+=s*l,i.vy+=a*l)},Lt={maxIteration:500,gravity:10,factor:1,edgeStrength:200,nodeStrength:1e3,coulombDisScale:.005,damping:.9,maxSpeed:500,minMovement:.4,interval:.02,linkDistance:200,clusterNodeStrength:20,preventOverlap:!0,distanceThresholdMode:"mean"},jt=function(){function t(t){void 0===t&&(t={}),this.options=t,this.id="force",this.timeInterval=0,this.judgingDistance=0,this.running=!1,this.options=r(r({},Lt),t)}return t.prototype.execute=function(t,e){return o(this,void 0,void 0,(function(){return i(this,(function(r){return[2,this.genericForceLayout(!1,t,e)]}))}))},t.prototype.assign=function(t,e){return o(this,void 0,void 0,(function(){return i(this,(function(r){return this.genericForceLayout(!0,t,e),[2]}))}))},t.prototype.stop=function(){this.timeInterval&&"undefined"!=typeof window&&window.clearInterval(this.timeInterval),this.running=!1},t.prototype.tick=function(t){var e=this;if(void 0===t&&(t=this.options.maxIteration||1),this.lastResult)return this.lastResult;for(var r=0;(this.judgingDistance>this.lastOptions.minMovement||r<1)&&r<t;r++)this.runOneStep(this.lastCalcGraph,this.lastGraph,r,this.lastVelMap,this.lastOptions),this.updatePosition(this.lastGraph,this.lastCalcGraph,this.lastVelMap,this.lastOptions);var n={nodes:this.lastLayoutNodes,edges:this.lastLayoutEdges};return this.lastAssign&&n.nodes.forEach((function(t){return e.lastGraph.mergeNodeData(t.id,{x:t.data.x,y:t.data.y})})),n},t.prototype.genericForceLayout=function(t,e,n){return o(this,void 0,void 0,(function(){var o,s,a,h,u,c,l,d,g,p,y,m,w,v,M,b,E,N,S,A=this;return i(this,(function(i){return o=r(r({},this.options),n),s=e.getAllNodes(),a=e.getAllEdges(),h=this.formatOptions(o,e),u=h.width,c=h.height,l=h.nodeSize,d=h.getMass,g=h.nodeStrength,p=h.edgeStrength,y=h.linkDistance,m=s.map((function(t){return r(r({},t),{data:r(r({},t.data),{x:x(t.data.x)?t.data.x:Math.random()*u,y:x(t.data.y)?t.data.y:Math.random()*c,size:l(t)||30,mass:d(t),nodeStrength:g(t)})})})),w=a.map((function(t){return r(r({},t),{data:r(r({},t.data),{edgeStrength:p(t),linkDistance:y(t,e.getNode(t.source),e.getNode(t.target))})})})),(null==s?void 0:s.length)?(v={},s.forEach((function(t,e){v[t.id]={x:0,y:0}})),M=new f({nodes:m,edges:w}),this.formatCentripetal(h,M),b=h.maxIteration,E=h.minMovement,N=h.onTick,this.lastLayoutNodes=m,this.lastLayoutEdges=w,this.lastAssign=t,this.lastGraph=e,this.lastCalcGraph=M,this.lastOptions=h,this.lastVelMap=v,"undefined"==typeof window?[2]:(S=0,[2,new Promise((function(r){A.timeInterval=window.setInterval((function(){s&&A.running||r({nodes:Ut(e,m),edges:a}),A.runOneStep(M,e,S,v,h),A.updatePosition(e,M,v,h),t&&m.forEach((function(t){return e.mergeNodeData(t.id,{x:t.data.x,y:t.data.y})})),null==N||N({nodes:Ut(e,m),edges:a}),(++S>=b||A.judgingDistance<E)&&(window.clearInterval(A.timeInterval),r({nodes:Ut(e,m),edges:a}))}),0),A.running=!0}))])):(this.lastResult={nodes:[],edges:a},[2,{nodes:[],edges:a}])}))}))},t.prototype.formatOptions=function(t,e){var r=t,n=t.width,o=t.height,i=t.getMass;if(r.width=n||"undefined"==typeof window?n:window.innerWidth,r.height=o||"undefined"==typeof window?o:window.innerHeight,t.center||(r.center=[r.width/2,r.height/2]),i||(r.getMass=function(t){var r=1;x(null==t?void 0:t.data.mass)&&(r=null==t?void 0:t.data.mass);var n=e.getDegree(t.id,"both");return!n||n<5?r:5*n*r}),t.preventOverlap){var s=S(0,t.nodeSpacing);t.nodeSize?g(t.nodeSize)?r.nodeSize=function(e){var r=t.nodeSize;return Math.max(r[0],r[1])+s(e)}:r.nodeSize=function(e){return t.nodeSize+s(e)}:r.nodeSize=function(t){var e=((null==t?void 0:t.data)||{}).size;return e?g(e)?Math.max(e[0],e[1])+s(t):N(e)?Math.max(e.width,e.height)+s(t):e+s(t):10+s(t)}}return r.linkDistance=t.linkDistance?S(1,t.linkDistance):function(t){return 1+r.nodeSize(e.getNode(t.source))+r.nodeSize(e.getNode(t.target))},r.nodeStrength=S(1,t.nodeStrength),r.edgeStrength=S(1,t.edgeStrength),t},t.prototype.formatCentripetal=function(t,e){var r,n=t.centripetalOptions,o=t.center,i=t.clusterNodeStrength,s=t.leafCluster,a=t.clustering,h=t.nodeClusterBy,u=e.getAllNodes(),c=n||{leaf:2,single:2,others:1,center:function(t){return{x:o[0],y:o[1]}}};"function"!=typeof i&&(t.clusterNodeStrength=function(t){return i});var l=[];if(s&&h&&(r=Vt(e,h),l=Array.from(new Set(null==u?void 0:u.map((function(t){return t.data[h]}))))||[],t.centripetalOptions=Object.assign(c,{single:100,leaf:function(e){var n=r[e.id]||{},o=n.siblingLeaves,i=n.sameTypeLeaves;return(null==i?void 0:i.length)===(null==o?void 0:o.length)||1===(null==l?void 0:l.length)?1:t.clusterNodeStrength(e)},others:1,center:function(t){var n,o=e.getDegree(t.id,"both");if(!o)return{x:100,y:100};if(1===o){var i=(r[t.id]||{}).sameTypeLeaves,s=void 0===i?[]:i;1===s.length?n=void 0:s.length>1&&(n=Gt(s))}else n=void 0;return{x:null==n?void 0:n.x,y:null==n?void 0:n.y}}})),a&&h){r||(r=Vt(e,h)),l||(l=Array.from(new Set(u.map((function(t){return t.data[h]}))))),l=l.filter((function(t){return void 0!==t}));var f={};l.forEach((function(t){var r=u.filter((function(e){return e.data[h]===t})).map((function(t){return e.getNode(t.id)}));f[t]=Gt(r)})),t.centripetalOptions=Object.assign(c,{single:function(e){return t.clusterNodeStrength(e)},leaf:function(e){return t.clusterNodeStrength(e)},others:function(e){return t.clusterNodeStrength(e)},center:function(t){var e=f[t.data[h]];return{x:null==e?void 0:e.x,y:null==e?void 0:e.y}}})}var d=t.centripetalOptions||{},g=d.leaf,p=d.single,y=d.others;g&&"function"!=typeof g&&(t.centripetalOptions.leaf=function(){return g}),p&&"function"!=typeof p&&(t.centripetalOptions.single=function(){return p}),y&&"function"!=typeof y&&(t.centripetalOptions.others=function(){return y})},t.prototype.runOneStep=function(t,e,r,n,o){var i={},s=t.getAllNodes(),a=t.getAllEdges();if(null==s?void 0:s.length){var h=o.monitor;this.calRepulsive(t,i,o),a&&this.calAttractive(t,i),this.calGravity(t,e,i,o),this.updateVelocity(t,i,n,o),h&&h({energy:this.calTotalEnergy(i,s),nodes:e.getAllNodes(),edges:e.getAllEdges(),iterations:r})}},t.prototype.calTotalEnergy=function(t,e){if(!(null==e?void 0:e.length))return 0;var r=0;return e.forEach((function(e,n){var o=t[e.id].x,i=t[e.id].y,s=o*o+i*i,a=e.data.mass;r+=(void 0===a?1:a)*s*.5})),r},t.prototype.calRepulsive=function(t,e,r){var n=r.factor,o=r.coulombDisScale;!function(t,e,r,n){var o=e/r,i=t.getAllNodes(),s=i.map((function(t,e){var r=t.data,n=r.nodeStrength;return{x:r.x,y:r.y,size:r.size,index:e,vx:0,vy:0,weight:o*n}})),a=L(s,(function(t){return t.x}),(function(t){return t.y})).visitAfter(qt);s.forEach((function(t){!function(t,e){e.visit((function(e,r,n,o,i){return Ft(e,r,n,o,i,t)}))}(t,a)})),s.map((function(t,e){var r=i[e],o=r.id,s=r.data.mass,a=void 0===s?1:s;n[o]={x:t.vx/a,y:t.vy/a}}))}(t,n,o*o,e)},t.prototype.calAttractive=function(t,e){t.getAllEdges().forEach((function(r,n){var o=r.source,i=r.target,s=t.getNode(o),a=t.getNode(i);if(s&&a){var h=a.data.x-s.data.x,u=a.data.y-s.data.y;h||u||(h=.01*Math.random(),u=.01*Math.random());var c=Math.sqrt(h*h+u*u),l=h/c,f=u/c,d=r.data||{},g=d.linkDistance,p=void 0===g?200:g,y=d.edgeStrength,m=(p-c)*(void 0===y?200:y),w=1/(s.data.mass||1),v=1/(a.data.mass||1),x=l*m,M=f*m;e[o].x-=x*w,e[o].y-=M*w,e[i].x+=x*v,e[i].y+=M*v}}))},t.prototype.calGravity=function(t,e,r,n){var o=n.getCenter,i=t.getAllNodes(),a=e.getAllNodes(),h=e.getAllEdges(),u=n.width,c=n.height,l=n.center,f=n.gravity,d=n.centripetalOptions;i&&i.forEach((function(n){var i=n.id,g=n.data,p=g.mass,y=g.x,m=g.y,w=e.getNode(i),v=0,M=0,b=f,E=t.getDegree(i,"in"),N=t.getDegree(i,"out"),S=t.getDegree(i,"both"),A=null==o?void 0:o(w,S);if(A){var k=s(A,3);v=y-k[0],M=m-k[1],b=k[2]}else v=y-l[0],M=m-l[1];if(b&&(r[i].x-=b*v/p,r[i].y-=b*M/p),d){var D=d.leaf,I=d.single,_=d.others,R=d.center,z=(null==R?void 0:R(w,a,h,u,c))||{x:0,y:0,centerStrength:0},T=z.x,C=z.y,O=z.centerStrength;if(!x(T)||!x(C))return;var P=(y-T)/p,q=(m-C)/p;if(O&&(r[i].x-=O*P,r[i].y-=O*q),0===S){var F=I(w);if(!F)return;return r[i].x-=F*P,void(r[i].y-=F*q)}if(0===E||0===N){var L=D(w,a,h);if(!L)return;return r[i].x-=L*P,void(r[i].y-=L*q)}var j=_(w);if(!j)return;r[i].x-=j*P,r[i].y-=j*q}}))},t.prototype.updateVelocity=function(t,e,r,n){var o=n.damping,i=n.maxSpeed,s=n.interval,a=t.getAllNodes();(null==a?void 0:a.length)&&a.forEach((function(t){var n=t.id,a=(r[n].x+e[n].x*s)*o||.01,h=(r[n].y+e[n].y*s)*o||.01,u=Math.sqrt(a*a+h*h);if(u>i){var c=i/u;a*=c,h*=c}r[n]={x:a,y:h}}))},t.prototype.updatePosition=function(t,e,r,n){var o=this,i=n.distanceThresholdMode,s=n.interval,a=e.getAllNodes();if(null==a?void 0:a.length){var h=0;"max"===i?this.judgingDistance=-1/0:"min"===i&&(this.judgingDistance=1/0),a.forEach((function(n){var a=n.id,u=t.getNode(a);if(x(u.data.fx)&&x(u.data.fy))e.mergeNodeData(a,{x:u.data.fx,y:u.data.fy});else{var c=r[a].x*s,l=r[a].y*s;e.mergeNodeData(a,{x:n.data.x+c,y:n.data.y+l});var f=Math.sqrt(c*c+l*l);switch(i){case"max":o.judgingDistance<f&&(o.judgingDistance=f);break;case"min":o.judgingDistance>f&&(o.judgingDistance=f);break;default:h+=f}}})),i&&"mean"!==i||(this.judgingDistance=h/a.length)}else this.judgingDistance=0},t}(),Vt=function(t,e){var r=t.getAllNodes();if(!(null==r?void 0:r.length))return{};var n={};return r.forEach((function(r,o){1===t.getDegree(r.id,"both")&&(n[r.id]=Wt(t,"leaf",r,e))})),n},Wt=function(t,e,r,n){var o=t.getDegree(r.id,"in"),i=t.getDegree(r.id,"out"),s=r,a=[];return 0===o?(s=t.getSuccessors(r.id)[0],a=t.getNeighbors(s.id)):0===i&&(s=t.getPredecessors(r.id)[0],a=t.getNeighbors(s.id)),a=a.filter((function(e){return 0===t.getDegree(e.id,"in")||0===t.getDegree(e.id,"out")})),{coreNode:s,siblingLeaves:a,sameTypeLeaves:$t(t,e,n,r,a)}},$t=function(t,e,r,n,o){var i=n.data[r]||"",s=(null==o?void 0:o.filter((function(t){return t.data[r]===i})))||[];return"leaf"===e&&(s=s.filter((function(e){return 0===t.getDegree(e.id,"in")||0===t.getDegree(e.id,"out")}))),s},Gt=function(t){var e={x:0,y:0};t.forEach((function(t){var r=t.data,n=r.x,o=r.y;e.x+=n||0,e.y+=o||0}));var r=t.length||1;return{x:e.x/r,y:e.y/r}},Ut=function(t,e){return e.map((function(e){var n=e.id,o=e.data,i=t.getNode(n);return r(r({},i),{data:r(r({},i.data),{x:o.x,y:o.y})})}))},Bt=function(){function t(t){this.id=t.id||0,this.rx=t.rx,this.ry=t.ry,this.fx=0,this.fy=0,this.mass=t.mass,this.degree=t.degree,this.g=t.g||0}return t.prototype.distanceTo=function(t){var e=this.rx-t.rx,r=this.ry-t.ry;return Math.hypot(e,r)},t.prototype.setPos=function(t,e){this.rx=t,this.ry=e},t.prototype.resetForce=function(){this.fx=0,this.fy=0},t.prototype.addForce=function(t){var e=t.rx-this.rx,r=t.ry-this.ry,n=Math.hypot(e,r);n=n<1e-4?1e-4:n;var o=this.g*(this.degree+1)*(t.degree+1)/n;this.fx+=o*e/n,this.fy+=o*r/n},t.prototype.in=function(t){return t.contains(this.rx,this.ry)},t.prototype.add=function(e){var r=this.mass+e.mass;return new t({rx:(this.rx*this.mass+e.rx*e.mass)/r,ry:(this.ry*this.mass+e.ry*e.mass)/r,mass:r,degree:this.degree+e.degree})},t}();const Ht=Bt;const Kt=function(){function t(t){this.xmid=t.xmid,this.ymid=t.ymid,this.length=t.length,this.massCenter=t.massCenter||[0,0],this.mass=t.mass||1}return t.prototype.getLength=function(){return this.length},t.prototype.contains=function(t,e){var r=this.length/2;return t<=this.xmid+r&&t>=this.xmid-r&&e<=this.ymid+r&&e>=this.ymid-r},t.prototype.NW=function(){return new t({xmid:this.xmid-this.length/4,ymid:this.ymid+this.length/4,length:this.length/2})},t.prototype.NE=function(){return new t({xmid:this.xmid+this.length/4,ymid:this.ymid+this.length/4,length:this.length/2})},t.prototype.SW=function(){return new t({xmid:this.xmid-this.length/4,ymid:this.ymid-this.length/4,length:this.length/2})},t.prototype.SE=function(){return new t({xmid:this.xmid+this.length/4,ymid:this.ymid-this.length/4,length:this.length/2})},t}(),Jt=function(){function t(t){this.body=null,this.quad=null,this.NW=null,this.NE=null,this.SW=null,this.SE=null,this.theta=.5,null!=t&&(this.quad=t)}return t.prototype.insert=function(e){null!=this.body?this._isExternal()?(this.quad&&(this.NW=new t(this.quad.NW()),this.NE=new t(this.quad.NE()),this.SW=new t(this.quad.SW()),this.SE=new t(this.quad.SE())),this._putBody(this.body),this._putBody(e),this.body=this.body.add(e)):(this.body=this.body.add(e),this._putBody(e)):this.body=e},t.prototype._putBody=function(t){this.quad&&(t.in(this.quad.NW())&&this.NW?this.NW.insert(t):t.in(this.quad.NE())&&this.NE?this.NE.insert(t):t.in(this.quad.SW())&&this.SW?this.SW.insert(t):t.in(this.quad.SE())&&this.SE&&this.SE.insert(t))},t.prototype._isExternal=function(){return null==this.NW&&null==this.NE&&null==this.SW&&null==this.SE},t.prototype.updateForce=function(t){null!=this.body&&t!==this.body&&(this._isExternal()||(this.quad?this.quad.getLength():0)/this.body.distanceTo(t)<this.theta?t.addForce(this.body):(this.NW&&this.NW.updateForce(t),this.NE&&this.NE.updateForce(t),this.SW&&this.SW.updateForce(t),this.SE&&this.SE.updateForce(t)))},t}();var Yt={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},Xt=function(){function t(t){void 0===t&&(t={}),this.options=t,this.id="forceAtlas2",this.options=r(r({},Yt),t)}return t.prototype.execute=function(t,e){return o(this,void 0,void 0,(function(){return i(this,(function(r){return[2,this.genericForceAtlas2Layout(!1,t,e)]}))}))},t.prototype.assign=function(t,e){return o(this,void 0,void 0,(function(){return i(this,(function(r){return this.genericForceAtlas2Layout(!0,t,e),[2]}))}))},t.prototype.genericForceAtlas2Layout=function(t,e,n){return o(this,void 0,void 0,(function(){var o,s,a,h,u,c,l,d,g,p,y,m,w,v,x,M,E,N,S,A,D,I;return i(this,(function(i){if(o=e.getAllEdges(),s=e.getAllNodes(),a=this.formatOptions(n,s.length),h=a.width,u=a.height,c=a.prune,l=a.maxIteration,d=a.nodeSize,g=a.center,!(null==s?void 0:s.length)||1===s.length)return[2,k(e,t,g)];if(p=s.map((function(t){return b(t,[h,u])})),y=o.filter((function(t){return t.source!==t.target})),m=new f({nodes:p,edges:y}),w=this.getSizes(m,e,d),this.run(m,e,l,w,t,a),c){for(v=0;v<y.length;v+=1)x=y[v],M=x.source,E=x.target,N=m.getDegree(M),S=m.getDegree(M),N<=1?(A=m.getNode(E),m.mergeNodeData(M,{x:A.data.x,y:A.data.y})):S<=1&&(D=m.getNode(M),m.mergeNodeData(E,{x:D.data.x,y:D.data.y}));I=r(r({},a),{prune:!1,barnesHut:!1}),this.run(m,e,100,w,t,I)}return[2,{nodes:p,edges:o}]}))}))},t.prototype.getSizes=function(t,e,r){for(var n=t.getAllNodes(),o={},i=0;i<n.length;i+=1){var h=n[i],u=h.id,c=h.data;if(o[u]=10,x(c.size))o[u]=c.size;else if(g(c.size))isNaN(c.size[0])||(o[u]=Math.max(c.size[0])),isNaN(c.size[1])||(o[u]=Math.max(c.size[1]));else if(N(c.size))o[u]=Math.max(c.size.width,c.size.height);else if(E(r)){var l=r(e.getNode(u));g(l)?o[u]=Math.max.apply(Math,a([],s(l),!1)):o[u]=l}else g(r)?o[u]=Math.max.apply(Math,a([],s(r),!1)):x(r)&&(o[u]=r)}return o},t.prototype.formatOptions=function(t,e){void 0===t&&(t={});var n=r(r({},this.options),t),o=n.center,i=n.width,s=n.height,a=n.barnesHut,h=n.prune,u=n.maxIteration,c=n.kr,l=n.kg;return n.width=i||"undefined"==typeof window?i:window.innerWidth,n.height=s||"undefined"==typeof window?s:window.innerHeight,n.center=o||[n.width/2,n.height/2],void 0===a&&e>250&&(n.barnesHut=!0),void 0===h&&e>100&&(n.prune=!0),0!==u||h?0===u&&h&&(n.maxIteration=100,e<=200&&e>100?n.maxIteration=500:e>200&&(n.maxIteration=950)):(n.maxIteration=250,e<=200&&e>100?n.maxIteration=1e3:e>200&&(n.maxIteration=1200)),c||(n.kr=50,e>100&&e<=500?n.kr=20:e>500&&(n.kr=1)),l||(n.kg=20,e>100&&e<=500?n.kg=10:e>500&&(n.kg=1)),n},t.prototype.run=function(t,e,r,n,o,i){for(var s=i.kr,a=i.barnesHut,h=i.onTick,u=t.getAllNodes(),c=0,l=r,f={},d={},g={},p=0;p<u.length;p+=1){var y=u[p],m=y.data,w=y.id;if(f[w]=[0,0],a){var v={id:p,rx:m.x,ry:m.y,mass:1,g:s,degree:t.getDegree(w)};g[w]=new Ht(v)}}for(;l>0;)c=this.oneStep(t,{iter:l,preventOverlapIters:50,krPrime:100,sg:c,forces:f,preForces:d,bodies:g,sizes:n},i),l--,null==h||h({nodes:u,edges:e.getAllEdges()});return t},t.prototype.oneStep=function(t,e,r){for(var n=e.iter,o=e.preventOverlapIters,i=e.krPrime,h=e.sg,u=e.preForces,c=e.bodies,l=e.sizes,f=e.forces,d=r.preventOverlap,g=r.barnesHut,p=t.getAllNodes(),y=0;y<p.length;y+=1){var m=p[y].id;u[m]=a([],s(f[m]),!1),f[m]=[0,0]}return f=this.getAttrForces(t,n,o,l,f,r),f=g&&(d&&n>o||!d)?this.getOptRepGraForces(t,f,c,r):this.getRepGraForces(t,n,o,f,i,l,r),this.updatePos(t,f,u,h,r)},t.prototype.getAttrForces=function(t,e,r,n,o,i){for(var s=i.preventOverlap,a=i.dissuadeHubs,h=i.mode,u=i.prune,c=t.getAllEdges(),l=0;l<c.length;l+=1){var f=c[l],d=f.source,g=f.target,p=t.getNode(d),y=t.getNode(g),m=t.getDegree(d),w=t.getDegree(g);if(!u||!(m<=1||w<=1)){var v=[y.data.x-p.data.x,y.data.y-p.data.y],x=Math.hypot(v[0],v[1]);x=x<1e-4?1e-4:x,v[0]=v[0]/x,v[1]=v[1]/x,s&&e<r&&(x=x-n[d]-n[g]);var M=x,b=M;"linlog"===h&&(b=M=Math.log(1+x)),a&&(M=x/m,b=x/w),s&&e<r&&x<=0?(M=0,b=0):s&&e<r&&x>0&&(M=x,b=x),o[d][0]+=M*v[0],o[g][0]-=b*v[0],o[d][1]+=M*v[1],o[g][1]-=b*v[1]}}return o},t.prototype.getOptRepGraForces=function(t,e,r,n){for(var o=n.kg,i=n.center,s=n.prune,a=t.getAllNodes(),h=a.length,u=9e10,c=-9e10,l=9e10,f=-9e10,d=0;d<h;d+=1){var g=a[d],p=g.id,y=g.data;s&&t.getDegree(p)<=1||(r[p].setPos(y.x,y.y),y.x>=c&&(c=y.x),y.x<=u&&(u=y.x),y.y>=f&&(f=y.y),y.y<=l&&(l=y.y))}var m=Math.max(c-u,f-l),w=new Kt({xmid:(c+u)/2,ymid:(f+l)/2,length:m,massCenter:i,mass:h}),v=new Jt(w);for(d=0;d<h;d+=1)p=a[d].id,s&&t.getDegree(p)<=1||r[p].in(w)&&v.insert(r[p]);for(d=0;d<h;d+=1){var x=a[d],M=(p=x.id,y=x.data,t.getDegree(p));if(!(s&&M<=1)){r[p].resetForce(),v.updateForce(r[p]),e[p][0]-=r[p].fx,e[p][1]-=r[p].fy;var b=[y.x-i[0],y.y-i[1]],E=Math.hypot(b[0],b[1]);E=E<1e-4?1e-4:E,b[0]=b[0]/E,b[1]=b[1]/E;var N=o*(M+1);e[p][0]-=N*b[0],e[p][1]-=N*b[1]}}return e},t.prototype.getRepGraForces=function(t,e,r,n,o,i,s){for(var a=s.preventOverlap,h=s.kr,u=s.kg,c=s.center,l=s.prune,f=t.getAllNodes(),d=f.length,g=0;g<d;g+=1){for(var p=f[g],y=t.getDegree(p.id),m=g+1;m<d;m+=1){var w=f[m],v=t.getDegree(w.id);if(!l||!(y<=1||v<=1)){var x=[w.data.x-p.data.x,w.data.y-p.data.y],M=Math.hypot(x[0],x[1]);M=M<1e-4?1e-4:M,x[0]=x[0]/M,x[1]=x[1]/M,a&&e<r&&(M=M-i[p.id]-i[w.id]);var b=h*(y+1)*(v+1)/M;a&&e<r&&M<0?b=o*(y+1)*(v+1):a&&e<r&&0===M?b=0:a&&e<r&&M>0&&(b=h*(y+1)*(v+1)/M),n[p.id][0]-=b*x[0],n[w.id][0]+=b*x[0],n[p.id][1]-=b*x[1],n[w.id][1]+=b*x[1]}}var E=[p.data.x-c[0],p.data.y-c[1]],N=Math.hypot(E[0],E[1]);E[0]=E[0]/N,E[1]=E[1]/N;var S=u*(y+1);n[p.id][0]-=S*E[0],n[p.id][1]-=S*E[1]}return n},t.prototype.updatePos=function(t,e,r,n,o){for(var i=o.ks,s=o.tao,a=o.prune,h=o.ksmax,u=t.getAllNodes(),c=u.length,l=[],f=[],d=0,g=0,p=n,y=0;y<c;y+=1){var m=u[y].id,w=t.getDegree(m);if(!(a&&w<=1)){var v=[e[m][0]-r[m][0],e[m][1]-r[m][1]],M=Math.hypot(v[0],v[1]),b=[e[m][0]+r[m][0],e[m][1]+r[m][1]],E=Math.hypot(b[0],b[1]);l[y]=M,f[y]=E/2,d+=(w+1)*l[y],g+=(w+1)*f[y]}}var N=p;for(p=s*g/d,0!==N&&(p=p>1.5*N?1.5*N:p),y=0;y<c;y+=1){var S=u[y],A=(m=S.id,S.data);if(w=t.getDegree(m),!(a&&w<=1||x(A.fx)&&x(A.fy))){var k=i*p/(1+p*Math.sqrt(l[y])),D=Math.hypot(e[m][0],e[m][1]),I=h/(D=D<1e-4?1e-4:D),_=(k=k>I?I:k)*e[m][0],R=k*e[m][1];t.mergeNodeData(m,{x:A.x+_,y:A.y+R})}}return p},t}(),Qt={maxIteration:1e3,gravity:10,speed:5,clustering:!1,clusterGravity:10,width:300,height:300,nodeClusterBy:"cluster"},Zt=function(){function t(t){void 0===t&&(t={}),this.options=t,this.id="fruchterman",this.timeInterval=0,this.running=!1,this.options=r(r({},Qt),t)}return t.prototype.execute=function(t,e){return o(this,void 0,void 0,(function(){return i(this,(function(r){return[2,this.genericFruchtermanLayout(!1,t,e)]}))}))},t.prototype.assign=function(t,e){return o(this,void 0,void 0,(function(){return i(this,(function(r){return this.genericFruchtermanLayout(!0,t,e),[2]}))}))},t.prototype.stop=function(){this.timeInterval&&"undefined"!=typeof window&&window.clearInterval(this.timeInterval),this.running=!1},t.prototype.tick=function(t){var e=this;if(void 0===t&&(t=this.options.maxIteration||1),this.lastResult)return this.lastResult;for(var r=0;r<t;r++)this.runOneStep(this.lastGraph,this.lastClusterMap,this.lastOptions);var n={nodes:this.lastLayoutNodes,edges:this.lastLayoutEdges};return this.lastAssign&&n.nodes.forEach((function(t){return e.lastGraph.mergeNodeData(t.id,{x:t.data.x,y:t.data.y})})),n},t.prototype.genericFruchtermanLayout=function(t,e,n){return o(this,void 0,void 0,(function(){var o,s,a,h,u,c,l,d,g,p,y,m,w,v,x,M=this;return i(this,(function(i){return this.running?[2]:(o=this.formatOptions(n),s=o.width,a=o.height,h=o.center,u=o.clustering,c=o.nodeClusterBy,l=o.maxIteration,d=o.onTick,g=e.getAllNodes(),p=e.getAllEdges(),(null==g?void 0:g.length)?1===g.length?(t&&e.mergeNodeData(g[0].id,{x:h[0],y:h[1]}),y={nodes:[r(r({},g[0]),{data:r(r({},g[0].data),{x:h[0],y:h[1]})})],edges:p},this.lastResult=y,[2,y]):(m=g.map((function(t){return b(t,[s,a])})),w=new f({nodes:m,edges:p}),v={},u&&m.forEach((function(t){var e=t.data[c];v[e]||(v[e]={name:e,cx:0,cy:0,count:0})})),this.lastLayoutNodes=m,this.lastLayoutEdges=p,this.lastAssign=t,this.lastGraph=w,this.lastOptions=o,this.lastClusterMap=v,"undefined"==typeof window?[2]:(x=0,[2,new Promise((function(r){M.timeInterval=window.setInterval((function(){M.running?(M.runOneStep(w,v,o),t&&m.forEach((function(t){var r=t.id,n=t.data;return e.mergeNodeData(r,{x:n.x,y:n.y})})),null==d||d({nodes:m,edges:p}),++x>=l&&(window.clearInterval(M.timeInterval),r({nodes:m,edges:p}))):r({nodes:m,edges:p})}),0),M.running=!0}))])):(y={nodes:[],edges:p},this.lastResult=y,[2,y]))}))}))},t.prototype.formatOptions=function(t){void 0===t&&(t={});var e=r(r({},this.options),t),n=e.clustering,o=e.nodeClusterBy,i=e.center,s=e.width,a=e.height;return e.width=s||"undefined"==typeof window?s:window.innerWidth,e.height=a||"undefined"==typeof window?a:window.innerHeight,e.center=i||[e.width/2,e.height/2],e.clustering=n&&!!o,e},t.prototype.runOneStep=function(t,e,r){var n=r.height,o=r.width,i=r.gravity,s=r.center,a=r.speed,h=r.clustering,u=r.nodeClusterBy,c=r.clusterGravity,l=n*o,f=Math.sqrt(l)/10,d=t.getAllNodes(),g=l/(d.length+1),p=Math.sqrt(g),y={};if(this.applyCalculate(t,y,p,g),h){for(var m in e)e[m].cx=0,e[m].cy=0,e[m].count=0;for(var m in d.forEach((function(t){var r=t.data,n=e[r[u]];x(r.x)&&(n.cx+=r.x),x(r.y)&&(n.cy+=r.y),n.count++})),e)e[m].cx/=e[m].count,e[m].cy/=e[m].count;var w=c||i;d.forEach((function(t,r){var n=t.id,o=t.data;if(x(o.x)&&x(o.y)){var i=e[o[u]],s=Math.sqrt((o.x-i.cx)*(o.x-i.cx)+(o.y-i.cy)*(o.y-i.cy)),a=p*w;y[n].x-=a*(o.x-i.cx)/s,y[n].y-=a*(o.y-i.cy)/s}}))}d.forEach((function(t,e){var r=t.id,n=t.data;if(x(n.x)&&x(n.y)){var o=.01*p*i;y[r].x-=o*(n.x-s[0]),y[r].y-=o*(n.y-s[1])}})),d.forEach((function(e,r){var n=e.id,o=e.data;if(x(o.fx)&&x(o.fy))return o.x=o.fx,void(o.y=o.fy);if(x(o.x)&&x(o.y)){var i=Math.sqrt(y[n].x*y[n].x+y[n].y*y[n].y);if(i>0){var s=Math.min(f*(a/800),i);t.mergeNodeData(n,{x:o.x+y[n].x/i*s,y:o.y+y[n].y/i*s})}}}))},t.prototype.applyCalculate=function(t,e,r,n){this.calRepulsive(t,e,n),this.calAttractive(t,e,r)},t.prototype.calRepulsive=function(t,e,r){var n=t.getAllNodes();n.forEach((function(t,o){var i=t.data,s=t.id;e[s]={x:0,y:0},n.forEach((function(t,n){var a=t.data,h=t.id;if(!(o<=n)&&x(i.x)&&x(a.x)&&x(i.y)&&x(a.y)){var u=i.x-a.x,c=i.y-a.y,l=u*u+c*c;0===l&&(l=1,u=.01,c=.01);var f=r/l,d=u*f,g=c*f;e[s].x+=d,e[s].y+=g,e[h].x-=d,e[h].y-=g}}))}))},t.prototype.calAttractive=function(t,e,r){t.getAllEdges().forEach((function(n){var o=n.source,i=n.target;if(o&&i&&o!==i){var s=t.getNode(o).data,a=t.getNode(i).data;if(x(a.x)&&x(s.x)&&x(a.y)&&x(s.y)){var h=a.x-s.x,u=a.y-s.y,c=Math.sqrt(h*h+u*u)/r,l=h*c,f=u*c;e[o].x+=l,e[o].y+=f,e[i].x-=l,e[i].y-=f}}}))},t}(),te={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},ee=function(){function t(t){void 0===t&&(t={}),this.options=t,this.id="grid",this.options=r(r({},te),t)}return t.prototype.execute=function(t,e){return o(this,void 0,void 0,(function(){return i(this,(function(r){return[2,this.genericGridLayout(!1,t,e)]}))}))},t.prototype.assign=function(t,e){return o(this,void 0,void 0,(function(){return i(this,(function(r){return this.genericGridLayout(!0,t,e),[2]}))}))},t.prototype.genericGridLayout=function(t,e,n){return o(this,void 0,void 0,(function(){var o,s,a,h,u,c,l,f,d,p,y,m,w,v,M,E,N,D,I,_,R,T,C,O,P,q,F,L,j,V,W,$,G,U,B,H,K;return i(this,(function(i){if(o=r(r({},this.options),n),s=o.begin,a=void 0===s?[0,0]:s,h=o.condense,u=o.preventOverlapPadding,c=o.preventOverlap,l=o.rows,f=o.cols,d=o.nodeSpacing,p=o.nodeSize,y=o.width,m=o.height,w=o.position,v=o.sortBy,M=e.getAllNodes(),E=e.getAllEdges(),!(N=null==M?void 0:M.length)||1===N)return[2,k(e,t,a)];if(D=M.map((function(t){return b(t)})),"id"===v||z(v)&&void 0!==D[0].data[v]||(v="degree"),"degree"===v?D.sort((function(t,r){return e.getDegree(r.id,"both")-e.getDegree(t.id,"both")})):"id"===v?D.sort((function(t,e){return x(e.id)&&x(t.id)?e.id-t.id:"".concat(t.id).localeCompare("".concat(e.id))})):D.sort((function(t,e){return e.data[v]-t.data[v]})),I=y||"undefined"==typeof window?y:window.innerWidth,_=m||"undefined"==typeof window?m:window.innerHeight,R=N,T={rows:l,cols:f},null!=l&&null!=f?(T.rows=l,T.cols=f):null!=l&&null==f?(T.rows=l,T.cols=Math.ceil(R/T.rows)):null==l&&null!=f?(T.cols=f,T.rows=Math.ceil(R/T.cols)):(C=Math.sqrt(R*_/I),T.rows=Math.round(C),T.cols=Math.round(I/_*C)),T.rows=Math.max(T.rows,1),T.cols=Math.max(T.cols,1),T.cols*T.rows>R)O=re(T),P=ne(T),(O-1)*P>=R?re(T,O-1):(P-1)*O>=R&&ne(T,P-1);else for(;T.cols*T.rows<R;)O=re(T),((P=ne(T))+1)*O>=R?ne(T,P+1):re(T,O+1);for(q=h?0:I/T.cols,F=h?0:_/T.rows,(c||d)&&(L=S(10,d),j=A(30,p,!1),D.forEach((function(t){t.data.x&&t.data.y||(t.data.x=0,t.data.y=0);var r,n,o=e.getNode(t.id),i=j(o)||30;g(i)?(r=i[0],n=i[1]):(r=i,n=i);var s=void 0!==L?L(t):u,a=r+s,h=n+s;q=Math.max(q,a),F=Math.max(F,h)}))),V={},W={row:0,col:0},$={},G=0;G<D.length;G++){if(U=D[G],B=void 0,w&&(B=w(e.getNode(U.id))),B&&(void 0!==B.row||void 0!==B.col)){if(void 0===(H={row:B.row,col:B.col}).col)for(H.col=0;oe(V,H);)H.col++;else if(void 0===H.row)for(H.row=0;oe(V,H);)H.row++;$[U.id]=H,ie(V,H)}ae(U,a,q,F,$,T,W,V)}return K={nodes:D,edges:E},t&&D.forEach((function(t){e.mergeNodeData(t.id,{x:t.data.x,y:t.data.y})})),[2,K]}))}))},t}(),re=function(t,e){var r,n=t.rows||5,o=t.cols||5;return null==e?r=Math.min(n,o):Math.min(n,o)===t.rows?t.rows=e:t.cols=e,r},ne=function(t,e){var r,n=t.rows||5,o=t.cols||5;return null==e?r=Math.max(n,o):Math.max(n,o)===t.rows?t.rows=e:t.cols=e,r},oe=function(t,e){return t["c-".concat(e.row,"-").concat(e.col)]||!1},ie=function(t,e){return t["c-".concat(e.row,"-").concat(e.col)]=!0},se=function(t,e){var r=t.cols||5;e.col++,e.col>=r&&(e.col=0,e.row++)},ae=function(t,e,r,n,o,i,s,a){var h,u,c=o[t.id];if(c)h=c.col*r+r/2+e[0],u=c.row*n+n/2+e[1];else{for(;oe(a,s);)se(i,s);h=s.col*r+r/2+e[0],u=s.row*n+n/2+e[1],ie(a,s),se(i,s)}t.data.x=h,t.data.y=u};const he=Object.prototype.toString;function ue(t){return he.call(t).endsWith("Array]")}function ce(t){var e,r=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};if(!ue(t))throw new TypeError("input must be an array");if(0===t.length)throw new TypeError("input must not be empty");if(void 0!==r.output){if(!ue(r.output))throw new TypeError("output option must be an array if specified");e=r.output}else e=new Array(t.length);var n=function(t){var e=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};if(!ue(t))throw new TypeError("input must be an array");if(0===t.length)throw new TypeError("input must not be empty");var r=e.fromIndex,n=void 0===r?0:r,o=e.toIndex,i=void 0===o?t.length:o;if(n<0||n>=t.length||!Number.isInteger(n))throw new Error("fromIndex must be a positive integer smaller than length");if(i<=n||i>t.length||!Number.isInteger(i))throw new Error("toIndex must be an integer greater than fromIndex and at most equal to length");for(var s=t[n],a=n+1;a<i;a++)t[a]<s&&(s=t[a]);return s}(t),o=function(t){var e=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};if(!ue(t))throw new TypeError("input must be an array");if(0===t.length)throw new TypeError("input must not be empty");var r=e.fromIndex,n=void 0===r?0:r,o=e.toIndex,i=void 0===o?t.length:o;if(n<0||n>=t.length||!Number.isInteger(n))throw new Error("fromIndex must be a positive integer smaller than length");if(i<=n||i>t.length||!Number.isInteger(i))throw new Error("toIndex must be an integer greater than fromIndex and at most equal to length");for(var s=t[n],a=n+1;a<i;a++)t[a]>s&&(s=t[a]);return s}(t);if(n===o)throw new RangeError("minimum and maximum input values are equal. Cannot rescale a constant array");var i=r.min,s=void 0===i?r.autoMinMax?n:0:i,a=r.max,h=void 0===a?r.autoMinMax?o:1:a;if(s>=h)throw new RangeError("min option must be smaller than max option");for(var u=(h-s)/(o-n),c=0;c<t.length;c++)e[c]=(t[c]-n)*u+s;return e}const le=" ".repeat(2),fe=" ".repeat(4);function de(t,e={}){const{maxRows:r=15,maxColumns:n=10,maxNumSize:o=8,padMinus:i="auto"}=e;return`${t.constructor.name} {\\n${le}[\\n${fe}${function(t,e,r,n,o){const{rows:i,columns:s}=t,a=Math.min(i,e),h=Math.min(s,r),u=[];if("auto"===o){o=!1;t:for(let e=0;e<a;e++)for(let r=0;r<h;r++)if(t.get(e,r)<0){o=!0;break t}}for(let e=0;e<a;e++){let r=[];for(let i=0;i<h;i++)r.push(ge(t.get(e,i),n,o));u.push(`${r.join(" ")}`)}return h!==s&&(u[u.length-1]+=` ... ${s-r} more columns`),a!==i&&u.push(`... ${i-e} more rows`),u.join(`\\n${fe}`)}(t,r,n,o,i)}\\n${le}]\\n${le}rows: ${t.rows}\\n${le}columns: ${t.columns}\\n}`}function ge(t,e,r){return(t>=0&&r?` ${pe(t,e-1)}`:pe(t,e)).padEnd(e)}function pe(t,e){let r=t.toString();if(r.length<=e)return r;let n=t.toFixed(e);if(n.length>e&&(n=t.toFixed(Math.max(0,e-(n.length-e)))),n.length<=e&&!n.startsWith("0.000")&&!n.startsWith("-0.000"))return n;let o=t.toExponential(e);return o.length>e&&(o=t.toExponential(Math.max(0,e-(o.length-e)))),o.slice(0)}function ye(t,e,r){let n=r?t.rows:t.rows-1;if(e<0||e>n)throw new RangeError("Row index out of range")}function me(t,e,r){let n=r?t.columns:t.columns-1;if(e<0||e>n)throw new RangeError("Column index out of range")}function we(t,e){if(e.to1DArray&&(e=e.to1DArray()),e.length!==t.columns)throw new RangeError("vector size must be the same as the number of columns");return e}function ve(t,e){if(e.to1DArray&&(e=e.to1DArray()),e.length!==t.rows)throw new RangeError("vector size must be the same as the number of rows");return e}function xe(t,e,r,n,o){if(5!==arguments.length)throw new RangeError("expected 4 arguments");if(be("startRow",e),be("endRow",r),be("startColumn",n),be("endColumn",o),e>r||n>o||e<0||e>=t.rows||r<0||r>=t.rows||n<0||n>=t.columns||o<0||o>=t.columns)throw new RangeError("Submatrix indices are out of range")}function Me(t,e=0){let r=[];for(let n=0;n<t;n++)r.push(e);return r}function be(t,e){if("number"!=typeof e)throw new TypeError(`${t} must be a number`)}function Ee(t){if(t.isEmpty())throw new Error("Empty matrix has no elements to index")}class Ne{static from1DArray(t,e,r){if(t*e!==r.length)throw new RangeError("data length does not match given dimensions");let n=new Ae(t,e);for(let o=0;o<t;o++)for(let t=0;t<e;t++)n.set(o,t,r[o*e+t]);return n}static rowVector(t){let e=new Ae(1,t.length);for(let r=0;r<t.length;r++)e.set(0,r,t[r]);return e}static columnVector(t){let e=new Ae(t.length,1);for(let r=0;r<t.length;r++)e.set(r,0,t[r]);return e}static zeros(t,e){return new Ae(t,e)}static ones(t,e){return new Ae(t,e).fill(1)}static rand(t,e,r={}){if("object"!=typeof r)throw new TypeError("options must be an object");const{random:n=Math.random}=r;let o=new Ae(t,e);for(let r=0;r<t;r++)for(let t=0;t<e;t++)o.set(r,t,n());return o}static randInt(t,e,r={}){if("object"!=typeof r)throw new TypeError("options must be an object");const{min:n=0,max:o=1e3,random:i=Math.random}=r;if(!Number.isInteger(n))throw new TypeError("min must be an integer");if(!Number.isInteger(o))throw new TypeError("max must be an integer");if(n>=o)throw new RangeError("min must be smaller than max");let s=o-n,a=new Ae(t,e);for(let r=0;r<t;r++)for(let t=0;t<e;t++){let e=n+Math.round(i()*s);a.set(r,t,e)}return a}static eye(t,e,r){void 0===e&&(e=t),void 0===r&&(r=1);let n=Math.min(t,e),o=this.zeros(t,e);for(let t=0;t<n;t++)o.set(t,t,r);return o}static diag(t,e,r){let n=t.length;void 0===e&&(e=n),void 0===r&&(r=e);let o=Math.min(n,e,r),i=this.zeros(e,r);for(let e=0;e<o;e++)i.set(e,e,t[e]);return i}static min(t,e){t=this.checkMatrix(t),e=this.checkMatrix(e);let r=t.rows,n=t.columns,o=new Ae(r,n);for(let i=0;i<r;i++)for(let r=0;r<n;r++)o.set(i,r,Math.min(t.get(i,r),e.get(i,r)));return o}static max(t,e){t=this.checkMatrix(t),e=this.checkMatrix(e);let r=t.rows,n=t.columns,o=new this(r,n);for(let i=0;i<r;i++)for(let r=0;r<n;r++)o.set(i,r,Math.max(t.get(i,r),e.get(i,r)));return o}static checkMatrix(t){return Ne.isMatrix(t)?t:new Ae(t)}static isMatrix(t){return null!=t&&"Matrix"===t.klass}get size(){return this.rows*this.columns}apply(t){if("function"!=typeof t)throw new TypeError("callback must be a function");for(let e=0;e<this.rows;e++)for(let r=0;r<this.columns;r++)t.call(this,e,r);return this}to1DArray(){let t=[];for(let e=0;e<this.rows;e++)for(let r=0;r<this.columns;r++)t.push(this.get(e,r));return t}to2DArray(){let t=[];for(let e=0;e<this.rows;e++){t.push([]);for(let r=0;r<this.columns;r++)t[e].push(this.get(e,r))}return t}toJSON(){return this.to2DArray()}isRowVector(){return 1===this.rows}isColumnVector(){return 1===this.columns}isVector(){return 1===this.rows||1===this.columns}isSquare(){return this.rows===this.columns}isEmpty(){return 0===this.rows||0===this.columns}isSymmetric(){if(this.isSquare()){for(let t=0;t<this.rows;t++)for(let e=0;e<=t;e++)if(this.get(t,e)!==this.get(e,t))return!1;return!0}return!1}isEchelonForm(){let t=0,e=0,r=-1,n=!0,o=!1;for(;t<this.rows&&n;){for(e=0,o=!1;e<this.columns&&!1===o;)0===this.get(t,e)?e++:1===this.get(t,e)&&e>r?(o=!0,r=e):(n=!1,o=!0);t++}return n}isReducedEchelonForm(){let t=0,e=0,r=-1,n=!0,o=!1;for(;t<this.rows&&n;){for(e=0,o=!1;e<this.columns&&!1===o;)0===this.get(t,e)?e++:1===this.get(t,e)&&e>r?(o=!0,r=e):(n=!1,o=!0);for(let r=e+1;r<this.rows;r++)0!==this.get(t,r)&&(n=!1);t++}return n}echelonForm(){let t=this.clone(),e=0,r=0;for(;e<t.rows&&r<t.columns;){let n=e;for(let o=e;o<t.rows;o++)t.get(o,r)>t.get(n,r)&&(n=o);if(0===t.get(n,r))r++;else{t.swapRows(e,n);let o=t.get(e,r);for(let n=r;n<t.columns;n++)t.set(e,n,t.get(e,n)/o);for(let n=e+1;n<t.rows;n++){let o=t.get(n,r)/t.get(e,r);t.set(n,r,0);for(let i=r+1;i<t.columns;i++)t.set(n,i,t.get(n,i)-t.get(e,i)*o)}e++,r++}}return t}reducedEchelonForm(){let t=this.echelonForm(),e=t.columns,r=t.rows,n=r-1;for(;n>=0;)if(0===t.maxRow(n))n--;else{let o=0,i=!1;for(;o<r&&!1===i;)1===t.get(n,o)?i=!0:o++;for(let r=0;r<n;r++){let i=t.get(r,o);for(let s=o;s<e;s++){let e=t.get(r,s)-i*t.get(n,s);t.set(r,s,e)}}n--}return t}set(){throw new Error("set method is unimplemented")}get(){throw new Error("get method is unimplemented")}repeat(t={}){if("object"!=typeof t)throw new TypeError("options must be an object");const{rows:e=1,columns:r=1}=t;if(!Number.isInteger(e)||e<=0)throw new TypeError("rows must be a positive integer");if(!Number.isInteger(r)||r<=0)throw new TypeError("columns must be a positive integer");let n=new Ae(this.rows*e,this.columns*r);for(let t=0;t<e;t++)for(let e=0;e<r;e++)n.setSubMatrix(this,this.rows*t,this.columns*e);return n}fill(t){for(let e=0;e<this.rows;e++)for(let r=0;r<this.columns;r++)this.set(e,r,t);return this}neg(){return this.mulS(-1)}getRow(t){ye(this,t);let e=[];for(let r=0;r<this.columns;r++)e.push(this.get(t,r));return e}getRowVector(t){return Ae.rowVector(this.getRow(t))}setRow(t,e){ye(this,t),e=we(this,e);for(let r=0;r<this.columns;r++)this.set(t,r,e[r]);return this}swapRows(t,e){ye(this,t),ye(this,e);for(let r=0;r<this.columns;r++){let n=this.get(t,r);this.set(t,r,this.get(e,r)),this.set(e,r,n)}return this}getColumn(t){me(this,t);let e=[];for(let r=0;r<this.rows;r++)e.push(this.get(r,t));return e}getColumnVector(t){return Ae.columnVector(this.getColumn(t))}setColumn(t,e){me(this,t),e=ve(this,e);for(let r=0;r<this.rows;r++)this.set(r,t,e[r]);return this}swapColumns(t,e){me(this,t),me(this,e);for(let r=0;r<this.rows;r++){let n=this.get(r,t);this.set(r,t,this.get(r,e)),this.set(r,e,n)}return this}addRowVector(t){t=we(this,t);for(let e=0;e<this.rows;e++)for(let r=0;r<this.columns;r++)this.set(e,r,this.get(e,r)+t[r]);return this}subRowVector(t){t=we(this,t);for(let e=0;e<this.rows;e++)for(let r=0;r<this.columns;r++)this.set(e,r,this.get(e,r)-t[r]);return this}mulRowVector(t){t=we(this,t);for(let e=0;e<this.rows;e++)for(let r=0;r<this.columns;r++)this.set(e,r,this.get(e,r)*t[r]);return this}divRowVector(t){t=we(this,t);for(let e=0;e<this.rows;e++)for(let r=0;r<this.columns;r++)this.set(e,r,this.get(e,r)/t[r]);return this}addColumnVector(t){t=ve(this,t);for(let e=0;e<this.rows;e++)for(let r=0;r<this.columns;r++)this.set(e,r,this.get(e,r)+t[e]);return this}subColumnVector(t){t=ve(this,t);for(let e=0;e<this.rows;e++)for(let r=0;r<this.columns;r++)this.set(e,r,this.get(e,r)-t[e]);return this}mulColumnVector(t){t=ve(this,t);for(let e=0;e<this.rows;e++)for(let r=0;r<this.columns;r++)this.set(e,r,this.get(e,r)*t[e]);return this}divColumnVector(t){t=ve(this,t);for(let e=0;e<this.rows;e++)for(let r=0;r<this.columns;r++)this.set(e,r,this.get(e,r)/t[e]);return this}mulRow(t,e){ye(this,t);for(let r=0;r<this.columns;r++)this.set(t,r,this.get(t,r)*e);return this}mulColumn(t,e){me(this,t);for(let r=0;r<this.rows;r++)this.set(r,t,this.get(r,t)*e);return this}max(t){if(this.isEmpty())return NaN;switch(t){case"row":{const t=new Array(this.rows).fill(Number.NEGATIVE_INFINITY);for(let e=0;e<this.rows;e++)for(let r=0;r<this.columns;r++)this.get(e,r)>t[e]&&(t[e]=this.get(e,r));return t}case"column":{const t=new Array(this.columns).fill(Number.NEGATIVE_INFINITY);for(let e=0;e<this.rows;e++)for(let r=0;r<this.columns;r++)this.get(e,r)>t[r]&&(t[r]=this.get(e,r));return t}case void 0:{let t=this.get(0,0);for(let e=0;e<this.rows;e++)for(let r=0;r<this.columns;r++)this.get(e,r)>t&&(t=this.get(e,r));return t}default:throw new Error(`invalid option: ${t}`)}}maxIndex(){Ee(this);let t=this.get(0,0),e=[0,0];for(let r=0;r<this.rows;r++)for(let n=0;n<this.columns;n++)this.get(r,n)>t&&(t=this.get(r,n),e[0]=r,e[1]=n);return e}min(t){if(this.isEmpty())return NaN;switch(t){case"row":{const t=new Array(this.rows).fill(Number.POSITIVE_INFINITY);for(let e=0;e<this.rows;e++)for(let r=0;r<this.columns;r++)this.get(e,r)<t[e]&&(t[e]=this.get(e,r));return t}case"column":{const t=new Array(this.columns).fill(Number.POSITIVE_INFINITY);for(let e=0;e<this.rows;e++)for(let r=0;r<this.columns;r++)this.get(e,r)<t[r]&&(t[r]=this.get(e,r));return t}case void 0:{let t=this.get(0,0);for(let e=0;e<this.rows;e++)for(let r=0;r<this.columns;r++)this.get(e,r)<t&&(t=this.get(e,r));return t}default:throw new Error(`invalid option: ${t}`)}}minIndex(){Ee(this);let t=this.get(0,0),e=[0,0];for(let r=0;r<this.rows;r++)for(let n=0;n<this.columns;n++)this.get(r,n)<t&&(t=this.get(r,n),e[0]=r,e[1]=n);return e}maxRow(t){if(ye(this,t),this.isEmpty())return NaN;let e=this.get(t,0);for(let r=1;r<this.columns;r++)this.get(t,r)>e&&(e=this.get(t,r));return e}maxRowIndex(t){ye(this,t),Ee(this);let e=this.get(t,0),r=[t,0];for(let n=1;n<this.columns;n++)this.get(t,n)>e&&(e=this.get(t,n),r[1]=n);return r}minRow(t){if(ye(this,t),this.isEmpty())return NaN;let e=this.get(t,0);for(let r=1;r<this.columns;r++)this.get(t,r)<e&&(e=this.get(t,r));return e}minRowIndex(t){ye(this,t),Ee(this);let e=this.get(t,0),r=[t,0];for(let n=1;n<this.columns;n++)this.get(t,n)<e&&(e=this.get(t,n),r[1]=n);return r}maxColumn(t){if(me(this,t),this.isEmpty())return NaN;let e=this.get(0,t);for(let r=1;r<this.rows;r++)this.get(r,t)>e&&(e=this.get(r,t));return e}maxColumnIndex(t){me(this,t),Ee(this);let e=this.get(0,t),r=[0,t];for(let n=1;n<this.rows;n++)this.get(n,t)>e&&(e=this.get(n,t),r[0]=n);return r}minColumn(t){if(me(this,t),this.isEmpty())return NaN;let e=this.get(0,t);for(let r=1;r<this.rows;r++)this.get(r,t)<e&&(e=this.get(r,t));return e}minColumnIndex(t){me(this,t),Ee(this);let e=this.get(0,t),r=[0,t];for(let n=1;n<this.rows;n++)this.get(n,t)<e&&(e=this.get(n,t),r[0]=n);return r}diag(){let t=Math.min(this.rows,this.columns),e=[];for(let r=0;r<t;r++)e.push(this.get(r,r));return e}norm(t="frobenius"){let e=0;if("max"===t)return this.max();if("frobenius"===t){for(let t=0;t<this.rows;t++)for(let r=0;r<this.columns;r++)e+=this.get(t,r)*this.get(t,r);return Math.sqrt(e)}throw new RangeError(`unknown norm type: ${t}`)}cumulativeSum(){let t=0;for(let e=0;e<this.rows;e++)for(let r=0;r<this.columns;r++)t+=this.get(e,r),this.set(e,r,t);return this}dot(t){Ne.isMatrix(t)&&(t=t.to1DArray());let e=this.to1DArray();if(e.length!==t.length)throw new RangeError("vectors do not have the same size");let r=0;for(let n=0;n<e.length;n++)r+=e[n]*t[n];return r}mmul(t){t=Ae.checkMatrix(t);let e=this.rows,r=this.columns,n=t.columns,o=new Ae(e,n),i=new Float64Array(r);for(let s=0;s<n;s++){for(let e=0;e<r;e++)i[e]=t.get(e,s);for(let t=0;t<e;t++){let e=0;for(let n=0;n<r;n++)e+=this.get(t,n)*i[n];o.set(t,s,e)}}return o}strassen2x2(t){t=Ae.checkMatrix(t);let e=new Ae(2,2);const r=this.get(0,0),n=t.get(0,0),o=this.get(0,1),i=t.get(0,1),s=this.get(1,0),a=t.get(1,0),h=this.get(1,1),u=t.get(1,1),c=(r+h)*(n+u),l=(s+h)*n,f=r*(i-u),d=h*(a-n),g=(r+o)*u,p=c+d-g+(o-h)*(a+u),y=f+g,m=l+d,w=c-l+f+(s-r)*(n+i);return e.set(0,0,p),e.set(0,1,y),e.set(1,0,m),e.set(1,1,w),e}strassen3x3(t){t=Ae.checkMatrix(t);let e=new Ae(3,3);const r=this.get(0,0),n=this.get(0,1),o=this.get(0,2),i=this.get(1,0),s=this.get(1,1),a=this.get(1,2),h=this.get(2,0),u=this.get(2,1),c=this.get(2,2),l=t.get(0,0),f=t.get(0,1),d=t.get(0,2),g=t.get(1,0),p=t.get(1,1),y=t.get(1,2),m=t.get(2,0),w=t.get(2,1),v=t.get(2,2),x=(r-i)*(-f+p),M=(-r+i+s)*(l-f+p),b=(i+s)*(-l+f),E=r*l,N=(-r+h+u)*(l-d+y),S=(-r+h)*(d-y),A=(h+u)*(-l+d),k=(-o+u+c)*(p+m-w),D=(o-c)*(p-w),I=o*m,_=(u+c)*(-m+w),R=(-o+s+a)*(y+m-v),z=(o-a)*(y-v),T=(s+a)*(-m+v),C=E+I+n*g,O=(r+n+o-i-s-u-c)*p+M+b+E+k+I+_,P=E+N+A+(r+n+o-s-a-h-u)*y+I+R+T,q=x+s*(-l+f+g-p-y-m+v)+M+E+I+R+z,F=x+M+b+E+a*w,L=I+R+z+T+i*d,j=E+N+S+u*(-l+d+g-p-y-m+w)+k+D+I,V=k+D+I+_+h*f,W=E+N+S+A+c*v;return e.set(0,0,C),e.set(0,1,O),e.set(0,2,P),e.set(1,0,q),e.set(1,1,F),e.set(1,2,L),e.set(2,0,j),e.set(2,1,V),e.set(2,2,W),e}mmulStrassen(t){t=Ae.checkMatrix(t);let e=this.clone(),r=e.rows,n=e.columns,o=t.rows,i=t.columns;function s(t,e,r){let n=t.rows,o=t.columns;if(n===e&&o===r)return t;{let n=Ne.zeros(e,r);return n=n.setSubMatrix(t,0,0),n}}n!==o&&console.warn(`Multiplying ${r} x ${n} and ${o} x ${i} matrix: dimensions do not match.`);let a=Math.max(r,o),h=Math.max(n,i);return e=s(e,a,h),function t(e,r,n,o){if(n<=512||o<=512)return e.mmul(r);n%2==1&&o%2==1?(e=s(e,n+1,o+1),r=s(r,n+1,o+1)):n%2==1?(e=s(e,n+1,o),r=s(r,n+1,o)):o%2==1&&(e=s(e,n,o+1),r=s(r,n,o+1));let i=parseInt(e.rows/2,10),a=parseInt(e.columns/2,10),h=e.subMatrix(0,i-1,0,a-1),u=r.subMatrix(0,i-1,0,a-1),c=e.subMatrix(0,i-1,a,e.columns-1),l=r.subMatrix(0,i-1,a,r.columns-1),f=e.subMatrix(i,e.rows-1,0,a-1),d=r.subMatrix(i,r.rows-1,0,a-1),g=e.subMatrix(i,e.rows-1,a,e.columns-1),p=r.subMatrix(i,r.rows-1,a,r.columns-1),y=t(Ne.add(h,g),Ne.add(u,p),i,a),m=t(Ne.add(f,g),u,i,a),w=t(h,Ne.sub(l,p),i,a),v=t(g,Ne.sub(d,u),i,a),x=t(Ne.add(h,c),p,i,a),M=t(Ne.sub(f,h),Ne.add(u,l),i,a),b=t(Ne.sub(c,g),Ne.add(d,p),i,a),E=Ne.add(y,v);E.sub(x),E.add(b);let N=Ne.add(w,x),S=Ne.add(m,v),A=Ne.sub(y,m);A.add(w),A.add(M);let k=Ne.zeros(2*E.rows,2*E.columns);return k=k.setSubMatrix(E,0,0),k=k.setSubMatrix(N,E.rows,0),k=k.setSubMatrix(S,0,E.columns),k=k.setSubMatrix(A,E.rows,E.columns),k.subMatrix(0,n-1,0,o-1)}(e,t=s(t,a,h),a,h)}scaleRows(t={}){if("object"!=typeof t)throw new TypeError("options must be an object");const{min:e=0,max:r=1}=t;if(!Number.isFinite(e))throw new TypeError("min must be a number");if(!Number.isFinite(r))throw new TypeError("max must be a number");if(e>=r)throw new RangeError("min must be smaller than max");let n=new Ae(this.rows,this.columns);for(let t=0;t<this.rows;t++){const o=this.getRow(t);o.length>0&&ce(o,{min:e,max:r,output:o}),n.setRow(t,o)}return n}scaleColumns(t={}){if("object"!=typeof t)throw new TypeError("options must be an object");const{min:e=0,max:r=1}=t;if(!Number.isFinite(e))throw new TypeError("min must be a number");if(!Number.isFinite(r))throw new TypeError("max must be a number");if(e>=r)throw new RangeError("min must be smaller than max");let n=new Ae(this.rows,this.columns);for(let t=0;t<this.columns;t++){const o=this.getColumn(t);o.length&&ce(o,{min:e,max:r,output:o}),n.setColumn(t,o)}return n}flipRows(){const t=Math.ceil(this.columns/2);for(let e=0;e<this.rows;e++)for(let r=0;r<t;r++){let t=this.get(e,r),n=this.get(e,this.columns-1-r);this.set(e,r,n),this.set(e,this.columns-1-r,t)}return this}flipColumns(){const t=Math.ceil(this.rows/2);for(let e=0;e<this.columns;e++)for(let r=0;r<t;r++){let t=this.get(r,e),n=this.get(this.rows-1-r,e);this.set(r,e,n),this.set(this.rows-1-r,e,t)}return this}kroneckerProduct(t){t=Ae.checkMatrix(t);let e=this.rows,r=this.columns,n=t.rows,o=t.columns,i=new Ae(e*n,r*o);for(let s=0;s<e;s++)for(let e=0;e<r;e++)for(let r=0;r<n;r++)for(let a=0;a<o;a++)i.set(n*s+r,o*e+a,this.get(s,e)*t.get(r,a));return i}kroneckerSum(t){if(t=Ae.checkMatrix(t),!this.isSquare()||!t.isSquare())throw new Error("Kronecker Sum needs two Square Matrices");let e=this.rows,r=t.rows,n=this.kroneckerProduct(Ae.eye(r,r)),o=Ae.eye(e,e).kroneckerProduct(t);return n.add(o)}transpose(){let t=new Ae(this.columns,this.rows);for(let e=0;e<this.rows;e++)for(let r=0;r<this.columns;r++)t.set(r,e,this.get(e,r));return t}sortRows(t=Se){for(let e=0;e<this.rows;e++)this.setRow(e,this.getRow(e).sort(t));return this}sortColumns(t=Se){for(let e=0;e<this.columns;e++)this.setColumn(e,this.getColumn(e).sort(t));return this}subMatrix(t,e,r,n){xe(this,t,e,r,n);let o=new Ae(e-t+1,n-r+1);for(let i=t;i<=e;i++)for(let e=r;e<=n;e++)o.set(i-t,e-r,this.get(i,e));return o}subMatrixRow(t,e,r){if(void 0===e&&(e=0),void 0===r&&(r=this.columns-1),e>r||e<0||e>=this.columns||r<0||r>=this.columns)throw new RangeError("Argument out of range");let n=new Ae(t.length,r-e+1);for(let o=0;o<t.length;o++)for(let i=e;i<=r;i++){if(t[o]<0||t[o]>=this.rows)throw new RangeError(`Row index out of range: ${t[o]}`);n.set(o,i-e,this.get(t[o],i))}return n}subMatrixColumn(t,e,r){if(void 0===e&&(e=0),void 0===r&&(r=this.rows-1),e>r||e<0||e>=this.rows||r<0||r>=this.rows)throw new RangeError("Argument out of range");let n=new Ae(r-e+1,t.length);for(let o=0;o<t.length;o++)for(let i=e;i<=r;i++){if(t[o]<0||t[o]>=this.columns)throw new RangeError(`Column index out of range: ${t[o]}`);n.set(i-e,o,this.get(i,t[o]))}return n}setSubMatrix(t,e,r){if((t=Ae.checkMatrix(t)).isEmpty())return this;xe(this,e,e+t.rows-1,r,r+t.columns-1);for(let n=0;n<t.rows;n++)for(let o=0;o<t.columns;o++)this.set(e+n,r+o,t.get(n,o));return this}selection(t,e){!function(t,e){if(!ue(e))throw new TypeError("row indices must be an array");for(let r=0;r<e.length;r++)if(e[r]<0||e[r]>=t.rows)throw new RangeError("row indices are out of range")}(this,t),function(t,e){if(!ue(e))throw new TypeError("column indices must be an array");for(let r=0;r<e.length;r++)if(e[r]<0||e[r]>=t.columns)throw new RangeError("column indices are out of range")}(this,e);let r=new Ae(t.length,e.length);for(let n=0;n<t.length;n++){let o=t[n];for(let t=0;t<e.length;t++){let i=e[t];r.set(n,t,this.get(o,i))}}return r}trace(){let t=Math.min(this.rows,this.columns),e=0;for(let r=0;r<t;r++)e+=this.get(r,r);return e}clone(){let t=new Ae(this.rows,this.columns);for(let e=0;e<this.rows;e++)for(let r=0;r<this.columns;r++)t.set(e,r,this.get(e,r));return t}sum(t){switch(t){case"row":return function(t){let e=Me(t.rows);for(let r=0;r<t.rows;++r)for(let n=0;n<t.columns;++n)e[r]+=t.get(r,n);return e}(this);case"column":return function(t){let e=Me(t.columns);for(let r=0;r<t.rows;++r)for(let n=0;n<t.columns;++n)e[n]+=t.get(r,n);return e}(this);case void 0:return function(t){let e=0;for(let r=0;r<t.rows;r++)for(let n=0;n<t.columns;n++)e+=t.get(r,n);return e}(this);default:throw new Error(`invalid option: ${t}`)}}product(t){switch(t){case"row":return function(t){let e=Me(t.rows,1);for(let r=0;r<t.rows;++r)for(let n=0;n<t.columns;++n)e[r]*=t.get(r,n);return e}(this);case"column":return function(t){let e=Me(t.columns,1);for(let r=0;r<t.rows;++r)for(let n=0;n<t.columns;++n)e[n]*=t.get(r,n);return e}(this);case void 0:return function(t){let e=1;for(let r=0;r<t.rows;r++)for(let n=0;n<t.columns;n++)e*=t.get(r,n);return e}(this);default:throw new Error(`invalid option: ${t}`)}}mean(t){const e=this.sum(t);switch(t){case"row":for(let t=0;t<this.rows;t++)e[t]/=this.columns;return e;case"column":for(let t=0;t<this.columns;t++)e[t]/=this.rows;return e;case void 0:return e/this.size;default:throw new Error(`invalid option: ${t}`)}}variance(t,e={}){if("object"==typeof t&&(e=t,t=void 0),"object"!=typeof e)throw new TypeError("options must be an object");const{unbiased:r=!0,mean:n=this.mean(t)}=e;if("boolean"!=typeof r)throw new TypeError("unbiased must be a boolean");switch(t){case"row":if(!ue(n))throw new TypeError("mean must be an array");return function(t,e,r){const n=t.rows,o=t.columns,i=[];for(let s=0;s<n;s++){let n=0,a=0,h=0;for(let e=0;e<o;e++)h=t.get(s,e)-r[s],n+=h,a+=h*h;e?i.push((a-n*n/o)/(o-1)):i.push((a-n*n/o)/o)}return i}(this,r,n);case"column":if(!ue(n))throw new TypeError("mean must be an array");return function(t,e,r){const n=t.rows,o=t.columns,i=[];for(let s=0;s<o;s++){let o=0,a=0,h=0;for(let e=0;e<n;e++)h=t.get(e,s)-r[s],o+=h,a+=h*h;e?i.push((a-o*o/n)/(n-1)):i.push((a-o*o/n)/n)}return i}(this,r,n);case void 0:if("number"!=typeof n)throw new TypeError("mean must be a number");return function(t,e,r){const n=t.rows,o=t.columns,i=n*o;let s=0,a=0,h=0;for(let e=0;e<n;e++)for(let n=0;n<o;n++)h=t.get(e,n)-r,s+=h,a+=h*h;return e?(a-s*s/i)/(i-1):(a-s*s/i)/i}(this,r,n);default:throw new Error(`invalid option: ${t}`)}}standardDeviation(t,e){"object"==typeof t&&(e=t,t=void 0);const r=this.variance(t,e);if(void 0===t)return Math.sqrt(r);for(let t=0;t<r.length;t++)r[t]=Math.sqrt(r[t]);return r}center(t,e={}){if("object"==typeof t&&(e=t,t=void 0),"object"!=typeof e)throw new TypeError("options must be an object");const{center:r=this.mean(t)}=e;switch(t){case"row":if(!ue(r))throw new TypeError("center must be an array");return function(t,e){for(let r=0;r<t.rows;r++)for(let n=0;n<t.columns;n++)t.set(r,n,t.get(r,n)-e[r])}(this,r),this;case"column":if(!ue(r))throw new TypeError("center must be an array");return function(t,e){for(let r=0;r<t.rows;r++)for(let n=0;n<t.columns;n++)t.set(r,n,t.get(r,n)-e[n])}(this,r),this;case void 0:if("number"!=typeof r)throw new TypeError("center must be a number");return function(t,e){for(let r=0;r<t.rows;r++)for(let n=0;n<t.columns;n++)t.set(r,n,t.get(r,n)-e)}(this,r),this;default:throw new Error(`invalid option: ${t}`)}}scale(t,e={}){if("object"==typeof t&&(e=t,t=void 0),"object"!=typeof e)throw new TypeError("options must be an object");let r=e.scale;switch(t){case"row":if(void 0===r)r=function(t){const e=[];for(let r=0;r<t.rows;r++){let n=0;for(let e=0;e<t.columns;e++)n+=Math.pow(t.get(r,e),2)/(t.columns-1);e.push(Math.sqrt(n))}return e}(this);else if(!ue(r))throw new TypeError("scale must be an array");return function(t,e){for(let r=0;r<t.rows;r++)for(let n=0;n<t.columns;n++)t.set(r,n,t.get(r,n)/e[r])}(this,r),this;case"column":if(void 0===r)r=function(t){const e=[];for(let r=0;r<t.columns;r++){let n=0;for(let e=0;e<t.rows;e++)n+=Math.pow(t.get(e,r),2)/(t.rows-1);e.push(Math.sqrt(n))}return e}(this);else if(!ue(r))throw new TypeError("scale must be an array");return function(t,e){for(let r=0;r<t.rows;r++)for(let n=0;n<t.columns;n++)t.set(r,n,t.get(r,n)/e[n])}(this,r),this;case void 0:if(void 0===r)r=function(t){const e=t.size-1;let r=0;for(let n=0;n<t.columns;n++)for(let o=0;o<t.rows;o++)r+=Math.pow(t.get(o,n),2)/e;return Math.sqrt(r)}(this);else if("number"!=typeof r)throw new TypeError("scale must be a number");return function(t,e){for(let r=0;r<t.rows;r++)for(let n=0;n<t.columns;n++)t.set(r,n,t.get(r,n)/e)}(this,r),this;default:throw new Error(`invalid option: ${t}`)}}toString(t){return de(this,t)}}function Se(t,e){return t-e}Ne.prototype.klass="Matrix","undefined"!=typeof Symbol&&(Ne.prototype[Symbol.for("nodejs.util.inspect.custom")]=function(){return de(this)}),Ne.random=Ne.rand,Ne.randomInt=Ne.randInt,Ne.diagonal=Ne.diag,Ne.prototype.diagonal=Ne.prototype.diag,Ne.identity=Ne.eye,Ne.prototype.negate=Ne.prototype.neg,Ne.prototype.tensorProduct=Ne.prototype.kroneckerProduct;class Ae extends Ne{constructor(t,e){if(super(),Ae.isMatrix(t))return t.clone();if(Number.isInteger(t)&&t>=0){if(this.data=[],!(Number.isInteger(e)&&e>=0))throw new TypeError("nColumns must be a positive integer");for(let r=0;r<t;r++)this.data.push(new Float64Array(e))}else{if(!ue(t))throw new TypeError("First argument must be a positive number or an array");{const r=t;if("number"!=typeof(e=(t=r.length)?r[0].length:0))throw new TypeError("Data must be a 2D array with at least one element");this.data=[];for(let n=0;n<t;n++){if(r[n].length!==e)throw new RangeError("Inconsistent array dimensions");if(!r[n].every((t=>"number"==typeof t)))throw new TypeError("Input data contains non-numeric values");this.data.push(Float64Array.from(r[n]))}}}this.rows=t,this.columns=e}set(t,e,r){return this.data[t][e]=r,this}get(t,e){return this.data[t][e]}removeRow(t){return ye(this,t),this.data.splice(t,1),this.rows-=1,this}addRow(t,e){return void 0===e&&(e=t,t=this.rows),ye(this,t,!0),e=Float64Array.from(we(this,e)),this.data.splice(t,0,e),this.rows+=1,this}removeColumn(t){me(this,t);for(let e=0;e<this.rows;e++){const r=new Float64Array(this.columns-1);for(let n=0;n<t;n++)r[n]=this.data[e][n];for(let n=t+1;n<this.columns;n++)r[n-1]=this.data[e][n];this.data[e]=r}return this.columns-=1,this}addColumn(t,e){void 0===e&&(e=t,t=this.columns),me(this,t,!0),e=ve(this,e);for(let r=0;r<this.rows;r++){const n=new Float64Array(this.columns+1);let o=0;for(;o<t;o++)n[o]=this.data[r][o];for(n[o++]=e[r];o<this.columns+1;o++)n[o]=this.data[r][o-1];this.data[r]=n}return this.columns+=1,this}}!function(t,e){t.prototype.add=function(t){return"number"==typeof t?this.addS(t):this.addM(t)},t.prototype.addS=function(t){for(let e=0;e<this.rows;e++)for(let r=0;r<this.columns;r++)this.set(e,r,this.get(e,r)+t);return this},t.prototype.addM=function(t){if(t=e.checkMatrix(t),this.rows!==t.rows||this.columns!==t.columns)throw new RangeError("Matrices dimensions must be equal");for(let e=0;e<this.rows;e++)for(let r=0;r<this.columns;r++)this.set(e,r,this.get(e,r)+t.get(e,r));return this},t.add=function(t,r){return new e(t).add(r)},t.prototype.sub=function(t){return"number"==typeof t?this.subS(t):this.subM(t)},t.prototype.subS=function(t){for(let e=0;e<this.rows;e++)for(let r=0;r<this.columns;r++)this.set(e,r,this.get(e,r)-t);return this},t.prototype.subM=function(t){if(t=e.checkMatrix(t),this.rows!==t.rows||this.columns!==t.columns)throw new RangeError("Matrices dimensions must be equal");for(let e=0;e<this.rows;e++)for(let r=0;r<this.columns;r++)this.set(e,r,this.get(e,r)-t.get(e,r));return this},t.sub=function(t,r){return new e(t).sub(r)},t.prototype.subtract=t.prototype.sub,t.prototype.subtractS=t.prototype.subS,t.prototype.subtractM=t.prototype.subM,t.subtract=t.sub,t.prototype.mul=function(t){return"number"==typeof t?this.mulS(t):this.mulM(t)},t.prototype.mulS=function(t){for(let e=0;e<this.rows;e++)for(let r=0;r<this.columns;r++)this.set(e,r,this.get(e,r)*t);return this},t.prototype.mulM=function(t){if(t=e.checkMatrix(t),this.rows!==t.rows||this.columns!==t.columns)throw new RangeError("Matrices dimensions must be equal");for(let e=0;e<this.rows;e++)for(let r=0;r<this.columns;r++)this.set(e,r,this.get(e,r)*t.get(e,r));return this},t.mul=function(t,r){return new e(t).mul(r)},t.prototype.multiply=t.prototype.mul,t.prototype.multiplyS=t.prototype.mulS,t.prototype.multiplyM=t.prototype.mulM,t.multiply=t.mul,t.prototype.div=function(t){return"number"==typeof t?this.divS(t):this.divM(t)},t.prototype.divS=function(t){for(let e=0;e<this.rows;e++)for(let r=0;r<this.columns;r++)this.set(e,r,this.get(e,r)/t);return this},t.prototype.divM=function(t){if(t=e.checkMatrix(t),this.rows!==t.rows||this.columns!==t.columns)throw new RangeError("Matrices dimensions must be equal");for(let e=0;e<this.rows;e++)for(let r=0;r<this.columns;r++)this.set(e,r,this.get(e,r)/t.get(e,r));return this},t.div=function(t,r){return new e(t).div(r)},t.prototype.divide=t.prototype.div,t.prototype.divideS=t.prototype.divS,t.prototype.divideM=t.prototype.divM,t.divide=t.div,t.prototype.mod=function(t){return"number"==typeof t?this.modS(t):this.modM(t)},t.prototype.modS=function(t){for(let e=0;e<this.rows;e++)for(let r=0;r<this.columns;r++)this.set(e,r,this.get(e,r)%t);return this},t.prototype.modM=function(t){if(t=e.checkMatrix(t),this.rows!==t.rows||this.columns!==t.columns)throw new RangeError("Matrices dimensions must be equal");for(let e=0;e<this.rows;e++)for(let r=0;r<this.columns;r++)this.set(e,r,this.get(e,r)%t.get(e,r));return this},t.mod=function(t,r){return new e(t).mod(r)},t.prototype.modulus=t.prototype.mod,t.prototype.modulusS=t.prototype.modS,t.prototype.modulusM=t.prototype.modM,t.modulus=t.mod,t.prototype.and=function(t){return"number"==typeof t?this.andS(t):this.andM(t)},t.prototype.andS=function(t){for(let e=0;e<this.rows;e++)for(let r=0;r<this.columns;r++)this.set(e,r,this.get(e,r)&t);return this},t.prototype.andM=function(t){if(t=e.checkMatrix(t),this.rows!==t.rows||this.columns!==t.columns)throw new RangeError("Matrices dimensions must be equal");for(let e=0;e<this.rows;e++)for(let r=0;r<this.columns;r++)this.set(e,r,this.get(e,r)&t.get(e,r));return this},t.and=function(t,r){return new e(t).and(r)},t.prototype.or=function(t){return"number"==typeof t?this.orS(t):this.orM(t)},t.prototype.orS=function(t){for(let e=0;e<this.rows;e++)for(let r=0;r<this.columns;r++)this.set(e,r,this.get(e,r)|t);return this},t.prototype.orM=function(t){if(t=e.checkMatrix(t),this.rows!==t.rows||this.columns!==t.columns)throw new RangeError("Matrices dimensions must be equal");for(let e=0;e<this.rows;e++)for(let r=0;r<this.columns;r++)this.set(e,r,this.get(e,r)|t.get(e,r));return this},t.or=function(t,r){return new e(t).or(r)},t.prototype.xor=function(t){return"number"==typeof t?this.xorS(t):this.xorM(t)},t.prototype.xorS=function(t){for(let e=0;e<this.rows;e++)for(let r=0;r<this.columns;r++)this.set(e,r,this.get(e,r)^t);return this},t.prototype.xorM=function(t){if(t=e.checkMatrix(t),this.rows!==t.rows||this.columns!==t.columns)throw new RangeError("Matrices dimensions must be equal");for(let e=0;e<this.rows;e++)for(let r=0;r<this.columns;r++)this.set(e,r,this.get(e,r)^t.get(e,r));return this},t.xor=function(t,r){return new e(t).xor(r)},t.prototype.leftShift=function(t){return"number"==typeof t?this.leftShiftS(t):this.leftShiftM(t)},t.prototype.leftShiftS=function(t){for(let e=0;e<this.rows;e++)for(let r=0;r<this.columns;r++)this.set(e,r,this.get(e,r)<<t);return this},t.prototype.leftShiftM=function(t){if(t=e.checkMatrix(t),this.rows!==t.rows||this.columns!==t.columns)throw new RangeError("Matrices dimensions must be equal");for(let e=0;e<this.rows;e++)for(let r=0;r<this.columns;r++)this.set(e,r,this.get(e,r)<<t.get(e,r));return this},t.leftShift=function(t,r){return new e(t).leftShift(r)},t.prototype.signPropagatingRightShift=function(t){return"number"==typeof t?this.signPropagatingRightShiftS(t):this.signPropagatingRightShiftM(t)},t.prototype.signPropagatingRightShiftS=function(t){for(let e=0;e<this.rows;e++)for(let r=0;r<this.columns;r++)this.set(e,r,this.get(e,r)>>t);return this},t.prototype.signPropagatingRightShiftM=function(t){if(t=e.checkMatrix(t),this.rows!==t.rows||this.columns!==t.columns)throw new RangeError("Matrices dimensions must be equal");for(let e=0;e<this.rows;e++)for(let r=0;r<this.columns;r++)this.set(e,r,this.get(e,r)>>t.get(e,r));return this},t.signPropagatingRightShift=function(t,r){return new e(t).signPropagatingRightShift(r)},t.prototype.rightShift=function(t){return"number"==typeof t?this.rightShiftS(t):this.rightShiftM(t)},t.prototype.rightShiftS=function(t){for(let e=0;e<this.rows;e++)for(let r=0;r<this.columns;r++)this.set(e,r,this.get(e,r)>>>t);return this},t.prototype.rightShiftM=function(t){if(t=e.checkMatrix(t),this.rows!==t.rows||this.columns!==t.columns)throw new RangeError("Matrices dimensions must be equal");for(let e=0;e<this.rows;e++)for(let r=0;r<this.columns;r++)this.set(e,r,this.get(e,r)>>>t.get(e,r));return this},t.rightShift=function(t,r){return new e(t).rightShift(r)},t.prototype.zeroFillRightShift=t.prototype.rightShift,t.prototype.zeroFillRightShiftS=t.prototype.rightShiftS,t.prototype.zeroFillRightShiftM=t.prototype.rightShiftM,t.zeroFillRightShift=t.rightShift,t.prototype.not=function(){for(let t=0;t<this.rows;t++)for(let e=0;e<this.columns;e++)this.set(t,e,~this.get(t,e));return this},t.not=function(t){return new e(t).not()},t.prototype.abs=function(){for(let t=0;t<this.rows;t++)for(let e=0;e<this.columns;e++)this.set(t,e,Math.abs(this.get(t,e)));return this},t.abs=function(t){return new e(t).abs()},t.prototype.acos=function(){for(let t=0;t<this.rows;t++)for(let e=0;e<this.columns;e++)this.set(t,e,Math.acos(this.get(t,e)));return this},t.acos=function(t){return new e(t).acos()},t.prototype.acosh=function(){for(let t=0;t<this.rows;t++)for(let e=0;e<this.columns;e++)this.set(t,e,Math.acosh(this.get(t,e)));return this},t.acosh=function(t){return new e(t).acosh()},t.prototype.asin=function(){for(let t=0;t<this.rows;t++)for(let e=0;e<this.columns;e++)this.set(t,e,Math.asin(this.get(t,e)));return this},t.asin=function(t){return new e(t).asin()},t.prototype.asinh=function(){for(let t=0;t<this.rows;t++)for(let e=0;e<this.columns;e++)this.set(t,e,Math.asinh(this.get(t,e)));return this},t.asinh=function(t){return new e(t).asinh()},t.prototype.atan=function(){for(let t=0;t<this.rows;t++)for(let e=0;e<this.columns;e++)this.set(t,e,Math.atan(this.get(t,e)));return this},t.atan=function(t){return new e(t).atan()},t.prototype.atanh=function(){for(let t=0;t<this.rows;t++)for(let e=0;e<this.columns;e++)this.set(t,e,Math.atanh(this.get(t,e)));return this},t.atanh=function(t){return new e(t).atanh()},t.prototype.cbrt=function(){for(let t=0;t<this.rows;t++)for(let e=0;e<this.columns;e++)this.set(t,e,Math.cbrt(this.get(t,e)));return this},t.cbrt=function(t){return new e(t).cbrt()},t.prototype.ceil=function(){for(let t=0;t<this.rows;t++)for(let e=0;e<this.columns;e++)this.set(t,e,Math.ceil(this.get(t,e)));return this},t.ceil=function(t){return new e(t).ceil()},t.prototype.clz32=function(){for(let t=0;t<this.rows;t++)for(let e=0;e<this.columns;e++)this.set(t,e,Math.clz32(this.get(t,e)));return this},t.clz32=function(t){return new e(t).clz32()},t.prototype.cos=function(){for(let t=0;t<this.rows;t++)for(let e=0;e<this.columns;e++)this.set(t,e,Math.cos(this.get(t,e)));return this},t.cos=function(t){return new e(t).cos()},t.prototype.cosh=function(){for(let t=0;t<this.rows;t++)for(let e=0;e<this.columns;e++)this.set(t,e,Math.cosh(this.get(t,e)));return this},t.cosh=function(t){return new e(t).cosh()},t.prototype.exp=function(){for(let t=0;t<this.rows;t++)for(let e=0;e<this.columns;e++)this.set(t,e,Math.exp(this.get(t,e)));return this},t.exp=function(t){return new e(t).exp()},t.prototype.expm1=function(){for(let t=0;t<this.rows;t++)for(let e=0;e<this.columns;e++)this.set(t,e,Math.expm1(this.get(t,e)));return this},t.expm1=function(t){return new e(t).expm1()},t.prototype.floor=function(){for(let t=0;t<this.rows;t++)for(let e=0;e<this.columns;e++)this.set(t,e,Math.floor(this.get(t,e)));return this},t.floor=function(t){return new e(t).floor()},t.prototype.fround=function(){for(let t=0;t<this.rows;t++)for(let e=0;e<this.columns;e++)this.set(t,e,Math.fround(this.get(t,e)));return this},t.fround=function(t){return new e(t).fround()},t.prototype.log=function(){for(let t=0;t<this.rows;t++)for(let e=0;e<this.columns;e++)this.set(t,e,Math.log(this.get(t,e)));return this},t.log=function(t){return new e(t).log()},t.prototype.log1p=function(){for(let t=0;t<this.rows;t++)for(let e=0;e<this.columns;e++)this.set(t,e,Math.log1p(this.get(t,e)));return this},t.log1p=function(t){return new e(t).log1p()},t.prototype.log10=function(){for(let t=0;t<this.rows;t++)for(let e=0;e<this.columns;e++)this.set(t,e,Math.log10(this.get(t,e)));return this},t.log10=function(t){return new e(t).log10()},t.prototype.log2=function(){for(let t=0;t<this.rows;t++)for(let e=0;e<this.columns;e++)this.set(t,e,Math.log2(this.get(t,e)));return this},t.log2=function(t){return new e(t).log2()},t.prototype.round=function(){for(let t=0;t<this.rows;t++)for(let e=0;e<this.columns;e++)this.set(t,e,Math.round(this.get(t,e)));return this},t.round=function(t){return new e(t).round()},t.prototype.sign=function(){for(let t=0;t<this.rows;t++)for(let e=0;e<this.columns;e++)this.set(t,e,Math.sign(this.get(t,e)));return this},t.sign=function(t){return new e(t).sign()},t.prototype.sin=function(){for(let t=0;t<this.rows;t++)for(let e=0;e<this.columns;e++)this.set(t,e,Math.sin(this.get(t,e)));return this},t.sin=function(t){return new e(t).sin()},t.prototype.sinh=function(){for(let t=0;t<this.rows;t++)for(let e=0;e<this.columns;e++)this.set(t,e,Math.sinh(this.get(t,e)));return this},t.sinh=function(t){return new e(t).sinh()},t.prototype.sqrt=function(){for(let t=0;t<this.rows;t++)for(let e=0;e<this.columns;e++)this.set(t,e,Math.sqrt(this.get(t,e)));return this},t.sqrt=function(t){return new e(t).sqrt()},t.prototype.tan=function(){for(let t=0;t<this.rows;t++)for(let e=0;e<this.columns;e++)this.set(t,e,Math.tan(this.get(t,e)));return this},t.tan=function(t){return new e(t).tan()},t.prototype.tanh=function(){for(let t=0;t<this.rows;t++)for(let e=0;e<this.columns;e++)this.set(t,e,Math.tanh(this.get(t,e)));return this},t.tanh=function(t){return new e(t).tanh()},t.prototype.trunc=function(){for(let t=0;t<this.rows;t++)for(let e=0;e<this.columns;e++)this.set(t,e,Math.trunc(this.get(t,e)));return this},t.trunc=function(t){return new e(t).trunc()},t.pow=function(t,r){return new e(t).pow(r)},t.prototype.pow=function(t){return"number"==typeof t?this.powS(t):this.powM(t)},t.prototype.powS=function(t){for(let e=0;e<this.rows;e++)for(let r=0;r<this.columns;r++)this.set(e,r,Math.pow(this.get(e,r),t));return this},t.prototype.powM=function(t){if(t=e.checkMatrix(t),this.rows!==t.rows||this.columns!==t.columns)throw new RangeError("Matrices dimensions must be equal");for(let e=0;e<this.rows;e++)for(let r=0;r<this.columns;r++)this.set(e,r,Math.pow(this.get(e,r),t.get(e,r)));return this}}(Ne,Ae);class ke extends Ne{constructor(t){super(),this.data=t,this.rows=t.length,this.columns=t[0].length}set(t,e,r){return this.data[t][e]=r,this}get(t,e){return this.data[t][e]}}function De(t,e){let r=0;return Math.abs(t)>Math.abs(e)?(r=e/t,Math.abs(t)*Math.sqrt(1+r*r)):0!==e?(r=t/e,Math.abs(e)*Math.sqrt(1+r*r)):0}class Ie{constructor(t,e={}){if((t=ke.checkMatrix(t)).isEmpty())throw new Error("Matrix must be non-empty");let r=t.rows,n=t.columns;const{computeLeftSingularVectors:o=!0,computeRightSingularVectors:i=!0,autoTranspose:s=!1}=e;let a,h=Boolean(o),u=Boolean(i),c=!1;if(r<n)if(s){a=t.transpose(),r=a.rows,n=a.columns,c=!0;let e=h;h=u,u=e}else a=t.clone(),console.warn("Computing SVD on a matrix with more columns than rows. Consider enabling autoTranspose");else a=t.clone();let l=Math.min(r,n),f=Math.min(r+1,n),d=new Float64Array(f),g=new Ae(r,l),p=new Ae(n,n),y=new Float64Array(n),m=new Float64Array(r),w=new Float64Array(f);for(let t=0;t<f;t++)w[t]=t;let v=Math.min(r-1,n),x=Math.max(0,Math.min(n-2,r)),M=Math.max(v,x);for(let t=0;t<M;t++){if(t<v){d[t]=0;for(let e=t;e<r;e++)d[t]=De(d[t],a.get(e,t));if(0!==d[t]){a.get(t,t)<0&&(d[t]=-d[t]);for(let e=t;e<r;e++)a.set(e,t,a.get(e,t)/d[t]);a.set(t,t,a.get(t,t)+1)}d[t]=-d[t]}for(let e=t+1;e<n;e++){if(t<v&&0!==d[t]){let n=0;for(let o=t;o<r;o++)n+=a.get(o,t)*a.get(o,e);n=-n/a.get(t,t);for(let o=t;o<r;o++)a.set(o,e,a.get(o,e)+n*a.get(o,t))}y[e]=a.get(t,e)}if(h&&t<v)for(let e=t;e<r;e++)g.set(e,t,a.get(e,t));if(t<x){y[t]=0;for(let e=t+1;e<n;e++)y[t]=De(y[t],y[e]);if(0!==y[t]){y[t+1]<0&&(y[t]=0-y[t]);for(let e=t+1;e<n;e++)y[e]/=y[t];y[t+1]+=1}if(y[t]=-y[t],t+1<r&&0!==y[t]){for(let e=t+1;e<r;e++)m[e]=0;for(let e=t+1;e<r;e++)for(let r=t+1;r<n;r++)m[e]+=y[r]*a.get(e,r);for(let e=t+1;e<n;e++){let n=-y[e]/y[t+1];for(let o=t+1;o<r;o++)a.set(o,e,a.get(o,e)+n*m[o])}}if(u)for(let e=t+1;e<n;e++)p.set(e,t,y[e])}}let b=Math.min(n,r+1);if(v<n&&(d[v]=a.get(v,v)),r<b&&(d[b-1]=0),x+1<b&&(y[x]=a.get(x,b-1)),y[b-1]=0,h){for(let t=v;t<l;t++){for(let e=0;e<r;e++)g.set(e,t,0);g.set(t,t,1)}for(let t=v-1;t>=0;t--)if(0!==d[t]){for(let e=t+1;e<l;e++){let n=0;for(let o=t;o<r;o++)n+=g.get(o,t)*g.get(o,e);n=-n/g.get(t,t);for(let o=t;o<r;o++)g.set(o,e,g.get(o,e)+n*g.get(o,t))}for(let e=t;e<r;e++)g.set(e,t,-g.get(e,t));g.set(t,t,1+g.get(t,t));for(let e=0;e<t-1;e++)g.set(e,t,0)}else{for(let e=0;e<r;e++)g.set(e,t,0);g.set(t,t,1)}}if(u)for(let t=n-1;t>=0;t--){if(t<x&&0!==y[t])for(let e=t+1;e<n;e++){let r=0;for(let o=t+1;o<n;o++)r+=p.get(o,t)*p.get(o,e);r=-r/p.get(t+1,t);for(let o=t+1;o<n;o++)p.set(o,e,p.get(o,e)+r*p.get(o,t))}for(let e=0;e<n;e++)p.set(e,t,0);p.set(t,t,1)}let E=b-1,N=0,S=Number.EPSILON;for(;b>0;){let t,e;for(t=b-2;t>=-1&&-1!==t;t--){const e=Number.MIN_VALUE+S*Math.abs(d[t]+Math.abs(d[t+1]));if(Math.abs(y[t])<=e||Number.isNaN(y[t])){y[t]=0;break}}if(t===b-2)e=4;else{let r;for(r=b-1;r>=t&&r!==t;r--){let e=(r!==b?Math.abs(y[r]):0)+(r!==t+1?Math.abs(y[r-1]):0);if(Math.abs(d[r])<=S*e){d[r]=0;break}}r===t?e=3:r===b-1?e=1:(e=2,t=r)}switch(t++,e){case 1:{let e=y[b-2];y[b-2]=0;for(let r=b-2;r>=t;r--){let o=De(d[r],e),i=d[r]/o,s=e/o;if(d[r]=o,r!==t&&(e=-s*y[r-1],y[r-1]=i*y[r-1]),u)for(let t=0;t<n;t++)o=i*p.get(t,r)+s*p.get(t,b-1),p.set(t,b-1,-s*p.get(t,r)+i*p.get(t,b-1)),p.set(t,r,o)}break}case 2:{let e=y[t-1];y[t-1]=0;for(let n=t;n<b;n++){let o=De(d[n],e),i=d[n]/o,s=e/o;if(d[n]=o,e=-s*y[n],y[n]=i*y[n],h)for(let e=0;e<r;e++)o=i*g.get(e,n)+s*g.get(e,t-1),g.set(e,t-1,-s*g.get(e,n)+i*g.get(e,t-1)),g.set(e,n,o)}break}case 3:{const e=Math.max(Math.abs(d[b-1]),Math.abs(d[b-2]),Math.abs(y[b-2]),Math.abs(d[t]),Math.abs(y[t])),o=d[b-1]/e,i=d[b-2]/e,s=y[b-2]/e,a=d[t]/e,c=y[t]/e,l=((i+o)*(i-o)+s*s)/2,f=o*s*(o*s);let m=0;0===l&&0===f||(m=l<0?0-Math.sqrt(l*l+f):Math.sqrt(l*l+f),m=f/(l+m));let w=(a+o)*(a-o)+m,v=a*c;for(let e=t;e<b-1;e++){let o=De(w,v);0===o&&(o=Number.MIN_VALUE);let i=w/o,s=v/o;if(e!==t&&(y[e-1]=o),w=i*d[e]+s*y[e],y[e]=i*y[e]-s*d[e],v=s*d[e+1],d[e+1]=i*d[e+1],u)for(let t=0;t<n;t++)o=i*p.get(t,e)+s*p.get(t,e+1),p.set(t,e+1,-s*p.get(t,e)+i*p.get(t,e+1)),p.set(t,e,o);if(o=De(w,v),0===o&&(o=Number.MIN_VALUE),i=w/o,s=v/o,d[e]=o,w=i*y[e]+s*d[e+1],d[e+1]=-s*y[e]+i*d[e+1],v=s*y[e+1],y[e+1]=i*y[e+1],h&&e<r-1)for(let t=0;t<r;t++)o=i*g.get(t,e)+s*g.get(t,e+1),g.set(t,e+1,-s*g.get(t,e)+i*g.get(t,e+1)),g.set(t,e,o)}y[b-2]=w,N+=1;break}case 4:if(d[t]<=0&&(d[t]=d[t]<0?-d[t]:0,u))for(let e=0;e<=E;e++)p.set(e,t,-p.get(e,t));for(;t<E&&!(d[t]>=d[t+1]);){let e=d[t];if(d[t]=d[t+1],d[t+1]=e,u&&t<n-1)for(let r=0;r<n;r++)e=p.get(r,t+1),p.set(r,t+1,p.get(r,t)),p.set(r,t,e);if(h&&t<r-1)for(let n=0;n<r;n++)e=g.get(n,t+1),g.set(n,t+1,g.get(n,t)),g.set(n,t,e);t++}N=0,b--}}if(c){let t=p;p=g,g=t}this.m=r,this.n=n,this.s=d,this.U=g,this.V=p}solve(t){let e=t,r=this.threshold,n=this.s.length,o=Ae.zeros(n,n);for(let t=0;t<n;t++)Math.abs(this.s[t])<=r?o.set(t,t,0):o.set(t,t,1/this.s[t]);let i=this.U,s=this.rightSingularVectors,a=s.mmul(o),h=s.rows,u=i.rows,c=Ae.zeros(h,u);for(let t=0;t<h;t++)for(let e=0;e<u;e++){let r=0;for(let o=0;o<n;o++)r+=a.get(t,o)*i.get(e,o);c.set(t,e,r)}return c.mmul(e)}solveForDiagonal(t){return this.solve(Ae.diag(t))}inverse(){let t=this.V,e=this.threshold,r=t.rows,n=t.columns,o=new Ae(r,this.s.length);for(let i=0;i<r;i++)for(let r=0;r<n;r++)Math.abs(this.s[r])>e&&o.set(i,r,t.get(i,r)/this.s[r]);let i=this.U,s=i.rows,a=i.columns,h=new Ae(r,s);for(let t=0;t<r;t++)for(let e=0;e<s;e++){let r=0;for(let n=0;n<a;n++)r+=o.get(t,n)*i.get(e,n);h.set(t,e,r)}return h}get condition(){return this.s[0]/this.s[Math.min(this.m,this.n)-1]}get norm2(){return this.s[0]}get rank(){let t=Math.max(this.m,this.n)*this.s[0]*Number.EPSILON,e=0,r=this.s;for(let n=0,o=r.length;n<o;n++)r[n]>t&&e++;return e}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 Ae.diag(this.s)}}var _e,Re={center:[0,0],linkDistance:50},ze=function(){function t(t){void 0===t&&(t={}),this.options=t,this.id="mds",this.options=r(r({},Re),t)}return t.prototype.execute=function(t,e){return o(this,void 0,void 0,(function(){return i(this,(function(r){return[2,this.genericMDSLayout(!1,t,e)]}))}))},t.prototype.assign=function(t,e){return o(this,void 0,void 0,(function(){return i(this,(function(r){return this.genericMDSLayout(!0,t,e),[2]}))}))},t.prototype.genericMDSLayout=function(t,e,n){return o(this,void 0,void 0,(function(){var o,s,a,h,u,c,l,f,d,g,m;return i(this,(function(i){return o=r(r({},this.options),n),s=o.center,a=void 0===s?[0,0]:s,h=o.linkDistance,u=void 0===h?50:h,c=e.getAllNodes(),l=e.getAllEdges(),(null==c?void 0:c.length)&&1!==c.length?(f=y({nodes:c,edges:l},!1),d=p(f),Te(d),w=u,v=[],d.forEach((function(t){var e=[];t.forEach((function(t){e.push(t*w)})),v.push(e)})),g=Ce(v),m=[],g.forEach((function(t,e){var r=b(c[e]);r.data.x=t[0]+a[0],r.data.y=t[1]+a[1],m.push(r)})),t&&m.forEach((function(t){return e.mergeNodeData(t.id,{x:t.data.x,y:t.data.y})})),[2,{nodes:m,edges:l}]):[2,k(e,t,a)];var w,v}))}))},t}(),Te=function(t){var e=-999999;t.forEach((function(t){t.forEach((function(t){t!==1/0&&e<t&&(e=t)}))})),t.forEach((function(r,n){r.forEach((function(r,o){r===1/0&&(t[n][o]=e)}))}))},Ce=function(t){var e=Ae.mul(Ae.pow(t,2),-.5),r=e.mean("row"),n=e.mean("column"),o=e.mean();e.add(o).subRowVector(r).subColumnVector(n);var i=new Ie(e),s=Ae.sqrt(i.diagonalMatrix).diagonal();return i.leftSingularVectors.toJSON().map((function(t){return Ae.mul([t],[s]).toJSON()[0].splice(0,2)}))},Oe={iterations:10,height:10,width:10,speed:100,gravity:10,k:5},Pe=function(t,e,r,n,o,i){e.forEach((function(s,a){r[a]={x:0,y:0},e.forEach((function(e,h){if(a!==h&&o[a]===o[h]){var u=s.x-e.x,c=s.y-e.y,l=Math.sqrt(u*u+c*c);if(0===l){l=1;var f=a>h?1:-1;u=.01*f,c=.01*f}if(l<i(t[a])/2+i(t[h])/2){var d=n*n/l;r[a].x+=u/l*d,r[a].y+=c/l*d}}}))}))},qe=function(t,e,r,n,o,i,s,a){var h=i||s/10;return n&&e.forEach((function(e,r){var n=t[r].x-t[o].x,i=t[r].y-t[o].y,s=Math.sqrt(n*n+i*i),a=i/s,h=-n/s,u=Math.sqrt(e.x*e.x+e.y*e.y),c=Math.acos((a*e.x+h*e.y)/u);c>Math.PI/2&&(c-=Math.PI/2,a*=-1,h*=-1);var l=Math.cos(c)*u;e.x=a*l,e.y=h*l})),t.forEach((function(i,s){if(s!==o){var u=Math.sqrt(e[s].x*e[s].x+e[s].y*e[s].y);if(u>0&&s!==o){var c=Math.min(h*(r/800),u);if(i.x+=e[s].x/u*c,i.y+=e[s].y/u*c,n){var l=i.x-t[o].x,f=i.y-t[o].y,d=Math.sqrt(l*l+f*f);l=l/d*a[s],f=f/d*a[s],i.x=t[o].x+l,i.y=t[o].y+f}}}})),t},Fe={maxIteration:1e3,focusNode:null,unitRadius:null,linkDistance:50,preventOverlap:!1,strictRadial:!0,maxPreventOverlapIteration:200,sortStrength:10},Le=function(){function t(t){void 0===t&&(t={}),this.options=t,this.id="radial",this.options=r(r({},Fe),t)}return t.prototype.execute=function(t,e){return o(this,void 0,void 0,(function(){return i(this,(function(r){return[2,this.genericRadialLayout(!1,t,e)]}))}))},t.prototype.assign=function(t,e){return o(this,void 0,void 0,(function(){return i(this,(function(r){return this.genericRadialLayout(!0,t,e),[2]}))}))},t.prototype.genericRadialLayout=function(t,e,n){return o(this,void 0,void 0,(function(){var o,h,u,c,l,f,d,g,m,w,v,x,M,E,N,S,A,D,I,_,R,T,C,O,P,q,F,L,j,V,W,$,G,U,B,H,K,J,Y,X,Q,Z,tt;return i(this,(function(i){if(o=r(r({},this.options),n),h=o.width,u=o.height,c=o.center,l=o.focusNode,f=o.unitRadius,d=o.nodeSize,g=o.nodeSpacing,m=o.strictRadial,w=o.preventOverlap,v=o.maxPreventOverlapIteration,x=o.sortBy,M=o.linkDistance,E=void 0===M?50:M,N=o.sortStrength,S=void 0===N?10:N,A=o.maxIteration,D=void 0===A?1e3:A,I=e.getAllNodes(),_=e.getAllEdges(),R=h||"undefined"==typeof window?h:window.innerWidth,T=u||"undefined"==typeof window?u:window.innerHeight,C=c||[R/2,T/2],!(null==I?void 0:I.length)||1===I.length)return[2,k(e,t,C)];if(O=I[0],z(l)){for(P=0;P<I.length;P++)if(I[P].id===l){O=I[P];break}}else O=l||I[0];return q=We(I,O.id),F=y({nodes:I,edges:_},!1),L=p(F),j=Ge(L,q),$e(L,q,j+1),V=L[q],W=R-C[0]>C[0]?C[0]:R-C[0],$=T-C[1]>C[1]?C[1]:T-C[1],0===W&&(W=R/2),0===$&&($=T/2),G=Math.min(W,$),U=Math.max.apply(Math,a([],s(V),!1)),B=[],H=f||G/U,V.forEach((function(t,e){B[e]=t*H})),K=je(I,L,E,B,H,x,S),J=Ve(K),Y=function(t,e,r){try{var n=Ae.mul(Ae.pow(e,2),-.5),o=n.mean("row"),i=n.mean("column"),s=n.mean();n.add(s).subRowVector(o).subColumnVector(i);var a=new Ie(n),h=Ae.sqrt(a.diagonalMatrix).diagonal();return a.leftSingularVectors.toJSON().map((function(e){return Ae.mul([e],[h]).toJSON()[0].splice(0,t)}))}catch(t){for(var u=[],c=0;c<e.length;c++){var l=Math.random()*r,f=Math.random()*r;u.push([l,f])}return u}}(E,K,E),X=Y.map((function(t){var e=s(t,2),r=e[0],n=e[1];return{x:(isNaN(r)?Math.random()*E:r)-Y[q][0],y:(isNaN(n)?Math.random()*E:n)-Y[q][1]}})),this.run(D,X,J,K,B,q),w&&(Q=Ue(d,g),Z={nodes:I,nodeSizeFunc:Q,positions:X,radii:B,height:T,width:R,strictRadial:Boolean(m),focusIdx:q,iterations:v||200,k:X.length/4.5},X=function(t,e){for(var n=r(r({},Oe),e),o=n.positions,i=n.iterations,s=n.width,a=n.k,h=n.speed,u=void 0===h?100:h,c=n.strictRadial,l=n.focusIdx,f=n.radii,d=void 0===f?[]:f,g=n.nodeSizeFunc,p=t.getAllNodes(),y=[],m=s/10,w=0;w<i;w++)o.forEach((function(t,e){y[e]={x:0,y:0}})),Pe(p,o,y,a,d,g),qe(o,y,u,c,l,m,s,d);return o}(e,Z)),tt=[],X.forEach((function(t,e){var r=b(I[e]);r.data.x=t.x+C[0],r.data.y=t.y+C[1],tt.push(r)})),t&&tt.forEach((function(t){return e.mergeNodeData(t.id,{x:t.data.x,y:t.data.y})})),[2,{nodes:tt,edges:_}]}))}))},t.prototype.run=function(t,e,r,n,o,i){for(var s=0;s<=t;s++){var a=s/t;this.oneIteration(a,e,o,n,r,i)}},t.prototype.oneIteration=function(t,e,r,n,o,i){var s=1-t;e.forEach((function(a,h){var u=m(a,{x:0,y:0}),c=0===u?0:1/u;if(h!==i){var l=0,f=0,d=0;e.forEach((function(t,e){if(h!==e){var r=m(a,t),i=0===r?0:1/r,s=n[e][h];d+=o[h][e],l+=o[h][e]*(t.x+s*(a.x-t.x)*i),f+=o[h][e]*(t.y+s*(a.y-t.y)*i)}}));var g=0===r[h]?0:1/r[h];d*=s,d+=t*g*g,l*=s,l+=t*g*a.x*c,a.x=l/d,f*=s,f+=t*g*a.y*c,a.y=f/d}}))},t}(),je=function(t,e,r,n,o,i,s){if(!t)return[];var a=[];if(e){var h={};e.forEach((function(e,u){var c=[];e.forEach((function(e,a){var l,f;if(u===a)c.push(0);else if(n[u]===n[a])if("data"===i)c.push(e*(Math.abs(u-a)*s)/(n[u]/o));else if(i){var d=void 0,g=void 0;if(h[t[u].id])d=h[t[u].id];else{var p=("id"===i?t[u].id:null===(l=t[u].data)||void 0===l?void 0:l[i])||0;d=z(p)?p.charCodeAt(0):p,h[t[u].id]=d}h[t[a].id]?g=h[t[a].id]:(p=("id"===i?t[a].id:null===(f=t[a].data)||void 0===f?void 0:f[i])||0,g=z(p)?p.charCodeAt(0):p,h[t[a].id]=g),c.push(e*(Math.abs(d-g)*s)/(n[u]/o))}else c.push(e*r/(n[u]/o));else{var y=(r+o)/2;c.push(e*y)}})),a.push(c)}))}return a},Ve=function(t){for(var e=t.length,r=t[0].length,n=[],o=0;o<e;o++){for(var i=[],s=0;s<r;s++)0!==t[o][s]?i.push(1/(t[o][s]*t[o][s])):i.push(0);n.push(i)}return n},We=function(t,e){var r=-1;return t.forEach((function(t,n){t.id===e&&(r=n)})),Math.max(r,0)},$e=function(t,e,r){for(var n=t.length,o=0;o<n;o++)if(t[e][o]===1/0){t[e][o]=r,t[o][e]=r;for(var i=0;i<n;i++)t[o][i]!==1/0&&t[e][i]===1/0&&(t[e][i]=r+t[o][i],t[i][e]=r+t[o][i])}for(o=0;o<n;o++)if(o!==e)for(i=0;i<n;i++)if(t[o][i]===1/0){var s=Math.abs(t[e][o]-t[e][i]);s=0===s?1:s,t[o][i]=s}},Ge=function(t,e){for(var r=0,n=0;n<t[e].length;n++)t[e][n]!==1/0&&(r=t[e][n]>r?t[e][n]:r);return r},Ue=function(t,e){var r;return r=x(e)?function(){return e}:E(e)?e:function(){return 0},t?g(t)?function(e){return(t[0]>t[1]?t[0]:t[1])+r(e)}:function(e){return t+r(e)}:function(t){var e,n;if(null===(e=t.data)||void 0===e?void 0:e.bboxSize)return Math.max(t.data.bboxSize[0],t.data.bboxSize[1])+r(t);if(null===(n=t.data)||void 0===n?void 0:n.size){if(g(t.data.size))return Math.max(t.data.size[0],t.data.size[1])+r(t);var o=t.data.size;return N(o)?(o.width>o.height?o.width:o.height)+r(t):o+r(t)}return 10+r(t)}},Be={center:[0,0],width:300,height:300},He={circular:I,concentric:C,mds:ze,random:function(){function t(t){void 0===t&&(t={}),this.options=t,this.id="random",this.options=r(r({},Be),t)}return t.prototype.execute=function(t,e){return o(this,void 0,void 0,(function(){return i(this,(function(r){return[2,this.genericRandomLayout(!1,t,e)]}))}))},t.prototype.assign=function(t,e){return o(this,void 0,void 0,(function(){return i(this,(function(r){return this.genericRandomLayout(!0,t,e),[2]}))}))},t.prototype.genericRandomLayout=function(t,e,n){return o(this,void 0,void 0,(function(){var o,s,a,h,u,c,l,f,d;return i(this,(function(i){return o=r(r({},this.options),n),s=o.center,a=o.width,h=o.height,u=e.getAllNodes(),c=a||"undefined"==typeof window?a:window.innerWidth,l=h||"undefined"==typeof window?h:window.innerHeight,f=s||[c/2,l/2],d=[],u&&u.forEach((function(t){d.push({id:t.id,data:{x:.9*(Math.random()-.5)*c+f[0],y:.9*(Math.random()-.5)*l+f[1]}})})),t&&d.forEach((function(t){return e.mergeNodeData(t.id,{x:t.data.x,y:t.data.y})})),[2,{nodes:d,edges:e.getAllEdges()}]}))}))},t}(),grid:ee,radial:Le,force:jt,d3force:Ct,fruchterman:Zt,forceAtlas2:Xt};function Ke(){(null==_e?void 0:_e.stop)&&_e.stop()}function Je(t,e){return o(this,void 0,void 0,(function(){var r,n,o,s,a,h,u,c,l;return i(this,(function(i){switch(i.label){case 0:if(r=t.layout,n=r.id,o=r.options,s=r.iterations,a=t.nodes,h=t.edges,u=new f({nodes:a,edges:h}),!(c=He[n]))throw new Error("Unknown layout id: ".concat(n));return[4,(_e=new c(o)).execute(u)];case 1:return l=i.sent(),(d=_e).tick&&d.stop&&(_e.stop(),l=_e.tick(s)),[2,[l,e]]}var d}))}))}addEventListener("message",(function(t){var r,n=t.data,o=n.type,i=n.method,s=n.id,a=n.params;"RPC"===o&&i&&((r=e[i])?Promise.resolve().then((function(){return r.apply(e,a)})):Promise.reject("No such method")).then((function(t){postMessage({type:"RPC",id:s,result:t})})).catch((function(t){var e={message:t};t.stack&&(e.message=t.message,e.stack=t.stack,e.name=t.name),postMessage({type:"RPC",id:s,error:e})}))})),postMessage({type:"RPC",method:"ready"});\n//# sourceMappingURL=6b692814699bee26e220.worker.js.map'])),{name:"[fullhash].worker.js"});return URL.revokeObjectURL(URL.createObjectURL(new Blob(['var t={d:(e,r)=>{for(var n in r)t.o(r,n)&&!t.o(e,n)&&Object.defineProperty(e,n,{enumerable:!0,get:r[n]})},o:(t,e)=>Object.prototype.hasOwnProperty.call(t,e)},e={};t.d(e,{calculateLayout:()=>Je,stopLayout:()=>Ke});var r=function(){return r=Object.assign||function(t){for(var e,r=1,n=arguments.length;r<n;r++)for(var o in e=arguments[r])Object.prototype.hasOwnProperty.call(e,o)&&(t[o]=e[o]);return t},r.apply(this,arguments)};function n(t,e){var r={};for(var n in t)Object.prototype.hasOwnProperty.call(t,n)&&e.indexOf(n)<0&&(r[n]=t[n]);if(null!=t&&"function"==typeof Object.getOwnPropertySymbols){var o=0;for(n=Object.getOwnPropertySymbols(t);o<n.length;o++)e.indexOf(n[o])<0&&Object.prototype.propertyIsEnumerable.call(t,n[o])&&(r[n[o]]=t[n[o]])}return r}function o(t,e,r,n){return new(r||(r=Promise))((function(o,i){function s(t){try{h(n.next(t))}catch(t){i(t)}}function a(t){try{h(n.throw(t))}catch(t){i(t)}}function h(t){var e;t.done?o(t.value):(e=t.value,e instanceof r?e:new r((function(t){t(e)}))).then(s,a)}h((n=n.apply(t,e||[])).next())}))}function i(t,e){var r,n,o,i,s={label:0,sent:function(){if(1&o[0])throw o[1];return o[1]},trys:[],ops:[]};return i={next:a(0),throw:a(1),return:a(2)},"function"==typeof Symbol&&(i[Symbol.iterator]=function(){return this}),i;function a(a){return function(h){return function(a){if(r)throw new TypeError("Generator is already executing.");for(;i&&(i=0,a[0]&&(s=0)),s;)try{if(r=1,n&&(o=2&a[0]?n.return:a[0]?n.throw||((o=n.return)&&o.call(n),0):n.next)&&!(o=o.call(n,a[1])).done)return o;switch(n=0,o&&(a=[2&a[0],o.value]),a[0]){case 0:case 1:o=a;break;case 4:return s.label++,{value:a[1],done:!1};case 5:s.label++,n=a[1],a=[0];continue;case 7:a=s.ops.pop(),s.trys.pop();continue;default:if(!((o=(o=s.trys).length>0&&o[o.length-1])||6!==a[0]&&2!==a[0])){s=0;continue}if(3===a[0]&&(!o||a[1]>o[0]&&a[1]<o[3])){s.label=a[1];break}if(6===a[0]&&s.label<o[1]){s.label=o[1],o=a;break}if(o&&s.label<o[2]){s.label=o[2],s.ops.push(a);break}o[2]&&s.ops.pop(),s.trys.pop();continue}a=e.call(t,s)}catch(t){a=[6,t],n=0}finally{r=o=0}if(5&a[0])throw a[1];return{value:a[0]?a[1]:void 0,done:!0}}([a,h])}}}function s(t,e){var r="function"==typeof Symbol&&t[Symbol.iterator];if(!r)return t;var n,o,i=r.call(t),s=[];try{for(;(void 0===e||e-- >0)&&!(n=i.next()).done;)s.push(n.value)}catch(t){o={error:t}}finally{try{n&&!n.done&&(r=i.return)&&r.call(i)}finally{if(o)throw o.error}}return s}function a(t,e,r){if(r||2===arguments.length)for(var n,o=0,i=e.length;o<i;o++)!n&&o in e||(n||(n=Array.prototype.slice.call(e,0,o)),n[o]=e[o]);return t.concat(n||Array.prototype.slice.call(e))}Object.create,Object.create;var h="*";const u=function(){function t(){this._events={}}return t.prototype.on=function(t,e,r){return this._events[t]||(this._events[t]=[]),this._events[t].push({callback:e,once:!!r}),this},t.prototype.once=function(t,e){return this.on(t,e,!0)},t.prototype.emit=function(t){for(var e=this,r=[],n=1;n<arguments.length;n++)r[n-1]=arguments[n];var o=this._events[t]||[],i=this._events[h]||[],s=function(n){for(var o=n.length,i=0;i<o;i++)if(n[i]){var s=n[i],a=s.callback;s.once&&(n.splice(i,1),0===n.length&&delete e._events[t],o--,i--),a.apply(e,r)}};s(o),s(i)},t.prototype.off=function(t,e){if(t)if(e){for(var r=this._events[t]||[],n=r.length,o=0;o<n;o++)r[o].callback===e&&(r.splice(o,1),n--,o--);0===r.length&&delete this._events[t]}else delete this._events[t];else this._events={};return this},t.prototype.getEvents=function(){return this._events},t}();function c(t,e,r,n){for(;t.length;){const o=t.shift();if(r(o))return!0;e.add(o.id),n(o.id).forEach((r=>{e.has(r.id)||(e.add(r.id),t.push(r))}))}return!1}function l(t,e,r,n){if(r(t))return!0;e.add(t.id);for(const o of n(t.id))if(!e.has(o.id)&&l(o,e,r,n))return!0;return!1}class f extends u{nodeMap=new Map;edgeMap=new Map;inEdgesMap=new Map;outEdgesMap=new Map;bothEdgesMap=new Map;treeIndices=new Map;changes=[];batchCount=0;onChanged=()=>{};constructor(t){super(),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))}batch=t=>{this.batchCount+=1,t(),this.batchCount-=1,this.batchCount||this.commit()};commit(){const t=this.changes;this.changes=[];const e={graph:this,changes:t};this.emit("changed",e),this.onChanged(e)}reduceChanges(t){let e=[];return t.forEach((t=>{switch(t.type){case"NodeRemoved":{let r=!1;e=e.filter((e=>{if("NodeAdded"===e.type){const n=e.value.id===t.value.id;return n&&(r=!0),!n}return"NodeDataUpdated"===e.type?e.id!==t.value.id:"TreeStructureChanged"!==e.type||e.nodeId!==t.value.id})),r||e.push(t);break}case"EdgeRemoved":{let r=!1;e=e.filter((e=>{if("EdgeAdded"===e.type){const n=e.value.id===t.value.id;return n&&(r=!0),!n}return"EdgeDataUpdated"!==e.type&&"EdgeUpdated"!==e.type||e.id!==t.value.id})),r||e.push(t);break}case"NodeDataUpdated":case"EdgeDataUpdated":case"EdgeUpdated":{const r=e.find((e=>e.type===t.type&&e.id===t.id&&e.propertyName===t.propertyName));r?r.newValue=t.newValue:e.push(t);break}case"TreeStructureDetached":e=e.filter((e=>"TreeStructureAttached"===e.type?e.treeKey!==t.treeKey:"TreeStructureChanged"!==e.type||e.treeKey!==t.treeKey)),e.push(t);break;case"TreeStructureChanged":{const r=e.find((e=>"TreeStructureChanged"===e.type&&e.treeKey===t.treeKey&&e.nodeId===t.nodeId));r?r.newParentId=t.newParentId:e.push(t);break}default:e.push(t)}})),e}checkNodeExistence(t){this.getNode(t)}hasNode(t){return this.nodeMap.has(t)}areNeighbors(t,e){return this.getNeighbors(e).some((e=>e.id===t))}getNode(t){const e=this.nodeMap.get(t);if(!e)throw new Error("Node not found for id: "+t);return e}getRelatedEdges(t,e){if(this.checkNodeExistence(t),"in"===e){const e=this.inEdgesMap.get(t);return Array.from(e)}if("out"===e){const e=this.outEdgesMap.get(t);return Array.from(e)}{const e=this.bothEdgesMap.get(t);return Array.from(e)}}getDegree(t,e){return this.getRelatedEdges(t,e).length}getSuccessors(t){const e=this.getRelatedEdges(t,"out").map((t=>this.getNode(t.target)));return Array.from(new Set(e))}getPredecessors(t){const e=this.getRelatedEdges(t,"in").map((t=>this.getNode(t.source)));return Array.from(new Set(e))}getNeighbors(t){const e=this.getPredecessors(t),r=this.getSuccessors(t);return Array.from(new Set([...e,...r]))}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((e=>{e.childrenMap.set(t.id,new Set)})),this.changes.push({type:"NodeAdded",value:t})}addNodes(t){this.batch((()=>{for(const e of t)this.doAddNode(e)}))}addNode(t){this.addNodes([t])}doRemoveNode(t){const e=this.getNode(t);this.bothEdgesMap.get(t)?.forEach((t=>this.doRemoveEdge(t.id))),this.nodeMap.delete(t),this.treeIndices.forEach((e=>{e.childrenMap.get(t)?.forEach((t=>{e.parentMap.delete(t.id)})),e.parentMap.delete(t),e.childrenMap.delete(t)})),this.changes.push({type:"NodeRemoved",value:e})}removeNodes(t){this.batch((()=>{t.forEach((t=>this.doRemoveNode(t)))}))}removeNode(t){this.removeNodes([t])}updateNodeDataProperty(t,e,r){const n=this.getNode(t);this.batch((()=>{const o=n.data[e],i=r;n.data[e]=i,this.changes.push({type:"NodeDataUpdated",id:t,propertyName:e,oldValue:o,newValue:i})}))}mergeNodeData(t,e){this.batch((()=>{Object.entries(e).forEach((([e,r])=>{this.updateNodeDataProperty(t,e,r)}))}))}updateNodeData(...t){const e=t[0],r=this.getNode(e);if("string"==typeof t[1])return void this.updateNodeDataProperty(e,t[1],t[2]);let n;if("function"==typeof t[1]){const e=t[1];n=e(r.data)}else"object"==typeof t[1]&&(n=t[1]);this.batch((()=>{const t=r.data,o=n;r.data=n,this.changes.push({type:"NodeDataUpdated",id:e,oldValue:t,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 e=this.getEdge(t);return{edge:e,source:this.getNode(e.source),target:this.getNode(e.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 e=this.inEdgesMap.get(t.target),r=this.outEdgesMap.get(t.source),n=this.bothEdgesMap.get(t.source),o=this.bothEdgesMap.get(t.target);e.add(t),r.add(t),n.add(t),o.add(t),this.changes.push({type:"EdgeAdded",value:t})}addEdges(t){this.batch((()=>{for(const e of t)this.doAddEdge(e)}))}addEdge(t){this.addEdges([t])}doRemoveEdge(t){const e=this.getEdge(t),r=this.outEdgesMap.get(e.source),n=this.inEdgesMap.get(e.target),o=this.bothEdgesMap.get(e.source),i=this.bothEdgesMap.get(e.target);r.delete(e),n.delete(e),o.delete(e),i.delete(e),this.edgeMap.delete(t),this.changes.push({type:"EdgeRemoved",value:e})}removeEdges(t){this.batch((()=>{t.forEach((t=>this.doRemoveEdge(t)))}))}removeEdge(t){this.removeEdges([t])}updateEdgeSource(t,e){const r=this.getEdge(t);this.checkNodeExistence(e);const n=r.source,o=e;this.outEdgesMap.get(n).delete(r),this.bothEdgesMap.get(n).delete(r),this.outEdgesMap.get(o).add(r),this.bothEdgesMap.get(o).add(r),r.source=e,this.batch((()=>{this.changes.push({type:"EdgeUpdated",id:t,propertyName:"source",oldValue:n,newValue:o})}))}updateEdgeTarget(t,e){const r=this.getEdge(t);this.checkNodeExistence(e);const n=r.target,o=e;this.inEdgesMap.get(n).delete(r),this.bothEdgesMap.get(n).delete(r),this.inEdgesMap.get(o).add(r),this.bothEdgesMap.get(o).add(r),r.target=e,this.batch((()=>{this.changes.push({type:"EdgeUpdated",id:t,propertyName:"target",oldValue:n,newValue:o})}))}updateEdgeDataProperty(t,e,r){const n=this.getEdge(t);this.batch((()=>{const o=n.data[e],i=r;n.data[e]=i,this.changes.push({type:"EdgeDataUpdated",id:t,propertyName:e,oldValue:o,newValue:i})}))}updateEdgeData(...t){const e=t[0],r=this.getEdge(e);if("string"==typeof t[1])return void this.updateEdgeDataProperty(e,t[1],t[2]);let n;if("function"==typeof t[1]){const e=t[1];n=e(r.data)}else"object"==typeof t[1]&&(n=t[1]);this.batch((()=>{const t=r.data,o=n;r.data=n,this.changes.push({type:"EdgeDataUpdated",id:e,oldValue:t,newValue:o})}))}mergeEdgeData(t,e){this.batch((()=>{Object.entries(e).forEach((([e,r])=>{this.updateEdgeDataProperty(t,e,r)}))}))}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,e){this.batch((()=>{this.attachTreeStructure(e);const r=[],n=Array.isArray(t)?t:[t];for(;n.length;){const t=n.shift();r.push(t),t.children&&n.push(...t.children)}this.addNodes(r),r.forEach((t=>{t.children?.forEach((r=>{this.setParent(r.id,t.id,e)}))}))}))}getRoots(t){return this.checkTreeExistence(t),this.getAllNodes().filter((e=>!this.getParent(e.id,t)))}getChildren(t,e){this.checkNodeExistence(t),this.checkTreeExistence(e);const r=this.treeIndices.get(e).childrenMap.get(t);return Array.from(r||[])}getParent(t,e){return this.checkNodeExistence(t),this.checkTreeExistence(e),this.treeIndices.get(e).parentMap.get(t)||null}getAncestors(t,e){const r=[];let n,o=this.getNode(t);for(;n=this.getParent(o.id,e);)r.push(n),o=n;return r}setParent(t,e,r){this.checkTreeExistence(r);const n=this.treeIndices.get(r),o=this.getNode(t),i=n.parentMap.get(t),s=this.getNode(e);n.parentMap.set(t,s),i&&n.childrenMap.get(i.id)?.delete(o);let a=n.childrenMap.get(s.id);a||(a=new Set,n.childrenMap.set(s.id,a)),a.add(o),this.batch((()=>{this.changes.push({type:"TreeStructureChanged",treeKey:r,nodeId:t,oldParentId:i?.id,newParentId:s.id})}))}dfsTree(t,e,r){return l(this.getNode(t),new Set,e,(t=>this.getChildren(t,r)))}bfsTree(t,e,r){return c([this.getNode(t)],new Set,e,(t=>this.getChildren(t,r)))}getAllNodes(){return Array.from(this.nodeMap.values())}getAllEdges(){return Array.from(this.edgeMap.values())}bfs(t,e,r="out"){const n={in:this.getPredecessors.bind(this),out:this.getSuccessors.bind(this),both:this.getNeighbors.bind(this)}[r];return c([this.getNode(t)],new Set,e,n)}dfs(t,e,r="out"){const n={in:this.getPredecessors.bind(this),out:this.getSuccessors.bind(this),both:this.getNeighbors.bind(this)}[r];return l(this.getNode(t),new Set,e,n)}clone(){const t=this.getAllNodes().map((t=>({...t,data:{...t.data}}))),e=this.getAllEdges().map((t=>({...t,data:{...t.data}}))),r=new f({nodes:t,edges:e});return this.treeIndices.forEach((({parentMap:t,childrenMap:e},n)=>{const o=new Map;t.forEach(((t,e)=>{o.set(e,r.getNode(t.id))}));const i=new Map;e.forEach(((t,e)=>{i.set(e,new Set(Array.from(t).map((t=>r.getNode(t.id)))))})),r.treeIndices.set(n,{parentMap:o,childrenMap:i})})),r}toJSON(){return JSON.stringify({nodes:this.getAllNodes(),edges:this.getAllEdges()})}}var d=/-(\\w)/g,g=(function(t){return t.replace(d,(function(t,e){return e?e.toUpperCase():""}))},Object.create(null),Array.isArray),p=function(t){for(var e=[],r=t.length,n=0;n<r;n+=1){e[n]=[];for(var o=0;o<r;o+=1)n===o?e[n][o]=0:0!==t[n][o]&&t[n][o]?e[n][o]=t[n][o]:e[n][o]=1/0}for(var i=0;i<r;i+=1)for(n=0;n<r;n+=1)for(o=0;o<r;o+=1)e[n][o]>e[n][i]+e[i][o]&&(e[n][o]=e[n][i]+e[i][o]);return e},y=function(t,e){var r=t.nodes,n=t.edges,o=[],i={};if(!r)throw new Error("invalid nodes data!");return r&&r.forEach((function(t,e){i[t.id]=e,o.push([])})),null==n||n.forEach((function(t){var r=t.source,n=t.target,s=i[r],a=i[n];void 0!==s&&void 0!==a&&(o[s][a]=1,e||(o[a][s]=1))})),o},m=function(t,e){return Math.sqrt((t.x-e.x)*(t.x-e.x)+(t.y-e.y)*(t.y-e.y))},w={}.toString;const v=function(t,e){return w.call(t)==="[object "+e+"]"},x=function(t){return v(t,"Number")};var M=function(t){if(null===t)return t;if(t instanceof Date)return new Date(t.getTime());if(t instanceof Array){var e=[];return t.forEach((function(t){e.push(t)})),e.map((function(t){return M(t)}))}if("object"==typeof t){var r={};return Object.keys(t).forEach((function(e){r[e]=M(t[e])})),r}return t},b=function(t,e){var r=M(t);return r.data=r.data||{},e&&(x(r.data.x)||(r.data.x=Math.random()*e[0]),x(r.data.y)||(r.data.y=Math.random()*e[1])),r};const E=function(t){return"function"==typeof t},N=function(t){var e=typeof t;return null!==t&&"object"===e||"function"===e};function S(t,e){return E(e)?e:x(e)?function(){return e}:function(){return t}}function A(t,e,r){return void 0===r&&(r=!0),e||0===e?E(e)?e:x(e)?function(){return e}:g(e)?function(){if(r){var n=Math.max.apply(Math,a([],s(e),!1));return isNaN(n)?t:n}return e}:N(e)?function(){if(r){var n=Math.max(e.width,e.height);return isNaN(n)?t:n}return[e.width,e.height]}:function(){return t}:function(e){var r=(e.data||{}).size;return r?g(r)?r[0]>r[1]?r[0]:r[1]:N(r)?r.width>r.height?r.width:r.height:r:t}}var k=function(t,e,n){var o=t.getAllNodes(),i=t.getAllEdges();return(null==o?void 0:o.length)?1===o.length?(e&&t.mergeNodeData(o[0].id,{x:n[0],y:n[1]}),{nodes:[r(r({},o[0]),{data:r(r({},o[0].data),{x:n[0],y:n[1]})})],edges:i}):void 0:{nodes:[],edges:i}},D={radius:null,startRadius:null,endRadius:null,startAngle:0,endAngle:2*Math.PI,clockwise:!0,divisions:1,ordering:null,angleRatio:1},I=function(){function t(t){void 0===t&&(t={}),this.options=t,this.id="circular",this.options=r(r({},D),t)}return t.prototype.execute=function(t,e){return o(this,void 0,void 0,(function(){return i(this,(function(r){return[2,this.genericCircularLayout(!1,t,e)]}))}))},t.prototype.assign=function(t,e){return o(this,void 0,void 0,(function(){return i(this,(function(r){switch(r.label){case 0:return[4,this.genericCircularLayout(!0,t,e)];case 1:return r.sent(),[2]}}))}))},t.prototype.genericCircularLayout=function(t,e,n){return o(this,void 0,void 0,(function(){var o,a,h,u,c,l,f,d,g,p,y,m,w,v,x,M,E,N,D,I,z,T,C,O,P,q,F,L,j,V,W,$,G,U,B;return i(this,(function(i){if(o=r(r({},this.options),n),a=o.width,h=o.height,u=o.center,c=o.divisions,l=o.startAngle,f=void 0===l?0:l,d=o.endAngle,g=void 0===d?2*Math.PI:d,p=o.angleRatio,y=o.ordering,m=o.clockwise,w=o.nodeSpacing,v=o.nodeSize,x=e.getAllNodes(),M=e.getAllEdges(),E=s(R(a,h,u),3),N=E[0],D=E[1],I=E[2],!(z=null==x?void 0:x.length)||1===z)return[2,k(e,t,I)];for(T=(g-f)/z,C=o.radius,O=o.startRadius,P=o.endRadius,w?(q=S(10,w),F=A(10,v),L=-1/0,x.forEach((function(t){var e=F(t);L<e&&(L=e)})),j=0,x.forEach((function(t,e){j+=0===e?L||10:(q(t)||0)+(L||10)})),C=j/(2*Math.PI)):C||O||P?!O&&P?O=P:O&&!P&&(P=O):C=Math.min(D,N)/2,V=T*p,W=[],W="topology"===y?_(e,x):"topology-directed"===y?_(e,x,!0):"degree"===y?function(t,e){var r=[];return e.forEach((function(t,e){r.push(b(t))})),r.sort((function(e,r){return t.getDegree(e.id,"both")-t.getDegree(r.id,"both")})),r}(e,x):x.map((function(t){return b(t)})),$=Math.ceil(z/c),G=0;G<z;++G)(U=C)||null===O||null===P||(U=O+G*(P-O)/(z-1)),U||(U=10+100*G/(z-1)),B=f+G%$*V+2*Math.PI/c*Math.floor(G/$),m||(B=g-G%$*V-2*Math.PI/c*Math.floor(G/$)),W[G].data.x=I[0]+Math.cos(B)*U,W[G].data.y=I[1]+Math.sin(B)*U;return t&&W.forEach((function(t){e.mergeNodeData(t.id,{x:t.data.x,y:t.data.y})})),[2,{nodes:W,edges:M}]}))}))},t}(),_=function(t,e,r){void 0===r&&(r=!1);var n=[b(e[0])],o={},i=e.length;o[e[0].id]=!0;var s=0;return e.forEach((function(a,h){if(0!==h)if(h!==i-1&&t.getDegree(a.id,"both")===t.getDegree(e[h+1].id,"both")&&!t.areNeighbors(n[s].id,a.id)||o[a.id]){for(var u=r?t.getSuccessors(n[s].id):t.getNeighbors(n[s].id),c=!1,l=0;l<u.length;l++){var f=u[l];if(t.getDegree(f.id)===t.getDegree(a.id)&&!o[f.id]){n.push(b(f)),o[f.id]=!0,c=!0;break}}for(var d=0;!c&&(o[e[d].id]||(n.push(b(e[d])),o[e[d].id]=!0,c=!0),++d!==i););}else n.push(b(a)),o[a.id]=!0,s++})),n},R=function(t,e,r){var n=t,o=e,i=r;return n||"undefined"==typeof window||(n=window.innerWidth),o||"undefined"==typeof window||(o=window.innerHeight),i||(i=[n/2,o/2]),[n,o,i]};const z=function(t){return v(t,"String")};var T={nodeSize:30,nodeSpacing:10,preventOverlap:!1,sweep:void 0,equidistant:!1,startAngle:1.5*Math.PI,clockwise:!0,maxLevelDiff:void 0,sortBy:"degree"},C=function(){function t(t){void 0===t&&(t={}),this.options=t,this.id="concentric",this.options=r(r({},T),t)}return t.prototype.execute=function(t,e){return o(this,void 0,void 0,(function(){return i(this,(function(r){return[2,this.genericConcentricLayout(!1,t,e)]}))}))},t.prototype.assign=function(t,e){return o(this,void 0,void 0,(function(){return i(this,(function(r){return this.genericConcentricLayout(!0,t,e),[2]}))}))},t.prototype.genericConcentricLayout=function(t,e,n){return o(this,void 0,void 0,(function(){var o,s,a,h,u,c,l,f,d,p,y,m,w,v,M,S,A,D,I,_,R,T,C,O,P,q,F,L,j,V,W,$,G,U,B,H,K,J;return i(this,(function(i){if(o=r(r({},this.options),n),s=o.center,a=o.width,h=o.height,u=o.sortBy,c=o.maxLevelDiff,l=o.sweep,f=o.clockwise,d=o.equidistant,p=o.preventOverlap,y=o.startAngle,m=void 0===y?1.5*Math.PI:y,w=o.nodeSize,v=o.nodeSpacing,M=e.getAllNodes(),S=e.getAllEdges(),A=a||"undefined"==typeof window?a:window.innerWidth,D=h||"undefined"==typeof window?h:window.innerHeight,I=s||[A/2,D/2],!(null==M?void 0:M.length)||1===M.length)return[2,k(e,t,I)];if(_=[],T=0,R=g(w)?Math.max(w[0],w[1]):w,g(v)?T=Math.max(v[0],v[1]):x(v)&&(T=v),M.forEach((function(t){var e=b(t);_.push(e);var r=R,n=e.data;g(n.size)?r=Math.max(n.size[0],n.size[1]):x(n.size)?r=n.size:N(n.size)&&(r=Math.max(n.size.width,n.size.height)),R=Math.max(R,r),E(v)&&(T=Math.max(v(t),T))})),C={},_.forEach((function(t,e){C[t.id]=e})),z(O=u)&&void 0!==_[0].data[O]||(O="degree"),"degree"===O?_.sort((function(t,r){return e.getDegree(r.id,"both")-e.getDegree(t.id,"both")})):_.sort((function(t,e){return e.data[O]-t.data[O]})),P=_[0],q=(c||("degree"===O?e.getDegree(P.id,"both"):P.data[O]))/4,L=(F=[{nodes:[]}])[0],_.forEach((function(t){if(L.nodes.length>0){var r="degree"===O?Math.abs(e.getDegree(L.nodes[0].id,"both")-e.getDegree(t.id,"both")):Math.abs(L.nodes[0].data[O]-t.data[O]);q&&r>=q&&(L={nodes:[]},F.push(L))}L.nodes.push(t)})),j=R+T,p||(V=F.length>0&&F[0].nodes.length>1,W=Math.min(A,D)/2-j,$=W/(F.length+(V?1:0)),j=Math.min(j,$)),G=0,F.forEach((function(t){var e=void 0===l?2*Math.PI-2*Math.PI/t.nodes.length:l;if(t.dTheta=e/Math.max(1,t.nodes.length-1),t.nodes.length>1&&p){var r=Math.cos(t.dTheta)-Math.cos(0),n=Math.sin(t.dTheta)-Math.sin(0),o=Math.sqrt(j*j/(r*r+n*n));G=Math.max(o,G)}t.r=G,G+=j})),d){for(U=0,B=0,H=0;H<F.length;H++)K=F[H],J=(K.r||0)-B,U=Math.max(U,J);B=0,F.forEach((function(t,e){0===e&&(B=t.r||0),t.r=B,B+=U}))}return F.forEach((function(t){var e=t.dTheta||0,r=t.r||0;t.nodes.forEach((function(t,n){var o=m+(f?1:-1)*e*n;t.data.x=I[0]+r*Math.cos(o),t.data.y=I[1]+r*Math.sin(o)}))})),t&&_.forEach((function(t){return e.mergeNodeData(t.id,{x:t.data.x,y:t.data.y})})),[2,{nodes:_,edges:S}]}))}))},t}();function O(t,e,r,n){if(isNaN(e)||isNaN(r))return t;var o,i,s,a,h,u,c,l,f,d=t._root,g={data:n},p=t._x0,y=t._y0,m=t._x1,w=t._y1;if(!d)return t._root=g,t;for(;d.length;)if((u=e>=(i=(p+m)/2))?p=i:m=i,(c=r>=(s=(y+w)/2))?y=s:w=s,o=d,!(d=d[l=c<<1|u]))return o[l]=g,t;if(a=+t._x.call(null,d.data),h=+t._y.call(null,d.data),e===a&&r===h)return g.next=d,o?o[l]=g:t._root=g,t;do{o=o?o[l]=new Array(4):t._root=new Array(4),(u=e>=(i=(p+m)/2))?p=i:m=i,(c=r>=(s=(y+w)/2))?y=s:w=s}while((l=c<<1|u)==(f=(h>=s)<<1|a>=i));return o[f]=d,o[l]=g,t}function P(t,e,r,n,o){this.node=t,this.x0=e,this.y0=r,this.x1=n,this.y1=o}function q(t){return t[0]}function F(t){return t[1]}function L(t,e,r){var n=new j(null==e?q:e,null==r?F:r,NaN,NaN,NaN,NaN);return null==t?n:n.addAll(t)}function j(t,e,r,n,o,i){this._x=t,this._y=e,this._x0=r,this._y0=n,this._x1=o,this._y1=i,this._root=void 0}function V(t){for(var e={data:t.data},r=e;t=t.next;)r=r.next={data:t.data};return e}var W=L.prototype=j.prototype;function $(t){return function(){return t}}function G(t){return 1e-6*(t()-.5)}W.copy=function(){var t,e,r=new j(this._x,this._y,this._x0,this._y0,this._x1,this._y1),n=this._root;if(!n)return r;if(!n.length)return r._root=V(n),r;for(t=[{source:n,target:r._root=new Array(4)}];n=t.pop();)for(var o=0;o<4;++o)(e=n.source[o])&&(e.length?t.push({source:e,target:n.target[o]=new Array(4)}):n.target[o]=V(e));return r},W.add=function(t){const e=+this._x.call(null,t),r=+this._y.call(null,t);return O(this.cover(e,r),e,r,t)},W.addAll=function(t){var e,r,n,o,i=t.length,s=new Array(i),a=new Array(i),h=1/0,u=1/0,c=-1/0,l=-1/0;for(r=0;r<i;++r)isNaN(n=+this._x.call(null,e=t[r]))||isNaN(o=+this._y.call(null,e))||(s[r]=n,a[r]=o,n<h&&(h=n),n>c&&(c=n),o<u&&(u=o),o>l&&(l=o));if(h>c||u>l)return this;for(this.cover(h,u).cover(c,l),r=0;r<i;++r)O(this,s[r],a[r],t[r]);return this},W.cover=function(t,e){if(isNaN(t=+t)||isNaN(e=+e))return this;var r=this._x0,n=this._y0,o=this._x1,i=this._y1;if(isNaN(r))o=(r=Math.floor(t))+1,i=(n=Math.floor(e))+1;else{for(var s,a,h=o-r||1,u=this._root;r>t||t>=o||n>e||e>=i;)switch(a=(e<n)<<1|t<r,(s=new Array(4))[a]=u,u=s,h*=2,a){case 0:o=r+h,i=n+h;break;case 1:r=o-h,i=n+h;break;case 2:o=r+h,n=i-h;break;case 3:r=o-h,n=i-h}this._root&&this._root.length&&(this._root=u)}return this._x0=r,this._y0=n,this._x1=o,this._y1=i,this},W.data=function(){var t=[];return this.visit((function(e){if(!e.length)do{t.push(e.data)}while(e=e.next)})),t},W.extent=function(t){return arguments.length?this.cover(+t[0][0],+t[0][1]).cover(+t[1][0],+t[1][1]):isNaN(this._x0)?void 0:[[this._x0,this._y0],[this._x1,this._y1]]},W.find=function(t,e,r){var n,o,i,s,a,h,u,c=this._x0,l=this._y0,f=this._x1,d=this._y1,g=[],p=this._root;for(p&&g.push(new P(p,c,l,f,d)),null==r?r=1/0:(c=t-r,l=e-r,f=t+r,d=e+r,r*=r);h=g.pop();)if(!(!(p=h.node)||(o=h.x0)>f||(i=h.y0)>d||(s=h.x1)<c||(a=h.y1)<l))if(p.length){var y=(o+s)/2,m=(i+a)/2;g.push(new P(p[3],y,m,s,a),new P(p[2],o,m,y,a),new P(p[1],y,i,s,m),new P(p[0],o,i,y,m)),(u=(e>=m)<<1|t>=y)&&(h=g[g.length-1],g[g.length-1]=g[g.length-1-u],g[g.length-1-u]=h)}else{var w=t-+this._x.call(null,p.data),v=e-+this._y.call(null,p.data),x=w*w+v*v;if(x<r){var M=Math.sqrt(r=x);c=t-M,l=e-M,f=t+M,d=e+M,n=p.data}}return n},W.remove=function(t){if(isNaN(i=+this._x.call(null,t))||isNaN(s=+this._y.call(null,t)))return this;var e,r,n,o,i,s,a,h,u,c,l,f,d=this._root,g=this._x0,p=this._y0,y=this._x1,m=this._y1;if(!d)return this;if(d.length)for(;;){if((u=i>=(a=(g+y)/2))?g=a:y=a,(c=s>=(h=(p+m)/2))?p=h:m=h,e=d,!(d=d[l=c<<1|u]))return this;if(!d.length)break;(e[l+1&3]||e[l+2&3]||e[l+3&3])&&(r=e,f=l)}for(;d.data!==t;)if(n=d,!(d=d.next))return this;return(o=d.next)&&delete d.next,n?(o?n.next=o:delete n.next,this):e?(o?e[l]=o:delete e[l],(d=e[0]||e[1]||e[2]||e[3])&&d===(e[3]||e[2]||e[1]||e[0])&&!d.length&&(r?r[f]=d:this._root=d),this):(this._root=o,this)},W.removeAll=function(t){for(var e=0,r=t.length;e<r;++e)this.remove(t[e]);return this},W.root=function(){return this._root},W.size=function(){var t=0;return this.visit((function(e){if(!e.length)do{++t}while(e=e.next)})),t},W.visit=function(t){var e,r,n,o,i,s,a=[],h=this._root;for(h&&a.push(new P(h,this._x0,this._y0,this._x1,this._y1));e=a.pop();)if(!t(h=e.node,n=e.x0,o=e.y0,i=e.x1,s=e.y1)&&h.length){var u=(n+i)/2,c=(o+s)/2;(r=h[3])&&a.push(new P(r,u,c,i,s)),(r=h[2])&&a.push(new P(r,n,c,u,s)),(r=h[1])&&a.push(new P(r,u,o,i,c)),(r=h[0])&&a.push(new P(r,n,o,u,c))}return this},W.visitAfter=function(t){var e,r=[],n=[];for(this._root&&r.push(new P(this._root,this._x0,this._y0,this._x1,this._y1));e=r.pop();){var o=e.node;if(o.length){var i,s=e.x0,a=e.y0,h=e.x1,u=e.y1,c=(s+h)/2,l=(a+u)/2;(i=o[0])&&r.push(new P(i,s,a,c,l)),(i=o[1])&&r.push(new P(i,c,a,h,l)),(i=o[2])&&r.push(new P(i,s,l,c,u)),(i=o[3])&&r.push(new P(i,c,l,h,u))}n.push(e)}for(;e=n.pop();)t(e.node,e.x0,e.y0,e.x1,e.y1);return this},W.x=function(t){return arguments.length?(this._x=t,this):this._x},W.y=function(t){return arguments.length?(this._y=t,this):this._y};var U={value:()=>{}};function B(){for(var t,e=0,r=arguments.length,n={};e<r;++e){if(!(t=arguments[e]+"")||t in n||/[\\s.]/.test(t))throw new Error("illegal type: "+t);n[t]=[]}return new H(n)}function H(t){this._=t}function K(t,e){for(var r,n=0,o=t.length;n<o;++n)if((r=t[n]).name===e)return r.value}function J(t,e,r){for(var n=0,o=t.length;n<o;++n)if(t[n].name===e){t[n]=U,t=t.slice(0,n).concat(t.slice(n+1));break}return null!=r&&t.push({name:e,value:r}),t}H.prototype=B.prototype={constructor:H,on:function(t,e){var r,n,o=this._,i=(n=o,(t+"").trim().split(/^|\\s+/).map((function(t){var e="",r=t.indexOf(".");if(r>=0&&(e=t.slice(r+1),t=t.slice(0,r)),t&&!n.hasOwnProperty(t))throw new Error("unknown type: "+t);return{type:t,name:e}}))),s=-1,a=i.length;if(!(arguments.length<2)){if(null!=e&&"function"!=typeof e)throw new Error("invalid callback: "+e);for(;++s<a;)if(r=(t=i[s]).type)o[r]=J(o[r],t.name,e);else if(null==e)for(r in o)o[r]=J(o[r],t.name,null);return this}for(;++s<a;)if((r=(t=i[s]).type)&&(r=K(o[r],t.name)))return r},copy:function(){var t={},e=this._;for(var r in e)t[r]=e[r].slice();return new H(t)},call:function(t,e){if((r=arguments.length-2)>0)for(var r,n,o=new Array(r),i=0;i<r;++i)o[i]=arguments[i+2];if(!this._.hasOwnProperty(t))throw new Error("unknown type: "+t);for(i=0,r=(n=this._[t]).length;i<r;++i)n[i].value.apply(e,o)},apply:function(t,e,r){if(!this._.hasOwnProperty(t))throw new Error("unknown type: "+t);for(var n=this._[t],o=0,i=n.length;o<i;++o)n[o].value.apply(e,r)}};const Y=B;var X,Q,Z=0,tt=0,et=0,rt=1e3,nt=0,ot=0,it=0,st="object"==typeof performance&&performance.now?performance:Date,at="object"==typeof window&&window.requestAnimationFrame?window.requestAnimationFrame.bind(window):function(t){setTimeout(t,17)};function ht(){return ot||(at(ut),ot=st.now()+it)}function ut(){ot=0}function ct(){this._call=this._time=this._next=null}function lt(t,e,r){var n=new ct;return n.restart(t,e,r),n}function ft(){ot=(nt=st.now())+it,Z=tt=0;try{!function(){ht(),++Z;for(var t,e=X;e;)(t=ot-e._time)>=0&&e._call.call(void 0,t),e=e._next;--Z}()}finally{Z=0,function(){for(var t,e,r=X,n=1/0;r;)r._call?(n>r._time&&(n=r._time),t=r,r=r._next):(e=r._next,r._next=null,r=t?t._next=e:X=e);Q=t,gt(n)}(),ot=0}}function dt(){var t=st.now(),e=t-nt;e>rt&&(it-=e,nt=t)}function gt(t){Z||(tt&&(tt=clearTimeout(tt)),t-ot>24?(t<1/0&&(tt=setTimeout(ft,t-st.now()-it)),et&&(et=clearInterval(et))):(et||(nt=st.now(),et=setInterval(dt,rt)),Z=1,at(ft)))}ct.prototype=lt.prototype={constructor:ct,restart:function(t,e,r){if("function"!=typeof t)throw new TypeError("callback is not a function");r=(null==r?ht():+r)+(null==e?0:+e),this._next||Q===this||(Q?Q._next=this:X=this,Q=this),this._call=t,this._time=r,gt()},stop:function(){this._call&&(this._call=null,this._time=1/0,gt())}};const pt=1664525,yt=1013904223,mt=4294967296;function wt(t){return t.x}function vt(t){return t.y}var xt=10,Mt=Math.PI*(3-Math.sqrt(5));function bt(t){var e,r=1,n=.001,o=1-Math.pow(n,1/300),i=0,s=.6,a=new Map,h=lt(l),u=Y("tick","end"),c=function(){let t=1;return()=>(t=(pt*t+yt)%mt)/mt}();function l(){f(),u.call("tick",e),r<n&&(h.stop(),u.call("end",e))}function f(n){var h,u,c=t.length;void 0===n&&(n=1);for(var l=0;l<n;++l)for(r+=(i-r)*o,a.forEach((function(t){t(r)})),h=0;h<c;++h)null==(u=t[h]).fx?u.x+=u.vx*=s:(u.x=u.fx,u.vx=0),null==u.fy?u.y+=u.vy*=s:(u.y=u.fy,u.vy=0);return e}function d(){for(var e,r=0,n=t.length;r<n;++r){if((e=t[r]).index=r,null!=e.fx&&(e.x=e.fx),null!=e.fy&&(e.y=e.fy),isNaN(e.x)||isNaN(e.y)){var o=xt*Math.sqrt(.5+r),i=r*Mt;e.x=o*Math.cos(i),e.y=o*Math.sin(i)}(isNaN(e.vx)||isNaN(e.vy))&&(e.vx=e.vy=0)}}function g(e){return e.initialize&&e.initialize(t,c),e}return null==t&&(t=[]),d(),e={tick:f,restart:function(){return h.restart(l),e},stop:function(){return h.stop(),e},nodes:function(r){return arguments.length?(t=r,d(),a.forEach(g),e):t},alpha:function(t){return arguments.length?(r=+t,e):r},alphaMin:function(t){return arguments.length?(n=+t,e):n},alphaDecay:function(t){return arguments.length?(o=+t,e):+o},alphaTarget:function(t){return arguments.length?(i=+t,e):i},velocityDecay:function(t){return arguments.length?(s=1-t,e):1-s},randomSource:function(t){return arguments.length?(c=t,a.forEach(g),e):c},force:function(t,r){return arguments.length>1?(null==r?a.delete(t):a.set(t,g(r)),e):a.get(t)},find:function(e,r,n){var o,i,s,a,h,u=0,c=t.length;for(null==n?n=1/0:n*=n,u=0;u<c;++u)(s=(o=e-(a=t[u]).x)*o+(i=r-a.y)*i)<n&&(h=a,n=s);return h},on:function(t,r){return arguments.length>1?(u.on(t,r),e):u.on(t)}}}function Et(){var t,e,r,n,o,i=$(-30),s=1,a=1/0,h=.81;function u(r){var o,i=t.length,s=L(t,wt,vt).visitAfter(l);for(n=r,o=0;o<i;++o)e=t[o],s.visit(f)}function c(){if(t){var e,r,n=t.length;for(o=new Array(n),e=0;e<n;++e)r=t[e],o[r.index]=+i(r,e,t)}}function l(t){var e,r,n,i,s,a=0,h=0;if(t.length){for(n=i=s=0;s<4;++s)(e=t[s])&&(r=Math.abs(e.value))&&(a+=e.value,h+=r,n+=r*e.x,i+=r*e.y);t.x=n/h,t.y=i/h}else{(e=t).x=e.data.x,e.y=e.data.y;do{a+=o[e.data.index]}while(e=e.next)}t.value=a}function f(t,i,u,c){if(!t.value)return!0;var l=t.x-e.x,f=t.y-e.y,d=c-i,g=l*l+f*f;if(d*d/h<g)return g<a&&(0===l&&(g+=(l=G(r))*l),0===f&&(g+=(f=G(r))*f),g<s&&(g=Math.sqrt(s*g)),e.vx+=l*t.value*n/g,e.vy+=f*t.value*n/g),!0;if(!(t.length||g>=a)){(t.data!==e||t.next)&&(0===l&&(g+=(l=G(r))*l),0===f&&(g+=(f=G(r))*f),g<s&&(g=Math.sqrt(s*g)));do{t.data!==e&&(d=o[t.data.index]*n/g,e.vx+=l*d,e.vy+=f*d)}while(t=t.next)}}return u.initialize=function(e,n){t=e,r=n,c()},u.strength=function(t){return arguments.length?(i="function"==typeof t?t:$(+t),c(),u):i},u.distanceMin=function(t){return arguments.length?(s=t*t,u):Math.sqrt(s)},u.distanceMax=function(t){return arguments.length?(a=t*t,u):Math.sqrt(a)},u.theta=function(t){return arguments.length?(h=t*t,u):Math.sqrt(h)},u}function Nt(t){return t.index}function St(t,e){var r=t.get(e);if(!r)throw new Error("node not found: "+e);return r}function At(t){var e,r,n,o,i,s,a=Nt,h=function(t){return 1/Math.min(o[t.source.index],o[t.target.index])},u=$(30),c=1;function l(n){for(var o=0,a=t.length;o<c;++o)for(var h,u,l,f,d,g,p,y=0;y<a;++y)u=(h=t[y]).source,f=(l=h.target).x+l.vx-u.x-u.vx||G(s),d=l.y+l.vy-u.y-u.vy||G(s),f*=g=((g=Math.sqrt(f*f+d*d))-r[y])/g*n*e[y],d*=g,l.vx-=f*(p=i[y]),l.vy-=d*p,u.vx+=f*(p=1-p),u.vy+=d*p}function f(){if(n){var s,h,u=n.length,c=t.length,l=new Map(n.map(((t,e)=>[a(t,e,n),t])));for(s=0,o=new Array(u);s<c;++s)(h=t[s]).index=s,"object"!=typeof h.source&&(h.source=St(l,h.source)),"object"!=typeof h.target&&(h.target=St(l,h.target)),o[h.source.index]=(o[h.source.index]||0)+1,o[h.target.index]=(o[h.target.index]||0)+1;for(s=0,i=new Array(c);s<c;++s)h=t[s],i[s]=o[h.source.index]/(o[h.source.index]+o[h.target.index]);e=new Array(c),d(),r=new Array(c),g()}}function d(){if(n)for(var r=0,o=t.length;r<o;++r)e[r]=+h(t[r],r,t)}function g(){if(n)for(var e=0,o=t.length;e<o;++e)r[e]=+u(t[e],e,t)}return null==t&&(t=[]),l.initialize=function(t,e){n=t,s=e,f()},l.links=function(e){return arguments.length?(t=e,f(),l):t},l.id=function(t){return arguments.length?(a=t,l):a},l.iterations=function(t){return arguments.length?(c=+t,l):c},l.strength=function(t){return arguments.length?(h="function"==typeof t?t:$(+t),d(),l):h},l.distance=function(t){return arguments.length?(u="function"==typeof t?t:$(+t),g(),l):u},l}function kt(t){return t.x+t.vx}function Dt(t){return t.y+t.vy}function It(t){var e,r,n,o=1,i=1;function s(){for(var t,s,h,u,c,l,f,d=e.length,g=0;g<i;++g)for(s=L(e,kt,Dt).visitAfter(a),t=0;t<d;++t)h=e[t],l=r[h.index],f=l*l,u=h.x+h.vx,c=h.y+h.vy,s.visit(p);function p(t,e,r,i,s){var a=t.data,d=t.r,g=l+d;if(!a)return e>u+g||i<u-g||r>c+g||s<c-g;if(a.index>h.index){var p=u-a.x-a.vx,y=c-a.y-a.vy,m=p*p+y*y;m<g*g&&(0===p&&(m+=(p=G(n))*p),0===y&&(m+=(y=G(n))*y),m=(g-(m=Math.sqrt(m)))/m*o,h.vx+=(p*=m)*(g=(d*=d)/(f+d)),h.vy+=(y*=m)*g,a.vx-=p*(g=1-g),a.vy-=y*g)}}}function a(t){if(t.data)return t.r=r[t.data.index];for(var e=t.r=0;e<4;++e)t[e]&&t[e].r>t.r&&(t.r=t[e].r)}function h(){if(e){var n,o,i=e.length;for(r=new Array(i),n=0;n<i;++n)o=e[n],r[o.index]=+t(o,n,e)}}return"function"!=typeof t&&(t=$(null==t?1:+t)),s.initialize=function(t,r){e=t,n=r,h()},s.iterations=function(t){return arguments.length?(i=+t,s):i},s.strength=function(t){return arguments.length?(o=+t,s):o},s.radius=function(e){return arguments.length?(t="function"==typeof e?e:$(+e),h(),s):t},s}function _t(t){var e,r,n,o=$(.1);function i(t){for(var o,i=0,s=e.length;i<s;++i)(o=e[i]).vx+=(n[i]-o.x)*r[i]*t}function s(){if(e){var i,s=e.length;for(r=new Array(s),n=new Array(s),i=0;i<s;++i)r[i]=isNaN(n[i]=+t(e[i],i,e))?0:+o(e[i],i,e)}}return"function"!=typeof t&&(t=$(null==t?0:+t)),i.initialize=function(t){e=t,s()},i.strength=function(t){return arguments.length?(o="function"==typeof t?t:$(+t),s(),i):o},i.x=function(e){return arguments.length?(t="function"==typeof e?e:$(+e),s(),i):t},i}function Rt(t){var e,r,n,o=$(.1);function i(t){for(var o,i=0,s=e.length;i<s;++i)(o=e[i]).vy+=(n[i]-o.y)*r[i]*t}function s(){if(e){var i,s=e.length;for(r=new Array(s),n=new Array(s),i=0;i<s;++i)r[i]=isNaN(n[i]=+t(e[i],i,e))?0:+o(e[i],i,e)}}return"function"!=typeof t&&(t=$(null==t?0:+t)),i.initialize=function(t){e=t,s()},i.strength=function(t){return arguments.length?(o="function"==typeof t?t:$(+t),s(),i):o},i.y=function(e){return arguments.length?(t="function"==typeof e?e:$(+e),s(),i):t},i}function zt(){function t(t){return function(){return t}}var e,r=function(t){return t.cluster},n=t(1),o=t(-1),i=t(100),a=t(.1),h=[0,0],u=[],c={},l=[],f=100,d=100,g={none:{x:0,y:0}},p=[],y="force",m=!0,w=.1;function v(t){if(!m)return v;e.tick(),M();for(var n=0,o=u.length,i=void 0,s=t*w;n<o;++n)(i=u[n]).vx+=(g[r(i)].x-i.x)*s,i.vy+=(g[r(i)].y-i.y)*s}function x(){u&&function(){if(u&&u.length){if(void 0===r(u[0]))throw Error("Couldnt find the grouping attribute for the nodes. Make sure to set it up with forceInBox.groupBy(\'clusterAttr\') before calling .links()");var t,h,g,y,m,w=(t=[],h=[],g={},{},m=[],y=function(t){var e={};return t.forEach((function(t){var n=r(t);e[n]||(e[n]={count:0,sumforceNodeSize:0})})),t.forEach((function(t){var o=r(t),i=n(t),s=e[o];s.count=s.count+1,s.sumforceNodeSize=s.sumforceNodeSize+Math.PI*(i*i)*1.3,e[o]=s})),e}(u),m=function(t){var e={},n=[];return t.forEach((function(t){var n,o,i,s,a,h=(o=(n=t).source,i=n.target,(s=r(c[o]))<=(a=r(c[i]))?"".concat(s,"~").concat(a):"".concat(a,"~").concat(s)),u=0;void 0!==e[h]&&(u=e[h]),u+=1,e[h]=u})),Object.entries(e).forEach((function(t){var e=s(t,2),r=e[0],o=e[1],i=r.split("~")[0],a=r.split("~")[1];void 0!==i&&void 0!==a&&n.push({source:i,target:a,count:o})})),n}(l),Object.keys(y).forEach((function(e,r){var n=y[e];t.push({id:e,size:n.count,r:Math.sqrt(n.sumforceNodeSize/Math.PI)}),g[e]=r})),m.forEach((function(t){var e=t.source,r=t.target,n=g[e],o=g[r];void 0!==n&&void 0!==o&&h.push({source:n,target:o,count:t.count})})),{nodes:t,links:h});e=bt(w.nodes).force("x",_t(f).strength(.1)).force("y",Rt(d).strength(.1)).force("collide",It((function(t){return t.r})).iterations(4)).force("charge",Et().strength(o)).force("links",At(w.nodes.length?w.links:[]).distance(i).strength(a)),p=e.nodes(),M()}}()}function M(){return g={none:{x:0,y:0}},p.forEach((function(t){g[t.id]={x:t.x-h[0],y:t.y-h[1]}})),g}return v.initialize=function(t){u=t,x()},v.template=function(t){return arguments.length?(y=t,x(),v):y},v.groupBy=function(t){return arguments.length?"string"==typeof t?(r=function(e){return e[t]},v):(r=t,v):r},v.enableGrouping=function(t){return arguments.length?(m=t,v):m},v.strength=function(t){return arguments.length?(w=t,v):w},v.centerX=function(t){return arguments.length?(f=t,v):f},v.centerY=function(t){return arguments.length?(d=t,v):d},v.nodes=function(t){return arguments.length?(function(t){c={},t.forEach((function(t){c[t.id]=t}))}(t||[]),u=t||[],v):u},v.links=function(t){return arguments.length?(l=t||[],x(),v):l},v.forceNodeSize=function(e){return arguments.length?(n="function"==typeof e?e:t(+e),x(),v):n},v.nodeSize=v.forceNodeSize,v.forceCharge=function(e){return arguments.length?(o="function"==typeof e?e:t(+e),x(),v):o},v.forceLinkDistance=function(e){return arguments.length?(i="function"==typeof e?e:t(+e),x(),v):i},v.forceLinkStrength=function(e){return arguments.length?(a="function"==typeof e?e:t(+e),x(),v):a},v.offset=function(t){return arguments.length?(h=t,v):h},v.getFocis=M,v}var Tt={center:[0,0],preventOverlap:!1,nodeSize:void 0,nodeSpacing:void 0,linkDistance:50,forceSimulation:null,alphaDecay:.028,alphaMin:.001,alpha:.3,collideStrength:1,clustering:!1,clusterNodeStrength:-1,clusterEdgeStrength:.1,clusterEdgeDistance:100,clusterFociStrength:.8,clusterNodeSize:10},Ct=function(){function t(t){void 0===t&&(t={}),this.options=t,this.id="d3force",this.options=r(r({},Tt),t)}return t.prototype.execute=function(t,e){return o(this,void 0,void 0,(function(){return i(this,(function(r){return[2,this.genericForceLayout(!1,t,e)]}))}))},t.prototype.assign=function(t,e){return o(this,void 0,void 0,(function(){return i(this,(function(r){return this.genericForceLayout(!0,t,e),[2]}))}))},t.prototype.stop=function(){var t;null===(t=this.forceSimulation)||void 0===t||t.stop()},t.prototype.tick=function(t){var e=this;void 0===t&&(t=1),this.forceSimulation.tick(t);var r={nodes:Ot(this.lastLayoutNodes),edges:Pt(this.lastLayoutEdges)};return this.lastAssign&&r.nodes.forEach((function(t){return e.lastGraph.mergeNodeData(t.id,{x:t.data.x,y:t.data.y})})),r},t.prototype.genericForceLayout=function(t,e,n){return o(this,void 0,void 0,(function(){var o,s,a,h,u,c,l,f,d,g,p,y,m,w,v,x,M,E,N,S,A,k,D,I,_,R,z=this;return i(this,(function(i){return o=r(r({},this.options),n),s=e.getAllNodes(),a=e.getAllEdges(),h=s.map((function(t){var e,n;return r(r({},b(t)),{x:null===(e=t.data)||void 0===e?void 0:e.x,y:null===(n=t.data)||void 0===n?void 0:n.y})})),u=a.map((function(t){return b(t)})),this.lastLayoutNodes=h,this.lastLayoutEdges=u,this.lastAssign=t,this.lastGraph=e,c=o.alphaMin,l=o.alphaDecay,f=o.alpha,d=o.nodeStrength,g=o.edgeStrength,p=o.linkDistance,y=o.clustering,m=o.clusterFociStrength,w=o.clusterEdgeDistance,v=o.clusterEdgeStrength,x=o.clusterNodeStrength,M=o.clusterNodeSize,E=o.collideStrength,N=void 0===E?1:E,S=o.center,A=void 0===S?[0,0]:S,k=o.preventOverlap,D=o.nodeSize,I=o.nodeSpacing,_=o.onTick,R=o.forceSimulation,[2,new Promise((function(r){if(R){y&&((i=zt()).nodes(h),i.links(u)),R.nodes(h),u&&(a=At().id((function(t){return t.id})).links(u),g&&a.strength(g),p&&a.distance(p),R.force("link",a)),k&&z.overlapProcess(R,{nodeSize:D,nodeSpacing:I,collideStrength:N}),R.alpha(f).restart();var n=Ot(h),o=Pt(u);t&&n.forEach((function(t){return e.mergeNodeData(t.id,{x:t.data.x,y:t.data.y})})),r({nodes:n,edges:o})}else try{var i,s=Et();if(d&&s.strength(d),R=bt().nodes(h),y&&((i=zt()).centerX(A[0]).centerY(A[1]).template("force").strength(m),u&&i.links(u),h&&i.nodes(h),i.forceLinkDistance(w).forceLinkStrength(v).forceCharge(x).forceNodeSize(M),R.force("group",i)),R.force("center",function(t,e){var r,n=1;function o(){var o,i,s=r.length,a=0,h=0;for(o=0;o<s;++o)a+=(i=r[o]).x,h+=i.y;for(a=(a/s-t)*n,h=(h/s-e)*n,o=0;o<s;++o)(i=r[o]).x-=a,i.y-=h}return null==t&&(t=0),null==e&&(e=0),o.initialize=function(t){r=t},o.x=function(e){return arguments.length?(t=+e,o):t},o.y=function(t){return arguments.length?(e=+t,o):e},o.strength=function(t){return arguments.length?(n=+t,o):n},o}(A[0],A[1])).force("charge",s).alpha(f).alphaDecay(l).alphaMin(c),k&&z.overlapProcess(R,{nodeSize:D,nodeSpacing:I,collideStrength:N}),u){var a=At().id((function(t){return t.id})).links(u);g&&a.strength(g),p&&a.distance(p),R.force("link",a)}R.on("tick",(function(){var r=Ot(h);null==_||_({nodes:r,edges:Pt(u)}),t&&r.forEach((function(t){return e.mergeNodeData(t.id,{x:t.data.x,y:t.data.y})}))})).on("end",(function(){var n=Ot(h);t&&n.forEach((function(t){return e.mergeNodeData(t.id,{x:t.data.x,y:t.data.y})})),r({nodes:n,edges:Pt(u)})}))}catch(t){console.warn(t)}z.forceSimulation=R}))]}))}))},t.prototype.overlapProcess=function(t,e){var r,n,o=e.nodeSize,i=e.nodeSpacing,s=e.collideStrength;if(n=x(i)?function(){return i}:E(i)?i:function(){return 0},o)if(E(o))r=function(t){return o(t)+n(t)};else if(g(o)){var a=(o[0]>o[1]?o[0]:o[1])/2;r=function(t){return a+n(t)}}else if(x(o)){var h=o/2;r=function(t){return h+n(t)}}else r=function(){return 10};else r=function(t){return t.size?g(t.size)?(t.size[0]>t.size[1]?t.size[0]:t.size[1])/2+n(t):N(t.size)?(t.size.width>t.size.height?t.size.width:t.size.height)/2+n(t):t.size/2+n(t):10+n(t)};t.force("collisionForce",It(r).strength(s))},t}(),Ot=function(t){return t.map((function(t){var e=t.x,o=t.y,i=n(t,["x","y"]);return r(r({},i),{data:r(r({},i.data),{x:e,y:o})})}))},Pt=function(t){return t.map((function(t){var e=t.source,o=t.target,i=n(t,["source","target"]);return r(r({},i),{source:e.id,target:o.id})}))};function qt(t){var e=0,r=0,n=0;if(t.length){for(var o=0;o<4;o++)(i=t[o])&&i.weight&&(e+=i.weight,r+=i.x*i.weight,n+=i.y*i.weight);t.x=r/e,t.y=n/e,t.weight=e}else{var i=t;t.x=i.data.x,t.y=i.data.y,t.weight=i.data.weight}}var Ft=function(t,e,r,n,o,i){var s=i.x-t.x||.1,a=i.y-t.y||.1,h=n-e,u=s*s+a*a,c=Math.sqrt(u)*u;if(h*h*.81<u){var l=t.weight/c;return i.vx+=s*l,i.vy+=a*l,!0}if(t.length)return!1;t.data!==i&&(l=t.data.weight/c,i.vx+=s*l,i.vy+=a*l)},Lt={maxIteration:500,gravity:10,factor:1,edgeStrength:200,nodeStrength:1e3,coulombDisScale:.005,damping:.9,maxSpeed:500,minMovement:.4,interval:.02,linkDistance:200,clusterNodeStrength:20,preventOverlap:!0,distanceThresholdMode:"mean"},jt=function(){function t(t){void 0===t&&(t={}),this.options=t,this.id="force",this.timeInterval=0,this.judgingDistance=0,this.running=!1,this.options=r(r({},Lt),t)}return t.prototype.execute=function(t,e){return o(this,void 0,void 0,(function(){return i(this,(function(r){return[2,this.genericForceLayout(!1,t,e)]}))}))},t.prototype.assign=function(t,e){return o(this,void 0,void 0,(function(){return i(this,(function(r){return this.genericForceLayout(!0,t,e),[2]}))}))},t.prototype.stop=function(){this.timeInterval&&"undefined"!=typeof window&&window.clearInterval(this.timeInterval),this.running=!1},t.prototype.tick=function(t){var e=this;if(void 0===t&&(t=this.options.maxIteration||1),this.lastResult)return this.lastResult;for(var r=0;(this.judgingDistance>this.lastOptions.minMovement||r<1)&&r<t;r++)this.runOneStep(this.lastCalcGraph,this.lastGraph,r,this.lastVelMap,this.lastOptions),this.updatePosition(this.lastGraph,this.lastCalcGraph,this.lastVelMap,this.lastOptions);var n={nodes:this.lastLayoutNodes,edges:this.lastLayoutEdges};return this.lastAssign&&n.nodes.forEach((function(t){return e.lastGraph.mergeNodeData(t.id,{x:t.data.x,y:t.data.y})})),n},t.prototype.genericForceLayout=function(t,e,n){return o(this,void 0,void 0,(function(){var o,s,a,h,u,c,l,d,g,p,y,m,w,v,M,b,E,N,S,A=this;return i(this,(function(i){return o=r(r({},this.options),n),s=e.getAllNodes(),a=e.getAllEdges(),h=this.formatOptions(o,e),u=h.width,c=h.height,l=h.nodeSize,d=h.getMass,g=h.nodeStrength,p=h.edgeStrength,y=h.linkDistance,m=s.map((function(t){return r(r({},t),{data:r(r({},t.data),{x:x(t.data.x)?t.data.x:Math.random()*u,y:x(t.data.y)?t.data.y:Math.random()*c,size:l(t)||30,mass:d(t),nodeStrength:g(t)})})})),w=a.map((function(t){return r(r({},t),{data:r(r({},t.data),{edgeStrength:p(t),linkDistance:y(t,e.getNode(t.source),e.getNode(t.target))})})})),(null==s?void 0:s.length)?(v={},s.forEach((function(t,e){v[t.id]={x:0,y:0}})),M=new f({nodes:m,edges:w}),this.formatCentripetal(h,M),b=h.maxIteration,E=h.minMovement,N=h.onTick,this.lastLayoutNodes=m,this.lastLayoutEdges=w,this.lastAssign=t,this.lastGraph=e,this.lastCalcGraph=M,this.lastOptions=h,this.lastVelMap=v,"undefined"==typeof window?[2]:(S=0,[2,new Promise((function(r){A.timeInterval=window.setInterval((function(){s&&A.running||r({nodes:Ut(e,m),edges:a}),A.runOneStep(M,e,S,v,h),A.updatePosition(e,M,v,h),t&&m.forEach((function(t){return e.mergeNodeData(t.id,{x:t.data.x,y:t.data.y})})),null==N||N({nodes:Ut(e,m),edges:a}),(++S>=b||A.judgingDistance<E)&&(window.clearInterval(A.timeInterval),r({nodes:Ut(e,m),edges:a}))}),0),A.running=!0}))])):(this.lastResult={nodes:[],edges:a},[2,{nodes:[],edges:a}])}))}))},t.prototype.formatOptions=function(t,e){var r=t,n=t.width,o=t.height,i=t.getMass;if(r.width=n||"undefined"==typeof window?n:window.innerWidth,r.height=o||"undefined"==typeof window?o:window.innerHeight,t.center||(r.center=[r.width/2,r.height/2]),i||(r.getMass=function(t){var r=1;x(null==t?void 0:t.data.mass)&&(r=null==t?void 0:t.data.mass);var n=e.getDegree(t.id,"both");return!n||n<5?r:5*n*r}),t.preventOverlap){var s=S(0,t.nodeSpacing);t.nodeSize?g(t.nodeSize)?r.nodeSize=function(e){var r=t.nodeSize;return Math.max(r[0],r[1])+s(e)}:r.nodeSize=function(e){return t.nodeSize+s(e)}:r.nodeSize=function(t){var e=((null==t?void 0:t.data)||{}).size;return e?g(e)?Math.max(e[0],e[1])+s(t):N(e)?Math.max(e.width,e.height)+s(t):e+s(t):10+s(t)}}return r.linkDistance=t.linkDistance?S(1,t.linkDistance):function(t){return 1+r.nodeSize(e.getNode(t.source))+r.nodeSize(e.getNode(t.target))},r.nodeStrength=S(1,t.nodeStrength),r.edgeStrength=S(1,t.edgeStrength),t},t.prototype.formatCentripetal=function(t,e){var r,n=t.centripetalOptions,o=t.center,i=t.clusterNodeStrength,s=t.leafCluster,a=t.clustering,h=t.nodeClusterBy,u=e.getAllNodes(),c=n||{leaf:2,single:2,others:1,center:function(t){return{x:o[0],y:o[1]}}};"function"!=typeof i&&(t.clusterNodeStrength=function(t){return i});var l=[];if(s&&h&&(r=Vt(e,h),l=Array.from(new Set(null==u?void 0:u.map((function(t){return t.data[h]}))))||[],t.centripetalOptions=Object.assign(c,{single:100,leaf:function(e){var n=r[e.id]||{},o=n.siblingLeaves,i=n.sameTypeLeaves;return(null==i?void 0:i.length)===(null==o?void 0:o.length)||1===(null==l?void 0:l.length)?1:t.clusterNodeStrength(e)},others:1,center:function(t){var n,o=e.getDegree(t.id,"both");if(!o)return{x:100,y:100};if(1===o){var i=(r[t.id]||{}).sameTypeLeaves,s=void 0===i?[]:i;1===s.length?n=void 0:s.length>1&&(n=Gt(s))}else n=void 0;return{x:null==n?void 0:n.x,y:null==n?void 0:n.y}}})),a&&h){r||(r=Vt(e,h)),l||(l=Array.from(new Set(u.map((function(t){return t.data[h]}))))),l=l.filter((function(t){return void 0!==t}));var f={};l.forEach((function(t){var r=u.filter((function(e){return e.data[h]===t})).map((function(t){return e.getNode(t.id)}));f[t]=Gt(r)})),t.centripetalOptions=Object.assign(c,{single:function(e){return t.clusterNodeStrength(e)},leaf:function(e){return t.clusterNodeStrength(e)},others:function(e){return t.clusterNodeStrength(e)},center:function(t){var e=f[t.data[h]];return{x:null==e?void 0:e.x,y:null==e?void 0:e.y}}})}var d=t.centripetalOptions||{},g=d.leaf,p=d.single,y=d.others;g&&"function"!=typeof g&&(t.centripetalOptions.leaf=function(){return g}),p&&"function"!=typeof p&&(t.centripetalOptions.single=function(){return p}),y&&"function"!=typeof y&&(t.centripetalOptions.others=function(){return y})},t.prototype.runOneStep=function(t,e,r,n,o){var i={},s=t.getAllNodes(),a=t.getAllEdges();if(null==s?void 0:s.length){var h=o.monitor;this.calRepulsive(t,i,o),a&&this.calAttractive(t,i),this.calGravity(t,e,i,o),this.updateVelocity(t,i,n,o),h&&h({energy:this.calTotalEnergy(i,s),nodes:e.getAllNodes(),edges:e.getAllEdges(),iterations:r})}},t.prototype.calTotalEnergy=function(t,e){if(!(null==e?void 0:e.length))return 0;var r=0;return e.forEach((function(e,n){var o=t[e.id].x,i=t[e.id].y,s=o*o+i*i,a=e.data.mass;r+=(void 0===a?1:a)*s*.5})),r},t.prototype.calRepulsive=function(t,e,r){var n=r.factor,o=r.coulombDisScale;!function(t,e,r,n){var o=e/r,i=t.getAllNodes(),s=i.map((function(t,e){var r=t.data,n=r.nodeStrength;return{x:r.x,y:r.y,size:r.size,index:e,vx:0,vy:0,weight:o*n}})),a=L(s,(function(t){return t.x}),(function(t){return t.y})).visitAfter(qt);s.forEach((function(t){!function(t,e){e.visit((function(e,r,n,o,i){return Ft(e,r,n,o,i,t)}))}(t,a)})),s.map((function(t,e){var r=i[e],o=r.id,s=r.data.mass,a=void 0===s?1:s;n[o]={x:t.vx/a,y:t.vy/a}}))}(t,n,o*o,e)},t.prototype.calAttractive=function(t,e){t.getAllEdges().forEach((function(r,n){var o=r.source,i=r.target,s=t.getNode(o),a=t.getNode(i);if(s&&a){var h=a.data.x-s.data.x,u=a.data.y-s.data.y;h||u||(h=.01*Math.random(),u=.01*Math.random());var c=Math.sqrt(h*h+u*u),l=h/c,f=u/c,d=r.data||{},g=d.linkDistance,p=void 0===g?200:g,y=d.edgeStrength,m=(p-c)*(void 0===y?200:y),w=1/(s.data.mass||1),v=1/(a.data.mass||1),x=l*m,M=f*m;e[o].x-=x*w,e[o].y-=M*w,e[i].x+=x*v,e[i].y+=M*v}}))},t.prototype.calGravity=function(t,e,r,n){var o=n.getCenter,i=t.getAllNodes(),a=e.getAllNodes(),h=e.getAllEdges(),u=n.width,c=n.height,l=n.center,f=n.gravity,d=n.centripetalOptions;i&&i.forEach((function(n){var i=n.id,g=n.data,p=g.mass,y=g.x,m=g.y,w=e.getNode(i),v=0,M=0,b=f,E=t.getDegree(i,"in"),N=t.getDegree(i,"out"),S=t.getDegree(i,"both"),A=null==o?void 0:o(w,S);if(A){var k=s(A,3);v=y-k[0],M=m-k[1],b=k[2]}else v=y-l[0],M=m-l[1];if(b&&(r[i].x-=b*v/p,r[i].y-=b*M/p),d){var D=d.leaf,I=d.single,_=d.others,R=d.center,z=(null==R?void 0:R(w,a,h,u,c))||{x:0,y:0,centerStrength:0},T=z.x,C=z.y,O=z.centerStrength;if(!x(T)||!x(C))return;var P=(y-T)/p,q=(m-C)/p;if(O&&(r[i].x-=O*P,r[i].y-=O*q),0===S){var F=I(w);if(!F)return;return r[i].x-=F*P,void(r[i].y-=F*q)}if(0===E||0===N){var L=D(w,a,h);if(!L)return;return r[i].x-=L*P,void(r[i].y-=L*q)}var j=_(w);if(!j)return;r[i].x-=j*P,r[i].y-=j*q}}))},t.prototype.updateVelocity=function(t,e,r,n){var o=n.damping,i=n.maxSpeed,s=n.interval,a=t.getAllNodes();(null==a?void 0:a.length)&&a.forEach((function(t){var n=t.id,a=(r[n].x+e[n].x*s)*o||.01,h=(r[n].y+e[n].y*s)*o||.01,u=Math.sqrt(a*a+h*h);if(u>i){var c=i/u;a*=c,h*=c}r[n]={x:a,y:h}}))},t.prototype.updatePosition=function(t,e,r,n){var o=this,i=n.distanceThresholdMode,s=n.interval,a=e.getAllNodes();if(null==a?void 0:a.length){var h=0;"max"===i?this.judgingDistance=-1/0:"min"===i&&(this.judgingDistance=1/0),a.forEach((function(n){var a=n.id,u=t.getNode(a);if(x(u.data.fx)&&x(u.data.fy))e.mergeNodeData(a,{x:u.data.fx,y:u.data.fy});else{var c=r[a].x*s,l=r[a].y*s;e.mergeNodeData(a,{x:n.data.x+c,y:n.data.y+l});var f=Math.sqrt(c*c+l*l);switch(i){case"max":o.judgingDistance<f&&(o.judgingDistance=f);break;case"min":o.judgingDistance>f&&(o.judgingDistance=f);break;default:h+=f}}})),i&&"mean"!==i||(this.judgingDistance=h/a.length)}else this.judgingDistance=0},t}(),Vt=function(t,e){var r=t.getAllNodes();if(!(null==r?void 0:r.length))return{};var n={};return r.forEach((function(r,o){1===t.getDegree(r.id,"both")&&(n[r.id]=Wt(t,"leaf",r,e))})),n},Wt=function(t,e,r,n){var o=t.getDegree(r.id,"in"),i=t.getDegree(r.id,"out"),s=r,a=[];return 0===o?(s=t.getSuccessors(r.id)[0],a=t.getNeighbors(s.id)):0===i&&(s=t.getPredecessors(r.id)[0],a=t.getNeighbors(s.id)),a=a.filter((function(e){return 0===t.getDegree(e.id,"in")||0===t.getDegree(e.id,"out")})),{coreNode:s,siblingLeaves:a,sameTypeLeaves:$t(t,e,n,r,a)}},$t=function(t,e,r,n,o){var i=n.data[r]||"",s=(null==o?void 0:o.filter((function(t){return t.data[r]===i})))||[];return"leaf"===e&&(s=s.filter((function(e){return 0===t.getDegree(e.id,"in")||0===t.getDegree(e.id,"out")}))),s},Gt=function(t){var e={x:0,y:0};t.forEach((function(t){var r=t.data,n=r.x,o=r.y;e.x+=n||0,e.y+=o||0}));var r=t.length||1;return{x:e.x/r,y:e.y/r}},Ut=function(t,e){return e.map((function(e){var n=e.id,o=e.data,i=t.getNode(n);return r(r({},i),{data:r(r({},i.data),{x:o.x,y:o.y})})}))},Bt=function(){function t(t){this.id=t.id||0,this.rx=t.rx,this.ry=t.ry,this.fx=0,this.fy=0,this.mass=t.mass,this.degree=t.degree,this.g=t.g||0}return t.prototype.distanceTo=function(t){var e=this.rx-t.rx,r=this.ry-t.ry;return Math.hypot(e,r)},t.prototype.setPos=function(t,e){this.rx=t,this.ry=e},t.prototype.resetForce=function(){this.fx=0,this.fy=0},t.prototype.addForce=function(t){var e=t.rx-this.rx,r=t.ry-this.ry,n=Math.hypot(e,r);n=n<1e-4?1e-4:n;var o=this.g*(this.degree+1)*(t.degree+1)/n;this.fx+=o*e/n,this.fy+=o*r/n},t.prototype.in=function(t){return t.contains(this.rx,this.ry)},t.prototype.add=function(e){var r=this.mass+e.mass;return new t({rx:(this.rx*this.mass+e.rx*e.mass)/r,ry:(this.ry*this.mass+e.ry*e.mass)/r,mass:r,degree:this.degree+e.degree})},t}();const Ht=Bt;const Kt=function(){function t(t){this.xmid=t.xmid,this.ymid=t.ymid,this.length=t.length,this.massCenter=t.massCenter||[0,0],this.mass=t.mass||1}return t.prototype.getLength=function(){return this.length},t.prototype.contains=function(t,e){var r=this.length/2;return t<=this.xmid+r&&t>=this.xmid-r&&e<=this.ymid+r&&e>=this.ymid-r},t.prototype.NW=function(){return new t({xmid:this.xmid-this.length/4,ymid:this.ymid+this.length/4,length:this.length/2})},t.prototype.NE=function(){return new t({xmid:this.xmid+this.length/4,ymid:this.ymid+this.length/4,length:this.length/2})},t.prototype.SW=function(){return new t({xmid:this.xmid-this.length/4,ymid:this.ymid-this.length/4,length:this.length/2})},t.prototype.SE=function(){return new t({xmid:this.xmid+this.length/4,ymid:this.ymid-this.length/4,length:this.length/2})},t}(),Jt=function(){function t(t){this.body=null,this.quad=null,this.NW=null,this.NE=null,this.SW=null,this.SE=null,this.theta=.5,null!=t&&(this.quad=t)}return t.prototype.insert=function(e){null!=this.body?this._isExternal()?(this.quad&&(this.NW=new t(this.quad.NW()),this.NE=new t(this.quad.NE()),this.SW=new t(this.quad.SW()),this.SE=new t(this.quad.SE())),this._putBody(this.body),this._putBody(e),this.body=this.body.add(e)):(this.body=this.body.add(e),this._putBody(e)):this.body=e},t.prototype._putBody=function(t){this.quad&&(t.in(this.quad.NW())&&this.NW?this.NW.insert(t):t.in(this.quad.NE())&&this.NE?this.NE.insert(t):t.in(this.quad.SW())&&this.SW?this.SW.insert(t):t.in(this.quad.SE())&&this.SE&&this.SE.insert(t))},t.prototype._isExternal=function(){return null==this.NW&&null==this.NE&&null==this.SW&&null==this.SE},t.prototype.updateForce=function(t){null!=this.body&&t!==this.body&&(this._isExternal()||(this.quad?this.quad.getLength():0)/this.body.distanceTo(t)<this.theta?t.addForce(this.body):(this.NW&&this.NW.updateForce(t),this.NE&&this.NE.updateForce(t),this.SW&&this.SW.updateForce(t),this.SE&&this.SE.updateForce(t)))},t}();var Yt={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},Xt=function(){function t(t){void 0===t&&(t={}),this.options=t,this.id="forceAtlas2",this.options=r(r({},Yt),t)}return t.prototype.execute=function(t,e){return o(this,void 0,void 0,(function(){return i(this,(function(r){return[2,this.genericForceAtlas2Layout(!1,t,e)]}))}))},t.prototype.assign=function(t,e){return o(this,void 0,void 0,(function(){return i(this,(function(r){return this.genericForceAtlas2Layout(!0,t,e),[2]}))}))},t.prototype.genericForceAtlas2Layout=function(t,e,n){return o(this,void 0,void 0,(function(){var o,s,a,h,u,c,l,d,g,p,y,m,w,v,x,M,E,N,S,A,D,I;return i(this,(function(i){if(o=e.getAllEdges(),s=e.getAllNodes(),a=this.formatOptions(n,s.length),h=a.width,u=a.height,c=a.prune,l=a.maxIteration,d=a.nodeSize,g=a.center,!(null==s?void 0:s.length)||1===s.length)return[2,k(e,t,g)];if(p=s.map((function(t){return b(t,[h,u])})),y=o.filter((function(t){return t.source!==t.target})),m=new f({nodes:p,edges:y}),w=this.getSizes(m,e,d),this.run(m,e,l,w,t,a),c){for(v=0;v<y.length;v+=1)x=y[v],M=x.source,E=x.target,N=m.getDegree(M),S=m.getDegree(M),N<=1?(A=m.getNode(E),m.mergeNodeData(M,{x:A.data.x,y:A.data.y})):S<=1&&(D=m.getNode(M),m.mergeNodeData(E,{x:D.data.x,y:D.data.y}));I=r(r({},a),{prune:!1,barnesHut:!1}),this.run(m,e,100,w,t,I)}return[2,{nodes:p,edges:o}]}))}))},t.prototype.getSizes=function(t,e,r){for(var n=t.getAllNodes(),o={},i=0;i<n.length;i+=1){var h=n[i],u=h.id,c=h.data;if(o[u]=10,x(c.size))o[u]=c.size;else if(g(c.size))isNaN(c.size[0])||(o[u]=Math.max(c.size[0])),isNaN(c.size[1])||(o[u]=Math.max(c.size[1]));else if(N(c.size))o[u]=Math.max(c.size.width,c.size.height);else if(E(r)){var l=r(e.getNode(u));g(l)?o[u]=Math.max.apply(Math,a([],s(l),!1)):o[u]=l}else g(r)?o[u]=Math.max.apply(Math,a([],s(r),!1)):x(r)&&(o[u]=r)}return o},t.prototype.formatOptions=function(t,e){void 0===t&&(t={});var n=r(r({},this.options),t),o=n.center,i=n.width,s=n.height,a=n.barnesHut,h=n.prune,u=n.maxIteration,c=n.kr,l=n.kg;return n.width=i||"undefined"==typeof window?i:window.innerWidth,n.height=s||"undefined"==typeof window?s:window.innerHeight,n.center=o||[n.width/2,n.height/2],void 0===a&&e>250&&(n.barnesHut=!0),void 0===h&&e>100&&(n.prune=!0),0!==u||h?0===u&&h&&(n.maxIteration=100,e<=200&&e>100?n.maxIteration=500:e>200&&(n.maxIteration=950)):(n.maxIteration=250,e<=200&&e>100?n.maxIteration=1e3:e>200&&(n.maxIteration=1200)),c||(n.kr=50,e>100&&e<=500?n.kr=20:e>500&&(n.kr=1)),l||(n.kg=20,e>100&&e<=500?n.kg=10:e>500&&(n.kg=1)),n},t.prototype.run=function(t,e,r,n,o,i){for(var s=i.kr,a=i.barnesHut,h=i.onTick,u=t.getAllNodes(),c=0,l=r,f={},d={},g={},p=0;p<u.length;p+=1){var y=u[p],m=y.data,w=y.id;if(f[w]=[0,0],a){var v={id:p,rx:m.x,ry:m.y,mass:1,g:s,degree:t.getDegree(w)};g[w]=new Ht(v)}}for(;l>0;)c=this.oneStep(t,{iter:l,preventOverlapIters:50,krPrime:100,sg:c,forces:f,preForces:d,bodies:g,sizes:n},i),l--,null==h||h({nodes:u,edges:e.getAllEdges()});return t},t.prototype.oneStep=function(t,e,r){for(var n=e.iter,o=e.preventOverlapIters,i=e.krPrime,h=e.sg,u=e.preForces,c=e.bodies,l=e.sizes,f=e.forces,d=r.preventOverlap,g=r.barnesHut,p=t.getAllNodes(),y=0;y<p.length;y+=1){var m=p[y].id;u[m]=a([],s(f[m]),!1),f[m]=[0,0]}return f=this.getAttrForces(t,n,o,l,f,r),f=g&&(d&&n>o||!d)?this.getOptRepGraForces(t,f,c,r):this.getRepGraForces(t,n,o,f,i,l,r),this.updatePos(t,f,u,h,r)},t.prototype.getAttrForces=function(t,e,r,n,o,i){for(var s=i.preventOverlap,a=i.dissuadeHubs,h=i.mode,u=i.prune,c=t.getAllEdges(),l=0;l<c.length;l+=1){var f=c[l],d=f.source,g=f.target,p=t.getNode(d),y=t.getNode(g),m=t.getDegree(d),w=t.getDegree(g);if(!u||!(m<=1||w<=1)){var v=[y.data.x-p.data.x,y.data.y-p.data.y],x=Math.hypot(v[0],v[1]);x=x<1e-4?1e-4:x,v[0]=v[0]/x,v[1]=v[1]/x,s&&e<r&&(x=x-n[d]-n[g]);var M=x,b=M;"linlog"===h&&(b=M=Math.log(1+x)),a&&(M=x/m,b=x/w),s&&e<r&&x<=0?(M=0,b=0):s&&e<r&&x>0&&(M=x,b=x),o[d][0]+=M*v[0],o[g][0]-=b*v[0],o[d][1]+=M*v[1],o[g][1]-=b*v[1]}}return o},t.prototype.getOptRepGraForces=function(t,e,r,n){for(var o=n.kg,i=n.center,s=n.prune,a=t.getAllNodes(),h=a.length,u=9e10,c=-9e10,l=9e10,f=-9e10,d=0;d<h;d+=1){var g=a[d],p=g.id,y=g.data;s&&t.getDegree(p)<=1||(r[p].setPos(y.x,y.y),y.x>=c&&(c=y.x),y.x<=u&&(u=y.x),y.y>=f&&(f=y.y),y.y<=l&&(l=y.y))}var m=Math.max(c-u,f-l),w=new Kt({xmid:(c+u)/2,ymid:(f+l)/2,length:m,massCenter:i,mass:h}),v=new Jt(w);for(d=0;d<h;d+=1)p=a[d].id,s&&t.getDegree(p)<=1||r[p].in(w)&&v.insert(r[p]);for(d=0;d<h;d+=1){var x=a[d],M=(p=x.id,y=x.data,t.getDegree(p));if(!(s&&M<=1)){r[p].resetForce(),v.updateForce(r[p]),e[p][0]-=r[p].fx,e[p][1]-=r[p].fy;var b=[y.x-i[0],y.y-i[1]],E=Math.hypot(b[0],b[1]);E=E<1e-4?1e-4:E,b[0]=b[0]/E,b[1]=b[1]/E;var N=o*(M+1);e[p][0]-=N*b[0],e[p][1]-=N*b[1]}}return e},t.prototype.getRepGraForces=function(t,e,r,n,o,i,s){for(var a=s.preventOverlap,h=s.kr,u=s.kg,c=s.center,l=s.prune,f=t.getAllNodes(),d=f.length,g=0;g<d;g+=1){for(var p=f[g],y=t.getDegree(p.id),m=g+1;m<d;m+=1){var w=f[m],v=t.getDegree(w.id);if(!l||!(y<=1||v<=1)){var x=[w.data.x-p.data.x,w.data.y-p.data.y],M=Math.hypot(x[0],x[1]);M=M<1e-4?1e-4:M,x[0]=x[0]/M,x[1]=x[1]/M,a&&e<r&&(M=M-i[p.id]-i[w.id]);var b=h*(y+1)*(v+1)/M;a&&e<r&&M<0?b=o*(y+1)*(v+1):a&&e<r&&0===M?b=0:a&&e<r&&M>0&&(b=h*(y+1)*(v+1)/M),n[p.id][0]-=b*x[0],n[w.id][0]+=b*x[0],n[p.id][1]-=b*x[1],n[w.id][1]+=b*x[1]}}var E=[p.data.x-c[0],p.data.y-c[1]],N=Math.hypot(E[0],E[1]);E[0]=E[0]/N,E[1]=E[1]/N;var S=u*(y+1);n[p.id][0]-=S*E[0],n[p.id][1]-=S*E[1]}return n},t.prototype.updatePos=function(t,e,r,n,o){for(var i=o.ks,s=o.tao,a=o.prune,h=o.ksmax,u=t.getAllNodes(),c=u.length,l=[],f=[],d=0,g=0,p=n,y=0;y<c;y+=1){var m=u[y].id,w=t.getDegree(m);if(!(a&&w<=1)){var v=[e[m][0]-r[m][0],e[m][1]-r[m][1]],M=Math.hypot(v[0],v[1]),b=[e[m][0]+r[m][0],e[m][1]+r[m][1]],E=Math.hypot(b[0],b[1]);l[y]=M,f[y]=E/2,d+=(w+1)*l[y],g+=(w+1)*f[y]}}var N=p;for(p=s*g/d,0!==N&&(p=p>1.5*N?1.5*N:p),y=0;y<c;y+=1){var S=u[y],A=(m=S.id,S.data);if(w=t.getDegree(m),!(a&&w<=1||x(A.fx)&&x(A.fy))){var k=i*p/(1+p*Math.sqrt(l[y])),D=Math.hypot(e[m][0],e[m][1]),I=h/(D=D<1e-4?1e-4:D),_=(k=k>I?I:k)*e[m][0],R=k*e[m][1];t.mergeNodeData(m,{x:A.x+_,y:A.y+R})}}return p},t}(),Qt={maxIteration:1e3,gravity:10,speed:5,clustering:!1,clusterGravity:10,width:300,height:300,nodeClusterBy:"cluster"},Zt=function(){function t(t){void 0===t&&(t={}),this.options=t,this.id="fruchterman",this.timeInterval=0,this.running=!1,this.options=r(r({},Qt),t)}return t.prototype.execute=function(t,e){return o(this,void 0,void 0,(function(){return i(this,(function(r){return[2,this.genericFruchtermanLayout(!1,t,e)]}))}))},t.prototype.assign=function(t,e){return o(this,void 0,void 0,(function(){return i(this,(function(r){return this.genericFruchtermanLayout(!0,t,e),[2]}))}))},t.prototype.stop=function(){this.timeInterval&&"undefined"!=typeof window&&window.clearInterval(this.timeInterval),this.running=!1},t.prototype.tick=function(t){var e=this;if(void 0===t&&(t=this.options.maxIteration||1),this.lastResult)return this.lastResult;for(var r=0;r<t;r++)this.runOneStep(this.lastGraph,this.lastClusterMap,this.lastOptions);var n={nodes:this.lastLayoutNodes,edges:this.lastLayoutEdges};return this.lastAssign&&n.nodes.forEach((function(t){return e.lastGraph.mergeNodeData(t.id,{x:t.data.x,y:t.data.y})})),n},t.prototype.genericFruchtermanLayout=function(t,e,n){return o(this,void 0,void 0,(function(){var o,s,a,h,u,c,l,d,g,p,y,m,w,v,x,M=this;return i(this,(function(i){return this.running?[2]:(o=this.formatOptions(n),s=o.width,a=o.height,h=o.center,u=o.clustering,c=o.nodeClusterBy,l=o.maxIteration,d=o.onTick,g=e.getAllNodes(),p=e.getAllEdges(),(null==g?void 0:g.length)?1===g.length?(t&&e.mergeNodeData(g[0].id,{x:h[0],y:h[1]}),y={nodes:[r(r({},g[0]),{data:r(r({},g[0].data),{x:h[0],y:h[1]})})],edges:p},this.lastResult=y,[2,y]):(m=g.map((function(t){return b(t,[s,a])})),w=new f({nodes:m,edges:p}),v={},u&&m.forEach((function(t){var e=t.data[c];v[e]||(v[e]={name:e,cx:0,cy:0,count:0})})),this.lastLayoutNodes=m,this.lastLayoutEdges=p,this.lastAssign=t,this.lastGraph=w,this.lastOptions=o,this.lastClusterMap=v,"undefined"==typeof window?[2]:(x=0,[2,new Promise((function(r){M.timeInterval=window.setInterval((function(){M.running?(M.runOneStep(w,v,o),t&&m.forEach((function(t){var r=t.id,n=t.data;return e.mergeNodeData(r,{x:n.x,y:n.y})})),null==d||d({nodes:m,edges:p}),++x>=l&&(window.clearInterval(M.timeInterval),r({nodes:m,edges:p}))):r({nodes:m,edges:p})}),0),M.running=!0}))])):(y={nodes:[],edges:p},this.lastResult=y,[2,y]))}))}))},t.prototype.formatOptions=function(t){void 0===t&&(t={});var e=r(r({},this.options),t),n=e.clustering,o=e.nodeClusterBy,i=e.center,s=e.width,a=e.height;return e.width=s||"undefined"==typeof window?s:window.innerWidth,e.height=a||"undefined"==typeof window?a:window.innerHeight,e.center=i||[e.width/2,e.height/2],e.clustering=n&&!!o,e},t.prototype.runOneStep=function(t,e,r){var n=r.height,o=r.width,i=r.gravity,s=r.center,a=r.speed,h=r.clustering,u=r.nodeClusterBy,c=r.clusterGravity,l=n*o,f=Math.sqrt(l)/10,d=t.getAllNodes(),g=l/(d.length+1),p=Math.sqrt(g),y={};if(this.applyCalculate(t,y,p,g),h){for(var m in e)e[m].cx=0,e[m].cy=0,e[m].count=0;for(var m in d.forEach((function(t){var r=t.data,n=e[r[u]];x(r.x)&&(n.cx+=r.x),x(r.y)&&(n.cy+=r.y),n.count++})),e)e[m].cx/=e[m].count,e[m].cy/=e[m].count;var w=c||i;d.forEach((function(t,r){var n=t.id,o=t.data;if(x(o.x)&&x(o.y)){var i=e[o[u]],s=Math.sqrt((o.x-i.cx)*(o.x-i.cx)+(o.y-i.cy)*(o.y-i.cy)),a=p*w;y[n].x-=a*(o.x-i.cx)/s,y[n].y-=a*(o.y-i.cy)/s}}))}d.forEach((function(t,e){var r=t.id,n=t.data;if(x(n.x)&&x(n.y)){var o=.01*p*i;y[r].x-=o*(n.x-s[0]),y[r].y-=o*(n.y-s[1])}})),d.forEach((function(e,r){var n=e.id,o=e.data;if(x(o.fx)&&x(o.fy))return o.x=o.fx,void(o.y=o.fy);if(x(o.x)&&x(o.y)){var i=Math.sqrt(y[n].x*y[n].x+y[n].y*y[n].y);if(i>0){var s=Math.min(f*(a/800),i);t.mergeNodeData(n,{x:o.x+y[n].x/i*s,y:o.y+y[n].y/i*s})}}}))},t.prototype.applyCalculate=function(t,e,r,n){this.calRepulsive(t,e,n),this.calAttractive(t,e,r)},t.prototype.calRepulsive=function(t,e,r){var n=t.getAllNodes();n.forEach((function(t,o){var i=t.data,s=t.id;e[s]={x:0,y:0},n.forEach((function(t,n){var a=t.data,h=t.id;if(!(o<=n)&&x(i.x)&&x(a.x)&&x(i.y)&&x(a.y)){var u=i.x-a.x,c=i.y-a.y,l=u*u+c*c;0===l&&(l=1,u=.01,c=.01);var f=r/l,d=u*f,g=c*f;e[s].x+=d,e[s].y+=g,e[h].x-=d,e[h].y-=g}}))}))},t.prototype.calAttractive=function(t,e,r){t.getAllEdges().forEach((function(n){var o=n.source,i=n.target;if(o&&i&&o!==i){var s=t.getNode(o).data,a=t.getNode(i).data;if(x(a.x)&&x(s.x)&&x(a.y)&&x(s.y)){var h=a.x-s.x,u=a.y-s.y,c=Math.sqrt(h*h+u*u)/r,l=h*c,f=u*c;e[o].x+=l,e[o].y+=f,e[i].x-=l,e[i].y-=f}}}))},t}(),te={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},ee=function(){function t(t){void 0===t&&(t={}),this.options=t,this.id="grid",this.options=r(r({},te),t)}return t.prototype.execute=function(t,e){return o(this,void 0,void 0,(function(){return i(this,(function(r){return[2,this.genericGridLayout(!1,t,e)]}))}))},t.prototype.assign=function(t,e){return o(this,void 0,void 0,(function(){return i(this,(function(r){return this.genericGridLayout(!0,t,e),[2]}))}))},t.prototype.genericGridLayout=function(t,e,n){return o(this,void 0,void 0,(function(){var o,s,a,h,u,c,l,f,d,p,y,m,w,v,M,E,N,D,I,_,R,T,C,O,P,q,F,L,j,V,W,$,G,U,B,H,K;return i(this,(function(i){if(o=r(r({},this.options),n),s=o.begin,a=void 0===s?[0,0]:s,h=o.condense,u=o.preventOverlapPadding,c=o.preventOverlap,l=o.rows,f=o.cols,d=o.nodeSpacing,p=o.nodeSize,y=o.width,m=o.height,w=o.position,v=o.sortBy,M=e.getAllNodes(),E=e.getAllEdges(),!(N=null==M?void 0:M.length)||1===N)return[2,k(e,t,a)];if(D=M.map((function(t){return b(t)})),"id"===v||z(v)&&void 0!==D[0].data[v]||(v="degree"),"degree"===v?D.sort((function(t,r){return e.getDegree(r.id,"both")-e.getDegree(t.id,"both")})):"id"===v?D.sort((function(t,e){return x(e.id)&&x(t.id)?e.id-t.id:"".concat(t.id).localeCompare("".concat(e.id))})):D.sort((function(t,e){return e.data[v]-t.data[v]})),I=y||"undefined"==typeof window?y:window.innerWidth,_=m||"undefined"==typeof window?m:window.innerHeight,R=N,T={rows:l,cols:f},null!=l&&null!=f?(T.rows=l,T.cols=f):null!=l&&null==f?(T.rows=l,T.cols=Math.ceil(R/T.rows)):null==l&&null!=f?(T.cols=f,T.rows=Math.ceil(R/T.cols)):(C=Math.sqrt(R*_/I),T.rows=Math.round(C),T.cols=Math.round(I/_*C)),T.rows=Math.max(T.rows,1),T.cols=Math.max(T.cols,1),T.cols*T.rows>R)O=re(T),P=ne(T),(O-1)*P>=R?re(T,O-1):(P-1)*O>=R&&ne(T,P-1);else for(;T.cols*T.rows<R;)O=re(T),((P=ne(T))+1)*O>=R?ne(T,P+1):re(T,O+1);for(q=h?0:I/T.cols,F=h?0:_/T.rows,(c||d)&&(L=S(10,d),j=A(30,p,!1),D.forEach((function(t){t.data.x&&t.data.y||(t.data.x=0,t.data.y=0);var r,n,o=e.getNode(t.id),i=j(o)||30;g(i)?(r=i[0],n=i[1]):(r=i,n=i);var s=void 0!==L?L(t):u,a=r+s,h=n+s;q=Math.max(q,a),F=Math.max(F,h)}))),V={},W={row:0,col:0},$={},G=0;G<D.length;G++){if(U=D[G],B=void 0,w&&(B=w(e.getNode(U.id))),B&&(void 0!==B.row||void 0!==B.col)){if(void 0===(H={row:B.row,col:B.col}).col)for(H.col=0;oe(V,H);)H.col++;else if(void 0===H.row)for(H.row=0;oe(V,H);)H.row++;$[U.id]=H,ie(V,H)}ae(U,a,q,F,$,T,W,V)}return K={nodes:D,edges:E},t&&D.forEach((function(t){e.mergeNodeData(t.id,{x:t.data.x,y:t.data.y})})),[2,K]}))}))},t}(),re=function(t,e){var r,n=t.rows||5,o=t.cols||5;return null==e?r=Math.min(n,o):Math.min(n,o)===t.rows?t.rows=e:t.cols=e,r},ne=function(t,e){var r,n=t.rows||5,o=t.cols||5;return null==e?r=Math.max(n,o):Math.max(n,o)===t.rows?t.rows=e:t.cols=e,r},oe=function(t,e){return t["c-".concat(e.row,"-").concat(e.col)]||!1},ie=function(t,e){return t["c-".concat(e.row,"-").concat(e.col)]=!0},se=function(t,e){var r=t.cols||5;e.col++,e.col>=r&&(e.col=0,e.row++)},ae=function(t,e,r,n,o,i,s,a){var h,u,c=o[t.id];if(c)h=c.col*r+r/2+e[0],u=c.row*n+n/2+e[1];else{for(;oe(a,s);)se(i,s);h=s.col*r+r/2+e[0],u=s.row*n+n/2+e[1],ie(a,s),se(i,s)}t.data.x=h,t.data.y=u};const he=Object.prototype.toString;function ue(t){return he.call(t).endsWith("Array]")}function ce(t){var e,r=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};if(!ue(t))throw new TypeError("input must be an array");if(0===t.length)throw new TypeError("input must not be empty");if(void 0!==r.output){if(!ue(r.output))throw new TypeError("output option must be an array if specified");e=r.output}else e=new Array(t.length);var n=function(t){var e=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};if(!ue(t))throw new TypeError("input must be an array");if(0===t.length)throw new TypeError("input must not be empty");var r=e.fromIndex,n=void 0===r?0:r,o=e.toIndex,i=void 0===o?t.length:o;if(n<0||n>=t.length||!Number.isInteger(n))throw new Error("fromIndex must be a positive integer smaller than length");if(i<=n||i>t.length||!Number.isInteger(i))throw new Error("toIndex must be an integer greater than fromIndex and at most equal to length");for(var s=t[n],a=n+1;a<i;a++)t[a]<s&&(s=t[a]);return s}(t),o=function(t){var e=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};if(!ue(t))throw new TypeError("input must be an array");if(0===t.length)throw new TypeError("input must not be empty");var r=e.fromIndex,n=void 0===r?0:r,o=e.toIndex,i=void 0===o?t.length:o;if(n<0||n>=t.length||!Number.isInteger(n))throw new Error("fromIndex must be a positive integer smaller than length");if(i<=n||i>t.length||!Number.isInteger(i))throw new Error("toIndex must be an integer greater than fromIndex and at most equal to length");for(var s=t[n],a=n+1;a<i;a++)t[a]>s&&(s=t[a]);return s}(t);if(n===o)throw new RangeError("minimum and maximum input values are equal. Cannot rescale a constant array");var i=r.min,s=void 0===i?r.autoMinMax?n:0:i,a=r.max,h=void 0===a?r.autoMinMax?o:1:a;if(s>=h)throw new RangeError("min option must be smaller than max option");for(var u=(h-s)/(o-n),c=0;c<t.length;c++)e[c]=(t[c]-n)*u+s;return e}const le=" ".repeat(2),fe=" ".repeat(4);function de(t,e={}){const{maxRows:r=15,maxColumns:n=10,maxNumSize:o=8,padMinus:i="auto"}=e;return`${t.constructor.name} {\\n${le}[\\n${fe}${function(t,e,r,n,o){const{rows:i,columns:s}=t,a=Math.min(i,e),h=Math.min(s,r),u=[];if("auto"===o){o=!1;t:for(let e=0;e<a;e++)for(let r=0;r<h;r++)if(t.get(e,r)<0){o=!0;break t}}for(let e=0;e<a;e++){let r=[];for(let i=0;i<h;i++)r.push(ge(t.get(e,i),n,o));u.push(`${r.join(" ")}`)}return h!==s&&(u[u.length-1]+=` ... ${s-r} more columns`),a!==i&&u.push(`... ${i-e} more rows`),u.join(`\\n${fe}`)}(t,r,n,o,i)}\\n${le}]\\n${le}rows: ${t.rows}\\n${le}columns: ${t.columns}\\n}`}function ge(t,e,r){return(t>=0&&r?` ${pe(t,e-1)}`:pe(t,e)).padEnd(e)}function pe(t,e){let r=t.toString();if(r.length<=e)return r;let n=t.toFixed(e);if(n.length>e&&(n=t.toFixed(Math.max(0,e-(n.length-e)))),n.length<=e&&!n.startsWith("0.000")&&!n.startsWith("-0.000"))return n;let o=t.toExponential(e);return o.length>e&&(o=t.toExponential(Math.max(0,e-(o.length-e)))),o.slice(0)}function ye(t,e,r){let n=r?t.rows:t.rows-1;if(e<0||e>n)throw new RangeError("Row index out of range")}function me(t,e,r){let n=r?t.columns:t.columns-1;if(e<0||e>n)throw new RangeError("Column index out of range")}function we(t,e){if(e.to1DArray&&(e=e.to1DArray()),e.length!==t.columns)throw new RangeError("vector size must be the same as the number of columns");return e}function ve(t,e){if(e.to1DArray&&(e=e.to1DArray()),e.length!==t.rows)throw new RangeError("vector size must be the same as the number of rows");return e}function xe(t,e,r,n,o){if(5!==arguments.length)throw new RangeError("expected 4 arguments");if(be("startRow",e),be("endRow",r),be("startColumn",n),be("endColumn",o),e>r||n>o||e<0||e>=t.rows||r<0||r>=t.rows||n<0||n>=t.columns||o<0||o>=t.columns)throw new RangeError("Submatrix indices are out of range")}function Me(t,e=0){let r=[];for(let n=0;n<t;n++)r.push(e);return r}function be(t,e){if("number"!=typeof e)throw new TypeError(`${t} must be a number`)}function Ee(t){if(t.isEmpty())throw new Error("Empty matrix has no elements to index")}class Ne{static from1DArray(t,e,r){if(t*e!==r.length)throw new RangeError("data length does not match given dimensions");let n=new Ae(t,e);for(let o=0;o<t;o++)for(let t=0;t<e;t++)n.set(o,t,r[o*e+t]);return n}static rowVector(t){let e=new Ae(1,t.length);for(let r=0;r<t.length;r++)e.set(0,r,t[r]);return e}static columnVector(t){let e=new Ae(t.length,1);for(let r=0;r<t.length;r++)e.set(r,0,t[r]);return e}static zeros(t,e){return new Ae(t,e)}static ones(t,e){return new Ae(t,e).fill(1)}static rand(t,e,r={}){if("object"!=typeof r)throw new TypeError("options must be an object");const{random:n=Math.random}=r;let o=new Ae(t,e);for(let r=0;r<t;r++)for(let t=0;t<e;t++)o.set(r,t,n());return o}static randInt(t,e,r={}){if("object"!=typeof r)throw new TypeError("options must be an object");const{min:n=0,max:o=1e3,random:i=Math.random}=r;if(!Number.isInteger(n))throw new TypeError("min must be an integer");if(!Number.isInteger(o))throw new TypeError("max must be an integer");if(n>=o)throw new RangeError("min must be smaller than max");let s=o-n,a=new Ae(t,e);for(let r=0;r<t;r++)for(let t=0;t<e;t++){let e=n+Math.round(i()*s);a.set(r,t,e)}return a}static eye(t,e,r){void 0===e&&(e=t),void 0===r&&(r=1);let n=Math.min(t,e),o=this.zeros(t,e);for(let t=0;t<n;t++)o.set(t,t,r);return o}static diag(t,e,r){let n=t.length;void 0===e&&(e=n),void 0===r&&(r=e);let o=Math.min(n,e,r),i=this.zeros(e,r);for(let e=0;e<o;e++)i.set(e,e,t[e]);return i}static min(t,e){t=this.checkMatrix(t),e=this.checkMatrix(e);let r=t.rows,n=t.columns,o=new Ae(r,n);for(let i=0;i<r;i++)for(let r=0;r<n;r++)o.set(i,r,Math.min(t.get(i,r),e.get(i,r)));return o}static max(t,e){t=this.checkMatrix(t),e=this.checkMatrix(e);let r=t.rows,n=t.columns,o=new this(r,n);for(let i=0;i<r;i++)for(let r=0;r<n;r++)o.set(i,r,Math.max(t.get(i,r),e.get(i,r)));return o}static checkMatrix(t){return Ne.isMatrix(t)?t:new Ae(t)}static isMatrix(t){return null!=t&&"Matrix"===t.klass}get size(){return this.rows*this.columns}apply(t){if("function"!=typeof t)throw new TypeError("callback must be a function");for(let e=0;e<this.rows;e++)for(let r=0;r<this.columns;r++)t.call(this,e,r);return this}to1DArray(){let t=[];for(let e=0;e<this.rows;e++)for(let r=0;r<this.columns;r++)t.push(this.get(e,r));return t}to2DArray(){let t=[];for(let e=0;e<this.rows;e++){t.push([]);for(let r=0;r<this.columns;r++)t[e].push(this.get(e,r))}return t}toJSON(){return this.to2DArray()}isRowVector(){return 1===this.rows}isColumnVector(){return 1===this.columns}isVector(){return 1===this.rows||1===this.columns}isSquare(){return this.rows===this.columns}isEmpty(){return 0===this.rows||0===this.columns}isSymmetric(){if(this.isSquare()){for(let t=0;t<this.rows;t++)for(let e=0;e<=t;e++)if(this.get(t,e)!==this.get(e,t))return!1;return!0}return!1}isEchelonForm(){let t=0,e=0,r=-1,n=!0,o=!1;for(;t<this.rows&&n;){for(e=0,o=!1;e<this.columns&&!1===o;)0===this.get(t,e)?e++:1===this.get(t,e)&&e>r?(o=!0,r=e):(n=!1,o=!0);t++}return n}isReducedEchelonForm(){let t=0,e=0,r=-1,n=!0,o=!1;for(;t<this.rows&&n;){for(e=0,o=!1;e<this.columns&&!1===o;)0===this.get(t,e)?e++:1===this.get(t,e)&&e>r?(o=!0,r=e):(n=!1,o=!0);for(let r=e+1;r<this.rows;r++)0!==this.get(t,r)&&(n=!1);t++}return n}echelonForm(){let t=this.clone(),e=0,r=0;for(;e<t.rows&&r<t.columns;){let n=e;for(let o=e;o<t.rows;o++)t.get(o,r)>t.get(n,r)&&(n=o);if(0===t.get(n,r))r++;else{t.swapRows(e,n);let o=t.get(e,r);for(let n=r;n<t.columns;n++)t.set(e,n,t.get(e,n)/o);for(let n=e+1;n<t.rows;n++){let o=t.get(n,r)/t.get(e,r);t.set(n,r,0);for(let i=r+1;i<t.columns;i++)t.set(n,i,t.get(n,i)-t.get(e,i)*o)}e++,r++}}return t}reducedEchelonForm(){let t=this.echelonForm(),e=t.columns,r=t.rows,n=r-1;for(;n>=0;)if(0===t.maxRow(n))n--;else{let o=0,i=!1;for(;o<r&&!1===i;)1===t.get(n,o)?i=!0:o++;for(let r=0;r<n;r++){let i=t.get(r,o);for(let s=o;s<e;s++){let e=t.get(r,s)-i*t.get(n,s);t.set(r,s,e)}}n--}return t}set(){throw new Error("set method is unimplemented")}get(){throw new Error("get method is unimplemented")}repeat(t={}){if("object"!=typeof t)throw new TypeError("options must be an object");const{rows:e=1,columns:r=1}=t;if(!Number.isInteger(e)||e<=0)throw new TypeError("rows must be a positive integer");if(!Number.isInteger(r)||r<=0)throw new TypeError("columns must be a positive integer");let n=new Ae(this.rows*e,this.columns*r);for(let t=0;t<e;t++)for(let e=0;e<r;e++)n.setSubMatrix(this,this.rows*t,this.columns*e);return n}fill(t){for(let e=0;e<this.rows;e++)for(let r=0;r<this.columns;r++)this.set(e,r,t);return this}neg(){return this.mulS(-1)}getRow(t){ye(this,t);let e=[];for(let r=0;r<this.columns;r++)e.push(this.get(t,r));return e}getRowVector(t){return Ae.rowVector(this.getRow(t))}setRow(t,e){ye(this,t),e=we(this,e);for(let r=0;r<this.columns;r++)this.set(t,r,e[r]);return this}swapRows(t,e){ye(this,t),ye(this,e);for(let r=0;r<this.columns;r++){let n=this.get(t,r);this.set(t,r,this.get(e,r)),this.set(e,r,n)}return this}getColumn(t){me(this,t);let e=[];for(let r=0;r<this.rows;r++)e.push(this.get(r,t));return e}getColumnVector(t){return Ae.columnVector(this.getColumn(t))}setColumn(t,e){me(this,t),e=ve(this,e);for(let r=0;r<this.rows;r++)this.set(r,t,e[r]);return this}swapColumns(t,e){me(this,t),me(this,e);for(let r=0;r<this.rows;r++){let n=this.get(r,t);this.set(r,t,this.get(r,e)),this.set(r,e,n)}return this}addRowVector(t){t=we(this,t);for(let e=0;e<this.rows;e++)for(let r=0;r<this.columns;r++)this.set(e,r,this.get(e,r)+t[r]);return this}subRowVector(t){t=we(this,t);for(let e=0;e<this.rows;e++)for(let r=0;r<this.columns;r++)this.set(e,r,this.get(e,r)-t[r]);return this}mulRowVector(t){t=we(this,t);for(let e=0;e<this.rows;e++)for(let r=0;r<this.columns;r++)this.set(e,r,this.get(e,r)*t[r]);return this}divRowVector(t){t=we(this,t);for(let e=0;e<this.rows;e++)for(let r=0;r<this.columns;r++)this.set(e,r,this.get(e,r)/t[r]);return this}addColumnVector(t){t=ve(this,t);for(let e=0;e<this.rows;e++)for(let r=0;r<this.columns;r++)this.set(e,r,this.get(e,r)+t[e]);return this}subColumnVector(t){t=ve(this,t);for(let e=0;e<this.rows;e++)for(let r=0;r<this.columns;r++)this.set(e,r,this.get(e,r)-t[e]);return this}mulColumnVector(t){t=ve(this,t);for(let e=0;e<this.rows;e++)for(let r=0;r<this.columns;r++)this.set(e,r,this.get(e,r)*t[e]);return this}divColumnVector(t){t=ve(this,t);for(let e=0;e<this.rows;e++)for(let r=0;r<this.columns;r++)this.set(e,r,this.get(e,r)/t[e]);return this}mulRow(t,e){ye(this,t);for(let r=0;r<this.columns;r++)this.set(t,r,this.get(t,r)*e);return this}mulColumn(t,e){me(this,t);for(let r=0;r<this.rows;r++)this.set(r,t,this.get(r,t)*e);return this}max(t){if(this.isEmpty())return NaN;switch(t){case"row":{const t=new Array(this.rows).fill(Number.NEGATIVE_INFINITY);for(let e=0;e<this.rows;e++)for(let r=0;r<this.columns;r++)this.get(e,r)>t[e]&&(t[e]=this.get(e,r));return t}case"column":{const t=new Array(this.columns).fill(Number.NEGATIVE_INFINITY);for(let e=0;e<this.rows;e++)for(let r=0;r<this.columns;r++)this.get(e,r)>t[r]&&(t[r]=this.get(e,r));return t}case void 0:{let t=this.get(0,0);for(let e=0;e<this.rows;e++)for(let r=0;r<this.columns;r++)this.get(e,r)>t&&(t=this.get(e,r));return t}default:throw new Error(`invalid option: ${t}`)}}maxIndex(){Ee(this);let t=this.get(0,0),e=[0,0];for(let r=0;r<this.rows;r++)for(let n=0;n<this.columns;n++)this.get(r,n)>t&&(t=this.get(r,n),e[0]=r,e[1]=n);return e}min(t){if(this.isEmpty())return NaN;switch(t){case"row":{const t=new Array(this.rows).fill(Number.POSITIVE_INFINITY);for(let e=0;e<this.rows;e++)for(let r=0;r<this.columns;r++)this.get(e,r)<t[e]&&(t[e]=this.get(e,r));return t}case"column":{const t=new Array(this.columns).fill(Number.POSITIVE_INFINITY);for(let e=0;e<this.rows;e++)for(let r=0;r<this.columns;r++)this.get(e,r)<t[r]&&(t[r]=this.get(e,r));return t}case void 0:{let t=this.get(0,0);for(let e=0;e<this.rows;e++)for(let r=0;r<this.columns;r++)this.get(e,r)<t&&(t=this.get(e,r));return t}default:throw new Error(`invalid option: ${t}`)}}minIndex(){Ee(this);let t=this.get(0,0),e=[0,0];for(let r=0;r<this.rows;r++)for(let n=0;n<this.columns;n++)this.get(r,n)<t&&(t=this.get(r,n),e[0]=r,e[1]=n);return e}maxRow(t){if(ye(this,t),this.isEmpty())return NaN;let e=this.get(t,0);for(let r=1;r<this.columns;r++)this.get(t,r)>e&&(e=this.get(t,r));return e}maxRowIndex(t){ye(this,t),Ee(this);let e=this.get(t,0),r=[t,0];for(let n=1;n<this.columns;n++)this.get(t,n)>e&&(e=this.get(t,n),r[1]=n);return r}minRow(t){if(ye(this,t),this.isEmpty())return NaN;let e=this.get(t,0);for(let r=1;r<this.columns;r++)this.get(t,r)<e&&(e=this.get(t,r));return e}minRowIndex(t){ye(this,t),Ee(this);let e=this.get(t,0),r=[t,0];for(let n=1;n<this.columns;n++)this.get(t,n)<e&&(e=this.get(t,n),r[1]=n);return r}maxColumn(t){if(me(this,t),this.isEmpty())return NaN;let e=this.get(0,t);for(let r=1;r<this.rows;r++)this.get(r,t)>e&&(e=this.get(r,t));return e}maxColumnIndex(t){me(this,t),Ee(this);let e=this.get(0,t),r=[0,t];for(let n=1;n<this.rows;n++)this.get(n,t)>e&&(e=this.get(n,t),r[0]=n);return r}minColumn(t){if(me(this,t),this.isEmpty())return NaN;let e=this.get(0,t);for(let r=1;r<this.rows;r++)this.get(r,t)<e&&(e=this.get(r,t));return e}minColumnIndex(t){me(this,t),Ee(this);let e=this.get(0,t),r=[0,t];for(let n=1;n<this.rows;n++)this.get(n,t)<e&&(e=this.get(n,t),r[0]=n);return r}diag(){let t=Math.min(this.rows,this.columns),e=[];for(let r=0;r<t;r++)e.push(this.get(r,r));return e}norm(t="frobenius"){let e=0;if("max"===t)return this.max();if("frobenius"===t){for(let t=0;t<this.rows;t++)for(let r=0;r<this.columns;r++)e+=this.get(t,r)*this.get(t,r);return Math.sqrt(e)}throw new RangeError(`unknown norm type: ${t}`)}cumulativeSum(){let t=0;for(let e=0;e<this.rows;e++)for(let r=0;r<this.columns;r++)t+=this.get(e,r),this.set(e,r,t);return this}dot(t){Ne.isMatrix(t)&&(t=t.to1DArray());let e=this.to1DArray();if(e.length!==t.length)throw new RangeError("vectors do not have the same size");let r=0;for(let n=0;n<e.length;n++)r+=e[n]*t[n];return r}mmul(t){t=Ae.checkMatrix(t);let e=this.rows,r=this.columns,n=t.columns,o=new Ae(e,n),i=new Float64Array(r);for(let s=0;s<n;s++){for(let e=0;e<r;e++)i[e]=t.get(e,s);for(let t=0;t<e;t++){let e=0;for(let n=0;n<r;n++)e+=this.get(t,n)*i[n];o.set(t,s,e)}}return o}strassen2x2(t){t=Ae.checkMatrix(t);let e=new Ae(2,2);const r=this.get(0,0),n=t.get(0,0),o=this.get(0,1),i=t.get(0,1),s=this.get(1,0),a=t.get(1,0),h=this.get(1,1),u=t.get(1,1),c=(r+h)*(n+u),l=(s+h)*n,f=r*(i-u),d=h*(a-n),g=(r+o)*u,p=c+d-g+(o-h)*(a+u),y=f+g,m=l+d,w=c-l+f+(s-r)*(n+i);return e.set(0,0,p),e.set(0,1,y),e.set(1,0,m),e.set(1,1,w),e}strassen3x3(t){t=Ae.checkMatrix(t);let e=new Ae(3,3);const r=this.get(0,0),n=this.get(0,1),o=this.get(0,2),i=this.get(1,0),s=this.get(1,1),a=this.get(1,2),h=this.get(2,0),u=this.get(2,1),c=this.get(2,2),l=t.get(0,0),f=t.get(0,1),d=t.get(0,2),g=t.get(1,0),p=t.get(1,1),y=t.get(1,2),m=t.get(2,0),w=t.get(2,1),v=t.get(2,2),x=(r-i)*(-f+p),M=(-r+i+s)*(l-f+p),b=(i+s)*(-l+f),E=r*l,N=(-r+h+u)*(l-d+y),S=(-r+h)*(d-y),A=(h+u)*(-l+d),k=(-o+u+c)*(p+m-w),D=(o-c)*(p-w),I=o*m,_=(u+c)*(-m+w),R=(-o+s+a)*(y+m-v),z=(o-a)*(y-v),T=(s+a)*(-m+v),C=E+I+n*g,O=(r+n+o-i-s-u-c)*p+M+b+E+k+I+_,P=E+N+A+(r+n+o-s-a-h-u)*y+I+R+T,q=x+s*(-l+f+g-p-y-m+v)+M+E+I+R+z,F=x+M+b+E+a*w,L=I+R+z+T+i*d,j=E+N+S+u*(-l+d+g-p-y-m+w)+k+D+I,V=k+D+I+_+h*f,W=E+N+S+A+c*v;return e.set(0,0,C),e.set(0,1,O),e.set(0,2,P),e.set(1,0,q),e.set(1,1,F),e.set(1,2,L),e.set(2,0,j),e.set(2,1,V),e.set(2,2,W),e}mmulStrassen(t){t=Ae.checkMatrix(t);let e=this.clone(),r=e.rows,n=e.columns,o=t.rows,i=t.columns;function s(t,e,r){let n=t.rows,o=t.columns;if(n===e&&o===r)return t;{let n=Ne.zeros(e,r);return n=n.setSubMatrix(t,0,0),n}}n!==o&&console.warn(`Multiplying ${r} x ${n} and ${o} x ${i} matrix: dimensions do not match.`);let a=Math.max(r,o),h=Math.max(n,i);return e=s(e,a,h),function t(e,r,n,o){if(n<=512||o<=512)return e.mmul(r);n%2==1&&o%2==1?(e=s(e,n+1,o+1),r=s(r,n+1,o+1)):n%2==1?(e=s(e,n+1,o),r=s(r,n+1,o)):o%2==1&&(e=s(e,n,o+1),r=s(r,n,o+1));let i=parseInt(e.rows/2,10),a=parseInt(e.columns/2,10),h=e.subMatrix(0,i-1,0,a-1),u=r.subMatrix(0,i-1,0,a-1),c=e.subMatrix(0,i-1,a,e.columns-1),l=r.subMatrix(0,i-1,a,r.columns-1),f=e.subMatrix(i,e.rows-1,0,a-1),d=r.subMatrix(i,r.rows-1,0,a-1),g=e.subMatrix(i,e.rows-1,a,e.columns-1),p=r.subMatrix(i,r.rows-1,a,r.columns-1),y=t(Ne.add(h,g),Ne.add(u,p),i,a),m=t(Ne.add(f,g),u,i,a),w=t(h,Ne.sub(l,p),i,a),v=t(g,Ne.sub(d,u),i,a),x=t(Ne.add(h,c),p,i,a),M=t(Ne.sub(f,h),Ne.add(u,l),i,a),b=t(Ne.sub(c,g),Ne.add(d,p),i,a),E=Ne.add(y,v);E.sub(x),E.add(b);let N=Ne.add(w,x),S=Ne.add(m,v),A=Ne.sub(y,m);A.add(w),A.add(M);let k=Ne.zeros(2*E.rows,2*E.columns);return k=k.setSubMatrix(E,0,0),k=k.setSubMatrix(N,E.rows,0),k=k.setSubMatrix(S,0,E.columns),k=k.setSubMatrix(A,E.rows,E.columns),k.subMatrix(0,n-1,0,o-1)}(e,t=s(t,a,h),a,h)}scaleRows(t={}){if("object"!=typeof t)throw new TypeError("options must be an object");const{min:e=0,max:r=1}=t;if(!Number.isFinite(e))throw new TypeError("min must be a number");if(!Number.isFinite(r))throw new TypeError("max must be a number");if(e>=r)throw new RangeError("min must be smaller than max");let n=new Ae(this.rows,this.columns);for(let t=0;t<this.rows;t++){const o=this.getRow(t);o.length>0&&ce(o,{min:e,max:r,output:o}),n.setRow(t,o)}return n}scaleColumns(t={}){if("object"!=typeof t)throw new TypeError("options must be an object");const{min:e=0,max:r=1}=t;if(!Number.isFinite(e))throw new TypeError("min must be a number");if(!Number.isFinite(r))throw new TypeError("max must be a number");if(e>=r)throw new RangeError("min must be smaller than max");let n=new Ae(this.rows,this.columns);for(let t=0;t<this.columns;t++){const o=this.getColumn(t);o.length&&ce(o,{min:e,max:r,output:o}),n.setColumn(t,o)}return n}flipRows(){const t=Math.ceil(this.columns/2);for(let e=0;e<this.rows;e++)for(let r=0;r<t;r++){let t=this.get(e,r),n=this.get(e,this.columns-1-r);this.set(e,r,n),this.set(e,this.columns-1-r,t)}return this}flipColumns(){const t=Math.ceil(this.rows/2);for(let e=0;e<this.columns;e++)for(let r=0;r<t;r++){let t=this.get(r,e),n=this.get(this.rows-1-r,e);this.set(r,e,n),this.set(this.rows-1-r,e,t)}return this}kroneckerProduct(t){t=Ae.checkMatrix(t);let e=this.rows,r=this.columns,n=t.rows,o=t.columns,i=new Ae(e*n,r*o);for(let s=0;s<e;s++)for(let e=0;e<r;e++)for(let r=0;r<n;r++)for(let a=0;a<o;a++)i.set(n*s+r,o*e+a,this.get(s,e)*t.get(r,a));return i}kroneckerSum(t){if(t=Ae.checkMatrix(t),!this.isSquare()||!t.isSquare())throw new Error("Kronecker Sum needs two Square Matrices");let e=this.rows,r=t.rows,n=this.kroneckerProduct(Ae.eye(r,r)),o=Ae.eye(e,e).kroneckerProduct(t);return n.add(o)}transpose(){let t=new Ae(this.columns,this.rows);for(let e=0;e<this.rows;e++)for(let r=0;r<this.columns;r++)t.set(r,e,this.get(e,r));return t}sortRows(t=Se){for(let e=0;e<this.rows;e++)this.setRow(e,this.getRow(e).sort(t));return this}sortColumns(t=Se){for(let e=0;e<this.columns;e++)this.setColumn(e,this.getColumn(e).sort(t));return this}subMatrix(t,e,r,n){xe(this,t,e,r,n);let o=new Ae(e-t+1,n-r+1);for(let i=t;i<=e;i++)for(let e=r;e<=n;e++)o.set(i-t,e-r,this.get(i,e));return o}subMatrixRow(t,e,r){if(void 0===e&&(e=0),void 0===r&&(r=this.columns-1),e>r||e<0||e>=this.columns||r<0||r>=this.columns)throw new RangeError("Argument out of range");let n=new Ae(t.length,r-e+1);for(let o=0;o<t.length;o++)for(let i=e;i<=r;i++){if(t[o]<0||t[o]>=this.rows)throw new RangeError(`Row index out of range: ${t[o]}`);n.set(o,i-e,this.get(t[o],i))}return n}subMatrixColumn(t,e,r){if(void 0===e&&(e=0),void 0===r&&(r=this.rows-1),e>r||e<0||e>=this.rows||r<0||r>=this.rows)throw new RangeError("Argument out of range");let n=new Ae(r-e+1,t.length);for(let o=0;o<t.length;o++)for(let i=e;i<=r;i++){if(t[o]<0||t[o]>=this.columns)throw new RangeError(`Column index out of range: ${t[o]}`);n.set(i-e,o,this.get(i,t[o]))}return n}setSubMatrix(t,e,r){if((t=Ae.checkMatrix(t)).isEmpty())return this;xe(this,e,e+t.rows-1,r,r+t.columns-1);for(let n=0;n<t.rows;n++)for(let o=0;o<t.columns;o++)this.set(e+n,r+o,t.get(n,o));return this}selection(t,e){!function(t,e){if(!ue(e))throw new TypeError("row indices must be an array");for(let r=0;r<e.length;r++)if(e[r]<0||e[r]>=t.rows)throw new RangeError("row indices are out of range")}(this,t),function(t,e){if(!ue(e))throw new TypeError("column indices must be an array");for(let r=0;r<e.length;r++)if(e[r]<0||e[r]>=t.columns)throw new RangeError("column indices are out of range")}(this,e);let r=new Ae(t.length,e.length);for(let n=0;n<t.length;n++){let o=t[n];for(let t=0;t<e.length;t++){let i=e[t];r.set(n,t,this.get(o,i))}}return r}trace(){let t=Math.min(this.rows,this.columns),e=0;for(let r=0;r<t;r++)e+=this.get(r,r);return e}clone(){let t=new Ae(this.rows,this.columns);for(let e=0;e<this.rows;e++)for(let r=0;r<this.columns;r++)t.set(e,r,this.get(e,r));return t}sum(t){switch(t){case"row":return function(t){let e=Me(t.rows);for(let r=0;r<t.rows;++r)for(let n=0;n<t.columns;++n)e[r]+=t.get(r,n);return e}(this);case"column":return function(t){let e=Me(t.columns);for(let r=0;r<t.rows;++r)for(let n=0;n<t.columns;++n)e[n]+=t.get(r,n);return e}(this);case void 0:return function(t){let e=0;for(let r=0;r<t.rows;r++)for(let n=0;n<t.columns;n++)e+=t.get(r,n);return e}(this);default:throw new Error(`invalid option: ${t}`)}}product(t){switch(t){case"row":return function(t){let e=Me(t.rows,1);for(let r=0;r<t.rows;++r)for(let n=0;n<t.columns;++n)e[r]*=t.get(r,n);return e}(this);case"column":return function(t){let e=Me(t.columns,1);for(let r=0;r<t.rows;++r)for(let n=0;n<t.columns;++n)e[n]*=t.get(r,n);return e}(this);case void 0:return function(t){let e=1;for(let r=0;r<t.rows;r++)for(let n=0;n<t.columns;n++)e*=t.get(r,n);return e}(this);default:throw new Error(`invalid option: ${t}`)}}mean(t){const e=this.sum(t);switch(t){case"row":for(let t=0;t<this.rows;t++)e[t]/=this.columns;return e;case"column":for(let t=0;t<this.columns;t++)e[t]/=this.rows;return e;case void 0:return e/this.size;default:throw new Error(`invalid option: ${t}`)}}variance(t,e={}){if("object"==typeof t&&(e=t,t=void 0),"object"!=typeof e)throw new TypeError("options must be an object");const{unbiased:r=!0,mean:n=this.mean(t)}=e;if("boolean"!=typeof r)throw new TypeError("unbiased must be a boolean");switch(t){case"row":if(!ue(n))throw new TypeError("mean must be an array");return function(t,e,r){const n=t.rows,o=t.columns,i=[];for(let s=0;s<n;s++){let n=0,a=0,h=0;for(let e=0;e<o;e++)h=t.get(s,e)-r[s],n+=h,a+=h*h;e?i.push((a-n*n/o)/(o-1)):i.push((a-n*n/o)/o)}return i}(this,r,n);case"column":if(!ue(n))throw new TypeError("mean must be an array");return function(t,e,r){const n=t.rows,o=t.columns,i=[];for(let s=0;s<o;s++){let o=0,a=0,h=0;for(let e=0;e<n;e++)h=t.get(e,s)-r[s],o+=h,a+=h*h;e?i.push((a-o*o/n)/(n-1)):i.push((a-o*o/n)/n)}return i}(this,r,n);case void 0:if("number"!=typeof n)throw new TypeError("mean must be a number");return function(t,e,r){const n=t.rows,o=t.columns,i=n*o;let s=0,a=0,h=0;for(let e=0;e<n;e++)for(let n=0;n<o;n++)h=t.get(e,n)-r,s+=h,a+=h*h;return e?(a-s*s/i)/(i-1):(a-s*s/i)/i}(this,r,n);default:throw new Error(`invalid option: ${t}`)}}standardDeviation(t,e){"object"==typeof t&&(e=t,t=void 0);const r=this.variance(t,e);if(void 0===t)return Math.sqrt(r);for(let t=0;t<r.length;t++)r[t]=Math.sqrt(r[t]);return r}center(t,e={}){if("object"==typeof t&&(e=t,t=void 0),"object"!=typeof e)throw new TypeError("options must be an object");const{center:r=this.mean(t)}=e;switch(t){case"row":if(!ue(r))throw new TypeError("center must be an array");return function(t,e){for(let r=0;r<t.rows;r++)for(let n=0;n<t.columns;n++)t.set(r,n,t.get(r,n)-e[r])}(this,r),this;case"column":if(!ue(r))throw new TypeError("center must be an array");return function(t,e){for(let r=0;r<t.rows;r++)for(let n=0;n<t.columns;n++)t.set(r,n,t.get(r,n)-e[n])}(this,r),this;case void 0:if("number"!=typeof r)throw new TypeError("center must be a number");return function(t,e){for(let r=0;r<t.rows;r++)for(let n=0;n<t.columns;n++)t.set(r,n,t.get(r,n)-e)}(this,r),this;default:throw new Error(`invalid option: ${t}`)}}scale(t,e={}){if("object"==typeof t&&(e=t,t=void 0),"object"!=typeof e)throw new TypeError("options must be an object");let r=e.scale;switch(t){case"row":if(void 0===r)r=function(t){const e=[];for(let r=0;r<t.rows;r++){let n=0;for(let e=0;e<t.columns;e++)n+=Math.pow(t.get(r,e),2)/(t.columns-1);e.push(Math.sqrt(n))}return e}(this);else if(!ue(r))throw new TypeError("scale must be an array");return function(t,e){for(let r=0;r<t.rows;r++)for(let n=0;n<t.columns;n++)t.set(r,n,t.get(r,n)/e[r])}(this,r),this;case"column":if(void 0===r)r=function(t){const e=[];for(let r=0;r<t.columns;r++){let n=0;for(let e=0;e<t.rows;e++)n+=Math.pow(t.get(e,r),2)/(t.rows-1);e.push(Math.sqrt(n))}return e}(this);else if(!ue(r))throw new TypeError("scale must be an array");return function(t,e){for(let r=0;r<t.rows;r++)for(let n=0;n<t.columns;n++)t.set(r,n,t.get(r,n)/e[n])}(this,r),this;case void 0:if(void 0===r)r=function(t){const e=t.size-1;let r=0;for(let n=0;n<t.columns;n++)for(let o=0;o<t.rows;o++)r+=Math.pow(t.get(o,n),2)/e;return Math.sqrt(r)}(this);else if("number"!=typeof r)throw new TypeError("scale must be a number");return function(t,e){for(let r=0;r<t.rows;r++)for(let n=0;n<t.columns;n++)t.set(r,n,t.get(r,n)/e)}(this,r),this;default:throw new Error(`invalid option: ${t}`)}}toString(t){return de(this,t)}}function Se(t,e){return t-e}Ne.prototype.klass="Matrix","undefined"!=typeof Symbol&&(Ne.prototype[Symbol.for("nodejs.util.inspect.custom")]=function(){return de(this)}),Ne.random=Ne.rand,Ne.randomInt=Ne.randInt,Ne.diagonal=Ne.diag,Ne.prototype.diagonal=Ne.prototype.diag,Ne.identity=Ne.eye,Ne.prototype.negate=Ne.prototype.neg,Ne.prototype.tensorProduct=Ne.prototype.kroneckerProduct;class Ae extends Ne{constructor(t,e){if(super(),Ae.isMatrix(t))return t.clone();if(Number.isInteger(t)&&t>=0){if(this.data=[],!(Number.isInteger(e)&&e>=0))throw new TypeError("nColumns must be a positive integer");for(let r=0;r<t;r++)this.data.push(new Float64Array(e))}else{if(!ue(t))throw new TypeError("First argument must be a positive number or an array");{const r=t;if("number"!=typeof(e=(t=r.length)?r[0].length:0))throw new TypeError("Data must be a 2D array with at least one element");this.data=[];for(let n=0;n<t;n++){if(r[n].length!==e)throw new RangeError("Inconsistent array dimensions");if(!r[n].every((t=>"number"==typeof t)))throw new TypeError("Input data contains non-numeric values");this.data.push(Float64Array.from(r[n]))}}}this.rows=t,this.columns=e}set(t,e,r){return this.data[t][e]=r,this}get(t,e){return this.data[t][e]}removeRow(t){return ye(this,t),this.data.splice(t,1),this.rows-=1,this}addRow(t,e){return void 0===e&&(e=t,t=this.rows),ye(this,t,!0),e=Float64Array.from(we(this,e)),this.data.splice(t,0,e),this.rows+=1,this}removeColumn(t){me(this,t);for(let e=0;e<this.rows;e++){const r=new Float64Array(this.columns-1);for(let n=0;n<t;n++)r[n]=this.data[e][n];for(let n=t+1;n<this.columns;n++)r[n-1]=this.data[e][n];this.data[e]=r}return this.columns-=1,this}addColumn(t,e){void 0===e&&(e=t,t=this.columns),me(this,t,!0),e=ve(this,e);for(let r=0;r<this.rows;r++){const n=new Float64Array(this.columns+1);let o=0;for(;o<t;o++)n[o]=this.data[r][o];for(n[o++]=e[r];o<this.columns+1;o++)n[o]=this.data[r][o-1];this.data[r]=n}return this.columns+=1,this}}!function(t,e){t.prototype.add=function(t){return"number"==typeof t?this.addS(t):this.addM(t)},t.prototype.addS=function(t){for(let e=0;e<this.rows;e++)for(let r=0;r<this.columns;r++)this.set(e,r,this.get(e,r)+t);return this},t.prototype.addM=function(t){if(t=e.checkMatrix(t),this.rows!==t.rows||this.columns!==t.columns)throw new RangeError("Matrices dimensions must be equal");for(let e=0;e<this.rows;e++)for(let r=0;r<this.columns;r++)this.set(e,r,this.get(e,r)+t.get(e,r));return this},t.add=function(t,r){return new e(t).add(r)},t.prototype.sub=function(t){return"number"==typeof t?this.subS(t):this.subM(t)},t.prototype.subS=function(t){for(let e=0;e<this.rows;e++)for(let r=0;r<this.columns;r++)this.set(e,r,this.get(e,r)-t);return this},t.prototype.subM=function(t){if(t=e.checkMatrix(t),this.rows!==t.rows||this.columns!==t.columns)throw new RangeError("Matrices dimensions must be equal");for(let e=0;e<this.rows;e++)for(let r=0;r<this.columns;r++)this.set(e,r,this.get(e,r)-t.get(e,r));return this},t.sub=function(t,r){return new e(t).sub(r)},t.prototype.subtract=t.prototype.sub,t.prototype.subtractS=t.prototype.subS,t.prototype.subtractM=t.prototype.subM,t.subtract=t.sub,t.prototype.mul=function(t){return"number"==typeof t?this.mulS(t):this.mulM(t)},t.prototype.mulS=function(t){for(let e=0;e<this.rows;e++)for(let r=0;r<this.columns;r++)this.set(e,r,this.get(e,r)*t);return this},t.prototype.mulM=function(t){if(t=e.checkMatrix(t),this.rows!==t.rows||this.columns!==t.columns)throw new RangeError("Matrices dimensions must be equal");for(let e=0;e<this.rows;e++)for(let r=0;r<this.columns;r++)this.set(e,r,this.get(e,r)*t.get(e,r));return this},t.mul=function(t,r){return new e(t).mul(r)},t.prototype.multiply=t.prototype.mul,t.prototype.multiplyS=t.prototype.mulS,t.prototype.multiplyM=t.prototype.mulM,t.multiply=t.mul,t.prototype.div=function(t){return"number"==typeof t?this.divS(t):this.divM(t)},t.prototype.divS=function(t){for(let e=0;e<this.rows;e++)for(let r=0;r<this.columns;r++)this.set(e,r,this.get(e,r)/t);return this},t.prototype.divM=function(t){if(t=e.checkMatrix(t),this.rows!==t.rows||this.columns!==t.columns)throw new RangeError("Matrices dimensions must be equal");for(let e=0;e<this.rows;e++)for(let r=0;r<this.columns;r++)this.set(e,r,this.get(e,r)/t.get(e,r));return this},t.div=function(t,r){return new e(t).div(r)},t.prototype.divide=t.prototype.div,t.prototype.divideS=t.prototype.divS,t.prototype.divideM=t.prototype.divM,t.divide=t.div,t.prototype.mod=function(t){return"number"==typeof t?this.modS(t):this.modM(t)},t.prototype.modS=function(t){for(let e=0;e<this.rows;e++)for(let r=0;r<this.columns;r++)this.set(e,r,this.get(e,r)%t);return this},t.prototype.modM=function(t){if(t=e.checkMatrix(t),this.rows!==t.rows||this.columns!==t.columns)throw new RangeError("Matrices dimensions must be equal");for(let e=0;e<this.rows;e++)for(let r=0;r<this.columns;r++)this.set(e,r,this.get(e,r)%t.get(e,r));return this},t.mod=function(t,r){return new e(t).mod(r)},t.prototype.modulus=t.prototype.mod,t.prototype.modulusS=t.prototype.modS,t.prototype.modulusM=t.prototype.modM,t.modulus=t.mod,t.prototype.and=function(t){return"number"==typeof t?this.andS(t):this.andM(t)},t.prototype.andS=function(t){for(let e=0;e<this.rows;e++)for(let r=0;r<this.columns;r++)this.set(e,r,this.get(e,r)&t);return this},t.prototype.andM=function(t){if(t=e.checkMatrix(t),this.rows!==t.rows||this.columns!==t.columns)throw new RangeError("Matrices dimensions must be equal");for(let e=0;e<this.rows;e++)for(let r=0;r<this.columns;r++)this.set(e,r,this.get(e,r)&t.get(e,r));return this},t.and=function(t,r){return new e(t).and(r)},t.prototype.or=function(t){return"number"==typeof t?this.orS(t):this.orM(t)},t.prototype.orS=function(t){for(let e=0;e<this.rows;e++)for(let r=0;r<this.columns;r++)this.set(e,r,this.get(e,r)|t);return this},t.prototype.orM=function(t){if(t=e.checkMatrix(t),this.rows!==t.rows||this.columns!==t.columns)throw new RangeError("Matrices dimensions must be equal");for(let e=0;e<this.rows;e++)for(let r=0;r<this.columns;r++)this.set(e,r,this.get(e,r)|t.get(e,r));return this},t.or=function(t,r){return new e(t).or(r)},t.prototype.xor=function(t){return"number"==typeof t?this.xorS(t):this.xorM(t)},t.prototype.xorS=function(t){for(let e=0;e<this.rows;e++)for(let r=0;r<this.columns;r++)this.set(e,r,this.get(e,r)^t);return this},t.prototype.xorM=function(t){if(t=e.checkMatrix(t),this.rows!==t.rows||this.columns!==t.columns)throw new RangeError("Matrices dimensions must be equal");for(let e=0;e<this.rows;e++)for(let r=0;r<this.columns;r++)this.set(e,r,this.get(e,r)^t.get(e,r));return this},t.xor=function(t,r){return new e(t).xor(r)},t.prototype.leftShift=function(t){return"number"==typeof t?this.leftShiftS(t):this.leftShiftM(t)},t.prototype.leftShiftS=function(t){for(let e=0;e<this.rows;e++)for(let r=0;r<this.columns;r++)this.set(e,r,this.get(e,r)<<t);return this},t.prototype.leftShiftM=function(t){if(t=e.checkMatrix(t),this.rows!==t.rows||this.columns!==t.columns)throw new RangeError("Matrices dimensions must be equal");for(let e=0;e<this.rows;e++)for(let r=0;r<this.columns;r++)this.set(e,r,this.get(e,r)<<t.get(e,r));return this},t.leftShift=function(t,r){return new e(t).leftShift(r)},t.prototype.signPropagatingRightShift=function(t){return"number"==typeof t?this.signPropagatingRightShiftS(t):this.signPropagatingRightShiftM(t)},t.prototype.signPropagatingRightShiftS=function(t){for(let e=0;e<this.rows;e++)for(let r=0;r<this.columns;r++)this.set(e,r,this.get(e,r)>>t);return this},t.prototype.signPropagatingRightShiftM=function(t){if(t=e.checkMatrix(t),this.rows!==t.rows||this.columns!==t.columns)throw new RangeError("Matrices dimensions must be equal");for(let e=0;e<this.rows;e++)for(let r=0;r<this.columns;r++)this.set(e,r,this.get(e,r)>>t.get(e,r));return this},t.signPropagatingRightShift=function(t,r){return new e(t).signPropagatingRightShift(r)},t.prototype.rightShift=function(t){return"number"==typeof t?this.rightShiftS(t):this.rightShiftM(t)},t.prototype.rightShiftS=function(t){for(let e=0;e<this.rows;e++)for(let r=0;r<this.columns;r++)this.set(e,r,this.get(e,r)>>>t);return this},t.prototype.rightShiftM=function(t){if(t=e.checkMatrix(t),this.rows!==t.rows||this.columns!==t.columns)throw new RangeError("Matrices dimensions must be equal");for(let e=0;e<this.rows;e++)for(let r=0;r<this.columns;r++)this.set(e,r,this.get(e,r)>>>t.get(e,r));return this},t.rightShift=function(t,r){return new e(t).rightShift(r)},t.prototype.zeroFillRightShift=t.prototype.rightShift,t.prototype.zeroFillRightShiftS=t.prototype.rightShiftS,t.prototype.zeroFillRightShiftM=t.prototype.rightShiftM,t.zeroFillRightShift=t.rightShift,t.prototype.not=function(){for(let t=0;t<this.rows;t++)for(let e=0;e<this.columns;e++)this.set(t,e,~this.get(t,e));return this},t.not=function(t){return new e(t).not()},t.prototype.abs=function(){for(let t=0;t<this.rows;t++)for(let e=0;e<this.columns;e++)this.set(t,e,Math.abs(this.get(t,e)));return this},t.abs=function(t){return new e(t).abs()},t.prototype.acos=function(){for(let t=0;t<this.rows;t++)for(let e=0;e<this.columns;e++)this.set(t,e,Math.acos(this.get(t,e)));return this},t.acos=function(t){return new e(t).acos()},t.prototype.acosh=function(){for(let t=0;t<this.rows;t++)for(let e=0;e<this.columns;e++)this.set(t,e,Math.acosh(this.get(t,e)));return this},t.acosh=function(t){return new e(t).acosh()},t.prototype.asin=function(){for(let t=0;t<this.rows;t++)for(let e=0;e<this.columns;e++)this.set(t,e,Math.asin(this.get(t,e)));return this},t.asin=function(t){return new e(t).asin()},t.prototype.asinh=function(){for(let t=0;t<this.rows;t++)for(let e=0;e<this.columns;e++)this.set(t,e,Math.asinh(this.get(t,e)));return this},t.asinh=function(t){return new e(t).asinh()},t.prototype.atan=function(){for(let t=0;t<this.rows;t++)for(let e=0;e<this.columns;e++)this.set(t,e,Math.atan(this.get(t,e)));return this},t.atan=function(t){return new e(t).atan()},t.prototype.atanh=function(){for(let t=0;t<this.rows;t++)for(let e=0;e<this.columns;e++)this.set(t,e,Math.atanh(this.get(t,e)));return this},t.atanh=function(t){return new e(t).atanh()},t.prototype.cbrt=function(){for(let t=0;t<this.rows;t++)for(let e=0;e<this.columns;e++)this.set(t,e,Math.cbrt(this.get(t,e)));return this},t.cbrt=function(t){return new e(t).cbrt()},t.prototype.ceil=function(){for(let t=0;t<this.rows;t++)for(let e=0;e<this.columns;e++)this.set(t,e,Math.ceil(this.get(t,e)));return this},t.ceil=function(t){return new e(t).ceil()},t.prototype.clz32=function(){for(let t=0;t<this.rows;t++)for(let e=0;e<this.columns;e++)this.set(t,e,Math.clz32(this.get(t,e)));return this},t.clz32=function(t){return new e(t).clz32()},t.prototype.cos=function(){for(let t=0;t<this.rows;t++)for(let e=0;e<this.columns;e++)this.set(t,e,Math.cos(this.get(t,e)));return this},t.cos=function(t){return new e(t).cos()},t.prototype.cosh=function(){for(let t=0;t<this.rows;t++)for(let e=0;e<this.columns;e++)this.set(t,e,Math.cosh(this.get(t,e)));return this},t.cosh=function(t){return new e(t).cosh()},t.prototype.exp=function(){for(let t=0;t<this.rows;t++)for(let e=0;e<this.columns;e++)this.set(t,e,Math.exp(this.get(t,e)));return this},t.exp=function(t){return new e(t).exp()},t.prototype.expm1=function(){for(let t=0;t<this.rows;t++)for(let e=0;e<this.columns;e++)this.set(t,e,Math.expm1(this.get(t,e)));return this},t.expm1=function(t){return new e(t).expm1()},t.prototype.floor=function(){for(let t=0;t<this.rows;t++)for(let e=0;e<this.columns;e++)this.set(t,e,Math.floor(this.get(t,e)));return this},t.floor=function(t){return new e(t).floor()},t.prototype.fround=function(){for(let t=0;t<this.rows;t++)for(let e=0;e<this.columns;e++)this.set(t,e,Math.fround(this.get(t,e)));return this},t.fround=function(t){return new e(t).fround()},t.prototype.log=function(){for(let t=0;t<this.rows;t++)for(let e=0;e<this.columns;e++)this.set(t,e,Math.log(this.get(t,e)));return this},t.log=function(t){return new e(t).log()},t.prototype.log1p=function(){for(let t=0;t<this.rows;t++)for(let e=0;e<this.columns;e++)this.set(t,e,Math.log1p(this.get(t,e)));return this},t.log1p=function(t){return new e(t).log1p()},t.prototype.log10=function(){for(let t=0;t<this.rows;t++)for(let e=0;e<this.columns;e++)this.set(t,e,Math.log10(this.get(t,e)));return this},t.log10=function(t){return new e(t).log10()},t.prototype.log2=function(){for(let t=0;t<this.rows;t++)for(let e=0;e<this.columns;e++)this.set(t,e,Math.log2(this.get(t,e)));return this},t.log2=function(t){return new e(t).log2()},t.prototype.round=function(){for(let t=0;t<this.rows;t++)for(let e=0;e<this.columns;e++)this.set(t,e,Math.round(this.get(t,e)));return this},t.round=function(t){return new e(t).round()},t.prototype.sign=function(){for(let t=0;t<this.rows;t++)for(let e=0;e<this.columns;e++)this.set(t,e,Math.sign(this.get(t,e)));return this},t.sign=function(t){return new e(t).sign()},t.prototype.sin=function(){for(let t=0;t<this.rows;t++)for(let e=0;e<this.columns;e++)this.set(t,e,Math.sin(this.get(t,e)));return this},t.sin=function(t){return new e(t).sin()},t.prototype.sinh=function(){for(let t=0;t<this.rows;t++)for(let e=0;e<this.columns;e++)this.set(t,e,Math.sinh(this.get(t,e)));return this},t.sinh=function(t){return new e(t).sinh()},t.prototype.sqrt=function(){for(let t=0;t<this.rows;t++)for(let e=0;e<this.columns;e++)this.set(t,e,Math.sqrt(this.get(t,e)));return this},t.sqrt=function(t){return new e(t).sqrt()},t.prototype.tan=function(){for(let t=0;t<this.rows;t++)for(let e=0;e<this.columns;e++)this.set(t,e,Math.tan(this.get(t,e)));return this},t.tan=function(t){return new e(t).tan()},t.prototype.tanh=function(){for(let t=0;t<this.rows;t++)for(let e=0;e<this.columns;e++)this.set(t,e,Math.tanh(this.get(t,e)));return this},t.tanh=function(t){return new e(t).tanh()},t.prototype.trunc=function(){for(let t=0;t<this.rows;t++)for(let e=0;e<this.columns;e++)this.set(t,e,Math.trunc(this.get(t,e)));return this},t.trunc=function(t){return new e(t).trunc()},t.pow=function(t,r){return new e(t).pow(r)},t.prototype.pow=function(t){return"number"==typeof t?this.powS(t):this.powM(t)},t.prototype.powS=function(t){for(let e=0;e<this.rows;e++)for(let r=0;r<this.columns;r++)this.set(e,r,Math.pow(this.get(e,r),t));return this},t.prototype.powM=function(t){if(t=e.checkMatrix(t),this.rows!==t.rows||this.columns!==t.columns)throw new RangeError("Matrices dimensions must be equal");for(let e=0;e<this.rows;e++)for(let r=0;r<this.columns;r++)this.set(e,r,Math.pow(this.get(e,r),t.get(e,r)));return this}}(Ne,Ae);class ke extends Ne{constructor(t){super(),this.data=t,this.rows=t.length,this.columns=t[0].length}set(t,e,r){return this.data[t][e]=r,this}get(t,e){return this.data[t][e]}}function De(t,e){let r=0;return Math.abs(t)>Math.abs(e)?(r=e/t,Math.abs(t)*Math.sqrt(1+r*r)):0!==e?(r=t/e,Math.abs(e)*Math.sqrt(1+r*r)):0}class Ie{constructor(t,e={}){if((t=ke.checkMatrix(t)).isEmpty())throw new Error("Matrix must be non-empty");let r=t.rows,n=t.columns;const{computeLeftSingularVectors:o=!0,computeRightSingularVectors:i=!0,autoTranspose:s=!1}=e;let a,h=Boolean(o),u=Boolean(i),c=!1;if(r<n)if(s){a=t.transpose(),r=a.rows,n=a.columns,c=!0;let e=h;h=u,u=e}else a=t.clone(),console.warn("Computing SVD on a matrix with more columns than rows. Consider enabling autoTranspose");else a=t.clone();let l=Math.min(r,n),f=Math.min(r+1,n),d=new Float64Array(f),g=new Ae(r,l),p=new Ae(n,n),y=new Float64Array(n),m=new Float64Array(r),w=new Float64Array(f);for(let t=0;t<f;t++)w[t]=t;let v=Math.min(r-1,n),x=Math.max(0,Math.min(n-2,r)),M=Math.max(v,x);for(let t=0;t<M;t++){if(t<v){d[t]=0;for(let e=t;e<r;e++)d[t]=De(d[t],a.get(e,t));if(0!==d[t]){a.get(t,t)<0&&(d[t]=-d[t]);for(let e=t;e<r;e++)a.set(e,t,a.get(e,t)/d[t]);a.set(t,t,a.get(t,t)+1)}d[t]=-d[t]}for(let e=t+1;e<n;e++){if(t<v&&0!==d[t]){let n=0;for(let o=t;o<r;o++)n+=a.get(o,t)*a.get(o,e);n=-n/a.get(t,t);for(let o=t;o<r;o++)a.set(o,e,a.get(o,e)+n*a.get(o,t))}y[e]=a.get(t,e)}if(h&&t<v)for(let e=t;e<r;e++)g.set(e,t,a.get(e,t));if(t<x){y[t]=0;for(let e=t+1;e<n;e++)y[t]=De(y[t],y[e]);if(0!==y[t]){y[t+1]<0&&(y[t]=0-y[t]);for(let e=t+1;e<n;e++)y[e]/=y[t];y[t+1]+=1}if(y[t]=-y[t],t+1<r&&0!==y[t]){for(let e=t+1;e<r;e++)m[e]=0;for(let e=t+1;e<r;e++)for(let r=t+1;r<n;r++)m[e]+=y[r]*a.get(e,r);for(let e=t+1;e<n;e++){let n=-y[e]/y[t+1];for(let o=t+1;o<r;o++)a.set(o,e,a.get(o,e)+n*m[o])}}if(u)for(let e=t+1;e<n;e++)p.set(e,t,y[e])}}let b=Math.min(n,r+1);if(v<n&&(d[v]=a.get(v,v)),r<b&&(d[b-1]=0),x+1<b&&(y[x]=a.get(x,b-1)),y[b-1]=0,h){for(let t=v;t<l;t++){for(let e=0;e<r;e++)g.set(e,t,0);g.set(t,t,1)}for(let t=v-1;t>=0;t--)if(0!==d[t]){for(let e=t+1;e<l;e++){let n=0;for(let o=t;o<r;o++)n+=g.get(o,t)*g.get(o,e);n=-n/g.get(t,t);for(let o=t;o<r;o++)g.set(o,e,g.get(o,e)+n*g.get(o,t))}for(let e=t;e<r;e++)g.set(e,t,-g.get(e,t));g.set(t,t,1+g.get(t,t));for(let e=0;e<t-1;e++)g.set(e,t,0)}else{for(let e=0;e<r;e++)g.set(e,t,0);g.set(t,t,1)}}if(u)for(let t=n-1;t>=0;t--){if(t<x&&0!==y[t])for(let e=t+1;e<n;e++){let r=0;for(let o=t+1;o<n;o++)r+=p.get(o,t)*p.get(o,e);r=-r/p.get(t+1,t);for(let o=t+1;o<n;o++)p.set(o,e,p.get(o,e)+r*p.get(o,t))}for(let e=0;e<n;e++)p.set(e,t,0);p.set(t,t,1)}let E=b-1,N=0,S=Number.EPSILON;for(;b>0;){let t,e;for(t=b-2;t>=-1&&-1!==t;t--){const e=Number.MIN_VALUE+S*Math.abs(d[t]+Math.abs(d[t+1]));if(Math.abs(y[t])<=e||Number.isNaN(y[t])){y[t]=0;break}}if(t===b-2)e=4;else{let r;for(r=b-1;r>=t&&r!==t;r--){let e=(r!==b?Math.abs(y[r]):0)+(r!==t+1?Math.abs(y[r-1]):0);if(Math.abs(d[r])<=S*e){d[r]=0;break}}r===t?e=3:r===b-1?e=1:(e=2,t=r)}switch(t++,e){case 1:{let e=y[b-2];y[b-2]=0;for(let r=b-2;r>=t;r--){let o=De(d[r],e),i=d[r]/o,s=e/o;if(d[r]=o,r!==t&&(e=-s*y[r-1],y[r-1]=i*y[r-1]),u)for(let t=0;t<n;t++)o=i*p.get(t,r)+s*p.get(t,b-1),p.set(t,b-1,-s*p.get(t,r)+i*p.get(t,b-1)),p.set(t,r,o)}break}case 2:{let e=y[t-1];y[t-1]=0;for(let n=t;n<b;n++){let o=De(d[n],e),i=d[n]/o,s=e/o;if(d[n]=o,e=-s*y[n],y[n]=i*y[n],h)for(let e=0;e<r;e++)o=i*g.get(e,n)+s*g.get(e,t-1),g.set(e,t-1,-s*g.get(e,n)+i*g.get(e,t-1)),g.set(e,n,o)}break}case 3:{const e=Math.max(Math.abs(d[b-1]),Math.abs(d[b-2]),Math.abs(y[b-2]),Math.abs(d[t]),Math.abs(y[t])),o=d[b-1]/e,i=d[b-2]/e,s=y[b-2]/e,a=d[t]/e,c=y[t]/e,l=((i+o)*(i-o)+s*s)/2,f=o*s*(o*s);let m=0;0===l&&0===f||(m=l<0?0-Math.sqrt(l*l+f):Math.sqrt(l*l+f),m=f/(l+m));let w=(a+o)*(a-o)+m,v=a*c;for(let e=t;e<b-1;e++){let o=De(w,v);0===o&&(o=Number.MIN_VALUE);let i=w/o,s=v/o;if(e!==t&&(y[e-1]=o),w=i*d[e]+s*y[e],y[e]=i*y[e]-s*d[e],v=s*d[e+1],d[e+1]=i*d[e+1],u)for(let t=0;t<n;t++)o=i*p.get(t,e)+s*p.get(t,e+1),p.set(t,e+1,-s*p.get(t,e)+i*p.get(t,e+1)),p.set(t,e,o);if(o=De(w,v),0===o&&(o=Number.MIN_VALUE),i=w/o,s=v/o,d[e]=o,w=i*y[e]+s*d[e+1],d[e+1]=-s*y[e]+i*d[e+1],v=s*y[e+1],y[e+1]=i*y[e+1],h&&e<r-1)for(let t=0;t<r;t++)o=i*g.get(t,e)+s*g.get(t,e+1),g.set(t,e+1,-s*g.get(t,e)+i*g.get(t,e+1)),g.set(t,e,o)}y[b-2]=w,N+=1;break}case 4:if(d[t]<=0&&(d[t]=d[t]<0?-d[t]:0,u))for(let e=0;e<=E;e++)p.set(e,t,-p.get(e,t));for(;t<E&&!(d[t]>=d[t+1]);){let e=d[t];if(d[t]=d[t+1],d[t+1]=e,u&&t<n-1)for(let r=0;r<n;r++)e=p.get(r,t+1),p.set(r,t+1,p.get(r,t)),p.set(r,t,e);if(h&&t<r-1)for(let n=0;n<r;n++)e=g.get(n,t+1),g.set(n,t+1,g.get(n,t)),g.set(n,t,e);t++}N=0,b--}}if(c){let t=p;p=g,g=t}this.m=r,this.n=n,this.s=d,this.U=g,this.V=p}solve(t){let e=t,r=this.threshold,n=this.s.length,o=Ae.zeros(n,n);for(let t=0;t<n;t++)Math.abs(this.s[t])<=r?o.set(t,t,0):o.set(t,t,1/this.s[t]);let i=this.U,s=this.rightSingularVectors,a=s.mmul(o),h=s.rows,u=i.rows,c=Ae.zeros(h,u);for(let t=0;t<h;t++)for(let e=0;e<u;e++){let r=0;for(let o=0;o<n;o++)r+=a.get(t,o)*i.get(e,o);c.set(t,e,r)}return c.mmul(e)}solveForDiagonal(t){return this.solve(Ae.diag(t))}inverse(){let t=this.V,e=this.threshold,r=t.rows,n=t.columns,o=new Ae(r,this.s.length);for(let i=0;i<r;i++)for(let r=0;r<n;r++)Math.abs(this.s[r])>e&&o.set(i,r,t.get(i,r)/this.s[r]);let i=this.U,s=i.rows,a=i.columns,h=new Ae(r,s);for(let t=0;t<r;t++)for(let e=0;e<s;e++){let r=0;for(let n=0;n<a;n++)r+=o.get(t,n)*i.get(e,n);h.set(t,e,r)}return h}get condition(){return this.s[0]/this.s[Math.min(this.m,this.n)-1]}get norm2(){return this.s[0]}get rank(){let t=Math.max(this.m,this.n)*this.s[0]*Number.EPSILON,e=0,r=this.s;for(let n=0,o=r.length;n<o;n++)r[n]>t&&e++;return e}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 Ae.diag(this.s)}}var _e,Re={center:[0,0],linkDistance:50},ze=function(){function t(t){void 0===t&&(t={}),this.options=t,this.id="mds",this.options=r(r({},Re),t)}return t.prototype.execute=function(t,e){return o(this,void 0,void 0,(function(){return i(this,(function(r){return[2,this.genericMDSLayout(!1,t,e)]}))}))},t.prototype.assign=function(t,e){return o(this,void 0,void 0,(function(){return i(this,(function(r){return this.genericMDSLayout(!0,t,e),[2]}))}))},t.prototype.genericMDSLayout=function(t,e,n){return o(this,void 0,void 0,(function(){var o,s,a,h,u,c,l,f,d,g,m;return i(this,(function(i){return o=r(r({},this.options),n),s=o.center,a=void 0===s?[0,0]:s,h=o.linkDistance,u=void 0===h?50:h,c=e.getAllNodes(),l=e.getAllEdges(),(null==c?void 0:c.length)&&1!==c.length?(f=y({nodes:c,edges:l},!1),d=p(f),Te(d),w=u,v=[],d.forEach((function(t){var e=[];t.forEach((function(t){e.push(t*w)})),v.push(e)})),g=Ce(v),m=[],g.forEach((function(t,e){var r=b(c[e]);r.data.x=t[0]+a[0],r.data.y=t[1]+a[1],m.push(r)})),t&&m.forEach((function(t){return e.mergeNodeData(t.id,{x:t.data.x,y:t.data.y})})),[2,{nodes:m,edges:l}]):[2,k(e,t,a)];var w,v}))}))},t}(),Te=function(t){var e=-999999;t.forEach((function(t){t.forEach((function(t){t!==1/0&&e<t&&(e=t)}))})),t.forEach((function(r,n){r.forEach((function(r,o){r===1/0&&(t[n][o]=e)}))}))},Ce=function(t){var e=Ae.mul(Ae.pow(t,2),-.5),r=e.mean("row"),n=e.mean("column"),o=e.mean();e.add(o).subRowVector(r).subColumnVector(n);var i=new Ie(e),s=Ae.sqrt(i.diagonalMatrix).diagonal();return i.leftSingularVectors.toJSON().map((function(t){return Ae.mul([t],[s]).toJSON()[0].splice(0,2)}))},Oe={iterations:10,height:10,width:10,speed:100,gravity:10,k:5},Pe=function(t,e,r,n,o,i){e.forEach((function(s,a){r[a]={x:0,y:0},e.forEach((function(e,h){if(a!==h&&o[a]===o[h]){var u=s.x-e.x,c=s.y-e.y,l=Math.sqrt(u*u+c*c);if(0===l){l=1;var f=a>h?1:-1;u=.01*f,c=.01*f}if(l<i(t[a])/2+i(t[h])/2){var d=n*n/l;r[a].x+=u/l*d,r[a].y+=c/l*d}}}))}))},qe=function(t,e,r,n,o,i,s,a){var h=i||s/10;return n&&e.forEach((function(e,r){var n=t[r].x-t[o].x,i=t[r].y-t[o].y,s=Math.sqrt(n*n+i*i),a=i/s,h=-n/s,u=Math.sqrt(e.x*e.x+e.y*e.y),c=Math.acos((a*e.x+h*e.y)/u);c>Math.PI/2&&(c-=Math.PI/2,a*=-1,h*=-1);var l=Math.cos(c)*u;e.x=a*l,e.y=h*l})),t.forEach((function(i,s){if(s!==o){var u=Math.sqrt(e[s].x*e[s].x+e[s].y*e[s].y);if(u>0&&s!==o){var c=Math.min(h*(r/800),u);if(i.x+=e[s].x/u*c,i.y+=e[s].y/u*c,n){var l=i.x-t[o].x,f=i.y-t[o].y,d=Math.sqrt(l*l+f*f);l=l/d*a[s],f=f/d*a[s],i.x=t[o].x+l,i.y=t[o].y+f}}}})),t},Fe={maxIteration:1e3,focusNode:null,unitRadius:null,linkDistance:50,preventOverlap:!1,strictRadial:!0,maxPreventOverlapIteration:200,sortStrength:10},Le=function(){function t(t){void 0===t&&(t={}),this.options=t,this.id="radial",this.options=r(r({},Fe),t)}return t.prototype.execute=function(t,e){return o(this,void 0,void 0,(function(){return i(this,(function(r){return[2,this.genericRadialLayout(!1,t,e)]}))}))},t.prototype.assign=function(t,e){return o(this,void 0,void 0,(function(){return i(this,(function(r){return this.genericRadialLayout(!0,t,e),[2]}))}))},t.prototype.genericRadialLayout=function(t,e,n){return o(this,void 0,void 0,(function(){var o,h,u,c,l,f,d,g,m,w,v,x,M,E,N,S,A,D,I,_,R,T,C,O,P,q,F,L,j,V,W,$,G,U,B,H,K,J,Y,X,Q,Z,tt;return i(this,(function(i){if(o=r(r({},this.options),n),h=o.width,u=o.height,c=o.center,l=o.focusNode,f=o.unitRadius,d=o.nodeSize,g=o.nodeSpacing,m=o.strictRadial,w=o.preventOverlap,v=o.maxPreventOverlapIteration,x=o.sortBy,M=o.linkDistance,E=void 0===M?50:M,N=o.sortStrength,S=void 0===N?10:N,A=o.maxIteration,D=void 0===A?1e3:A,I=e.getAllNodes(),_=e.getAllEdges(),R=h||"undefined"==typeof window?h:window.innerWidth,T=u||"undefined"==typeof window?u:window.innerHeight,C=c||[R/2,T/2],!(null==I?void 0:I.length)||1===I.length)return[2,k(e,t,C)];if(O=I[0],z(l)){for(P=0;P<I.length;P++)if(I[P].id===l){O=I[P];break}}else O=l||I[0];return q=We(I,O.id),F=y({nodes:I,edges:_},!1),L=p(F),j=Ge(L,q),$e(L,q,j+1),V=L[q],W=R-C[0]>C[0]?C[0]:R-C[0],$=T-C[1]>C[1]?C[1]:T-C[1],0===W&&(W=R/2),0===$&&($=T/2),G=Math.min(W,$),U=Math.max.apply(Math,a([],s(V),!1)),B=[],H=f||G/U,V.forEach((function(t,e){B[e]=t*H})),K=je(I,L,E,B,H,x,S),J=Ve(K),Y=function(t,e,r){try{var n=Ae.mul(Ae.pow(e,2),-.5),o=n.mean("row"),i=n.mean("column"),s=n.mean();n.add(s).subRowVector(o).subColumnVector(i);var a=new Ie(n),h=Ae.sqrt(a.diagonalMatrix).diagonal();return a.leftSingularVectors.toJSON().map((function(e){return Ae.mul([e],[h]).toJSON()[0].splice(0,t)}))}catch(t){for(var u=[],c=0;c<e.length;c++){var l=Math.random()*r,f=Math.random()*r;u.push([l,f])}return u}}(E,K,E),X=Y.map((function(t){var e=s(t,2),r=e[0],n=e[1];return{x:(isNaN(r)?Math.random()*E:r)-Y[q][0],y:(isNaN(n)?Math.random()*E:n)-Y[q][1]}})),this.run(D,X,J,K,B,q),w&&(Q=Ue(d,g),Z={nodes:I,nodeSizeFunc:Q,positions:X,radii:B,height:T,width:R,strictRadial:Boolean(m),focusIdx:q,iterations:v||200,k:X.length/4.5},X=function(t,e){for(var n=r(r({},Oe),e),o=n.positions,i=n.iterations,s=n.width,a=n.k,h=n.speed,u=void 0===h?100:h,c=n.strictRadial,l=n.focusIdx,f=n.radii,d=void 0===f?[]:f,g=n.nodeSizeFunc,p=t.getAllNodes(),y=[],m=s/10,w=0;w<i;w++)o.forEach((function(t,e){y[e]={x:0,y:0}})),Pe(p,o,y,a,d,g),qe(o,y,u,c,l,m,s,d);return o}(e,Z)),tt=[],X.forEach((function(t,e){var r=b(I[e]);r.data.x=t.x+C[0],r.data.y=t.y+C[1],tt.push(r)})),t&&tt.forEach((function(t){return e.mergeNodeData(t.id,{x:t.data.x,y:t.data.y})})),[2,{nodes:tt,edges:_}]}))}))},t.prototype.run=function(t,e,r,n,o,i){for(var s=0;s<=t;s++){var a=s/t;this.oneIteration(a,e,o,n,r,i)}},t.prototype.oneIteration=function(t,e,r,n,o,i){var s=1-t;e.forEach((function(a,h){var u=m(a,{x:0,y:0}),c=0===u?0:1/u;if(h!==i){var l=0,f=0,d=0;e.forEach((function(t,e){if(h!==e){var r=m(a,t),i=0===r?0:1/r,s=n[e][h];d+=o[h][e],l+=o[h][e]*(t.x+s*(a.x-t.x)*i),f+=o[h][e]*(t.y+s*(a.y-t.y)*i)}}));var g=0===r[h]?0:1/r[h];d*=s,d+=t*g*g,l*=s,l+=t*g*a.x*c,a.x=l/d,f*=s,f+=t*g*a.y*c,a.y=f/d}}))},t}(),je=function(t,e,r,n,o,i,s){if(!t)return[];var a=[];if(e){var h={};e.forEach((function(e,u){var c=[];e.forEach((function(e,a){var l,f;if(u===a)c.push(0);else if(n[u]===n[a])if("data"===i)c.push(e*(Math.abs(u-a)*s)/(n[u]/o));else if(i){var d=void 0,g=void 0;if(h[t[u].id])d=h[t[u].id];else{var p=("id"===i?t[u].id:null===(l=t[u].data)||void 0===l?void 0:l[i])||0;d=z(p)?p.charCodeAt(0):p,h[t[u].id]=d}h[t[a].id]?g=h[t[a].id]:(p=("id"===i?t[a].id:null===(f=t[a].data)||void 0===f?void 0:f[i])||0,g=z(p)?p.charCodeAt(0):p,h[t[a].id]=g),c.push(e*(Math.abs(d-g)*s)/(n[u]/o))}else c.push(e*r/(n[u]/o));else{var y=(r+o)/2;c.push(e*y)}})),a.push(c)}))}return a},Ve=function(t){for(var e=t.length,r=t[0].length,n=[],o=0;o<e;o++){for(var i=[],s=0;s<r;s++)0!==t[o][s]?i.push(1/(t[o][s]*t[o][s])):i.push(0);n.push(i)}return n},We=function(t,e){var r=-1;return t.forEach((function(t,n){t.id===e&&(r=n)})),Math.max(r,0)},$e=function(t,e,r){for(var n=t.length,o=0;o<n;o++)if(t[e][o]===1/0){t[e][o]=r,t[o][e]=r;for(var i=0;i<n;i++)t[o][i]!==1/0&&t[e][i]===1/0&&(t[e][i]=r+t[o][i],t[i][e]=r+t[o][i])}for(o=0;o<n;o++)if(o!==e)for(i=0;i<n;i++)if(t[o][i]===1/0){var s=Math.abs(t[e][o]-t[e][i]);s=0===s?1:s,t[o][i]=s}},Ge=function(t,e){for(var r=0,n=0;n<t[e].length;n++)t[e][n]!==1/0&&(r=t[e][n]>r?t[e][n]:r);return r},Ue=function(t,e){var r;return r=x(e)?function(){return e}:E(e)?e:function(){return 0},t?g(t)?function(e){return(t[0]>t[1]?t[0]:t[1])+r(e)}:function(e){return t+r(e)}:function(t){var e,n;if(null===(e=t.data)||void 0===e?void 0:e.bboxSize)return Math.max(t.data.bboxSize[0],t.data.bboxSize[1])+r(t);if(null===(n=t.data)||void 0===n?void 0:n.size){if(g(t.data.size))return Math.max(t.data.size[0],t.data.size[1])+r(t);var o=t.data.size;return N(o)?(o.width>o.height?o.width:o.height)+r(t):o+r(t)}return 10+r(t)}},Be={center:[0,0],width:300,height:300},He={circular:I,concentric:C,mds:ze,random:function(){function t(t){void 0===t&&(t={}),this.options=t,this.id="random",this.options=r(r({},Be),t)}return t.prototype.execute=function(t,e){return o(this,void 0,void 0,(function(){return i(this,(function(r){return[2,this.genericRandomLayout(!1,t,e)]}))}))},t.prototype.assign=function(t,e){return o(this,void 0,void 0,(function(){return i(this,(function(r){return this.genericRandomLayout(!0,t,e),[2]}))}))},t.prototype.genericRandomLayout=function(t,e,n){return o(this,void 0,void 0,(function(){var o,s,a,h,u,c,l,f,d;return i(this,(function(i){return o=r(r({},this.options),n),s=o.center,a=o.width,h=o.height,u=e.getAllNodes(),c=a||"undefined"==typeof window?a:window.innerWidth,l=h||"undefined"==typeof window?h:window.innerHeight,f=s||[c/2,l/2],d=[],u&&u.forEach((function(t){d.push({id:t.id,data:{x:.9*(Math.random()-.5)*c+f[0],y:.9*(Math.random()-.5)*l+f[1]}})})),t&&d.forEach((function(t){return e.mergeNodeData(t.id,{x:t.data.x,y:t.data.y})})),[2,{nodes:d,edges:e.getAllEdges()}]}))}))},t}(),grid:ee,radial:Le,force:jt,d3force:Ct,fruchterman:Zt,forceAtlas2:Xt};function Ke(){(null==_e?void 0:_e.stop)&&_e.stop()}function Je(t,e){return o(this,void 0,void 0,(function(){var r,n,o,s,a,h,u,c,l;return i(this,(function(i){switch(i.label){case 0:if(r=t.layout,n=r.id,o=r.options,s=r.iterations,a=t.nodes,h=t.edges,u=new f({nodes:a,edges:h}),!(c=He[n]))throw new Error("Unknown layout id: ".concat(n));return[4,(_e=new c(o)).execute(u)];case 1:return l=i.sent(),(d=_e).tick&&d.stop&&(_e.stop(),l=_e.tick(s)),[2,[l,e]]}var d}))}))}addEventListener("message",(function(t){var r,n=t.data,o=n.type,i=n.method,s=n.id,a=n.params;"RPC"===o&&i&&((r=e[i])?Promise.resolve().then((function(){return r.apply(e,a)})):Promise.reject("No such method")).then((function(t){postMessage({type:"RPC",id:s,result:t})})).catch((function(t){var e={message:t};t.stack&&(e.message=t.message,e.stack=t.stack,e.name=t.name),postMessage({type:"RPC",id:s,error:e})}))})),postMessage({type:"RPC",method:"ready"});\n//# sourceMappingURL=6b692814699bee26e220.worker.js.map']))),n(t,o),t}},475:t=>{t.exports=function(t,e){var r=0,n={};t.addEventListener("message",(function(e){var r=e.data;if("RPC"===r.type)if(r.id){var o=n[r.id];o&&(delete n[r.id],r.error?o[1](Object.assign(Error(r.error.message),r.error)):o[0](r.result))}else{var i=document.createEvent("Event");i.initEvent(r.method,!1,!1),i.data=r.params,t.dispatchEvent(i)}})),e.forEach((function(e){t[e]=function(){var o=arguments;return new Promise((function(i,s){var a=++r;n[a]=[i,s],t.postMessage({type:"RPC",id:a,method:e,params:[].slice.call(o)})}))}}))}}},e={};function r(n){var o=e[n];if(void 0!==o)return o.exports;var i=e[n]={exports:{}};return t[n](i,i.exports,r),i.exports}r.n=t=>{var e=t&&t.__esModule?()=>t.default:()=>t;return r.d(e,{a:e}),e},r.d=(t,e)=>{for(var n in e)r.o(e,n)&&!r.o(t,n)&&Object.defineProperty(t,n,{enumerable:!0,get:e[n]})},r.o=(t,e)=>Object.prototype.hasOwnProperty.call(t,e);var n={};(()=>{r.d(n,{SB:()=>q,W1:()=>H,jA:()=>Ht,E9:()=>pe,y7:()=>oe,O2:()=>me,Me:()=>ve,AI:()=>Je,D4:()=>rr,_5:()=>cr,y9:()=>G,_A:()=>f,d9:()=>_,ul:()=>D,qs:()=>w,jE:()=>z,tO:()=>O,zJ:()=>v,h$:()=>N,BI:()=>k,$y:()=>I,H0:()=>E,kJ:()=>d,hY:()=>dr,qR:()=>fr,i_:()=>lr,nu:()=>x,He:()=>g,A3:()=>b});var t=function(e,r){return t=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(t,e){t.__proto__=e}||function(t,e){for(var r in e)Object.prototype.hasOwnProperty.call(e,r)&&(t[r]=e[r])},t(e,r)},e=function(){return e=Object.assign||function(t){for(var e,r=1,n=arguments.length;r<n;r++)for(var o in e=arguments[r])Object.prototype.hasOwnProperty.call(e,o)&&(t[o]=e[o]);return t},e.apply(this,arguments)};function o(t,e){var r={};for(var n in t)Object.prototype.hasOwnProperty.call(t,n)&&e.indexOf(n)<0&&(r[n]=t[n]);if(null!=t&&"function"==typeof Object.getOwnPropertySymbols){var o=0;for(n=Object.getOwnPropertySymbols(t);o<n.length;o++)e.indexOf(n[o])<0&&Object.prototype.propertyIsEnumerable.call(t,n[o])&&(r[n[o]]=t[n[o]])}return r}function i(t,e,r,n){return new(r||(r=Promise))((function(o,i){function s(t){try{u(n.next(t))}catch(t){i(t)}}function a(t){try{u(n.throw(t))}catch(t){i(t)}}function u(t){var e;t.done?o(t.value):(e=t.value,e instanceof r?e:new r((function(t){t(e)}))).then(s,a)}u((n=n.apply(t,e||[])).next())}))}function s(t,e){var r,n,o,i,s={label:0,sent:function(){if(1&o[0])throw o[1];return o[1]},trys:[],ops:[]};return i={next:a(0),throw:a(1),return:a(2)},"function"==typeof Symbol&&(i[Symbol.iterator]=function(){return this}),i;function a(a){return function(u){return function(a){if(r)throw new TypeError("Generator is already executing.");for(;i&&(i=0,a[0]&&(s=0)),s;)try{if(r=1,n&&(o=2&a[0]?n.return:a[0]?n.throw||((o=n.return)&&o.call(n),0):n.next)&&!(o=o.call(n,a[1])).done)return o;switch(n=0,o&&(a=[2&a[0],o.value]),a[0]){case 0:case 1:o=a;break;case 4:return s.label++,{value:a[1],done:!1};case 5:s.label++,n=a[1],a=[0];continue;case 7:a=s.ops.pop(),s.trys.pop();continue;default:if(!((o=(o=s.trys).length>0&&o[o.length-1])||6!==a[0]&&2!==a[0])){s=0;continue}if(3===a[0]&&(!o||a[1]>o[0]&&a[1]<o[3])){s.label=a[1];break}if(6===a[0]&&s.label<o[1]){s.label=o[1],o=a;break}if(o&&s.label<o[2]){s.label=o[2],s.ops.push(a);break}o[2]&&s.ops.pop(),s.trys.pop();continue}a=e.call(t,s)}catch(t){a=[6,t],n=0}finally{r=o=0}if(5&a[0])throw a[1];return{value:a[0]?a[1]:void 0,done:!0}}([a,u])}}}function a(t,e){var r="function"==typeof Symbol&&t[Symbol.iterator];if(!r)return t;var n,o,i=r.call(t),s=[];try{for(;(void 0===e||e-- >0)&&!(n=i.next()).done;)s.push(n.value)}catch(t){o={error:t}}finally{try{n&&!n.done&&(r=i.return)&&r.call(i)}finally{if(o)throw o.error}}return s}function u(t,e,r){if(r||2===arguments.length)for(var n,o=0,i=e.length;o<i;o++)!n&&o in e||(n||(n=Array.prototype.slice.call(e,0,o)),n[o]=e[o]);return t.concat(n||Array.prototype.slice.call(e))}Object.create,Object.create;var h,c,l=/-(\w)/g,f=(h=function(t){return t.replace(l,(function(t,e){return e?e.toUpperCase():""}))},c=Object.create(null),function(t){return c[t]||(c[t]=h(t))}),d=Array.isArray,g=function(t){var e=parseFloat(t);return isNaN(e)?t:e},p={}.toString;const y=function(t,e){return p.call(t)==="[object "+e+"]"},m=function(t){return y(t,"Number")};var w=function(t){for(var e=[],r=t.length,n=0;n<r;n+=1){e[n]=[];for(var o=0;o<r;o+=1)n===o?e[n][o]=0:0!==t[n][o]&&t[n][o]?e[n][o]=t[n][o]:e[n][o]=1/0}for(var i=0;i<r;i+=1)for(n=0;n<r;n+=1)for(o=0;o<r;o+=1)e[n][o]>e[n][i]+e[i][o]&&(e[n][o]=e[n][i]+e[i][o]);return e},v=function(t,e){var r=t.nodes,n=t.edges,o=[],i={};if(!r)throw new Error("invalid nodes data!");return r&&r.forEach((function(t,e){i[t.id]=e,o.push([])})),null==n||n.forEach((function(t){var r=t.source,n=t.target,s=i[r],a=i[n];void 0!==s&&void 0!==a&&(o[s][a]=1,e||(o[a][s]=1))})),o},x=function(t,e){var r=[];return t.forEach((function(t){var n=[];t.forEach((function(t){n.push(t*e)})),r.push(n)})),r},M=function(t,e){if(t&&t.children)for(var r=t.children.length-1;r>=0;r--)if(!M(t.children[r],e))return;return!!e(t)},b=function(t,e){"function"==typeof e&&M(t,e)},E=function(t){var e=1/0,r=1/0,n=-1/0,o=-1/0;return t.forEach((function(t){var i=t.data.size;d(i)?1===i.length&&(i=[i[0],i[0]]):m(i)?i=[i,i]:(void 0===i||isNaN(i))&&(i=[30,30]);var s=[i[0]/2,i[1]/2],a=t.data.x-s[0],u=t.data.x+s[0],h=t.data.y-s[1],c=t.data.y+s[1];e>a&&(e=a),r>h&&(r=h),n<u&&(n=u),o<c&&(o=c)})),{minX:e,minY:r,maxX:n,maxY:o}},N=function(t){var e={x:0,y:0};t.forEach((function(t){e.x+=t.data.x||0,e.y+=t.data.y||0}));var r=t.length||1;return{x:e.x/r,y:e.y/r}},S=function(t,e,r){var n,o;return"source"===t?(null===(n=null==r?void 0:r.find((function(t){return t.target===e.id})))||void 0===n?void 0:n.source)||{}:(null===(o=null==r?void 0:r.find((function(t){return t.source===e.id})))||void 0===o?void 0:o.target)||{}},A=function(t,e,r){var n=[];switch(t){case"source":n=null==r?void 0:r.filter((function(t){return t.source===e.id})).map((function(t){return t.target}));break;case"target":n=null==r?void 0:r.filter((function(t){return t.target===e.id})).map((function(t){return t.source}));break;case"both":n=null==r?void 0:r.filter((function(t){return t.source===e.id})).map((function(t){return t.target})).concat(null==r?void 0:r.filter((function(t){return t.target===e.id})).map((function(t){return t.source})))}var o=new Set(n);return Array.from(o)},k=function(t,e,r,n,o,i){var s=o[e.id],a=s.in,u=s.out,h=e,c=[];0===a?(h=S("source",e,r),c=A("both",h,r).map((function(t){return i[t]}))):0===u&&(h=S("target",e,r),c=A("both",h,r).map((function(t){return i[t]}))),c=c.filter((function(t){return o[t.id]&&(0===o[t.id].in||0===o[t.id].out)}));var l=function(t,e,r,n,o){var i=r[e]||"",s=(null==n?void 0:n.filter((function(t){return t[e]===i})))||[];return"leaf"===t&&(s=s.filter((function(t){var e,r;return 0===(null===(e=o[t.id])||void 0===e?void 0:e.in)||0===(null===(r=o[t.id])||void 0===r?void 0:r.out)}))),s}(t,n,e,c,o);return{coreNode:h,relativeLeafNodes:c,sameTypeLeafNodes:l}},I=function(t,e){return Math.sqrt((t.x-e.x)*(t.x-e.x)+(t.y-e.y)*(t.y-e.y))},_=function(t){if(null===t)return t;if(t instanceof Date)return new Date(t.getTime());if(t instanceof Array){var e=[];return t.forEach((function(t){e.push(t)})),e.map((function(t){return _(t)}))}if("object"==typeof t){var r={};return Object.keys(t).forEach((function(e){r[e]=_(t[e])})),r}return t},D=function(t,e){var r=_(t);return r.data=r.data||{},e&&(m(r.data.x)||(r.data.x=Math.random()*e[0]),m(r.data.y)||(r.data.y=Math.random()*e[1])),r};const R=function(t){return"function"==typeof t},T=function(t){var e=typeof t;return null!==t&&"object"===e||"function"===e};function z(t,e){return R(e)?e:m(e)?function(){return e}:function(){return t}}function O(t,e,r){return void 0===r&&(r=!0),e||0===e?R(e)?e:m(e)?function(){return e}:d(e)?function(){if(r){var n=Math.max.apply(Math,u([],a(e),!1));return isNaN(n)?t:n}return e}:T(e)?function(){if(r){var n=Math.max(e.width,e.height);return isNaN(n)?t:n}return[e.width,e.height]}:function(){return t}:function(e){var r=(e.data||{}).size;return r?d(r)?r[0]>r[1]?r[0]:r[1]:T(r)?r.width>r.height?r.width:r.height:r:t}}var P=function(t,r,n){var o=t.getAllNodes(),i=t.getAllEdges();return(null==o?void 0:o.length)?1===o.length?(r&&t.mergeNodeData(o[0].id,{x:n[0],y:n[1]}),{nodes:[e(e({},o[0]),{data:e(e({},o[0].data),{x:n[0],y:n[1]})})],edges:i}):void 0:{nodes:[],edges:i}},C={radius:null,startRadius:null,endRadius:null,startAngle:0,endAngle:2*Math.PI,clockwise:!0,divisions:1,ordering:null,angleRatio:1},q=function(){function t(t){void 0===t&&(t={}),this.options=t,this.id="circular",this.options=e(e({},C),t)}return t.prototype.execute=function(t,e){return i(this,void 0,void 0,(function(){return s(this,(function(r){return[2,this.genericCircularLayout(!1,t,e)]}))}))},t.prototype.assign=function(t,e){return i(this,void 0,void 0,(function(){return s(this,(function(r){switch(r.label){case 0:return[4,this.genericCircularLayout(!0,t,e)];case 1:return r.sent(),[2]}}))}))},t.prototype.genericCircularLayout=function(t,r,n){return i(this,void 0,void 0,(function(){var o,i,u,h,c,l,f,d,g,p,y,m,w,v,x,M,b,E,N,S,A,k,I,_,R,T,C,q,j,V,W,$,G,B,U;return s(this,(function(s){if(o=e(e({},this.options),n),i=o.width,u=o.height,h=o.center,c=o.divisions,l=o.startAngle,f=void 0===l?0:l,d=o.endAngle,g=void 0===d?2*Math.PI:d,p=o.angleRatio,y=o.ordering,m=o.clockwise,w=o.nodeSpacing,v=o.nodeSize,x=r.getAllNodes(),M=r.getAllEdges(),b=a(F(i,u,h),3),E=b[0],N=b[1],S=b[2],!(A=null==x?void 0:x.length)||1===A)return[2,P(r,t,S)];for(k=(g-f)/A,I=o.radius,_=o.startRadius,R=o.endRadius,w?(T=z(10,w),C=O(10,v),q=-1/0,x.forEach((function(t){var e=C(t);q<e&&(q=e)})),j=0,x.forEach((function(t,e){j+=0===e?q||10:(T(t)||0)+(q||10)})),I=j/(2*Math.PI)):I||_||R?!_&&R?_=R:_&&!R&&(R=_):I=Math.min(N,E)/2,V=k*p,W=[],W="topology"===y?L(r,x):"topology-directed"===y?L(r,x,!0):"degree"===y?function(t,e){var r=[];return e.forEach((function(t,e){r.push(D(t))})),r.sort((function(e,r){return t.getDegree(e.id,"both")-t.getDegree(r.id,"both")})),r}(r,x):x.map((function(t){return D(t)})),$=Math.ceil(A/c),G=0;G<A;++G)(B=I)||null===_||null===R||(B=_+G*(R-_)/(A-1)),B||(B=10+100*G/(A-1)),U=f+G%$*V+2*Math.PI/c*Math.floor(G/$),m||(U=g-G%$*V-2*Math.PI/c*Math.floor(G/$)),W[G].data.x=S[0]+Math.cos(U)*B,W[G].data.y=S[1]+Math.sin(U)*B;return t&&W.forEach((function(t){r.mergeNodeData(t.id,{x:t.data.x,y:t.data.y})})),[2,{nodes:W,edges:M}]}))}))},t}(),L=function(t,e,r){void 0===r&&(r=!1);var n=[D(e[0])],o={},i=e.length;o[e[0].id]=!0;var s=0;return e.forEach((function(a,u){if(0!==u)if(u!==i-1&&t.getDegree(a.id,"both")===t.getDegree(e[u+1].id,"both")&&!t.areNeighbors(n[s].id,a.id)||o[a.id]){for(var h=r?t.getSuccessors(n[s].id):t.getNeighbors(n[s].id),c=!1,l=0;l<h.length;l++){var f=h[l];if(t.getDegree(f.id)===t.getDegree(a.id)&&!o[f.id]){n.push(D(f)),o[f.id]=!0,c=!0;break}}for(var d=0;!c&&(o[e[d].id]||(n.push(D(e[d])),o[e[d].id]=!0,c=!0),++d!==i););}else n.push(D(a)),o[a.id]=!0,s++})),n},F=function(t,e,r){var n=t,o=e,i=r;return n||"undefined"==typeof window||(n=window.innerWidth),o||"undefined"==typeof window||(o=window.innerHeight),i||(i=[n/2,o/2]),[n,o,i]},j=r(161),V=r.n(j),W=r(825),$=r.n(W),G=function(e){function r(t,r,n){var o=e.call(this)||this;return o.graph=t,o.layout=r,o.options=n,o.spawnWorker(),o}return function(e,r){if("function"!=typeof r&&null!==r)throw new TypeError("Class extends value "+String(r)+" is not a constructor or null");function n(){this.constructor=e}t(e,r),e.prototype=null===r?Object.create(r):(n.prototype=r.prototype,new n)}(r,e),r.prototype.spawnWorker=function(){this.worker&&this.worker.terminate(),this.worker=$()(),this.running&&(this.running=!1,this.execute())},r.prototype.execute=function(){var t;return i(this,void 0,void 0,(function(){var e,r,n,i;return s(this,(function(s){switch(s.label){case 0:return this.running?[2,this]:(this.running=!0,(e=this.layout.options).onTick,r=o(e,["onTick"]),n={layout:{id:this.layout.id,options:r,iterations:null===(t=this.options)||void 0===t?void 0:t.iterations},nodes:this.graph.getAllNodes(),edges:this.graph.getAllEdges()},i=new Float32Array([0]),[4,this.worker.calculateLayout(n,[i])]);case 1:return[2,a.apply(void 0,[s.sent(),1])[0]]}}))}))},r.prototype.stop=function(){return this.running=!1,this.worker.stopLayout(),this},r.prototype.kill=function(){this.worker&&this.worker.terminate()},r.prototype.isRunning=function(){return this.running},r}(V());const B=function(t){return y(t,"String")};var U={nodeSize:30,nodeSpacing:10,preventOverlap:!1,sweep:void 0,equidistant:!1,startAngle:1.5*Math.PI,clockwise:!0,maxLevelDiff:void 0,sortBy:"degree"},H=function(){function t(t){void 0===t&&(t={}),this.options=t,this.id="concentric",this.options=e(e({},U),t)}return t.prototype.execute=function(t,e){return i(this,void 0,void 0,(function(){return s(this,(function(r){return[2,this.genericConcentricLayout(!1,t,e)]}))}))},t.prototype.assign=function(t,e){return i(this,void 0,void 0,(function(){return s(this,(function(r){return this.genericConcentricLayout(!0,t,e),[2]}))}))},t.prototype.genericConcentricLayout=function(t,r,n){return i(this,void 0,void 0,(function(){var o,i,a,u,h,c,l,f,g,p,y,w,v,x,M,b,E,N,S,A,k,I,_,z,O,C,q,L,F,j,V,W,$,G,U,H,K,J;return s(this,(function(s){if(o=e(e({},this.options),n),i=o.center,a=o.width,u=o.height,h=o.sortBy,c=o.maxLevelDiff,l=o.sweep,f=o.clockwise,g=o.equidistant,p=o.preventOverlap,y=o.startAngle,w=void 0===y?1.5*Math.PI:y,v=o.nodeSize,x=o.nodeSpacing,M=r.getAllNodes(),b=r.getAllEdges(),E=a||"undefined"==typeof window?a:window.innerWidth,N=u||"undefined"==typeof window?u:window.innerHeight,S=i||[E/2,N/2],!(null==M?void 0:M.length)||1===M.length)return[2,P(r,t,S)];if(A=[],I=0,k=d(v)?Math.max(v[0],v[1]):v,d(x)?I=Math.max(x[0],x[1]):m(x)&&(I=x),M.forEach((function(t){var e=D(t);A.push(e);var r=k,n=e.data;d(n.size)?r=Math.max(n.size[0],n.size[1]):m(n.size)?r=n.size:T(n.size)&&(r=Math.max(n.size.width,n.size.height)),k=Math.max(k,r),R(x)&&(I=Math.max(x(t),I))})),_={},A.forEach((function(t,e){_[t.id]=e})),B(z=h)&&void 0!==A[0].data[z]||(z="degree"),"degree"===z?A.sort((function(t,e){return r.getDegree(e.id,"both")-r.getDegree(t.id,"both")})):A.sort((function(t,e){return e.data[z]-t.data[z]})),O=A[0],C=(c||("degree"===z?r.getDegree(O.id,"both"):O.data[z]))/4,L=(q=[{nodes:[]}])[0],A.forEach((function(t){if(L.nodes.length>0){var e="degree"===z?Math.abs(r.getDegree(L.nodes[0].id,"both")-r.getDegree(t.id,"both")):Math.abs(L.nodes[0].data[z]-t.data[z]);C&&e>=C&&(L={nodes:[]},q.push(L))}L.nodes.push(t)})),F=k+I,p||(j=q.length>0&&q[0].nodes.length>1,V=Math.min(E,N)/2-F,W=V/(q.length+(j?1:0)),F=Math.min(F,W)),$=0,q.forEach((function(t){var e=void 0===l?2*Math.PI-2*Math.PI/t.nodes.length:l;if(t.dTheta=e/Math.max(1,t.nodes.length-1),t.nodes.length>1&&p){var r=Math.cos(t.dTheta)-Math.cos(0),n=Math.sin(t.dTheta)-Math.sin(0),o=Math.sqrt(F*F/(r*r+n*n));$=Math.max(o,$)}t.r=$,$+=F})),g){for(G=0,U=0,H=0;H<q.length;H++)K=q[H],J=(K.r||0)-U,G=Math.max(G,J);U=0,q.forEach((function(t,e){0===e&&(U=t.r||0),t.r=U,U+=G}))}return q.forEach((function(t){var e=t.dTheta||0,r=t.r||0;t.nodes.forEach((function(t,n){var o=w+(f?1:-1)*e*n;t.data.x=S[0]+r*Math.cos(o),t.data.y=S[1]+r*Math.sin(o)}))})),t&&A.forEach((function(t){return r.mergeNodeData(t.id,{x:t.data.x,y:t.data.y})})),[2,{nodes:A,edges:b}]}))}))},t}();function K(t,e,r,n){if(isNaN(e)||isNaN(r))return t;var o,i,s,a,u,h,c,l,f,d=t._root,g={data:n},p=t._x0,y=t._y0,m=t._x1,w=t._y1;if(!d)return t._root=g,t;for(;d.length;)if((h=e>=(i=(p+m)/2))?p=i:m=i,(c=r>=(s=(y+w)/2))?y=s:w=s,o=d,!(d=d[l=c<<1|h]))return o[l]=g,t;if(a=+t._x.call(null,d.data),u=+t._y.call(null,d.data),e===a&&r===u)return g.next=d,o?o[l]=g:t._root=g,t;do{o=o?o[l]=new Array(4):t._root=new Array(4),(h=e>=(i=(p+m)/2))?p=i:m=i,(c=r>=(s=(y+w)/2))?y=s:w=s}while((l=c<<1|h)==(f=(u>=s)<<1|a>=i));return o[f]=d,o[l]=g,t}function J(t,e,r,n,o){this.node=t,this.x0=e,this.y0=r,this.x1=n,this.y1=o}function Y(t){return t[0]}function X(t){return t[1]}function Z(t,e,r){var n=new Q(null==e?Y:e,null==r?X:r,NaN,NaN,NaN,NaN);return null==t?n:n.addAll(t)}function Q(t,e,r,n,o,i){this._x=t,this._y=e,this._x0=r,this._y0=n,this._x1=o,this._y1=i,this._root=void 0}function tt(t){for(var e={data:t.data},r=e;t=t.next;)r=r.next={data:t.data};return e}var et=Z.prototype=Q.prototype;function rt(t){return function(){return t}}function nt(t){return 1e-6*(t()-.5)}et.copy=function(){var t,e,r=new Q(this._x,this._y,this._x0,this._y0,this._x1,this._y1),n=this._root;if(!n)return r;if(!n.length)return r._root=tt(n),r;for(t=[{source:n,target:r._root=new Array(4)}];n=t.pop();)for(var o=0;o<4;++o)(e=n.source[o])&&(e.length?t.push({source:e,target:n.target[o]=new Array(4)}):n.target[o]=tt(e));return r},et.add=function(t){const e=+this._x.call(null,t),r=+this._y.call(null,t);return K(this.cover(e,r),e,r,t)},et.addAll=function(t){var e,r,n,o,i=t.length,s=new Array(i),a=new Array(i),u=1/0,h=1/0,c=-1/0,l=-1/0;for(r=0;r<i;++r)isNaN(n=+this._x.call(null,e=t[r]))||isNaN(o=+this._y.call(null,e))||(s[r]=n,a[r]=o,n<u&&(u=n),n>c&&(c=n),o<h&&(h=o),o>l&&(l=o));if(u>c||h>l)return this;for(this.cover(u,h).cover(c,l),r=0;r<i;++r)K(this,s[r],a[r],t[r]);return this},et.cover=function(t,e){if(isNaN(t=+t)||isNaN(e=+e))return this;var r=this._x0,n=this._y0,o=this._x1,i=this._y1;if(isNaN(r))o=(r=Math.floor(t))+1,i=(n=Math.floor(e))+1;else{for(var s,a,u=o-r||1,h=this._root;r>t||t>=o||n>e||e>=i;)switch(a=(e<n)<<1|t<r,(s=new Array(4))[a]=h,h=s,u*=2,a){case 0:o=r+u,i=n+u;break;case 1:r=o-u,i=n+u;break;case 2:o=r+u,n=i-u;break;case 3:r=o-u,n=i-u}this._root&&this._root.length&&(this._root=h)}return this._x0=r,this._y0=n,this._x1=o,this._y1=i,this},et.data=function(){var t=[];return this.visit((function(e){if(!e.length)do{t.push(e.data)}while(e=e.next)})),t},et.extent=function(t){return arguments.length?this.cover(+t[0][0],+t[0][1]).cover(+t[1][0],+t[1][1]):isNaN(this._x0)?void 0:[[this._x0,this._y0],[this._x1,this._y1]]},et.find=function(t,e,r){var n,o,i,s,a,u,h,c=this._x0,l=this._y0,f=this._x1,d=this._y1,g=[],p=this._root;for(p&&g.push(new J(p,c,l,f,d)),null==r?r=1/0:(c=t-r,l=e-r,f=t+r,d=e+r,r*=r);u=g.pop();)if(!(!(p=u.node)||(o=u.x0)>f||(i=u.y0)>d||(s=u.x1)<c||(a=u.y1)<l))if(p.length){var y=(o+s)/2,m=(i+a)/2;g.push(new J(p[3],y,m,s,a),new J(p[2],o,m,y,a),new J(p[1],y,i,s,m),new J(p[0],o,i,y,m)),(h=(e>=m)<<1|t>=y)&&(u=g[g.length-1],g[g.length-1]=g[g.length-1-h],g[g.length-1-h]=u)}else{var w=t-+this._x.call(null,p.data),v=e-+this._y.call(null,p.data),x=w*w+v*v;if(x<r){var M=Math.sqrt(r=x);c=t-M,l=e-M,f=t+M,d=e+M,n=p.data}}return n},et.remove=function(t){if(isNaN(i=+this._x.call(null,t))||isNaN(s=+this._y.call(null,t)))return this;var e,r,n,o,i,s,a,u,h,c,l,f,d=this._root,g=this._x0,p=this._y0,y=this._x1,m=this._y1;if(!d)return this;if(d.length)for(;;){if((h=i>=(a=(g+y)/2))?g=a:y=a,(c=s>=(u=(p+m)/2))?p=u:m=u,e=d,!(d=d[l=c<<1|h]))return this;if(!d.length)break;(e[l+1&3]||e[l+2&3]||e[l+3&3])&&(r=e,f=l)}for(;d.data!==t;)if(n=d,!(d=d.next))return this;return(o=d.next)&&delete d.next,n?(o?n.next=o:delete n.next,this):e?(o?e[l]=o:delete e[l],(d=e[0]||e[1]||e[2]||e[3])&&d===(e[3]||e[2]||e[1]||e[0])&&!d.length&&(r?r[f]=d:this._root=d),this):(this._root=o,this)},et.removeAll=function(t){for(var e=0,r=t.length;e<r;++e)this.remove(t[e]);return this},et.root=function(){return this._root},et.size=function(){var t=0;return this.visit((function(e){if(!e.length)do{++t}while(e=e.next)})),t},et.visit=function(t){var e,r,n,o,i,s,a=[],u=this._root;for(u&&a.push(new J(u,this._x0,this._y0,this._x1,this._y1));e=a.pop();)if(!t(u=e.node,n=e.x0,o=e.y0,i=e.x1,s=e.y1)&&u.length){var h=(n+i)/2,c=(o+s)/2;(r=u[3])&&a.push(new J(r,h,c,i,s)),(r=u[2])&&a.push(new J(r,n,c,h,s)),(r=u[1])&&a.push(new J(r,h,o,i,c)),(r=u[0])&&a.push(new J(r,n,o,h,c))}return this},et.visitAfter=function(t){var e,r=[],n=[];for(this._root&&r.push(new J(this._root,this._x0,this._y0,this._x1,this._y1));e=r.pop();){var o=e.node;if(o.length){var i,s=e.x0,a=e.y0,u=e.x1,h=e.y1,c=(s+u)/2,l=(a+h)/2;(i=o[0])&&r.push(new J(i,s,a,c,l)),(i=o[1])&&r.push(new J(i,c,a,u,l)),(i=o[2])&&r.push(new J(i,s,l,c,h)),(i=o[3])&&r.push(new J(i,c,l,u,h))}n.push(e)}for(;e=n.pop();)t(e.node,e.x0,e.y0,e.x1,e.y1);return this},et.x=function(t){return arguments.length?(this._x=t,this):this._x},et.y=function(t){return arguments.length?(this._y=t,this):this._y};var ot={value:()=>{}};function it(){for(var t,e=0,r=arguments.length,n={};e<r;++e){if(!(t=arguments[e]+"")||t in n||/[\s.]/.test(t))throw new Error("illegal type: "+t);n[t]=[]}return new st(n)}function st(t){this._=t}function at(t,e){for(var r,n=0,o=t.length;n<o;++n)if((r=t[n]).name===e)return r.value}function ut(t,e,r){for(var n=0,o=t.length;n<o;++n)if(t[n].name===e){t[n]=ot,t=t.slice(0,n).concat(t.slice(n+1));break}return null!=r&&t.push({name:e,value:r}),t}st.prototype=it.prototype={constructor:st,on:function(t,e){var r,n,o=this._,i=(n=o,(t+"").trim().split(/^|\s+/).map((function(t){var e="",r=t.indexOf(".");if(r>=0&&(e=t.slice(r+1),t=t.slice(0,r)),t&&!n.hasOwnProperty(t))throw new Error("unknown type: "+t);return{type:t,name:e}}))),s=-1,a=i.length;if(!(arguments.length<2)){if(null!=e&&"function"!=typeof e)throw new Error("invalid callback: "+e);for(;++s<a;)if(r=(t=i[s]).type)o[r]=ut(o[r],t.name,e);else if(null==e)for(r in o)o[r]=ut(o[r],t.name,null);return this}for(;++s<a;)if((r=(t=i[s]).type)&&(r=at(o[r],t.name)))return r},copy:function(){var t={},e=this._;for(var r in e)t[r]=e[r].slice();return new st(t)},call:function(t,e){if((r=arguments.length-2)>0)for(var r,n,o=new Array(r),i=0;i<r;++i)o[i]=arguments[i+2];if(!this._.hasOwnProperty(t))throw new Error("unknown type: "+t);for(i=0,r=(n=this._[t]).length;i<r;++i)n[i].value.apply(e,o)},apply:function(t,e,r){if(!this._.hasOwnProperty(t))throw new Error("unknown type: "+t);for(var n=this._[t],o=0,i=n.length;o<i;++o)n[o].value.apply(e,r)}};const ht=it;var ct,lt,ft=0,dt=0,gt=0,pt=1e3,yt=0,mt=0,wt=0,vt="object"==typeof performance&&performance.now?performance:Date,xt="object"==typeof window&&window.requestAnimationFrame?window.requestAnimationFrame.bind(window):function(t){setTimeout(t,17)};function Mt(){return mt||(xt(bt),mt=vt.now()+wt)}function bt(){mt=0}function Et(){this._call=this._time=this._next=null}function Nt(t,e,r){var n=new Et;return n.restart(t,e,r),n}function St(){mt=(yt=vt.now())+wt,ft=dt=0;try{!function(){Mt(),++ft;for(var t,e=ct;e;)(t=mt-e._time)>=0&&e._call.call(void 0,t),e=e._next;--ft}()}finally{ft=0,function(){for(var t,e,r=ct,n=1/0;r;)r._call?(n>r._time&&(n=r._time),t=r,r=r._next):(e=r._next,r._next=null,r=t?t._next=e:ct=e);lt=t,kt(n)}(),mt=0}}function At(){var t=vt.now(),e=t-yt;e>pt&&(wt-=e,yt=t)}function kt(t){ft||(dt&&(dt=clearTimeout(dt)),t-mt>24?(t<1/0&&(dt=setTimeout(St,t-vt.now()-wt)),gt&&(gt=clearInterval(gt))):(gt||(yt=vt.now(),gt=setInterval(At,pt)),ft=1,xt(St)))}Et.prototype=Nt.prototype={constructor:Et,restart:function(t,e,r){if("function"!=typeof t)throw new TypeError("callback is not a function");r=(null==r?Mt():+r)+(null==e?0:+e),this._next||lt===this||(lt?lt._next=this:ct=this,lt=this),this._call=t,this._time=r,kt()},stop:function(){this._call&&(this._call=null,this._time=1/0,kt())}};const It=1664525,_t=1013904223,Dt=4294967296;function Rt(t){return t.x}function Tt(t){return t.y}var zt=10,Ot=Math.PI*(3-Math.sqrt(5));function Pt(t){var e,r=1,n=.001,o=1-Math.pow(n,1/300),i=0,s=.6,a=new Map,u=Nt(l),h=ht("tick","end"),c=function(){let t=1;return()=>(t=(It*t+_t)%Dt)/Dt}();function l(){f(),h.call("tick",e),r<n&&(u.stop(),h.call("end",e))}function f(n){var u,h,c=t.length;void 0===n&&(n=1);for(var l=0;l<n;++l)for(r+=(i-r)*o,a.forEach((function(t){t(r)})),u=0;u<c;++u)null==(h=t[u]).fx?h.x+=h.vx*=s:(h.x=h.fx,h.vx=0),null==h.fy?h.y+=h.vy*=s:(h.y=h.fy,h.vy=0);return e}function d(){for(var e,r=0,n=t.length;r<n;++r){if((e=t[r]).index=r,null!=e.fx&&(e.x=e.fx),null!=e.fy&&(e.y=e.fy),isNaN(e.x)||isNaN(e.y)){var o=zt*Math.sqrt(.5+r),i=r*Ot;e.x=o*Math.cos(i),e.y=o*Math.sin(i)}(isNaN(e.vx)||isNaN(e.vy))&&(e.vx=e.vy=0)}}function g(e){return e.initialize&&e.initialize(t,c),e}return null==t&&(t=[]),d(),e={tick:f,restart:function(){return u.restart(l),e},stop:function(){return u.stop(),e},nodes:function(r){return arguments.length?(t=r,d(),a.forEach(g),e):t},alpha:function(t){return arguments.length?(r=+t,e):r},alphaMin:function(t){return arguments.length?(n=+t,e):n},alphaDecay:function(t){return arguments.length?(o=+t,e):+o},alphaTarget:function(t){return arguments.length?(i=+t,e):i},velocityDecay:function(t){return arguments.length?(s=1-t,e):1-s},randomSource:function(t){return arguments.length?(c=t,a.forEach(g),e):c},force:function(t,r){return arguments.length>1?(null==r?a.delete(t):a.set(t,g(r)),e):a.get(t)},find:function(e,r,n){var o,i,s,a,u,h=0,c=t.length;for(null==n?n=1/0:n*=n,h=0;h<c;++h)(s=(o=e-(a=t[h]).x)*o+(i=r-a.y)*i)<n&&(u=a,n=s);return u},on:function(t,r){return arguments.length>1?(h.on(t,r),e):h.on(t)}}}function Ct(){var t,e,r,n,o,i=rt(-30),s=1,a=1/0,u=.81;function h(r){var o,i=t.length,s=Z(t,Rt,Tt).visitAfter(l);for(n=r,o=0;o<i;++o)e=t[o],s.visit(f)}function c(){if(t){var e,r,n=t.length;for(o=new Array(n),e=0;e<n;++e)r=t[e],o[r.index]=+i(r,e,t)}}function l(t){var e,r,n,i,s,a=0,u=0;if(t.length){for(n=i=s=0;s<4;++s)(e=t[s])&&(r=Math.abs(e.value))&&(a+=e.value,u+=r,n+=r*e.x,i+=r*e.y);t.x=n/u,t.y=i/u}else{(e=t).x=e.data.x,e.y=e.data.y;do{a+=o[e.data.index]}while(e=e.next)}t.value=a}function f(t,i,h,c){if(!t.value)return!0;var l=t.x-e.x,f=t.y-e.y,d=c-i,g=l*l+f*f;if(d*d/u<g)return g<a&&(0===l&&(g+=(l=nt(r))*l),0===f&&(g+=(f=nt(r))*f),g<s&&(g=Math.sqrt(s*g)),e.vx+=l*t.value*n/g,e.vy+=f*t.value*n/g),!0;if(!(t.length||g>=a)){(t.data!==e||t.next)&&(0===l&&(g+=(l=nt(r))*l),0===f&&(g+=(f=nt(r))*f),g<s&&(g=Math.sqrt(s*g)));do{t.data!==e&&(d=o[t.data.index]*n/g,e.vx+=l*d,e.vy+=f*d)}while(t=t.next)}}return h.initialize=function(e,n){t=e,r=n,c()},h.strength=function(t){return arguments.length?(i="function"==typeof t?t:rt(+t),c(),h):i},h.distanceMin=function(t){return arguments.length?(s=t*t,h):Math.sqrt(s)},h.distanceMax=function(t){return arguments.length?(a=t*t,h):Math.sqrt(a)},h.theta=function(t){return arguments.length?(u=t*t,h):Math.sqrt(u)},h}function qt(t){return t.index}function Lt(t,e){var r=t.get(e);if(!r)throw new Error("node not found: "+e);return r}function Ft(t){var e,r,n,o,i,s,a=qt,u=function(t){return 1/Math.min(o[t.source.index],o[t.target.index])},h=rt(30),c=1;function l(n){for(var o=0,a=t.length;o<c;++o)for(var u,h,l,f,d,g,p,y=0;y<a;++y)h=(u=t[y]).source,f=(l=u.target).x+l.vx-h.x-h.vx||nt(s),d=l.y+l.vy-h.y-h.vy||nt(s),f*=g=((g=Math.sqrt(f*f+d*d))-r[y])/g*n*e[y],d*=g,l.vx-=f*(p=i[y]),l.vy-=d*p,h.vx+=f*(p=1-p),h.vy+=d*p}function f(){if(n){var s,u,h=n.length,c=t.length,l=new Map(n.map(((t,e)=>[a(t,e,n),t])));for(s=0,o=new Array(h);s<c;++s)(u=t[s]).index=s,"object"!=typeof u.source&&(u.source=Lt(l,u.source)),"object"!=typeof u.target&&(u.target=Lt(l,u.target)),o[u.source.index]=(o[u.source.index]||0)+1,o[u.target.index]=(o[u.target.index]||0)+1;for(s=0,i=new Array(c);s<c;++s)u=t[s],i[s]=o[u.source.index]/(o[u.source.index]+o[u.target.index]);e=new Array(c),d(),r=new Array(c),g()}}function d(){if(n)for(var r=0,o=t.length;r<o;++r)e[r]=+u(t[r],r,t)}function g(){if(n)for(var e=0,o=t.length;e<o;++e)r[e]=+h(t[e],e,t)}return null==t&&(t=[]),l.initialize=function(t,e){n=t,s=e,f()},l.links=function(e){return arguments.length?(t=e,f(),l):t},l.id=function(t){return arguments.length?(a=t,l):a},l.iterations=function(t){return arguments.length?(c=+t,l):c},l.strength=function(t){return arguments.length?(u="function"==typeof t?t:rt(+t),d(),l):u},l.distance=function(t){return arguments.length?(h="function"==typeof t?t:rt(+t),g(),l):h},l}function jt(t){return t.x+t.vx}function Vt(t){return t.y+t.vy}function Wt(t){var e,r,n,o=1,i=1;function s(){for(var t,s,u,h,c,l,f,d=e.length,g=0;g<i;++g)for(s=Z(e,jt,Vt).visitAfter(a),t=0;t<d;++t)u=e[t],l=r[u.index],f=l*l,h=u.x+u.vx,c=u.y+u.vy,s.visit(p);function p(t,e,r,i,s){var a=t.data,d=t.r,g=l+d;if(!a)return e>h+g||i<h-g||r>c+g||s<c-g;if(a.index>u.index){var p=h-a.x-a.vx,y=c-a.y-a.vy,m=p*p+y*y;m<g*g&&(0===p&&(m+=(p=nt(n))*p),0===y&&(m+=(y=nt(n))*y),m=(g-(m=Math.sqrt(m)))/m*o,u.vx+=(p*=m)*(g=(d*=d)/(f+d)),u.vy+=(y*=m)*g,a.vx-=p*(g=1-g),a.vy-=y*g)}}}function a(t){if(t.data)return t.r=r[t.data.index];for(var e=t.r=0;e<4;++e)t[e]&&t[e].r>t.r&&(t.r=t[e].r)}function u(){if(e){var n,o,i=e.length;for(r=new Array(i),n=0;n<i;++n)o=e[n],r[o.index]=+t(o,n,e)}}return"function"!=typeof t&&(t=rt(null==t?1:+t)),s.initialize=function(t,r){e=t,n=r,u()},s.iterations=function(t){return arguments.length?(i=+t,s):i},s.strength=function(t){return arguments.length?(o=+t,s):o},s.radius=function(e){return arguments.length?(t="function"==typeof e?e:rt(+e),u(),s):t},s}function $t(t){var e,r,n,o=rt(.1);function i(t){for(var o,i=0,s=e.length;i<s;++i)(o=e[i]).vx+=(n[i]-o.x)*r[i]*t}function s(){if(e){var i,s=e.length;for(r=new Array(s),n=new Array(s),i=0;i<s;++i)r[i]=isNaN(n[i]=+t(e[i],i,e))?0:+o(e[i],i,e)}}return"function"!=typeof t&&(t=rt(null==t?0:+t)),i.initialize=function(t){e=t,s()},i.strength=function(t){return arguments.length?(o="function"==typeof t?t:rt(+t),s(),i):o},i.x=function(e){return arguments.length?(t="function"==typeof e?e:rt(+e),s(),i):t},i}function Gt(t){var e,r,n,o=rt(.1);function i(t){for(var o,i=0,s=e.length;i<s;++i)(o=e[i]).vy+=(n[i]-o.y)*r[i]*t}function s(){if(e){var i,s=e.length;for(r=new Array(s),n=new Array(s),i=0;i<s;++i)r[i]=isNaN(n[i]=+t(e[i],i,e))?0:+o(e[i],i,e)}}return"function"!=typeof t&&(t=rt(null==t?0:+t)),i.initialize=function(t){e=t,s()},i.strength=function(t){return arguments.length?(o="function"==typeof t?t:rt(+t),s(),i):o},i.y=function(e){return arguments.length?(t="function"==typeof e?e:rt(+e),s(),i):t},i}function Bt(){function t(t){return function(){return t}}var e,r=function(t){return t.cluster},n=t(1),o=t(-1),i=t(100),s=t(.1),u=[0,0],h=[],c={},l=[],f=100,d=100,g={none:{x:0,y:0}},p=[],y="force",m=!0,w=.1;function v(t){if(!m)return v;e.tick(),M();for(var n=0,o=h.length,i=void 0,s=t*w;n<o;++n)(i=h[n]).vx+=(g[r(i)].x-i.x)*s,i.vy+=(g[r(i)].y-i.y)*s}function x(){h&&function(){if(h&&h.length){if(void 0===r(h[0]))throw Error("Couldnt find the grouping attribute for the nodes. Make sure to set it up with forceInBox.groupBy('clusterAttr') before calling .links()");var t,u,g,y,m,w=(t=[],u=[],g={},{},m=[],y=function(t){var e={};return t.forEach((function(t){var n=r(t);e[n]||(e[n]={count:0,sumforceNodeSize:0})})),t.forEach((function(t){var o=r(t),i=n(t),s=e[o];s.count=s.count+1,s.sumforceNodeSize=s.sumforceNodeSize+Math.PI*(i*i)*1.3,e[o]=s})),e}(h),m=function(t){var e={},n=[];return t.forEach((function(t){var n,o,i,s,a,u=(o=(n=t).source,i=n.target,(s=r(c[o]))<=(a=r(c[i]))?"".concat(s,"~").concat(a):"".concat(a,"~").concat(s)),h=0;void 0!==e[u]&&(h=e[u]),h+=1,e[u]=h})),Object.entries(e).forEach((function(t){var e=a(t,2),r=e[0],o=e[1],i=r.split("~")[0],s=r.split("~")[1];void 0!==i&&void 0!==s&&n.push({source:i,target:s,count:o})})),n}(l),Object.keys(y).forEach((function(e,r){var n=y[e];t.push({id:e,size:n.count,r:Math.sqrt(n.sumforceNodeSize/Math.PI)}),g[e]=r})),m.forEach((function(t){var e=t.source,r=t.target,n=g[e],o=g[r];void 0!==n&&void 0!==o&&u.push({source:n,target:o,count:t.count})})),{nodes:t,links:u});e=Pt(w.nodes).force("x",$t(f).strength(.1)).force("y",Gt(d).strength(.1)).force("collide",Wt((function(t){return t.r})).iterations(4)).force("charge",Ct().strength(o)).force("links",Ft(w.nodes.length?w.links:[]).distance(i).strength(s)),p=e.nodes(),M()}}()}function M(){return g={none:{x:0,y:0}},p.forEach((function(t){g[t.id]={x:t.x-u[0],y:t.y-u[1]}})),g}return v.initialize=function(t){h=t,x()},v.template=function(t){return arguments.length?(y=t,x(),v):y},v.groupBy=function(t){return arguments.length?"string"==typeof t?(r=function(e){return e[t]},v):(r=t,v):r},v.enableGrouping=function(t){return arguments.length?(m=t,v):m},v.strength=function(t){return arguments.length?(w=t,v):w},v.centerX=function(t){return arguments.length?(f=t,v):f},v.centerY=function(t){return arguments.length?(d=t,v):d},v.nodes=function(t){return arguments.length?(function(t){c={},t.forEach((function(t){c[t.id]=t}))}(t||[]),h=t||[],v):h},v.links=function(t){return arguments.length?(l=t||[],x(),v):l},v.forceNodeSize=function(e){return arguments.length?(n="function"==typeof e?e:t(+e),x(),v):n},v.nodeSize=v.forceNodeSize,v.forceCharge=function(e){return arguments.length?(o="function"==typeof e?e:t(+e),x(),v):o},v.forceLinkDistance=function(e){return arguments.length?(i="function"==typeof e?e:t(+e),x(),v):i},v.forceLinkStrength=function(e){return arguments.length?(s="function"==typeof e?e:t(+e),x(),v):s},v.offset=function(t){return arguments.length?(u=t,v):u},v.getFocis=M,v}var Ut={center:[0,0],preventOverlap:!1,nodeSize:void 0,nodeSpacing:void 0,linkDistance:50,forceSimulation:null,alphaDecay:.028,alphaMin:.001,alpha:.3,collideStrength:1,clustering:!1,clusterNodeStrength:-1,clusterEdgeStrength:.1,clusterEdgeDistance:100,clusterFociStrength:.8,clusterNodeSize:10},Ht=function(){function t(t){void 0===t&&(t={}),this.options=t,this.id="d3force",this.options=e(e({},Ut),t)}return t.prototype.execute=function(t,e){return i(this,void 0,void 0,(function(){return s(this,(function(r){return[2,this.genericForceLayout(!1,t,e)]}))}))},t.prototype.assign=function(t,e){return i(this,void 0,void 0,(function(){return s(this,(function(r){return this.genericForceLayout(!0,t,e),[2]}))}))},t.prototype.stop=function(){var t;null===(t=this.forceSimulation)||void 0===t||t.stop()},t.prototype.tick=function(t){var e=this;void 0===t&&(t=1),this.forceSimulation.tick(t);var r={nodes:Kt(this.lastLayoutNodes),edges:Jt(this.lastLayoutEdges)};return this.lastAssign&&r.nodes.forEach((function(t){return e.lastGraph.mergeNodeData(t.id,{x:t.data.x,y:t.data.y})})),r},t.prototype.genericForceLayout=function(t,r,n){return i(this,void 0,void 0,(function(){var o,i,a,u,h,c,l,f,d,g,p,y,m,w,v,x,M,b,E,N,S,A,k,I,_,R,T=this;return s(this,(function(s){return o=e(e({},this.options),n),i=r.getAllNodes(),a=r.getAllEdges(),u=i.map((function(t){var r,n;return e(e({},D(t)),{x:null===(r=t.data)||void 0===r?void 0:r.x,y:null===(n=t.data)||void 0===n?void 0:n.y})})),h=a.map((function(t){return D(t)})),this.lastLayoutNodes=u,this.lastLayoutEdges=h,this.lastAssign=t,this.lastGraph=r,c=o.alphaMin,l=o.alphaDecay,f=o.alpha,d=o.nodeStrength,g=o.edgeStrength,p=o.linkDistance,y=o.clustering,m=o.clusterFociStrength,w=o.clusterEdgeDistance,v=o.clusterEdgeStrength,x=o.clusterNodeStrength,M=o.clusterNodeSize,b=o.collideStrength,E=void 0===b?1:b,N=o.center,S=void 0===N?[0,0]:N,A=o.preventOverlap,k=o.nodeSize,I=o.nodeSpacing,_=o.onTick,R=o.forceSimulation,[2,new Promise((function(e){if(R){y&&((i=Bt()).nodes(u),i.links(h)),R.nodes(u),h&&(a=Ft().id((function(t){return t.id})).links(h),g&&a.strength(g),p&&a.distance(p),R.force("link",a)),A&&T.overlapProcess(R,{nodeSize:k,nodeSpacing:I,collideStrength:E}),R.alpha(f).restart();var n=Kt(u),o=Jt(h);t&&n.forEach((function(t){return r.mergeNodeData(t.id,{x:t.data.x,y:t.data.y})})),e({nodes:n,edges:o})}else try{var i,s=Ct();if(d&&s.strength(d),R=Pt().nodes(u),y&&((i=Bt()).centerX(S[0]).centerY(S[1]).template("force").strength(m),h&&i.links(h),u&&i.nodes(u),i.forceLinkDistance(w).forceLinkStrength(v).forceCharge(x).forceNodeSize(M),R.force("group",i)),R.force("center",function(t,e){var r,n=1;function o(){var o,i,s=r.length,a=0,u=0;for(o=0;o<s;++o)a+=(i=r[o]).x,u+=i.y;for(a=(a/s-t)*n,u=(u/s-e)*n,o=0;o<s;++o)(i=r[o]).x-=a,i.y-=u}return null==t&&(t=0),null==e&&(e=0),o.initialize=function(t){r=t},o.x=function(e){return arguments.length?(t=+e,o):t},o.y=function(t){return arguments.length?(e=+t,o):e},o.strength=function(t){return arguments.length?(n=+t,o):n},o}(S[0],S[1])).force("charge",s).alpha(f).alphaDecay(l).alphaMin(c),A&&T.overlapProcess(R,{nodeSize:k,nodeSpacing:I,collideStrength:E}),h){var a=Ft().id((function(t){return t.id})).links(h);g&&a.strength(g),p&&a.distance(p),R.force("link",a)}R.on("tick",(function(){var e=Kt(u);null==_||_({nodes:e,edges:Jt(h)}),t&&e.forEach((function(t){return r.mergeNodeData(t.id,{x:t.data.x,y:t.data.y})}))})).on("end",(function(){var n=Kt(u);t&&n.forEach((function(t){return r.mergeNodeData(t.id,{x:t.data.x,y:t.data.y})})),e({nodes:n,edges:Jt(h)})}))}catch(t){console.warn(t)}T.forceSimulation=R}))]}))}))},t.prototype.overlapProcess=function(t,e){var r,n,o=e.nodeSize,i=e.nodeSpacing,s=e.collideStrength;if(n=m(i)?function(){return i}:R(i)?i:function(){return 0},o)if(R(o))r=function(t){return o(t)+n(t)};else if(d(o)){var a=(o[0]>o[1]?o[0]:o[1])/2;r=function(t){return a+n(t)}}else if(m(o)){var u=o/2;r=function(t){return u+n(t)}}else r=function(){return 10};else r=function(t){return t.size?d(t.size)?(t.size[0]>t.size[1]?t.size[0]:t.size[1])/2+n(t):T(t.size)?(t.size.width>t.size.height?t.size.width:t.size.height)/2+n(t):t.size/2+n(t):10+n(t)};t.force("collisionForce",Wt(r).strength(s))},t}(),Kt=function(t){return t.map((function(t){var r=t.x,n=t.y,i=o(t,["x","y"]);return e(e({},i),{data:e(e({},i.data),{x:r,y:n})})}))},Jt=function(t){return t.map((function(t){var r=t.source,n=t.target,i=o(t,["source","target"]);return e(e({},i),{source:r.id,target:n.id})}))},Yt="*";const Xt=function(){function t(){this._events={}}return t.prototype.on=function(t,e,r){return this._events[t]||(this._events[t]=[]),this._events[t].push({callback:e,once:!!r}),this},t.prototype.once=function(t,e){return this.on(t,e,!0)},t.prototype.emit=function(t){for(var e=this,r=[],n=1;n<arguments.length;n++)r[n-1]=arguments[n];var o=this._events[t]||[],i=this._events[Yt]||[],s=function(n){for(var o=n.length,i=0;i<o;i++)if(n[i]){var s=n[i],a=s.callback;s.once&&(n.splice(i,1),0===n.length&&delete e._events[t],o--,i--),a.apply(e,r)}};s(o),s(i)},t.prototype.off=function(t,e){if(t)if(e){for(var r=this._events[t]||[],n=r.length,o=0;o<n;o++)r[o].callback===e&&(r.splice(o,1),n--,o--);0===r.length&&delete this._events[t]}else delete this._events[t];else this._events={};return this},t.prototype.getEvents=function(){return this._events},t}();function Zt(t,e,r,n){for(;t.length;){const o=t.shift();if(r(o))return!0;e.add(o.id),n(o.id).forEach((r=>{e.has(r.id)||(e.add(r.id),t.push(r))}))}return!1}function Qt(t,e,r,n){if(r(t))return!0;e.add(t.id);for(const o of n(t.id))if(!e.has(o.id)&&Qt(o,e,r,n))return!0;return!1}class te extends Xt{nodeMap=new Map;edgeMap=new Map;inEdgesMap=new Map;outEdgesMap=new Map;bothEdgesMap=new Map;treeIndices=new Map;changes=[];batchCount=0;onChanged=()=>{};constructor(t){super(),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))}batch=t=>{this.batchCount+=1,t(),this.batchCount-=1,this.batchCount||this.commit()};commit(){const t=this.changes;this.changes=[];const e={graph:this,changes:t};this.emit("changed",e),this.onChanged(e)}reduceChanges(t){let e=[];return t.forEach((t=>{switch(t.type){case"NodeRemoved":{let r=!1;e=e.filter((e=>{if("NodeAdded"===e.type){const n=e.value.id===t.value.id;return n&&(r=!0),!n}return"NodeDataUpdated"===e.type?e.id!==t.value.id:"TreeStructureChanged"!==e.type||e.nodeId!==t.value.id})),r||e.push(t);break}case"EdgeRemoved":{let r=!1;e=e.filter((e=>{if("EdgeAdded"===e.type){const n=e.value.id===t.value.id;return n&&(r=!0),!n}return"EdgeDataUpdated"!==e.type&&"EdgeUpdated"!==e.type||e.id!==t.value.id})),r||e.push(t);break}case"NodeDataUpdated":case"EdgeDataUpdated":case"EdgeUpdated":{const r=e.find((e=>e.type===t.type&&e.id===t.id&&e.propertyName===t.propertyName));r?r.newValue=t.newValue:e.push(t);break}case"TreeStructureDetached":e=e.filter((e=>"TreeStructureAttached"===e.type?e.treeKey!==t.treeKey:"TreeStructureChanged"!==e.type||e.treeKey!==t.treeKey)),e.push(t);break;case"TreeStructureChanged":{const r=e.find((e=>"TreeStructureChanged"===e.type&&e.treeKey===t.treeKey&&e.nodeId===t.nodeId));r?r.newParentId=t.newParentId:e.push(t);break}default:e.push(t)}})),e}checkNodeExistence(t){this.getNode(t)}hasNode(t){return this.nodeMap.has(t)}areNeighbors(t,e){return this.getNeighbors(e).some((e=>e.id===t))}getNode(t){const e=this.nodeMap.get(t);if(!e)throw new Error("Node not found for id: "+t);return e}getRelatedEdges(t,e){if(this.checkNodeExistence(t),"in"===e){const e=this.inEdgesMap.get(t);return Array.from(e)}if("out"===e){const e=this.outEdgesMap.get(t);return Array.from(e)}{const e=this.bothEdgesMap.get(t);return Array.from(e)}}getDegree(t,e){return this.getRelatedEdges(t,e).length}getSuccessors(t){const e=this.getRelatedEdges(t,"out").map((t=>this.getNode(t.target)));return Array.from(new Set(e))}getPredecessors(t){const e=this.getRelatedEdges(t,"in").map((t=>this.getNode(t.source)));return Array.from(new Set(e))}getNeighbors(t){const e=this.getPredecessors(t),r=this.getSuccessors(t);return Array.from(new Set([...e,...r]))}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((e=>{e.childrenMap.set(t.id,new Set)})),this.changes.push({type:"NodeAdded",value:t})}addNodes(t){this.batch((()=>{for(const e of t)this.doAddNode(e)}))}addNode(t){this.addNodes([t])}doRemoveNode(t){const e=this.getNode(t);this.bothEdgesMap.get(t)?.forEach((t=>this.doRemoveEdge(t.id))),this.nodeMap.delete(t),this.treeIndices.forEach((e=>{e.childrenMap.get(t)?.forEach((t=>{e.parentMap.delete(t.id)})),e.parentMap.delete(t),e.childrenMap.delete(t)})),this.changes.push({type:"NodeRemoved",value:e})}removeNodes(t){this.batch((()=>{t.forEach((t=>this.doRemoveNode(t)))}))}removeNode(t){this.removeNodes([t])}updateNodeDataProperty(t,e,r){const n=this.getNode(t);this.batch((()=>{const o=n.data[e],i=r;n.data[e]=i,this.changes.push({type:"NodeDataUpdated",id:t,propertyName:e,oldValue:o,newValue:i})}))}mergeNodeData(t,e){this.batch((()=>{Object.entries(e).forEach((([e,r])=>{this.updateNodeDataProperty(t,e,r)}))}))}updateNodeData(...t){const e=t[0],r=this.getNode(e);if("string"==typeof t[1])return void this.updateNodeDataProperty(e,t[1],t[2]);let n;if("function"==typeof t[1]){const e=t[1];n=e(r.data)}else"object"==typeof t[1]&&(n=t[1]);this.batch((()=>{const t=r.data,o=n;r.data=n,this.changes.push({type:"NodeDataUpdated",id:e,oldValue:t,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 e=this.getEdge(t);return{edge:e,source:this.getNode(e.source),target:this.getNode(e.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 e=this.inEdgesMap.get(t.target),r=this.outEdgesMap.get(t.source),n=this.bothEdgesMap.get(t.source),o=this.bothEdgesMap.get(t.target);e.add(t),r.add(t),n.add(t),o.add(t),this.changes.push({type:"EdgeAdded",value:t})}addEdges(t){this.batch((()=>{for(const e of t)this.doAddEdge(e)}))}addEdge(t){this.addEdges([t])}doRemoveEdge(t){const e=this.getEdge(t),r=this.outEdgesMap.get(e.source),n=this.inEdgesMap.get(e.target),o=this.bothEdgesMap.get(e.source),i=this.bothEdgesMap.get(e.target);r.delete(e),n.delete(e),o.delete(e),i.delete(e),this.edgeMap.delete(t),this.changes.push({type:"EdgeRemoved",value:e})}removeEdges(t){this.batch((()=>{t.forEach((t=>this.doRemoveEdge(t)))}))}removeEdge(t){this.removeEdges([t])}updateEdgeSource(t,e){const r=this.getEdge(t);this.checkNodeExistence(e);const n=r.source,o=e;this.outEdgesMap.get(n).delete(r),this.bothEdgesMap.get(n).delete(r),this.outEdgesMap.get(o).add(r),this.bothEdgesMap.get(o).add(r),r.source=e,this.batch((()=>{this.changes.push({type:"EdgeUpdated",id:t,propertyName:"source",oldValue:n,newValue:o})}))}updateEdgeTarget(t,e){const r=this.getEdge(t);this.checkNodeExistence(e);const n=r.target,o=e;this.inEdgesMap.get(n).delete(r),this.bothEdgesMap.get(n).delete(r),this.inEdgesMap.get(o).add(r),this.bothEdgesMap.get(o).add(r),r.target=e,this.batch((()=>{this.changes.push({type:"EdgeUpdated",id:t,propertyName:"target",oldValue:n,newValue:o})}))}updateEdgeDataProperty(t,e,r){const n=this.getEdge(t);this.batch((()=>{const o=n.data[e],i=r;n.data[e]=i,this.changes.push({type:"EdgeDataUpdated",id:t,propertyName:e,oldValue:o,newValue:i})}))}updateEdgeData(...t){const e=t[0],r=this.getEdge(e);if("string"==typeof t[1])return void this.updateEdgeDataProperty(e,t[1],t[2]);let n;if("function"==typeof t[1]){const e=t[1];n=e(r.data)}else"object"==typeof t[1]&&(n=t[1]);this.batch((()=>{const t=r.data,o=n;r.data=n,this.changes.push({type:"EdgeDataUpdated",id:e,oldValue:t,newValue:o})}))}mergeEdgeData(t,e){this.batch((()=>{Object.entries(e).forEach((([e,r])=>{this.updateEdgeDataProperty(t,e,r)}))}))}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,e){this.batch((()=>{this.attachTreeStructure(e);const r=[],n=Array.isArray(t)?t:[t];for(;n.length;){const t=n.shift();r.push(t),t.children&&n.push(...t.children)}this.addNodes(r),r.forEach((t=>{t.children?.forEach((r=>{this.setParent(r.id,t.id,e)}))}))}))}getRoots(t){return this.checkTreeExistence(t),this.getAllNodes().filter((e=>!this.getParent(e.id,t)))}getChildren(t,e){this.checkNodeExistence(t),this.checkTreeExistence(e);const r=this.treeIndices.get(e).childrenMap.get(t);return Array.from(r||[])}getParent(t,e){return this.checkNodeExistence(t),this.checkTreeExistence(e),this.treeIndices.get(e).parentMap.get(t)||null}getAncestors(t,e){const r=[];let n,o=this.getNode(t);for(;n=this.getParent(o.id,e);)r.push(n),o=n;return r}setParent(t,e,r){this.checkTreeExistence(r);const n=this.treeIndices.get(r),o=this.getNode(t),i=n.parentMap.get(t),s=this.getNode(e);n.parentMap.set(t,s),i&&n.childrenMap.get(i.id)?.delete(o);let a=n.childrenMap.get(s.id);a||(a=new Set,n.childrenMap.set(s.id,a)),a.add(o),this.batch((()=>{this.changes.push({type:"TreeStructureChanged",treeKey:r,nodeId:t,oldParentId:i?.id,newParentId:s.id})}))}dfsTree(t,e,r){return Qt(this.getNode(t),new Set,e,(t=>this.getChildren(t,r)))}bfsTree(t,e,r){return Zt([this.getNode(t)],new Set,e,(t=>this.getChildren(t,r)))}getAllNodes(){return Array.from(this.nodeMap.values())}getAllEdges(){return Array.from(this.edgeMap.values())}bfs(t,e,r="out"){const n={in:this.getPredecessors.bind(this),out:this.getSuccessors.bind(this),both:this.getNeighbors.bind(this)}[r];return Zt([this.getNode(t)],new Set,e,n)}dfs(t,e,r="out"){const n={in:this.getPredecessors.bind(this),out:this.getSuccessors.bind(this),both:this.getNeighbors.bind(this)}[r];return Qt(this.getNode(t),new Set,e,n)}clone(){const t=this.getAllNodes().map((t=>({...t,data:{...t.data}}))),e=this.getAllEdges().map((t=>({...t,data:{...t.data}}))),r=new te({nodes:t,edges:e});return this.treeIndices.forEach((({parentMap:t,childrenMap:e},n)=>{const o=new Map;t.forEach(((t,e)=>{o.set(e,r.getNode(t.id))}));const i=new Map;e.forEach(((t,e)=>{i.set(e,new Set(Array.from(t).map((t=>r.getNode(t.id)))))})),r.treeIndices.set(n,{parentMap:o,childrenMap:i})})),r}toJSON(){return JSON.stringify({nodes:this.getAllNodes(),edges:this.getAllEdges()})}}function ee(t){var e=0,r=0,n=0;if(t.length){for(var o=0;o<4;o++)(i=t[o])&&i.weight&&(e+=i.weight,r+=i.x*i.weight,n+=i.y*i.weight);t.x=r/e,t.y=n/e,t.weight=e}else{var i=t;t.x=i.data.x,t.y=i.data.y,t.weight=i.data.weight}}var re=function(t,e,r,n,o,i){var s=i.x-t.x||.1,a=i.y-t.y||.1,u=n-e,h=s*s+a*a,c=Math.sqrt(h)*h;if(u*u*.81<h){var l=t.weight/c;return i.vx+=s*l,i.vy+=a*l,!0}if(t.length)return!1;t.data!==i&&(l=t.data.weight/c,i.vx+=s*l,i.vy+=a*l)},ne={maxIteration:500,gravity:10,factor:1,edgeStrength:200,nodeStrength:1e3,coulombDisScale:.005,damping:.9,maxSpeed:500,minMovement:.4,interval:.02,linkDistance:200,clusterNodeStrength:20,preventOverlap:!0,distanceThresholdMode:"mean"},oe=function(){function t(t){void 0===t&&(t={}),this.options=t,this.id="force",this.timeInterval=0,this.judgingDistance=0,this.running=!1,this.options=e(e({},ne),t)}return t.prototype.execute=function(t,e){return i(this,void 0,void 0,(function(){return s(this,(function(r){return[2,this.genericForceLayout(!1,t,e)]}))}))},t.prototype.assign=function(t,e){return i(this,void 0,void 0,(function(){return s(this,(function(r){return this.genericForceLayout(!0,t,e),[2]}))}))},t.prototype.stop=function(){this.timeInterval&&"undefined"!=typeof window&&window.clearInterval(this.timeInterval),this.running=!1},t.prototype.tick=function(t){var e=this;if(void 0===t&&(t=this.options.maxIteration||1),this.lastResult)return this.lastResult;for(var r=0;(this.judgingDistance>this.lastOptions.minMovement||r<1)&&r<t;r++)this.runOneStep(this.lastCalcGraph,this.lastGraph,r,this.lastVelMap,this.lastOptions),this.updatePosition(this.lastGraph,this.lastCalcGraph,this.lastVelMap,this.lastOptions);var n={nodes:this.lastLayoutNodes,edges:this.lastLayoutEdges};return this.lastAssign&&n.nodes.forEach((function(t){return e.lastGraph.mergeNodeData(t.id,{x:t.data.x,y:t.data.y})})),n},t.prototype.genericForceLayout=function(t,r,n){return i(this,void 0,void 0,(function(){var o,i,a,u,h,c,l,f,d,g,p,y,w,v,x,M,b,E,N,S=this;return s(this,(function(s){return o=e(e({},this.options),n),i=r.getAllNodes(),a=r.getAllEdges(),u=this.formatOptions(o,r),h=u.width,c=u.height,l=u.nodeSize,f=u.getMass,d=u.nodeStrength,g=u.edgeStrength,p=u.linkDistance,y=i.map((function(t){return e(e({},t),{data:e(e({},t.data),{x:m(t.data.x)?t.data.x:Math.random()*h,y:m(t.data.y)?t.data.y:Math.random()*c,size:l(t)||30,mass:f(t),nodeStrength:d(t)})})})),w=a.map((function(t){return e(e({},t),{data:e(e({},t.data),{edgeStrength:g(t),linkDistance:p(t,r.getNode(t.source),r.getNode(t.target))})})})),(null==i?void 0:i.length)?(v={},i.forEach((function(t,e){v[t.id]={x:0,y:0}})),x=new te({nodes:y,edges:w}),this.formatCentripetal(u,x),M=u.maxIteration,b=u.minMovement,E=u.onTick,this.lastLayoutNodes=y,this.lastLayoutEdges=w,this.lastAssign=t,this.lastGraph=r,this.lastCalcGraph=x,this.lastOptions=u,this.lastVelMap=v,"undefined"==typeof window?[2]:(N=0,[2,new Promise((function(e){S.timeInterval=window.setInterval((function(){i&&S.running||e({nodes:he(r,y),edges:a}),S.runOneStep(x,r,N,v,u),S.updatePosition(r,x,v,u),t&&y.forEach((function(t){return r.mergeNodeData(t.id,{x:t.data.x,y:t.data.y})})),null==E||E({nodes:he(r,y),edges:a}),(++N>=M||S.judgingDistance<b)&&(window.clearInterval(S.timeInterval),e({nodes:he(r,y),edges:a}))}),0),S.running=!0}))])):(this.lastResult={nodes:[],edges:a},[2,{nodes:[],edges:a}])}))}))},t.prototype.formatOptions=function(t,e){var r=t,n=t.width,o=t.height,i=t.getMass;if(r.width=n||"undefined"==typeof window?n:window.innerWidth,r.height=o||"undefined"==typeof window?o:window.innerHeight,t.center||(r.center=[r.width/2,r.height/2]),i||(r.getMass=function(t){var r=1;m(null==t?void 0:t.data.mass)&&(r=null==t?void 0:t.data.mass);var n=e.getDegree(t.id,"both");return!n||n<5?r:5*n*r}),t.preventOverlap){var s=z(0,t.nodeSpacing);t.nodeSize?d(t.nodeSize)?r.nodeSize=function(e){var r=t.nodeSize;return Math.max(r[0],r[1])+s(e)}:r.nodeSize=function(e){return t.nodeSize+s(e)}:r.nodeSize=function(t){var e=((null==t?void 0:t.data)||{}).size;return e?d(e)?Math.max(e[0],e[1])+s(t):T(e)?Math.max(e.width,e.height)+s(t):e+s(t):10+s(t)}}return r.linkDistance=t.linkDistance?z(1,t.linkDistance):function(t){return 1+r.nodeSize(e.getNode(t.source))+r.nodeSize(e.getNode(t.target))},r.nodeStrength=z(1,t.nodeStrength),r.edgeStrength=z(1,t.edgeStrength),t},t.prototype.formatCentripetal=function(t,e){var r,n=t.centripetalOptions,o=t.center,i=t.clusterNodeStrength,s=t.leafCluster,a=t.clustering,u=t.nodeClusterBy,h=e.getAllNodes(),c=n||{leaf:2,single:2,others:1,center:function(t){return{x:o[0],y:o[1]}}};"function"!=typeof i&&(t.clusterNodeStrength=function(t){return i});var l=[];if(s&&u&&(r=ie(e,u),l=Array.from(new Set(null==h?void 0:h.map((function(t){return t.data[u]}))))||[],t.centripetalOptions=Object.assign(c,{single:100,leaf:function(e){var n=r[e.id]||{},o=n.siblingLeaves,i=n.sameTypeLeaves;return(null==i?void 0:i.length)===(null==o?void 0:o.length)||1===(null==l?void 0:l.length)?1:t.clusterNodeStrength(e)},others:1,center:function(t){var n,o=e.getDegree(t.id,"both");if(!o)return{x:100,y:100};if(1===o){var i=(r[t.id]||{}).sameTypeLeaves,s=void 0===i?[]:i;1===s.length?n=void 0:s.length>1&&(n=ue(s))}else n=void 0;return{x:null==n?void 0:n.x,y:null==n?void 0:n.y}}})),a&&u){r||(r=ie(e,u)),l||(l=Array.from(new Set(h.map((function(t){return t.data[u]}))))),l=l.filter((function(t){return void 0!==t}));var f={};l.forEach((function(t){var r=h.filter((function(e){return e.data[u]===t})).map((function(t){return e.getNode(t.id)}));f[t]=ue(r)})),t.centripetalOptions=Object.assign(c,{single:function(e){return t.clusterNodeStrength(e)},leaf:function(e){return t.clusterNodeStrength(e)},others:function(e){return t.clusterNodeStrength(e)},center:function(t){var e=f[t.data[u]];return{x:null==e?void 0:e.x,y:null==e?void 0:e.y}}})}var d=t.centripetalOptions||{},g=d.leaf,p=d.single,y=d.others;g&&"function"!=typeof g&&(t.centripetalOptions.leaf=function(){return g}),p&&"function"!=typeof p&&(t.centripetalOptions.single=function(){return p}),y&&"function"!=typeof y&&(t.centripetalOptions.others=function(){return y})},t.prototype.runOneStep=function(t,e,r,n,o){var i={},s=t.getAllNodes(),a=t.getAllEdges();if(null==s?void 0:s.length){var u=o.monitor;this.calRepulsive(t,i,o),a&&this.calAttractive(t,i),this.calGravity(t,e,i,o),this.updateVelocity(t,i,n,o),u&&u({energy:this.calTotalEnergy(i,s),nodes:e.getAllNodes(),edges:e.getAllEdges(),iterations:r})}},t.prototype.calTotalEnergy=function(t,e){if(!(null==e?void 0:e.length))return 0;var r=0;return e.forEach((function(e,n){var o=t[e.id].x,i=t[e.id].y,s=o*o+i*i,a=e.data.mass;r+=(void 0===a?1:a)*s*.5})),r},t.prototype.calRepulsive=function(t,e,r){var n=r.factor,o=r.coulombDisScale;!function(t,e,r,n){var o=e/r,i=t.getAllNodes(),s=i.map((function(t,e){var r=t.data,n=r.nodeStrength;return{x:r.x,y:r.y,size:r.size,index:e,vx:0,vy:0,weight:o*n}})),a=Z(s,(function(t){return t.x}),(function(t){return t.y})).visitAfter(ee);s.forEach((function(t){!function(t,e){e.visit((function(e,r,n,o,i){return re(e,r,n,o,i,t)}))}(t,a)})),s.map((function(t,e){var r=i[e],o=r.id,s=r.data.mass,a=void 0===s?1:s;n[o]={x:t.vx/a,y:t.vy/a}}))}(t,n,o*o,e)},t.prototype.calAttractive=function(t,e){t.getAllEdges().forEach((function(r,n){var o=r.source,i=r.target,s=t.getNode(o),a=t.getNode(i);if(s&&a){var u=a.data.x-s.data.x,h=a.data.y-s.data.y;u||h||(u=.01*Math.random(),h=.01*Math.random());var c=Math.sqrt(u*u+h*h),l=u/c,f=h/c,d=r.data||{},g=d.linkDistance,p=void 0===g?200:g,y=d.edgeStrength,m=(p-c)*(void 0===y?200:y),w=1/(s.data.mass||1),v=1/(a.data.mass||1),x=l*m,M=f*m;e[o].x-=x*w,e[o].y-=M*w,e[i].x+=x*v,e[i].y+=M*v}}))},t.prototype.calGravity=function(t,e,r,n){var o=n.getCenter,i=t.getAllNodes(),s=e.getAllNodes(),u=e.getAllEdges(),h=n.width,c=n.height,l=n.center,f=n.gravity,d=n.centripetalOptions;i&&i.forEach((function(n){var i=n.id,g=n.data,p=g.mass,y=g.x,w=g.y,v=e.getNode(i),x=0,M=0,b=f,E=t.getDegree(i,"in"),N=t.getDegree(i,"out"),S=t.getDegree(i,"both"),A=null==o?void 0:o(v,S);if(A){var k=a(A,3);x=y-k[0],M=w-k[1],b=k[2]}else x=y-l[0],M=w-l[1];if(b&&(r[i].x-=b*x/p,r[i].y-=b*M/p),d){var I=d.leaf,_=d.single,D=d.others,R=d.center,T=(null==R?void 0:R(v,s,u,h,c))||{x:0,y:0,centerStrength:0},z=T.x,O=T.y,P=T.centerStrength;if(!m(z)||!m(O))return;var C=(y-z)/p,q=(w-O)/p;if(P&&(r[i].x-=P*C,r[i].y-=P*q),0===S){var L=_(v);if(!L)return;return r[i].x-=L*C,void(r[i].y-=L*q)}if(0===E||0===N){var F=I(v,s,u);if(!F)return;return r[i].x-=F*C,void(r[i].y-=F*q)}var j=D(v);if(!j)return;r[i].x-=j*C,r[i].y-=j*q}}))},t.prototype.updateVelocity=function(t,e,r,n){var o=n.damping,i=n.maxSpeed,s=n.interval,a=t.getAllNodes();(null==a?void 0:a.length)&&a.forEach((function(t){var n=t.id,a=(r[n].x+e[n].x*s)*o||.01,u=(r[n].y+e[n].y*s)*o||.01,h=Math.sqrt(a*a+u*u);if(h>i){var c=i/h;a*=c,u*=c}r[n]={x:a,y:u}}))},t.prototype.updatePosition=function(t,e,r,n){var o=this,i=n.distanceThresholdMode,s=n.interval,a=e.getAllNodes();if(null==a?void 0:a.length){var u=0;"max"===i?this.judgingDistance=-1/0:"min"===i&&(this.judgingDistance=1/0),a.forEach((function(n){var a=n.id,h=t.getNode(a);if(m(h.data.fx)&&m(h.data.fy))e.mergeNodeData(a,{x:h.data.fx,y:h.data.fy});else{var c=r[a].x*s,l=r[a].y*s;e.mergeNodeData(a,{x:n.data.x+c,y:n.data.y+l});var f=Math.sqrt(c*c+l*l);switch(i){case"max":o.judgingDistance<f&&(o.judgingDistance=f);break;case"min":o.judgingDistance>f&&(o.judgingDistance=f);break;default:u+=f}}})),i&&"mean"!==i||(this.judgingDistance=u/a.length)}else this.judgingDistance=0},t}(),ie=function(t,e){var r=t.getAllNodes();if(!(null==r?void 0:r.length))return{};var n={};return r.forEach((function(r,o){1===t.getDegree(r.id,"both")&&(n[r.id]=se(t,"leaf",r,e))})),n},se=function(t,e,r,n){var o=t.getDegree(r.id,"in"),i=t.getDegree(r.id,"out"),s=r,a=[];return 0===o?(s=t.getSuccessors(r.id)[0],a=t.getNeighbors(s.id)):0===i&&(s=t.getPredecessors(r.id)[0],a=t.getNeighbors(s.id)),a=a.filter((function(e){return 0===t.getDegree(e.id,"in")||0===t.getDegree(e.id,"out")})),{coreNode:s,siblingLeaves:a,sameTypeLeaves:ae(t,e,n,r,a)}},ae=function(t,e,r,n,o){var i=n.data[r]||"",s=(null==o?void 0:o.filter((function(t){return t.data[r]===i})))||[];return"leaf"===e&&(s=s.filter((function(e){return 0===t.getDegree(e.id,"in")||0===t.getDegree(e.id,"out")}))),s},ue=function(t){var e={x:0,y:0};t.forEach((function(t){var r=t.data,n=r.x,o=r.y;e.x+=n||0,e.y+=o||0}));var r=t.length||1;return{x:e.x/r,y:e.y/r}},he=function(t,r){return r.map((function(r){var n=r.id,o=r.data,i=t.getNode(n);return e(e({},i),{data:e(e({},i.data),{x:o.x,y:o.y})})}))},ce=function(){function t(t){this.id=t.id||0,this.rx=t.rx,this.ry=t.ry,this.fx=0,this.fy=0,this.mass=t.mass,this.degree=t.degree,this.g=t.g||0}return t.prototype.distanceTo=function(t){var e=this.rx-t.rx,r=this.ry-t.ry;return Math.hypot(e,r)},t.prototype.setPos=function(t,e){this.rx=t,this.ry=e},t.prototype.resetForce=function(){this.fx=0,this.fy=0},t.prototype.addForce=function(t){var e=t.rx-this.rx,r=t.ry-this.ry,n=Math.hypot(e,r);n=n<1e-4?1e-4:n;var o=this.g*(this.degree+1)*(t.degree+1)/n;this.fx+=o*e/n,this.fy+=o*r/n},t.prototype.in=function(t){return t.contains(this.rx,this.ry)},t.prototype.add=function(e){var r=this.mass+e.mass;return new t({rx:(this.rx*this.mass+e.rx*e.mass)/r,ry:(this.ry*this.mass+e.ry*e.mass)/r,mass:r,degree:this.degree+e.degree})},t}();const le=ce;const fe=function(){function t(t){this.xmid=t.xmid,this.ymid=t.ymid,this.length=t.length,this.massCenter=t.massCenter||[0,0],this.mass=t.mass||1}return t.prototype.getLength=function(){return this.length},t.prototype.contains=function(t,e){var r=this.length/2;return t<=this.xmid+r&&t>=this.xmid-r&&e<=this.ymid+r&&e>=this.ymid-r},t.prototype.NW=function(){return new t({xmid:this.xmid-this.length/4,ymid:this.ymid+this.length/4,length:this.length/2})},t.prototype.NE=function(){return new t({xmid:this.xmid+this.length/4,ymid:this.ymid+this.length/4,length:this.length/2})},t.prototype.SW=function(){return new t({xmid:this.xmid-this.length/4,ymid:this.ymid-this.length/4,length:this.length/2})},t.prototype.SE=function(){return new t({xmid:this.xmid+this.length/4,ymid:this.ymid-this.length/4,length:this.length/2})},t}(),de=function(){function t(t){this.body=null,this.quad=null,this.NW=null,this.NE=null,this.SW=null,this.SE=null,this.theta=.5,null!=t&&(this.quad=t)}return t.prototype.insert=function(e){null!=this.body?this._isExternal()?(this.quad&&(this.NW=new t(this.quad.NW()),this.NE=new t(this.quad.NE()),this.SW=new t(this.quad.SW()),this.SE=new t(this.quad.SE())),this._putBody(this.body),this._putBody(e),this.body=this.body.add(e)):(this.body=this.body.add(e),this._putBody(e)):this.body=e},t.prototype._putBody=function(t){this.quad&&(t.in(this.quad.NW())&&this.NW?this.NW.insert(t):t.in(this.quad.NE())&&this.NE?this.NE.insert(t):t.in(this.quad.SW())&&this.SW?this.SW.insert(t):t.in(this.quad.SE())&&this.SE&&this.SE.insert(t))},t.prototype._isExternal=function(){return null==this.NW&&null==this.NE&&null==this.SW&&null==this.SE},t.prototype.updateForce=function(t){null!=this.body&&t!==this.body&&(this._isExternal()||(this.quad?this.quad.getLength():0)/this.body.distanceTo(t)<this.theta?t.addForce(this.body):(this.NW&&this.NW.updateForce(t),this.NE&&this.NE.updateForce(t),this.SW&&this.SW.updateForce(t),this.SE&&this.SE.updateForce(t)))},t}();var ge={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},pe=function(){function t(t){void 0===t&&(t={}),this.options=t,this.id="forceAtlas2",this.options=e(e({},ge),t)}return t.prototype.execute=function(t,e){return i(this,void 0,void 0,(function(){return s(this,(function(r){return[2,this.genericForceAtlas2Layout(!1,t,e)]}))}))},t.prototype.assign=function(t,e){return i(this,void 0,void 0,(function(){return s(this,(function(r){return this.genericForceAtlas2Layout(!0,t,e),[2]}))}))},t.prototype.genericForceAtlas2Layout=function(t,r,n){return i(this,void 0,void 0,(function(){var o,i,a,u,h,c,l,f,d,g,p,y,m,w,v,x,M,b,E,N,S,A;return s(this,(function(s){if(o=r.getAllEdges(),i=r.getAllNodes(),a=this.formatOptions(n,i.length),u=a.width,h=a.height,c=a.prune,l=a.maxIteration,f=a.nodeSize,d=a.center,!(null==i?void 0:i.length)||1===i.length)return[2,P(r,t,d)];if(g=i.map((function(t){return D(t,[u,h])})),p=o.filter((function(t){return t.source!==t.target})),y=new te({nodes:g,edges:p}),m=this.getSizes(y,r,f),this.run(y,r,l,m,t,a),c){for(w=0;w<p.length;w+=1)v=p[w],x=v.source,M=v.target,b=y.getDegree(x),E=y.getDegree(x),b<=1?(N=y.getNode(M),y.mergeNodeData(x,{x:N.data.x,y:N.data.y})):E<=1&&(S=y.getNode(x),y.mergeNodeData(M,{x:S.data.x,y:S.data.y}));A=e(e({},a),{prune:!1,barnesHut:!1}),this.run(y,r,100,m,t,A)}return[2,{nodes:g,edges:o}]}))}))},t.prototype.getSizes=function(t,e,r){for(var n=t.getAllNodes(),o={},i=0;i<n.length;i+=1){var s=n[i],h=s.id,c=s.data;if(o[h]=10,m(c.size))o[h]=c.size;else if(d(c.size))isNaN(c.size[0])||(o[h]=Math.max(c.size[0])),isNaN(c.size[1])||(o[h]=Math.max(c.size[1]));else if(T(c.size))o[h]=Math.max(c.size.width,c.size.height);else if(R(r)){var l=r(e.getNode(h));d(l)?o[h]=Math.max.apply(Math,u([],a(l),!1)):o[h]=l}else d(r)?o[h]=Math.max.apply(Math,u([],a(r),!1)):m(r)&&(o[h]=r)}return o},t.prototype.formatOptions=function(t,r){void 0===t&&(t={});var n=e(e({},this.options),t),o=n.center,i=n.width,s=n.height,a=n.barnesHut,u=n.prune,h=n.maxIteration,c=n.kr,l=n.kg;return n.width=i||"undefined"==typeof window?i:window.innerWidth,n.height=s||"undefined"==typeof window?s:window.innerHeight,n.center=o||[n.width/2,n.height/2],void 0===a&&r>250&&(n.barnesHut=!0),void 0===u&&r>100&&(n.prune=!0),0!==h||u?0===h&&u&&(n.maxIteration=100,r<=200&&r>100?n.maxIteration=500:r>200&&(n.maxIteration=950)):(n.maxIteration=250,r<=200&&r>100?n.maxIteration=1e3:r>200&&(n.maxIteration=1200)),c||(n.kr=50,r>100&&r<=500?n.kr=20:r>500&&(n.kr=1)),l||(n.kg=20,r>100&&r<=500?n.kg=10:r>500&&(n.kg=1)),n},t.prototype.run=function(t,e,r,n,o,i){for(var s=i.kr,a=i.barnesHut,u=i.onTick,h=t.getAllNodes(),c=0,l=r,f={},d={},g={},p=0;p<h.length;p+=1){var y=h[p],m=y.data,w=y.id;if(f[w]=[0,0],a){var v={id:p,rx:m.x,ry:m.y,mass:1,g:s,degree:t.getDegree(w)};g[w]=new le(v)}}for(;l>0;)c=this.oneStep(t,{iter:l,preventOverlapIters:50,krPrime:100,sg:c,forces:f,preForces:d,bodies:g,sizes:n},i),l--,null==u||u({nodes:h,edges:e.getAllEdges()});return t},t.prototype.oneStep=function(t,e,r){for(var n=e.iter,o=e.preventOverlapIters,i=e.krPrime,s=e.sg,h=e.preForces,c=e.bodies,l=e.sizes,f=e.forces,d=r.preventOverlap,g=r.barnesHut,p=t.getAllNodes(),y=0;y<p.length;y+=1){var m=p[y].id;h[m]=u([],a(f[m]),!1),f[m]=[0,0]}return f=this.getAttrForces(t,n,o,l,f,r),f=g&&(d&&n>o||!d)?this.getOptRepGraForces(t,f,c,r):this.getRepGraForces(t,n,o,f,i,l,r),this.updatePos(t,f,h,s,r)},t.prototype.getAttrForces=function(t,e,r,n,o,i){for(var s=i.preventOverlap,a=i.dissuadeHubs,u=i.mode,h=i.prune,c=t.getAllEdges(),l=0;l<c.length;l+=1){var f=c[l],d=f.source,g=f.target,p=t.getNode(d),y=t.getNode(g),m=t.getDegree(d),w=t.getDegree(g);if(!h||!(m<=1||w<=1)){var v=[y.data.x-p.data.x,y.data.y-p.data.y],x=Math.hypot(v[0],v[1]);x=x<1e-4?1e-4:x,v[0]=v[0]/x,v[1]=v[1]/x,s&&e<r&&(x=x-n[d]-n[g]);var M=x,b=M;"linlog"===u&&(b=M=Math.log(1+x)),a&&(M=x/m,b=x/w),s&&e<r&&x<=0?(M=0,b=0):s&&e<r&&x>0&&(M=x,b=x),o[d][0]+=M*v[0],o[g][0]-=b*v[0],o[d][1]+=M*v[1],o[g][1]-=b*v[1]}}return o},t.prototype.getOptRepGraForces=function(t,e,r,n){for(var o=n.kg,i=n.center,s=n.prune,a=t.getAllNodes(),u=a.length,h=9e10,c=-9e10,l=9e10,f=-9e10,d=0;d<u;d+=1){var g=a[d],p=g.id,y=g.data;s&&t.getDegree(p)<=1||(r[p].setPos(y.x,y.y),y.x>=c&&(c=y.x),y.x<=h&&(h=y.x),y.y>=f&&(f=y.y),y.y<=l&&(l=y.y))}var m=Math.max(c-h,f-l),w=new fe({xmid:(c+h)/2,ymid:(f+l)/2,length:m,massCenter:i,mass:u}),v=new de(w);for(d=0;d<u;d+=1)p=a[d].id,s&&t.getDegree(p)<=1||r[p].in(w)&&v.insert(r[p]);for(d=0;d<u;d+=1){var x=a[d],M=(p=x.id,y=x.data,t.getDegree(p));if(!(s&&M<=1)){r[p].resetForce(),v.updateForce(r[p]),e[p][0]-=r[p].fx,e[p][1]-=r[p].fy;var b=[y.x-i[0],y.y-i[1]],E=Math.hypot(b[0],b[1]);E=E<1e-4?1e-4:E,b[0]=b[0]/E,b[1]=b[1]/E;var N=o*(M+1);e[p][0]-=N*b[0],e[p][1]-=N*b[1]}}return e},t.prototype.getRepGraForces=function(t,e,r,n,o,i,s){for(var a=s.preventOverlap,u=s.kr,h=s.kg,c=s.center,l=s.prune,f=t.getAllNodes(),d=f.length,g=0;g<d;g+=1){for(var p=f[g],y=t.getDegree(p.id),m=g+1;m<d;m+=1){var w=f[m],v=t.getDegree(w.id);if(!l||!(y<=1||v<=1)){var x=[w.data.x-p.data.x,w.data.y-p.data.y],M=Math.hypot(x[0],x[1]);M=M<1e-4?1e-4:M,x[0]=x[0]/M,x[1]=x[1]/M,a&&e<r&&(M=M-i[p.id]-i[w.id]);var b=u*(y+1)*(v+1)/M;a&&e<r&&M<0?b=o*(y+1)*(v+1):a&&e<r&&0===M?b=0:a&&e<r&&M>0&&(b=u*(y+1)*(v+1)/M),n[p.id][0]-=b*x[0],n[w.id][0]+=b*x[0],n[p.id][1]-=b*x[1],n[w.id][1]+=b*x[1]}}var E=[p.data.x-c[0],p.data.y-c[1]],N=Math.hypot(E[0],E[1]);E[0]=E[0]/N,E[1]=E[1]/N;var S=h*(y+1);n[p.id][0]-=S*E[0],n[p.id][1]-=S*E[1]}return n},t.prototype.updatePos=function(t,e,r,n,o){for(var i=o.ks,s=o.tao,a=o.prune,u=o.ksmax,h=t.getAllNodes(),c=h.length,l=[],f=[],d=0,g=0,p=n,y=0;y<c;y+=1){var w=h[y].id,v=t.getDegree(w);if(!(a&&v<=1)){var x=[e[w][0]-r[w][0],e[w][1]-r[w][1]],M=Math.hypot(x[0],x[1]),b=[e[w][0]+r[w][0],e[w][1]+r[w][1]],E=Math.hypot(b[0],b[1]);l[y]=M,f[y]=E/2,d+=(v+1)*l[y],g+=(v+1)*f[y]}}var N=p;for(p=s*g/d,0!==N&&(p=p>1.5*N?1.5*N:p),y=0;y<c;y+=1){var S=h[y],A=(w=S.id,S.data);if(v=t.getDegree(w),!(a&&v<=1||m(A.fx)&&m(A.fy))){var k=i*p/(1+p*Math.sqrt(l[y])),I=Math.hypot(e[w][0],e[w][1]),_=u/(I=I<1e-4?1e-4:I),D=(k=k>_?_:k)*e[w][0],R=k*e[w][1];t.mergeNodeData(w,{x:A.x+D,y:A.y+R})}}return p},t}(),ye={maxIteration:1e3,gravity:10,speed:5,clustering:!1,clusterGravity:10,width:300,height:300,nodeClusterBy:"cluster"},me=function(){function t(t){void 0===t&&(t={}),this.options=t,this.id="fruchterman",this.timeInterval=0,this.running=!1,this.options=e(e({},ye),t)}return t.prototype.execute=function(t,e){return i(this,void 0,void 0,(function(){return s(this,(function(r){return[2,this.genericFruchtermanLayout(!1,t,e)]}))}))},t.prototype.assign=function(t,e){return i(this,void 0,void 0,(function(){return s(this,(function(r){return this.genericFruchtermanLayout(!0,t,e),[2]}))}))},t.prototype.stop=function(){this.timeInterval&&"undefined"!=typeof window&&window.clearInterval(this.timeInterval),this.running=!1},t.prototype.tick=function(t){var e=this;if(void 0===t&&(t=this.options.maxIteration||1),this.lastResult)return this.lastResult;for(var r=0;r<t;r++)this.runOneStep(this.lastGraph,this.lastClusterMap,this.lastOptions);var n={nodes:this.lastLayoutNodes,edges:this.lastLayoutEdges};return this.lastAssign&&n.nodes.forEach((function(t){return e.lastGraph.mergeNodeData(t.id,{x:t.data.x,y:t.data.y})})),n},t.prototype.genericFruchtermanLayout=function(t,r,n){return i(this,void 0,void 0,(function(){var o,i,a,u,h,c,l,f,d,g,p,y,m,w,v,x=this;return s(this,(function(s){return this.running?[2]:(o=this.formatOptions(n),i=o.width,a=o.height,u=o.center,h=o.clustering,c=o.nodeClusterBy,l=o.maxIteration,f=o.onTick,d=r.getAllNodes(),g=r.getAllEdges(),(null==d?void 0:d.length)?1===d.length?(t&&r.mergeNodeData(d[0].id,{x:u[0],y:u[1]}),p={nodes:[e(e({},d[0]),{data:e(e({},d[0].data),{x:u[0],y:u[1]})})],edges:g},this.lastResult=p,[2,p]):(y=d.map((function(t){return D(t,[i,a])})),m=new te({nodes:y,edges:g}),w={},h&&y.forEach((function(t){var e=t.data[c];w[e]||(w[e]={name:e,cx:0,cy:0,count:0})})),this.lastLayoutNodes=y,this.lastLayoutEdges=g,this.lastAssign=t,this.lastGraph=m,this.lastOptions=o,this.lastClusterMap=w,"undefined"==typeof window?[2]:(v=0,[2,new Promise((function(e){x.timeInterval=window.setInterval((function(){x.running?(x.runOneStep(m,w,o),t&&y.forEach((function(t){var e=t.id,n=t.data;return r.mergeNodeData(e,{x:n.x,y:n.y})})),null==f||f({nodes:y,edges:g}),++v>=l&&(window.clearInterval(x.timeInterval),e({nodes:y,edges:g}))):e({nodes:y,edges:g})}),0),x.running=!0}))])):(p={nodes:[],edges:g},this.lastResult=p,[2,p]))}))}))},t.prototype.formatOptions=function(t){void 0===t&&(t={});var r=e(e({},this.options),t),n=r.clustering,o=r.nodeClusterBy,i=r.center,s=r.width,a=r.height;return r.width=s||"undefined"==typeof window?s:window.innerWidth,r.height=a||"undefined"==typeof window?a:window.innerHeight,r.center=i||[r.width/2,r.height/2],r.clustering=n&&!!o,r},t.prototype.runOneStep=function(t,e,r){var n=r.height,o=r.width,i=r.gravity,s=r.center,a=r.speed,u=r.clustering,h=r.nodeClusterBy,c=r.clusterGravity,l=n*o,f=Math.sqrt(l)/10,d=t.getAllNodes(),g=l/(d.length+1),p=Math.sqrt(g),y={};if(this.applyCalculate(t,y,p,g),u){for(var w in e)e[w].cx=0,e[w].cy=0,e[w].count=0;for(var w in d.forEach((function(t){var r=t.data,n=e[r[h]];m(r.x)&&(n.cx+=r.x),m(r.y)&&(n.cy+=r.y),n.count++})),e)e[w].cx/=e[w].count,e[w].cy/=e[w].count;var v=c||i;d.forEach((function(t,r){var n=t.id,o=t.data;if(m(o.x)&&m(o.y)){var i=e[o[h]],s=Math.sqrt((o.x-i.cx)*(o.x-i.cx)+(o.y-i.cy)*(o.y-i.cy)),a=p*v;y[n].x-=a*(o.x-i.cx)/s,y[n].y-=a*(o.y-i.cy)/s}}))}d.forEach((function(t,e){var r=t.id,n=t.data;if(m(n.x)&&m(n.y)){var o=.01*p*i;y[r].x-=o*(n.x-s[0]),y[r].y-=o*(n.y-s[1])}})),d.forEach((function(e,r){var n=e.id,o=e.data;if(m(o.fx)&&m(o.fy))return o.x=o.fx,void(o.y=o.fy);if(m(o.x)&&m(o.y)){var i=Math.sqrt(y[n].x*y[n].x+y[n].y*y[n].y);if(i>0){var s=Math.min(f*(a/800),i);t.mergeNodeData(n,{x:o.x+y[n].x/i*s,y:o.y+y[n].y/i*s})}}}))},t.prototype.applyCalculate=function(t,e,r,n){this.calRepulsive(t,e,n),this.calAttractive(t,e,r)},t.prototype.calRepulsive=function(t,e,r){var n=t.getAllNodes();n.forEach((function(t,o){var i=t.data,s=t.id;e[s]={x:0,y:0},n.forEach((function(t,n){var a=t.data,u=t.id;if(!(o<=n)&&m(i.x)&&m(a.x)&&m(i.y)&&m(a.y)){var h=i.x-a.x,c=i.y-a.y,l=h*h+c*c;0===l&&(l=1,h=.01,c=.01);var f=r/l,d=h*f,g=c*f;e[s].x+=d,e[s].y+=g,e[u].x-=d,e[u].y-=g}}))}))},t.prototype.calAttractive=function(t,e,r){t.getAllEdges().forEach((function(n){var o=n.source,i=n.target;if(o&&i&&o!==i){var s=t.getNode(o).data,a=t.getNode(i).data;if(m(a.x)&&m(s.x)&&m(a.y)&&m(s.y)){var u=a.x-s.x,h=a.y-s.y,c=Math.sqrt(u*u+h*h)/r,l=u*c,f=h*c;e[o].x+=l,e[o].y+=f,e[i].x-=l,e[i].y-=f}}}))},t}(),we={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},ve=function(){function t(t){void 0===t&&(t={}),this.options=t,this.id="grid",this.options=e(e({},we),t)}return t.prototype.execute=function(t,e){return i(this,void 0,void 0,(function(){return s(this,(function(r){return[2,this.genericGridLayout(!1,t,e)]}))}))},t.prototype.assign=function(t,e){return i(this,void 0,void 0,(function(){return s(this,(function(r){return this.genericGridLayout(!0,t,e),[2]}))}))},t.prototype.genericGridLayout=function(t,r,n){return i(this,void 0,void 0,(function(){var o,i,a,u,h,c,l,f,g,p,y,w,v,x,M,b,E,N,S,A,k,I,_,R,T,C,q,L,F,j,V,W,$,G,U,H,K;return s(this,(function(s){if(o=e(e({},this.options),n),i=o.begin,a=void 0===i?[0,0]:i,u=o.condense,h=o.preventOverlapPadding,c=o.preventOverlap,l=o.rows,f=o.cols,g=o.nodeSpacing,p=o.nodeSize,y=o.width,w=o.height,v=o.position,x=o.sortBy,M=r.getAllNodes(),b=r.getAllEdges(),!(E=null==M?void 0:M.length)||1===E)return[2,P(r,t,a)];if(N=M.map((function(t){return D(t)})),"id"===x||B(x)&&void 0!==N[0].data[x]||(x="degree"),"degree"===x?N.sort((function(t,e){return r.getDegree(e.id,"both")-r.getDegree(t.id,"both")})):"id"===x?N.sort((function(t,e){return m(e.id)&&m(t.id)?e.id-t.id:"".concat(t.id).localeCompare("".concat(e.id))})):N.sort((function(t,e){return e.data[x]-t.data[x]})),S=y||"undefined"==typeof window?y:window.innerWidth,A=w||"undefined"==typeof window?w:window.innerHeight,k=E,I={rows:l,cols:f},null!=l&&null!=f?(I.rows=l,I.cols=f):null!=l&&null==f?(I.rows=l,I.cols=Math.ceil(k/I.rows)):null==l&&null!=f?(I.cols=f,I.rows=Math.ceil(k/I.cols)):(_=Math.sqrt(k*A/S),I.rows=Math.round(_),I.cols=Math.round(S/A*_)),I.rows=Math.max(I.rows,1),I.cols=Math.max(I.cols,1),I.cols*I.rows>k)R=xe(I),T=Me(I),(R-1)*T>=k?xe(I,R-1):(T-1)*R>=k&&Me(I,T-1);else for(;I.cols*I.rows<k;)R=xe(I),((T=Me(I))+1)*R>=k?Me(I,T+1):xe(I,R+1);for(C=u?0:S/I.cols,q=u?0:A/I.rows,(c||g)&&(L=z(10,g),F=O(30,p,!1),N.forEach((function(t){t.data.x&&t.data.y||(t.data.x=0,t.data.y=0);var e,n,o=r.getNode(t.id),i=F(o)||30;d(i)?(e=i[0],n=i[1]):(e=i,n=i);var s=void 0!==L?L(t):h,a=e+s,u=n+s;C=Math.max(C,a),q=Math.max(q,u)}))),j={},V={row:0,col:0},W={},$=0;$<N.length;$++){if(G=N[$],U=void 0,v&&(U=v(r.getNode(G.id))),U&&(void 0!==U.row||void 0!==U.col)){if(void 0===(H={row:U.row,col:U.col}).col)for(H.col=0;be(j,H);)H.col++;else if(void 0===H.row)for(H.row=0;be(j,H);)H.row++;W[G.id]=H,Ee(j,H)}Se(G,a,C,q,W,I,V,j)}return K={nodes:N,edges:b},t&&N.forEach((function(t){r.mergeNodeData(t.id,{x:t.data.x,y:t.data.y})})),[2,K]}))}))},t}(),xe=function(t,e){var r,n=t.rows||5,o=t.cols||5;return null==e?r=Math.min(n,o):Math.min(n,o)===t.rows?t.rows=e:t.cols=e,r},Me=function(t,e){var r,n=t.rows||5,o=t.cols||5;return null==e?r=Math.max(n,o):Math.max(n,o)===t.rows?t.rows=e:t.cols=e,r},be=function(t,e){return t["c-".concat(e.row,"-").concat(e.col)]||!1},Ee=function(t,e){return t["c-".concat(e.row,"-").concat(e.col)]=!0},Ne=function(t,e){var r=t.cols||5;e.col++,e.col>=r&&(e.col=0,e.row++)},Se=function(t,e,r,n,o,i,s,a){var u,h,c=o[t.id];if(c)u=c.col*r+r/2+e[0],h=c.row*n+n/2+e[1];else{for(;be(a,s);)Ne(i,s);u=s.col*r+r/2+e[0],h=s.row*n+n/2+e[1],Ee(a,s),Ne(i,s)}t.data.x=u,t.data.y=h};const Ae=Object.prototype.toString;function ke(t){return Ae.call(t).endsWith("Array]")}function Ie(t){var e,r=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};if(!ke(t))throw new TypeError("input must be an array");if(0===t.length)throw new TypeError("input must not be empty");if(void 0!==r.output){if(!ke(r.output))throw new TypeError("output option must be an array if specified");e=r.output}else e=new Array(t.length);var n=function(t){var e=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};if(!ke(t))throw new TypeError("input must be an array");if(0===t.length)throw new TypeError("input must not be empty");var r=e.fromIndex,n=void 0===r?0:r,o=e.toIndex,i=void 0===o?t.length:o;if(n<0||n>=t.length||!Number.isInteger(n))throw new Error("fromIndex must be a positive integer smaller than length");if(i<=n||i>t.length||!Number.isInteger(i))throw new Error("toIndex must be an integer greater than fromIndex and at most equal to length");for(var s=t[n],a=n+1;a<i;a++)t[a]<s&&(s=t[a]);return s}(t),o=function(t){var e=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};if(!ke(t))throw new TypeError("input must be an array");if(0===t.length)throw new TypeError("input must not be empty");var r=e.fromIndex,n=void 0===r?0:r,o=e.toIndex,i=void 0===o?t.length:o;if(n<0||n>=t.length||!Number.isInteger(n))throw new Error("fromIndex must be a positive integer smaller than length");if(i<=n||i>t.length||!Number.isInteger(i))throw new Error("toIndex must be an integer greater than fromIndex and at most equal to length");for(var s=t[n],a=n+1;a<i;a++)t[a]>s&&(s=t[a]);return s}(t);if(n===o)throw new RangeError("minimum and maximum input values are equal. Cannot rescale a constant array");var i=r.min,s=void 0===i?r.autoMinMax?n:0:i,a=r.max,u=void 0===a?r.autoMinMax?o:1:a;if(s>=u)throw new RangeError("min option must be smaller than max option");for(var h=(u-s)/(o-n),c=0;c<t.length;c++)e[c]=(t[c]-n)*h+s;return e}const _e=" ".repeat(2),De=" ".repeat(4);function Re(t,e={}){const{maxRows:r=15,maxColumns:n=10,maxNumSize:o=8,padMinus:i="auto"}=e;return`${t.constructor.name} {\n${_e}[\n${De}${function(t,e,r,n,o){const{rows:i,columns:s}=t,a=Math.min(i,e),u=Math.min(s,r),h=[];if("auto"===o){o=!1;t:for(let e=0;e<a;e++)for(let r=0;r<u;r++)if(t.get(e,r)<0){o=!0;break t}}for(let e=0;e<a;e++){let r=[];for(let i=0;i<u;i++)r.push(Te(t.get(e,i),n,o));h.push(`${r.join(" ")}`)}return u!==s&&(h[h.length-1]+=` ... ${s-r} more columns`),a!==i&&h.push(`... ${i-e} more rows`),h.join(`\n${De}`)}(t,r,n,o,i)}\n${_e}]\n${_e}rows: ${t.rows}\n${_e}columns: ${t.columns}\n}`}function Te(t,e,r){return(t>=0&&r?` ${ze(t,e-1)}`:ze(t,e)).padEnd(e)}function ze(t,e){let r=t.toString();if(r.length<=e)return r;let n=t.toFixed(e);if(n.length>e&&(n=t.toFixed(Math.max(0,e-(n.length-e)))),n.length<=e&&!n.startsWith("0.000")&&!n.startsWith("-0.000"))return n;let o=t.toExponential(e);return o.length>e&&(o=t.toExponential(Math.max(0,e-(o.length-e)))),o.slice(0)}function Oe(t,e,r){let n=r?t.rows:t.rows-1;if(e<0||e>n)throw new RangeError("Row index out of range")}function Pe(t,e,r){let n=r?t.columns:t.columns-1;if(e<0||e>n)throw new RangeError("Column index out of range")}function Ce(t,e){if(e.to1DArray&&(e=e.to1DArray()),e.length!==t.columns)throw new RangeError("vector size must be the same as the number of columns");return e}function qe(t,e){if(e.to1DArray&&(e=e.to1DArray()),e.length!==t.rows)throw new RangeError("vector size must be the same as the number of rows");return e}function Le(t,e,r,n,o){if(5!==arguments.length)throw new RangeError("expected 4 arguments");if(je("startRow",e),je("endRow",r),je("startColumn",n),je("endColumn",o),e>r||n>o||e<0||e>=t.rows||r<0||r>=t.rows||n<0||n>=t.columns||o<0||o>=t.columns)throw new RangeError("Submatrix indices are out of range")}function Fe(t,e=0){let r=[];for(let n=0;n<t;n++)r.push(e);return r}function je(t,e){if("number"!=typeof e)throw new TypeError(`${t} must be a number`)}function Ve(t){if(t.isEmpty())throw new Error("Empty matrix has no elements to index")}class We{static from1DArray(t,e,r){if(t*e!==r.length)throw new RangeError("data length does not match given dimensions");let n=new Ge(t,e);for(let o=0;o<t;o++)for(let t=0;t<e;t++)n.set(o,t,r[o*e+t]);return n}static rowVector(t){let e=new Ge(1,t.length);for(let r=0;r<t.length;r++)e.set(0,r,t[r]);return e}static columnVector(t){let e=new Ge(t.length,1);for(let r=0;r<t.length;r++)e.set(r,0,t[r]);return e}static zeros(t,e){return new Ge(t,e)}static ones(t,e){return new Ge(t,e).fill(1)}static rand(t,e,r={}){if("object"!=typeof r)throw new TypeError("options must be an object");const{random:n=Math.random}=r;let o=new Ge(t,e);for(let r=0;r<t;r++)for(let t=0;t<e;t++)o.set(r,t,n());return o}static randInt(t,e,r={}){if("object"!=typeof r)throw new TypeError("options must be an object");const{min:n=0,max:o=1e3,random:i=Math.random}=r;if(!Number.isInteger(n))throw new TypeError("min must be an integer");if(!Number.isInteger(o))throw new TypeError("max must be an integer");if(n>=o)throw new RangeError("min must be smaller than max");let s=o-n,a=new Ge(t,e);for(let r=0;r<t;r++)for(let t=0;t<e;t++){let e=n+Math.round(i()*s);a.set(r,t,e)}return a}static eye(t,e,r){void 0===e&&(e=t),void 0===r&&(r=1);let n=Math.min(t,e),o=this.zeros(t,e);for(let t=0;t<n;t++)o.set(t,t,r);return o}static diag(t,e,r){let n=t.length;void 0===e&&(e=n),void 0===r&&(r=e);let o=Math.min(n,e,r),i=this.zeros(e,r);for(let e=0;e<o;e++)i.set(e,e,t[e]);return i}static min(t,e){t=this.checkMatrix(t),e=this.checkMatrix(e);let r=t.rows,n=t.columns,o=new Ge(r,n);for(let i=0;i<r;i++)for(let r=0;r<n;r++)o.set(i,r,Math.min(t.get(i,r),e.get(i,r)));return o}static max(t,e){t=this.checkMatrix(t),e=this.checkMatrix(e);let r=t.rows,n=t.columns,o=new this(r,n);for(let i=0;i<r;i++)for(let r=0;r<n;r++)o.set(i,r,Math.max(t.get(i,r),e.get(i,r)));return o}static checkMatrix(t){return We.isMatrix(t)?t:new Ge(t)}static isMatrix(t){return null!=t&&"Matrix"===t.klass}get size(){return this.rows*this.columns}apply(t){if("function"!=typeof t)throw new TypeError("callback must be a function");for(let e=0;e<this.rows;e++)for(let r=0;r<this.columns;r++)t.call(this,e,r);return this}to1DArray(){let t=[];for(let e=0;e<this.rows;e++)for(let r=0;r<this.columns;r++)t.push(this.get(e,r));return t}to2DArray(){let t=[];for(let e=0;e<this.rows;e++){t.push([]);for(let r=0;r<this.columns;r++)t[e].push(this.get(e,r))}return t}toJSON(){return this.to2DArray()}isRowVector(){return 1===this.rows}isColumnVector(){return 1===this.columns}isVector(){return 1===this.rows||1===this.columns}isSquare(){return this.rows===this.columns}isEmpty(){return 0===this.rows||0===this.columns}isSymmetric(){if(this.isSquare()){for(let t=0;t<this.rows;t++)for(let e=0;e<=t;e++)if(this.get(t,e)!==this.get(e,t))return!1;return!0}return!1}isEchelonForm(){let t=0,e=0,r=-1,n=!0,o=!1;for(;t<this.rows&&n;){for(e=0,o=!1;e<this.columns&&!1===o;)0===this.get(t,e)?e++:1===this.get(t,e)&&e>r?(o=!0,r=e):(n=!1,o=!0);t++}return n}isReducedEchelonForm(){let t=0,e=0,r=-1,n=!0,o=!1;for(;t<this.rows&&n;){for(e=0,o=!1;e<this.columns&&!1===o;)0===this.get(t,e)?e++:1===this.get(t,e)&&e>r?(o=!0,r=e):(n=!1,o=!0);for(let r=e+1;r<this.rows;r++)0!==this.get(t,r)&&(n=!1);t++}return n}echelonForm(){let t=this.clone(),e=0,r=0;for(;e<t.rows&&r<t.columns;){let n=e;for(let o=e;o<t.rows;o++)t.get(o,r)>t.get(n,r)&&(n=o);if(0===t.get(n,r))r++;else{t.swapRows(e,n);let o=t.get(e,r);for(let n=r;n<t.columns;n++)t.set(e,n,t.get(e,n)/o);for(let n=e+1;n<t.rows;n++){let o=t.get(n,r)/t.get(e,r);t.set(n,r,0);for(let i=r+1;i<t.columns;i++)t.set(n,i,t.get(n,i)-t.get(e,i)*o)}e++,r++}}return t}reducedEchelonForm(){let t=this.echelonForm(),e=t.columns,r=t.rows,n=r-1;for(;n>=0;)if(0===t.maxRow(n))n--;else{let o=0,i=!1;for(;o<r&&!1===i;)1===t.get(n,o)?i=!0:o++;for(let r=0;r<n;r++){let i=t.get(r,o);for(let s=o;s<e;s++){let e=t.get(r,s)-i*t.get(n,s);t.set(r,s,e)}}n--}return t}set(){throw new Error("set method is unimplemented")}get(){throw new Error("get method is unimplemented")}repeat(t={}){if("object"!=typeof t)throw new TypeError("options must be an object");const{rows:e=1,columns:r=1}=t;if(!Number.isInteger(e)||e<=0)throw new TypeError("rows must be a positive integer");if(!Number.isInteger(r)||r<=0)throw new TypeError("columns must be a positive integer");let n=new Ge(this.rows*e,this.columns*r);for(let t=0;t<e;t++)for(let e=0;e<r;e++)n.setSubMatrix(this,this.rows*t,this.columns*e);return n}fill(t){for(let e=0;e<this.rows;e++)for(let r=0;r<this.columns;r++)this.set(e,r,t);return this}neg(){return this.mulS(-1)}getRow(t){Oe(this,t);let e=[];for(let r=0;r<this.columns;r++)e.push(this.get(t,r));return e}getRowVector(t){return Ge.rowVector(this.getRow(t))}setRow(t,e){Oe(this,t),e=Ce(this,e);for(let r=0;r<this.columns;r++)this.set(t,r,e[r]);return this}swapRows(t,e){Oe(this,t),Oe(this,e);for(let r=0;r<this.columns;r++){let n=this.get(t,r);this.set(t,r,this.get(e,r)),this.set(e,r,n)}return this}getColumn(t){Pe(this,t);let e=[];for(let r=0;r<this.rows;r++)e.push(this.get(r,t));return e}getColumnVector(t){return Ge.columnVector(this.getColumn(t))}setColumn(t,e){Pe(this,t),e=qe(this,e);for(let r=0;r<this.rows;r++)this.set(r,t,e[r]);return this}swapColumns(t,e){Pe(this,t),Pe(this,e);for(let r=0;r<this.rows;r++){let n=this.get(r,t);this.set(r,t,this.get(r,e)),this.set(r,e,n)}return this}addRowVector(t){t=Ce(this,t);for(let e=0;e<this.rows;e++)for(let r=0;r<this.columns;r++)this.set(e,r,this.get(e,r)+t[r]);return this}subRowVector(t){t=Ce(this,t);for(let e=0;e<this.rows;e++)for(let r=0;r<this.columns;r++)this.set(e,r,this.get(e,r)-t[r]);return this}mulRowVector(t){t=Ce(this,t);for(let e=0;e<this.rows;e++)for(let r=0;r<this.columns;r++)this.set(e,r,this.get(e,r)*t[r]);return this}divRowVector(t){t=Ce(this,t);for(let e=0;e<this.rows;e++)for(let r=0;r<this.columns;r++)this.set(e,r,this.get(e,r)/t[r]);return this}addColumnVector(t){t=qe(this,t);for(let e=0;e<this.rows;e++)for(let r=0;r<this.columns;r++)this.set(e,r,this.get(e,r)+t[e]);return this}subColumnVector(t){t=qe(this,t);for(let e=0;e<this.rows;e++)for(let r=0;r<this.columns;r++)this.set(e,r,this.get(e,r)-t[e]);return this}mulColumnVector(t){t=qe(this,t);for(let e=0;e<this.rows;e++)for(let r=0;r<this.columns;r++)this.set(e,r,this.get(e,r)*t[e]);return this}divColumnVector(t){t=qe(this,t);for(let e=0;e<this.rows;e++)for(let r=0;r<this.columns;r++)this.set(e,r,this.get(e,r)/t[e]);return this}mulRow(t,e){Oe(this,t);for(let r=0;r<this.columns;r++)this.set(t,r,this.get(t,r)*e);return this}mulColumn(t,e){Pe(this,t);for(let r=0;r<this.rows;r++)this.set(r,t,this.get(r,t)*e);return this}max(t){if(this.isEmpty())return NaN;switch(t){case"row":{const t=new Array(this.rows).fill(Number.NEGATIVE_INFINITY);for(let e=0;e<this.rows;e++)for(let r=0;r<this.columns;r++)this.get(e,r)>t[e]&&(t[e]=this.get(e,r));return t}case"column":{const t=new Array(this.columns).fill(Number.NEGATIVE_INFINITY);for(let e=0;e<this.rows;e++)for(let r=0;r<this.columns;r++)this.get(e,r)>t[r]&&(t[r]=this.get(e,r));return t}case void 0:{let t=this.get(0,0);for(let e=0;e<this.rows;e++)for(let r=0;r<this.columns;r++)this.get(e,r)>t&&(t=this.get(e,r));return t}default:throw new Error(`invalid option: ${t}`)}}maxIndex(){Ve(this);let t=this.get(0,0),e=[0,0];for(let r=0;r<this.rows;r++)for(let n=0;n<this.columns;n++)this.get(r,n)>t&&(t=this.get(r,n),e[0]=r,e[1]=n);return e}min(t){if(this.isEmpty())return NaN;switch(t){case"row":{const t=new Array(this.rows).fill(Number.POSITIVE_INFINITY);for(let e=0;e<this.rows;e++)for(let r=0;r<this.columns;r++)this.get(e,r)<t[e]&&(t[e]=this.get(e,r));return t}case"column":{const t=new Array(this.columns).fill(Number.POSITIVE_INFINITY);for(let e=0;e<this.rows;e++)for(let r=0;r<this.columns;r++)this.get(e,r)<t[r]&&(t[r]=this.get(e,r));return t}case void 0:{let t=this.get(0,0);for(let e=0;e<this.rows;e++)for(let r=0;r<this.columns;r++)this.get(e,r)<t&&(t=this.get(e,r));return t}default:throw new Error(`invalid option: ${t}`)}}minIndex(){Ve(this);let t=this.get(0,0),e=[0,0];for(let r=0;r<this.rows;r++)for(let n=0;n<this.columns;n++)this.get(r,n)<t&&(t=this.get(r,n),e[0]=r,e[1]=n);return e}maxRow(t){if(Oe(this,t),this.isEmpty())return NaN;let e=this.get(t,0);for(let r=1;r<this.columns;r++)this.get(t,r)>e&&(e=this.get(t,r));return e}maxRowIndex(t){Oe(this,t),Ve(this);let e=this.get(t,0),r=[t,0];for(let n=1;n<this.columns;n++)this.get(t,n)>e&&(e=this.get(t,n),r[1]=n);return r}minRow(t){if(Oe(this,t),this.isEmpty())return NaN;let e=this.get(t,0);for(let r=1;r<this.columns;r++)this.get(t,r)<e&&(e=this.get(t,r));return e}minRowIndex(t){Oe(this,t),Ve(this);let e=this.get(t,0),r=[t,0];for(let n=1;n<this.columns;n++)this.get(t,n)<e&&(e=this.get(t,n),r[1]=n);return r}maxColumn(t){if(Pe(this,t),this.isEmpty())return NaN;let e=this.get(0,t);for(let r=1;r<this.rows;r++)this.get(r,t)>e&&(e=this.get(r,t));return e}maxColumnIndex(t){Pe(this,t),Ve(this);let e=this.get(0,t),r=[0,t];for(let n=1;n<this.rows;n++)this.get(n,t)>e&&(e=this.get(n,t),r[0]=n);return r}minColumn(t){if(Pe(this,t),this.isEmpty())return NaN;let e=this.get(0,t);for(let r=1;r<this.rows;r++)this.get(r,t)<e&&(e=this.get(r,t));return e}minColumnIndex(t){Pe(this,t),Ve(this);let e=this.get(0,t),r=[0,t];for(let n=1;n<this.rows;n++)this.get(n,t)<e&&(e=this.get(n,t),r[0]=n);return r}diag(){let t=Math.min(this.rows,this.columns),e=[];for(let r=0;r<t;r++)e.push(this.get(r,r));return e}norm(t="frobenius"){let e=0;if("max"===t)return this.max();if("frobenius"===t){for(let t=0;t<this.rows;t++)for(let r=0;r<this.columns;r++)e+=this.get(t,r)*this.get(t,r);return Math.sqrt(e)}throw new RangeError(`unknown norm type: ${t}`)}cumulativeSum(){let t=0;for(let e=0;e<this.rows;e++)for(let r=0;r<this.columns;r++)t+=this.get(e,r),this.set(e,r,t);return this}dot(t){We.isMatrix(t)&&(t=t.to1DArray());let e=this.to1DArray();if(e.length!==t.length)throw new RangeError("vectors do not have the same size");let r=0;for(let n=0;n<e.length;n++)r+=e[n]*t[n];return r}mmul(t){t=Ge.checkMatrix(t);let e=this.rows,r=this.columns,n=t.columns,o=new Ge(e,n),i=new Float64Array(r);for(let s=0;s<n;s++){for(let e=0;e<r;e++)i[e]=t.get(e,s);for(let t=0;t<e;t++){let e=0;for(let n=0;n<r;n++)e+=this.get(t,n)*i[n];o.set(t,s,e)}}return o}strassen2x2(t){t=Ge.checkMatrix(t);let e=new Ge(2,2);const r=this.get(0,0),n=t.get(0,0),o=this.get(0,1),i=t.get(0,1),s=this.get(1,0),a=t.get(1,0),u=this.get(1,1),h=t.get(1,1),c=(r+u)*(n+h),l=(s+u)*n,f=r*(i-h),d=u*(a-n),g=(r+o)*h,p=c+d-g+(o-u)*(a+h),y=f+g,m=l+d,w=c-l+f+(s-r)*(n+i);return e.set(0,0,p),e.set(0,1,y),e.set(1,0,m),e.set(1,1,w),e}strassen3x3(t){t=Ge.checkMatrix(t);let e=new Ge(3,3);const r=this.get(0,0),n=this.get(0,1),o=this.get(0,2),i=this.get(1,0),s=this.get(1,1),a=this.get(1,2),u=this.get(2,0),h=this.get(2,1),c=this.get(2,2),l=t.get(0,0),f=t.get(0,1),d=t.get(0,2),g=t.get(1,0),p=t.get(1,1),y=t.get(1,2),m=t.get(2,0),w=t.get(2,1),v=t.get(2,2),x=(r-i)*(-f+p),M=(-r+i+s)*(l-f+p),b=(i+s)*(-l+f),E=r*l,N=(-r+u+h)*(l-d+y),S=(-r+u)*(d-y),A=(u+h)*(-l+d),k=(-o+h+c)*(p+m-w),I=(o-c)*(p-w),_=o*m,D=(h+c)*(-m+w),R=(-o+s+a)*(y+m-v),T=(o-a)*(y-v),z=(s+a)*(-m+v),O=E+_+n*g,P=(r+n+o-i-s-h-c)*p+M+b+E+k+_+D,C=E+N+A+(r+n+o-s-a-u-h)*y+_+R+z,q=x+s*(-l+f+g-p-y-m+v)+M+E+_+R+T,L=x+M+b+E+a*w,F=_+R+T+z+i*d,j=E+N+S+h*(-l+d+g-p-y-m+w)+k+I+_,V=k+I+_+D+u*f,W=E+N+S+A+c*v;return e.set(0,0,O),e.set(0,1,P),e.set(0,2,C),e.set(1,0,q),e.set(1,1,L),e.set(1,2,F),e.set(2,0,j),e.set(2,1,V),e.set(2,2,W),e}mmulStrassen(t){t=Ge.checkMatrix(t);let e=this.clone(),r=e.rows,n=e.columns,o=t.rows,i=t.columns;function s(t,e,r){let n=t.rows,o=t.columns;if(n===e&&o===r)return t;{let n=We.zeros(e,r);return n=n.setSubMatrix(t,0,0),n}}n!==o&&console.warn(`Multiplying ${r} x ${n} and ${o} x ${i} matrix: dimensions do not match.`);let a=Math.max(r,o),u=Math.max(n,i);return e=s(e,a,u),function t(e,r,n,o){if(n<=512||o<=512)return e.mmul(r);n%2==1&&o%2==1?(e=s(e,n+1,o+1),r=s(r,n+1,o+1)):n%2==1?(e=s(e,n+1,o),r=s(r,n+1,o)):o%2==1&&(e=s(e,n,o+1),r=s(r,n,o+1));let i=parseInt(e.rows/2,10),a=parseInt(e.columns/2,10),u=e.subMatrix(0,i-1,0,a-1),h=r.subMatrix(0,i-1,0,a-1),c=e.subMatrix(0,i-1,a,e.columns-1),l=r.subMatrix(0,i-1,a,r.columns-1),f=e.subMatrix(i,e.rows-1,0,a-1),d=r.subMatrix(i,r.rows-1,0,a-1),g=e.subMatrix(i,e.rows-1,a,e.columns-1),p=r.subMatrix(i,r.rows-1,a,r.columns-1),y=t(We.add(u,g),We.add(h,p),i,a),m=t(We.add(f,g),h,i,a),w=t(u,We.sub(l,p),i,a),v=t(g,We.sub(d,h),i,a),x=t(We.add(u,c),p,i,a),M=t(We.sub(f,u),We.add(h,l),i,a),b=t(We.sub(c,g),We.add(d,p),i,a),E=We.add(y,v);E.sub(x),E.add(b);let N=We.add(w,x),S=We.add(m,v),A=We.sub(y,m);A.add(w),A.add(M);let k=We.zeros(2*E.rows,2*E.columns);return k=k.setSubMatrix(E,0,0),k=k.setSubMatrix(N,E.rows,0),k=k.setSubMatrix(S,0,E.columns),k=k.setSubMatrix(A,E.rows,E.columns),k.subMatrix(0,n-1,0,o-1)}(e,t=s(t,a,u),a,u)}scaleRows(t={}){if("object"!=typeof t)throw new TypeError("options must be an object");const{min:e=0,max:r=1}=t;if(!Number.isFinite(e))throw new TypeError("min must be a number");if(!Number.isFinite(r))throw new TypeError("max must be a number");if(e>=r)throw new RangeError("min must be smaller than max");let n=new Ge(this.rows,this.columns);for(let t=0;t<this.rows;t++){const o=this.getRow(t);o.length>0&&Ie(o,{min:e,max:r,output:o}),n.setRow(t,o)}return n}scaleColumns(t={}){if("object"!=typeof t)throw new TypeError("options must be an object");const{min:e=0,max:r=1}=t;if(!Number.isFinite(e))throw new TypeError("min must be a number");if(!Number.isFinite(r))throw new TypeError("max must be a number");if(e>=r)throw new RangeError("min must be smaller than max");let n=new Ge(this.rows,this.columns);for(let t=0;t<this.columns;t++){const o=this.getColumn(t);o.length&&Ie(o,{min:e,max:r,output:o}),n.setColumn(t,o)}return n}flipRows(){const t=Math.ceil(this.columns/2);for(let e=0;e<this.rows;e++)for(let r=0;r<t;r++){let t=this.get(e,r),n=this.get(e,this.columns-1-r);this.set(e,r,n),this.set(e,this.columns-1-r,t)}return this}flipColumns(){const t=Math.ceil(this.rows/2);for(let e=0;e<this.columns;e++)for(let r=0;r<t;r++){let t=this.get(r,e),n=this.get(this.rows-1-r,e);this.set(r,e,n),this.set(this.rows-1-r,e,t)}return this}kroneckerProduct(t){t=Ge.checkMatrix(t);let e=this.rows,r=this.columns,n=t.rows,o=t.columns,i=new Ge(e*n,r*o);for(let s=0;s<e;s++)for(let e=0;e<r;e++)for(let r=0;r<n;r++)for(let a=0;a<o;a++)i.set(n*s+r,o*e+a,this.get(s,e)*t.get(r,a));return i}kroneckerSum(t){if(t=Ge.checkMatrix(t),!this.isSquare()||!t.isSquare())throw new Error("Kronecker Sum needs two Square Matrices");let e=this.rows,r=t.rows,n=this.kroneckerProduct(Ge.eye(r,r)),o=Ge.eye(e,e).kroneckerProduct(t);return n.add(o)}transpose(){let t=new Ge(this.columns,this.rows);for(let e=0;e<this.rows;e++)for(let r=0;r<this.columns;r++)t.set(r,e,this.get(e,r));return t}sortRows(t=$e){for(let e=0;e<this.rows;e++)this.setRow(e,this.getRow(e).sort(t));return this}sortColumns(t=$e){for(let e=0;e<this.columns;e++)this.setColumn(e,this.getColumn(e).sort(t));return this}subMatrix(t,e,r,n){Le(this,t,e,r,n);let o=new Ge(e-t+1,n-r+1);for(let i=t;i<=e;i++)for(let e=r;e<=n;e++)o.set(i-t,e-r,this.get(i,e));return o}subMatrixRow(t,e,r){if(void 0===e&&(e=0),void 0===r&&(r=this.columns-1),e>r||e<0||e>=this.columns||r<0||r>=this.columns)throw new RangeError("Argument out of range");let n=new Ge(t.length,r-e+1);for(let o=0;o<t.length;o++)for(let i=e;i<=r;i++){if(t[o]<0||t[o]>=this.rows)throw new RangeError(`Row index out of range: ${t[o]}`);n.set(o,i-e,this.get(t[o],i))}return n}subMatrixColumn(t,e,r){if(void 0===e&&(e=0),void 0===r&&(r=this.rows-1),e>r||e<0||e>=this.rows||r<0||r>=this.rows)throw new RangeError("Argument out of range");let n=new Ge(r-e+1,t.length);for(let o=0;o<t.length;o++)for(let i=e;i<=r;i++){if(t[o]<0||t[o]>=this.columns)throw new RangeError(`Column index out of range: ${t[o]}`);n.set(i-e,o,this.get(i,t[o]))}return n}setSubMatrix(t,e,r){if((t=Ge.checkMatrix(t)).isEmpty())return this;Le(this,e,e+t.rows-1,r,r+t.columns-1);for(let n=0;n<t.rows;n++)for(let o=0;o<t.columns;o++)this.set(e+n,r+o,t.get(n,o));return this}selection(t,e){!function(t,e){if(!ke(e))throw new TypeError("row indices must be an array");for(let r=0;r<e.length;r++)if(e[r]<0||e[r]>=t.rows)throw new RangeError("row indices are out of range")}(this,t),function(t,e){if(!ke(e))throw new TypeError("column indices must be an array");for(let r=0;r<e.length;r++)if(e[r]<0||e[r]>=t.columns)throw new RangeError("column indices are out of range")}(this,e);let r=new Ge(t.length,e.length);for(let n=0;n<t.length;n++){let o=t[n];for(let t=0;t<e.length;t++){let i=e[t];r.set(n,t,this.get(o,i))}}return r}trace(){let t=Math.min(this.rows,this.columns),e=0;for(let r=0;r<t;r++)e+=this.get(r,r);return e}clone(){let t=new Ge(this.rows,this.columns);for(let e=0;e<this.rows;e++)for(let r=0;r<this.columns;r++)t.set(e,r,this.get(e,r));return t}sum(t){switch(t){case"row":return function(t){let e=Fe(t.rows);for(let r=0;r<t.rows;++r)for(let n=0;n<t.columns;++n)e[r]+=t.get(r,n);return e}(this);case"column":return function(t){let e=Fe(t.columns);for(let r=0;r<t.rows;++r)for(let n=0;n<t.columns;++n)e[n]+=t.get(r,n);return e}(this);case void 0:return function(t){let e=0;for(let r=0;r<t.rows;r++)for(let n=0;n<t.columns;n++)e+=t.get(r,n);return e}(this);default:throw new Error(`invalid option: ${t}`)}}product(t){switch(t){case"row":return function(t){let e=Fe(t.rows,1);for(let r=0;r<t.rows;++r)for(let n=0;n<t.columns;++n)e[r]*=t.get(r,n);return e}(this);case"column":return function(t){let e=Fe(t.columns,1);for(let r=0;r<t.rows;++r)for(let n=0;n<t.columns;++n)e[n]*=t.get(r,n);return e}(this);case void 0:return function(t){let e=1;for(let r=0;r<t.rows;r++)for(let n=0;n<t.columns;n++)e*=t.get(r,n);return e}(this);default:throw new Error(`invalid option: ${t}`)}}mean(t){const e=this.sum(t);switch(t){case"row":for(let t=0;t<this.rows;t++)e[t]/=this.columns;return e;case"column":for(let t=0;t<this.columns;t++)e[t]/=this.rows;return e;case void 0:return e/this.size;default:throw new Error(`invalid option: ${t}`)}}variance(t,e={}){if("object"==typeof t&&(e=t,t=void 0),"object"!=typeof e)throw new TypeError("options must be an object");const{unbiased:r=!0,mean:n=this.mean(t)}=e;if("boolean"!=typeof r)throw new TypeError("unbiased must be a boolean");switch(t){case"row":if(!ke(n))throw new TypeError("mean must be an array");return function(t,e,r){const n=t.rows,o=t.columns,i=[];for(let s=0;s<n;s++){let n=0,a=0,u=0;for(let e=0;e<o;e++)u=t.get(s,e)-r[s],n+=u,a+=u*u;e?i.push((a-n*n/o)/(o-1)):i.push((a-n*n/o)/o)}return i}(this,r,n);case"column":if(!ke(n))throw new TypeError("mean must be an array");return function(t,e,r){const n=t.rows,o=t.columns,i=[];for(let s=0;s<o;s++){let o=0,a=0,u=0;for(let e=0;e<n;e++)u=t.get(e,s)-r[s],o+=u,a+=u*u;e?i.push((a-o*o/n)/(n-1)):i.push((a-o*o/n)/n)}return i}(this,r,n);case void 0:if("number"!=typeof n)throw new TypeError("mean must be a number");return function(t,e,r){const n=t.rows,o=t.columns,i=n*o;let s=0,a=0,u=0;for(let e=0;e<n;e++)for(let n=0;n<o;n++)u=t.get(e,n)-r,s+=u,a+=u*u;return e?(a-s*s/i)/(i-1):(a-s*s/i)/i}(this,r,n);default:throw new Error(`invalid option: ${t}`)}}standardDeviation(t,e){"object"==typeof t&&(e=t,t=void 0);const r=this.variance(t,e);if(void 0===t)return Math.sqrt(r);for(let t=0;t<r.length;t++)r[t]=Math.sqrt(r[t]);return r}center(t,e={}){if("object"==typeof t&&(e=t,t=void 0),"object"!=typeof e)throw new TypeError("options must be an object");const{center:r=this.mean(t)}=e;switch(t){case"row":if(!ke(r))throw new TypeError("center must be an array");return function(t,e){for(let r=0;r<t.rows;r++)for(let n=0;n<t.columns;n++)t.set(r,n,t.get(r,n)-e[r])}(this,r),this;case"column":if(!ke(r))throw new TypeError("center must be an array");return function(t,e){for(let r=0;r<t.rows;r++)for(let n=0;n<t.columns;n++)t.set(r,n,t.get(r,n)-e[n])}(this,r),this;case void 0:if("number"!=typeof r)throw new TypeError("center must be a number");return function(t,e){for(let r=0;r<t.rows;r++)for(let n=0;n<t.columns;n++)t.set(r,n,t.get(r,n)-e)}(this,r),this;default:throw new Error(`invalid option: ${t}`)}}scale(t,e={}){if("object"==typeof t&&(e=t,t=void 0),"object"!=typeof e)throw new TypeError("options must be an object");let r=e.scale;switch(t){case"row":if(void 0===r)r=function(t){const e=[];for(let r=0;r<t.rows;r++){let n=0;for(let e=0;e<t.columns;e++)n+=Math.pow(t.get(r,e),2)/(t.columns-1);e.push(Math.sqrt(n))}return e}(this);else if(!ke(r))throw new TypeError("scale must be an array");return function(t,e){for(let r=0;r<t.rows;r++)for(let n=0;n<t.columns;n++)t.set(r,n,t.get(r,n)/e[r])}(this,r),this;case"column":if(void 0===r)r=function(t){const e=[];for(let r=0;r<t.columns;r++){let n=0;for(let e=0;e<t.rows;e++)n+=Math.pow(t.get(e,r),2)/(t.rows-1);e.push(Math.sqrt(n))}return e}(this);else if(!ke(r))throw new TypeError("scale must be an array");return function(t,e){for(let r=0;r<t.rows;r++)for(let n=0;n<t.columns;n++)t.set(r,n,t.get(r,n)/e[n])}(this,r),this;case void 0:if(void 0===r)r=function(t){const e=t.size-1;let r=0;for(let n=0;n<t.columns;n++)for(let o=0;o<t.rows;o++)r+=Math.pow(t.get(o,n),2)/e;return Math.sqrt(r)}(this);else if("number"!=typeof r)throw new TypeError("scale must be a number");return function(t,e){for(let r=0;r<t.rows;r++)for(let n=0;n<t.columns;n++)t.set(r,n,t.get(r,n)/e)}(this,r),this;default:throw new Error(`invalid option: ${t}`)}}toString(t){return Re(this,t)}}function $e(t,e){return t-e}We.prototype.klass="Matrix","undefined"!=typeof Symbol&&(We.prototype[Symbol.for("nodejs.util.inspect.custom")]=function(){return Re(this)}),We.random=We.rand,We.randomInt=We.randInt,We.diagonal=We.diag,We.prototype.diagonal=We.prototype.diag,We.identity=We.eye,We.prototype.negate=We.prototype.neg,We.prototype.tensorProduct=We.prototype.kroneckerProduct;class Ge extends We{constructor(t,e){if(super(),Ge.isMatrix(t))return t.clone();if(Number.isInteger(t)&&t>=0){if(this.data=[],!(Number.isInteger(e)&&e>=0))throw new TypeError("nColumns must be a positive integer");for(let r=0;r<t;r++)this.data.push(new Float64Array(e))}else{if(!ke(t))throw new TypeError("First argument must be a positive number or an array");{const r=t;if("number"!=typeof(e=(t=r.length)?r[0].length:0))throw new TypeError("Data must be a 2D array with at least one element");this.data=[];for(let n=0;n<t;n++){if(r[n].length!==e)throw new RangeError("Inconsistent array dimensions");if(!r[n].every((t=>"number"==typeof t)))throw new TypeError("Input data contains non-numeric values");this.data.push(Float64Array.from(r[n]))}}}this.rows=t,this.columns=e}set(t,e,r){return this.data[t][e]=r,this}get(t,e){return this.data[t][e]}removeRow(t){return Oe(this,t),this.data.splice(t,1),this.rows-=1,this}addRow(t,e){return void 0===e&&(e=t,t=this.rows),Oe(this,t,!0),e=Float64Array.from(Ce(this,e)),this.data.splice(t,0,e),this.rows+=1,this}removeColumn(t){Pe(this,t);for(let e=0;e<this.rows;e++){const r=new Float64Array(this.columns-1);for(let n=0;n<t;n++)r[n]=this.data[e][n];for(let n=t+1;n<this.columns;n++)r[n-1]=this.data[e][n];this.data[e]=r}return this.columns-=1,this}addColumn(t,e){void 0===e&&(e=t,t=this.columns),Pe(this,t,!0),e=qe(this,e);for(let r=0;r<this.rows;r++){const n=new Float64Array(this.columns+1);let o=0;for(;o<t;o++)n[o]=this.data[r][o];for(n[o++]=e[r];o<this.columns+1;o++)n[o]=this.data[r][o-1];this.data[r]=n}return this.columns+=1,this}}!function(t,e){t.prototype.add=function(t){return"number"==typeof t?this.addS(t):this.addM(t)},t.prototype.addS=function(t){for(let e=0;e<this.rows;e++)for(let r=0;r<this.columns;r++)this.set(e,r,this.get(e,r)+t);return this},t.prototype.addM=function(t){if(t=e.checkMatrix(t),this.rows!==t.rows||this.columns!==t.columns)throw new RangeError("Matrices dimensions must be equal");for(let e=0;e<this.rows;e++)for(let r=0;r<this.columns;r++)this.set(e,r,this.get(e,r)+t.get(e,r));return this},t.add=function(t,r){return new e(t).add(r)},t.prototype.sub=function(t){return"number"==typeof t?this.subS(t):this.subM(t)},t.prototype.subS=function(t){for(let e=0;e<this.rows;e++)for(let r=0;r<this.columns;r++)this.set(e,r,this.get(e,r)-t);return this},t.prototype.subM=function(t){if(t=e.checkMatrix(t),this.rows!==t.rows||this.columns!==t.columns)throw new RangeError("Matrices dimensions must be equal");for(let e=0;e<this.rows;e++)for(let r=0;r<this.columns;r++)this.set(e,r,this.get(e,r)-t.get(e,r));return this},t.sub=function(t,r){return new e(t).sub(r)},t.prototype.subtract=t.prototype.sub,t.prototype.subtractS=t.prototype.subS,t.prototype.subtractM=t.prototype.subM,t.subtract=t.sub,t.prototype.mul=function(t){return"number"==typeof t?this.mulS(t):this.mulM(t)},t.prototype.mulS=function(t){for(let e=0;e<this.rows;e++)for(let r=0;r<this.columns;r++)this.set(e,r,this.get(e,r)*t);return this},t.prototype.mulM=function(t){if(t=e.checkMatrix(t),this.rows!==t.rows||this.columns!==t.columns)throw new RangeError("Matrices dimensions must be equal");for(let e=0;e<this.rows;e++)for(let r=0;r<this.columns;r++)this.set(e,r,this.get(e,r)*t.get(e,r));return this},t.mul=function(t,r){return new e(t).mul(r)},t.prototype.multiply=t.prototype.mul,t.prototype.multiplyS=t.prototype.mulS,t.prototype.multiplyM=t.prototype.mulM,t.multiply=t.mul,t.prototype.div=function(t){return"number"==typeof t?this.divS(t):this.divM(t)},t.prototype.divS=function(t){for(let e=0;e<this.rows;e++)for(let r=0;r<this.columns;r++)this.set(e,r,this.get(e,r)/t);return this},t.prototype.divM=function(t){if(t=e.checkMatrix(t),this.rows!==t.rows||this.columns!==t.columns)throw new RangeError("Matrices dimensions must be equal");for(let e=0;e<this.rows;e++)for(let r=0;r<this.columns;r++)this.set(e,r,this.get(e,r)/t.get(e,r));return this},t.div=function(t,r){return new e(t).div(r)},t.prototype.divide=t.prototype.div,t.prototype.divideS=t.prototype.divS,t.prototype.divideM=t.prototype.divM,t.divide=t.div,t.prototype.mod=function(t){return"number"==typeof t?this.modS(t):this.modM(t)},t.prototype.modS=function(t){for(let e=0;e<this.rows;e++)for(let r=0;r<this.columns;r++)this.set(e,r,this.get(e,r)%t);return this},t.prototype.modM=function(t){if(t=e.checkMatrix(t),this.rows!==t.rows||this.columns!==t.columns)throw new RangeError("Matrices dimensions must be equal");for(let e=0;e<this.rows;e++)for(let r=0;r<this.columns;r++)this.set(e,r,this.get(e,r)%t.get(e,r));return this},t.mod=function(t,r){return new e(t).mod(r)},t.prototype.modulus=t.prototype.mod,t.prototype.modulusS=t.prototype.modS,t.prototype.modulusM=t.prototype.modM,t.modulus=t.mod,t.prototype.and=function(t){return"number"==typeof t?this.andS(t):this.andM(t)},t.prototype.andS=function(t){for(let e=0;e<this.rows;e++)for(let r=0;r<this.columns;r++)this.set(e,r,this.get(e,r)&t);return this},t.prototype.andM=function(t){if(t=e.checkMatrix(t),this.rows!==t.rows||this.columns!==t.columns)throw new RangeError("Matrices dimensions must be equal");for(let e=0;e<this.rows;e++)for(let r=0;r<this.columns;r++)this.set(e,r,this.get(e,r)&t.get(e,r));return this},t.and=function(t,r){return new e(t).and(r)},t.prototype.or=function(t){return"number"==typeof t?this.orS(t):this.orM(t)},t.prototype.orS=function(t){for(let e=0;e<this.rows;e++)for(let r=0;r<this.columns;r++)this.set(e,r,this.get(e,r)|t);return this},t.prototype.orM=function(t){if(t=e.checkMatrix(t),this.rows!==t.rows||this.columns!==t.columns)throw new RangeError("Matrices dimensions must be equal");for(let e=0;e<this.rows;e++)for(let r=0;r<this.columns;r++)this.set(e,r,this.get(e,r)|t.get(e,r));return this},t.or=function(t,r){return new e(t).or(r)},t.prototype.xor=function(t){return"number"==typeof t?this.xorS(t):this.xorM(t)},t.prototype.xorS=function(t){for(let e=0;e<this.rows;e++)for(let r=0;r<this.columns;r++)this.set(e,r,this.get(e,r)^t);return this},t.prototype.xorM=function(t){if(t=e.checkMatrix(t),this.rows!==t.rows||this.columns!==t.columns)throw new RangeError("Matrices dimensions must be equal");for(let e=0;e<this.rows;e++)for(let r=0;r<this.columns;r++)this.set(e,r,this.get(e,r)^t.get(e,r));return this},t.xor=function(t,r){return new e(t).xor(r)},t.prototype.leftShift=function(t){return"number"==typeof t?this.leftShiftS(t):this.leftShiftM(t)},t.prototype.leftShiftS=function(t){for(let e=0;e<this.rows;e++)for(let r=0;r<this.columns;r++)this.set(e,r,this.get(e,r)<<t);return this},t.prototype.leftShiftM=function(t){if(t=e.checkMatrix(t),this.rows!==t.rows||this.columns!==t.columns)throw new RangeError("Matrices dimensions must be equal");for(let e=0;e<this.rows;e++)for(let r=0;r<this.columns;r++)this.set(e,r,this.get(e,r)<<t.get(e,r));return this},t.leftShift=function(t,r){return new e(t).leftShift(r)},t.prototype.signPropagatingRightShift=function(t){return"number"==typeof t?this.signPropagatingRightShiftS(t):this.signPropagatingRightShiftM(t)},t.prototype.signPropagatingRightShiftS=function(t){for(let e=0;e<this.rows;e++)for(let r=0;r<this.columns;r++)this.set(e,r,this.get(e,r)>>t);return this},t.prototype.signPropagatingRightShiftM=function(t){if(t=e.checkMatrix(t),this.rows!==t.rows||this.columns!==t.columns)throw new RangeError("Matrices dimensions must be equal");for(let e=0;e<this.rows;e++)for(let r=0;r<this.columns;r++)this.set(e,r,this.get(e,r)>>t.get(e,r));return this},t.signPropagatingRightShift=function(t,r){return new e(t).signPropagatingRightShift(r)},t.prototype.rightShift=function(t){return"number"==typeof t?this.rightShiftS(t):this.rightShiftM(t)},t.prototype.rightShiftS=function(t){for(let e=0;e<this.rows;e++)for(let r=0;r<this.columns;r++)this.set(e,r,this.get(e,r)>>>t);return this},t.prototype.rightShiftM=function(t){if(t=e.checkMatrix(t),this.rows!==t.rows||this.columns!==t.columns)throw new RangeError("Matrices dimensions must be equal");for(let e=0;e<this.rows;e++)for(let r=0;r<this.columns;r++)this.set(e,r,this.get(e,r)>>>t.get(e,r));return this},t.rightShift=function(t,r){return new e(t).rightShift(r)},t.prototype.zeroFillRightShift=t.prototype.rightShift,t.prototype.zeroFillRightShiftS=t.prototype.rightShiftS,t.prototype.zeroFillRightShiftM=t.prototype.rightShiftM,t.zeroFillRightShift=t.rightShift,t.prototype.not=function(){for(let t=0;t<this.rows;t++)for(let e=0;e<this.columns;e++)this.set(t,e,~this.get(t,e));return this},t.not=function(t){return new e(t).not()},t.prototype.abs=function(){for(let t=0;t<this.rows;t++)for(let e=0;e<this.columns;e++)this.set(t,e,Math.abs(this.get(t,e)));return this},t.abs=function(t){return new e(t).abs()},t.prototype.acos=function(){for(let t=0;t<this.rows;t++)for(let e=0;e<this.columns;e++)this.set(t,e,Math.acos(this.get(t,e)));return this},t.acos=function(t){return new e(t).acos()},t.prototype.acosh=function(){for(let t=0;t<this.rows;t++)for(let e=0;e<this.columns;e++)this.set(t,e,Math.acosh(this.get(t,e)));return this},t.acosh=function(t){return new e(t).acosh()},t.prototype.asin=function(){for(let t=0;t<this.rows;t++)for(let e=0;e<this.columns;e++)this.set(t,e,Math.asin(this.get(t,e)));return this},t.asin=function(t){return new e(t).asin()},t.prototype.asinh=function(){for(let t=0;t<this.rows;t++)for(let e=0;e<this.columns;e++)this.set(t,e,Math.asinh(this.get(t,e)));return this},t.asinh=function(t){return new e(t).asinh()},t.prototype.atan=function(){for(let t=0;t<this.rows;t++)for(let e=0;e<this.columns;e++)this.set(t,e,Math.atan(this.get(t,e)));return this},t.atan=function(t){return new e(t).atan()},t.prototype.atanh=function(){for(let t=0;t<this.rows;t++)for(let e=0;e<this.columns;e++)this.set(t,e,Math.atanh(this.get(t,e)));return this},t.atanh=function(t){return new e(t).atanh()},t.prototype.cbrt=function(){for(let t=0;t<this.rows;t++)for(let e=0;e<this.columns;e++)this.set(t,e,Math.cbrt(this.get(t,e)));return this},t.cbrt=function(t){return new e(t).cbrt()},t.prototype.ceil=function(){for(let t=0;t<this.rows;t++)for(let e=0;e<this.columns;e++)this.set(t,e,Math.ceil(this.get(t,e)));return this},t.ceil=function(t){return new e(t).ceil()},t.prototype.clz32=function(){for(let t=0;t<this.rows;t++)for(let e=0;e<this.columns;e++)this.set(t,e,Math.clz32(this.get(t,e)));return this},t.clz32=function(t){return new e(t).clz32()},t.prototype.cos=function(){for(let t=0;t<this.rows;t++)for(let e=0;e<this.columns;e++)this.set(t,e,Math.cos(this.get(t,e)));return this},t.cos=function(t){return new e(t).cos()},t.prototype.cosh=function(){for(let t=0;t<this.rows;t++)for(let e=0;e<this.columns;e++)this.set(t,e,Math.cosh(this.get(t,e)));return this},t.cosh=function(t){return new e(t).cosh()},t.prototype.exp=function(){for(let t=0;t<this.rows;t++)for(let e=0;e<this.columns;e++)this.set(t,e,Math.exp(this.get(t,e)));return this},t.exp=function(t){return new e(t).exp()},t.prototype.expm1=function(){for(let t=0;t<this.rows;t++)for(let e=0;e<this.columns;e++)this.set(t,e,Math.expm1(this.get(t,e)));return this},t.expm1=function(t){return new e(t).expm1()},t.prototype.floor=function(){for(let t=0;t<this.rows;t++)for(let e=0;e<this.columns;e++)this.set(t,e,Math.floor(this.get(t,e)));return this},t.floor=function(t){return new e(t).floor()},t.prototype.fround=function(){for(let t=0;t<this.rows;t++)for(let e=0;e<this.columns;e++)this.set(t,e,Math.fround(this.get(t,e)));return this},t.fround=function(t){return new e(t).fround()},t.prototype.log=function(){for(let t=0;t<this.rows;t++)for(let e=0;e<this.columns;e++)this.set(t,e,Math.log(this.get(t,e)));return this},t.log=function(t){return new e(t).log()},t.prototype.log1p=function(){for(let t=0;t<this.rows;t++)for(let e=0;e<this.columns;e++)this.set(t,e,Math.log1p(this.get(t,e)));return this},t.log1p=function(t){return new e(t).log1p()},t.prototype.log10=function(){for(let t=0;t<this.rows;t++)for(let e=0;e<this.columns;e++)this.set(t,e,Math.log10(this.get(t,e)));return this},t.log10=function(t){return new e(t).log10()},t.prototype.log2=function(){for(let t=0;t<this.rows;t++)for(let e=0;e<this.columns;e++)this.set(t,e,Math.log2(this.get(t,e)));return this},t.log2=function(t){return new e(t).log2()},t.prototype.round=function(){for(let t=0;t<this.rows;t++)for(let e=0;e<this.columns;e++)this.set(t,e,Math.round(this.get(t,e)));return this},t.round=function(t){return new e(t).round()},t.prototype.sign=function(){for(let t=0;t<this.rows;t++)for(let e=0;e<this.columns;e++)this.set(t,e,Math.sign(this.get(t,e)));return this},t.sign=function(t){return new e(t).sign()},t.prototype.sin=function(){for(let t=0;t<this.rows;t++)for(let e=0;e<this.columns;e++)this.set(t,e,Math.sin(this.get(t,e)));return this},t.sin=function(t){return new e(t).sin()},t.prototype.sinh=function(){for(let t=0;t<this.rows;t++)for(let e=0;e<this.columns;e++)this.set(t,e,Math.sinh(this.get(t,e)));return this},t.sinh=function(t){return new e(t).sinh()},t.prototype.sqrt=function(){for(let t=0;t<this.rows;t++)for(let e=0;e<this.columns;e++)this.set(t,e,Math.sqrt(this.get(t,e)));return this},t.sqrt=function(t){return new e(t).sqrt()},t.prototype.tan=function(){for(let t=0;t<this.rows;t++)for(let e=0;e<this.columns;e++)this.set(t,e,Math.tan(this.get(t,e)));return this},t.tan=function(t){return new e(t).tan()},t.prototype.tanh=function(){for(let t=0;t<this.rows;t++)for(let e=0;e<this.columns;e++)this.set(t,e,Math.tanh(this.get(t,e)));return this},t.tanh=function(t){return new e(t).tanh()},t.prototype.trunc=function(){for(let t=0;t<this.rows;t++)for(let e=0;e<this.columns;e++)this.set(t,e,Math.trunc(this.get(t,e)));return this},t.trunc=function(t){return new e(t).trunc()},t.pow=function(t,r){return new e(t).pow(r)},t.prototype.pow=function(t){return"number"==typeof t?this.powS(t):this.powM(t)},t.prototype.powS=function(t){for(let e=0;e<this.rows;e++)for(let r=0;r<this.columns;r++)this.set(e,r,Math.pow(this.get(e,r),t));return this},t.prototype.powM=function(t){if(t=e.checkMatrix(t),this.rows!==t.rows||this.columns!==t.columns)throw new RangeError("Matrices dimensions must be equal");for(let e=0;e<this.rows;e++)for(let r=0;r<this.columns;r++)this.set(e,r,Math.pow(this.get(e,r),t.get(e,r)));return this}}(We,Ge);class Be extends We{constructor(t){super(),this.data=t,this.rows=t.length,this.columns=t[0].length}set(t,e,r){return this.data[t][e]=r,this}get(t,e){return this.data[t][e]}}function Ue(t,e){let r=0;return Math.abs(t)>Math.abs(e)?(r=e/t,Math.abs(t)*Math.sqrt(1+r*r)):0!==e?(r=t/e,Math.abs(e)*Math.sqrt(1+r*r)):0}class He{constructor(t,e={}){if((t=Be.checkMatrix(t)).isEmpty())throw new Error("Matrix must be non-empty");let r=t.rows,n=t.columns;const{computeLeftSingularVectors:o=!0,computeRightSingularVectors:i=!0,autoTranspose:s=!1}=e;let a,u=Boolean(o),h=Boolean(i),c=!1;if(r<n)if(s){a=t.transpose(),r=a.rows,n=a.columns,c=!0;let e=u;u=h,h=e}else a=t.clone(),console.warn("Computing SVD on a matrix with more columns than rows. Consider enabling autoTranspose");else a=t.clone();let l=Math.min(r,n),f=Math.min(r+1,n),d=new Float64Array(f),g=new Ge(r,l),p=new Ge(n,n),y=new Float64Array(n),m=new Float64Array(r),w=new Float64Array(f);for(let t=0;t<f;t++)w[t]=t;let v=Math.min(r-1,n),x=Math.max(0,Math.min(n-2,r)),M=Math.max(v,x);for(let t=0;t<M;t++){if(t<v){d[t]=0;for(let e=t;e<r;e++)d[t]=Ue(d[t],a.get(e,t));if(0!==d[t]){a.get(t,t)<0&&(d[t]=-d[t]);for(let e=t;e<r;e++)a.set(e,t,a.get(e,t)/d[t]);a.set(t,t,a.get(t,t)+1)}d[t]=-d[t]}for(let e=t+1;e<n;e++){if(t<v&&0!==d[t]){let n=0;for(let o=t;o<r;o++)n+=a.get(o,t)*a.get(o,e);n=-n/a.get(t,t);for(let o=t;o<r;o++)a.set(o,e,a.get(o,e)+n*a.get(o,t))}y[e]=a.get(t,e)}if(u&&t<v)for(let e=t;e<r;e++)g.set(e,t,a.get(e,t));if(t<x){y[t]=0;for(let e=t+1;e<n;e++)y[t]=Ue(y[t],y[e]);if(0!==y[t]){y[t+1]<0&&(y[t]=0-y[t]);for(let e=t+1;e<n;e++)y[e]/=y[t];y[t+1]+=1}if(y[t]=-y[t],t+1<r&&0!==y[t]){for(let e=t+1;e<r;e++)m[e]=0;for(let e=t+1;e<r;e++)for(let r=t+1;r<n;r++)m[e]+=y[r]*a.get(e,r);for(let e=t+1;e<n;e++){let n=-y[e]/y[t+1];for(let o=t+1;o<r;o++)a.set(o,e,a.get(o,e)+n*m[o])}}if(h)for(let e=t+1;e<n;e++)p.set(e,t,y[e])}}let b=Math.min(n,r+1);if(v<n&&(d[v]=a.get(v,v)),r<b&&(d[b-1]=0),x+1<b&&(y[x]=a.get(x,b-1)),y[b-1]=0,u){for(let t=v;t<l;t++){for(let e=0;e<r;e++)g.set(e,t,0);g.set(t,t,1)}for(let t=v-1;t>=0;t--)if(0!==d[t]){for(let e=t+1;e<l;e++){let n=0;for(let o=t;o<r;o++)n+=g.get(o,t)*g.get(o,e);n=-n/g.get(t,t);for(let o=t;o<r;o++)g.set(o,e,g.get(o,e)+n*g.get(o,t))}for(let e=t;e<r;e++)g.set(e,t,-g.get(e,t));g.set(t,t,1+g.get(t,t));for(let e=0;e<t-1;e++)g.set(e,t,0)}else{for(let e=0;e<r;e++)g.set(e,t,0);g.set(t,t,1)}}if(h)for(let t=n-1;t>=0;t--){if(t<x&&0!==y[t])for(let e=t+1;e<n;e++){let r=0;for(let o=t+1;o<n;o++)r+=p.get(o,t)*p.get(o,e);r=-r/p.get(t+1,t);for(let o=t+1;o<n;o++)p.set(o,e,p.get(o,e)+r*p.get(o,t))}for(let e=0;e<n;e++)p.set(e,t,0);p.set(t,t,1)}let E=b-1,N=0,S=Number.EPSILON;for(;b>0;){let t,e;for(t=b-2;t>=-1&&-1!==t;t--){const e=Number.MIN_VALUE+S*Math.abs(d[t]+Math.abs(d[t+1]));if(Math.abs(y[t])<=e||Number.isNaN(y[t])){y[t]=0;break}}if(t===b-2)e=4;else{let r;for(r=b-1;r>=t&&r!==t;r--){let e=(r!==b?Math.abs(y[r]):0)+(r!==t+1?Math.abs(y[r-1]):0);if(Math.abs(d[r])<=S*e){d[r]=0;break}}r===t?e=3:r===b-1?e=1:(e=2,t=r)}switch(t++,e){case 1:{let e=y[b-2];y[b-2]=0;for(let r=b-2;r>=t;r--){let o=Ue(d[r],e),i=d[r]/o,s=e/o;if(d[r]=o,r!==t&&(e=-s*y[r-1],y[r-1]=i*y[r-1]),h)for(let t=0;t<n;t++)o=i*p.get(t,r)+s*p.get(t,b-1),p.set(t,b-1,-s*p.get(t,r)+i*p.get(t,b-1)),p.set(t,r,o)}break}case 2:{let e=y[t-1];y[t-1]=0;for(let n=t;n<b;n++){let o=Ue(d[n],e),i=d[n]/o,s=e/o;if(d[n]=o,e=-s*y[n],y[n]=i*y[n],u)for(let e=0;e<r;e++)o=i*g.get(e,n)+s*g.get(e,t-1),g.set(e,t-1,-s*g.get(e,n)+i*g.get(e,t-1)),g.set(e,n,o)}break}case 3:{const e=Math.max(Math.abs(d[b-1]),Math.abs(d[b-2]),Math.abs(y[b-2]),Math.abs(d[t]),Math.abs(y[t])),o=d[b-1]/e,i=d[b-2]/e,s=y[b-2]/e,a=d[t]/e,c=y[t]/e,l=((i+o)*(i-o)+s*s)/2,f=o*s*(o*s);let m=0;0===l&&0===f||(m=l<0?0-Math.sqrt(l*l+f):Math.sqrt(l*l+f),m=f/(l+m));let w=(a+o)*(a-o)+m,v=a*c;for(let e=t;e<b-1;e++){let o=Ue(w,v);0===o&&(o=Number.MIN_VALUE);let i=w/o,s=v/o;if(e!==t&&(y[e-1]=o),w=i*d[e]+s*y[e],y[e]=i*y[e]-s*d[e],v=s*d[e+1],d[e+1]=i*d[e+1],h)for(let t=0;t<n;t++)o=i*p.get(t,e)+s*p.get(t,e+1),p.set(t,e+1,-s*p.get(t,e)+i*p.get(t,e+1)),p.set(t,e,o);if(o=Ue(w,v),0===o&&(o=Number.MIN_VALUE),i=w/o,s=v/o,d[e]=o,w=i*y[e]+s*d[e+1],d[e+1]=-s*y[e]+i*d[e+1],v=s*y[e+1],y[e+1]=i*y[e+1],u&&e<r-1)for(let t=0;t<r;t++)o=i*g.get(t,e)+s*g.get(t,e+1),g.set(t,e+1,-s*g.get(t,e)+i*g.get(t,e+1)),g.set(t,e,o)}y[b-2]=w,N+=1;break}case 4:if(d[t]<=0&&(d[t]=d[t]<0?-d[t]:0,h))for(let e=0;e<=E;e++)p.set(e,t,-p.get(e,t));for(;t<E&&!(d[t]>=d[t+1]);){let e=d[t];if(d[t]=d[t+1],d[t+1]=e,h&&t<n-1)for(let r=0;r<n;r++)e=p.get(r,t+1),p.set(r,t+1,p.get(r,t)),p.set(r,t,e);if(u&&t<r-1)for(let n=0;n<r;n++)e=g.get(n,t+1),g.set(n,t+1,g.get(n,t)),g.set(n,t,e);t++}N=0,b--}}if(c){let t=p;p=g,g=t}this.m=r,this.n=n,this.s=d,this.U=g,this.V=p}solve(t){let e=t,r=this.threshold,n=this.s.length,o=Ge.zeros(n,n);for(let t=0;t<n;t++)Math.abs(this.s[t])<=r?o.set(t,t,0):o.set(t,t,1/this.s[t]);let i=this.U,s=this.rightSingularVectors,a=s.mmul(o),u=s.rows,h=i.rows,c=Ge.zeros(u,h);for(let t=0;t<u;t++)for(let e=0;e<h;e++){let r=0;for(let o=0;o<n;o++)r+=a.get(t,o)*i.get(e,o);c.set(t,e,r)}return c.mmul(e)}solveForDiagonal(t){return this.solve(Ge.diag(t))}inverse(){let t=this.V,e=this.threshold,r=t.rows,n=t.columns,o=new Ge(r,this.s.length);for(let i=0;i<r;i++)for(let r=0;r<n;r++)Math.abs(this.s[r])>e&&o.set(i,r,t.get(i,r)/this.s[r]);let i=this.U,s=i.rows,a=i.columns,u=new Ge(r,s);for(let t=0;t<r;t++)for(let e=0;e<s;e++){let r=0;for(let n=0;n<a;n++)r+=o.get(t,n)*i.get(e,n);u.set(t,e,r)}return u}get condition(){return this.s[0]/this.s[Math.min(this.m,this.n)-1]}get norm2(){return this.s[0]}get rank(){let t=Math.max(this.m,this.n)*this.s[0]*Number.EPSILON,e=0,r=this.s;for(let n=0,o=r.length;n<o;n++)r[n]>t&&e++;return e}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 Ge.diag(this.s)}}var Ke={center:[0,0],linkDistance:50},Je=function(){function t(t){void 0===t&&(t={}),this.options=t,this.id="mds",this.options=e(e({},Ke),t)}return t.prototype.execute=function(t,e){return i(this,void 0,void 0,(function(){return s(this,(function(r){return[2,this.genericMDSLayout(!1,t,e)]}))}))},t.prototype.assign=function(t,e){return i(this,void 0,void 0,(function(){return s(this,(function(r){return this.genericMDSLayout(!0,t,e),[2]}))}))},t.prototype.genericMDSLayout=function(t,r,n){return i(this,void 0,void 0,(function(){var o,i,a,u,h,c,l,f,d,g,p,y;return s(this,(function(s){return o=e(e({},this.options),n),i=o.center,a=void 0===i?[0,0]:i,u=o.linkDistance,h=void 0===u?50:u,c=r.getAllNodes(),l=r.getAllEdges(),(null==c?void 0:c.length)&&1!==c.length?(f=v({nodes:c,edges:l},!1),d=w(f),Ye(d),g=x(d,h),p=Xe(g),y=[],p.forEach((function(t,e){var r=D(c[e]);r.data.x=t[0]+a[0],r.data.y=t[1]+a[1],y.push(r)})),t&&y.forEach((function(t){return r.mergeNodeData(t.id,{x:t.data.x,y:t.data.y})})),[2,{nodes:y,edges:l}]):[2,P(r,t,a)]}))}))},t}(),Ye=function(t){var e=-999999;t.forEach((function(t){t.forEach((function(t){t!==1/0&&e<t&&(e=t)}))})),t.forEach((function(r,n){r.forEach((function(r,o){r===1/0&&(t[n][o]=e)}))}))},Xe=function(t){var e=Ge.mul(Ge.pow(t,2),-.5),r=e.mean("row"),n=e.mean("column"),o=e.mean();e.add(o).subRowVector(r).subColumnVector(n);var i=new He(e),s=Ge.sqrt(i.diagonalMatrix).diagonal();return i.leftSingularVectors.toJSON().map((function(t){return Ge.mul([t],[s]).toJSON()[0].splice(0,2)}))},Ze={iterations:10,height:10,width:10,speed:100,gravity:10,k:5},Qe=function(t,e,r,n,o,i){e.forEach((function(s,a){r[a]={x:0,y:0},e.forEach((function(e,u){if(a!==u&&o[a]===o[u]){var h=s.x-e.x,c=s.y-e.y,l=Math.sqrt(h*h+c*c);if(0===l){l=1;var f=a>u?1:-1;h=.01*f,c=.01*f}if(l<i(t[a])/2+i(t[u])/2){var d=n*n/l;r[a].x+=h/l*d,r[a].y+=c/l*d}}}))}))},tr=function(t,e,r,n,o,i,s,a){var u=i||s/10;return n&&e.forEach((function(e,r){var n=t[r].x-t[o].x,i=t[r].y-t[o].y,s=Math.sqrt(n*n+i*i),a=i/s,u=-n/s,h=Math.sqrt(e.x*e.x+e.y*e.y),c=Math.acos((a*e.x+u*e.y)/h);c>Math.PI/2&&(c-=Math.PI/2,a*=-1,u*=-1);var l=Math.cos(c)*h;e.x=a*l,e.y=u*l})),t.forEach((function(i,s){if(s!==o){var h=Math.sqrt(e[s].x*e[s].x+e[s].y*e[s].y);if(h>0&&s!==o){var c=Math.min(u*(r/800),h);if(i.x+=e[s].x/h*c,i.y+=e[s].y/h*c,n){var l=i.x-t[o].x,f=i.y-t[o].y,d=Math.sqrt(l*l+f*f);l=l/d*a[s],f=f/d*a[s],i.x=t[o].x+l,i.y=t[o].y+f}}}})),t},er={maxIteration:1e3,focusNode:null,unitRadius:null,linkDistance:50,preventOverlap:!1,strictRadial:!0,maxPreventOverlapIteration:200,sortStrength:10},rr=function(){function t(t){void 0===t&&(t={}),this.options=t,this.id="radial",this.options=e(e({},er),t)}return t.prototype.execute=function(t,e){return i(this,void 0,void 0,(function(){return s(this,(function(r){return[2,this.genericRadialLayout(!1,t,e)]}))}))},t.prototype.assign=function(t,e){return i(this,void 0,void 0,(function(){return s(this,(function(r){return this.genericRadialLayout(!0,t,e),[2]}))}))},t.prototype.genericRadialLayout=function(t,r,n){return i(this,void 0,void 0,(function(){var o,i,h,c,l,f,d,g,p,y,m,x,M,b,E,N,S,A,k,I,_,R,T,z,O,C,q,L,F,j,V,W,$,G,U,H,K,J,Y,X,Z,Q,tt;return s(this,(function(s){if(o=e(e({},this.options),n),i=o.width,h=o.height,c=o.center,l=o.focusNode,f=o.unitRadius,d=o.nodeSize,g=o.nodeSpacing,p=o.strictRadial,y=o.preventOverlap,m=o.maxPreventOverlapIteration,x=o.sortBy,M=o.linkDistance,b=void 0===M?50:M,E=o.sortStrength,N=void 0===E?10:E,S=o.maxIteration,A=void 0===S?1e3:S,k=r.getAllNodes(),I=r.getAllEdges(),_=i||"undefined"==typeof window?i:window.innerWidth,R=h||"undefined"==typeof window?h:window.innerHeight,T=c||[_/2,R/2],!(null==k?void 0:k.length)||1===k.length)return[2,P(r,t,T)];if(z=k[0],B(l)){for(O=0;O<k.length;O++)if(k[O].id===l){z=k[O];break}}else z=l||k[0];return C=ir(k,z.id),q=v({nodes:k,edges:I},!1),L=w(q),F=ar(L,C),sr(L,C,F+1),j=L[C],V=_-T[0]>T[0]?T[0]:_-T[0],W=R-T[1]>T[1]?T[1]:R-T[1],0===V&&(V=_/2),0===W&&(W=R/2),$=Math.min(V,W),G=Math.max.apply(Math,u([],a(j),!1)),U=[],H=f||$/G,j.forEach((function(t,e){U[e]=t*H})),K=nr(k,L,b,U,H,x,N),J=or(K),Y=function(t,e,r){try{var n=Ge.mul(Ge.pow(e,2),-.5),o=n.mean("row"),i=n.mean("column"),s=n.mean();n.add(s).subRowVector(o).subColumnVector(i);var a=new He(n),u=Ge.sqrt(a.diagonalMatrix).diagonal();return a.leftSingularVectors.toJSON().map((function(e){return Ge.mul([e],[u]).toJSON()[0].splice(0,t)}))}catch(t){for(var h=[],c=0;c<e.length;c++){var l=Math.random()*r,f=Math.random()*r;h.push([l,f])}return h}}(b,K,b),X=Y.map((function(t){var e=a(t,2),r=e[0],n=e[1];return{x:(isNaN(r)?Math.random()*b:r)-Y[C][0],y:(isNaN(n)?Math.random()*b:n)-Y[C][1]}})),this.run(A,X,J,K,U,C),y&&(Z=ur(d,g),Q={nodes:k,nodeSizeFunc:Z,positions:X,radii:U,height:R,width:_,strictRadial:Boolean(p),focusIdx:C,iterations:m||200,k:X.length/4.5},X=function(t,r){for(var n=e(e({},Ze),r),o=n.positions,i=n.iterations,s=n.width,a=n.k,u=n.speed,h=void 0===u?100:u,c=n.strictRadial,l=n.focusIdx,f=n.radii,d=void 0===f?[]:f,g=n.nodeSizeFunc,p=t.getAllNodes(),y=[],m=s/10,w=0;w<i;w++)o.forEach((function(t,e){y[e]={x:0,y:0}})),Qe(p,o,y,a,d,g),tr(o,y,h,c,l,m,s,d);return o}(r,Q)),tt=[],X.forEach((function(t,e){var r=D(k[e]);r.data.x=t.x+T[0],r.data.y=t.y+T[1],tt.push(r)})),t&&tt.forEach((function(t){return r.mergeNodeData(t.id,{x:t.data.x,y:t.data.y})})),[2,{nodes:tt,edges:I}]}))}))},t.prototype.run=function(t,e,r,n,o,i){for(var s=0;s<=t;s++){var a=s/t;this.oneIteration(a,e,o,n,r,i)}},t.prototype.oneIteration=function(t,e,r,n,o,i){var s=1-t;e.forEach((function(a,u){var h=I(a,{x:0,y:0}),c=0===h?0:1/h;if(u!==i){var l=0,f=0,d=0;e.forEach((function(t,e){if(u!==e){var r=I(a,t),i=0===r?0:1/r,s=n[e][u];d+=o[u][e],l+=o[u][e]*(t.x+s*(a.x-t.x)*i),f+=o[u][e]*(t.y+s*(a.y-t.y)*i)}}));var g=0===r[u]?0:1/r[u];d*=s,d+=t*g*g,l*=s,l+=t*g*a.x*c,a.x=l/d,f*=s,f+=t*g*a.y*c,a.y=f/d}}))},t}(),nr=function(t,e,r,n,o,i,s){if(!t)return[];var a=[];if(e){var u={};e.forEach((function(e,h){var c=[];e.forEach((function(e,a){var l,f;if(h===a)c.push(0);else if(n[h]===n[a])if("data"===i)c.push(e*(Math.abs(h-a)*s)/(n[h]/o));else if(i){var d=void 0,g=void 0;if(u[t[h].id])d=u[t[h].id];else{var p=("id"===i?t[h].id:null===(l=t[h].data)||void 0===l?void 0:l[i])||0;d=B(p)?p.charCodeAt(0):p,u[t[h].id]=d}u[t[a].id]?g=u[t[a].id]:(p=("id"===i?t[a].id:null===(f=t[a].data)||void 0===f?void 0:f[i])||0,g=B(p)?p.charCodeAt(0):p,u[t[a].id]=g),c.push(e*(Math.abs(d-g)*s)/(n[h]/o))}else c.push(e*r/(n[h]/o));else{var y=(r+o)/2;c.push(e*y)}})),a.push(c)}))}return a},or=function(t){for(var e=t.length,r=t[0].length,n=[],o=0;o<e;o++){for(var i=[],s=0;s<r;s++)0!==t[o][s]?i.push(1/(t[o][s]*t[o][s])):i.push(0);n.push(i)}return n},ir=function(t,e){var r=-1;return t.forEach((function(t,n){t.id===e&&(r=n)})),Math.max(r,0)},sr=function(t,e,r){for(var n=t.length,o=0;o<n;o++)if(t[e][o]===1/0){t[e][o]=r,t[o][e]=r;for(var i=0;i<n;i++)t[o][i]!==1/0&&t[e][i]===1/0&&(t[e][i]=r+t[o][i],t[i][e]=r+t[o][i])}for(o=0;o<n;o++)if(o!==e)for(i=0;i<n;i++)if(t[o][i]===1/0){var s=Math.abs(t[e][o]-t[e][i]);s=0===s?1:s,t[o][i]=s}},ar=function(t,e){for(var r=0,n=0;n<t[e].length;n++)t[e][n]!==1/0&&(r=t[e][n]>r?t[e][n]:r);return r},ur=function(t,e){var r;return r=m(e)?function(){return e}:R(e)?e:function(){return 0},t?d(t)?function(e){return(t[0]>t[1]?t[0]:t[1])+r(e)}:function(e){return t+r(e)}:function(t){var e,n;if(null===(e=t.data)||void 0===e?void 0:e.bboxSize)return Math.max(t.data.bboxSize[0],t.data.bboxSize[1])+r(t);if(null===(n=t.data)||void 0===n?void 0:n.size){if(d(t.data.size))return Math.max(t.data.size[0],t.data.size[1])+r(t);var o=t.data.size;return T(o)?(o.width>o.height?o.width:o.height)+r(t):o+r(t)}return 10+r(t)}},hr={center:[0,0],width:300,height:300},cr=function(){function t(t){void 0===t&&(t={}),this.options=t,this.id="random",this.options=e(e({},hr),t)}return t.prototype.execute=function(t,e){return i(this,void 0,void 0,(function(){return s(this,(function(r){return[2,this.genericRandomLayout(!1,t,e)]}))}))},t.prototype.assign=function(t,e){return i(this,void 0,void 0,(function(){return s(this,(function(r){return this.genericRandomLayout(!0,t,e),[2]}))}))},t.prototype.genericRandomLayout=function(t,r,n){return i(this,void 0,void 0,(function(){var o,i,a,u,h,c,l,f,d;return s(this,(function(s){return o=e(e({},this.options),n),i=o.center,a=o.width,u=o.height,h=r.getAllNodes(),c=a||"undefined"==typeof window?a:window.innerWidth,l=u||"undefined"==typeof window?u:window.innerHeight,f=i||[c/2,l/2],d=[],h&&h.forEach((function(t){d.push({id:t.id,data:{x:.9*(Math.random()-.5)*c+f[0],y:.9*(Math.random()-.5)*l+f[1]}})})),t&&d.forEach((function(t){return r.mergeNodeData(t.id,{x:t.data.x,y:t.data.y})})),[2,{nodes:d,edges:r.getAllEdges()}]}))}))},t}(),lr={circular:q,concentric:H,mds:Je,random:cr,grid:ve,radial:rr,force:oe,d3force:Ht,fruchterman:me,forceAtlas2:pe};function fr(t,e){lr[t]=e}function dr(t){return!!t.tick&&!!t.stop}})();var o=n.SB,i=n.W1,s=n.jA,a=n.E9,u=n.y7,h=n.O2,c=n.Me,l=n.AI,f=n.D4,d=n._5,g=n.y9,p=n._A,y=n.d9,m=n.ul,w=n.qs,v=n.jE,x=n.tO,M=n.zJ,b=n.h$,E=n.BI,N=n.$y,S=n.H0,A=n.kJ,k=n.hY,I=n.qR,_=n.i_,D=n.nu,R=n.He,T=n.A3;export{o as CircularLayout,i as ConcentricLayout,s as D3ForceLayout,a as ForceAtlas2Layout,u as ForceLayout,h as FruchtermanLayout,c as GridLayout,l as MDSLayout,f as RadialLayout,d as RandomLayout,g as Supervisor,p as camelize,y as clone,m as cloneFormatData,w as floydWarshall,v as formatNumberFn,x as formatSizeFn,M as getAdjMatrix,b as getAvgNodePosition,E as getCoreNodeAndRelativeLeafNodes,N as getEuclideanDistance,S as getLayoutBBox,A as isArray,k as isLayoutWithIterations,I as registerLayout,_ as registry,D as scaleMatrix,R as toNumber,T as traverseTreeUp};
|
|
1
|
+
var t={161:t=>{var e=Object.prototype.hasOwnProperty,r="~";function n(){}function o(t,e,r){this.fn=t,this.context=e,this.once=r||!1}function i(t,e,n,i,a){if("function"!=typeof n)throw new TypeError("The listener must be a function");var s=new o(n,i||t,a),u=r?r+e:e;return t._events[u]?t._events[u].fn?t._events[u]=[t._events[u],s]:t._events[u].push(s):(t._events[u]=s,t._eventsCount++),t}function a(t,e){0==--t._eventsCount?t._events=new n:delete t._events[e]}function s(){this._events=new n,this._eventsCount=0}Object.create&&(n.prototype=Object.create(null),(new n).__proto__||(r=!1)),s.prototype.eventNames=function(){var t,n,o=[];if(0===this._eventsCount)return o;for(n in t=this._events)e.call(t,n)&&o.push(r?n.slice(1):n);return Object.getOwnPropertySymbols?o.concat(Object.getOwnPropertySymbols(t)):o},s.prototype.listeners=function(t){var e=r?r+t:t,n=this._events[e];if(!n)return[];if(n.fn)return[n.fn];for(var o=0,i=n.length,a=new Array(i);o<i;o++)a[o]=n[o].fn;return a},s.prototype.listenerCount=function(t){var e=r?r+t:t,n=this._events[e];return n?n.fn?1:n.length:0},s.prototype.emit=function(t,e,n,o,i,a){var s=r?r+t:t;if(!this._events[s])return!1;var u,d,h=this._events[s],c=arguments.length;if(h.fn){switch(h.once&&this.removeListener(t,h.fn,void 0,!0),c){case 1:return h.fn.call(h.context),!0;case 2:return h.fn.call(h.context,e),!0;case 3:return h.fn.call(h.context,e,n),!0;case 4:return h.fn.call(h.context,e,n,o),!0;case 5:return h.fn.call(h.context,e,n,o,i),!0;case 6:return h.fn.call(h.context,e,n,o,i,a),!0}for(d=1,u=new Array(c-1);d<c;d++)u[d-1]=arguments[d];h.fn.apply(h.context,u)}else{var l,f=h.length;for(d=0;d<f;d++)switch(h[d].once&&this.removeListener(t,h[d].fn,void 0,!0),c){case 1:h[d].fn.call(h[d].context);break;case 2:h[d].fn.call(h[d].context,e);break;case 3:h[d].fn.call(h[d].context,e,n);break;case 4:h[d].fn.call(h[d].context,e,n,o);break;default:if(!u)for(l=1,u=new Array(c-1);l<c;l++)u[l-1]=arguments[l];h[d].fn.apply(h[d].context,u)}}return!0},s.prototype.on=function(t,e,r){return i(this,t,e,r,!1)},s.prototype.once=function(t,e,r){return i(this,t,e,r,!0)},s.prototype.removeListener=function(t,e,n,o){var i=r?r+t:t;if(!this._events[i])return this;if(!e)return a(this,i),this;var s=this._events[i];if(s.fn)s.fn!==e||o&&!s.once||n&&s.context!==n||a(this,i);else{for(var u=0,d=[],h=s.length;u<h;u++)(s[u].fn!==e||o&&!s[u].once||n&&s[u].context!==n)&&d.push(s[u]);d.length?this._events[i]=1===d.length?d[0]:d:a(this,i)}return this},s.prototype.removeAllListeners=function(t){var e;return t?(e=r?r+t:t,this._events[e]&&a(this,e)):(this._events=new n,this._eventsCount=0),this},s.prototype.off=s.prototype.removeListener,s.prototype.addListener=s.prototype.on,s.prefixed=r,s.EventEmitter=s,t.exports=s},825:(t,e,r)=>{var n=r(475),o=["stopLayout","calculateLayout"];t.exports=function(){var t=new Worker(URL.createObjectURL(new Blob(['var t={d:(e,r)=>{for(var n in r)t.o(r,n)&&!t.o(e,n)&&Object.defineProperty(e,n,{enumerable:!0,get:r[n]})},o:(t,e)=>Object.prototype.hasOwnProperty.call(t,e)},e={};t.d(e,{calculateLayout:()=>Dn,stopLayout:()=>_n});var r=function(t,e){return r=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(t,e){t.__proto__=e}||function(t,e){for(var r in e)Object.prototype.hasOwnProperty.call(e,r)&&(t[r]=e[r])},r(t,e)},n=function(){return n=Object.assign||function(t){for(var e,r=1,n=arguments.length;r<n;r++)for(var o in e=arguments[r])Object.prototype.hasOwnProperty.call(e,o)&&(t[o]=e[o]);return t},n.apply(this,arguments)};function o(t,e){var r={};for(var n in t)Object.prototype.hasOwnProperty.call(t,n)&&e.indexOf(n)<0&&(r[n]=t[n]);if(null!=t&&"function"==typeof Object.getOwnPropertySymbols){var o=0;for(n=Object.getOwnPropertySymbols(t);o<n.length;o++)e.indexOf(n[o])<0&&Object.prototype.propertyIsEnumerable.call(t,n[o])&&(r[n[o]]=t[n[o]])}return r}function i(t,e,r,n){return new(r||(r=Promise))((function(o,i){function a(t){try{u(n.next(t))}catch(t){i(t)}}function s(t){try{u(n.throw(t))}catch(t){i(t)}}function u(t){var e;t.done?o(t.value):(e=t.value,e instanceof r?e:new r((function(t){t(e)}))).then(a,s)}u((n=n.apply(t,e||[])).next())}))}function a(t,e){var r,n,o,i,a={label:0,sent:function(){if(1&o[0])throw o[1];return o[1]},trys:[],ops:[]};return i={next:s(0),throw:s(1),return:s(2)},"function"==typeof Symbol&&(i[Symbol.iterator]=function(){return this}),i;function s(s){return function(u){return function(s){if(r)throw new TypeError("Generator is already executing.");for(;i&&(i=0,s[0]&&(a=0)),a;)try{if(r=1,n&&(o=2&s[0]?n.return:s[0]?n.throw||((o=n.return)&&o.call(n),0):n.next)&&!(o=o.call(n,s[1])).done)return o;switch(n=0,o&&(s=[2&s[0],o.value]),s[0]){case 0:case 1:o=s;break;case 4:return a.label++,{value:s[1],done:!1};case 5:a.label++,n=s[1],s=[0];continue;case 7:s=a.ops.pop(),a.trys.pop();continue;default:if(!((o=(o=a.trys).length>0&&o[o.length-1])||6!==s[0]&&2!==s[0])){a=0;continue}if(3===s[0]&&(!o||s[1]>o[0]&&s[1]<o[3])){a.label=s[1];break}if(6===s[0]&&a.label<o[1]){a.label=o[1],o=s;break}if(o&&a.label<o[2]){a.label=o[2],a.ops.push(s);break}o[2]&&a.ops.pop(),a.trys.pop();continue}s=e.call(t,a)}catch(t){s=[6,t],n=0}finally{r=o=0}if(5&s[0])throw s[1];return{value:s[0]?s[1]:void 0,done:!0}}([s,u])}}}function s(t,e){var r="function"==typeof Symbol&&t[Symbol.iterator];if(!r)return t;var n,o,i=r.call(t),a=[];try{for(;(void 0===e||e-- >0)&&!(n=i.next()).done;)a.push(n.value)}catch(t){o={error:t}}finally{try{n&&!n.done&&(r=i.return)&&r.call(i)}finally{if(o)throw o.error}}return a}function u(t,e,r){if(r||2===arguments.length)for(var n,o=0,i=e.length;o<i;o++)!n&&o in e||(n||(n=Array.prototype.slice.call(e,0,o)),n[o]=e[o]);return t.concat(n||Array.prototype.slice.call(e))}Object.create,Object.create;var d="*";const h=function(){function t(){this._events={}}return t.prototype.on=function(t,e,r){return this._events[t]||(this._events[t]=[]),this._events[t].push({callback:e,once:!!r}),this},t.prototype.once=function(t,e){return this.on(t,e,!0)},t.prototype.emit=function(t){for(var e=this,r=[],n=1;n<arguments.length;n++)r[n-1]=arguments[n];var o=this._events[t]||[],i=this._events[d]||[],a=function(n){for(var o=n.length,i=0;i<o;i++)if(n[i]){var a=n[i],s=a.callback;a.once&&(n.splice(i,1),0===n.length&&delete e._events[t],o--,i--),s.apply(e,r)}};a(o),a(i)},t.prototype.off=function(t,e){if(t)if(e){for(var r=this._events[t]||[],n=r.length,o=0;o<n;o++)r[o].callback===e&&(r.splice(o,1),n--,o--);0===r.length&&delete this._events[t]}else delete this._events[t];else this._events={};return this},t.prototype.getEvents=function(){return this._events},t}();function c(t,e,r,n){for(;t.length;){const o=t.shift();if(r(o))return!0;e.add(o.id),n(o.id).forEach((r=>{e.has(r.id)||(e.add(r.id),t.push(r))}))}return!1}function l(t,e,r,n){if(r(t))return!0;e.add(t.id);for(const o of n(t.id))if(!e.has(o.id)&&l(o,e,r,n))return!0;return!1}class f extends h{nodeMap=new Map;edgeMap=new Map;inEdgesMap=new Map;outEdgesMap=new Map;bothEdgesMap=new Map;treeIndices=new Map;changes=[];batchCount=0;onChanged=()=>{};constructor(t){super(),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))}batch=t=>{this.batchCount+=1,t(),this.batchCount-=1,this.batchCount||this.commit()};commit(){const t=this.changes;this.changes=[];const e={graph:this,changes:t};this.emit("changed",e),this.onChanged(e)}reduceChanges(t){let e=[];return t.forEach((t=>{switch(t.type){case"NodeRemoved":{let r=!1;e=e.filter((e=>{if("NodeAdded"===e.type){const n=e.value.id===t.value.id;return n&&(r=!0),!n}return"NodeDataUpdated"===e.type?e.id!==t.value.id:"TreeStructureChanged"!==e.type||e.nodeId!==t.value.id})),r||e.push(t);break}case"EdgeRemoved":{let r=!1;e=e.filter((e=>{if("EdgeAdded"===e.type){const n=e.value.id===t.value.id;return n&&(r=!0),!n}return"EdgeDataUpdated"!==e.type&&"EdgeUpdated"!==e.type||e.id!==t.value.id})),r||e.push(t);break}case"NodeDataUpdated":case"EdgeDataUpdated":case"EdgeUpdated":{const r=e.find((e=>e.type===t.type&&e.id===t.id&&e.propertyName===t.propertyName));r?r.newValue=t.newValue:e.push(t);break}case"TreeStructureDetached":e=e.filter((e=>"TreeStructureAttached"===e.type?e.treeKey!==t.treeKey:"TreeStructureChanged"!==e.type||e.treeKey!==t.treeKey)),e.push(t);break;case"TreeStructureChanged":{const r=e.find((e=>"TreeStructureChanged"===e.type&&e.treeKey===t.treeKey&&e.nodeId===t.nodeId));r?r.newParentId=t.newParentId:e.push(t);break}default:e.push(t)}})),e}checkNodeExistence(t){this.getNode(t)}hasNode(t){return this.nodeMap.has(t)}areNeighbors(t,e){return this.getNeighbors(e).some((e=>e.id===t))}getNode(t){const e=this.nodeMap.get(t);if(!e)throw new Error("Node not found for id: "+t);return e}getRelatedEdges(t,e){if(this.checkNodeExistence(t),"in"===e){const e=this.inEdgesMap.get(t);return Array.from(e)}if("out"===e){const e=this.outEdgesMap.get(t);return Array.from(e)}{const e=this.bothEdgesMap.get(t);return Array.from(e)}}getDegree(t,e){return this.getRelatedEdges(t,e).length}getSuccessors(t){const e=this.getRelatedEdges(t,"out").map((t=>this.getNode(t.target)));return Array.from(new Set(e))}getPredecessors(t){const e=this.getRelatedEdges(t,"in").map((t=>this.getNode(t.source)));return Array.from(new Set(e))}getNeighbors(t){const e=this.getPredecessors(t),r=this.getSuccessors(t);return Array.from(new Set([...e,...r]))}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((e=>{e.childrenMap.set(t.id,new Set)})),this.changes.push({type:"NodeAdded",value:t})}addNodes(t){this.batch((()=>{for(const e of t)this.doAddNode(e)}))}addNode(t){this.addNodes([t])}doRemoveNode(t){const e=this.getNode(t);this.bothEdgesMap.get(t)?.forEach((t=>this.doRemoveEdge(t.id))),this.nodeMap.delete(t),this.treeIndices.forEach((e=>{e.childrenMap.get(t)?.forEach((t=>{e.parentMap.delete(t.id)})),e.parentMap.delete(t),e.childrenMap.delete(t)})),this.changes.push({type:"NodeRemoved",value:e})}removeNodes(t){this.batch((()=>{t.forEach((t=>this.doRemoveNode(t)))}))}removeNode(t){this.removeNodes([t])}updateNodeDataProperty(t,e,r){const n=this.getNode(t);this.batch((()=>{const o=n.data[e],i=r;n.data[e]=i,this.changes.push({type:"NodeDataUpdated",id:t,propertyName:e,oldValue:o,newValue:i})}))}mergeNodeData(t,e){this.batch((()=>{Object.entries(e).forEach((([e,r])=>{this.updateNodeDataProperty(t,e,r)}))}))}updateNodeData(...t){const e=t[0],r=this.getNode(e);if("string"==typeof t[1])return void this.updateNodeDataProperty(e,t[1],t[2]);let n;if("function"==typeof t[1]){const e=t[1];n=e(r.data)}else"object"==typeof t[1]&&(n=t[1]);this.batch((()=>{const t=r.data,o=n;r.data=n,this.changes.push({type:"NodeDataUpdated",id:e,oldValue:t,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 e=this.getEdge(t);return{edge:e,source:this.getNode(e.source),target:this.getNode(e.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 e=this.inEdgesMap.get(t.target),r=this.outEdgesMap.get(t.source),n=this.bothEdgesMap.get(t.source),o=this.bothEdgesMap.get(t.target);e.add(t),r.add(t),n.add(t),o.add(t),this.changes.push({type:"EdgeAdded",value:t})}addEdges(t){this.batch((()=>{for(const e of t)this.doAddEdge(e)}))}addEdge(t){this.addEdges([t])}doRemoveEdge(t){const e=this.getEdge(t),r=this.outEdgesMap.get(e.source),n=this.inEdgesMap.get(e.target),o=this.bothEdgesMap.get(e.source),i=this.bothEdgesMap.get(e.target);r.delete(e),n.delete(e),o.delete(e),i.delete(e),this.edgeMap.delete(t),this.changes.push({type:"EdgeRemoved",value:e})}removeEdges(t){this.batch((()=>{t.forEach((t=>this.doRemoveEdge(t)))}))}removeEdge(t){this.removeEdges([t])}updateEdgeSource(t,e){const r=this.getEdge(t);this.checkNodeExistence(e);const n=r.source,o=e;this.outEdgesMap.get(n).delete(r),this.bothEdgesMap.get(n).delete(r),this.outEdgesMap.get(o).add(r),this.bothEdgesMap.get(o).add(r),r.source=e,this.batch((()=>{this.changes.push({type:"EdgeUpdated",id:t,propertyName:"source",oldValue:n,newValue:o})}))}updateEdgeTarget(t,e){const r=this.getEdge(t);this.checkNodeExistence(e);const n=r.target,o=e;this.inEdgesMap.get(n).delete(r),this.bothEdgesMap.get(n).delete(r),this.inEdgesMap.get(o).add(r),this.bothEdgesMap.get(o).add(r),r.target=e,this.batch((()=>{this.changes.push({type:"EdgeUpdated",id:t,propertyName:"target",oldValue:n,newValue:o})}))}updateEdgeDataProperty(t,e,r){const n=this.getEdge(t);this.batch((()=>{const o=n.data[e],i=r;n.data[e]=i,this.changes.push({type:"EdgeDataUpdated",id:t,propertyName:e,oldValue:o,newValue:i})}))}updateEdgeData(...t){const e=t[0],r=this.getEdge(e);if("string"==typeof t[1])return void this.updateEdgeDataProperty(e,t[1],t[2]);let n;if("function"==typeof t[1]){const e=t[1];n=e(r.data)}else"object"==typeof t[1]&&(n=t[1]);this.batch((()=>{const t=r.data,o=n;r.data=n,this.changes.push({type:"EdgeDataUpdated",id:e,oldValue:t,newValue:o})}))}mergeEdgeData(t,e){this.batch((()=>{Object.entries(e).forEach((([e,r])=>{this.updateEdgeDataProperty(t,e,r)}))}))}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,e){this.batch((()=>{this.attachTreeStructure(e);const r=[],n=Array.isArray(t)?t:[t];for(;n.length;){const t=n.shift();r.push(t),t.children&&n.push(...t.children)}this.addNodes(r),r.forEach((t=>{t.children?.forEach((r=>{this.setParent(r.id,t.id,e)}))}))}))}getRoots(t){return this.checkTreeExistence(t),this.getAllNodes().filter((e=>!this.getParent(e.id,t)))}getChildren(t,e){this.checkNodeExistence(t),this.checkTreeExistence(e);const r=this.treeIndices.get(e).childrenMap.get(t);return Array.from(r||[])}getParent(t,e){return this.checkNodeExistence(t),this.checkTreeExistence(e),this.treeIndices.get(e).parentMap.get(t)||null}getAncestors(t,e){const r=[];let n,o=this.getNode(t);for(;n=this.getParent(o.id,e);)r.push(n),o=n;return r}setParent(t,e,r){this.checkTreeExistence(r);const n=this.treeIndices.get(r),o=this.getNode(t),i=n.parentMap.get(t),a=this.getNode(e);n.parentMap.set(t,a),i&&n.childrenMap.get(i.id)?.delete(o);let s=n.childrenMap.get(a.id);s||(s=new Set,n.childrenMap.set(a.id,s)),s.add(o),this.batch((()=>{this.changes.push({type:"TreeStructureChanged",treeKey:r,nodeId:t,oldParentId:i?.id,newParentId:a.id})}))}dfsTree(t,e,r){return l(this.getNode(t),new Set,e,(t=>this.getChildren(t,r)))}bfsTree(t,e,r){return c([this.getNode(t)],new Set,e,(t=>this.getChildren(t,r)))}getAllNodes(){return Array.from(this.nodeMap.values())}getAllEdges(){return Array.from(this.edgeMap.values())}bfs(t,e,r="out"){const n={in:this.getPredecessors.bind(this),out:this.getSuccessors.bind(this),both:this.getNeighbors.bind(this)}[r];return c([this.getNode(t)],new Set,e,n)}dfs(t,e,r="out"){const n={in:this.getPredecessors.bind(this),out:this.getSuccessors.bind(this),both:this.getNeighbors.bind(this)}[r];return l(this.getNode(t),new Set,e,n)}clone(){const t=this.getAllNodes().map((t=>({...t,data:{...t.data}}))),e=this.getAllEdges().map((t=>({...t,data:{...t.data}}))),r=new f({nodes:t,edges:e});return this.treeIndices.forEach((({parentMap:t,childrenMap:e},n)=>{const o=new Map;t.forEach(((t,e)=>{o.set(e,r.getNode(t.id))}));const i=new Map;e.forEach(((t,e)=>{i.set(e,new Set(Array.from(t).map((t=>r.getNode(t.id)))))})),r.treeIndices.set(n,{parentMap:o,childrenMap:i})})),r}toJSON(){return JSON.stringify({nodes:this.getAllNodes(),edges:this.getAllEdges()})}}var g=/-(\\w)/g,p=(function(t){return t.replace(g,(function(t,e){return e?e.toUpperCase():""}))},Object.create(null),Array.isArray),v=function(t){for(var e=[],r=t.length,n=0;n<r;n+=1){e[n]=[];for(var o=0;o<r;o+=1)n===o?e[n][o]=0:0!==t[n][o]&&t[n][o]?e[n][o]=t[n][o]:e[n][o]=1/0}for(var i=0;i<r;i+=1)for(n=0;n<r;n+=1)for(o=0;o<r;o+=1)e[n][o]>e[n][i]+e[i][o]&&(e[n][o]=e[n][i]+e[i][o]);return e},y=function(t,e){var r=t.nodes,n=t.edges,o=[],i={};if(!r)throw new Error("invalid nodes data!");return r&&r.forEach((function(t,e){i[t.id]=e,o.push([])})),null==n||n.forEach((function(t){var r=t.source,n=t.target,a=i[r],s=i[n];void 0!==a&&void 0!==s&&(o[a][s]=1,e||(o[s][a]=1))})),o},m=function(t,e){return Math.sqrt((t.x-e.x)*(t.x-e.x)+(t.y-e.y)*(t.y-e.y))},w={}.toString;const x=function(t,e){return w.call(t)==="[object "+e+"]"},E=function(t){return x(t,"Number")};var b=function(t){if(null===t)return t;if(t instanceof Date)return new Date(t.getTime());if(t instanceof Array){var e=[];return t.forEach((function(t){e.push(t)})),e.map((function(t){return b(t)}))}if("object"==typeof t){var r={};return Object.keys(t).forEach((function(e){r[e]=b(t[e])})),r}return t},N=function(t,e){var r=b(t);return r.data=r.data||{},e&&(E(r.data.x)||(r.data.x=Math.random()*e[0]),E(r.data.y)||(r.data.y=Math.random()*e[1])),r};const M=function(t){return"function"==typeof t},S=function(t){var e=typeof t;return null!==t&&"object"===e||"function"===e};function k(t,e){return M(e)?e:E(e)?function(){return e}:function(){return t}}function A(t,e,r){return void 0===r&&(r=!0),e||0===e?M(e)?e:E(e)?function(){return e}:p(e)?function(){if(r){var n=Math.max.apply(Math,u([],s(e),!1));return isNaN(n)?t:n}return e}:S(e)?function(){if(r){var n=Math.max(e.width,e.height);return isNaN(n)?t:n}return[e.width,e.height]}:function(){return t}:function(e){var r=(e.data||{}).size;return r?p(r)?r[0]>r[1]?r[0]:r[1]:S(r)?r.width>r.height?r.width:r.height:r:t}}var R=function(t,e){var r;return r=E(e)?function(){return e}:M(e)?e:function(){return 0},t?p(t)?function(e){return(t[0]>t[1]?t[0]:t[1])+r(e)}:function(e){return t+r(e)}:function(t){var e,n;if(null===(e=t.data)||void 0===e?void 0:e.bboxSize)return Math.max(t.data.bboxSize[0],t.data.bboxSize[1])+r(t);if(null===(n=t.data)||void 0===n?void 0:n.size){if(p(t.data.size))return Math.max(t.data.size[0],t.data.size[1])+r(t);var o=t.data.size;return S(o)?(o.width>o.height?o.width:o.height)+r(t):o+r(t)}return 10+r(t)}},I=function(t,e,r){var o=t.getAllNodes(),i=t.getAllEdges();return(null==o?void 0:o.length)?1===o.length?(e&&t.mergeNodeData(o[0].id,{x:r[0],y:r[1]}),{nodes:[n(n({},o[0]),{data:n(n({},o[0].data),{x:r[0],y:r[1]})})],edges:i}):void 0:{nodes:[],edges:i}},_={radius:null,startRadius:null,endRadius:null,startAngle:0,endAngle:2*Math.PI,clockwise:!0,divisions:1,ordering:null,angleRatio:1},D=function(){function t(t){void 0===t&&(t={}),this.options=t,this.id="circular",this.options=n(n({},_),t)}return t.prototype.execute=function(t,e){return i(this,void 0,void 0,(function(){return a(this,(function(r){return[2,this.genericCircularLayout(!1,t,e)]}))}))},t.prototype.assign=function(t,e){return i(this,void 0,void 0,(function(){return a(this,(function(r){switch(r.label){case 0:return[4,this.genericCircularLayout(!0,t,e)];case 1:return r.sent(),[2]}}))}))},t.prototype.genericCircularLayout=function(t,e,r){return i(this,void 0,void 0,(function(){var o,i,u,d,h,c,l,f,g,p,v,y,m,w,x,E,b,M,S,R,_,D,T,z,C,L,q,j,F,V,G,W,B,$,U;return a(this,(function(a){if(o=n(n({},this.options),r),i=o.width,u=o.height,d=o.center,h=o.divisions,c=o.startAngle,l=void 0===c?0:c,f=o.endAngle,g=void 0===f?2*Math.PI:f,p=o.angleRatio,v=o.ordering,y=o.clockwise,m=o.nodeSpacing,w=o.nodeSize,x=e.getAllNodes(),E=e.getAllEdges(),b=s(P(i,u,d),3),M=b[0],S=b[1],R=b[2],!(_=null==x?void 0:x.length)||1===_)return[2,I(e,t,R)];for(D=(g-l)/_,T=o.radius,z=o.startRadius,C=o.endRadius,m?(L=k(10,m),q=A(10,w),j=-1/0,x.forEach((function(t){var e=q(t);j<e&&(j=e)})),F=0,x.forEach((function(t,e){F+=0===e?j||10:(L(t)||0)+(j||10)})),T=F/(2*Math.PI)):T||z||C?!z&&C?z=C:z&&!C&&(C=z):T=Math.min(S,M)/2,V=D*p,G=[],G="topology"===v?O(e,x):"topology-directed"===v?O(e,x,!0):"degree"===v?function(t,e){var r=[];return e.forEach((function(t,e){r.push(N(t))})),r.sort((function(e,r){return t.getDegree(e.id,"both")-t.getDegree(r.id,"both")})),r}(e,x):x.map((function(t){return N(t)})),W=Math.ceil(_/h),B=0;B<_;++B)($=T)||null===z||null===C||($=z+B*(C-z)/(_-1)),$||($=10+100*B/(_-1)),U=l+B%W*V+2*Math.PI/h*Math.floor(B/W),y||(U=g-B%W*V-2*Math.PI/h*Math.floor(B/W)),G[B].data.x=R[0]+Math.cos(U)*$,G[B].data.y=R[1]+Math.sin(U)*$;return t&&G.forEach((function(t){e.mergeNodeData(t.id,{x:t.data.x,y:t.data.y})})),[2,{nodes:G,edges:E}]}))}))},t}(),O=function(t,e,r){void 0===r&&(r=!1);var n=[N(e[0])],o={},i=e.length;o[e[0].id]=!0;var a=0;return e.forEach((function(s,u){if(0!==u)if(u!==i-1&&t.getDegree(s.id,"both")===t.getDegree(e[u+1].id,"both")&&!t.areNeighbors(n[a].id,s.id)||o[s.id]){for(var d=r?t.getSuccessors(n[a].id):t.getNeighbors(n[a].id),h=!1,c=0;c<d.length;c++){var l=d[c];if(t.getDegree(l.id)===t.getDegree(s.id)&&!o[l.id]){n.push(N(l)),o[l.id]=!0,h=!0;break}}for(var f=0;!h&&(o[e[f].id]||(n.push(N(e[f])),o[e[f].id]=!0,h=!0),++f!==i););}else n.push(N(s)),o[s.id]=!0,a++})),n},P=function(t,e,r){var n=t,o=e,i=r;return n||"undefined"==typeof window||(n=window.innerWidth),o||"undefined"==typeof window||(o=window.innerHeight),i||(i=[n/2,o/2]),[n,o,i]};const T=function(t){return x(t,"String")};var z={nodeSize:30,nodeSpacing:10,preventOverlap:!1,sweep:void 0,equidistant:!1,startAngle:1.5*Math.PI,clockwise:!0,maxLevelDiff:void 0,sortBy:"degree"},C=function(){function t(t){void 0===t&&(t={}),this.options=t,this.id="concentric",this.options=n(n({},z),t)}return t.prototype.execute=function(t,e){return i(this,void 0,void 0,(function(){return a(this,(function(r){return[2,this.genericConcentricLayout(!1,t,e)]}))}))},t.prototype.assign=function(t,e){return i(this,void 0,void 0,(function(){return a(this,(function(r){return this.genericConcentricLayout(!0,t,e),[2]}))}))},t.prototype.genericConcentricLayout=function(t,e,r){return i(this,void 0,void 0,(function(){var o,i,s,u,d,h,c,l,f,g,v,y,m,w,x,b,k,A,R,_,D,O,P,z,C,L,q,j,F,V,G,W,B,$,U,H,K,Y;return a(this,(function(a){if(o=n(n({},this.options),r),i=o.center,s=o.width,u=o.height,d=o.sortBy,h=o.maxLevelDiff,c=o.sweep,l=o.clockwise,f=o.equidistant,g=o.preventOverlap,v=o.startAngle,y=void 0===v?1.5*Math.PI:v,m=o.nodeSize,w=o.nodeSpacing,x=e.getAllNodes(),b=e.getAllEdges(),k=s||"undefined"==typeof window?s:window.innerWidth,A=u||"undefined"==typeof window?u:window.innerHeight,R=i||[k/2,A/2],!(null==x?void 0:x.length)||1===x.length)return[2,I(e,t,R)];if(_=[],O=0,D=p(m)?Math.max(m[0],m[1]):m,p(w)?O=Math.max(w[0],w[1]):E(w)&&(O=w),x.forEach((function(t){var e=N(t);_.push(e);var r=D,n=e.data;p(n.size)?r=Math.max(n.size[0],n.size[1]):E(n.size)?r=n.size:S(n.size)&&(r=Math.max(n.size.width,n.size.height)),D=Math.max(D,r),M(w)&&(O=Math.max(w(t),O))})),P={},_.forEach((function(t,e){P[t.id]=e})),T(z=d)&&void 0!==_[0].data[z]||(z="degree"),"degree"===z?_.sort((function(t,r){return e.getDegree(r.id,"both")-e.getDegree(t.id,"both")})):_.sort((function(t,e){return e.data[z]-t.data[z]})),C=_[0],L=(h||("degree"===z?e.getDegree(C.id,"both"):C.data[z]))/4,j=(q=[{nodes:[]}])[0],_.forEach((function(t){if(j.nodes.length>0){var r="degree"===z?Math.abs(e.getDegree(j.nodes[0].id,"both")-e.getDegree(t.id,"both")):Math.abs(j.nodes[0].data[z]-t.data[z]);L&&r>=L&&(j={nodes:[]},q.push(j))}j.nodes.push(t)})),F=D+O,g||(V=q.length>0&&q[0].nodes.length>1,G=Math.min(k,A)/2-F,W=G/(q.length+(V?1:0)),F=Math.min(F,W)),B=0,q.forEach((function(t){var e=void 0===c?2*Math.PI-2*Math.PI/t.nodes.length:c;if(t.dTheta=e/Math.max(1,t.nodes.length-1),t.nodes.length>1&&g){var r=Math.cos(t.dTheta)-Math.cos(0),n=Math.sin(t.dTheta)-Math.sin(0),o=Math.sqrt(F*F/(r*r+n*n));B=Math.max(o,B)}t.r=B,B+=F})),f){for($=0,U=0,H=0;H<q.length;H++)K=q[H],Y=(K.r||0)-U,$=Math.max($,Y);U=0,q.forEach((function(t,e){0===e&&(U=t.r||0),t.r=U,U+=$}))}return q.forEach((function(t){var e=t.dTheta||0,r=t.r||0;t.nodes.forEach((function(t,n){var o=y+(l?1:-1)*e*n;t.data.x=R[0]+r*Math.cos(o),t.data.y=R[1]+r*Math.sin(o)}))})),t&&_.forEach((function(t){return e.mergeNodeData(t.id,{x:t.data.x,y:t.data.y})})),[2,{nodes:_,edges:b}]}))}))},t}();function L(t,e,r,n){if(isNaN(e)||isNaN(r))return t;var o,i,a,s,u,d,h,c,l,f=t._root,g={data:n},p=t._x0,v=t._y0,y=t._x1,m=t._y1;if(!f)return t._root=g,t;for(;f.length;)if((d=e>=(i=(p+y)/2))?p=i:y=i,(h=r>=(a=(v+m)/2))?v=a:m=a,o=f,!(f=f[c=h<<1|d]))return o[c]=g,t;if(s=+t._x.call(null,f.data),u=+t._y.call(null,f.data),e===s&&r===u)return g.next=f,o?o[c]=g:t._root=g,t;do{o=o?o[c]=new Array(4):t._root=new Array(4),(d=e>=(i=(p+y)/2))?p=i:y=i,(h=r>=(a=(v+m)/2))?v=a:m=a}while((c=h<<1|d)==(l=(u>=a)<<1|s>=i));return o[l]=f,o[c]=g,t}function q(t,e,r,n,o){this.node=t,this.x0=e,this.y0=r,this.x1=n,this.y1=o}function j(t){return t[0]}function F(t){return t[1]}function V(t,e,r){var n=new G(null==e?j:e,null==r?F:r,NaN,NaN,NaN,NaN);return null==t?n:n.addAll(t)}function G(t,e,r,n,o,i){this._x=t,this._y=e,this._x0=r,this._y0=n,this._x1=o,this._y1=i,this._root=void 0}function W(t){for(var e={data:t.data},r=e;t=t.next;)r=r.next={data:t.data};return e}var B=V.prototype=G.prototype;function $(t){return function(){return t}}function U(t){return 1e-6*(t()-.5)}B.copy=function(){var t,e,r=new G(this._x,this._y,this._x0,this._y0,this._x1,this._y1),n=this._root;if(!n)return r;if(!n.length)return r._root=W(n),r;for(t=[{source:n,target:r._root=new Array(4)}];n=t.pop();)for(var o=0;o<4;++o)(e=n.source[o])&&(e.length?t.push({source:e,target:n.target[o]=new Array(4)}):n.target[o]=W(e));return r},B.add=function(t){const e=+this._x.call(null,t),r=+this._y.call(null,t);return L(this.cover(e,r),e,r,t)},B.addAll=function(t){var e,r,n,o,i=t.length,a=new Array(i),s=new Array(i),u=1/0,d=1/0,h=-1/0,c=-1/0;for(r=0;r<i;++r)isNaN(n=+this._x.call(null,e=t[r]))||isNaN(o=+this._y.call(null,e))||(a[r]=n,s[r]=o,n<u&&(u=n),n>h&&(h=n),o<d&&(d=o),o>c&&(c=o));if(u>h||d>c)return this;for(this.cover(u,d).cover(h,c),r=0;r<i;++r)L(this,a[r],s[r],t[r]);return this},B.cover=function(t,e){if(isNaN(t=+t)||isNaN(e=+e))return this;var r=this._x0,n=this._y0,o=this._x1,i=this._y1;if(isNaN(r))o=(r=Math.floor(t))+1,i=(n=Math.floor(e))+1;else{for(var a,s,u=o-r||1,d=this._root;r>t||t>=o||n>e||e>=i;)switch(s=(e<n)<<1|t<r,(a=new Array(4))[s]=d,d=a,u*=2,s){case 0:o=r+u,i=n+u;break;case 1:r=o-u,i=n+u;break;case 2:o=r+u,n=i-u;break;case 3:r=o-u,n=i-u}this._root&&this._root.length&&(this._root=d)}return this._x0=r,this._y0=n,this._x1=o,this._y1=i,this},B.data=function(){var t=[];return this.visit((function(e){if(!e.length)do{t.push(e.data)}while(e=e.next)})),t},B.extent=function(t){return arguments.length?this.cover(+t[0][0],+t[0][1]).cover(+t[1][0],+t[1][1]):isNaN(this._x0)?void 0:[[this._x0,this._y0],[this._x1,this._y1]]},B.find=function(t,e,r){var n,o,i,a,s,u,d,h=this._x0,c=this._y0,l=this._x1,f=this._y1,g=[],p=this._root;for(p&&g.push(new q(p,h,c,l,f)),null==r?r=1/0:(h=t-r,c=e-r,l=t+r,f=e+r,r*=r);u=g.pop();)if(!(!(p=u.node)||(o=u.x0)>l||(i=u.y0)>f||(a=u.x1)<h||(s=u.y1)<c))if(p.length){var v=(o+a)/2,y=(i+s)/2;g.push(new q(p[3],v,y,a,s),new q(p[2],o,y,v,s),new q(p[1],v,i,a,y),new q(p[0],o,i,v,y)),(d=(e>=y)<<1|t>=v)&&(u=g[g.length-1],g[g.length-1]=g[g.length-1-d],g[g.length-1-d]=u)}else{var m=t-+this._x.call(null,p.data),w=e-+this._y.call(null,p.data),x=m*m+w*w;if(x<r){var E=Math.sqrt(r=x);h=t-E,c=e-E,l=t+E,f=e+E,n=p.data}}return n},B.remove=function(t){if(isNaN(i=+this._x.call(null,t))||isNaN(a=+this._y.call(null,t)))return this;var e,r,n,o,i,a,s,u,d,h,c,l,f=this._root,g=this._x0,p=this._y0,v=this._x1,y=this._y1;if(!f)return this;if(f.length)for(;;){if((d=i>=(s=(g+v)/2))?g=s:v=s,(h=a>=(u=(p+y)/2))?p=u:y=u,e=f,!(f=f[c=h<<1|d]))return this;if(!f.length)break;(e[c+1&3]||e[c+2&3]||e[c+3&3])&&(r=e,l=c)}for(;f.data!==t;)if(n=f,!(f=f.next))return this;return(o=f.next)&&delete f.next,n?(o?n.next=o:delete n.next,this):e?(o?e[c]=o:delete e[c],(f=e[0]||e[1]||e[2]||e[3])&&f===(e[3]||e[2]||e[1]||e[0])&&!f.length&&(r?r[l]=f:this._root=f),this):(this._root=o,this)},B.removeAll=function(t){for(var e=0,r=t.length;e<r;++e)this.remove(t[e]);return this},B.root=function(){return this._root},B.size=function(){var t=0;return this.visit((function(e){if(!e.length)do{++t}while(e=e.next)})),t},B.visit=function(t){var e,r,n,o,i,a,s=[],u=this._root;for(u&&s.push(new q(u,this._x0,this._y0,this._x1,this._y1));e=s.pop();)if(!t(u=e.node,n=e.x0,o=e.y0,i=e.x1,a=e.y1)&&u.length){var d=(n+i)/2,h=(o+a)/2;(r=u[3])&&s.push(new q(r,d,h,i,a)),(r=u[2])&&s.push(new q(r,n,h,d,a)),(r=u[1])&&s.push(new q(r,d,o,i,h)),(r=u[0])&&s.push(new q(r,n,o,d,h))}return this},B.visitAfter=function(t){var e,r=[],n=[];for(this._root&&r.push(new q(this._root,this._x0,this._y0,this._x1,this._y1));e=r.pop();){var o=e.node;if(o.length){var i,a=e.x0,s=e.y0,u=e.x1,d=e.y1,h=(a+u)/2,c=(s+d)/2;(i=o[0])&&r.push(new q(i,a,s,h,c)),(i=o[1])&&r.push(new q(i,h,s,u,c)),(i=o[2])&&r.push(new q(i,a,c,h,d)),(i=o[3])&&r.push(new q(i,h,c,u,d))}n.push(e)}for(;e=n.pop();)t(e.node,e.x0,e.y0,e.x1,e.y1);return this},B.x=function(t){return arguments.length?(this._x=t,this):this._x},B.y=function(t){return arguments.length?(this._y=t,this):this._y};var H={value:()=>{}};function K(){for(var t,e=0,r=arguments.length,n={};e<r;++e){if(!(t=arguments[e]+"")||t in n||/[\\s.]/.test(t))throw new Error("illegal type: "+t);n[t]=[]}return new Y(n)}function Y(t){this._=t}function J(t,e){for(var r,n=0,o=t.length;n<o;++n)if((r=t[n]).name===e)return r.value}function X(t,e,r){for(var n=0,o=t.length;n<o;++n)if(t[n].name===e){t[n]=H,t=t.slice(0,n).concat(t.slice(n+1));break}return null!=r&&t.push({name:e,value:r}),t}Y.prototype=K.prototype={constructor:Y,on:function(t,e){var r,n,o=this._,i=(n=o,(t+"").trim().split(/^|\\s+/).map((function(t){var e="",r=t.indexOf(".");if(r>=0&&(e=t.slice(r+1),t=t.slice(0,r)),t&&!n.hasOwnProperty(t))throw new Error("unknown type: "+t);return{type:t,name:e}}))),a=-1,s=i.length;if(!(arguments.length<2)){if(null!=e&&"function"!=typeof e)throw new Error("invalid callback: "+e);for(;++a<s;)if(r=(t=i[a]).type)o[r]=X(o[r],t.name,e);else if(null==e)for(r in o)o[r]=X(o[r],t.name,null);return this}for(;++a<s;)if((r=(t=i[a]).type)&&(r=J(o[r],t.name)))return r},copy:function(){var t={},e=this._;for(var r in e)t[r]=e[r].slice();return new Y(t)},call:function(t,e){if((r=arguments.length-2)>0)for(var r,n,o=new Array(r),i=0;i<r;++i)o[i]=arguments[i+2];if(!this._.hasOwnProperty(t))throw new Error("unknown type: "+t);for(i=0,r=(n=this._[t]).length;i<r;++i)n[i].value.apply(e,o)},apply:function(t,e,r){if(!this._.hasOwnProperty(t))throw new Error("unknown type: "+t);for(var n=this._[t],o=0,i=n.length;o<i;++o)n[o].value.apply(e,r)}};const Q=K;var Z,tt,et=0,rt=0,nt=0,ot=1e3,it=0,at=0,st=0,ut="object"==typeof performance&&performance.now?performance:Date,dt="object"==typeof window&&window.requestAnimationFrame?window.requestAnimationFrame.bind(window):function(t){setTimeout(t,17)};function ht(){return at||(dt(ct),at=ut.now()+st)}function ct(){at=0}function lt(){this._call=this._time=this._next=null}function ft(t,e,r){var n=new lt;return n.restart(t,e,r),n}function gt(){at=(it=ut.now())+st,et=rt=0;try{!function(){ht(),++et;for(var t,e=Z;e;)(t=at-e._time)>=0&&e._call.call(void 0,t),e=e._next;--et}()}finally{et=0,function(){for(var t,e,r=Z,n=1/0;r;)r._call?(n>r._time&&(n=r._time),t=r,r=r._next):(e=r._next,r._next=null,r=t?t._next=e:Z=e);tt=t,vt(n)}(),at=0}}function pt(){var t=ut.now(),e=t-it;e>ot&&(st-=e,it=t)}function vt(t){et||(rt&&(rt=clearTimeout(rt)),t-at>24?(t<1/0&&(rt=setTimeout(gt,t-ut.now()-st)),nt&&(nt=clearInterval(nt))):(nt||(it=ut.now(),nt=setInterval(pt,ot)),et=1,dt(gt)))}lt.prototype=ft.prototype={constructor:lt,restart:function(t,e,r){if("function"!=typeof t)throw new TypeError("callback is not a function");r=(null==r?ht():+r)+(null==e?0:+e),this._next||tt===this||(tt?tt._next=this:Z=this,tt=this),this._call=t,this._time=r,vt()},stop:function(){this._call&&(this._call=null,this._time=1/0,vt())}};const yt=1664525,mt=1013904223,wt=4294967296;function xt(t){return t.x}function Et(t){return t.y}var bt=10,Nt=Math.PI*(3-Math.sqrt(5));function Mt(t){var e,r=1,n=.001,o=1-Math.pow(n,1/300),i=0,a=.6,s=new Map,u=ft(c),d=Q("tick","end"),h=function(){let t=1;return()=>(t=(yt*t+mt)%wt)/wt}();function c(){l(),d.call("tick",e),r<n&&(u.stop(),d.call("end",e))}function l(n){var u,d,h=t.length;void 0===n&&(n=1);for(var c=0;c<n;++c)for(r+=(i-r)*o,s.forEach((function(t){t(r)})),u=0;u<h;++u)null==(d=t[u]).fx?d.x+=d.vx*=a:(d.x=d.fx,d.vx=0),null==d.fy?d.y+=d.vy*=a:(d.y=d.fy,d.vy=0);return e}function f(){for(var e,r=0,n=t.length;r<n;++r){if((e=t[r]).index=r,null!=e.fx&&(e.x=e.fx),null!=e.fy&&(e.y=e.fy),isNaN(e.x)||isNaN(e.y)){var o=bt*Math.sqrt(.5+r),i=r*Nt;e.x=o*Math.cos(i),e.y=o*Math.sin(i)}(isNaN(e.vx)||isNaN(e.vy))&&(e.vx=e.vy=0)}}function g(e){return e.initialize&&e.initialize(t,h),e}return null==t&&(t=[]),f(),e={tick:l,restart:function(){return u.restart(c),e},stop:function(){return u.stop(),e},nodes:function(r){return arguments.length?(t=r,f(),s.forEach(g),e):t},alpha:function(t){return arguments.length?(r=+t,e):r},alphaMin:function(t){return arguments.length?(n=+t,e):n},alphaDecay:function(t){return arguments.length?(o=+t,e):+o},alphaTarget:function(t){return arguments.length?(i=+t,e):i},velocityDecay:function(t){return arguments.length?(a=1-t,e):1-a},randomSource:function(t){return arguments.length?(h=t,s.forEach(g),e):h},force:function(t,r){return arguments.length>1?(null==r?s.delete(t):s.set(t,g(r)),e):s.get(t)},find:function(e,r,n){var o,i,a,s,u,d=0,h=t.length;for(null==n?n=1/0:n*=n,d=0;d<h;++d)(a=(o=e-(s=t[d]).x)*o+(i=r-s.y)*i)<n&&(u=s,n=a);return u},on:function(t,r){return arguments.length>1?(d.on(t,r),e):d.on(t)}}}function St(){var t,e,r,n,o,i=$(-30),a=1,s=1/0,u=.81;function d(r){var o,i=t.length,a=V(t,xt,Et).visitAfter(c);for(n=r,o=0;o<i;++o)e=t[o],a.visit(l)}function h(){if(t){var e,r,n=t.length;for(o=new Array(n),e=0;e<n;++e)r=t[e],o[r.index]=+i(r,e,t)}}function c(t){var e,r,n,i,a,s=0,u=0;if(t.length){for(n=i=a=0;a<4;++a)(e=t[a])&&(r=Math.abs(e.value))&&(s+=e.value,u+=r,n+=r*e.x,i+=r*e.y);t.x=n/u,t.y=i/u}else{(e=t).x=e.data.x,e.y=e.data.y;do{s+=o[e.data.index]}while(e=e.next)}t.value=s}function l(t,i,d,h){if(!t.value)return!0;var c=t.x-e.x,l=t.y-e.y,f=h-i,g=c*c+l*l;if(f*f/u<g)return g<s&&(0===c&&(g+=(c=U(r))*c),0===l&&(g+=(l=U(r))*l),g<a&&(g=Math.sqrt(a*g)),e.vx+=c*t.value*n/g,e.vy+=l*t.value*n/g),!0;if(!(t.length||g>=s)){(t.data!==e||t.next)&&(0===c&&(g+=(c=U(r))*c),0===l&&(g+=(l=U(r))*l),g<a&&(g=Math.sqrt(a*g)));do{t.data!==e&&(f=o[t.data.index]*n/g,e.vx+=c*f,e.vy+=l*f)}while(t=t.next)}}return d.initialize=function(e,n){t=e,r=n,h()},d.strength=function(t){return arguments.length?(i="function"==typeof t?t:$(+t),h(),d):i},d.distanceMin=function(t){return arguments.length?(a=t*t,d):Math.sqrt(a)},d.distanceMax=function(t){return arguments.length?(s=t*t,d):Math.sqrt(s)},d.theta=function(t){return arguments.length?(u=t*t,d):Math.sqrt(u)},d}function kt(t){return t.index}function At(t,e){var r=t.get(e);if(!r)throw new Error("node not found: "+e);return r}function Rt(t){var e,r,n,o,i,a,s=kt,u=function(t){return 1/Math.min(o[t.source.index],o[t.target.index])},d=$(30),h=1;function c(n){for(var o=0,s=t.length;o<h;++o)for(var u,d,c,l,f,g,p,v=0;v<s;++v)d=(u=t[v]).source,l=(c=u.target).x+c.vx-d.x-d.vx||U(a),f=c.y+c.vy-d.y-d.vy||U(a),l*=g=((g=Math.sqrt(l*l+f*f))-r[v])/g*n*e[v],f*=g,c.vx-=l*(p=i[v]),c.vy-=f*p,d.vx+=l*(p=1-p),d.vy+=f*p}function l(){if(n){var a,u,d=n.length,h=t.length,c=new Map(n.map(((t,e)=>[s(t,e,n),t])));for(a=0,o=new Array(d);a<h;++a)(u=t[a]).index=a,"object"!=typeof u.source&&(u.source=At(c,u.source)),"object"!=typeof u.target&&(u.target=At(c,u.target)),o[u.source.index]=(o[u.source.index]||0)+1,o[u.target.index]=(o[u.target.index]||0)+1;for(a=0,i=new Array(h);a<h;++a)u=t[a],i[a]=o[u.source.index]/(o[u.source.index]+o[u.target.index]);e=new Array(h),f(),r=new Array(h),g()}}function f(){if(n)for(var r=0,o=t.length;r<o;++r)e[r]=+u(t[r],r,t)}function g(){if(n)for(var e=0,o=t.length;e<o;++e)r[e]=+d(t[e],e,t)}return null==t&&(t=[]),c.initialize=function(t,e){n=t,a=e,l()},c.links=function(e){return arguments.length?(t=e,l(),c):t},c.id=function(t){return arguments.length?(s=t,c):s},c.iterations=function(t){return arguments.length?(h=+t,c):h},c.strength=function(t){return arguments.length?(u="function"==typeof t?t:$(+t),f(),c):u},c.distance=function(t){return arguments.length?(d="function"==typeof t?t:$(+t),g(),c):d},c}function It(t){return t.x+t.vx}function _t(t){return t.y+t.vy}function Dt(t){var e,r,n,o=1,i=1;function a(){for(var t,a,u,d,h,c,l,f=e.length,g=0;g<i;++g)for(a=V(e,It,_t).visitAfter(s),t=0;t<f;++t)u=e[t],c=r[u.index],l=c*c,d=u.x+u.vx,h=u.y+u.vy,a.visit(p);function p(t,e,r,i,a){var s=t.data,f=t.r,g=c+f;if(!s)return e>d+g||i<d-g||r>h+g||a<h-g;if(s.index>u.index){var p=d-s.x-s.vx,v=h-s.y-s.vy,y=p*p+v*v;y<g*g&&(0===p&&(y+=(p=U(n))*p),0===v&&(y+=(v=U(n))*v),y=(g-(y=Math.sqrt(y)))/y*o,u.vx+=(p*=y)*(g=(f*=f)/(l+f)),u.vy+=(v*=y)*g,s.vx-=p*(g=1-g),s.vy-=v*g)}}}function s(t){if(t.data)return t.r=r[t.data.index];for(var e=t.r=0;e<4;++e)t[e]&&t[e].r>t.r&&(t.r=t[e].r)}function u(){if(e){var n,o,i=e.length;for(r=new Array(i),n=0;n<i;++n)o=e[n],r[o.index]=+t(o,n,e)}}return"function"!=typeof t&&(t=$(null==t?1:+t)),a.initialize=function(t,r){e=t,n=r,u()},a.iterations=function(t){return arguments.length?(i=+t,a):i},a.strength=function(t){return arguments.length?(o=+t,a):o},a.radius=function(e){return arguments.length?(t="function"==typeof e?e:$(+e),u(),a):t},a}function Ot(t){var e,r,n,o=$(.1);function i(t){for(var o,i=0,a=e.length;i<a;++i)(o=e[i]).vx+=(n[i]-o.x)*r[i]*t}function a(){if(e){var i,a=e.length;for(r=new Array(a),n=new Array(a),i=0;i<a;++i)r[i]=isNaN(n[i]=+t(e[i],i,e))?0:+o(e[i],i,e)}}return"function"!=typeof t&&(t=$(null==t?0:+t)),i.initialize=function(t){e=t,a()},i.strength=function(t){return arguments.length?(o="function"==typeof t?t:$(+t),a(),i):o},i.x=function(e){return arguments.length?(t="function"==typeof e?e:$(+e),a(),i):t},i}function Pt(t){var e,r,n,o=$(.1);function i(t){for(var o,i=0,a=e.length;i<a;++i)(o=e[i]).vy+=(n[i]-o.y)*r[i]*t}function a(){if(e){var i,a=e.length;for(r=new Array(a),n=new Array(a),i=0;i<a;++i)r[i]=isNaN(n[i]=+t(e[i],i,e))?0:+o(e[i],i,e)}}return"function"!=typeof t&&(t=$(null==t?0:+t)),i.initialize=function(t){e=t,a()},i.strength=function(t){return arguments.length?(o="function"==typeof t?t:$(+t),a(),i):o},i.y=function(e){return arguments.length?(t="function"==typeof e?e:$(+e),a(),i):t},i}function Tt(){function t(t){return function(){return t}}var e,r=function(t){return t.cluster},n=t(1),o=t(-1),i=t(100),a=t(.1),u=[0,0],d=[],h={},c=[],l=100,f=100,g={none:{x:0,y:0}},p=[],v="force",y=!0,m=.1;function w(t){if(!y)return w;e.tick(),E();for(var n=0,o=d.length,i=void 0,a=t*m;n<o;++n)(i=d[n]).vx+=(g[r(i)].x-i.x)*a,i.vy+=(g[r(i)].y-i.y)*a}function x(){d&&function(){if(d&&d.length){if(void 0===r(d[0]))throw Error("Couldnt find the grouping attribute for the nodes. Make sure to set it up with forceInBox.groupBy(\'clusterAttr\') before calling .links()");var t,u,g,v,y,m=(t=[],u=[],g={},{},y=[],v=function(t){var e={};return t.forEach((function(t){var n=r(t);e[n]||(e[n]={count:0,sumforceNodeSize:0})})),t.forEach((function(t){var o=r(t),i=n(t),a=e[o];a.count=a.count+1,a.sumforceNodeSize=a.sumforceNodeSize+Math.PI*(i*i)*1.3,e[o]=a})),e}(d),y=function(t){var e={},n=[];return t.forEach((function(t){var n,o,i,a,s,u=(o=(n=t).source,i=n.target,(a=r(h[o]))<=(s=r(h[i]))?"".concat(a,"~").concat(s):"".concat(s,"~").concat(a)),d=0;void 0!==e[u]&&(d=e[u]),d+=1,e[u]=d})),Object.entries(e).forEach((function(t){var e=s(t,2),r=e[0],o=e[1],i=r.split("~")[0],a=r.split("~")[1];void 0!==i&&void 0!==a&&n.push({source:i,target:a,count:o})})),n}(c),Object.keys(v).forEach((function(e,r){var n=v[e];t.push({id:e,size:n.count,r:Math.sqrt(n.sumforceNodeSize/Math.PI)}),g[e]=r})),y.forEach((function(t){var e=t.source,r=t.target,n=g[e],o=g[r];void 0!==n&&void 0!==o&&u.push({source:n,target:o,count:t.count})})),{nodes:t,links:u});e=Mt(m.nodes).force("x",Ot(l).strength(.1)).force("y",Pt(f).strength(.1)).force("collide",Dt((function(t){return t.r})).iterations(4)).force("charge",St().strength(o)).force("links",Rt(m.nodes.length?m.links:[]).distance(i).strength(a)),p=e.nodes(),E()}}()}function E(){return g={none:{x:0,y:0}},p.forEach((function(t){g[t.id]={x:t.x-u[0],y:t.y-u[1]}})),g}return w.initialize=function(t){d=t,x()},w.template=function(t){return arguments.length?(v=t,x(),w):v},w.groupBy=function(t){return arguments.length?"string"==typeof t?(r=function(e){return e[t]},w):(r=t,w):r},w.enableGrouping=function(t){return arguments.length?(y=t,w):y},w.strength=function(t){return arguments.length?(m=t,w):m},w.centerX=function(t){return arguments.length?(l=t,w):l},w.centerY=function(t){return arguments.length?(f=t,w):f},w.nodes=function(t){return arguments.length?(function(t){h={},t.forEach((function(t){h[t.id]=t}))}(t||[]),d=t||[],w):d},w.links=function(t){return arguments.length?(c=t||[],x(),w):c},w.forceNodeSize=function(e){return arguments.length?(n="function"==typeof e?e:t(+e),x(),w):n},w.nodeSize=w.forceNodeSize,w.forceCharge=function(e){return arguments.length?(o="function"==typeof e?e:t(+e),x(),w):o},w.forceLinkDistance=function(e){return arguments.length?(i="function"==typeof e?e:t(+e),x(),w):i},w.forceLinkStrength=function(e){return arguments.length?(a="function"==typeof e?e:t(+e),x(),w):a},w.offset=function(t){return arguments.length?(u=t,w):u},w.getFocis=E,w}var zt={center:[0,0],preventOverlap:!1,nodeSize:void 0,nodeSpacing:void 0,linkDistance:50,forceSimulation:null,alphaDecay:.028,alphaMin:.001,alpha:.3,collideStrength:1,clustering:!1,clusterNodeStrength:-1,clusterEdgeStrength:.1,clusterEdgeDistance:100,clusterFociStrength:.8,clusterNodeSize:10},Ct=function(){function t(t){void 0===t&&(t={}),this.options=t,this.id="d3force",this.options=n(n({},zt),t)}return t.prototype.execute=function(t,e){return i(this,void 0,void 0,(function(){return a(this,(function(r){return[2,this.genericForceLayout(!1,t,e)]}))}))},t.prototype.assign=function(t,e){return i(this,void 0,void 0,(function(){return a(this,(function(r){return this.genericForceLayout(!0,t,e),[2]}))}))},t.prototype.stop=function(){var t;null===(t=this.forceSimulation)||void 0===t||t.stop()},t.prototype.tick=function(t){var e=this;void 0===t&&(t=1),this.forceSimulation.tick(t);var r={nodes:Lt(this.lastLayoutNodes),edges:qt(this.lastLayoutEdges)};return this.lastAssign&&r.nodes.forEach((function(t){return e.lastGraph.mergeNodeData(t.id,{x:t.data.x,y:t.data.y})})),r},t.prototype.genericForceLayout=function(t,e,r){return i(this,void 0,void 0,(function(){var o,i,s,u,d,h,c,l,f,g,p,v,y,m,w,x,E,b,M,S,k,A,R,I,_,D,O=this;return a(this,(function(a){return o=n(n({},this.options),r),i=e.getAllNodes(),s=e.getAllEdges(),u=i.map((function(t){var e,r;return n(n({},N(t)),{x:null===(e=t.data)||void 0===e?void 0:e.x,y:null===(r=t.data)||void 0===r?void 0:r.y})})),d=s.map((function(t){return N(t)})),this.lastLayoutNodes=u,this.lastLayoutEdges=d,this.lastAssign=t,this.lastGraph=e,h=o.alphaMin,c=o.alphaDecay,l=o.alpha,f=o.nodeStrength,g=o.edgeStrength,p=o.linkDistance,v=o.clustering,y=o.clusterFociStrength,m=o.clusterEdgeDistance,w=o.clusterEdgeStrength,x=o.clusterNodeStrength,E=o.clusterNodeSize,b=o.collideStrength,M=void 0===b?1:b,S=o.center,k=void 0===S?[0,0]:S,A=o.preventOverlap,R=o.nodeSize,I=o.nodeSpacing,_=o.onTick,D=o.forceSimulation,[2,new Promise((function(r){if(D){v&&((i=Tt()).nodes(u),i.links(d)),D.nodes(u),d&&(s=Rt().id((function(t){return t.id})).links(d),g&&s.strength(g),p&&s.distance(p),D.force("link",s)),A&&O.overlapProcess(D,{nodeSize:R,nodeSpacing:I,collideStrength:M}),D.alpha(l).restart();var n=Lt(u),o=qt(d);t&&n.forEach((function(t){return e.mergeNodeData(t.id,{x:t.data.x,y:t.data.y})})),r({nodes:n,edges:o})}else try{var i,a=St();if(f&&a.strength(f),D=Mt().nodes(u),v&&((i=Tt()).centerX(k[0]).centerY(k[1]).template("force").strength(y),d&&i.links(d),u&&i.nodes(u),i.forceLinkDistance(m).forceLinkStrength(w).forceCharge(x).forceNodeSize(E),D.force("group",i)),D.force("center",function(t,e){var r,n=1;function o(){var o,i,a=r.length,s=0,u=0;for(o=0;o<a;++o)s+=(i=r[o]).x,u+=i.y;for(s=(s/a-t)*n,u=(u/a-e)*n,o=0;o<a;++o)(i=r[o]).x-=s,i.y-=u}return null==t&&(t=0),null==e&&(e=0),o.initialize=function(t){r=t},o.x=function(e){return arguments.length?(t=+e,o):t},o.y=function(t){return arguments.length?(e=+t,o):e},o.strength=function(t){return arguments.length?(n=+t,o):n},o}(k[0],k[1])).force("charge",a).alpha(l).alphaDecay(c).alphaMin(h),A&&O.overlapProcess(D,{nodeSize:R,nodeSpacing:I,collideStrength:M}),d){var s=Rt().id((function(t){return t.id})).links(d);g&&s.strength(g),p&&s.distance(p),D.force("link",s)}D.on("tick",(function(){var r=Lt(u);null==_||_({nodes:r,edges:qt(d)}),t&&r.forEach((function(t){return e.mergeNodeData(t.id,{x:t.data.x,y:t.data.y})}))})).on("end",(function(){var n=Lt(u);t&&n.forEach((function(t){return e.mergeNodeData(t.id,{x:t.data.x,y:t.data.y})})),r({nodes:n,edges:qt(d)})}))}catch(t){console.warn(t)}O.forceSimulation=D}))]}))}))},t.prototype.overlapProcess=function(t,e){var r,n,o=e.nodeSize,i=e.nodeSpacing,a=e.collideStrength;if(n=E(i)?function(){return i}:M(i)?i:function(){return 0},o)if(M(o))r=function(t){return o(t)+n(t)};else if(p(o)){var s=(o[0]>o[1]?o[0]:o[1])/2;r=function(t){return s+n(t)}}else if(E(o)){var u=o/2;r=function(t){return u+n(t)}}else r=function(){return 10};else r=function(t){return t.size?p(t.size)?(t.size[0]>t.size[1]?t.size[0]:t.size[1])/2+n(t):S(t.size)?(t.size.width>t.size.height?t.size.width:t.size.height)/2+n(t):t.size/2+n(t):10+n(t)};t.force("collisionForce",Dt(r).strength(a))},t}(),Lt=function(t){return t.map((function(t){var e=t.x,r=t.y,i=o(t,["x","y"]);return n(n({},i),{data:n(n({},i.data),{x:e,y:r})})}))},qt=function(t){return t.map((function(t){var e=t.source,r=t.target,i=o(t,["source","target"]);return n(n({},i),{source:e.id,target:r.id})}))};var jt=function(t,e){if("next"!==t&&"prev"!==t)return e},Ft=function(t){t.prev.next=t.next,t.next.prev=t.prev,delete t.next,delete t.prev},Vt=function(t){function e(){return null!==t&&t.apply(this,arguments)||this}return function(t,e){if("function"!=typeof e&&null!==e)throw new TypeError("Class extends value "+String(e)+" is not a constructor or null");function n(){this.constructor=t}r(t,e),t.prototype=null===e?Object.create(e):(n.prototype=e.prototype,new n)}(e,t),e}(function(){function t(){var t={};t.prev=t,t.next=t.prev,this.shortcut=t}return t.prototype.dequeue=function(){var t=this.shortcut,e=t.prev;if(e&&e!==t)return Ft(e),e},t.prototype.enqueue=function(t){var e=this.shortcut;t.prev&&t.next&&Ft(t),t.next=e.next,e.next.prev=t,e.next=t,t.prev=e},t.prototype.toString=function(){for(var t=[],e=this.shortcut,r=e.prev;r!==e;)t.push(JSON.stringify(r,jt)),r=null==r?void 0:r.prev;return"[".concat(t.join(", "),"]")},t}()),Gt=function(){return 1},Wt=function(t,e,r,o,i){var a,s,u=[];return t.hasNode(o.v)&&(null===(a=t.getRelatedEdges(o.v,"in"))||void 0===a||a.forEach((function(o){var a=o.data.weight,s=t.getNode(o.source);i&&u.push({v:o.source,w:o.target,in:0,out:0}),void 0===s.data.out&&(s.data.out=0),s.data.out-=a,Bt(e,r,n({v:s.id},s.data))})),null===(s=t.getRelatedEdges(o.v,"out"))||void 0===s||s.forEach((function(o){var i=o.data.weight,a=o.target,s=t.getNode(a);void 0===s.data.in&&(s.data.in=0),s.data.in-=i,Bt(e,r,n({v:s.id},s.data))})),t.removeNode(o.v)),i?u:void 0},Bt=function(t,e,r){r.out?r.in?t[r.out-r.in+e].enqueue(r):t[t.length-1].enqueue(r):t[0].enqueue(r)},$t=function(t,e){var r="greedy"===e?function(t,e){var r;if(t.getAllNodes().length<=1)return[];var o=function(t,e){var r=new f,o=0,i=0;t.getAllNodes().forEach((function(t){r.addNode({id:t.id,data:{v:t.id,in:0,out:0}})})),t.getAllEdges().forEach((function(t){var a=r.getRelatedEdges(t.source,"out").find((function(e){return e.target===t.target})),s=(null==e?void 0:e(t))||1;a?r.updateEdgeData(null==a?void 0:a.id,n(n({},a.data),{weight:a.data.weight+s})):r.addEdge({id:t.id,source:t.source,target:t.target,data:{weight:s}}),i=Math.max(i,r.getNode(t.source).data.out+=s),o=Math.max(o,r.getNode(t.target).data.in+=s)}));for(var a=[],s=i+o+3,u=0;u<s;u++)a.push(new Vt);var d=o+1;return r.getAllNodes().forEach((function(t){Bt(a,d,n({v:t.id},r.getNode(t.id).data))})),{buckets:a,zeroIdx:d,graph:r}}(t,function(t){return t.data.weight||1}||Gt);return null===(r=function(t,e,r){for(var n,o=[],i=e[e.length-1],a=e[0];t.getAllNodes().length;){for(;n=a.dequeue();)Wt(t,e,r,n);for(;n=i.dequeue();)Wt(t,e,r,n);if(t.getAllNodes().length)for(var s=e.length-2;s>0;--s)if(n=e[s].dequeue()){o=o.concat(Wt(t,e,r,n,!0));break}}return o}(o.graph,o.buckets,o.zeroIdx).map((function(e){return t.getRelatedEdges(e.v,"out").filter((function(t){return t.target===e.w}))})))||void 0===r?void 0:r.flat()}(t):Ut(t);null==r||r.forEach((function(e){var r=e.data;t.removeEdge(e.id),r.forwardName=e.data.name,r.reversed=!0,t.addEdge({id:e.id,source:e.target,target:e.source,data:n({},r)})}))},Ut=function(t){var e=[],r={},n={},o=function(i){n[i]||(n[i]=!0,r[i]=!0,t.getRelatedEdges(i,"out").forEach((function(t){r[t.target]?e.push(t):o(t.target)})),delete r[i])};return t.getAllNodes().forEach((function(t){return o(t.id)})),e},Ht=function(t,e,r,n){var o;do{o="".concat(n).concat(Math.random())}while(t.hasNode(o));return r.dummy=e,t.addNode({id:o,data:r}),o},Kt=function(t){var e=new f;return t.getAllNodes().forEach((function(r){t.getChildren(r.id).length||e.addNode(n({},r))})),t.getAllEdges().forEach((function(t){e.addEdge(t)})),e},Yt=function(t,e){var r,n,o=Number(t.x),i=Number(t.y),a=Number(e.x)-o,s=Number(e.y)-i,u=Number(t.width)/2,d=Number(t.height)/2;return a||s?(Math.abs(s)*u>Math.abs(a)*d?(s<0&&(d=-d),r=d*a/s,n=d):(a<0&&(u=-u),r=u,n=u*s/a),{x:o+r,y:i+n}):{x:0,y:0}},Jt=function(t){for(var e=[],r=Qt(t)+1,n=0;n<r;n++)e.push([]);for(t.getAllNodes().forEach((function(t){var r=t.data.rank;void 0!==r&&e[r]&&e[r].push(t.id)})),n=0;n<r;n++)e[n]=e[n].sort((function(e,r){return n=t.getNode(e).data.order,o=t.getNode(r).data.order,Number(n)-Number(o);var n,o}));return e},Xt=function(t,e,r,n){var o={width:0,height:0};return E(r)&&E(n)&&(o.rank=r,o.order=n),Ht(t,"border",o,e)},Qt=function(t){var e;return t.getAllNodes().forEach((function(t){var r=t.data.rank;void 0!==r&&(void 0===e||r>e)&&(e=r)})),e||(e=0),e},Zt=function(t,e){return t.reduce((function(t,r){return e(t)>e(r)?r:t}))},te=function(t,e,r,n,o,i){n.includes(e.id)||(n.push(e.id),r||i.push(e.id),o(e.id).forEach((function(e){return te(t,e,r,n,o,i)})),r&&i.push(e.id))},ee=function(t,e,r,n){var o=Array.isArray(e)?e:[e],i=function(e){return n?t.getSuccessors(e):t.getNeighbors(e)},a=[],s=[];return o.forEach((function(e){if(!t.hasNode(e.id))throw new Error("Graph does not have node: "+e);te(t,e,"post"===r,s,i,a)})),a},re="edge-label",ne=function(t){var e={},r=function(n){var o,i,a=t.getNode(n);return a?e[n]?a.data.rank:(e[n]=!0,null===(o=t.getRelatedEdges(n,"out"))||void 0===o||o.forEach((function(t){var e=r(t.target)-t.data.minlen;e&&(void 0===i||e<i)&&(i=e)})),i||(i=0),a.data.rank=i,i):0};t.getAllNodes().filter((function(e){return 0===t.getRelatedEdges(e.id,"in").length})).forEach((function(t){return r(t.id)}))},oe=function(t,e){return t.getNode(e.target).data.rank-t.getNode(e.source).data.rank-e.data.minlen},ie=function(t,e){var r=function(n){e.getRelatedEdges(n,"both").forEach((function(o){var i=o.source,a=n===i?o.target:i;t.hasNode(a)||oe(e,o)||(t.addNode({id:a,data:{}}),t.addEdge({id:o.id,source:n,target:a,data:{}}),r(a))}))};return t.getAllNodes().forEach((function(t){return r(t.id)})),t.getAllNodes().length},ae=function(t,e){var r=function(n){var o;null===(o=e.getRelatedEdges(n,"both"))||void 0===o||o.forEach((function(o){var i=o.source,a=n===i?o.target:i;t.hasNode(a)||void 0===e.getNode(a).data.layer&&oe(e,o)||(t.addNode({id:a,data:{}}),t.addEdge({id:o.id,source:n,target:a,data:{}}),r(a))}))};return t.getAllNodes().forEach((function(t){return r(t.id)})),t.getAllNodes().length},se=function(t,e){return Zt(e.getAllEdges(),(function(r){return t.hasNode(r.source)!==t.hasNode(r.target)?oe(e,r):1/0}))},ue=function(t,e,r){t.getAllNodes().forEach((function(t){var n=e.getNode(t.id);n.data.rank||(n.data.rank=0),n.data.rank+=r}))},de=function(t,e){var r=ee(t,t.getAllNodes(),"post",!1);(r=r.slice(0,(null==r?void 0:r.length)-1)).forEach((function(r){he(t,e,r)}))},he=function(t,e,r){var n=t.getNode(r).data.parent;t.getRelatedEdges(r,"both").find((function(t){return t.target===n||t.source===n})).data.cutvalue=ce(t,e,r)},ce=function(t,e,r){var n=t.getNode(r).data.parent,o=!0,i=e.getRelatedEdges(r,"out").find((function(t){return t.target===n})),a=0;return i||(o=!1,i=e.getRelatedEdges(n,"out").find((function(t){return t.target===r}))),a=i.data.weight,e.getRelatedEdges(r,"both").forEach((function(e){var i=e.source===r,s=i?e.target:e.source;if(s!==n){var u=i===o,d=e.data.weight;if(a+=u?d:-d,me(t,r,s)){var h=t.getRelatedEdges(r,"both").find((function(t){return t.source===s||t.target===s})).data.cutvalue;a+=u?-h:h}}})),a},le=function(t,e){void 0===e&&(e=t.getAllNodes()[0].id),fe(t,{},1,e)},fe=function(t,e,r,n,o){var i,a=r,s=r,u=t.getNode(n);return e[n]=!0,null===(i=t.getNeighbors(n))||void 0===i||i.forEach((function(r){e[r.id]||(s=fe(t,e,s,r.id,n))})),u.data.low=a,u.data.lim=s++,o?u.data.parent=o:delete u.data.parent,s},ge=function(t){return t.getAllEdges().find((function(t){return t.data.cutvalue<0}))},pe=function(t,e,r){var n=r.source,o=r.target;e.getRelatedEdges(n,"out").find((function(t){return t.target===o}))||(n=r.target,o=r.source);var i=t.getNode(n),a=t.getNode(o),s=i,u=!1;i.data.lim>a.data.lim&&(s=a,u=!0);var d=e.getAllEdges().filter((function(e){return u===we(t.getNode(e.source),s)&&u!==we(t.getNode(e.target),s)}));return Zt(d,(function(t){return oe(e,t)}))},ve=function(t,e,r,n){var o=t.getRelatedEdges(r.source,"both").find((function(t){return t.source===r.target||t.target===r.target}));o&&t.removeEdge(o.id),t.addEdge({id:"e".concat(Math.random()),source:n.source,target:n.target,data:{}}),le(t),de(t,e),ye(t,e)},ye=function(t,e){var r=t.getAllNodes().find((function(t){return!t.data.parent})),n=ee(t,r,"pre",!1);(n=n.slice(1)).forEach((function(r){var n=t.getNode(r).data.parent,o=e.getRelatedEdges(r,"out").find((function(t){return t.target===n})),i=!1;!o&&e.hasNode(n)&&(o=e.getRelatedEdges(n,"out").find((function(t){return t.target===r})),i=!0),e.getNode(r).data.rank=(e.hasNode(n)&&e.getNode(n).data.rank||0)+(i?null==o?void 0:o.data.minlen:-(null==o?void 0:o.data.minlen))}))},me=function(t,e,r){return t.getRelatedEdges(e,"both").find((function(t){return t.source===r||t.target===r}))},we=function(t,e){return e.data.low<=t.data.lim&&t.data.lim<=e.data.lim},xe=ne,Ee=function(t){!function(t){var e=function(t){var e=new f;return t.getAllNodes().forEach((function(t){e.addNode(n({},t))})),t.getAllEdges().forEach((function(t){var r=e.getRelatedEdges(t.source,"out").find((function(e){return e.target===t.target}));r?e.updateEdgeData(null==r?void 0:r.id,n(n({},r.data),{weight:r.data.weight+t.data.weight||0,minlen:Math.max(r.data.minlen,t.data.minlen||1)})):e.addEdge({id:t.id,source:t.source,target:t.target,data:{weight:t.data.weight||0,minlen:t.data.minlen||1}})})),e}(t);ne(e);var r,o,i=function(t){var e,r,n=new f({tree:[]}),o=t.getAllNodes()[0],i=t.getAllNodes().length;for(n.addNode(o);ie(n,t)<i;)e=se(n,t),r=n.hasNode(e.source)?oe(t,e):-oe(t,e),ue(n,t,r);return n}(e);for(le(i),de(i,e);r=ge(i);)o=pe(i,e,r),ve(i,e,r,o)}(t)},be=function(t,e,r,n,o,i,a){var s=t.getChildren(a);if(null==s?void 0:s.length){var u=Xt(t,"_bt"),d=Xt(t,"_bb"),h=t.getNode(a);t.setParent(u,a),h.data.borderTop=u,t.setParent(d,a),h.data.borderBottom=d,null==s||s.forEach((function(s){be(t,e,r,n,o,i,s.id);var h=s.data.borderTop?s.data.borderTop:s.id,c=s.data.borderBottom?s.data.borderBottom:s.id,l=s.data.borderTop?n:2*n,f=h!==c?1:o-i[a]+1;t.addEdge({id:"e".concat(Math.random()),source:u,target:h,data:{minlen:f,weight:l,nestingEdge:!0}}),t.addEdge({id:"e".concat(Math.random()),source:c,target:d,data:{minlen:f,weight:l,nestingEdge:!0}})})),t.getParent(a)||t.addEdge({id:"e".concat(Math.random()),source:e,target:u,data:{weight:0,minlen:o+i[a]}})}else a!==e&&t.addEdge({id:"e".concat(Math.random()),source:e,target:a,data:{weight:0,minlen:r}})},Ne=function(t,e,r,n,o,i){var a={rank:i,borderType:e,width:0,height:0},s=o.data[e][i-1],u=Ht(t,"border",a,r);o.data[e][i]=u,t.setParent(u,n),s&&t.addEdge({id:"e".concat(Math.random()),source:s,target:u,data:{weight:1}})},Me=function(t){t.getAllNodes().forEach((function(t){Se(t)})),t.getAllEdges().forEach((function(t){Se(t)}))},Se=function(t){var e=t.data.width;t.data.width=t.data.height,t.data.height=e},ke=function(t){(null==t?void 0:t.y)&&(t.y=-t.y)},Ae=function(t){var e=t.x;t.x=t.y,t.y=e},Re=function(t){for(var e={},r=t.getAllNodes(),n=r.map((function(t){var e;return null!==(e=t.data.rank)&&void 0!==e?e:-1/0})),o=Math.max.apply(Math,u([],s(n),!1)),i=[],a=0;a<o+1;a++)i.push([]);var d=r.sort((function(e,r){return t.getNode(e.id).data.rank-t.getNode(r.id).data.rank})),h=d.filter((function(e){return void 0!==t.getNode(e.id).data.fixorder})).sort((function(e,r){return t.getNode(e.id).data.fixorder-t.getNode(r.id).data.fixorder}));return null==h||h.forEach((function(r){isNaN(t.getNode(r.id).data.rank)||i[t.getNode(r.id).data.rank].push(r.id),e[r.id]=!0})),null==d||d.forEach((function(r){return t.dfsTree(r.id,(function(t){if(e.hasOwnProperty(t.id))return!0;e[t.id]=!0,isNaN(t.data.rank)||i[t.data.rank].push(t.id)}))})),i},Ie=function(t,e,r){for(var n=function(t,e){return null==t?void 0:t.reduce((function(t,r,n){return t[r]=e[n],t}),{})}(r,r.map((function(t,e){return e}))),o=e.map((function(e){var r=t.getRelatedEdges(e,"out").map((function(t){return{pos:n[t.target]||0,weight:t.data.weight}}));return null==r?void 0:r.sort((function(t,e){return t.pos-e.pos}))})),i=o.flat().filter((function(t){return void 0!==t})),a=1;a<r.length;)a<<=1;var s=2*a-1;a-=1;var u=Array(s).fill(0,0,s),d=0;return null==i||i.forEach((function(t){if(t){var e=t.pos+a;u[e]+=t.weight;for(var r=0;e>0;)e%2&&(r+=u[e+1]),u[e=e-1>>1]+=t.weight;d+=t.weight*r}})),d},_e=function(t,e){for(var r=0,n=1;n<(null==e?void 0:e.length);n+=1)r+=Ie(t,e[n-1],e[n]);return r},De=function(t,e){var r,n=0,o=0;t.weight&&(n+=t.barycenter*t.weight,o+=t.weight),e.weight&&(n+=e.barycenter*e.weight,o+=e.weight),t.vs=null===(r=e.vs)||void 0===r?void 0:r.concat(t.vs),t.barycenter=n/o,t.weight=o,t.i=Math.min(e.i,t.i),e.merged=!0};const Oe=function(t,e){var r,n,o,i={};return null==t||t.forEach((function(t,e){i[t.v]={i:e,indegree:0,in:[],out:[],vs:[t.v]};var r=i[t.v];void 0!==t.barycenter&&(r.barycenter=t.barycenter,r.weight=t.weight)})),null===(r=e.getAllEdges())||void 0===r||r.forEach((function(t){var e=i[t.source],r=i[t.target];void 0!==e&&void 0!==r&&(r.indegree++,e.out.push(i[t.target]))})),function(t){for(var e,r,n=[],o=function(){var o=t.pop();n.push(o),null===(e=o.in.reverse())||void 0===e||e.forEach((function(t){return(e=o,function(t){t.merged||(void 0===t.barycenter||void 0===e.barycenter||t.barycenter>=e.barycenter)&&De(e,t)})(t);var e})),null===(r=o.out)||void 0===r||r.forEach((function(e){return(r=o,function(e){e.in.push(r),0==--e.indegree&&t.push(e)})(e);var r}))};null==t?void 0:t.length;)o();var i=n.filter((function(t){return!t.merged})),a=["vs","i","barycenter","weight"];return i.map((function(t){var e={};return null==a||a.forEach((function(r){void 0!==t[r]&&(e[r]=t[r])})),e}))}(null===(o=(n=Object.values(i)).filter)||void 0===o?void 0:o.call(n,(function(t){return!t.indegree})))};var Pe=function(t,e,r){for(var n,o=r;e.length&&(n=e[e.length-1]).i<=o;)e.pop(),null==t||t.push(n.vs),o++;return o},Te=function(t,e,r,n,o,i){var a,s,u,d,h=t.getChildren(e).map((function(t){return t.id})),c=t.getNode(e),l=c?c.data.borderLeft:void 0,f=c?c.data.borderRight:void 0,g={};l&&(h=null==h?void 0:h.filter((function(t){return t!==l&&t!==f})));var p=function(t,e){return e.map((function(e){var r=t.getRelatedEdges(e,"in");if(!(null==r?void 0:r.length))return{v:e};var n={sum:0,weight:0};return null==r||r.forEach((function(e){var r=t.getNode(e.source);n.sum+=e.data.weight*r.data.order,n.weight+=e.data.weight})),{v:e,barycenter:n.sum/n.weight,weight:n.weight}}))}(t,h||[]);null==p||p.forEach((function(e){var o;if(null===(o=t.getChildren(e.v))||void 0===o?void 0:o.length){var a=Te(t,e.v,r,n,i);g[e.v]=a,a.hasOwnProperty("barycenter")&&Ce(e,a)}}));var v=Oe(p,r);ze(v,g),null===(a=v.filter((function(t){return t.vs.length>0})))||void 0===a||a.forEach((function(e){var r=t.getNode(e.vs[0]);r&&(e.fixorder=r.data.fixorder,e.order=r.data.order)}));var y=function(t,e,r,n){var o=function(t,e){var r={lhs:[],rhs:[]};return null==t||t.forEach((function(t){var e,o;o=(e=t).hasOwnProperty("fixorder")&&!isNaN(e.fixorder),(n?!o&&e.hasOwnProperty("barycenter"):o||e.hasOwnProperty("barycenter"))?r.lhs.push(t):r.rhs.push(t)})),r}(t),i=o.lhs,a=o.rhs.sort((function(t,e){return-t.i- -e.i})),s=[],u=0,d=0,h=0;null==i||i.sort(function(t,e){return function(r,n){if(void 0!==r.fixorder&&void 0!==n.fixorder)return r.fixorder-n.fixorder;if(r.barycenter<n.barycenter)return-1;if(r.barycenter>n.barycenter)return 1;if(e&&void 0!==r.order&&void 0!==n.order){if(r.order<n.order)return-1;if(r.order>n.order)return 1}return t?n.i-r.i:r.i-n.i}}(!!e,!!r)),h=Pe(s,a,h),null==i||i.forEach((function(t){var e;h+=null===(e=t.vs)||void 0===e?void 0:e.length,s.push(t.vs),u+=t.barycenter*t.weight,d+=t.weight,h=Pe(s,a,h)}));var c={vs:s.flat()};return d&&(c.barycenter=u/d,c.weight=d),c}(v,n,o,i);if(l&&(y.vs=[l,y.vs,f].flat(),null===(s=t.getPredecessors(l))||void 0===s?void 0:s.length)){var m=t.getNode((null===(u=t.getPredecessors(l))||void 0===u?void 0:u[0].id)||""),w=t.getNode((null===(d=t.getPredecessors(f))||void 0===d?void 0:d[0].id)||"");y.hasOwnProperty("barycenter")||(y.barycenter=0,y.weight=0),y.barycenter=(y.barycenter*y.weight+m.data.order+w.data.order)/(y.weight+2),y.weight+=2}return y},ze=function(t,e){null==t||t.forEach((function(t){var r,n=null===(r=t.vs)||void 0===r?void 0:r.map((function(t){return e[t]?e[t].vs:t}));t.vs=n.flat()}))},Ce=function(t,e){void 0!==t.barycenter?(t.barycenter=(t.barycenter*t.weight+e.barycenter*e.weight)/(t.weight+e.weight),t.weight+=e.weight):(t.barycenter=e.barycenter,t.weight=e.weight)},Le=function(t){if("object"!=typeof t||null===t)return t;var e,r;if(r=t,Array.isArray?Array.isArray(r):x(r,"Array")){e=[];for(var n=0,o=t.length;n<o;n++)"object"==typeof t[n]&&null!=t[n]?e[n]=Le(t[n]):e[n]=t[n]}else for(var i in e={},t)"object"==typeof t[i]&&null!=t[i]?e[i]=Le(t[i]):e[i]=t[i];return e};const qe=Le;var je=function(t,e,r){return e.map((function(e){return function(t,e,r){var o=function(t){for(var e;t.hasNode(e="_root".concat(Math.random())););return e}(t),i=new f({tree:[{id:o,children:[],data:{}}]});return t.getAllNodes().forEach((function(a){var s=t.getParent(a.id);(a.data.rank===e||a.data.minRank<=e&&e<=a.data.maxRank)&&(i.hasNode(a.id)||i.addNode(n({},a)),(null==s?void 0:s.id)&&!i.hasNode(null==s?void 0:s.id)&&i.addNode(n({},s)),i.setParent(a.id,(null==s?void 0:s.id)||o),t.getRelatedEdges(a.id,r).forEach((function(e){var r=e.source===a.id?e.target:e.source;i.hasNode(r)||i.addNode(n({},t.getNode(r)));var o=i.getRelatedEdges(r,"out").find((function(t){return t.target===a.id})),s=void 0!==o?o.data.weight:0;o?i.updateEdgeData(o.id,n(n({},o.data),{weight:e.data.weight+s})):i.addEdge({id:e.id,source:r,target:a.id,data:{weight:e.data.weight+s}})})),a.data.hasOwnProperty("minRank")&&i.updateNodeData(a.id,n(n({},a.data),{borderLeft:a.data.borderLeft[e],borderRight:a.data.borderRight[e]})))})),i}(t,e,r)}))},Fe=function(t,e,r,n){var o=new f;null==t||t.forEach((function(t){for(var i,a=t.getRoots()[0].id,s=Te(t,a,o,e,r,n),u=0;u<(null===(i=s.vs)||void 0===i?void 0:i.length);u++){var d=t.getNode(s.vs[u]);d&&(d.data.order=u)}!function(t,e,r){var n,o={};null==r||r.forEach((function(r){for(var i,a,s=t.getParent(r);s;){if((i=t.getParent(s.id))?(a=o[i.id],o[i.id]=s.id):(a=n,n=s.id),a&&a!==s.id)return e.addNodes([{id:a,data:{}},{id:s.id,data:{}}]),void e.addEdge({id:"e".concat(a,"-").concat(s.id),source:a,target:s.id,data:{}});s=i}}))}(t,o,s.vs)}))},Ve=function(t,e){null==e||e.forEach((function(e){null==e||e.forEach((function(e,r){t.getNode(e).data.order=r}))}))},Ge=function(t,e){var r={};function n(e,n,o,i,a){for(var s,u,d,h=n;h<o;h++)d=e[h],(null===(s=t.getNode(d))||void 0===s?void 0:s.data.dummy)&&(null===(u=t.getPredecessors(d))||void 0===u||u.forEach((function(e){var n=t.getNode(e.id);n.data.dummy&&(n.data.order<i||n.data.order>a)&&Be(r,e.id,d)})))}function o(t,e){var r=function(t){return JSON.stringify(t.slice(1))}(t);e.get(r)||(n.apply(void 0,u([],s(t),!1)),e.set(r,!0))}return(null==e?void 0:e.length)&&e.reduce((function(e,r){var n,i=-1,a=0,s=new Map;return null==r||r.forEach((function(u,d){var h;if("border"===(null===(h=t.getNode(u))||void 0===h?void 0:h.data.dummy)){var c=t.getPredecessors(u)||[];c.length&&(n=t.getNode(c[0].id).data.order,o([r,a,d,i,n],s),a=d,i=n)}o([r,a,r.length,n,e.length],s)})),r})),r},We=function(t,e){var r,n;if(null===(r=t.getNode(e))||void 0===r?void 0:r.data.dummy)return null===(n=t.getPredecessors(e))||void 0===n?void 0:n.find((function(e){return t.getNode(e.id).data.dummy}))},Be=function(t,e,r){var n=e,o=r;if(n>o){var i=n;n=o,o=i}var a=t[n];a||(t[n]=a={}),a[o]=!0},$e=function(t,e,r){var n=e;return n>r&&(n=r),!!t[n]},Ue=function(t,e,r,o,i,a){var s=new f,u=He(o,i,a);return null==e||e.forEach((function(e){var o;null==e||e.forEach((function(e){var i=r[e];if(s.hasNode(i)||s.addNode({id:i,data:{}}),o){var a=r[o],d=s.getRelatedEdges(a,"out").find((function(t){return t.target===i}));d?s.updateEdgeData(d.id,n(n({},d.data),{weight:Math.max(u(t,e,o),d.data.weight||0)})):s.addEdge({id:"e".concat(Math.random()),source:a,target:i,data:{weight:Math.max(u(t,e,o),0)}})}o=e}))})),s};var He=function(t,e,r){return function(n,o,i){var a=n.getNode(o),s=n.getNode(i),u=0,d=0;if(u+=a.data.width/2,a.data.hasOwnProperty("labelpos"))switch((a.data.labelpos||"").toLowerCase()){case"l":d=-a.data.width/2;break;case"r":d=a.data.width/2}if(d&&(u+=r?d:-d),d=0,u+=(a.data.dummy?e:t)/2,u+=(s.data.dummy?e:t)/2,u+=s.data.width/2,s.data.labelpos)switch((s.data.labelpos||"").toLowerCase()){case"l":d=s.data.width/2;break;case"r":d=-s.data.width/2}return d&&(u+=r?d:-d),d=0,u}},Ke=function(t,e){return t.getNode(e).data.width||0},Ye=function(t,e){var r,n=Kt(t);!function(t,e){var r=(e||{}).ranksep,n=void 0===r?0:r,o=Jt(t),i=0;null==o||o.forEach((function(e){var r=e.map((function(e){return t.getNode(e).data.height})),o=Math.max.apply(Math,u(u([],s(r),!1),[0],!1));null==e||e.forEach((function(e){t.getNode(e).data.y=i+o/2})),i+=o+n}))}(n,e);var o=function(t,e){var r=e||{},n=r.align,o=void 0===n?"":n,i=r.nodesep,a=void 0===i?0:i,d=r.edgesep,h=void 0===d?0:d,c=Jt(t),l=Object.assign(function(t,e){var r={};return(null==e?void 0:e.length)&&e.reduce((function(e,n){var o=0,i=0,a=e.length,s=null==n?void 0:n[(null==n?void 0:n.length)-1];return null==n||n.forEach((function(e,u){var d,h=We(t,e),c=h?t.getNode(h.id).data.order:a;(h||e===s)&&(null===(d=n.slice(i,u+1))||void 0===d||d.forEach((function(e){var n;null===(n=t.getPredecessors(e))||void 0===n||n.forEach((function(n){var i,a=t.getNode(n.id),s=a.data.order;!(s<o||c<s)||a.data.dummy&&(null===(i=t.getNode(e))||void 0===i?void 0:i.data.dummy)||Be(r,n.id,e)}))})),i=u+1,o=c)})),n})),r}(t,c),Ge(t,c)),f={},g=[];["u","d"].forEach((function(e){g="u"===e?c:Object.values(c).reverse(),["l","r"].forEach((function(r){"r"===r&&(g=g.map((function(t){return Object.values(t).reverse()})));var n=("u"===e?t.getPredecessors:t.getSuccessors).bind(t),o=function(t,e,r,n){var o={},i={},a={};return null==e||e.forEach((function(t){null==t||t.forEach((function(t,e){o[t]=t,i[t]=t,a[t]=e}))})),null==e||e.forEach((function(t){var e=-1;null==t||t.forEach((function(t){var s=n(t).map((function(t){return t.id}));if(s.length){s=s.sort((function(t,e){return a[t]-a[e]}));for(var u=(s.length-1)/2,d=Math.floor(u),h=Math.ceil(u);d<=h;++d){var c=s[d];i[t]===t&&e<a[c]&&!$e(r,t,c)&&(i[c]=t,i[t]=o[t]=o[c],e=a[c])}}}))})),{root:o,align:i}}(0,g,l,n),i=function(t,e,r,n,o,i,a){var s,u={},d=Ue(t,e,r,o,i,a),h=a?"borderLeft":"borderRight",c=function(t,e){for(var r=d.getAllNodes(),n=r.pop(),o={};n;)o[n.id]?t(n.id):(o[n.id]=!0,r.push(n),r=r.concat(e(n.id))),n=r.pop()};return c((function(t){u[t]=(d.getRelatedEdges(t,"in")||[]).reduce((function(t,e){return Math.max(t,(u[e.source]||0)+e.data.weight)}),0)}),d.getPredecessors.bind(d)),c((function(e){var r=(d.getRelatedEdges(e,"out")||[]).reduce((function(t,e){return Math.min(t,(u[e.target]||0)-e.data.weight)}),Number.POSITIVE_INFINITY),n=t.getNode(e);r!==Number.POSITIVE_INFINITY&&n.data.borderType!==h&&(u[e]=Math.max(u[e],r))}),d.getSuccessors.bind(d)),null===(s=Object.values(n))||void 0===s||s.forEach((function(t){u[t]=u[r[t]]})),u}(t,g,o.root,o.align,a,h,"r"===r);"r"===r&&Object.keys(i).forEach((function(t){return i[t]=-i[t]})),f[e+r]=i}))}));var p=function(t,e){return Zt(Object.values(e),(function(e){var r,n=Number.NEGATIVE_INFINITY,o=Number.POSITIVE_INFINITY;return null===(r=Object.keys(e))||void 0===r||r.forEach((function(r){var i=e[r],a=Ke(t,r)/2;n=Math.max(i+a,n),o=Math.min(i-a,o)})),n-o}))}(t,f);return p&&function(t,e){var r=Object.values(e),n=Math.min.apply(Math,u([],s(r),!1)),o=Math.max.apply(Math,u([],s(r),!1));["u","d"].forEach((function(r){["l","r"].forEach((function(i){var a,d=r+i,h=t[d];if(h!==e){var c=Object.values(h);(a="l"===i?n-Math.min.apply(Math,u([],s(c),!1)):o-Math.max.apply(Math,u([],s(c),!1)))&&(t[d]={},Object.keys(h).forEach((function(e){t[d][e]=h[e]+a})))}}))}))}(f,p),function(t,e){var r={};return Object.keys(t.ul).forEach((function(n){if(e)r[n]=t[e.toLowerCase()][n];else{var o=Object.values(t).map((function(t){return t[n]}));r[n]=(o[0]+o[1])/2}})),r}(f,o)}(n,e);null===(r=Object.keys(o))||void 0===r||r.forEach((function(t){n.getNode(t).data.x=o[t]}))},Je=function(t,e){var r=e.acyclicer,o=e.ranker,i=e.rankdir,a=void 0===i?"tb":i,d=e.nodeOrder,h=e.keepNodeOrder,c=e.align,l=void 0===c?"":c,g=e.nodesep,p=void 0===g?50:g,v=e.edgesep,y=void 0===v?20:v,m=e.ranksep,w=void 0===m?50:m;hr(t),$t(t,r);var x=function(t){var e=Ht(t,"root",{},"_root"),r=function(t){var e={},r=function(n,o){var i=t.getChildren(n);null==i||i.forEach((function(t){return r(t.id,o+1)})),e[n]=o};return t.getRoots().forEach((function(t){return r(t.id,1)})),e}(t),n=Math.max.apply(Math,u([],s(Object.values(r)),!1));Math.abs(n)===1/0&&(n=1);var o=n-1,i=2*o+1;t.getAllEdges().forEach((function(t){t.data.minlen*=i}));var a=function(t){var e=0;return t.getAllEdges().forEach((function(t){e+=t.data.weight})),e}(t)+1;return t.getRoots().forEach((function(n){be(t,e,i,a,o,r,n.id)})),{nestingRoot:e,nodeRankFactor:i}}(t),E=x.nestingRoot,b=x.nodeRankFactor;!function(t,e){switch(e){case"network-simplex":Ee(t);break;case"tight-tree":default:!function(t){!function(t){var e,r={},n=function(o){var i,a,s=t.getNode(o);return s?r[o]?s.data.rank:(r[o]=!0,null===(i=t.getRelatedEdges(o,"out"))||void 0===i||i.forEach((function(t){var e=n(t.target)-t.data.minlen;e&&(void 0===a||e<a)&&(a=e)})),a||(a=0),(void 0===e||a<e)&&(e=a),s.data.rank=a,a):0};t.getAllNodes().filter((function(e){return 0===t.getRelatedEdges(e.id,"in").length})).forEach((function(t){t&&n(t.id)})),void 0===e&&(e=0);var o={},i=function(e,r){var n,a=t.getNode(e),s=isNaN(a.data.layer)?r:a.data.layer;(void 0===a.data.rank||a.data.rank<s)&&(a.data.rank=s),o[e]||(o[e]=!0,null===(n=t.getRelatedEdges(e,"out"))||void 0===n||n.forEach((function(t){i(t.target,s+t.data.minlen)})))};t.getAllNodes().forEach((function(t){var r=t.data;r&&(isNaN(r.layer)?r.rank-=e:i(t.id,r.layer))}))}(t),function(t){var e,r,n=new f({tree:[]}),o=t.getAllNodes()[0],i=t.getAllNodes().length;for(n.addNode(o);ae(n,t)<i;)e=se(n,t),r=n.hasNode(e.source)?oe(t,e):-oe(t,e),ue(n,t,r)}(t)}(t);break;case"longest-path":xe(t)}}(Kt(t),o),rr(t),function(t,e){void 0===e&&(e=0);var r=t.getAllNodes(),n=r.filter((function(t){return void 0!==t.data.rank})).map((function(t){return t.data.rank})),o=Math.min.apply(Math,u([],s(n),!1)),i=[];r.forEach((function(t){var e=(t.data.rank||0)-o;i[e]||(i[e]=[]),i[e].push(t.id)}));for(var a=0,d=0;d<i.length;d++){var h=i[d];void 0===h?d%e!=0&&(a-=1):a&&(null==h||h.forEach((function(e){var r=t.getNode(e);r&&(r.data.rank=r.data.rank||0,r.data.rank+=a)})))}}(t,b),function(t,e){e&&t.removeNode(e),t.getAllEdges().forEach((function(e){e.data.nestingEdge&&t.removeEdge(e.id)}))}(t,E),function(t){var e=t.getAllNodes().filter((function(t){return void 0!==t.data.rank})).map((function(t){return t.data.rank})),r=Math.min.apply(Math,u([],s(e),!1));t.getAllNodes().forEach((function(t){t.data.hasOwnProperty("rank")&&r!==1/0&&(t.data.rank-=r)}))}(t),nr(t),or(t);var N=[];!function(t,e){t.getAllEdges().forEach((function(r){return function(t,e,r){var n=e.source,o=t.getNode(n).data.rank,i=e.target,a=t.getNode(i).data.rank,s=e.data.labelRank;if(a!==o+1){var u,d,h;for(t.removeEdge(e.id),h=0,++o;o<a;++h,++o)e.data.points=[],u=Ht(t,"edge",d={originalEdge:e,width:0,height:0,rank:o},"_d"),o===s&&(d.width=e.data.width,d.height=e.data.height,d.dummy=re,d.labelpos=e.data.labelpos),t.addEdge({id:"e".concat(Math.random()),source:n,target:u,data:{weight:e.data.weight}}),0===h&&r.push(u),n=u;t.addEdge({id:"e".concat(Math.random()),source:n,target:i,data:{weight:e.data.weight}})}}(t,r,e)}))}(t,N),function(t,e){var r=function(t){var e={},r=0,n=function(o){var i=r;t.getChildren(o).forEach((function(t){return n(t.id)})),e[o]={low:i,lim:r++}};return t.getRoots().forEach((function(t){return n(t.id)})),e}(t);e.forEach((function(e){var n,o,i=e,a=t.getNode(i),s=a.data.originalEdge;if(s)for(var u=function(t,e,r,n){var o,i,a,s,u=[],d=[],h=Math.min(e[r].low,e[n].low),c=Math.max(e[r].lim,e[n].lim);a=r;do{a=null===(o=t.getParent(a))||void 0===o?void 0:o.id,u.push(a)}while(a&&(e[a].low>h||c>e[a].lim));for(s=a,a=n;a&&a!==s;)d.push(a),a=null===(i=t.getParent(a))||void 0===i?void 0:i.id;return{lca:s,path:u.concat(d.reverse())}}(t,r,s.source,s.target),d=u.path,h=u.lca,c=0,l=d[c],f=!0;i!==s.target;){if(a=t.getNode(i),f){for(;l!==h&&(null===(n=t.getNode(l))||void 0===n?void 0:n.data.maxRank)<a.data.rank;)l=d[++c];l===h&&(f=!1)}if(!f){for(;c<d.length-1&&(null===(o=t.getNode(d[c+1]))||void 0===o?void 0:o.data.minRank)<=a.data.rank;)c++;l=d[c]}t.hasNode(l)&&t.setParent(i,l),i=t.getSuccessors(i)[0].id}}))}(t,N),function(t){var e=function(r){var n=t.getChildren(r),o=t.getNode(r);if((null==n?void 0:n.length)&&n.forEach((function(t){return e(t.id)})),o.data.hasOwnProperty("minRank")){o.data.borderLeft=[],o.data.borderRight=[];for(var i=o.data.minRank,a=o.data.maxRank+1;i<a;i+=1)Ne(t,"borderLeft","_bl",r,o,i),Ne(t,"borderRight","_br",r,o,i)}};t.getRoots().forEach((function(t){return e(t.id)}))}(t),h&&function(t,e){for(var r=t.getAllNodes().filter((function(e){var r;return!(null===(r=t.getChildren(e.id))||void 0===r?void 0:r.length)})).map((function(t){return t.data.rank})),n=Math.max.apply(Math,u([],s(r),!1)),o=[],i=0;i<n+1;i++)o[i]=[];null==e||e.forEach((function(e){var r=t.getNode(e);r&&!(null==r?void 0:r.data.dummy)&&(isNaN(r.data.rank)||(r.data.fixorder=o[r.data.rank].length,o[r.data.rank].push(e)))}))}(t,d),function(t,e){for(var r=Qt(t),n=[],o=[],i=1;i<r+1;i++)n.push(i);for(i=r-1;i>-1;i--)o.push(i);var a=je(t,n,"in"),s=je(t,o,"out"),u=Re(t);Ve(t,u);for(var d,h=Number.POSITIVE_INFINITY,c=(i=0,0);c<4;++i,++c)Fe(i%2?a:s,i%4>=2,!1,e),u=Jt(t),(l=_e(t,u))<h&&(c=0,d=qe(u),h=l);for(u=Re(t),Ve(t,u),i=0,c=0;c<4;++i,++c){var l;Fe(i%2?a:s,i%4>=2,!0,e),u=Jt(t),(l=_e(t,u))<h&&(c=0,d=qe(u),h=l)}Ve(t,d)}(t,h),cr(t),function(t,e){var r=e.toLowerCase();"lr"!==r&&"rl"!==r||Me(t)}(t,a),Ye(t,{align:l,nodesep:p,edgesep:y,ranksep:w}),lr(t),dr(t),function(t,e){e.forEach((function(e){var r,n=t.getNode(e),o=n.data.originalEdge;o&&t.addEdge(o);for(var i=e;n.data.dummy;)r=t.getSuccessors(i)[0],t.removeNode(i),o.data.points.push({x:n.data.x,y:n.data.y}),n.data.dummy===re&&(o.data.x=n.data.x,o.data.y=n.data.y,o.data.width=n.data.width,o.data.height=n.data.height),i=r.id,n=t.getNode(i)}))}(t,N),sr(t),function(t,e){var r=e.toLowerCase();"bt"!==r&&"rl"!==r||function(t){t.getAllNodes().forEach((function(t){ke(t.data)})),t.getAllEdges().forEach((function(t){var e;null===(e=t.data.points)||void 0===e||e.forEach((function(t){return ke(t)})),t.data.hasOwnProperty("y")&&ke(t.data)}))}(t),"lr"!==r&&"rl"!==r||(function(t){t.getAllNodes().forEach((function(t){Ae(t.data)})),t.getAllEdges().forEach((function(t){var e;null===(e=t.data.points)||void 0===e||e.forEach((function(t){return Ae(t)})),t.data.hasOwnProperty("x")&&Ae(t.data)}))}(t),Me(t))}(t,a);var M=ir(t),S=M.width,k=M.height;return ar(t),ur(t),function(t){t.getAllEdges().forEach((function(e){var r=e.data;if(r.reversed){t.removeEdge(e.id);var o=r.forwardName;delete r.reversed,delete r.forwardName,t.addEdge({id:e.id,source:e.target,target:e.source,data:n(n({},r),{forwardName:o})})}}))}(t),{width:S,height:k}},Xe=["width","height","layer","fixorder"],Qe={width:0,height:0},Ze=["minlen","weight","width","height","labeloffset"],tr={minlen:1,weight:1,width:0,height:0,labeloffset:10,labelpos:"r"},er=["labelpos"],rr=function(t){t.getAllEdges().forEach((function(e){if(e.data.width&&e.data.height){var r=t.getNode(e.source),n={e,rank:(t.getNode(e.target).data.rank-r.data.rank)/2+r.data.rank};Ht(t,"edge-proxy",n,"_ep")}}))},nr=function(t){var e=0;return t.getAllNodes().forEach((function(r){var n,o;r.data.borderTop&&(r.data.minRank=null===(n=t.getNode(r.data.borderTop))||void 0===n?void 0:n.data.rank,r.data.maxRank=null===(o=t.getNode(r.data.borderBottom))||void 0===o?void 0:o.data.rank,e=Math.max(e,r.data.maxRank||-1/0))})),e},or=function(t){t.getAllNodes().forEach((function(e){"edge-proxy"===e.data.dummy&&(t.getEdge(e.data.e.id).data.labelRank=e.data.rank,t.removeNode(e.id))}))},ir=function(t,e){var r,n,o=0,i=0,a=e||{},s=a.marginx,u=void 0===s?0:s,d=a.marginy,h=void 0===d?0:d,c=function(t){if(t.data){var e=t.data.x,a=t.data.y,s=t.data.width,u=t.data.height;isNaN(e)||isNaN(s)||(void 0===r&&(r=e-s/2),r=Math.min(r,e-s/2),o=Math.max(o,e+s/2)),isNaN(a)||isNaN(u)||(void 0===n&&(n=a-u/2),n=Math.min(n,a-u/2),i=Math.max(i,a+u/2))}};return t.getAllNodes().forEach((function(t){c(t)})),t.getAllEdges().forEach((function(t){(null==t?void 0:t.data.hasOwnProperty("x"))&&c(t)})),r-=u,n-=h,t.getAllNodes().forEach((function(t){t.data.x-=r,t.data.y-=n})),t.getAllEdges().forEach((function(t){var e;null===(e=t.data.points)||void 0===e||e.forEach((function(t){t.x-=r,t.y-=n})),t.data.hasOwnProperty("x")&&(t.data.x-=r),t.data.hasOwnProperty("y")&&(t.data.y-=n)})),{width:o-r+u,height:i-n+h}},ar=function(t){t.getAllEdges().forEach((function(e){var r,n,o=t.getNode(e.source),i=t.getNode(e.target);e.data.points?(r=e.data.points[0],n=e.data.points[e.data.points.length-1]):(e.data.points=[],r={x:i.data.x,y:i.data.y},n={x:o.data.x,y:o.data.y}),e.data.points.unshift(Yt(o.data,r)),e.data.points.push(Yt(i.data,n))}))},sr=function(t){t.getAllEdges().forEach((function(t){if(t.data.hasOwnProperty("x"))switch("l"!==t.data.labelpos&&"r"!==t.data.labelpos||(t.data.width-=t.data.labeloffset),t.data.labelpos){case"l":t.data.x-=t.data.width/2+t.data.labeloffset;break;case"r":t.data.x+=t.data.width/2+t.data.labeloffset}}))},ur=function(t){t.getAllEdges().forEach((function(t){var e;t.data.reversed&&(null===(e=t.data.points)||void 0===e||e.reverse())}))},dr=function(t){t.getAllNodes().forEach((function(e){var r,n,o;if(null===(r=t.getChildren(e.id))||void 0===r?void 0:r.length){var i=t.getNode(e.id),a=t.getNode(i.data.borderTop),s=t.getNode(i.data.borderBottom),u=t.getNode(i.data.borderLeft[(null===(n=i.data.borderLeft)||void 0===n?void 0:n.length)-1]),d=t.getNode(i.data.borderRight[(null===(o=i.data.borderRight)||void 0===o?void 0:o.length)-1]);i.data.width=Math.abs((null==d?void 0:d.data.x)-(null==u?void 0:u.data.x))||10,i.data.height=Math.abs((null==s?void 0:s.data.y)-(null==a?void 0:a.data.y))||10,i.data.x=((null==u?void 0:u.data.x)||0)+i.data.width/2,i.data.y=((null==a?void 0:a.data.y)||0)+i.data.height/2}})),t.getAllNodes().forEach((function(e){"border"===e.data.dummy&&t.removeNode(e.id)}))},hr=function(t){t.getAllEdges().forEach((function(e){if(e.source===e.target){var r=t.getNode(e.source);r.data.selfEdges||(r.data.selfEdges=[]),r.data.selfEdges.push(e),t.removeEdge(e.id)}}))},cr=function(t){var e=Jt(t);null==e||e.forEach((function(e){var r=0;null==e||e.forEach((function(e,n){var o,i=t.getNode(e);i.data.order=n+r,null===(o=i.data.selfEdges)||void 0===o||o.forEach((function(e){Ht(t,"selfedge",{width:e.data.width,height:e.data.height,rank:i.data.rank,order:n+ ++r,e},"_se")})),delete i.data.selfEdges}))}))},lr=function(t){t.getAllNodes().forEach((function(e){var r=t.getNode(e.id);if("selfedge"===r.data.dummy){var n=t.getNode(r.data.e.source),o=n.data.x+n.data.width/2,i=n.data.y,a=r.data.x-o,s=n.data.height/2;t.hasEdge(r.data.e.id)?t.updateEdgeData(r.data.e.id,r.data.e.data):t.addEdge({id:r.data.e.id,source:r.data.e.source,target:r.data.e.target,data:r.data.e.data}),t.removeNode(e.id),r.data.e.data.points=[{x:o+2*a/3,y:i-s},{x:o+5*a/6,y:i-s},{y:i,x:o+a},{x:o+5*a/6,y:i+s},{x:o+2*a/3,y:i+s}],r.data.e.data.x=r.data.x,r.data.e.data.y=r.data.y}}))},fr=function(t,e){var r={};return null==e||e.forEach((function(e){void 0!==t[e]&&(r[e]=+t[e])})),r},gr=function(t){void 0===t&&(t={});var e={};return Object.keys(t).forEach((function(r){e[r.toLowerCase()]=t[r]})),e},pr={rankdir:"TB",nodesep:50,ranksep:50,edgeLabelSpace:!0,controlPoints:!1,radial:!1,focusNode:null},vr=function(){function t(t){void 0===t&&(t={}),this.options=t,this.id="dagre",this.layoutNode=function(t){return!1!==t.data.layout},this.options=n(n({},pr),t)}return t.prototype.execute=function(t,e){return i(this,void 0,void 0,(function(){return a(this,(function(r){return[2,this.genericDagreLayout(!1,t,e)]}))}))},t.prototype.assign=function(t,e){return i(this,void 0,void 0,(function(){return a(this,(function(r){switch(r.label){case 0:return[4,this.genericDagreLayout(!0,t,e)];case 1:return r.sent(),[2]}}))}))},t.prototype.genericDagreLayout=function(t,e,r){return i(this,void 0,void 0,(function(){var o,i,s,u,d,h,c,l,g,p,v,y,m,w,x,b,M,S,A,I,_,D,O,P,T,z,C,L,q,j,F,V=this;return a(this,(function(a){return o=n(n({},this.options),r),i=o.nodeSize,s=o.rankdir,u=void 0===s?"TB":s,d=o.ranksep,h=o.nodesep,c=o.ranksepFunc,l=o.nodesepFunc,g=o.edgeLabelSpace,p=o.nodeOrder,v=o.begin,y=o.controlPoints,m=new f({tree:[]}),w=k(d||50,c),x=k(h||50,l),b=x,M=w,"LR"!==u&&"RL"!==u||(b=w,M=x),S=R(i,void 0),A=e.getAllNodes(),I=e.getAllEdges(),A.filter((function(t){return!1!==t.data.layout})).forEach((function(t){var e=S(t),r=M(t),n=e+2*b(t),o=e+2*r,i=t.data.layer;E(i)?m.addNode({id:t.id,data:{width:n,height:o,layer:i}}):m.addNode({id:t.id,data:{width:n,height:o}})})),I.forEach((function(t){V.layoutNode(m.getNode(t.source))&&V.layoutNode(m.getNode(t.target))&&m.addEdge({id:t.id,source:t.source,target:t.target,data:{weight:t.data.weight||1}})})),function(t,e){var r,o,i=e.edgeLabelSpace,a=e.keepNodeOrder,s=e.prevGraph,u=e.rankdir,d=e.ranksep;!a&&s&&(o=s,(r=t).getAllNodes().forEach((function(t){var e=r.getNode(t.id),n=o.getNode(t.id);void 0!==n?(e.data.fixorder=n.data._order,delete n.data._order):delete e.data.fixorder})));var h=function(t){var e=new f({tree:[]});return t.getAllNodes().forEach((function(r){var o=gr(t.getNode(r.id).data),i=n(n({},Qe),o),a=fr(i,Xe);e.hasNode(r.id)||e.addNode({id:r.id,data:n({},a)});var s=t.getParent(r.id);null==s||(e.hasNode(s.id)||e.addNode(n({},s)),e.setParent(r.id,s.id))})),t.getAllEdges().forEach((function(r){var n=gr(t.getEdge(r.id).data),o={};null==er||er.forEach((function(t){void 0!==n[t]&&(o[t]=n[t])})),e.addEdge({id:r.id,source:r.source,target:r.target,data:Object.assign({},tr,fr(n,Ze),o)})})),e}(t);!1!==i&&(e.ranksep=function(t,e){var r=e.ranksep,n=void 0===r?0:r,o=e.rankdir;return t.getAllNodes().forEach((function(t){isNaN(t.data.layer)||t.data.layer||(t.data.layer=0)})),t.getAllEdges().forEach((function(t){var e;t.data.minlen*=2,"c"!==(null===(e=t.data.labelpos)||void 0===e?void 0:e.toLowerCase())&&("TB"===o||"BT"===o?t.data.width+=t.data.labeloffset:t.data.height+=t.data.labeloffset)})),n/2}(h,{rankdir:u,ranksep:d}));try{Je(h,e)}catch(t){if("Not possible to find intersection inside of the rectangle"===t.message)return void 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:\\n",t);throw t}!function(t,e){t.getAllNodes().forEach((function(r){var n,o=t.getNode(r.id);if(o){var i=e.getNode(r.id);o.data.x=i.data.x,o.data.y=i.data.y,o.data._order=i.data.order,o.data._rank=i.data.rank,(null===(n=e.getChildren(r.id))||void 0===n?void 0:n.length)&&(o.data.width=i.data.width,o.data.height=i.data.height)}})),t.getAllEdges().forEach((function(r){var n=t.getEdge(r.id),o=e.getEdge(r.id);n.data.points=o?o.data.points:[],o&&o.data.hasOwnProperty("x")&&(n.data.x=o.data.x,n.data.y=o.data.y)}))}(t,h)}(m,{prevGraph:null,edgeLabelSpace:g,keepNodeOrder:!!p,nodeOrder:p||[],acyclicer:"greedy",ranker:"network-simplex",rankdir:u,nodesep:h}),_=[0,0],v&&(D=1/0,O=1/0,m.getAllNodes().forEach((function(t){D>t.data.x&&(D=t.data.x),O>t.data.y&&(O=t.data.y)})),m.getAllEdges().forEach((function(t){var e;null===(e=t.data.points)||void 0===e||e.forEach((function(t){D>t.x&&(D=t.x),O>t.y&&(O=t.y)}))})),_[0]=v[0]-D,_[1]=v[1]-O),P="LR"===u||"RL"===u,T=new Set,z="BT"===u||"RL"===u?function(t,e){return e-t}:function(t,e){return t-e},m.getAllNodes().forEach((function(t){t.data.x=t.data.x+_[0],t.data.y=t.data.y+_[1],T.add(P?t.data.x:t.data.y)})),C=Array.from(T).sort(z),L=P?function(t,e){return t.x!==e.x}:function(t,e){return t.y!==e.y},q=P?function(t,e,r){var n=Math.max(e.y,r.y),o=Math.min(e.y,r.y);return t.filter((function(t){return t.y<=n&&t.y>=o}))}:function(t,e,r){var n=Math.max(e.x,r.x),o=Math.min(e.x,r.x);return t.filter((function(t){return t.x<=n&&t.x>=o}))},m.getAllEdges().forEach((function(t,e){var r;g&&y&&"loop"!==t.data.type&&(t.data.controlPoints=yr(t.data.points,m.getNode(t.source),m.getNode(t.target),C,P,L,q),null===(r=t.data.controlPoints)||void 0===r||r.forEach((function(t){t.x+=_[0],t.y+=_[1]})))})),j=[],j=m.getAllNodes().map((function(t){return N(t)})),F=m.getAllEdges(),t&&(j.forEach((function(t){e.mergeNodeData(t.id,{x:t.data.x,y:t.data.y})})),F.forEach((function(t){e.mergeEdgeData(t.id,{controlPoints:t.data.controlPoints})}))),[2,{nodes:j,edges:F}]}))}))},t}(),yr=function(t,e,r,n,o,i,a){var s=(null==t?void 0:t.slice(1,t.length-1))||[];if(e&&r){var u=e.data,d=u.x,h=u.y,c=r.data,l=c.x,f=c.y;if(o&&(d=e.data.y,h=e.data.x,l=r.data.y,f=r.data.x),f!==h&&d!==l){var g=n.indexOf(h),p=n[g+1];if(p){var v=s[0],y=o?{x:(h+p)/2,y:(null==v?void 0:v.y)||l}:{x:(null==v?void 0:v.x)||l,y:(h+p)/2};v&&!i(v,y)||s.unshift(y)}var m=n.indexOf(f),w=Math.abs(m-g);if(1===w)(s=a(s,e.data,r.data)).length||s.push(o?{x:(h+f)/2,y:d}:{x:d,y:(h+f)/2});else if(w>1){var x=n[m-1];if(x){var E=s[s.length-1],b=o?{x:(f+x)/2,y:(null==E?void 0:E.y)||l}:{x:(null==E?void 0:E.x)||d,y:(f+x)/2};E&&!i(E,b)||s.push(b)}}}}return s};function mr(t){var e=0,r=0,n=0;if(t.length){for(var o=0;o<4;o++)(i=t[o])&&i.weight&&(e+=i.weight,r+=i.x*i.weight,n+=i.y*i.weight);t.x=r/e,t.y=n/e,t.weight=e}else{var i=t;t.x=i.data.x,t.y=i.data.y,t.weight=i.data.weight}}var wr=function(t,e,r,n,o,i){var a=i.x-t.x||.1,s=i.y-t.y||.1,u=n-e,d=a*a+s*s,h=Math.sqrt(d)*d;if(u*u*.81<d){var c=t.weight/h;return i.vx+=a*c,i.vy+=s*c,!0}if(t.length)return!1;t.data!==i&&(c=t.data.weight/h,i.vx+=a*c,i.vy+=s*c)},xr={maxIteration:500,gravity:10,factor:1,edgeStrength:200,nodeStrength:1e3,coulombDisScale:.005,damping:.9,maxSpeed:500,minMovement:.4,interval:.02,linkDistance:200,clusterNodeStrength:20,preventOverlap:!0,distanceThresholdMode:"mean"},Er=function(){function t(t){void 0===t&&(t={}),this.options=t,this.id="force",this.timeInterval=0,this.judgingDistance=0,this.running=!1,this.options=n(n({},xr),t)}return t.prototype.execute=function(t,e){return i(this,void 0,void 0,(function(){return a(this,(function(r){return[2,this.genericForceLayout(!1,t,e)]}))}))},t.prototype.assign=function(t,e){return i(this,void 0,void 0,(function(){return a(this,(function(r){return this.genericForceLayout(!0,t,e),[2]}))}))},t.prototype.stop=function(){this.timeInterval&&"undefined"!=typeof window&&window.clearInterval(this.timeInterval),this.running=!1},t.prototype.tick=function(t){var e=this;if(void 0===t&&(t=this.options.maxIteration||1),this.lastResult)return this.lastResult;for(var r=0;(this.judgingDistance>this.lastOptions.minMovement||r<1)&&r<t;r++)this.runOneStep(this.lastCalcGraph,this.lastGraph,r,this.lastVelMap,this.lastOptions),this.updatePosition(this.lastGraph,this.lastCalcGraph,this.lastVelMap,this.lastOptions);var n={nodes:this.lastLayoutNodes,edges:this.lastLayoutEdges};return this.lastAssign&&n.nodes.forEach((function(t){return e.lastGraph.mergeNodeData(t.id,{x:t.data.x,y:t.data.y})})),n},t.prototype.genericForceLayout=function(t,e,r){return i(this,void 0,void 0,(function(){var o,i,s,u,d,h,c,l,g,p,v,y,m,w,x,b,N,M,S,k=this;return a(this,(function(a){return o=n(n({},this.options),r),i=e.getAllNodes(),s=e.getAllEdges(),u=this.formatOptions(o,e),d=u.width,h=u.height,c=u.nodeSize,l=u.getMass,g=u.nodeStrength,p=u.edgeStrength,v=u.linkDistance,y=i.map((function(t){return n(n({},t),{data:n(n({},t.data),{x:E(t.data.x)?t.data.x:Math.random()*d,y:E(t.data.y)?t.data.y:Math.random()*h,size:c(t)||30,mass:l(t),nodeStrength:g(t)})})})),m=s.map((function(t){return n(n({},t),{data:n(n({},t.data),{edgeStrength:p(t),linkDistance:v(t,e.getNode(t.source),e.getNode(t.target))})})})),(null==i?void 0:i.length)?(w={},i.forEach((function(t,e){w[t.id]={x:0,y:0}})),x=new f({nodes:y,edges:m}),this.formatCentripetal(u,x),b=u.maxIteration,N=u.minMovement,M=u.onTick,this.lastLayoutNodes=y,this.lastLayoutEdges=m,this.lastAssign=t,this.lastGraph=e,this.lastCalcGraph=x,this.lastOptions=u,this.lastVelMap=w,"undefined"==typeof window?[2]:(S=0,[2,new Promise((function(r){k.timeInterval=window.setInterval((function(){i&&k.running||r({nodes:kr(e,y),edges:s}),k.runOneStep(x,e,S,w,u),k.updatePosition(e,x,w,u),t&&y.forEach((function(t){return e.mergeNodeData(t.id,{x:t.data.x,y:t.data.y})})),null==M||M({nodes:kr(e,y),edges:s}),(++S>=b||k.judgingDistance<N)&&(window.clearInterval(k.timeInterval),r({nodes:kr(e,y),edges:s}))}),0),k.running=!0}))])):(this.lastResult={nodes:[],edges:s},[2,{nodes:[],edges:s}])}))}))},t.prototype.formatOptions=function(t,e){var r=t,n=t.width,o=t.height,i=t.getMass;if(r.width=n||"undefined"==typeof window?n:window.innerWidth,r.height=o||"undefined"==typeof window?o:window.innerHeight,t.center||(r.center=[r.width/2,r.height/2]),i||(r.getMass=function(t){var r=1;E(null==t?void 0:t.data.mass)&&(r=null==t?void 0:t.data.mass);var n=e.getDegree(t.id,"both");return!n||n<5?r:5*n*r}),t.preventOverlap){var a=k(0,t.nodeSpacing);t.nodeSize?p(t.nodeSize)?r.nodeSize=function(e){var r=t.nodeSize;return Math.max(r[0],r[1])+a(e)}:r.nodeSize=function(e){return t.nodeSize+a(e)}:r.nodeSize=function(t){var e=((null==t?void 0:t.data)||{}).size;return e?p(e)?Math.max(e[0],e[1])+a(t):S(e)?Math.max(e.width,e.height)+a(t):e+a(t):10+a(t)}}return r.linkDistance=t.linkDistance?k(1,t.linkDistance):function(t){return 1+r.nodeSize(e.getNode(t.source))+r.nodeSize(e.getNode(t.target))},r.nodeStrength=k(1,t.nodeStrength),r.edgeStrength=k(1,t.edgeStrength),t},t.prototype.formatCentripetal=function(t,e){var r,n=t.centripetalOptions,o=t.center,i=t.clusterNodeStrength,a=t.leafCluster,s=t.clustering,u=t.nodeClusterBy,d=e.getAllNodes(),h=n||{leaf:2,single:2,others:1,center:function(t){return{x:o[0],y:o[1]}}};"function"!=typeof i&&(t.clusterNodeStrength=function(t){return i});var c=[];if(a&&u&&(r=br(e,u),c=Array.from(new Set(null==d?void 0:d.map((function(t){return t.data[u]}))))||[],t.centripetalOptions=Object.assign(h,{single:100,leaf:function(e){var n=r[e.id]||{},o=n.siblingLeaves,i=n.sameTypeLeaves;return(null==i?void 0:i.length)===(null==o?void 0:o.length)||1===(null==c?void 0:c.length)?1:t.clusterNodeStrength(e)},others:1,center:function(t){var n,o=e.getDegree(t.id,"both");if(!o)return{x:100,y:100};if(1===o){var i=(r[t.id]||{}).sameTypeLeaves,a=void 0===i?[]:i;1===a.length?n=void 0:a.length>1&&(n=Sr(a))}else n=void 0;return{x:null==n?void 0:n.x,y:null==n?void 0:n.y}}})),s&&u){r||(r=br(e,u)),c||(c=Array.from(new Set(d.map((function(t){return t.data[u]}))))),c=c.filter((function(t){return void 0!==t}));var l={};c.forEach((function(t){var r=d.filter((function(e){return e.data[u]===t})).map((function(t){return e.getNode(t.id)}));l[t]=Sr(r)})),t.centripetalOptions=Object.assign(h,{single:function(e){return t.clusterNodeStrength(e)},leaf:function(e){return t.clusterNodeStrength(e)},others:function(e){return t.clusterNodeStrength(e)},center:function(t){var e=l[t.data[u]];return{x:null==e?void 0:e.x,y:null==e?void 0:e.y}}})}var f=t.centripetalOptions||{},g=f.leaf,p=f.single,v=f.others;g&&"function"!=typeof g&&(t.centripetalOptions.leaf=function(){return g}),p&&"function"!=typeof p&&(t.centripetalOptions.single=function(){return p}),v&&"function"!=typeof v&&(t.centripetalOptions.others=function(){return v})},t.prototype.runOneStep=function(t,e,r,n,o){var i={},a=t.getAllNodes(),s=t.getAllEdges();if(null==a?void 0:a.length){var u=o.monitor;this.calRepulsive(t,i,o),s&&this.calAttractive(t,i),this.calGravity(t,e,i,o),this.updateVelocity(t,i,n,o),u&&u({energy:this.calTotalEnergy(i,a),nodes:e.getAllNodes(),edges:e.getAllEdges(),iterations:r})}},t.prototype.calTotalEnergy=function(t,e){if(!(null==e?void 0:e.length))return 0;var r=0;return e.forEach((function(e,n){var o=t[e.id].x,i=t[e.id].y,a=o*o+i*i,s=e.data.mass;r+=(void 0===s?1:s)*a*.5})),r},t.prototype.calRepulsive=function(t,e,r){var n=r.factor,o=r.coulombDisScale;!function(t,e,r,n){var o=e/r,i=t.getAllNodes(),a=i.map((function(t,e){var r=t.data,n=r.nodeStrength;return{x:r.x,y:r.y,size:r.size,index:e,vx:0,vy:0,weight:o*n}})),s=V(a,(function(t){return t.x}),(function(t){return t.y})).visitAfter(mr);a.forEach((function(t){!function(t,e){e.visit((function(e,r,n,o,i){return wr(e,r,n,o,i,t)}))}(t,s)})),a.map((function(t,e){var r=i[e],o=r.id,a=r.data.mass,s=void 0===a?1:a;n[o]={x:t.vx/s,y:t.vy/s}}))}(t,n,o*o,e)},t.prototype.calAttractive=function(t,e){t.getAllEdges().forEach((function(r,n){var o=r.source,i=r.target,a=t.getNode(o),s=t.getNode(i);if(a&&s){var u=s.data.x-a.data.x,d=s.data.y-a.data.y;u||d||(u=.01*Math.random(),d=.01*Math.random());var h=Math.sqrt(u*u+d*d),c=u/h,l=d/h,f=r.data||{},g=f.linkDistance,p=void 0===g?200:g,v=f.edgeStrength,y=(p-h)*(void 0===v?200:v),m=1/(a.data.mass||1),w=1/(s.data.mass||1),x=c*y,E=l*y;e[o].x-=x*m,e[o].y-=E*m,e[i].x+=x*w,e[i].y+=E*w}}))},t.prototype.calGravity=function(t,e,r,n){var o=n.getCenter,i=t.getAllNodes(),a=e.getAllNodes(),u=e.getAllEdges(),d=n.width,h=n.height,c=n.center,l=n.gravity,f=n.centripetalOptions;i&&i.forEach((function(n){var i=n.id,g=n.data,p=g.mass,v=g.x,y=g.y,m=e.getNode(i),w=0,x=0,b=l,N=t.getDegree(i,"in"),M=t.getDegree(i,"out"),S=t.getDegree(i,"both"),k=null==o?void 0:o(m,S);if(k){var A=s(k,3);w=v-A[0],x=y-A[1],b=A[2]}else w=v-c[0],x=y-c[1];if(b&&(r[i].x-=b*w/p,r[i].y-=b*x/p),f){var R=f.leaf,I=f.single,_=f.others,D=f.center,O=(null==D?void 0:D(m,a,u,d,h))||{x:0,y:0,centerStrength:0},P=O.x,T=O.y,z=O.centerStrength;if(!E(P)||!E(T))return;var C=(v-P)/p,L=(y-T)/p;if(z&&(r[i].x-=z*C,r[i].y-=z*L),0===S){var q=I(m);if(!q)return;return r[i].x-=q*C,void(r[i].y-=q*L)}if(0===N||0===M){var j=R(m,a,u);if(!j)return;return r[i].x-=j*C,void(r[i].y-=j*L)}var F=_(m);if(!F)return;r[i].x-=F*C,r[i].y-=F*L}}))},t.prototype.updateVelocity=function(t,e,r,n){var o=n.damping,i=n.maxSpeed,a=n.interval,s=t.getAllNodes();(null==s?void 0:s.length)&&s.forEach((function(t){var n=t.id,s=(r[n].x+e[n].x*a)*o||.01,u=(r[n].y+e[n].y*a)*o||.01,d=Math.sqrt(s*s+u*u);if(d>i){var h=i/d;s*=h,u*=h}r[n]={x:s,y:u}}))},t.prototype.updatePosition=function(t,e,r,n){var o=this,i=n.distanceThresholdMode,a=n.interval,s=e.getAllNodes();if(null==s?void 0:s.length){var u=0;"max"===i?this.judgingDistance=-1/0:"min"===i&&(this.judgingDistance=1/0),s.forEach((function(n){var s=n.id,d=t.getNode(s);if(E(d.data.fx)&&E(d.data.fy))e.mergeNodeData(s,{x:d.data.fx,y:d.data.fy});else{var h=r[s].x*a,c=r[s].y*a;e.mergeNodeData(s,{x:n.data.x+h,y:n.data.y+c});var l=Math.sqrt(h*h+c*c);switch(i){case"max":o.judgingDistance<l&&(o.judgingDistance=l);break;case"min":o.judgingDistance>l&&(o.judgingDistance=l);break;default:u+=l}}})),i&&"mean"!==i||(this.judgingDistance=u/s.length)}else this.judgingDistance=0},t}(),br=function(t,e){var r=t.getAllNodes();if(!(null==r?void 0:r.length))return{};var n={};return r.forEach((function(r,o){1===t.getDegree(r.id,"both")&&(n[r.id]=Nr(t,"leaf",r,e))})),n},Nr=function(t,e,r,n){var o=t.getDegree(r.id,"in"),i=t.getDegree(r.id,"out"),a=r,s=[];return 0===o?(a=t.getSuccessors(r.id)[0],s=t.getNeighbors(a.id)):0===i&&(a=t.getPredecessors(r.id)[0],s=t.getNeighbors(a.id)),s=s.filter((function(e){return 0===t.getDegree(e.id,"in")||0===t.getDegree(e.id,"out")})),{coreNode:a,siblingLeaves:s,sameTypeLeaves:Mr(t,e,n,r,s)}},Mr=function(t,e,r,n,o){var i=n.data[r]||"",a=(null==o?void 0:o.filter((function(t){return t.data[r]===i})))||[];return"leaf"===e&&(a=a.filter((function(e){return 0===t.getDegree(e.id,"in")||0===t.getDegree(e.id,"out")}))),a},Sr=function(t){var e={x:0,y:0};t.forEach((function(t){var r=t.data,n=r.x,o=r.y;e.x+=n||0,e.y+=o||0}));var r=t.length||1;return{x:e.x/r,y:e.y/r}},kr=function(t,e){return e.map((function(e){var r=e.id,o=e.data,i=t.getNode(r);return n(n({},i),{data:n(n({},i.data),{x:o.x,y:o.y})})}))},Ar=function(){function t(t){this.id=t.id||0,this.rx=t.rx,this.ry=t.ry,this.fx=0,this.fy=0,this.mass=t.mass,this.degree=t.degree,this.g=t.g||0}return t.prototype.distanceTo=function(t){var e=this.rx-t.rx,r=this.ry-t.ry;return Math.hypot(e,r)},t.prototype.setPos=function(t,e){this.rx=t,this.ry=e},t.prototype.resetForce=function(){this.fx=0,this.fy=0},t.prototype.addForce=function(t){var e=t.rx-this.rx,r=t.ry-this.ry,n=Math.hypot(e,r);n=n<1e-4?1e-4:n;var o=this.g*(this.degree+1)*(t.degree+1)/n;this.fx+=o*e/n,this.fy+=o*r/n},t.prototype.in=function(t){return t.contains(this.rx,this.ry)},t.prototype.add=function(e){var r=this.mass+e.mass;return new t({rx:(this.rx*this.mass+e.rx*e.mass)/r,ry:(this.ry*this.mass+e.ry*e.mass)/r,mass:r,degree:this.degree+e.degree})},t}();const Rr=Ar;const Ir=function(){function t(t){this.xmid=t.xmid,this.ymid=t.ymid,this.length=t.length,this.massCenter=t.massCenter||[0,0],this.mass=t.mass||1}return t.prototype.getLength=function(){return this.length},t.prototype.contains=function(t,e){var r=this.length/2;return t<=this.xmid+r&&t>=this.xmid-r&&e<=this.ymid+r&&e>=this.ymid-r},t.prototype.NW=function(){return new t({xmid:this.xmid-this.length/4,ymid:this.ymid+this.length/4,length:this.length/2})},t.prototype.NE=function(){return new t({xmid:this.xmid+this.length/4,ymid:this.ymid+this.length/4,length:this.length/2})},t.prototype.SW=function(){return new t({xmid:this.xmid-this.length/4,ymid:this.ymid-this.length/4,length:this.length/2})},t.prototype.SE=function(){return new t({xmid:this.xmid+this.length/4,ymid:this.ymid-this.length/4,length:this.length/2})},t}(),_r=function(){function t(t){this.body=null,this.quad=null,this.NW=null,this.NE=null,this.SW=null,this.SE=null,this.theta=.5,null!=t&&(this.quad=t)}return t.prototype.insert=function(e){null!=this.body?this._isExternal()?(this.quad&&(this.NW=new t(this.quad.NW()),this.NE=new t(this.quad.NE()),this.SW=new t(this.quad.SW()),this.SE=new t(this.quad.SE())),this._putBody(this.body),this._putBody(e),this.body=this.body.add(e)):(this.body=this.body.add(e),this._putBody(e)):this.body=e},t.prototype._putBody=function(t){this.quad&&(t.in(this.quad.NW())&&this.NW?this.NW.insert(t):t.in(this.quad.NE())&&this.NE?this.NE.insert(t):t.in(this.quad.SW())&&this.SW?this.SW.insert(t):t.in(this.quad.SE())&&this.SE&&this.SE.insert(t))},t.prototype._isExternal=function(){return null==this.NW&&null==this.NE&&null==this.SW&&null==this.SE},t.prototype.updateForce=function(t){null!=this.body&&t!==this.body&&(this._isExternal()||(this.quad?this.quad.getLength():0)/this.body.distanceTo(t)<this.theta?t.addForce(this.body):(this.NW&&this.NW.updateForce(t),this.NE&&this.NE.updateForce(t),this.SW&&this.SW.updateForce(t),this.SE&&this.SE.updateForce(t)))},t}();var Dr={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},Or=function(){function t(t){void 0===t&&(t={}),this.options=t,this.id="forceAtlas2",this.options=n(n({},Dr),t)}return t.prototype.execute=function(t,e){return i(this,void 0,void 0,(function(){return a(this,(function(r){return[2,this.genericForceAtlas2Layout(!1,t,e)]}))}))},t.prototype.assign=function(t,e){return i(this,void 0,void 0,(function(){return a(this,(function(r){return this.genericForceAtlas2Layout(!0,t,e),[2]}))}))},t.prototype.genericForceAtlas2Layout=function(t,e,r){return i(this,void 0,void 0,(function(){var o,i,s,u,d,h,c,l,g,p,v,y,m,w,x,E,b,M,S,k,A,R;return a(this,(function(a){if(o=e.getAllEdges(),i=e.getAllNodes(),s=this.formatOptions(r,i.length),u=s.width,d=s.height,h=s.prune,c=s.maxIteration,l=s.nodeSize,g=s.center,!(null==i?void 0:i.length)||1===i.length)return[2,I(e,t,g)];if(p=i.map((function(t){return N(t,[u,d])})),v=o.filter((function(t){return t.source!==t.target})),y=new f({nodes:p,edges:v}),m=this.getSizes(y,e,l),this.run(y,e,c,m,t,s),h){for(w=0;w<v.length;w+=1)x=v[w],E=x.source,b=x.target,M=y.getDegree(E),S=y.getDegree(E),M<=1?(k=y.getNode(b),y.mergeNodeData(E,{x:k.data.x,y:k.data.y})):S<=1&&(A=y.getNode(E),y.mergeNodeData(b,{x:A.data.x,y:A.data.y}));R=n(n({},s),{prune:!1,barnesHut:!1}),this.run(y,e,100,m,t,R)}return[2,{nodes:p,edges:o}]}))}))},t.prototype.getSizes=function(t,e,r){for(var n=t.getAllNodes(),o={},i=0;i<n.length;i+=1){var a=n[i],d=a.id,h=a.data;if(o[d]=10,E(h.size))o[d]=h.size;else if(p(h.size))isNaN(h.size[0])||(o[d]=Math.max(h.size[0])),isNaN(h.size[1])||(o[d]=Math.max(h.size[1]));else if(S(h.size))o[d]=Math.max(h.size.width,h.size.height);else if(M(r)){var c=r(e.getNode(d));p(c)?o[d]=Math.max.apply(Math,u([],s(c),!1)):o[d]=c}else p(r)?o[d]=Math.max.apply(Math,u([],s(r),!1)):E(r)&&(o[d]=r)}return o},t.prototype.formatOptions=function(t,e){void 0===t&&(t={});var r=n(n({},this.options),t),o=r.center,i=r.width,a=r.height,s=r.barnesHut,u=r.prune,d=r.maxIteration,h=r.kr,c=r.kg;return r.width=i||"undefined"==typeof window?i:window.innerWidth,r.height=a||"undefined"==typeof window?a:window.innerHeight,r.center=o||[r.width/2,r.height/2],void 0===s&&e>250&&(r.barnesHut=!0),void 0===u&&e>100&&(r.prune=!0),0!==d||u?0===d&&u&&(r.maxIteration=100,e<=200&&e>100?r.maxIteration=500:e>200&&(r.maxIteration=950)):(r.maxIteration=250,e<=200&&e>100?r.maxIteration=1e3:e>200&&(r.maxIteration=1200)),h||(r.kr=50,e>100&&e<=500?r.kr=20:e>500&&(r.kr=1)),c||(r.kg=20,e>100&&e<=500?r.kg=10:e>500&&(r.kg=1)),r},t.prototype.run=function(t,e,r,n,o,i){for(var a=i.kr,s=i.barnesHut,u=i.onTick,d=t.getAllNodes(),h=0,c=r,l={},f={},g={},p=0;p<d.length;p+=1){var v=d[p],y=v.data,m=v.id;if(l[m]=[0,0],s){var w={id:p,rx:y.x,ry:y.y,mass:1,g:a,degree:t.getDegree(m)};g[m]=new Rr(w)}}for(;c>0;)h=this.oneStep(t,{iter:c,preventOverlapIters:50,krPrime:100,sg:h,forces:l,preForces:f,bodies:g,sizes:n},i),c--,null==u||u({nodes:d,edges:e.getAllEdges()});return t},t.prototype.oneStep=function(t,e,r){for(var n=e.iter,o=e.preventOverlapIters,i=e.krPrime,a=e.sg,d=e.preForces,h=e.bodies,c=e.sizes,l=e.forces,f=r.preventOverlap,g=r.barnesHut,p=t.getAllNodes(),v=0;v<p.length;v+=1){var y=p[v].id;d[y]=u([],s(l[y]),!1),l[y]=[0,0]}return l=this.getAttrForces(t,n,o,c,l,r),l=g&&(f&&n>o||!f)?this.getOptRepGraForces(t,l,h,r):this.getRepGraForces(t,n,o,l,i,c,r),this.updatePos(t,l,d,a,r)},t.prototype.getAttrForces=function(t,e,r,n,o,i){for(var a=i.preventOverlap,s=i.dissuadeHubs,u=i.mode,d=i.prune,h=t.getAllEdges(),c=0;c<h.length;c+=1){var l=h[c],f=l.source,g=l.target,p=t.getNode(f),v=t.getNode(g),y=t.getDegree(f),m=t.getDegree(g);if(!d||!(y<=1||m<=1)){var w=[v.data.x-p.data.x,v.data.y-p.data.y],x=Math.hypot(w[0],w[1]);x=x<1e-4?1e-4:x,w[0]=w[0]/x,w[1]=w[1]/x,a&&e<r&&(x=x-n[f]-n[g]);var E=x,b=E;"linlog"===u&&(b=E=Math.log(1+x)),s&&(E=x/y,b=x/m),a&&e<r&&x<=0?(E=0,b=0):a&&e<r&&x>0&&(E=x,b=x),o[f][0]+=E*w[0],o[g][0]-=b*w[0],o[f][1]+=E*w[1],o[g][1]-=b*w[1]}}return o},t.prototype.getOptRepGraForces=function(t,e,r,n){for(var o=n.kg,i=n.center,a=n.prune,s=t.getAllNodes(),u=s.length,d=9e10,h=-9e10,c=9e10,l=-9e10,f=0;f<u;f+=1){var g=s[f],p=g.id,v=g.data;a&&t.getDegree(p)<=1||(r[p].setPos(v.x,v.y),v.x>=h&&(h=v.x),v.x<=d&&(d=v.x),v.y>=l&&(l=v.y),v.y<=c&&(c=v.y))}var y=Math.max(h-d,l-c),m=new Ir({xmid:(h+d)/2,ymid:(l+c)/2,length:y,massCenter:i,mass:u}),w=new _r(m);for(f=0;f<u;f+=1)p=s[f].id,a&&t.getDegree(p)<=1||r[p].in(m)&&w.insert(r[p]);for(f=0;f<u;f+=1){var x=s[f],E=(p=x.id,v=x.data,t.getDegree(p));if(!(a&&E<=1)){r[p].resetForce(),w.updateForce(r[p]),e[p][0]-=r[p].fx,e[p][1]-=r[p].fy;var b=[v.x-i[0],v.y-i[1]],N=Math.hypot(b[0],b[1]);N=N<1e-4?1e-4:N,b[0]=b[0]/N,b[1]=b[1]/N;var M=o*(E+1);e[p][0]-=M*b[0],e[p][1]-=M*b[1]}}return e},t.prototype.getRepGraForces=function(t,e,r,n,o,i,a){for(var s=a.preventOverlap,u=a.kr,d=a.kg,h=a.center,c=a.prune,l=t.getAllNodes(),f=l.length,g=0;g<f;g+=1){for(var p=l[g],v=t.getDegree(p.id),y=g+1;y<f;y+=1){var m=l[y],w=t.getDegree(m.id);if(!c||!(v<=1||w<=1)){var x=[m.data.x-p.data.x,m.data.y-p.data.y],E=Math.hypot(x[0],x[1]);E=E<1e-4?1e-4:E,x[0]=x[0]/E,x[1]=x[1]/E,s&&e<r&&(E=E-i[p.id]-i[m.id]);var b=u*(v+1)*(w+1)/E;s&&e<r&&E<0?b=o*(v+1)*(w+1):s&&e<r&&0===E?b=0:s&&e<r&&E>0&&(b=u*(v+1)*(w+1)/E),n[p.id][0]-=b*x[0],n[m.id][0]+=b*x[0],n[p.id][1]-=b*x[1],n[m.id][1]+=b*x[1]}}var N=[p.data.x-h[0],p.data.y-h[1]],M=Math.hypot(N[0],N[1]);N[0]=N[0]/M,N[1]=N[1]/M;var S=d*(v+1);n[p.id][0]-=S*N[0],n[p.id][1]-=S*N[1]}return n},t.prototype.updatePos=function(t,e,r,n,o){for(var i=o.ks,a=o.tao,s=o.prune,u=o.ksmax,d=t.getAllNodes(),h=d.length,c=[],l=[],f=0,g=0,p=n,v=0;v<h;v+=1){var y=d[v].id,m=t.getDegree(y);if(!(s&&m<=1)){var w=[e[y][0]-r[y][0],e[y][1]-r[y][1]],x=Math.hypot(w[0],w[1]),b=[e[y][0]+r[y][0],e[y][1]+r[y][1]],N=Math.hypot(b[0],b[1]);c[v]=x,l[v]=N/2,f+=(m+1)*c[v],g+=(m+1)*l[v]}}var M=p;for(p=a*g/f,0!==M&&(p=p>1.5*M?1.5*M:p),v=0;v<h;v+=1){var S=d[v],k=(y=S.id,S.data);if(m=t.getDegree(y),!(s&&m<=1||E(k.fx)&&E(k.fy))){var A=i*p/(1+p*Math.sqrt(c[v])),R=Math.hypot(e[y][0],e[y][1]),I=u/(R=R<1e-4?1e-4:R),_=(A=A>I?I:A)*e[y][0],D=A*e[y][1];t.mergeNodeData(y,{x:k.x+_,y:k.y+D})}}return p},t}(),Pr={maxIteration:1e3,gravity:10,speed:5,clustering:!1,clusterGravity:10,width:300,height:300,nodeClusterBy:"cluster"},Tr=function(){function t(t){void 0===t&&(t={}),this.options=t,this.id="fruchterman",this.timeInterval=0,this.running=!1,this.options=n(n({},Pr),t)}return t.prototype.execute=function(t,e){return i(this,void 0,void 0,(function(){return a(this,(function(r){return[2,this.genericFruchtermanLayout(!1,t,e)]}))}))},t.prototype.assign=function(t,e){return i(this,void 0,void 0,(function(){return a(this,(function(r){return this.genericFruchtermanLayout(!0,t,e),[2]}))}))},t.prototype.stop=function(){this.timeInterval&&"undefined"!=typeof window&&window.clearInterval(this.timeInterval),this.running=!1},t.prototype.tick=function(t){var e=this;if(void 0===t&&(t=this.options.maxIteration||1),this.lastResult)return this.lastResult;for(var r=0;r<t;r++)this.runOneStep(this.lastGraph,this.lastClusterMap,this.lastOptions);var n={nodes:this.lastLayoutNodes,edges:this.lastLayoutEdges};return this.lastAssign&&n.nodes.forEach((function(t){return e.lastGraph.mergeNodeData(t.id,{x:t.data.x,y:t.data.y})})),n},t.prototype.genericFruchtermanLayout=function(t,e,r){return i(this,void 0,void 0,(function(){var o,i,s,u,d,h,c,l,g,p,v,y,m,w,x,E=this;return a(this,(function(a){return this.running?[2]:(o=this.formatOptions(r),i=o.width,s=o.height,u=o.center,d=o.clustering,h=o.nodeClusterBy,c=o.maxIteration,l=o.onTick,g=e.getAllNodes(),p=e.getAllEdges(),(null==g?void 0:g.length)?1===g.length?(t&&e.mergeNodeData(g[0].id,{x:u[0],y:u[1]}),v={nodes:[n(n({},g[0]),{data:n(n({},g[0].data),{x:u[0],y:u[1]})})],edges:p},this.lastResult=v,[2,v]):(y=g.map((function(t){return N(t,[i,s])})),m=new f({nodes:y,edges:p}),w={},d&&y.forEach((function(t){var e=t.data[h];w[e]||(w[e]={name:e,cx:0,cy:0,count:0})})),this.lastLayoutNodes=y,this.lastLayoutEdges=p,this.lastAssign=t,this.lastGraph=m,this.lastOptions=o,this.lastClusterMap=w,"undefined"==typeof window?[2]:(x=0,[2,new Promise((function(r){E.timeInterval=window.setInterval((function(){E.running?(E.runOneStep(m,w,o),t&&y.forEach((function(t){var r=t.id,n=t.data;return e.mergeNodeData(r,{x:n.x,y:n.y})})),null==l||l({nodes:y,edges:p}),++x>=c&&(window.clearInterval(E.timeInterval),r({nodes:y,edges:p}))):r({nodes:y,edges:p})}),0),E.running=!0}))])):(v={nodes:[],edges:p},this.lastResult=v,[2,v]))}))}))},t.prototype.formatOptions=function(t){void 0===t&&(t={});var e=n(n({},this.options),t),r=e.clustering,o=e.nodeClusterBy,i=e.center,a=e.width,s=e.height;return e.width=a||"undefined"==typeof window?a:window.innerWidth,e.height=s||"undefined"==typeof window?s:window.innerHeight,e.center=i||[e.width/2,e.height/2],e.clustering=r&&!!o,e},t.prototype.runOneStep=function(t,e,r){var n=r.height,o=r.width,i=r.gravity,a=r.center,s=r.speed,u=r.clustering,d=r.nodeClusterBy,h=r.clusterGravity,c=n*o,l=Math.sqrt(c)/10,f=t.getAllNodes(),g=c/(f.length+1),p=Math.sqrt(g),v={};if(this.applyCalculate(t,v,p,g),u){for(var y in e)e[y].cx=0,e[y].cy=0,e[y].count=0;for(var y in f.forEach((function(t){var r=t.data,n=e[r[d]];E(r.x)&&(n.cx+=r.x),E(r.y)&&(n.cy+=r.y),n.count++})),e)e[y].cx/=e[y].count,e[y].cy/=e[y].count;var m=h||i;f.forEach((function(t,r){var n=t.id,o=t.data;if(E(o.x)&&E(o.y)){var i=e[o[d]],a=Math.sqrt((o.x-i.cx)*(o.x-i.cx)+(o.y-i.cy)*(o.y-i.cy)),s=p*m;v[n].x-=s*(o.x-i.cx)/a,v[n].y-=s*(o.y-i.cy)/a}}))}f.forEach((function(t,e){var r=t.id,n=t.data;if(E(n.x)&&E(n.y)){var o=.01*p*i;v[r].x-=o*(n.x-a[0]),v[r].y-=o*(n.y-a[1])}})),f.forEach((function(e,r){var n=e.id,o=e.data;if(E(o.fx)&&E(o.fy))return o.x=o.fx,void(o.y=o.fy);if(E(o.x)&&E(o.y)){var i=Math.sqrt(v[n].x*v[n].x+v[n].y*v[n].y);if(i>0){var a=Math.min(l*(s/800),i);t.mergeNodeData(n,{x:o.x+v[n].x/i*a,y:o.y+v[n].y/i*a})}}}))},t.prototype.applyCalculate=function(t,e,r,n){this.calRepulsive(t,e,n),this.calAttractive(t,e,r)},t.prototype.calRepulsive=function(t,e,r){var n=t.getAllNodes();n.forEach((function(t,o){var i=t.data,a=t.id;e[a]={x:0,y:0},n.forEach((function(t,n){var s=t.data,u=t.id;if(!(o<=n)&&E(i.x)&&E(s.x)&&E(i.y)&&E(s.y)){var d=i.x-s.x,h=i.y-s.y,c=d*d+h*h;0===c&&(c=1,d=.01,h=.01);var l=r/c,f=d*l,g=h*l;e[a].x+=f,e[a].y+=g,e[u].x-=f,e[u].y-=g}}))}))},t.prototype.calAttractive=function(t,e,r){t.getAllEdges().forEach((function(n){var o=n.source,i=n.target;if(o&&i&&o!==i){var a=t.getNode(o).data,s=t.getNode(i).data;if(E(s.x)&&E(a.x)&&E(s.y)&&E(a.y)){var u=s.x-a.x,d=s.y-a.y,h=Math.sqrt(u*u+d*d)/r,c=u*h,l=d*h;e[o].x+=c,e[o].y+=l,e[i].x-=c,e[i].y-=l}}}))},t}(),zr={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},Cr=function(){function t(t){void 0===t&&(t={}),this.options=t,this.id="grid",this.options=n(n({},zr),t)}return t.prototype.execute=function(t,e){return i(this,void 0,void 0,(function(){return a(this,(function(r){return[2,this.genericGridLayout(!1,t,e)]}))}))},t.prototype.assign=function(t,e){return i(this,void 0,void 0,(function(){return a(this,(function(r){return this.genericGridLayout(!0,t,e),[2]}))}))},t.prototype.genericGridLayout=function(t,e,r){return i(this,void 0,void 0,(function(){var o,i,s,u,d,h,c,l,f,g,v,y,m,w,x,b,M,S,R,_,D,O,P,z,C,L,q,j,F,V,G,W,B,$,U,H,K;return a(this,(function(a){if(o=n(n({},this.options),r),i=o.begin,s=void 0===i?[0,0]:i,u=o.condense,d=o.preventOverlapPadding,h=o.preventOverlap,c=o.rows,l=o.cols,f=o.nodeSpacing,g=o.nodeSize,v=o.width,y=o.height,m=o.position,w=o.sortBy,x=e.getAllNodes(),b=e.getAllEdges(),!(M=null==x?void 0:x.length)||1===M)return[2,I(e,t,s)];if(S=x.map((function(t){return N(t)})),"id"===w||T(w)&&void 0!==S[0].data[w]||(w="degree"),"degree"===w?S.sort((function(t,r){return e.getDegree(r.id,"both")-e.getDegree(t.id,"both")})):"id"===w?S.sort((function(t,e){return E(e.id)&&E(t.id)?e.id-t.id:"".concat(t.id).localeCompare("".concat(e.id))})):S.sort((function(t,e){return e.data[w]-t.data[w]})),R=v||"undefined"==typeof window?v:window.innerWidth,_=y||"undefined"==typeof window?y:window.innerHeight,D=M,O={rows:c,cols:l},null!=c&&null!=l?(O.rows=c,O.cols=l):null!=c&&null==l?(O.rows=c,O.cols=Math.ceil(D/O.rows)):null==c&&null!=l?(O.cols=l,O.rows=Math.ceil(D/O.cols)):(P=Math.sqrt(D*_/R),O.rows=Math.round(P),O.cols=Math.round(R/_*P)),O.rows=Math.max(O.rows,1),O.cols=Math.max(O.cols,1),O.cols*O.rows>D)z=Lr(O),C=qr(O),(z-1)*C>=D?Lr(O,z-1):(C-1)*z>=D&&qr(O,C-1);else for(;O.cols*O.rows<D;)z=Lr(O),((C=qr(O))+1)*z>=D?qr(O,C+1):Lr(O,z+1);for(L=u?0:R/O.cols,q=u?0:_/O.rows,(h||f)&&(j=k(10,f),F=A(30,g,!1),S.forEach((function(t){t.data.x&&t.data.y||(t.data.x=0,t.data.y=0);var r,n,o=e.getNode(t.id),i=F(o)||30;p(i)?(r=i[0],n=i[1]):(r=i,n=i);var a=void 0!==j?j(t):d,s=r+a,u=n+a;L=Math.max(L,s),q=Math.max(q,u)}))),V={},G={row:0,col:0},W={},B=0;B<S.length;B++){if($=S[B],U=void 0,m&&(U=m(e.getNode($.id))),U&&(void 0!==U.row||void 0!==U.col)){if(void 0===(H={row:U.row,col:U.col}).col)for(H.col=0;jr(V,H);)H.col++;else if(void 0===H.row)for(H.row=0;jr(V,H);)H.row++;W[$.id]=H,Fr(V,H)}Gr($,s,L,q,W,O,G,V)}return K={nodes:S,edges:b},t&&S.forEach((function(t){e.mergeNodeData(t.id,{x:t.data.x,y:t.data.y})})),[2,K]}))}))},t}(),Lr=function(t,e){var r,n=t.rows||5,o=t.cols||5;return null==e?r=Math.min(n,o):Math.min(n,o)===t.rows?t.rows=e:t.cols=e,r},qr=function(t,e){var r,n=t.rows||5,o=t.cols||5;return null==e?r=Math.max(n,o):Math.max(n,o)===t.rows?t.rows=e:t.cols=e,r},jr=function(t,e){return t["c-".concat(e.row,"-").concat(e.col)]||!1},Fr=function(t,e){return t["c-".concat(e.row,"-").concat(e.col)]=!0},Vr=function(t,e){var r=t.cols||5;e.col++,e.col>=r&&(e.col=0,e.row++)},Gr=function(t,e,r,n,o,i,a,s){var u,d,h=o[t.id];if(h)u=h.col*r+r/2+e[0],d=h.row*n+n/2+e[1];else{for(;jr(s,a);)Vr(i,a);u=a.col*r+r/2+e[0],d=a.row*n+n/2+e[1],Fr(s,a),Vr(i,a)}t.data.x=u,t.data.y=d};const Wr=Object.prototype.toString;function Br(t){return Wr.call(t).endsWith("Array]")}function $r(t){var e,r=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};if(!Br(t))throw new TypeError("input must be an array");if(0===t.length)throw new TypeError("input must not be empty");if(void 0!==r.output){if(!Br(r.output))throw new TypeError("output option must be an array if specified");e=r.output}else e=new Array(t.length);var n=function(t){var e=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};if(!Br(t))throw new TypeError("input must be an array");if(0===t.length)throw new TypeError("input must not be empty");var r=e.fromIndex,n=void 0===r?0:r,o=e.toIndex,i=void 0===o?t.length:o;if(n<0||n>=t.length||!Number.isInteger(n))throw new Error("fromIndex must be a positive integer smaller than length");if(i<=n||i>t.length||!Number.isInteger(i))throw new Error("toIndex must be an integer greater than fromIndex and at most equal to length");for(var a=t[n],s=n+1;s<i;s++)t[s]<a&&(a=t[s]);return a}(t),o=function(t){var e=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};if(!Br(t))throw new TypeError("input must be an array");if(0===t.length)throw new TypeError("input must not be empty");var r=e.fromIndex,n=void 0===r?0:r,o=e.toIndex,i=void 0===o?t.length:o;if(n<0||n>=t.length||!Number.isInteger(n))throw new Error("fromIndex must be a positive integer smaller than length");if(i<=n||i>t.length||!Number.isInteger(i))throw new Error("toIndex must be an integer greater than fromIndex and at most equal to length");for(var a=t[n],s=n+1;s<i;s++)t[s]>a&&(a=t[s]);return a}(t);if(n===o)throw new RangeError("minimum and maximum input values are equal. Cannot rescale a constant array");var i=r.min,a=void 0===i?r.autoMinMax?n:0:i,s=r.max,u=void 0===s?r.autoMinMax?o:1:s;if(a>=u)throw new RangeError("min option must be smaller than max option");for(var d=(u-a)/(o-n),h=0;h<t.length;h++)e[h]=(t[h]-n)*d+a;return e}const Ur=" ".repeat(2),Hr=" ".repeat(4);function Kr(t,e={}){const{maxRows:r=15,maxColumns:n=10,maxNumSize:o=8,padMinus:i="auto"}=e;return`${t.constructor.name} {\\n${Ur}[\\n${Hr}${function(t,e,r,n,o){const{rows:i,columns:a}=t,s=Math.min(i,e),u=Math.min(a,r),d=[];if("auto"===o){o=!1;t:for(let e=0;e<s;e++)for(let r=0;r<u;r++)if(t.get(e,r)<0){o=!0;break t}}for(let e=0;e<s;e++){let r=[];for(let i=0;i<u;i++)r.push(Yr(t.get(e,i),n,o));d.push(`${r.join(" ")}`)}return u!==a&&(d[d.length-1]+=` ... ${a-r} more columns`),s!==i&&d.push(`... ${i-e} more rows`),d.join(`\\n${Hr}`)}(t,r,n,o,i)}\\n${Ur}]\\n${Ur}rows: ${t.rows}\\n${Ur}columns: ${t.columns}\\n}`}function Yr(t,e,r){return(t>=0&&r?` ${Jr(t,e-1)}`:Jr(t,e)).padEnd(e)}function Jr(t,e){let r=t.toString();if(r.length<=e)return r;let n=t.toFixed(e);if(n.length>e&&(n=t.toFixed(Math.max(0,e-(n.length-e)))),n.length<=e&&!n.startsWith("0.000")&&!n.startsWith("-0.000"))return n;let o=t.toExponential(e);return o.length>e&&(o=t.toExponential(Math.max(0,e-(o.length-e)))),o.slice(0)}function Xr(t,e,r){let n=r?t.rows:t.rows-1;if(e<0||e>n)throw new RangeError("Row index out of range")}function Qr(t,e,r){let n=r?t.columns:t.columns-1;if(e<0||e>n)throw new RangeError("Column index out of range")}function Zr(t,e){if(e.to1DArray&&(e=e.to1DArray()),e.length!==t.columns)throw new RangeError("vector size must be the same as the number of columns");return e}function tn(t,e){if(e.to1DArray&&(e=e.to1DArray()),e.length!==t.rows)throw new RangeError("vector size must be the same as the number of rows");return e}function en(t,e,r,n,o){if(5!==arguments.length)throw new RangeError("expected 4 arguments");if(nn("startRow",e),nn("endRow",r),nn("startColumn",n),nn("endColumn",o),e>r||n>o||e<0||e>=t.rows||r<0||r>=t.rows||n<0||n>=t.columns||o<0||o>=t.columns)throw new RangeError("Submatrix indices are out of range")}function rn(t,e=0){let r=[];for(let n=0;n<t;n++)r.push(e);return r}function nn(t,e){if("number"!=typeof e)throw new TypeError(`${t} must be a number`)}function on(t){if(t.isEmpty())throw new Error("Empty matrix has no elements to index")}class an{static from1DArray(t,e,r){if(t*e!==r.length)throw new RangeError("data length does not match given dimensions");let n=new un(t,e);for(let o=0;o<t;o++)for(let t=0;t<e;t++)n.set(o,t,r[o*e+t]);return n}static rowVector(t){let e=new un(1,t.length);for(let r=0;r<t.length;r++)e.set(0,r,t[r]);return e}static columnVector(t){let e=new un(t.length,1);for(let r=0;r<t.length;r++)e.set(r,0,t[r]);return e}static zeros(t,e){return new un(t,e)}static ones(t,e){return new un(t,e).fill(1)}static rand(t,e,r={}){if("object"!=typeof r)throw new TypeError("options must be an object");const{random:n=Math.random}=r;let o=new un(t,e);for(let r=0;r<t;r++)for(let t=0;t<e;t++)o.set(r,t,n());return o}static randInt(t,e,r={}){if("object"!=typeof r)throw new TypeError("options must be an object");const{min:n=0,max:o=1e3,random:i=Math.random}=r;if(!Number.isInteger(n))throw new TypeError("min must be an integer");if(!Number.isInteger(o))throw new TypeError("max must be an integer");if(n>=o)throw new RangeError("min must be smaller than max");let a=o-n,s=new un(t,e);for(let r=0;r<t;r++)for(let t=0;t<e;t++){let e=n+Math.round(i()*a);s.set(r,t,e)}return s}static eye(t,e,r){void 0===e&&(e=t),void 0===r&&(r=1);let n=Math.min(t,e),o=this.zeros(t,e);for(let t=0;t<n;t++)o.set(t,t,r);return o}static diag(t,e,r){let n=t.length;void 0===e&&(e=n),void 0===r&&(r=e);let o=Math.min(n,e,r),i=this.zeros(e,r);for(let e=0;e<o;e++)i.set(e,e,t[e]);return i}static min(t,e){t=this.checkMatrix(t),e=this.checkMatrix(e);let r=t.rows,n=t.columns,o=new un(r,n);for(let i=0;i<r;i++)for(let r=0;r<n;r++)o.set(i,r,Math.min(t.get(i,r),e.get(i,r)));return o}static max(t,e){t=this.checkMatrix(t),e=this.checkMatrix(e);let r=t.rows,n=t.columns,o=new this(r,n);for(let i=0;i<r;i++)for(let r=0;r<n;r++)o.set(i,r,Math.max(t.get(i,r),e.get(i,r)));return o}static checkMatrix(t){return an.isMatrix(t)?t:new un(t)}static isMatrix(t){return null!=t&&"Matrix"===t.klass}get size(){return this.rows*this.columns}apply(t){if("function"!=typeof t)throw new TypeError("callback must be a function");for(let e=0;e<this.rows;e++)for(let r=0;r<this.columns;r++)t.call(this,e,r);return this}to1DArray(){let t=[];for(let e=0;e<this.rows;e++)for(let r=0;r<this.columns;r++)t.push(this.get(e,r));return t}to2DArray(){let t=[];for(let e=0;e<this.rows;e++){t.push([]);for(let r=0;r<this.columns;r++)t[e].push(this.get(e,r))}return t}toJSON(){return this.to2DArray()}isRowVector(){return 1===this.rows}isColumnVector(){return 1===this.columns}isVector(){return 1===this.rows||1===this.columns}isSquare(){return this.rows===this.columns}isEmpty(){return 0===this.rows||0===this.columns}isSymmetric(){if(this.isSquare()){for(let t=0;t<this.rows;t++)for(let e=0;e<=t;e++)if(this.get(t,e)!==this.get(e,t))return!1;return!0}return!1}isEchelonForm(){let t=0,e=0,r=-1,n=!0,o=!1;for(;t<this.rows&&n;){for(e=0,o=!1;e<this.columns&&!1===o;)0===this.get(t,e)?e++:1===this.get(t,e)&&e>r?(o=!0,r=e):(n=!1,o=!0);t++}return n}isReducedEchelonForm(){let t=0,e=0,r=-1,n=!0,o=!1;for(;t<this.rows&&n;){for(e=0,o=!1;e<this.columns&&!1===o;)0===this.get(t,e)?e++:1===this.get(t,e)&&e>r?(o=!0,r=e):(n=!1,o=!0);for(let r=e+1;r<this.rows;r++)0!==this.get(t,r)&&(n=!1);t++}return n}echelonForm(){let t=this.clone(),e=0,r=0;for(;e<t.rows&&r<t.columns;){let n=e;for(let o=e;o<t.rows;o++)t.get(o,r)>t.get(n,r)&&(n=o);if(0===t.get(n,r))r++;else{t.swapRows(e,n);let o=t.get(e,r);for(let n=r;n<t.columns;n++)t.set(e,n,t.get(e,n)/o);for(let n=e+1;n<t.rows;n++){let o=t.get(n,r)/t.get(e,r);t.set(n,r,0);for(let i=r+1;i<t.columns;i++)t.set(n,i,t.get(n,i)-t.get(e,i)*o)}e++,r++}}return t}reducedEchelonForm(){let t=this.echelonForm(),e=t.columns,r=t.rows,n=r-1;for(;n>=0;)if(0===t.maxRow(n))n--;else{let o=0,i=!1;for(;o<r&&!1===i;)1===t.get(n,o)?i=!0:o++;for(let r=0;r<n;r++){let i=t.get(r,o);for(let a=o;a<e;a++){let e=t.get(r,a)-i*t.get(n,a);t.set(r,a,e)}}n--}return t}set(){throw new Error("set method is unimplemented")}get(){throw new Error("get method is unimplemented")}repeat(t={}){if("object"!=typeof t)throw new TypeError("options must be an object");const{rows:e=1,columns:r=1}=t;if(!Number.isInteger(e)||e<=0)throw new TypeError("rows must be a positive integer");if(!Number.isInteger(r)||r<=0)throw new TypeError("columns must be a positive integer");let n=new un(this.rows*e,this.columns*r);for(let t=0;t<e;t++)for(let e=0;e<r;e++)n.setSubMatrix(this,this.rows*t,this.columns*e);return n}fill(t){for(let e=0;e<this.rows;e++)for(let r=0;r<this.columns;r++)this.set(e,r,t);return this}neg(){return this.mulS(-1)}getRow(t){Xr(this,t);let e=[];for(let r=0;r<this.columns;r++)e.push(this.get(t,r));return e}getRowVector(t){return un.rowVector(this.getRow(t))}setRow(t,e){Xr(this,t),e=Zr(this,e);for(let r=0;r<this.columns;r++)this.set(t,r,e[r]);return this}swapRows(t,e){Xr(this,t),Xr(this,e);for(let r=0;r<this.columns;r++){let n=this.get(t,r);this.set(t,r,this.get(e,r)),this.set(e,r,n)}return this}getColumn(t){Qr(this,t);let e=[];for(let r=0;r<this.rows;r++)e.push(this.get(r,t));return e}getColumnVector(t){return un.columnVector(this.getColumn(t))}setColumn(t,e){Qr(this,t),e=tn(this,e);for(let r=0;r<this.rows;r++)this.set(r,t,e[r]);return this}swapColumns(t,e){Qr(this,t),Qr(this,e);for(let r=0;r<this.rows;r++){let n=this.get(r,t);this.set(r,t,this.get(r,e)),this.set(r,e,n)}return this}addRowVector(t){t=Zr(this,t);for(let e=0;e<this.rows;e++)for(let r=0;r<this.columns;r++)this.set(e,r,this.get(e,r)+t[r]);return this}subRowVector(t){t=Zr(this,t);for(let e=0;e<this.rows;e++)for(let r=0;r<this.columns;r++)this.set(e,r,this.get(e,r)-t[r]);return this}mulRowVector(t){t=Zr(this,t);for(let e=0;e<this.rows;e++)for(let r=0;r<this.columns;r++)this.set(e,r,this.get(e,r)*t[r]);return this}divRowVector(t){t=Zr(this,t);for(let e=0;e<this.rows;e++)for(let r=0;r<this.columns;r++)this.set(e,r,this.get(e,r)/t[r]);return this}addColumnVector(t){t=tn(this,t);for(let e=0;e<this.rows;e++)for(let r=0;r<this.columns;r++)this.set(e,r,this.get(e,r)+t[e]);return this}subColumnVector(t){t=tn(this,t);for(let e=0;e<this.rows;e++)for(let r=0;r<this.columns;r++)this.set(e,r,this.get(e,r)-t[e]);return this}mulColumnVector(t){t=tn(this,t);for(let e=0;e<this.rows;e++)for(let r=0;r<this.columns;r++)this.set(e,r,this.get(e,r)*t[e]);return this}divColumnVector(t){t=tn(this,t);for(let e=0;e<this.rows;e++)for(let r=0;r<this.columns;r++)this.set(e,r,this.get(e,r)/t[e]);return this}mulRow(t,e){Xr(this,t);for(let r=0;r<this.columns;r++)this.set(t,r,this.get(t,r)*e);return this}mulColumn(t,e){Qr(this,t);for(let r=0;r<this.rows;r++)this.set(r,t,this.get(r,t)*e);return this}max(t){if(this.isEmpty())return NaN;switch(t){case"row":{const t=new Array(this.rows).fill(Number.NEGATIVE_INFINITY);for(let e=0;e<this.rows;e++)for(let r=0;r<this.columns;r++)this.get(e,r)>t[e]&&(t[e]=this.get(e,r));return t}case"column":{const t=new Array(this.columns).fill(Number.NEGATIVE_INFINITY);for(let e=0;e<this.rows;e++)for(let r=0;r<this.columns;r++)this.get(e,r)>t[r]&&(t[r]=this.get(e,r));return t}case void 0:{let t=this.get(0,0);for(let e=0;e<this.rows;e++)for(let r=0;r<this.columns;r++)this.get(e,r)>t&&(t=this.get(e,r));return t}default:throw new Error(`invalid option: ${t}`)}}maxIndex(){on(this);let t=this.get(0,0),e=[0,0];for(let r=0;r<this.rows;r++)for(let n=0;n<this.columns;n++)this.get(r,n)>t&&(t=this.get(r,n),e[0]=r,e[1]=n);return e}min(t){if(this.isEmpty())return NaN;switch(t){case"row":{const t=new Array(this.rows).fill(Number.POSITIVE_INFINITY);for(let e=0;e<this.rows;e++)for(let r=0;r<this.columns;r++)this.get(e,r)<t[e]&&(t[e]=this.get(e,r));return t}case"column":{const t=new Array(this.columns).fill(Number.POSITIVE_INFINITY);for(let e=0;e<this.rows;e++)for(let r=0;r<this.columns;r++)this.get(e,r)<t[r]&&(t[r]=this.get(e,r));return t}case void 0:{let t=this.get(0,0);for(let e=0;e<this.rows;e++)for(let r=0;r<this.columns;r++)this.get(e,r)<t&&(t=this.get(e,r));return t}default:throw new Error(`invalid option: ${t}`)}}minIndex(){on(this);let t=this.get(0,0),e=[0,0];for(let r=0;r<this.rows;r++)for(let n=0;n<this.columns;n++)this.get(r,n)<t&&(t=this.get(r,n),e[0]=r,e[1]=n);return e}maxRow(t){if(Xr(this,t),this.isEmpty())return NaN;let e=this.get(t,0);for(let r=1;r<this.columns;r++)this.get(t,r)>e&&(e=this.get(t,r));return e}maxRowIndex(t){Xr(this,t),on(this);let e=this.get(t,0),r=[t,0];for(let n=1;n<this.columns;n++)this.get(t,n)>e&&(e=this.get(t,n),r[1]=n);return r}minRow(t){if(Xr(this,t),this.isEmpty())return NaN;let e=this.get(t,0);for(let r=1;r<this.columns;r++)this.get(t,r)<e&&(e=this.get(t,r));return e}minRowIndex(t){Xr(this,t),on(this);let e=this.get(t,0),r=[t,0];for(let n=1;n<this.columns;n++)this.get(t,n)<e&&(e=this.get(t,n),r[1]=n);return r}maxColumn(t){if(Qr(this,t),this.isEmpty())return NaN;let e=this.get(0,t);for(let r=1;r<this.rows;r++)this.get(r,t)>e&&(e=this.get(r,t));return e}maxColumnIndex(t){Qr(this,t),on(this);let e=this.get(0,t),r=[0,t];for(let n=1;n<this.rows;n++)this.get(n,t)>e&&(e=this.get(n,t),r[0]=n);return r}minColumn(t){if(Qr(this,t),this.isEmpty())return NaN;let e=this.get(0,t);for(let r=1;r<this.rows;r++)this.get(r,t)<e&&(e=this.get(r,t));return e}minColumnIndex(t){Qr(this,t),on(this);let e=this.get(0,t),r=[0,t];for(let n=1;n<this.rows;n++)this.get(n,t)<e&&(e=this.get(n,t),r[0]=n);return r}diag(){let t=Math.min(this.rows,this.columns),e=[];for(let r=0;r<t;r++)e.push(this.get(r,r));return e}norm(t="frobenius"){let e=0;if("max"===t)return this.max();if("frobenius"===t){for(let t=0;t<this.rows;t++)for(let r=0;r<this.columns;r++)e+=this.get(t,r)*this.get(t,r);return Math.sqrt(e)}throw new RangeError(`unknown norm type: ${t}`)}cumulativeSum(){let t=0;for(let e=0;e<this.rows;e++)for(let r=0;r<this.columns;r++)t+=this.get(e,r),this.set(e,r,t);return this}dot(t){an.isMatrix(t)&&(t=t.to1DArray());let e=this.to1DArray();if(e.length!==t.length)throw new RangeError("vectors do not have the same size");let r=0;for(let n=0;n<e.length;n++)r+=e[n]*t[n];return r}mmul(t){t=un.checkMatrix(t);let e=this.rows,r=this.columns,n=t.columns,o=new un(e,n),i=new Float64Array(r);for(let a=0;a<n;a++){for(let e=0;e<r;e++)i[e]=t.get(e,a);for(let t=0;t<e;t++){let e=0;for(let n=0;n<r;n++)e+=this.get(t,n)*i[n];o.set(t,a,e)}}return o}strassen2x2(t){t=un.checkMatrix(t);let e=new un(2,2);const r=this.get(0,0),n=t.get(0,0),o=this.get(0,1),i=t.get(0,1),a=this.get(1,0),s=t.get(1,0),u=this.get(1,1),d=t.get(1,1),h=(r+u)*(n+d),c=(a+u)*n,l=r*(i-d),f=u*(s-n),g=(r+o)*d,p=h+f-g+(o-u)*(s+d),v=l+g,y=c+f,m=h-c+l+(a-r)*(n+i);return e.set(0,0,p),e.set(0,1,v),e.set(1,0,y),e.set(1,1,m),e}strassen3x3(t){t=un.checkMatrix(t);let e=new un(3,3);const r=this.get(0,0),n=this.get(0,1),o=this.get(0,2),i=this.get(1,0),a=this.get(1,1),s=this.get(1,2),u=this.get(2,0),d=this.get(2,1),h=this.get(2,2),c=t.get(0,0),l=t.get(0,1),f=t.get(0,2),g=t.get(1,0),p=t.get(1,1),v=t.get(1,2),y=t.get(2,0),m=t.get(2,1),w=t.get(2,2),x=(r-i)*(-l+p),E=(-r+i+a)*(c-l+p),b=(i+a)*(-c+l),N=r*c,M=(-r+u+d)*(c-f+v),S=(-r+u)*(f-v),k=(u+d)*(-c+f),A=(-o+d+h)*(p+y-m),R=(o-h)*(p-m),I=o*y,_=(d+h)*(-y+m),D=(-o+a+s)*(v+y-w),O=(o-s)*(v-w),P=(a+s)*(-y+w),T=N+I+n*g,z=(r+n+o-i-a-d-h)*p+E+b+N+A+I+_,C=N+M+k+(r+n+o-a-s-u-d)*v+I+D+P,L=x+a*(-c+l+g-p-v-y+w)+E+N+I+D+O,q=x+E+b+N+s*m,j=I+D+O+P+i*f,F=N+M+S+d*(-c+f+g-p-v-y+m)+A+R+I,V=A+R+I+_+u*l,G=N+M+S+k+h*w;return e.set(0,0,T),e.set(0,1,z),e.set(0,2,C),e.set(1,0,L),e.set(1,1,q),e.set(1,2,j),e.set(2,0,F),e.set(2,1,V),e.set(2,2,G),e}mmulStrassen(t){t=un.checkMatrix(t);let e=this.clone(),r=e.rows,n=e.columns,o=t.rows,i=t.columns;function a(t,e,r){let n=t.rows,o=t.columns;if(n===e&&o===r)return t;{let n=an.zeros(e,r);return n=n.setSubMatrix(t,0,0),n}}n!==o&&console.warn(`Multiplying ${r} x ${n} and ${o} x ${i} matrix: dimensions do not match.`);let s=Math.max(r,o),u=Math.max(n,i);return e=a(e,s,u),function t(e,r,n,o){if(n<=512||o<=512)return e.mmul(r);n%2==1&&o%2==1?(e=a(e,n+1,o+1),r=a(r,n+1,o+1)):n%2==1?(e=a(e,n+1,o),r=a(r,n+1,o)):o%2==1&&(e=a(e,n,o+1),r=a(r,n,o+1));let i=parseInt(e.rows/2,10),s=parseInt(e.columns/2,10),u=e.subMatrix(0,i-1,0,s-1),d=r.subMatrix(0,i-1,0,s-1),h=e.subMatrix(0,i-1,s,e.columns-1),c=r.subMatrix(0,i-1,s,r.columns-1),l=e.subMatrix(i,e.rows-1,0,s-1),f=r.subMatrix(i,r.rows-1,0,s-1),g=e.subMatrix(i,e.rows-1,s,e.columns-1),p=r.subMatrix(i,r.rows-1,s,r.columns-1),v=t(an.add(u,g),an.add(d,p),i,s),y=t(an.add(l,g),d,i,s),m=t(u,an.sub(c,p),i,s),w=t(g,an.sub(f,d),i,s),x=t(an.add(u,h),p,i,s),E=t(an.sub(l,u),an.add(d,c),i,s),b=t(an.sub(h,g),an.add(f,p),i,s),N=an.add(v,w);N.sub(x),N.add(b);let M=an.add(m,x),S=an.add(y,w),k=an.sub(v,y);k.add(m),k.add(E);let A=an.zeros(2*N.rows,2*N.columns);return A=A.setSubMatrix(N,0,0),A=A.setSubMatrix(M,N.rows,0),A=A.setSubMatrix(S,0,N.columns),A=A.setSubMatrix(k,N.rows,N.columns),A.subMatrix(0,n-1,0,o-1)}(e,t=a(t,s,u),s,u)}scaleRows(t={}){if("object"!=typeof t)throw new TypeError("options must be an object");const{min:e=0,max:r=1}=t;if(!Number.isFinite(e))throw new TypeError("min must be a number");if(!Number.isFinite(r))throw new TypeError("max must be a number");if(e>=r)throw new RangeError("min must be smaller than max");let n=new un(this.rows,this.columns);for(let t=0;t<this.rows;t++){const o=this.getRow(t);o.length>0&&$r(o,{min:e,max:r,output:o}),n.setRow(t,o)}return n}scaleColumns(t={}){if("object"!=typeof t)throw new TypeError("options must be an object");const{min:e=0,max:r=1}=t;if(!Number.isFinite(e))throw new TypeError("min must be a number");if(!Number.isFinite(r))throw new TypeError("max must be a number");if(e>=r)throw new RangeError("min must be smaller than max");let n=new un(this.rows,this.columns);for(let t=0;t<this.columns;t++){const o=this.getColumn(t);o.length&&$r(o,{min:e,max:r,output:o}),n.setColumn(t,o)}return n}flipRows(){const t=Math.ceil(this.columns/2);for(let e=0;e<this.rows;e++)for(let r=0;r<t;r++){let t=this.get(e,r),n=this.get(e,this.columns-1-r);this.set(e,r,n),this.set(e,this.columns-1-r,t)}return this}flipColumns(){const t=Math.ceil(this.rows/2);for(let e=0;e<this.columns;e++)for(let r=0;r<t;r++){let t=this.get(r,e),n=this.get(this.rows-1-r,e);this.set(r,e,n),this.set(this.rows-1-r,e,t)}return this}kroneckerProduct(t){t=un.checkMatrix(t);let e=this.rows,r=this.columns,n=t.rows,o=t.columns,i=new un(e*n,r*o);for(let a=0;a<e;a++)for(let e=0;e<r;e++)for(let r=0;r<n;r++)for(let s=0;s<o;s++)i.set(n*a+r,o*e+s,this.get(a,e)*t.get(r,s));return i}kroneckerSum(t){if(t=un.checkMatrix(t),!this.isSquare()||!t.isSquare())throw new Error("Kronecker Sum needs two Square Matrices");let e=this.rows,r=t.rows,n=this.kroneckerProduct(un.eye(r,r)),o=un.eye(e,e).kroneckerProduct(t);return n.add(o)}transpose(){let t=new un(this.columns,this.rows);for(let e=0;e<this.rows;e++)for(let r=0;r<this.columns;r++)t.set(r,e,this.get(e,r));return t}sortRows(t=sn){for(let e=0;e<this.rows;e++)this.setRow(e,this.getRow(e).sort(t));return this}sortColumns(t=sn){for(let e=0;e<this.columns;e++)this.setColumn(e,this.getColumn(e).sort(t));return this}subMatrix(t,e,r,n){en(this,t,e,r,n);let o=new un(e-t+1,n-r+1);for(let i=t;i<=e;i++)for(let e=r;e<=n;e++)o.set(i-t,e-r,this.get(i,e));return o}subMatrixRow(t,e,r){if(void 0===e&&(e=0),void 0===r&&(r=this.columns-1),e>r||e<0||e>=this.columns||r<0||r>=this.columns)throw new RangeError("Argument out of range");let n=new un(t.length,r-e+1);for(let o=0;o<t.length;o++)for(let i=e;i<=r;i++){if(t[o]<0||t[o]>=this.rows)throw new RangeError(`Row index out of range: ${t[o]}`);n.set(o,i-e,this.get(t[o],i))}return n}subMatrixColumn(t,e,r){if(void 0===e&&(e=0),void 0===r&&(r=this.rows-1),e>r||e<0||e>=this.rows||r<0||r>=this.rows)throw new RangeError("Argument out of range");let n=new un(r-e+1,t.length);for(let o=0;o<t.length;o++)for(let i=e;i<=r;i++){if(t[o]<0||t[o]>=this.columns)throw new RangeError(`Column index out of range: ${t[o]}`);n.set(i-e,o,this.get(i,t[o]))}return n}setSubMatrix(t,e,r){if((t=un.checkMatrix(t)).isEmpty())return this;en(this,e,e+t.rows-1,r,r+t.columns-1);for(let n=0;n<t.rows;n++)for(let o=0;o<t.columns;o++)this.set(e+n,r+o,t.get(n,o));return this}selection(t,e){!function(t,e){if(!Br(e))throw new TypeError("row indices must be an array");for(let r=0;r<e.length;r++)if(e[r]<0||e[r]>=t.rows)throw new RangeError("row indices are out of range")}(this,t),function(t,e){if(!Br(e))throw new TypeError("column indices must be an array");for(let r=0;r<e.length;r++)if(e[r]<0||e[r]>=t.columns)throw new RangeError("column indices are out of range")}(this,e);let r=new un(t.length,e.length);for(let n=0;n<t.length;n++){let o=t[n];for(let t=0;t<e.length;t++){let i=e[t];r.set(n,t,this.get(o,i))}}return r}trace(){let t=Math.min(this.rows,this.columns),e=0;for(let r=0;r<t;r++)e+=this.get(r,r);return e}clone(){let t=new un(this.rows,this.columns);for(let e=0;e<this.rows;e++)for(let r=0;r<this.columns;r++)t.set(e,r,this.get(e,r));return t}sum(t){switch(t){case"row":return function(t){let e=rn(t.rows);for(let r=0;r<t.rows;++r)for(let n=0;n<t.columns;++n)e[r]+=t.get(r,n);return e}(this);case"column":return function(t){let e=rn(t.columns);for(let r=0;r<t.rows;++r)for(let n=0;n<t.columns;++n)e[n]+=t.get(r,n);return e}(this);case void 0:return function(t){let e=0;for(let r=0;r<t.rows;r++)for(let n=0;n<t.columns;n++)e+=t.get(r,n);return e}(this);default:throw new Error(`invalid option: ${t}`)}}product(t){switch(t){case"row":return function(t){let e=rn(t.rows,1);for(let r=0;r<t.rows;++r)for(let n=0;n<t.columns;++n)e[r]*=t.get(r,n);return e}(this);case"column":return function(t){let e=rn(t.columns,1);for(let r=0;r<t.rows;++r)for(let n=0;n<t.columns;++n)e[n]*=t.get(r,n);return e}(this);case void 0:return function(t){let e=1;for(let r=0;r<t.rows;r++)for(let n=0;n<t.columns;n++)e*=t.get(r,n);return e}(this);default:throw new Error(`invalid option: ${t}`)}}mean(t){const e=this.sum(t);switch(t){case"row":for(let t=0;t<this.rows;t++)e[t]/=this.columns;return e;case"column":for(let t=0;t<this.columns;t++)e[t]/=this.rows;return e;case void 0:return e/this.size;default:throw new Error(`invalid option: ${t}`)}}variance(t,e={}){if("object"==typeof t&&(e=t,t=void 0),"object"!=typeof e)throw new TypeError("options must be an object");const{unbiased:r=!0,mean:n=this.mean(t)}=e;if("boolean"!=typeof r)throw new TypeError("unbiased must be a boolean");switch(t){case"row":if(!Br(n))throw new TypeError("mean must be an array");return function(t,e,r){const n=t.rows,o=t.columns,i=[];for(let a=0;a<n;a++){let n=0,s=0,u=0;for(let e=0;e<o;e++)u=t.get(a,e)-r[a],n+=u,s+=u*u;e?i.push((s-n*n/o)/(o-1)):i.push((s-n*n/o)/o)}return i}(this,r,n);case"column":if(!Br(n))throw new TypeError("mean must be an array");return function(t,e,r){const n=t.rows,o=t.columns,i=[];for(let a=0;a<o;a++){let o=0,s=0,u=0;for(let e=0;e<n;e++)u=t.get(e,a)-r[a],o+=u,s+=u*u;e?i.push((s-o*o/n)/(n-1)):i.push((s-o*o/n)/n)}return i}(this,r,n);case void 0:if("number"!=typeof n)throw new TypeError("mean must be a number");return function(t,e,r){const n=t.rows,o=t.columns,i=n*o;let a=0,s=0,u=0;for(let e=0;e<n;e++)for(let n=0;n<o;n++)u=t.get(e,n)-r,a+=u,s+=u*u;return e?(s-a*a/i)/(i-1):(s-a*a/i)/i}(this,r,n);default:throw new Error(`invalid option: ${t}`)}}standardDeviation(t,e){"object"==typeof t&&(e=t,t=void 0);const r=this.variance(t,e);if(void 0===t)return Math.sqrt(r);for(let t=0;t<r.length;t++)r[t]=Math.sqrt(r[t]);return r}center(t,e={}){if("object"==typeof t&&(e=t,t=void 0),"object"!=typeof e)throw new TypeError("options must be an object");const{center:r=this.mean(t)}=e;switch(t){case"row":if(!Br(r))throw new TypeError("center must be an array");return function(t,e){for(let r=0;r<t.rows;r++)for(let n=0;n<t.columns;n++)t.set(r,n,t.get(r,n)-e[r])}(this,r),this;case"column":if(!Br(r))throw new TypeError("center must be an array");return function(t,e){for(let r=0;r<t.rows;r++)for(let n=0;n<t.columns;n++)t.set(r,n,t.get(r,n)-e[n])}(this,r),this;case void 0:if("number"!=typeof r)throw new TypeError("center must be a number");return function(t,e){for(let r=0;r<t.rows;r++)for(let n=0;n<t.columns;n++)t.set(r,n,t.get(r,n)-e)}(this,r),this;default:throw new Error(`invalid option: ${t}`)}}scale(t,e={}){if("object"==typeof t&&(e=t,t=void 0),"object"!=typeof e)throw new TypeError("options must be an object");let r=e.scale;switch(t){case"row":if(void 0===r)r=function(t){const e=[];for(let r=0;r<t.rows;r++){let n=0;for(let e=0;e<t.columns;e++)n+=Math.pow(t.get(r,e),2)/(t.columns-1);e.push(Math.sqrt(n))}return e}(this);else if(!Br(r))throw new TypeError("scale must be an array");return function(t,e){for(let r=0;r<t.rows;r++)for(let n=0;n<t.columns;n++)t.set(r,n,t.get(r,n)/e[r])}(this,r),this;case"column":if(void 0===r)r=function(t){const e=[];for(let r=0;r<t.columns;r++){let n=0;for(let e=0;e<t.rows;e++)n+=Math.pow(t.get(e,r),2)/(t.rows-1);e.push(Math.sqrt(n))}return e}(this);else if(!Br(r))throw new TypeError("scale must be an array");return function(t,e){for(let r=0;r<t.rows;r++)for(let n=0;n<t.columns;n++)t.set(r,n,t.get(r,n)/e[n])}(this,r),this;case void 0:if(void 0===r)r=function(t){const e=t.size-1;let r=0;for(let n=0;n<t.columns;n++)for(let o=0;o<t.rows;o++)r+=Math.pow(t.get(o,n),2)/e;return Math.sqrt(r)}(this);else if("number"!=typeof r)throw new TypeError("scale must be a number");return function(t,e){for(let r=0;r<t.rows;r++)for(let n=0;n<t.columns;n++)t.set(r,n,t.get(r,n)/e)}(this,r),this;default:throw new Error(`invalid option: ${t}`)}}toString(t){return Kr(this,t)}}function sn(t,e){return t-e}an.prototype.klass="Matrix","undefined"!=typeof Symbol&&(an.prototype[Symbol.for("nodejs.util.inspect.custom")]=function(){return Kr(this)}),an.random=an.rand,an.randomInt=an.randInt,an.diagonal=an.diag,an.prototype.diagonal=an.prototype.diag,an.identity=an.eye,an.prototype.negate=an.prototype.neg,an.prototype.tensorProduct=an.prototype.kroneckerProduct;class un extends an{constructor(t,e){if(super(),un.isMatrix(t))return t.clone();if(Number.isInteger(t)&&t>=0){if(this.data=[],!(Number.isInteger(e)&&e>=0))throw new TypeError("nColumns must be a positive integer");for(let r=0;r<t;r++)this.data.push(new Float64Array(e))}else{if(!Br(t))throw new TypeError("First argument must be a positive number or an array");{const r=t;if("number"!=typeof(e=(t=r.length)?r[0].length:0))throw new TypeError("Data must be a 2D array with at least one element");this.data=[];for(let n=0;n<t;n++){if(r[n].length!==e)throw new RangeError("Inconsistent array dimensions");if(!r[n].every((t=>"number"==typeof t)))throw new TypeError("Input data contains non-numeric values");this.data.push(Float64Array.from(r[n]))}}}this.rows=t,this.columns=e}set(t,e,r){return this.data[t][e]=r,this}get(t,e){return this.data[t][e]}removeRow(t){return Xr(this,t),this.data.splice(t,1),this.rows-=1,this}addRow(t,e){return void 0===e&&(e=t,t=this.rows),Xr(this,t,!0),e=Float64Array.from(Zr(this,e)),this.data.splice(t,0,e),this.rows+=1,this}removeColumn(t){Qr(this,t);for(let e=0;e<this.rows;e++){const r=new Float64Array(this.columns-1);for(let n=0;n<t;n++)r[n]=this.data[e][n];for(let n=t+1;n<this.columns;n++)r[n-1]=this.data[e][n];this.data[e]=r}return this.columns-=1,this}addColumn(t,e){void 0===e&&(e=t,t=this.columns),Qr(this,t,!0),e=tn(this,e);for(let r=0;r<this.rows;r++){const n=new Float64Array(this.columns+1);let o=0;for(;o<t;o++)n[o]=this.data[r][o];for(n[o++]=e[r];o<this.columns+1;o++)n[o]=this.data[r][o-1];this.data[r]=n}return this.columns+=1,this}}!function(t,e){t.prototype.add=function(t){return"number"==typeof t?this.addS(t):this.addM(t)},t.prototype.addS=function(t){for(let e=0;e<this.rows;e++)for(let r=0;r<this.columns;r++)this.set(e,r,this.get(e,r)+t);return this},t.prototype.addM=function(t){if(t=e.checkMatrix(t),this.rows!==t.rows||this.columns!==t.columns)throw new RangeError("Matrices dimensions must be equal");for(let e=0;e<this.rows;e++)for(let r=0;r<this.columns;r++)this.set(e,r,this.get(e,r)+t.get(e,r));return this},t.add=function(t,r){return new e(t).add(r)},t.prototype.sub=function(t){return"number"==typeof t?this.subS(t):this.subM(t)},t.prototype.subS=function(t){for(let e=0;e<this.rows;e++)for(let r=0;r<this.columns;r++)this.set(e,r,this.get(e,r)-t);return this},t.prototype.subM=function(t){if(t=e.checkMatrix(t),this.rows!==t.rows||this.columns!==t.columns)throw new RangeError("Matrices dimensions must be equal");for(let e=0;e<this.rows;e++)for(let r=0;r<this.columns;r++)this.set(e,r,this.get(e,r)-t.get(e,r));return this},t.sub=function(t,r){return new e(t).sub(r)},t.prototype.subtract=t.prototype.sub,t.prototype.subtractS=t.prototype.subS,t.prototype.subtractM=t.prototype.subM,t.subtract=t.sub,t.prototype.mul=function(t){return"number"==typeof t?this.mulS(t):this.mulM(t)},t.prototype.mulS=function(t){for(let e=0;e<this.rows;e++)for(let r=0;r<this.columns;r++)this.set(e,r,this.get(e,r)*t);return this},t.prototype.mulM=function(t){if(t=e.checkMatrix(t),this.rows!==t.rows||this.columns!==t.columns)throw new RangeError("Matrices dimensions must be equal");for(let e=0;e<this.rows;e++)for(let r=0;r<this.columns;r++)this.set(e,r,this.get(e,r)*t.get(e,r));return this},t.mul=function(t,r){return new e(t).mul(r)},t.prototype.multiply=t.prototype.mul,t.prototype.multiplyS=t.prototype.mulS,t.prototype.multiplyM=t.prototype.mulM,t.multiply=t.mul,t.prototype.div=function(t){return"number"==typeof t?this.divS(t):this.divM(t)},t.prototype.divS=function(t){for(let e=0;e<this.rows;e++)for(let r=0;r<this.columns;r++)this.set(e,r,this.get(e,r)/t);return this},t.prototype.divM=function(t){if(t=e.checkMatrix(t),this.rows!==t.rows||this.columns!==t.columns)throw new RangeError("Matrices dimensions must be equal");for(let e=0;e<this.rows;e++)for(let r=0;r<this.columns;r++)this.set(e,r,this.get(e,r)/t.get(e,r));return this},t.div=function(t,r){return new e(t).div(r)},t.prototype.divide=t.prototype.div,t.prototype.divideS=t.prototype.divS,t.prototype.divideM=t.prototype.divM,t.divide=t.div,t.prototype.mod=function(t){return"number"==typeof t?this.modS(t):this.modM(t)},t.prototype.modS=function(t){for(let e=0;e<this.rows;e++)for(let r=0;r<this.columns;r++)this.set(e,r,this.get(e,r)%t);return this},t.prototype.modM=function(t){if(t=e.checkMatrix(t),this.rows!==t.rows||this.columns!==t.columns)throw new RangeError("Matrices dimensions must be equal");for(let e=0;e<this.rows;e++)for(let r=0;r<this.columns;r++)this.set(e,r,this.get(e,r)%t.get(e,r));return this},t.mod=function(t,r){return new e(t).mod(r)},t.prototype.modulus=t.prototype.mod,t.prototype.modulusS=t.prototype.modS,t.prototype.modulusM=t.prototype.modM,t.modulus=t.mod,t.prototype.and=function(t){return"number"==typeof t?this.andS(t):this.andM(t)},t.prototype.andS=function(t){for(let e=0;e<this.rows;e++)for(let r=0;r<this.columns;r++)this.set(e,r,this.get(e,r)&t);return this},t.prototype.andM=function(t){if(t=e.checkMatrix(t),this.rows!==t.rows||this.columns!==t.columns)throw new RangeError("Matrices dimensions must be equal");for(let e=0;e<this.rows;e++)for(let r=0;r<this.columns;r++)this.set(e,r,this.get(e,r)&t.get(e,r));return this},t.and=function(t,r){return new e(t).and(r)},t.prototype.or=function(t){return"number"==typeof t?this.orS(t):this.orM(t)},t.prototype.orS=function(t){for(let e=0;e<this.rows;e++)for(let r=0;r<this.columns;r++)this.set(e,r,this.get(e,r)|t);return this},t.prototype.orM=function(t){if(t=e.checkMatrix(t),this.rows!==t.rows||this.columns!==t.columns)throw new RangeError("Matrices dimensions must be equal");for(let e=0;e<this.rows;e++)for(let r=0;r<this.columns;r++)this.set(e,r,this.get(e,r)|t.get(e,r));return this},t.or=function(t,r){return new e(t).or(r)},t.prototype.xor=function(t){return"number"==typeof t?this.xorS(t):this.xorM(t)},t.prototype.xorS=function(t){for(let e=0;e<this.rows;e++)for(let r=0;r<this.columns;r++)this.set(e,r,this.get(e,r)^t);return this},t.prototype.xorM=function(t){if(t=e.checkMatrix(t),this.rows!==t.rows||this.columns!==t.columns)throw new RangeError("Matrices dimensions must be equal");for(let e=0;e<this.rows;e++)for(let r=0;r<this.columns;r++)this.set(e,r,this.get(e,r)^t.get(e,r));return this},t.xor=function(t,r){return new e(t).xor(r)},t.prototype.leftShift=function(t){return"number"==typeof t?this.leftShiftS(t):this.leftShiftM(t)},t.prototype.leftShiftS=function(t){for(let e=0;e<this.rows;e++)for(let r=0;r<this.columns;r++)this.set(e,r,this.get(e,r)<<t);return this},t.prototype.leftShiftM=function(t){if(t=e.checkMatrix(t),this.rows!==t.rows||this.columns!==t.columns)throw new RangeError("Matrices dimensions must be equal");for(let e=0;e<this.rows;e++)for(let r=0;r<this.columns;r++)this.set(e,r,this.get(e,r)<<t.get(e,r));return this},t.leftShift=function(t,r){return new e(t).leftShift(r)},t.prototype.signPropagatingRightShift=function(t){return"number"==typeof t?this.signPropagatingRightShiftS(t):this.signPropagatingRightShiftM(t)},t.prototype.signPropagatingRightShiftS=function(t){for(let e=0;e<this.rows;e++)for(let r=0;r<this.columns;r++)this.set(e,r,this.get(e,r)>>t);return this},t.prototype.signPropagatingRightShiftM=function(t){if(t=e.checkMatrix(t),this.rows!==t.rows||this.columns!==t.columns)throw new RangeError("Matrices dimensions must be equal");for(let e=0;e<this.rows;e++)for(let r=0;r<this.columns;r++)this.set(e,r,this.get(e,r)>>t.get(e,r));return this},t.signPropagatingRightShift=function(t,r){return new e(t).signPropagatingRightShift(r)},t.prototype.rightShift=function(t){return"number"==typeof t?this.rightShiftS(t):this.rightShiftM(t)},t.prototype.rightShiftS=function(t){for(let e=0;e<this.rows;e++)for(let r=0;r<this.columns;r++)this.set(e,r,this.get(e,r)>>>t);return this},t.prototype.rightShiftM=function(t){if(t=e.checkMatrix(t),this.rows!==t.rows||this.columns!==t.columns)throw new RangeError("Matrices dimensions must be equal");for(let e=0;e<this.rows;e++)for(let r=0;r<this.columns;r++)this.set(e,r,this.get(e,r)>>>t.get(e,r));return this},t.rightShift=function(t,r){return new e(t).rightShift(r)},t.prototype.zeroFillRightShift=t.prototype.rightShift,t.prototype.zeroFillRightShiftS=t.prototype.rightShiftS,t.prototype.zeroFillRightShiftM=t.prototype.rightShiftM,t.zeroFillRightShift=t.rightShift,t.prototype.not=function(){for(let t=0;t<this.rows;t++)for(let e=0;e<this.columns;e++)this.set(t,e,~this.get(t,e));return this},t.not=function(t){return new e(t).not()},t.prototype.abs=function(){for(let t=0;t<this.rows;t++)for(let e=0;e<this.columns;e++)this.set(t,e,Math.abs(this.get(t,e)));return this},t.abs=function(t){return new e(t).abs()},t.prototype.acos=function(){for(let t=0;t<this.rows;t++)for(let e=0;e<this.columns;e++)this.set(t,e,Math.acos(this.get(t,e)));return this},t.acos=function(t){return new e(t).acos()},t.prototype.acosh=function(){for(let t=0;t<this.rows;t++)for(let e=0;e<this.columns;e++)this.set(t,e,Math.acosh(this.get(t,e)));return this},t.acosh=function(t){return new e(t).acosh()},t.prototype.asin=function(){for(let t=0;t<this.rows;t++)for(let e=0;e<this.columns;e++)this.set(t,e,Math.asin(this.get(t,e)));return this},t.asin=function(t){return new e(t).asin()},t.prototype.asinh=function(){for(let t=0;t<this.rows;t++)for(let e=0;e<this.columns;e++)this.set(t,e,Math.asinh(this.get(t,e)));return this},t.asinh=function(t){return new e(t).asinh()},t.prototype.atan=function(){for(let t=0;t<this.rows;t++)for(let e=0;e<this.columns;e++)this.set(t,e,Math.atan(this.get(t,e)));return this},t.atan=function(t){return new e(t).atan()},t.prototype.atanh=function(){for(let t=0;t<this.rows;t++)for(let e=0;e<this.columns;e++)this.set(t,e,Math.atanh(this.get(t,e)));return this},t.atanh=function(t){return new e(t).atanh()},t.prototype.cbrt=function(){for(let t=0;t<this.rows;t++)for(let e=0;e<this.columns;e++)this.set(t,e,Math.cbrt(this.get(t,e)));return this},t.cbrt=function(t){return new e(t).cbrt()},t.prototype.ceil=function(){for(let t=0;t<this.rows;t++)for(let e=0;e<this.columns;e++)this.set(t,e,Math.ceil(this.get(t,e)));return this},t.ceil=function(t){return new e(t).ceil()},t.prototype.clz32=function(){for(let t=0;t<this.rows;t++)for(let e=0;e<this.columns;e++)this.set(t,e,Math.clz32(this.get(t,e)));return this},t.clz32=function(t){return new e(t).clz32()},t.prototype.cos=function(){for(let t=0;t<this.rows;t++)for(let e=0;e<this.columns;e++)this.set(t,e,Math.cos(this.get(t,e)));return this},t.cos=function(t){return new e(t).cos()},t.prototype.cosh=function(){for(let t=0;t<this.rows;t++)for(let e=0;e<this.columns;e++)this.set(t,e,Math.cosh(this.get(t,e)));return this},t.cosh=function(t){return new e(t).cosh()},t.prototype.exp=function(){for(let t=0;t<this.rows;t++)for(let e=0;e<this.columns;e++)this.set(t,e,Math.exp(this.get(t,e)));return this},t.exp=function(t){return new e(t).exp()},t.prototype.expm1=function(){for(let t=0;t<this.rows;t++)for(let e=0;e<this.columns;e++)this.set(t,e,Math.expm1(this.get(t,e)));return this},t.expm1=function(t){return new e(t).expm1()},t.prototype.floor=function(){for(let t=0;t<this.rows;t++)for(let e=0;e<this.columns;e++)this.set(t,e,Math.floor(this.get(t,e)));return this},t.floor=function(t){return new e(t).floor()},t.prototype.fround=function(){for(let t=0;t<this.rows;t++)for(let e=0;e<this.columns;e++)this.set(t,e,Math.fround(this.get(t,e)));return this},t.fround=function(t){return new e(t).fround()},t.prototype.log=function(){for(let t=0;t<this.rows;t++)for(let e=0;e<this.columns;e++)this.set(t,e,Math.log(this.get(t,e)));return this},t.log=function(t){return new e(t).log()},t.prototype.log1p=function(){for(let t=0;t<this.rows;t++)for(let e=0;e<this.columns;e++)this.set(t,e,Math.log1p(this.get(t,e)));return this},t.log1p=function(t){return new e(t).log1p()},t.prototype.log10=function(){for(let t=0;t<this.rows;t++)for(let e=0;e<this.columns;e++)this.set(t,e,Math.log10(this.get(t,e)));return this},t.log10=function(t){return new e(t).log10()},t.prototype.log2=function(){for(let t=0;t<this.rows;t++)for(let e=0;e<this.columns;e++)this.set(t,e,Math.log2(this.get(t,e)));return this},t.log2=function(t){return new e(t).log2()},t.prototype.round=function(){for(let t=0;t<this.rows;t++)for(let e=0;e<this.columns;e++)this.set(t,e,Math.round(this.get(t,e)));return this},t.round=function(t){return new e(t).round()},t.prototype.sign=function(){for(let t=0;t<this.rows;t++)for(let e=0;e<this.columns;e++)this.set(t,e,Math.sign(this.get(t,e)));return this},t.sign=function(t){return new e(t).sign()},t.prototype.sin=function(){for(let t=0;t<this.rows;t++)for(let e=0;e<this.columns;e++)this.set(t,e,Math.sin(this.get(t,e)));return this},t.sin=function(t){return new e(t).sin()},t.prototype.sinh=function(){for(let t=0;t<this.rows;t++)for(let e=0;e<this.columns;e++)this.set(t,e,Math.sinh(this.get(t,e)));return this},t.sinh=function(t){return new e(t).sinh()},t.prototype.sqrt=function(){for(let t=0;t<this.rows;t++)for(let e=0;e<this.columns;e++)this.set(t,e,Math.sqrt(this.get(t,e)));return this},t.sqrt=function(t){return new e(t).sqrt()},t.prototype.tan=function(){for(let t=0;t<this.rows;t++)for(let e=0;e<this.columns;e++)this.set(t,e,Math.tan(this.get(t,e)));return this},t.tan=function(t){return new e(t).tan()},t.prototype.tanh=function(){for(let t=0;t<this.rows;t++)for(let e=0;e<this.columns;e++)this.set(t,e,Math.tanh(this.get(t,e)));return this},t.tanh=function(t){return new e(t).tanh()},t.prototype.trunc=function(){for(let t=0;t<this.rows;t++)for(let e=0;e<this.columns;e++)this.set(t,e,Math.trunc(this.get(t,e)));return this},t.trunc=function(t){return new e(t).trunc()},t.pow=function(t,r){return new e(t).pow(r)},t.prototype.pow=function(t){return"number"==typeof t?this.powS(t):this.powM(t)},t.prototype.powS=function(t){for(let e=0;e<this.rows;e++)for(let r=0;r<this.columns;r++)this.set(e,r,Math.pow(this.get(e,r),t));return this},t.prototype.powM=function(t){if(t=e.checkMatrix(t),this.rows!==t.rows||this.columns!==t.columns)throw new RangeError("Matrices dimensions must be equal");for(let e=0;e<this.rows;e++)for(let r=0;r<this.columns;r++)this.set(e,r,Math.pow(this.get(e,r),t.get(e,r)));return this}}(an,un);class dn extends an{constructor(t){super(),this.data=t,this.rows=t.length,this.columns=t[0].length}set(t,e,r){return this.data[t][e]=r,this}get(t,e){return this.data[t][e]}}function hn(t,e){let r=0;return Math.abs(t)>Math.abs(e)?(r=e/t,Math.abs(t)*Math.sqrt(1+r*r)):0!==e?(r=t/e,Math.abs(e)*Math.sqrt(1+r*r)):0}class cn{constructor(t,e={}){if((t=dn.checkMatrix(t)).isEmpty())throw new Error("Matrix must be non-empty");let r=t.rows,n=t.columns;const{computeLeftSingularVectors:o=!0,computeRightSingularVectors:i=!0,autoTranspose:a=!1}=e;let s,u=Boolean(o),d=Boolean(i),h=!1;if(r<n)if(a){s=t.transpose(),r=s.rows,n=s.columns,h=!0;let e=u;u=d,d=e}else s=t.clone(),console.warn("Computing SVD on a matrix with more columns than rows. Consider enabling autoTranspose");else s=t.clone();let c=Math.min(r,n),l=Math.min(r+1,n),f=new Float64Array(l),g=new un(r,c),p=new un(n,n),v=new Float64Array(n),y=new Float64Array(r),m=new Float64Array(l);for(let t=0;t<l;t++)m[t]=t;let w=Math.min(r-1,n),x=Math.max(0,Math.min(n-2,r)),E=Math.max(w,x);for(let t=0;t<E;t++){if(t<w){f[t]=0;for(let e=t;e<r;e++)f[t]=hn(f[t],s.get(e,t));if(0!==f[t]){s.get(t,t)<0&&(f[t]=-f[t]);for(let e=t;e<r;e++)s.set(e,t,s.get(e,t)/f[t]);s.set(t,t,s.get(t,t)+1)}f[t]=-f[t]}for(let e=t+1;e<n;e++){if(t<w&&0!==f[t]){let n=0;for(let o=t;o<r;o++)n+=s.get(o,t)*s.get(o,e);n=-n/s.get(t,t);for(let o=t;o<r;o++)s.set(o,e,s.get(o,e)+n*s.get(o,t))}v[e]=s.get(t,e)}if(u&&t<w)for(let e=t;e<r;e++)g.set(e,t,s.get(e,t));if(t<x){v[t]=0;for(let e=t+1;e<n;e++)v[t]=hn(v[t],v[e]);if(0!==v[t]){v[t+1]<0&&(v[t]=0-v[t]);for(let e=t+1;e<n;e++)v[e]/=v[t];v[t+1]+=1}if(v[t]=-v[t],t+1<r&&0!==v[t]){for(let e=t+1;e<r;e++)y[e]=0;for(let e=t+1;e<r;e++)for(let r=t+1;r<n;r++)y[e]+=v[r]*s.get(e,r);for(let e=t+1;e<n;e++){let n=-v[e]/v[t+1];for(let o=t+1;o<r;o++)s.set(o,e,s.get(o,e)+n*y[o])}}if(d)for(let e=t+1;e<n;e++)p.set(e,t,v[e])}}let b=Math.min(n,r+1);if(w<n&&(f[w]=s.get(w,w)),r<b&&(f[b-1]=0),x+1<b&&(v[x]=s.get(x,b-1)),v[b-1]=0,u){for(let t=w;t<c;t++){for(let e=0;e<r;e++)g.set(e,t,0);g.set(t,t,1)}for(let t=w-1;t>=0;t--)if(0!==f[t]){for(let e=t+1;e<c;e++){let n=0;for(let o=t;o<r;o++)n+=g.get(o,t)*g.get(o,e);n=-n/g.get(t,t);for(let o=t;o<r;o++)g.set(o,e,g.get(o,e)+n*g.get(o,t))}for(let e=t;e<r;e++)g.set(e,t,-g.get(e,t));g.set(t,t,1+g.get(t,t));for(let e=0;e<t-1;e++)g.set(e,t,0)}else{for(let e=0;e<r;e++)g.set(e,t,0);g.set(t,t,1)}}if(d)for(let t=n-1;t>=0;t--){if(t<x&&0!==v[t])for(let e=t+1;e<n;e++){let r=0;for(let o=t+1;o<n;o++)r+=p.get(o,t)*p.get(o,e);r=-r/p.get(t+1,t);for(let o=t+1;o<n;o++)p.set(o,e,p.get(o,e)+r*p.get(o,t))}for(let e=0;e<n;e++)p.set(e,t,0);p.set(t,t,1)}let N=b-1,M=0,S=Number.EPSILON;for(;b>0;){let t,e;for(t=b-2;t>=-1&&-1!==t;t--){const e=Number.MIN_VALUE+S*Math.abs(f[t]+Math.abs(f[t+1]));if(Math.abs(v[t])<=e||Number.isNaN(v[t])){v[t]=0;break}}if(t===b-2)e=4;else{let r;for(r=b-1;r>=t&&r!==t;r--){let e=(r!==b?Math.abs(v[r]):0)+(r!==t+1?Math.abs(v[r-1]):0);if(Math.abs(f[r])<=S*e){f[r]=0;break}}r===t?e=3:r===b-1?e=1:(e=2,t=r)}switch(t++,e){case 1:{let e=v[b-2];v[b-2]=0;for(let r=b-2;r>=t;r--){let o=hn(f[r],e),i=f[r]/o,a=e/o;if(f[r]=o,r!==t&&(e=-a*v[r-1],v[r-1]=i*v[r-1]),d)for(let t=0;t<n;t++)o=i*p.get(t,r)+a*p.get(t,b-1),p.set(t,b-1,-a*p.get(t,r)+i*p.get(t,b-1)),p.set(t,r,o)}break}case 2:{let e=v[t-1];v[t-1]=0;for(let n=t;n<b;n++){let o=hn(f[n],e),i=f[n]/o,a=e/o;if(f[n]=o,e=-a*v[n],v[n]=i*v[n],u)for(let e=0;e<r;e++)o=i*g.get(e,n)+a*g.get(e,t-1),g.set(e,t-1,-a*g.get(e,n)+i*g.get(e,t-1)),g.set(e,n,o)}break}case 3:{const e=Math.max(Math.abs(f[b-1]),Math.abs(f[b-2]),Math.abs(v[b-2]),Math.abs(f[t]),Math.abs(v[t])),o=f[b-1]/e,i=f[b-2]/e,a=v[b-2]/e,s=f[t]/e,h=v[t]/e,c=((i+o)*(i-o)+a*a)/2,l=o*a*(o*a);let y=0;0===c&&0===l||(y=c<0?0-Math.sqrt(c*c+l):Math.sqrt(c*c+l),y=l/(c+y));let m=(s+o)*(s-o)+y,w=s*h;for(let e=t;e<b-1;e++){let o=hn(m,w);0===o&&(o=Number.MIN_VALUE);let i=m/o,a=w/o;if(e!==t&&(v[e-1]=o),m=i*f[e]+a*v[e],v[e]=i*v[e]-a*f[e],w=a*f[e+1],f[e+1]=i*f[e+1],d)for(let t=0;t<n;t++)o=i*p.get(t,e)+a*p.get(t,e+1),p.set(t,e+1,-a*p.get(t,e)+i*p.get(t,e+1)),p.set(t,e,o);if(o=hn(m,w),0===o&&(o=Number.MIN_VALUE),i=m/o,a=w/o,f[e]=o,m=i*v[e]+a*f[e+1],f[e+1]=-a*v[e]+i*f[e+1],w=a*v[e+1],v[e+1]=i*v[e+1],u&&e<r-1)for(let t=0;t<r;t++)o=i*g.get(t,e)+a*g.get(t,e+1),g.set(t,e+1,-a*g.get(t,e)+i*g.get(t,e+1)),g.set(t,e,o)}v[b-2]=m,M+=1;break}case 4:if(f[t]<=0&&(f[t]=f[t]<0?-f[t]:0,d))for(let e=0;e<=N;e++)p.set(e,t,-p.get(e,t));for(;t<N&&!(f[t]>=f[t+1]);){let e=f[t];if(f[t]=f[t+1],f[t+1]=e,d&&t<n-1)for(let r=0;r<n;r++)e=p.get(r,t+1),p.set(r,t+1,p.get(r,t)),p.set(r,t,e);if(u&&t<r-1)for(let n=0;n<r;n++)e=g.get(n,t+1),g.set(n,t+1,g.get(n,t)),g.set(n,t,e);t++}M=0,b--}}if(h){let t=p;p=g,g=t}this.m=r,this.n=n,this.s=f,this.U=g,this.V=p}solve(t){let e=t,r=this.threshold,n=this.s.length,o=un.zeros(n,n);for(let t=0;t<n;t++)Math.abs(this.s[t])<=r?o.set(t,t,0):o.set(t,t,1/this.s[t]);let i=this.U,a=this.rightSingularVectors,s=a.mmul(o),u=a.rows,d=i.rows,h=un.zeros(u,d);for(let t=0;t<u;t++)for(let e=0;e<d;e++){let r=0;for(let o=0;o<n;o++)r+=s.get(t,o)*i.get(e,o);h.set(t,e,r)}return h.mmul(e)}solveForDiagonal(t){return this.solve(un.diag(t))}inverse(){let t=this.V,e=this.threshold,r=t.rows,n=t.columns,o=new un(r,this.s.length);for(let i=0;i<r;i++)for(let r=0;r<n;r++)Math.abs(this.s[r])>e&&o.set(i,r,t.get(i,r)/this.s[r]);let i=this.U,a=i.rows,s=i.columns,u=new un(r,a);for(let t=0;t<r;t++)for(let e=0;e<a;e++){let r=0;for(let n=0;n<s;n++)r+=o.get(t,n)*i.get(e,n);u.set(t,e,r)}return u}get condition(){return this.s[0]/this.s[Math.min(this.m,this.n)-1]}get norm2(){return this.s[0]}get rank(){let t=Math.max(this.m,this.n)*this.s[0]*Number.EPSILON,e=0,r=this.s;for(let n=0,o=r.length;n<o;n++)r[n]>t&&e++;return e}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 un.diag(this.s)}}var ln,fn={center:[0,0],linkDistance:50},gn=function(){function t(t){void 0===t&&(t={}),this.options=t,this.id="mds",this.options=n(n({},fn),t)}return t.prototype.execute=function(t,e){return i(this,void 0,void 0,(function(){return a(this,(function(r){return[2,this.genericMDSLayout(!1,t,e)]}))}))},t.prototype.assign=function(t,e){return i(this,void 0,void 0,(function(){return a(this,(function(r){return this.genericMDSLayout(!0,t,e),[2]}))}))},t.prototype.genericMDSLayout=function(t,e,r){return i(this,void 0,void 0,(function(){var o,i,s,u,d,h,c,l,f,g,p;return a(this,(function(a){return o=n(n({},this.options),r),i=o.center,s=void 0===i?[0,0]:i,u=o.linkDistance,d=void 0===u?50:u,h=e.getAllNodes(),c=e.getAllEdges(),(null==h?void 0:h.length)&&1!==h.length?(l=y({nodes:h,edges:c},!1),f=v(l),pn(f),m=d,w=[],f.forEach((function(t){var e=[];t.forEach((function(t){e.push(t*m)})),w.push(e)})),g=vn(w),p=[],g.forEach((function(t,e){var r=N(h[e]);r.data.x=t[0]+s[0],r.data.y=t[1]+s[1],p.push(r)})),t&&p.forEach((function(t){return e.mergeNodeData(t.id,{x:t.data.x,y:t.data.y})})),[2,{nodes:p,edges:c}]):[2,I(e,t,s)];var m,w}))}))},t}(),pn=function(t){var e=-999999;t.forEach((function(t){t.forEach((function(t){t!==1/0&&e<t&&(e=t)}))})),t.forEach((function(r,n){r.forEach((function(r,o){r===1/0&&(t[n][o]=e)}))}))},vn=function(t){var e=un.mul(un.pow(t,2),-.5),r=e.mean("row"),n=e.mean("column"),o=e.mean();e.add(o).subRowVector(r).subColumnVector(n);var i=new cn(e),a=un.sqrt(i.diagonalMatrix).diagonal();return i.leftSingularVectors.toJSON().map((function(t){return un.mul([t],[a]).toJSON()[0].splice(0,2)}))},yn={iterations:10,height:10,width:10,speed:100,gravity:10,k:5},mn=function(t,e,r,n,o,i){e.forEach((function(a,s){r[s]={x:0,y:0},e.forEach((function(e,u){if(s!==u&&o[s]===o[u]){var d=a.x-e.x,h=a.y-e.y,c=Math.sqrt(d*d+h*h);if(0===c){c=1;var l=s>u?1:-1;d=.01*l,h=.01*l}if(c<i(t[s])/2+i(t[u])/2){var f=n*n/c;r[s].x+=d/c*f,r[s].y+=h/c*f}}}))}))},wn=function(t,e,r,n,o,i,a,s){var u=i||a/10;return n&&e.forEach((function(e,r){var n=t[r].x-t[o].x,i=t[r].y-t[o].y,a=Math.sqrt(n*n+i*i),s=i/a,u=-n/a,d=Math.sqrt(e.x*e.x+e.y*e.y),h=Math.acos((s*e.x+u*e.y)/d);h>Math.PI/2&&(h-=Math.PI/2,s*=-1,u*=-1);var c=Math.cos(h)*d;e.x=s*c,e.y=u*c})),t.forEach((function(i,a){if(a!==o){var d=Math.sqrt(e[a].x*e[a].x+e[a].y*e[a].y);if(d>0&&a!==o){var h=Math.min(u*(r/800),d);if(i.x+=e[a].x/d*h,i.y+=e[a].y/d*h,n){var c=i.x-t[o].x,l=i.y-t[o].y,f=Math.sqrt(c*c+l*l);c=c/f*s[a],l=l/f*s[a],i.x=t[o].x+c,i.y=t[o].y+l}}}})),t},xn={maxIteration:1e3,focusNode:null,unitRadius:null,linkDistance:50,preventOverlap:!1,strictRadial:!0,maxPreventOverlapIteration:200,sortStrength:10},En=function(){function t(t){void 0===t&&(t={}),this.options=t,this.id="radial",this.options=n(n({},xn),t)}return t.prototype.execute=function(t,e){return i(this,void 0,void 0,(function(){return a(this,(function(r){return[2,this.genericRadialLayout(!1,t,e)]}))}))},t.prototype.assign=function(t,e){return i(this,void 0,void 0,(function(){return a(this,(function(r){return this.genericRadialLayout(!0,t,e),[2]}))}))},t.prototype.genericRadialLayout=function(t,e,r){return i(this,void 0,void 0,(function(){var o,i,d,h,c,l,f,g,p,m,w,x,E,b,M,S,k,A,_,D,O,P,z,C,L,q,j,F,V,G,W,B,$,U,H,K,Y,J,X,Q,Z,tt,et;return a(this,(function(a){if(o=n(n({},this.options),r),i=o.width,d=o.height,h=o.center,c=o.focusNode,l=o.unitRadius,f=o.nodeSize,g=o.nodeSpacing,p=o.strictRadial,m=o.preventOverlap,w=o.maxPreventOverlapIteration,x=o.sortBy,E=o.linkDistance,b=void 0===E?50:E,M=o.sortStrength,S=void 0===M?10:M,k=o.maxIteration,A=void 0===k?1e3:k,_=e.getAllNodes(),D=e.getAllEdges(),O=i||"undefined"==typeof window?i:window.innerWidth,P=d||"undefined"==typeof window?d:window.innerHeight,z=h||[O/2,P/2],!(null==_?void 0:_.length)||1===_.length)return[2,I(e,t,z)];if(C=_[0],T(c)){for(L=0;L<_.length;L++)if(_[L].id===c){C=_[L];break}}else C=c||_[0];return q=Mn(_,C.id),j=y({nodes:_,edges:D},!1),F=v(j),V=kn(F,q),Sn(F,q,V+1),G=F[q],W=O-z[0]>z[0]?z[0]:O-z[0],B=P-z[1]>z[1]?z[1]:P-z[1],0===W&&(W=O/2),0===B&&(B=P/2),$=Math.min(W,B),U=Math.max.apply(Math,u([],s(G),!1)),H=[],K=l||$/U,G.forEach((function(t,e){H[e]=t*K})),Y=bn(_,F,b,H,K,x,S),J=Nn(Y),X=function(t,e,r){try{var n=un.mul(un.pow(e,2),-.5),o=n.mean("row"),i=n.mean("column"),a=n.mean();n.add(a).subRowVector(o).subColumnVector(i);var s=new cn(n),u=un.sqrt(s.diagonalMatrix).diagonal();return s.leftSingularVectors.toJSON().map((function(e){return un.mul([e],[u]).toJSON()[0].splice(0,t)}))}catch(t){for(var d=[],h=0;h<e.length;h++){var c=Math.random()*r,l=Math.random()*r;d.push([c,l])}return d}}(b,Y,b),Q=X.map((function(t){var e=s(t,2),r=e[0],n=e[1];return{x:(isNaN(r)?Math.random()*b:r)-X[q][0],y:(isNaN(n)?Math.random()*b:n)-X[q][1]}})),this.run(A,Q,J,Y,H,q),m&&(Z=R(f,g),tt={nodes:_,nodeSizeFunc:Z,positions:Q,radii:H,height:P,width:O,strictRadial:Boolean(p),focusIdx:q,iterations:w||200,k:Q.length/4.5},Q=function(t,e){for(var r=n(n({},yn),e),o=r.positions,i=r.iterations,a=r.width,s=r.k,u=r.speed,d=void 0===u?100:u,h=r.strictRadial,c=r.focusIdx,l=r.radii,f=void 0===l?[]:l,g=r.nodeSizeFunc,p=t.getAllNodes(),v=[],y=a/10,m=0;m<i;m++)o.forEach((function(t,e){v[e]={x:0,y:0}})),mn(p,o,v,s,f,g),wn(o,v,d,h,c,y,a,f);return o}(e,tt)),et=[],Q.forEach((function(t,e){var r=N(_[e]);r.data.x=t.x+z[0],r.data.y=t.y+z[1],et.push(r)})),t&&et.forEach((function(t){return e.mergeNodeData(t.id,{x:t.data.x,y:t.data.y})})),[2,{nodes:et,edges:D}]}))}))},t.prototype.run=function(t,e,r,n,o,i){for(var a=0;a<=t;a++){var s=a/t;this.oneIteration(s,e,o,n,r,i)}},t.prototype.oneIteration=function(t,e,r,n,o,i){var a=1-t;e.forEach((function(s,u){var d=m(s,{x:0,y:0}),h=0===d?0:1/d;if(u!==i){var c=0,l=0,f=0;e.forEach((function(t,e){if(u!==e){var r=m(s,t),i=0===r?0:1/r,a=n[e][u];f+=o[u][e],c+=o[u][e]*(t.x+a*(s.x-t.x)*i),l+=o[u][e]*(t.y+a*(s.y-t.y)*i)}}));var g=0===r[u]?0:1/r[u];f*=a,f+=t*g*g,c*=a,c+=t*g*s.x*h,s.x=c/f,l*=a,l+=t*g*s.y*h,s.y=l/f}}))},t}(),bn=function(t,e,r,n,o,i,a){if(!t)return[];var s=[];if(e){var u={};e.forEach((function(e,d){var h=[];e.forEach((function(e,s){var c,l;if(d===s)h.push(0);else if(n[d]===n[s])if("data"===i)h.push(e*(Math.abs(d-s)*a)/(n[d]/o));else if(i){var f=void 0,g=void 0;if(u[t[d].id])f=u[t[d].id];else{var p=("id"===i?t[d].id:null===(c=t[d].data)||void 0===c?void 0:c[i])||0;f=T(p)?p.charCodeAt(0):p,u[t[d].id]=f}u[t[s].id]?g=u[t[s].id]:(p=("id"===i?t[s].id:null===(l=t[s].data)||void 0===l?void 0:l[i])||0,g=T(p)?p.charCodeAt(0):p,u[t[s].id]=g),h.push(e*(Math.abs(f-g)*a)/(n[d]/o))}else h.push(e*r/(n[d]/o));else{var v=(r+o)/2;h.push(e*v)}})),s.push(h)}))}return s},Nn=function(t){for(var e=t.length,r=t[0].length,n=[],o=0;o<e;o++){for(var i=[],a=0;a<r;a++)0!==t[o][a]?i.push(1/(t[o][a]*t[o][a])):i.push(0);n.push(i)}return n},Mn=function(t,e){var r=-1;return t.forEach((function(t,n){t.id===e&&(r=n)})),Math.max(r,0)},Sn=function(t,e,r){for(var n=t.length,o=0;o<n;o++)if(t[e][o]===1/0){t[e][o]=r,t[o][e]=r;for(var i=0;i<n;i++)t[o][i]!==1/0&&t[e][i]===1/0&&(t[e][i]=r+t[o][i],t[i][e]=r+t[o][i])}for(o=0;o<n;o++)if(o!==e)for(i=0;i<n;i++)if(t[o][i]===1/0){var a=Math.abs(t[e][o]-t[e][i]);a=0===a?1:a,t[o][i]=a}},kn=function(t,e){for(var r=0,n=0;n<t[e].length;n++)t[e][n]!==1/0&&(r=t[e][n]>r?t[e][n]:r);return r},An={center:[0,0],width:300,height:300},Rn=function(){function t(t){void 0===t&&(t={}),this.options=t,this.id="random",this.options=n(n({},An),t)}return t.prototype.execute=function(t,e){return i(this,void 0,void 0,(function(){return a(this,(function(r){return[2,this.genericRandomLayout(!1,t,e)]}))}))},t.prototype.assign=function(t,e){return i(this,void 0,void 0,(function(){return a(this,(function(r){return this.genericRandomLayout(!0,t,e),[2]}))}))},t.prototype.genericRandomLayout=function(t,e,r){return i(this,void 0,void 0,(function(){var o,i,s,u,d,h,c,l,f;return a(this,(function(a){return o=n(n({},this.options),r),i=o.center,s=o.width,u=o.height,d=e.getAllNodes(),h=s||"undefined"==typeof window?s:window.innerWidth,c=u||"undefined"==typeof window?u:window.innerHeight,l=i||[h/2,c/2],f=[],d&&d.forEach((function(t){f.push({id:t.id,data:{x:.9*(Math.random()-.5)*h+l[0],y:.9*(Math.random()-.5)*c+l[1]}})})),t&&f.forEach((function(t){return e.mergeNodeData(t.id,{x:t.data.x,y:t.data.y})})),[2,{nodes:f,edges:e.getAllEdges()}]}))}))},t}(),In={circular:D,concentric:C,mds:gn,random:Rn,grid:Cr,radial:En,force:Er,d3force:Ct,fruchterman:Tr,forceAtlas2:Or,dagre:vr};function _n(){(null==ln?void 0:ln.stop)&&ln.stop()}function Dn(t,e){return i(this,void 0,void 0,(function(){var r,n,o,i,s,u,d,h,c;return a(this,(function(a){switch(a.label){case 0:if(r=t.layout,n=r.id,o=r.options,i=r.iterations,s=t.nodes,u=t.edges,d=new f({nodes:s,edges:u}),!(h=In[n]))throw new Error("Unknown layout id: ".concat(n));return[4,(ln=new h(o)).execute(d)];case 1:return c=a.sent(),!!(l=ln).tick&&!!l.stop&&(ln.stop(),c=ln.tick(i)),[2,[c,e]]}var l}))}))}addEventListener("message",(function(t){var r,n=t.data,o=n.type,i=n.method,a=n.id,s=n.params;"RPC"===o&&i&&((r=e[i])?Promise.resolve().then((function(){return r.apply(e,s)})):Promise.reject("No such method")).then((function(t){postMessage({type:"RPC",id:a,result:t})})).catch((function(t){var e={message:t};t.stack&&(e.message=t.message,e.stack=t.stack,e.name=t.name),postMessage({type:"RPC",id:a,error:e})}))})),postMessage({type:"RPC",method:"ready"});\n//# sourceMappingURL=5eff5240d48719e2c5a3.worker.js.map'])),{name:"[fullhash].worker.js"});return URL.revokeObjectURL(URL.createObjectURL(new Blob(['var t={d:(e,r)=>{for(var n in r)t.o(r,n)&&!t.o(e,n)&&Object.defineProperty(e,n,{enumerable:!0,get:r[n]})},o:(t,e)=>Object.prototype.hasOwnProperty.call(t,e)},e={};t.d(e,{calculateLayout:()=>Dn,stopLayout:()=>_n});var r=function(t,e){return r=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(t,e){t.__proto__=e}||function(t,e){for(var r in e)Object.prototype.hasOwnProperty.call(e,r)&&(t[r]=e[r])},r(t,e)},n=function(){return n=Object.assign||function(t){for(var e,r=1,n=arguments.length;r<n;r++)for(var o in e=arguments[r])Object.prototype.hasOwnProperty.call(e,o)&&(t[o]=e[o]);return t},n.apply(this,arguments)};function o(t,e){var r={};for(var n in t)Object.prototype.hasOwnProperty.call(t,n)&&e.indexOf(n)<0&&(r[n]=t[n]);if(null!=t&&"function"==typeof Object.getOwnPropertySymbols){var o=0;for(n=Object.getOwnPropertySymbols(t);o<n.length;o++)e.indexOf(n[o])<0&&Object.prototype.propertyIsEnumerable.call(t,n[o])&&(r[n[o]]=t[n[o]])}return r}function i(t,e,r,n){return new(r||(r=Promise))((function(o,i){function a(t){try{u(n.next(t))}catch(t){i(t)}}function s(t){try{u(n.throw(t))}catch(t){i(t)}}function u(t){var e;t.done?o(t.value):(e=t.value,e instanceof r?e:new r((function(t){t(e)}))).then(a,s)}u((n=n.apply(t,e||[])).next())}))}function a(t,e){var r,n,o,i,a={label:0,sent:function(){if(1&o[0])throw o[1];return o[1]},trys:[],ops:[]};return i={next:s(0),throw:s(1),return:s(2)},"function"==typeof Symbol&&(i[Symbol.iterator]=function(){return this}),i;function s(s){return function(u){return function(s){if(r)throw new TypeError("Generator is already executing.");for(;i&&(i=0,s[0]&&(a=0)),a;)try{if(r=1,n&&(o=2&s[0]?n.return:s[0]?n.throw||((o=n.return)&&o.call(n),0):n.next)&&!(o=o.call(n,s[1])).done)return o;switch(n=0,o&&(s=[2&s[0],o.value]),s[0]){case 0:case 1:o=s;break;case 4:return a.label++,{value:s[1],done:!1};case 5:a.label++,n=s[1],s=[0];continue;case 7:s=a.ops.pop(),a.trys.pop();continue;default:if(!((o=(o=a.trys).length>0&&o[o.length-1])||6!==s[0]&&2!==s[0])){a=0;continue}if(3===s[0]&&(!o||s[1]>o[0]&&s[1]<o[3])){a.label=s[1];break}if(6===s[0]&&a.label<o[1]){a.label=o[1],o=s;break}if(o&&a.label<o[2]){a.label=o[2],a.ops.push(s);break}o[2]&&a.ops.pop(),a.trys.pop();continue}s=e.call(t,a)}catch(t){s=[6,t],n=0}finally{r=o=0}if(5&s[0])throw s[1];return{value:s[0]?s[1]:void 0,done:!0}}([s,u])}}}function s(t,e){var r="function"==typeof Symbol&&t[Symbol.iterator];if(!r)return t;var n,o,i=r.call(t),a=[];try{for(;(void 0===e||e-- >0)&&!(n=i.next()).done;)a.push(n.value)}catch(t){o={error:t}}finally{try{n&&!n.done&&(r=i.return)&&r.call(i)}finally{if(o)throw o.error}}return a}function u(t,e,r){if(r||2===arguments.length)for(var n,o=0,i=e.length;o<i;o++)!n&&o in e||(n||(n=Array.prototype.slice.call(e,0,o)),n[o]=e[o]);return t.concat(n||Array.prototype.slice.call(e))}Object.create,Object.create;var d="*";const h=function(){function t(){this._events={}}return t.prototype.on=function(t,e,r){return this._events[t]||(this._events[t]=[]),this._events[t].push({callback:e,once:!!r}),this},t.prototype.once=function(t,e){return this.on(t,e,!0)},t.prototype.emit=function(t){for(var e=this,r=[],n=1;n<arguments.length;n++)r[n-1]=arguments[n];var o=this._events[t]||[],i=this._events[d]||[],a=function(n){for(var o=n.length,i=0;i<o;i++)if(n[i]){var a=n[i],s=a.callback;a.once&&(n.splice(i,1),0===n.length&&delete e._events[t],o--,i--),s.apply(e,r)}};a(o),a(i)},t.prototype.off=function(t,e){if(t)if(e){for(var r=this._events[t]||[],n=r.length,o=0;o<n;o++)r[o].callback===e&&(r.splice(o,1),n--,o--);0===r.length&&delete this._events[t]}else delete this._events[t];else this._events={};return this},t.prototype.getEvents=function(){return this._events},t}();function c(t,e,r,n){for(;t.length;){const o=t.shift();if(r(o))return!0;e.add(o.id),n(o.id).forEach((r=>{e.has(r.id)||(e.add(r.id),t.push(r))}))}return!1}function l(t,e,r,n){if(r(t))return!0;e.add(t.id);for(const o of n(t.id))if(!e.has(o.id)&&l(o,e,r,n))return!0;return!1}class f extends h{nodeMap=new Map;edgeMap=new Map;inEdgesMap=new Map;outEdgesMap=new Map;bothEdgesMap=new Map;treeIndices=new Map;changes=[];batchCount=0;onChanged=()=>{};constructor(t){super(),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))}batch=t=>{this.batchCount+=1,t(),this.batchCount-=1,this.batchCount||this.commit()};commit(){const t=this.changes;this.changes=[];const e={graph:this,changes:t};this.emit("changed",e),this.onChanged(e)}reduceChanges(t){let e=[];return t.forEach((t=>{switch(t.type){case"NodeRemoved":{let r=!1;e=e.filter((e=>{if("NodeAdded"===e.type){const n=e.value.id===t.value.id;return n&&(r=!0),!n}return"NodeDataUpdated"===e.type?e.id!==t.value.id:"TreeStructureChanged"!==e.type||e.nodeId!==t.value.id})),r||e.push(t);break}case"EdgeRemoved":{let r=!1;e=e.filter((e=>{if("EdgeAdded"===e.type){const n=e.value.id===t.value.id;return n&&(r=!0),!n}return"EdgeDataUpdated"!==e.type&&"EdgeUpdated"!==e.type||e.id!==t.value.id})),r||e.push(t);break}case"NodeDataUpdated":case"EdgeDataUpdated":case"EdgeUpdated":{const r=e.find((e=>e.type===t.type&&e.id===t.id&&e.propertyName===t.propertyName));r?r.newValue=t.newValue:e.push(t);break}case"TreeStructureDetached":e=e.filter((e=>"TreeStructureAttached"===e.type?e.treeKey!==t.treeKey:"TreeStructureChanged"!==e.type||e.treeKey!==t.treeKey)),e.push(t);break;case"TreeStructureChanged":{const r=e.find((e=>"TreeStructureChanged"===e.type&&e.treeKey===t.treeKey&&e.nodeId===t.nodeId));r?r.newParentId=t.newParentId:e.push(t);break}default:e.push(t)}})),e}checkNodeExistence(t){this.getNode(t)}hasNode(t){return this.nodeMap.has(t)}areNeighbors(t,e){return this.getNeighbors(e).some((e=>e.id===t))}getNode(t){const e=this.nodeMap.get(t);if(!e)throw new Error("Node not found for id: "+t);return e}getRelatedEdges(t,e){if(this.checkNodeExistence(t),"in"===e){const e=this.inEdgesMap.get(t);return Array.from(e)}if("out"===e){const e=this.outEdgesMap.get(t);return Array.from(e)}{const e=this.bothEdgesMap.get(t);return Array.from(e)}}getDegree(t,e){return this.getRelatedEdges(t,e).length}getSuccessors(t){const e=this.getRelatedEdges(t,"out").map((t=>this.getNode(t.target)));return Array.from(new Set(e))}getPredecessors(t){const e=this.getRelatedEdges(t,"in").map((t=>this.getNode(t.source)));return Array.from(new Set(e))}getNeighbors(t){const e=this.getPredecessors(t),r=this.getSuccessors(t);return Array.from(new Set([...e,...r]))}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((e=>{e.childrenMap.set(t.id,new Set)})),this.changes.push({type:"NodeAdded",value:t})}addNodes(t){this.batch((()=>{for(const e of t)this.doAddNode(e)}))}addNode(t){this.addNodes([t])}doRemoveNode(t){const e=this.getNode(t);this.bothEdgesMap.get(t)?.forEach((t=>this.doRemoveEdge(t.id))),this.nodeMap.delete(t),this.treeIndices.forEach((e=>{e.childrenMap.get(t)?.forEach((t=>{e.parentMap.delete(t.id)})),e.parentMap.delete(t),e.childrenMap.delete(t)})),this.changes.push({type:"NodeRemoved",value:e})}removeNodes(t){this.batch((()=>{t.forEach((t=>this.doRemoveNode(t)))}))}removeNode(t){this.removeNodes([t])}updateNodeDataProperty(t,e,r){const n=this.getNode(t);this.batch((()=>{const o=n.data[e],i=r;n.data[e]=i,this.changes.push({type:"NodeDataUpdated",id:t,propertyName:e,oldValue:o,newValue:i})}))}mergeNodeData(t,e){this.batch((()=>{Object.entries(e).forEach((([e,r])=>{this.updateNodeDataProperty(t,e,r)}))}))}updateNodeData(...t){const e=t[0],r=this.getNode(e);if("string"==typeof t[1])return void this.updateNodeDataProperty(e,t[1],t[2]);let n;if("function"==typeof t[1]){const e=t[1];n=e(r.data)}else"object"==typeof t[1]&&(n=t[1]);this.batch((()=>{const t=r.data,o=n;r.data=n,this.changes.push({type:"NodeDataUpdated",id:e,oldValue:t,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 e=this.getEdge(t);return{edge:e,source:this.getNode(e.source),target:this.getNode(e.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 e=this.inEdgesMap.get(t.target),r=this.outEdgesMap.get(t.source),n=this.bothEdgesMap.get(t.source),o=this.bothEdgesMap.get(t.target);e.add(t),r.add(t),n.add(t),o.add(t),this.changes.push({type:"EdgeAdded",value:t})}addEdges(t){this.batch((()=>{for(const e of t)this.doAddEdge(e)}))}addEdge(t){this.addEdges([t])}doRemoveEdge(t){const e=this.getEdge(t),r=this.outEdgesMap.get(e.source),n=this.inEdgesMap.get(e.target),o=this.bothEdgesMap.get(e.source),i=this.bothEdgesMap.get(e.target);r.delete(e),n.delete(e),o.delete(e),i.delete(e),this.edgeMap.delete(t),this.changes.push({type:"EdgeRemoved",value:e})}removeEdges(t){this.batch((()=>{t.forEach((t=>this.doRemoveEdge(t)))}))}removeEdge(t){this.removeEdges([t])}updateEdgeSource(t,e){const r=this.getEdge(t);this.checkNodeExistence(e);const n=r.source,o=e;this.outEdgesMap.get(n).delete(r),this.bothEdgesMap.get(n).delete(r),this.outEdgesMap.get(o).add(r),this.bothEdgesMap.get(o).add(r),r.source=e,this.batch((()=>{this.changes.push({type:"EdgeUpdated",id:t,propertyName:"source",oldValue:n,newValue:o})}))}updateEdgeTarget(t,e){const r=this.getEdge(t);this.checkNodeExistence(e);const n=r.target,o=e;this.inEdgesMap.get(n).delete(r),this.bothEdgesMap.get(n).delete(r),this.inEdgesMap.get(o).add(r),this.bothEdgesMap.get(o).add(r),r.target=e,this.batch((()=>{this.changes.push({type:"EdgeUpdated",id:t,propertyName:"target",oldValue:n,newValue:o})}))}updateEdgeDataProperty(t,e,r){const n=this.getEdge(t);this.batch((()=>{const o=n.data[e],i=r;n.data[e]=i,this.changes.push({type:"EdgeDataUpdated",id:t,propertyName:e,oldValue:o,newValue:i})}))}updateEdgeData(...t){const e=t[0],r=this.getEdge(e);if("string"==typeof t[1])return void this.updateEdgeDataProperty(e,t[1],t[2]);let n;if("function"==typeof t[1]){const e=t[1];n=e(r.data)}else"object"==typeof t[1]&&(n=t[1]);this.batch((()=>{const t=r.data,o=n;r.data=n,this.changes.push({type:"EdgeDataUpdated",id:e,oldValue:t,newValue:o})}))}mergeEdgeData(t,e){this.batch((()=>{Object.entries(e).forEach((([e,r])=>{this.updateEdgeDataProperty(t,e,r)}))}))}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,e){this.batch((()=>{this.attachTreeStructure(e);const r=[],n=Array.isArray(t)?t:[t];for(;n.length;){const t=n.shift();r.push(t),t.children&&n.push(...t.children)}this.addNodes(r),r.forEach((t=>{t.children?.forEach((r=>{this.setParent(r.id,t.id,e)}))}))}))}getRoots(t){return this.checkTreeExistence(t),this.getAllNodes().filter((e=>!this.getParent(e.id,t)))}getChildren(t,e){this.checkNodeExistence(t),this.checkTreeExistence(e);const r=this.treeIndices.get(e).childrenMap.get(t);return Array.from(r||[])}getParent(t,e){return this.checkNodeExistence(t),this.checkTreeExistence(e),this.treeIndices.get(e).parentMap.get(t)||null}getAncestors(t,e){const r=[];let n,o=this.getNode(t);for(;n=this.getParent(o.id,e);)r.push(n),o=n;return r}setParent(t,e,r){this.checkTreeExistence(r);const n=this.treeIndices.get(r),o=this.getNode(t),i=n.parentMap.get(t),a=this.getNode(e);n.parentMap.set(t,a),i&&n.childrenMap.get(i.id)?.delete(o);let s=n.childrenMap.get(a.id);s||(s=new Set,n.childrenMap.set(a.id,s)),s.add(o),this.batch((()=>{this.changes.push({type:"TreeStructureChanged",treeKey:r,nodeId:t,oldParentId:i?.id,newParentId:a.id})}))}dfsTree(t,e,r){return l(this.getNode(t),new Set,e,(t=>this.getChildren(t,r)))}bfsTree(t,e,r){return c([this.getNode(t)],new Set,e,(t=>this.getChildren(t,r)))}getAllNodes(){return Array.from(this.nodeMap.values())}getAllEdges(){return Array.from(this.edgeMap.values())}bfs(t,e,r="out"){const n={in:this.getPredecessors.bind(this),out:this.getSuccessors.bind(this),both:this.getNeighbors.bind(this)}[r];return c([this.getNode(t)],new Set,e,n)}dfs(t,e,r="out"){const n={in:this.getPredecessors.bind(this),out:this.getSuccessors.bind(this),both:this.getNeighbors.bind(this)}[r];return l(this.getNode(t),new Set,e,n)}clone(){const t=this.getAllNodes().map((t=>({...t,data:{...t.data}}))),e=this.getAllEdges().map((t=>({...t,data:{...t.data}}))),r=new f({nodes:t,edges:e});return this.treeIndices.forEach((({parentMap:t,childrenMap:e},n)=>{const o=new Map;t.forEach(((t,e)=>{o.set(e,r.getNode(t.id))}));const i=new Map;e.forEach(((t,e)=>{i.set(e,new Set(Array.from(t).map((t=>r.getNode(t.id)))))})),r.treeIndices.set(n,{parentMap:o,childrenMap:i})})),r}toJSON(){return JSON.stringify({nodes:this.getAllNodes(),edges:this.getAllEdges()})}}var g=/-(\\w)/g,p=(function(t){return t.replace(g,(function(t,e){return e?e.toUpperCase():""}))},Object.create(null),Array.isArray),v=function(t){for(var e=[],r=t.length,n=0;n<r;n+=1){e[n]=[];for(var o=0;o<r;o+=1)n===o?e[n][o]=0:0!==t[n][o]&&t[n][o]?e[n][o]=t[n][o]:e[n][o]=1/0}for(var i=0;i<r;i+=1)for(n=0;n<r;n+=1)for(o=0;o<r;o+=1)e[n][o]>e[n][i]+e[i][o]&&(e[n][o]=e[n][i]+e[i][o]);return e},y=function(t,e){var r=t.nodes,n=t.edges,o=[],i={};if(!r)throw new Error("invalid nodes data!");return r&&r.forEach((function(t,e){i[t.id]=e,o.push([])})),null==n||n.forEach((function(t){var r=t.source,n=t.target,a=i[r],s=i[n];void 0!==a&&void 0!==s&&(o[a][s]=1,e||(o[s][a]=1))})),o},m=function(t,e){return Math.sqrt((t.x-e.x)*(t.x-e.x)+(t.y-e.y)*(t.y-e.y))},w={}.toString;const x=function(t,e){return w.call(t)==="[object "+e+"]"},E=function(t){return x(t,"Number")};var b=function(t){if(null===t)return t;if(t instanceof Date)return new Date(t.getTime());if(t instanceof Array){var e=[];return t.forEach((function(t){e.push(t)})),e.map((function(t){return b(t)}))}if("object"==typeof t){var r={};return Object.keys(t).forEach((function(e){r[e]=b(t[e])})),r}return t},N=function(t,e){var r=b(t);return r.data=r.data||{},e&&(E(r.data.x)||(r.data.x=Math.random()*e[0]),E(r.data.y)||(r.data.y=Math.random()*e[1])),r};const M=function(t){return"function"==typeof t},S=function(t){var e=typeof t;return null!==t&&"object"===e||"function"===e};function k(t,e){return M(e)?e:E(e)?function(){return e}:function(){return t}}function A(t,e,r){return void 0===r&&(r=!0),e||0===e?M(e)?e:E(e)?function(){return e}:p(e)?function(){if(r){var n=Math.max.apply(Math,u([],s(e),!1));return isNaN(n)?t:n}return e}:S(e)?function(){if(r){var n=Math.max(e.width,e.height);return isNaN(n)?t:n}return[e.width,e.height]}:function(){return t}:function(e){var r=(e.data||{}).size;return r?p(r)?r[0]>r[1]?r[0]:r[1]:S(r)?r.width>r.height?r.width:r.height:r:t}}var R=function(t,e){var r;return r=E(e)?function(){return e}:M(e)?e:function(){return 0},t?p(t)?function(e){return(t[0]>t[1]?t[0]:t[1])+r(e)}:function(e){return t+r(e)}:function(t){var e,n;if(null===(e=t.data)||void 0===e?void 0:e.bboxSize)return Math.max(t.data.bboxSize[0],t.data.bboxSize[1])+r(t);if(null===(n=t.data)||void 0===n?void 0:n.size){if(p(t.data.size))return Math.max(t.data.size[0],t.data.size[1])+r(t);var o=t.data.size;return S(o)?(o.width>o.height?o.width:o.height)+r(t):o+r(t)}return 10+r(t)}},I=function(t,e,r){var o=t.getAllNodes(),i=t.getAllEdges();return(null==o?void 0:o.length)?1===o.length?(e&&t.mergeNodeData(o[0].id,{x:r[0],y:r[1]}),{nodes:[n(n({},o[0]),{data:n(n({},o[0].data),{x:r[0],y:r[1]})})],edges:i}):void 0:{nodes:[],edges:i}},_={radius:null,startRadius:null,endRadius:null,startAngle:0,endAngle:2*Math.PI,clockwise:!0,divisions:1,ordering:null,angleRatio:1},D=function(){function t(t){void 0===t&&(t={}),this.options=t,this.id="circular",this.options=n(n({},_),t)}return t.prototype.execute=function(t,e){return i(this,void 0,void 0,(function(){return a(this,(function(r){return[2,this.genericCircularLayout(!1,t,e)]}))}))},t.prototype.assign=function(t,e){return i(this,void 0,void 0,(function(){return a(this,(function(r){switch(r.label){case 0:return[4,this.genericCircularLayout(!0,t,e)];case 1:return r.sent(),[2]}}))}))},t.prototype.genericCircularLayout=function(t,e,r){return i(this,void 0,void 0,(function(){var o,i,u,d,h,c,l,f,g,p,v,y,m,w,x,E,b,M,S,R,_,D,T,z,C,L,q,j,F,V,G,W,B,$,U;return a(this,(function(a){if(o=n(n({},this.options),r),i=o.width,u=o.height,d=o.center,h=o.divisions,c=o.startAngle,l=void 0===c?0:c,f=o.endAngle,g=void 0===f?2*Math.PI:f,p=o.angleRatio,v=o.ordering,y=o.clockwise,m=o.nodeSpacing,w=o.nodeSize,x=e.getAllNodes(),E=e.getAllEdges(),b=s(P(i,u,d),3),M=b[0],S=b[1],R=b[2],!(_=null==x?void 0:x.length)||1===_)return[2,I(e,t,R)];for(D=(g-l)/_,T=o.radius,z=o.startRadius,C=o.endRadius,m?(L=k(10,m),q=A(10,w),j=-1/0,x.forEach((function(t){var e=q(t);j<e&&(j=e)})),F=0,x.forEach((function(t,e){F+=0===e?j||10:(L(t)||0)+(j||10)})),T=F/(2*Math.PI)):T||z||C?!z&&C?z=C:z&&!C&&(C=z):T=Math.min(S,M)/2,V=D*p,G=[],G="topology"===v?O(e,x):"topology-directed"===v?O(e,x,!0):"degree"===v?function(t,e){var r=[];return e.forEach((function(t,e){r.push(N(t))})),r.sort((function(e,r){return t.getDegree(e.id,"both")-t.getDegree(r.id,"both")})),r}(e,x):x.map((function(t){return N(t)})),W=Math.ceil(_/h),B=0;B<_;++B)($=T)||null===z||null===C||($=z+B*(C-z)/(_-1)),$||($=10+100*B/(_-1)),U=l+B%W*V+2*Math.PI/h*Math.floor(B/W),y||(U=g-B%W*V-2*Math.PI/h*Math.floor(B/W)),G[B].data.x=R[0]+Math.cos(U)*$,G[B].data.y=R[1]+Math.sin(U)*$;return t&&G.forEach((function(t){e.mergeNodeData(t.id,{x:t.data.x,y:t.data.y})})),[2,{nodes:G,edges:E}]}))}))},t}(),O=function(t,e,r){void 0===r&&(r=!1);var n=[N(e[0])],o={},i=e.length;o[e[0].id]=!0;var a=0;return e.forEach((function(s,u){if(0!==u)if(u!==i-1&&t.getDegree(s.id,"both")===t.getDegree(e[u+1].id,"both")&&!t.areNeighbors(n[a].id,s.id)||o[s.id]){for(var d=r?t.getSuccessors(n[a].id):t.getNeighbors(n[a].id),h=!1,c=0;c<d.length;c++){var l=d[c];if(t.getDegree(l.id)===t.getDegree(s.id)&&!o[l.id]){n.push(N(l)),o[l.id]=!0,h=!0;break}}for(var f=0;!h&&(o[e[f].id]||(n.push(N(e[f])),o[e[f].id]=!0,h=!0),++f!==i););}else n.push(N(s)),o[s.id]=!0,a++})),n},P=function(t,e,r){var n=t,o=e,i=r;return n||"undefined"==typeof window||(n=window.innerWidth),o||"undefined"==typeof window||(o=window.innerHeight),i||(i=[n/2,o/2]),[n,o,i]};const T=function(t){return x(t,"String")};var z={nodeSize:30,nodeSpacing:10,preventOverlap:!1,sweep:void 0,equidistant:!1,startAngle:1.5*Math.PI,clockwise:!0,maxLevelDiff:void 0,sortBy:"degree"},C=function(){function t(t){void 0===t&&(t={}),this.options=t,this.id="concentric",this.options=n(n({},z),t)}return t.prototype.execute=function(t,e){return i(this,void 0,void 0,(function(){return a(this,(function(r){return[2,this.genericConcentricLayout(!1,t,e)]}))}))},t.prototype.assign=function(t,e){return i(this,void 0,void 0,(function(){return a(this,(function(r){return this.genericConcentricLayout(!0,t,e),[2]}))}))},t.prototype.genericConcentricLayout=function(t,e,r){return i(this,void 0,void 0,(function(){var o,i,s,u,d,h,c,l,f,g,v,y,m,w,x,b,k,A,R,_,D,O,P,z,C,L,q,j,F,V,G,W,B,$,U,H,K,Y;return a(this,(function(a){if(o=n(n({},this.options),r),i=o.center,s=o.width,u=o.height,d=o.sortBy,h=o.maxLevelDiff,c=o.sweep,l=o.clockwise,f=o.equidistant,g=o.preventOverlap,v=o.startAngle,y=void 0===v?1.5*Math.PI:v,m=o.nodeSize,w=o.nodeSpacing,x=e.getAllNodes(),b=e.getAllEdges(),k=s||"undefined"==typeof window?s:window.innerWidth,A=u||"undefined"==typeof window?u:window.innerHeight,R=i||[k/2,A/2],!(null==x?void 0:x.length)||1===x.length)return[2,I(e,t,R)];if(_=[],O=0,D=p(m)?Math.max(m[0],m[1]):m,p(w)?O=Math.max(w[0],w[1]):E(w)&&(O=w),x.forEach((function(t){var e=N(t);_.push(e);var r=D,n=e.data;p(n.size)?r=Math.max(n.size[0],n.size[1]):E(n.size)?r=n.size:S(n.size)&&(r=Math.max(n.size.width,n.size.height)),D=Math.max(D,r),M(w)&&(O=Math.max(w(t),O))})),P={},_.forEach((function(t,e){P[t.id]=e})),T(z=d)&&void 0!==_[0].data[z]||(z="degree"),"degree"===z?_.sort((function(t,r){return e.getDegree(r.id,"both")-e.getDegree(t.id,"both")})):_.sort((function(t,e){return e.data[z]-t.data[z]})),C=_[0],L=(h||("degree"===z?e.getDegree(C.id,"both"):C.data[z]))/4,j=(q=[{nodes:[]}])[0],_.forEach((function(t){if(j.nodes.length>0){var r="degree"===z?Math.abs(e.getDegree(j.nodes[0].id,"both")-e.getDegree(t.id,"both")):Math.abs(j.nodes[0].data[z]-t.data[z]);L&&r>=L&&(j={nodes:[]},q.push(j))}j.nodes.push(t)})),F=D+O,g||(V=q.length>0&&q[0].nodes.length>1,G=Math.min(k,A)/2-F,W=G/(q.length+(V?1:0)),F=Math.min(F,W)),B=0,q.forEach((function(t){var e=void 0===c?2*Math.PI-2*Math.PI/t.nodes.length:c;if(t.dTheta=e/Math.max(1,t.nodes.length-1),t.nodes.length>1&&g){var r=Math.cos(t.dTheta)-Math.cos(0),n=Math.sin(t.dTheta)-Math.sin(0),o=Math.sqrt(F*F/(r*r+n*n));B=Math.max(o,B)}t.r=B,B+=F})),f){for($=0,U=0,H=0;H<q.length;H++)K=q[H],Y=(K.r||0)-U,$=Math.max($,Y);U=0,q.forEach((function(t,e){0===e&&(U=t.r||0),t.r=U,U+=$}))}return q.forEach((function(t){var e=t.dTheta||0,r=t.r||0;t.nodes.forEach((function(t,n){var o=y+(l?1:-1)*e*n;t.data.x=R[0]+r*Math.cos(o),t.data.y=R[1]+r*Math.sin(o)}))})),t&&_.forEach((function(t){return e.mergeNodeData(t.id,{x:t.data.x,y:t.data.y})})),[2,{nodes:_,edges:b}]}))}))},t}();function L(t,e,r,n){if(isNaN(e)||isNaN(r))return t;var o,i,a,s,u,d,h,c,l,f=t._root,g={data:n},p=t._x0,v=t._y0,y=t._x1,m=t._y1;if(!f)return t._root=g,t;for(;f.length;)if((d=e>=(i=(p+y)/2))?p=i:y=i,(h=r>=(a=(v+m)/2))?v=a:m=a,o=f,!(f=f[c=h<<1|d]))return o[c]=g,t;if(s=+t._x.call(null,f.data),u=+t._y.call(null,f.data),e===s&&r===u)return g.next=f,o?o[c]=g:t._root=g,t;do{o=o?o[c]=new Array(4):t._root=new Array(4),(d=e>=(i=(p+y)/2))?p=i:y=i,(h=r>=(a=(v+m)/2))?v=a:m=a}while((c=h<<1|d)==(l=(u>=a)<<1|s>=i));return o[l]=f,o[c]=g,t}function q(t,e,r,n,o){this.node=t,this.x0=e,this.y0=r,this.x1=n,this.y1=o}function j(t){return t[0]}function F(t){return t[1]}function V(t,e,r){var n=new G(null==e?j:e,null==r?F:r,NaN,NaN,NaN,NaN);return null==t?n:n.addAll(t)}function G(t,e,r,n,o,i){this._x=t,this._y=e,this._x0=r,this._y0=n,this._x1=o,this._y1=i,this._root=void 0}function W(t){for(var e={data:t.data},r=e;t=t.next;)r=r.next={data:t.data};return e}var B=V.prototype=G.prototype;function $(t){return function(){return t}}function U(t){return 1e-6*(t()-.5)}B.copy=function(){var t,e,r=new G(this._x,this._y,this._x0,this._y0,this._x1,this._y1),n=this._root;if(!n)return r;if(!n.length)return r._root=W(n),r;for(t=[{source:n,target:r._root=new Array(4)}];n=t.pop();)for(var o=0;o<4;++o)(e=n.source[o])&&(e.length?t.push({source:e,target:n.target[o]=new Array(4)}):n.target[o]=W(e));return r},B.add=function(t){const e=+this._x.call(null,t),r=+this._y.call(null,t);return L(this.cover(e,r),e,r,t)},B.addAll=function(t){var e,r,n,o,i=t.length,a=new Array(i),s=new Array(i),u=1/0,d=1/0,h=-1/0,c=-1/0;for(r=0;r<i;++r)isNaN(n=+this._x.call(null,e=t[r]))||isNaN(o=+this._y.call(null,e))||(a[r]=n,s[r]=o,n<u&&(u=n),n>h&&(h=n),o<d&&(d=o),o>c&&(c=o));if(u>h||d>c)return this;for(this.cover(u,d).cover(h,c),r=0;r<i;++r)L(this,a[r],s[r],t[r]);return this},B.cover=function(t,e){if(isNaN(t=+t)||isNaN(e=+e))return this;var r=this._x0,n=this._y0,o=this._x1,i=this._y1;if(isNaN(r))o=(r=Math.floor(t))+1,i=(n=Math.floor(e))+1;else{for(var a,s,u=o-r||1,d=this._root;r>t||t>=o||n>e||e>=i;)switch(s=(e<n)<<1|t<r,(a=new Array(4))[s]=d,d=a,u*=2,s){case 0:o=r+u,i=n+u;break;case 1:r=o-u,i=n+u;break;case 2:o=r+u,n=i-u;break;case 3:r=o-u,n=i-u}this._root&&this._root.length&&(this._root=d)}return this._x0=r,this._y0=n,this._x1=o,this._y1=i,this},B.data=function(){var t=[];return this.visit((function(e){if(!e.length)do{t.push(e.data)}while(e=e.next)})),t},B.extent=function(t){return arguments.length?this.cover(+t[0][0],+t[0][1]).cover(+t[1][0],+t[1][1]):isNaN(this._x0)?void 0:[[this._x0,this._y0],[this._x1,this._y1]]},B.find=function(t,e,r){var n,o,i,a,s,u,d,h=this._x0,c=this._y0,l=this._x1,f=this._y1,g=[],p=this._root;for(p&&g.push(new q(p,h,c,l,f)),null==r?r=1/0:(h=t-r,c=e-r,l=t+r,f=e+r,r*=r);u=g.pop();)if(!(!(p=u.node)||(o=u.x0)>l||(i=u.y0)>f||(a=u.x1)<h||(s=u.y1)<c))if(p.length){var v=(o+a)/2,y=(i+s)/2;g.push(new q(p[3],v,y,a,s),new q(p[2],o,y,v,s),new q(p[1],v,i,a,y),new q(p[0],o,i,v,y)),(d=(e>=y)<<1|t>=v)&&(u=g[g.length-1],g[g.length-1]=g[g.length-1-d],g[g.length-1-d]=u)}else{var m=t-+this._x.call(null,p.data),w=e-+this._y.call(null,p.data),x=m*m+w*w;if(x<r){var E=Math.sqrt(r=x);h=t-E,c=e-E,l=t+E,f=e+E,n=p.data}}return n},B.remove=function(t){if(isNaN(i=+this._x.call(null,t))||isNaN(a=+this._y.call(null,t)))return this;var e,r,n,o,i,a,s,u,d,h,c,l,f=this._root,g=this._x0,p=this._y0,v=this._x1,y=this._y1;if(!f)return this;if(f.length)for(;;){if((d=i>=(s=(g+v)/2))?g=s:v=s,(h=a>=(u=(p+y)/2))?p=u:y=u,e=f,!(f=f[c=h<<1|d]))return this;if(!f.length)break;(e[c+1&3]||e[c+2&3]||e[c+3&3])&&(r=e,l=c)}for(;f.data!==t;)if(n=f,!(f=f.next))return this;return(o=f.next)&&delete f.next,n?(o?n.next=o:delete n.next,this):e?(o?e[c]=o:delete e[c],(f=e[0]||e[1]||e[2]||e[3])&&f===(e[3]||e[2]||e[1]||e[0])&&!f.length&&(r?r[l]=f:this._root=f),this):(this._root=o,this)},B.removeAll=function(t){for(var e=0,r=t.length;e<r;++e)this.remove(t[e]);return this},B.root=function(){return this._root},B.size=function(){var t=0;return this.visit((function(e){if(!e.length)do{++t}while(e=e.next)})),t},B.visit=function(t){var e,r,n,o,i,a,s=[],u=this._root;for(u&&s.push(new q(u,this._x0,this._y0,this._x1,this._y1));e=s.pop();)if(!t(u=e.node,n=e.x0,o=e.y0,i=e.x1,a=e.y1)&&u.length){var d=(n+i)/2,h=(o+a)/2;(r=u[3])&&s.push(new q(r,d,h,i,a)),(r=u[2])&&s.push(new q(r,n,h,d,a)),(r=u[1])&&s.push(new q(r,d,o,i,h)),(r=u[0])&&s.push(new q(r,n,o,d,h))}return this},B.visitAfter=function(t){var e,r=[],n=[];for(this._root&&r.push(new q(this._root,this._x0,this._y0,this._x1,this._y1));e=r.pop();){var o=e.node;if(o.length){var i,a=e.x0,s=e.y0,u=e.x1,d=e.y1,h=(a+u)/2,c=(s+d)/2;(i=o[0])&&r.push(new q(i,a,s,h,c)),(i=o[1])&&r.push(new q(i,h,s,u,c)),(i=o[2])&&r.push(new q(i,a,c,h,d)),(i=o[3])&&r.push(new q(i,h,c,u,d))}n.push(e)}for(;e=n.pop();)t(e.node,e.x0,e.y0,e.x1,e.y1);return this},B.x=function(t){return arguments.length?(this._x=t,this):this._x},B.y=function(t){return arguments.length?(this._y=t,this):this._y};var H={value:()=>{}};function K(){for(var t,e=0,r=arguments.length,n={};e<r;++e){if(!(t=arguments[e]+"")||t in n||/[\\s.]/.test(t))throw new Error("illegal type: "+t);n[t]=[]}return new Y(n)}function Y(t){this._=t}function J(t,e){for(var r,n=0,o=t.length;n<o;++n)if((r=t[n]).name===e)return r.value}function X(t,e,r){for(var n=0,o=t.length;n<o;++n)if(t[n].name===e){t[n]=H,t=t.slice(0,n).concat(t.slice(n+1));break}return null!=r&&t.push({name:e,value:r}),t}Y.prototype=K.prototype={constructor:Y,on:function(t,e){var r,n,o=this._,i=(n=o,(t+"").trim().split(/^|\\s+/).map((function(t){var e="",r=t.indexOf(".");if(r>=0&&(e=t.slice(r+1),t=t.slice(0,r)),t&&!n.hasOwnProperty(t))throw new Error("unknown type: "+t);return{type:t,name:e}}))),a=-1,s=i.length;if(!(arguments.length<2)){if(null!=e&&"function"!=typeof e)throw new Error("invalid callback: "+e);for(;++a<s;)if(r=(t=i[a]).type)o[r]=X(o[r],t.name,e);else if(null==e)for(r in o)o[r]=X(o[r],t.name,null);return this}for(;++a<s;)if((r=(t=i[a]).type)&&(r=J(o[r],t.name)))return r},copy:function(){var t={},e=this._;for(var r in e)t[r]=e[r].slice();return new Y(t)},call:function(t,e){if((r=arguments.length-2)>0)for(var r,n,o=new Array(r),i=0;i<r;++i)o[i]=arguments[i+2];if(!this._.hasOwnProperty(t))throw new Error("unknown type: "+t);for(i=0,r=(n=this._[t]).length;i<r;++i)n[i].value.apply(e,o)},apply:function(t,e,r){if(!this._.hasOwnProperty(t))throw new Error("unknown type: "+t);for(var n=this._[t],o=0,i=n.length;o<i;++o)n[o].value.apply(e,r)}};const Q=K;var Z,tt,et=0,rt=0,nt=0,ot=1e3,it=0,at=0,st=0,ut="object"==typeof performance&&performance.now?performance:Date,dt="object"==typeof window&&window.requestAnimationFrame?window.requestAnimationFrame.bind(window):function(t){setTimeout(t,17)};function ht(){return at||(dt(ct),at=ut.now()+st)}function ct(){at=0}function lt(){this._call=this._time=this._next=null}function ft(t,e,r){var n=new lt;return n.restart(t,e,r),n}function gt(){at=(it=ut.now())+st,et=rt=0;try{!function(){ht(),++et;for(var t,e=Z;e;)(t=at-e._time)>=0&&e._call.call(void 0,t),e=e._next;--et}()}finally{et=0,function(){for(var t,e,r=Z,n=1/0;r;)r._call?(n>r._time&&(n=r._time),t=r,r=r._next):(e=r._next,r._next=null,r=t?t._next=e:Z=e);tt=t,vt(n)}(),at=0}}function pt(){var t=ut.now(),e=t-it;e>ot&&(st-=e,it=t)}function vt(t){et||(rt&&(rt=clearTimeout(rt)),t-at>24?(t<1/0&&(rt=setTimeout(gt,t-ut.now()-st)),nt&&(nt=clearInterval(nt))):(nt||(it=ut.now(),nt=setInterval(pt,ot)),et=1,dt(gt)))}lt.prototype=ft.prototype={constructor:lt,restart:function(t,e,r){if("function"!=typeof t)throw new TypeError("callback is not a function");r=(null==r?ht():+r)+(null==e?0:+e),this._next||tt===this||(tt?tt._next=this:Z=this,tt=this),this._call=t,this._time=r,vt()},stop:function(){this._call&&(this._call=null,this._time=1/0,vt())}};const yt=1664525,mt=1013904223,wt=4294967296;function xt(t){return t.x}function Et(t){return t.y}var bt=10,Nt=Math.PI*(3-Math.sqrt(5));function Mt(t){var e,r=1,n=.001,o=1-Math.pow(n,1/300),i=0,a=.6,s=new Map,u=ft(c),d=Q("tick","end"),h=function(){let t=1;return()=>(t=(yt*t+mt)%wt)/wt}();function c(){l(),d.call("tick",e),r<n&&(u.stop(),d.call("end",e))}function l(n){var u,d,h=t.length;void 0===n&&(n=1);for(var c=0;c<n;++c)for(r+=(i-r)*o,s.forEach((function(t){t(r)})),u=0;u<h;++u)null==(d=t[u]).fx?d.x+=d.vx*=a:(d.x=d.fx,d.vx=0),null==d.fy?d.y+=d.vy*=a:(d.y=d.fy,d.vy=0);return e}function f(){for(var e,r=0,n=t.length;r<n;++r){if((e=t[r]).index=r,null!=e.fx&&(e.x=e.fx),null!=e.fy&&(e.y=e.fy),isNaN(e.x)||isNaN(e.y)){var o=bt*Math.sqrt(.5+r),i=r*Nt;e.x=o*Math.cos(i),e.y=o*Math.sin(i)}(isNaN(e.vx)||isNaN(e.vy))&&(e.vx=e.vy=0)}}function g(e){return e.initialize&&e.initialize(t,h),e}return null==t&&(t=[]),f(),e={tick:l,restart:function(){return u.restart(c),e},stop:function(){return u.stop(),e},nodes:function(r){return arguments.length?(t=r,f(),s.forEach(g),e):t},alpha:function(t){return arguments.length?(r=+t,e):r},alphaMin:function(t){return arguments.length?(n=+t,e):n},alphaDecay:function(t){return arguments.length?(o=+t,e):+o},alphaTarget:function(t){return arguments.length?(i=+t,e):i},velocityDecay:function(t){return arguments.length?(a=1-t,e):1-a},randomSource:function(t){return arguments.length?(h=t,s.forEach(g),e):h},force:function(t,r){return arguments.length>1?(null==r?s.delete(t):s.set(t,g(r)),e):s.get(t)},find:function(e,r,n){var o,i,a,s,u,d=0,h=t.length;for(null==n?n=1/0:n*=n,d=0;d<h;++d)(a=(o=e-(s=t[d]).x)*o+(i=r-s.y)*i)<n&&(u=s,n=a);return u},on:function(t,r){return arguments.length>1?(d.on(t,r),e):d.on(t)}}}function St(){var t,e,r,n,o,i=$(-30),a=1,s=1/0,u=.81;function d(r){var o,i=t.length,a=V(t,xt,Et).visitAfter(c);for(n=r,o=0;o<i;++o)e=t[o],a.visit(l)}function h(){if(t){var e,r,n=t.length;for(o=new Array(n),e=0;e<n;++e)r=t[e],o[r.index]=+i(r,e,t)}}function c(t){var e,r,n,i,a,s=0,u=0;if(t.length){for(n=i=a=0;a<4;++a)(e=t[a])&&(r=Math.abs(e.value))&&(s+=e.value,u+=r,n+=r*e.x,i+=r*e.y);t.x=n/u,t.y=i/u}else{(e=t).x=e.data.x,e.y=e.data.y;do{s+=o[e.data.index]}while(e=e.next)}t.value=s}function l(t,i,d,h){if(!t.value)return!0;var c=t.x-e.x,l=t.y-e.y,f=h-i,g=c*c+l*l;if(f*f/u<g)return g<s&&(0===c&&(g+=(c=U(r))*c),0===l&&(g+=(l=U(r))*l),g<a&&(g=Math.sqrt(a*g)),e.vx+=c*t.value*n/g,e.vy+=l*t.value*n/g),!0;if(!(t.length||g>=s)){(t.data!==e||t.next)&&(0===c&&(g+=(c=U(r))*c),0===l&&(g+=(l=U(r))*l),g<a&&(g=Math.sqrt(a*g)));do{t.data!==e&&(f=o[t.data.index]*n/g,e.vx+=c*f,e.vy+=l*f)}while(t=t.next)}}return d.initialize=function(e,n){t=e,r=n,h()},d.strength=function(t){return arguments.length?(i="function"==typeof t?t:$(+t),h(),d):i},d.distanceMin=function(t){return arguments.length?(a=t*t,d):Math.sqrt(a)},d.distanceMax=function(t){return arguments.length?(s=t*t,d):Math.sqrt(s)},d.theta=function(t){return arguments.length?(u=t*t,d):Math.sqrt(u)},d}function kt(t){return t.index}function At(t,e){var r=t.get(e);if(!r)throw new Error("node not found: "+e);return r}function Rt(t){var e,r,n,o,i,a,s=kt,u=function(t){return 1/Math.min(o[t.source.index],o[t.target.index])},d=$(30),h=1;function c(n){for(var o=0,s=t.length;o<h;++o)for(var u,d,c,l,f,g,p,v=0;v<s;++v)d=(u=t[v]).source,l=(c=u.target).x+c.vx-d.x-d.vx||U(a),f=c.y+c.vy-d.y-d.vy||U(a),l*=g=((g=Math.sqrt(l*l+f*f))-r[v])/g*n*e[v],f*=g,c.vx-=l*(p=i[v]),c.vy-=f*p,d.vx+=l*(p=1-p),d.vy+=f*p}function l(){if(n){var a,u,d=n.length,h=t.length,c=new Map(n.map(((t,e)=>[s(t,e,n),t])));for(a=0,o=new Array(d);a<h;++a)(u=t[a]).index=a,"object"!=typeof u.source&&(u.source=At(c,u.source)),"object"!=typeof u.target&&(u.target=At(c,u.target)),o[u.source.index]=(o[u.source.index]||0)+1,o[u.target.index]=(o[u.target.index]||0)+1;for(a=0,i=new Array(h);a<h;++a)u=t[a],i[a]=o[u.source.index]/(o[u.source.index]+o[u.target.index]);e=new Array(h),f(),r=new Array(h),g()}}function f(){if(n)for(var r=0,o=t.length;r<o;++r)e[r]=+u(t[r],r,t)}function g(){if(n)for(var e=0,o=t.length;e<o;++e)r[e]=+d(t[e],e,t)}return null==t&&(t=[]),c.initialize=function(t,e){n=t,a=e,l()},c.links=function(e){return arguments.length?(t=e,l(),c):t},c.id=function(t){return arguments.length?(s=t,c):s},c.iterations=function(t){return arguments.length?(h=+t,c):h},c.strength=function(t){return arguments.length?(u="function"==typeof t?t:$(+t),f(),c):u},c.distance=function(t){return arguments.length?(d="function"==typeof t?t:$(+t),g(),c):d},c}function It(t){return t.x+t.vx}function _t(t){return t.y+t.vy}function Dt(t){var e,r,n,o=1,i=1;function a(){for(var t,a,u,d,h,c,l,f=e.length,g=0;g<i;++g)for(a=V(e,It,_t).visitAfter(s),t=0;t<f;++t)u=e[t],c=r[u.index],l=c*c,d=u.x+u.vx,h=u.y+u.vy,a.visit(p);function p(t,e,r,i,a){var s=t.data,f=t.r,g=c+f;if(!s)return e>d+g||i<d-g||r>h+g||a<h-g;if(s.index>u.index){var p=d-s.x-s.vx,v=h-s.y-s.vy,y=p*p+v*v;y<g*g&&(0===p&&(y+=(p=U(n))*p),0===v&&(y+=(v=U(n))*v),y=(g-(y=Math.sqrt(y)))/y*o,u.vx+=(p*=y)*(g=(f*=f)/(l+f)),u.vy+=(v*=y)*g,s.vx-=p*(g=1-g),s.vy-=v*g)}}}function s(t){if(t.data)return t.r=r[t.data.index];for(var e=t.r=0;e<4;++e)t[e]&&t[e].r>t.r&&(t.r=t[e].r)}function u(){if(e){var n,o,i=e.length;for(r=new Array(i),n=0;n<i;++n)o=e[n],r[o.index]=+t(o,n,e)}}return"function"!=typeof t&&(t=$(null==t?1:+t)),a.initialize=function(t,r){e=t,n=r,u()},a.iterations=function(t){return arguments.length?(i=+t,a):i},a.strength=function(t){return arguments.length?(o=+t,a):o},a.radius=function(e){return arguments.length?(t="function"==typeof e?e:$(+e),u(),a):t},a}function Ot(t){var e,r,n,o=$(.1);function i(t){for(var o,i=0,a=e.length;i<a;++i)(o=e[i]).vx+=(n[i]-o.x)*r[i]*t}function a(){if(e){var i,a=e.length;for(r=new Array(a),n=new Array(a),i=0;i<a;++i)r[i]=isNaN(n[i]=+t(e[i],i,e))?0:+o(e[i],i,e)}}return"function"!=typeof t&&(t=$(null==t?0:+t)),i.initialize=function(t){e=t,a()},i.strength=function(t){return arguments.length?(o="function"==typeof t?t:$(+t),a(),i):o},i.x=function(e){return arguments.length?(t="function"==typeof e?e:$(+e),a(),i):t},i}function Pt(t){var e,r,n,o=$(.1);function i(t){for(var o,i=0,a=e.length;i<a;++i)(o=e[i]).vy+=(n[i]-o.y)*r[i]*t}function a(){if(e){var i,a=e.length;for(r=new Array(a),n=new Array(a),i=0;i<a;++i)r[i]=isNaN(n[i]=+t(e[i],i,e))?0:+o(e[i],i,e)}}return"function"!=typeof t&&(t=$(null==t?0:+t)),i.initialize=function(t){e=t,a()},i.strength=function(t){return arguments.length?(o="function"==typeof t?t:$(+t),a(),i):o},i.y=function(e){return arguments.length?(t="function"==typeof e?e:$(+e),a(),i):t},i}function Tt(){function t(t){return function(){return t}}var e,r=function(t){return t.cluster},n=t(1),o=t(-1),i=t(100),a=t(.1),u=[0,0],d=[],h={},c=[],l=100,f=100,g={none:{x:0,y:0}},p=[],v="force",y=!0,m=.1;function w(t){if(!y)return w;e.tick(),E();for(var n=0,o=d.length,i=void 0,a=t*m;n<o;++n)(i=d[n]).vx+=(g[r(i)].x-i.x)*a,i.vy+=(g[r(i)].y-i.y)*a}function x(){d&&function(){if(d&&d.length){if(void 0===r(d[0]))throw Error("Couldnt find the grouping attribute for the nodes. Make sure to set it up with forceInBox.groupBy(\'clusterAttr\') before calling .links()");var t,u,g,v,y,m=(t=[],u=[],g={},{},y=[],v=function(t){var e={};return t.forEach((function(t){var n=r(t);e[n]||(e[n]={count:0,sumforceNodeSize:0})})),t.forEach((function(t){var o=r(t),i=n(t),a=e[o];a.count=a.count+1,a.sumforceNodeSize=a.sumforceNodeSize+Math.PI*(i*i)*1.3,e[o]=a})),e}(d),y=function(t){var e={},n=[];return t.forEach((function(t){var n,o,i,a,s,u=(o=(n=t).source,i=n.target,(a=r(h[o]))<=(s=r(h[i]))?"".concat(a,"~").concat(s):"".concat(s,"~").concat(a)),d=0;void 0!==e[u]&&(d=e[u]),d+=1,e[u]=d})),Object.entries(e).forEach((function(t){var e=s(t,2),r=e[0],o=e[1],i=r.split("~")[0],a=r.split("~")[1];void 0!==i&&void 0!==a&&n.push({source:i,target:a,count:o})})),n}(c),Object.keys(v).forEach((function(e,r){var n=v[e];t.push({id:e,size:n.count,r:Math.sqrt(n.sumforceNodeSize/Math.PI)}),g[e]=r})),y.forEach((function(t){var e=t.source,r=t.target,n=g[e],o=g[r];void 0!==n&&void 0!==o&&u.push({source:n,target:o,count:t.count})})),{nodes:t,links:u});e=Mt(m.nodes).force("x",Ot(l).strength(.1)).force("y",Pt(f).strength(.1)).force("collide",Dt((function(t){return t.r})).iterations(4)).force("charge",St().strength(o)).force("links",Rt(m.nodes.length?m.links:[]).distance(i).strength(a)),p=e.nodes(),E()}}()}function E(){return g={none:{x:0,y:0}},p.forEach((function(t){g[t.id]={x:t.x-u[0],y:t.y-u[1]}})),g}return w.initialize=function(t){d=t,x()},w.template=function(t){return arguments.length?(v=t,x(),w):v},w.groupBy=function(t){return arguments.length?"string"==typeof t?(r=function(e){return e[t]},w):(r=t,w):r},w.enableGrouping=function(t){return arguments.length?(y=t,w):y},w.strength=function(t){return arguments.length?(m=t,w):m},w.centerX=function(t){return arguments.length?(l=t,w):l},w.centerY=function(t){return arguments.length?(f=t,w):f},w.nodes=function(t){return arguments.length?(function(t){h={},t.forEach((function(t){h[t.id]=t}))}(t||[]),d=t||[],w):d},w.links=function(t){return arguments.length?(c=t||[],x(),w):c},w.forceNodeSize=function(e){return arguments.length?(n="function"==typeof e?e:t(+e),x(),w):n},w.nodeSize=w.forceNodeSize,w.forceCharge=function(e){return arguments.length?(o="function"==typeof e?e:t(+e),x(),w):o},w.forceLinkDistance=function(e){return arguments.length?(i="function"==typeof e?e:t(+e),x(),w):i},w.forceLinkStrength=function(e){return arguments.length?(a="function"==typeof e?e:t(+e),x(),w):a},w.offset=function(t){return arguments.length?(u=t,w):u},w.getFocis=E,w}var zt={center:[0,0],preventOverlap:!1,nodeSize:void 0,nodeSpacing:void 0,linkDistance:50,forceSimulation:null,alphaDecay:.028,alphaMin:.001,alpha:.3,collideStrength:1,clustering:!1,clusterNodeStrength:-1,clusterEdgeStrength:.1,clusterEdgeDistance:100,clusterFociStrength:.8,clusterNodeSize:10},Ct=function(){function t(t){void 0===t&&(t={}),this.options=t,this.id="d3force",this.options=n(n({},zt),t)}return t.prototype.execute=function(t,e){return i(this,void 0,void 0,(function(){return a(this,(function(r){return[2,this.genericForceLayout(!1,t,e)]}))}))},t.prototype.assign=function(t,e){return i(this,void 0,void 0,(function(){return a(this,(function(r){return this.genericForceLayout(!0,t,e),[2]}))}))},t.prototype.stop=function(){var t;null===(t=this.forceSimulation)||void 0===t||t.stop()},t.prototype.tick=function(t){var e=this;void 0===t&&(t=1),this.forceSimulation.tick(t);var r={nodes:Lt(this.lastLayoutNodes),edges:qt(this.lastLayoutEdges)};return this.lastAssign&&r.nodes.forEach((function(t){return e.lastGraph.mergeNodeData(t.id,{x:t.data.x,y:t.data.y})})),r},t.prototype.genericForceLayout=function(t,e,r){return i(this,void 0,void 0,(function(){var o,i,s,u,d,h,c,l,f,g,p,v,y,m,w,x,E,b,M,S,k,A,R,I,_,D,O=this;return a(this,(function(a){return o=n(n({},this.options),r),i=e.getAllNodes(),s=e.getAllEdges(),u=i.map((function(t){var e,r;return n(n({},N(t)),{x:null===(e=t.data)||void 0===e?void 0:e.x,y:null===(r=t.data)||void 0===r?void 0:r.y})})),d=s.map((function(t){return N(t)})),this.lastLayoutNodes=u,this.lastLayoutEdges=d,this.lastAssign=t,this.lastGraph=e,h=o.alphaMin,c=o.alphaDecay,l=o.alpha,f=o.nodeStrength,g=o.edgeStrength,p=o.linkDistance,v=o.clustering,y=o.clusterFociStrength,m=o.clusterEdgeDistance,w=o.clusterEdgeStrength,x=o.clusterNodeStrength,E=o.clusterNodeSize,b=o.collideStrength,M=void 0===b?1:b,S=o.center,k=void 0===S?[0,0]:S,A=o.preventOverlap,R=o.nodeSize,I=o.nodeSpacing,_=o.onTick,D=o.forceSimulation,[2,new Promise((function(r){if(D){v&&((i=Tt()).nodes(u),i.links(d)),D.nodes(u),d&&(s=Rt().id((function(t){return t.id})).links(d),g&&s.strength(g),p&&s.distance(p),D.force("link",s)),A&&O.overlapProcess(D,{nodeSize:R,nodeSpacing:I,collideStrength:M}),D.alpha(l).restart();var n=Lt(u),o=qt(d);t&&n.forEach((function(t){return e.mergeNodeData(t.id,{x:t.data.x,y:t.data.y})})),r({nodes:n,edges:o})}else try{var i,a=St();if(f&&a.strength(f),D=Mt().nodes(u),v&&((i=Tt()).centerX(k[0]).centerY(k[1]).template("force").strength(y),d&&i.links(d),u&&i.nodes(u),i.forceLinkDistance(m).forceLinkStrength(w).forceCharge(x).forceNodeSize(E),D.force("group",i)),D.force("center",function(t,e){var r,n=1;function o(){var o,i,a=r.length,s=0,u=0;for(o=0;o<a;++o)s+=(i=r[o]).x,u+=i.y;for(s=(s/a-t)*n,u=(u/a-e)*n,o=0;o<a;++o)(i=r[o]).x-=s,i.y-=u}return null==t&&(t=0),null==e&&(e=0),o.initialize=function(t){r=t},o.x=function(e){return arguments.length?(t=+e,o):t},o.y=function(t){return arguments.length?(e=+t,o):e},o.strength=function(t){return arguments.length?(n=+t,o):n},o}(k[0],k[1])).force("charge",a).alpha(l).alphaDecay(c).alphaMin(h),A&&O.overlapProcess(D,{nodeSize:R,nodeSpacing:I,collideStrength:M}),d){var s=Rt().id((function(t){return t.id})).links(d);g&&s.strength(g),p&&s.distance(p),D.force("link",s)}D.on("tick",(function(){var r=Lt(u);null==_||_({nodes:r,edges:qt(d)}),t&&r.forEach((function(t){return e.mergeNodeData(t.id,{x:t.data.x,y:t.data.y})}))})).on("end",(function(){var n=Lt(u);t&&n.forEach((function(t){return e.mergeNodeData(t.id,{x:t.data.x,y:t.data.y})})),r({nodes:n,edges:qt(d)})}))}catch(t){console.warn(t)}O.forceSimulation=D}))]}))}))},t.prototype.overlapProcess=function(t,e){var r,n,o=e.nodeSize,i=e.nodeSpacing,a=e.collideStrength;if(n=E(i)?function(){return i}:M(i)?i:function(){return 0},o)if(M(o))r=function(t){return o(t)+n(t)};else if(p(o)){var s=(o[0]>o[1]?o[0]:o[1])/2;r=function(t){return s+n(t)}}else if(E(o)){var u=o/2;r=function(t){return u+n(t)}}else r=function(){return 10};else r=function(t){return t.size?p(t.size)?(t.size[0]>t.size[1]?t.size[0]:t.size[1])/2+n(t):S(t.size)?(t.size.width>t.size.height?t.size.width:t.size.height)/2+n(t):t.size/2+n(t):10+n(t)};t.force("collisionForce",Dt(r).strength(a))},t}(),Lt=function(t){return t.map((function(t){var e=t.x,r=t.y,i=o(t,["x","y"]);return n(n({},i),{data:n(n({},i.data),{x:e,y:r})})}))},qt=function(t){return t.map((function(t){var e=t.source,r=t.target,i=o(t,["source","target"]);return n(n({},i),{source:e.id,target:r.id})}))};var jt=function(t,e){if("next"!==t&&"prev"!==t)return e},Ft=function(t){t.prev.next=t.next,t.next.prev=t.prev,delete t.next,delete t.prev},Vt=function(t){function e(){return null!==t&&t.apply(this,arguments)||this}return function(t,e){if("function"!=typeof e&&null!==e)throw new TypeError("Class extends value "+String(e)+" is not a constructor or null");function n(){this.constructor=t}r(t,e),t.prototype=null===e?Object.create(e):(n.prototype=e.prototype,new n)}(e,t),e}(function(){function t(){var t={};t.prev=t,t.next=t.prev,this.shortcut=t}return t.prototype.dequeue=function(){var t=this.shortcut,e=t.prev;if(e&&e!==t)return Ft(e),e},t.prototype.enqueue=function(t){var e=this.shortcut;t.prev&&t.next&&Ft(t),t.next=e.next,e.next.prev=t,e.next=t,t.prev=e},t.prototype.toString=function(){for(var t=[],e=this.shortcut,r=e.prev;r!==e;)t.push(JSON.stringify(r,jt)),r=null==r?void 0:r.prev;return"[".concat(t.join(", "),"]")},t}()),Gt=function(){return 1},Wt=function(t,e,r,o,i){var a,s,u=[];return t.hasNode(o.v)&&(null===(a=t.getRelatedEdges(o.v,"in"))||void 0===a||a.forEach((function(o){var a=o.data.weight,s=t.getNode(o.source);i&&u.push({v:o.source,w:o.target,in:0,out:0}),void 0===s.data.out&&(s.data.out=0),s.data.out-=a,Bt(e,r,n({v:s.id},s.data))})),null===(s=t.getRelatedEdges(o.v,"out"))||void 0===s||s.forEach((function(o){var i=o.data.weight,a=o.target,s=t.getNode(a);void 0===s.data.in&&(s.data.in=0),s.data.in-=i,Bt(e,r,n({v:s.id},s.data))})),t.removeNode(o.v)),i?u:void 0},Bt=function(t,e,r){r.out?r.in?t[r.out-r.in+e].enqueue(r):t[t.length-1].enqueue(r):t[0].enqueue(r)},$t=function(t,e){var r="greedy"===e?function(t,e){var r;if(t.getAllNodes().length<=1)return[];var o=function(t,e){var r=new f,o=0,i=0;t.getAllNodes().forEach((function(t){r.addNode({id:t.id,data:{v:t.id,in:0,out:0}})})),t.getAllEdges().forEach((function(t){var a=r.getRelatedEdges(t.source,"out").find((function(e){return e.target===t.target})),s=(null==e?void 0:e(t))||1;a?r.updateEdgeData(null==a?void 0:a.id,n(n({},a.data),{weight:a.data.weight+s})):r.addEdge({id:t.id,source:t.source,target:t.target,data:{weight:s}}),i=Math.max(i,r.getNode(t.source).data.out+=s),o=Math.max(o,r.getNode(t.target).data.in+=s)}));for(var a=[],s=i+o+3,u=0;u<s;u++)a.push(new Vt);var d=o+1;return r.getAllNodes().forEach((function(t){Bt(a,d,n({v:t.id},r.getNode(t.id).data))})),{buckets:a,zeroIdx:d,graph:r}}(t,function(t){return t.data.weight||1}||Gt);return null===(r=function(t,e,r){for(var n,o=[],i=e[e.length-1],a=e[0];t.getAllNodes().length;){for(;n=a.dequeue();)Wt(t,e,r,n);for(;n=i.dequeue();)Wt(t,e,r,n);if(t.getAllNodes().length)for(var s=e.length-2;s>0;--s)if(n=e[s].dequeue()){o=o.concat(Wt(t,e,r,n,!0));break}}return o}(o.graph,o.buckets,o.zeroIdx).map((function(e){return t.getRelatedEdges(e.v,"out").filter((function(t){return t.target===e.w}))})))||void 0===r?void 0:r.flat()}(t):Ut(t);null==r||r.forEach((function(e){var r=e.data;t.removeEdge(e.id),r.forwardName=e.data.name,r.reversed=!0,t.addEdge({id:e.id,source:e.target,target:e.source,data:n({},r)})}))},Ut=function(t){var e=[],r={},n={},o=function(i){n[i]||(n[i]=!0,r[i]=!0,t.getRelatedEdges(i,"out").forEach((function(t){r[t.target]?e.push(t):o(t.target)})),delete r[i])};return t.getAllNodes().forEach((function(t){return o(t.id)})),e},Ht=function(t,e,r,n){var o;do{o="".concat(n).concat(Math.random())}while(t.hasNode(o));return r.dummy=e,t.addNode({id:o,data:r}),o},Kt=function(t){var e=new f;return t.getAllNodes().forEach((function(r){t.getChildren(r.id).length||e.addNode(n({},r))})),t.getAllEdges().forEach((function(t){e.addEdge(t)})),e},Yt=function(t,e){var r,n,o=Number(t.x),i=Number(t.y),a=Number(e.x)-o,s=Number(e.y)-i,u=Number(t.width)/2,d=Number(t.height)/2;return a||s?(Math.abs(s)*u>Math.abs(a)*d?(s<0&&(d=-d),r=d*a/s,n=d):(a<0&&(u=-u),r=u,n=u*s/a),{x:o+r,y:i+n}):{x:0,y:0}},Jt=function(t){for(var e=[],r=Qt(t)+1,n=0;n<r;n++)e.push([]);for(t.getAllNodes().forEach((function(t){var r=t.data.rank;void 0!==r&&e[r]&&e[r].push(t.id)})),n=0;n<r;n++)e[n]=e[n].sort((function(e,r){return n=t.getNode(e).data.order,o=t.getNode(r).data.order,Number(n)-Number(o);var n,o}));return e},Xt=function(t,e,r,n){var o={width:0,height:0};return E(r)&&E(n)&&(o.rank=r,o.order=n),Ht(t,"border",o,e)},Qt=function(t){var e;return t.getAllNodes().forEach((function(t){var r=t.data.rank;void 0!==r&&(void 0===e||r>e)&&(e=r)})),e||(e=0),e},Zt=function(t,e){return t.reduce((function(t,r){return e(t)>e(r)?r:t}))},te=function(t,e,r,n,o,i){n.includes(e.id)||(n.push(e.id),r||i.push(e.id),o(e.id).forEach((function(e){return te(t,e,r,n,o,i)})),r&&i.push(e.id))},ee=function(t,e,r,n){var o=Array.isArray(e)?e:[e],i=function(e){return n?t.getSuccessors(e):t.getNeighbors(e)},a=[],s=[];return o.forEach((function(e){if(!t.hasNode(e.id))throw new Error("Graph does not have node: "+e);te(t,e,"post"===r,s,i,a)})),a},re="edge-label",ne=function(t){var e={},r=function(n){var o,i,a=t.getNode(n);return a?e[n]?a.data.rank:(e[n]=!0,null===(o=t.getRelatedEdges(n,"out"))||void 0===o||o.forEach((function(t){var e=r(t.target)-t.data.minlen;e&&(void 0===i||e<i)&&(i=e)})),i||(i=0),a.data.rank=i,i):0};t.getAllNodes().filter((function(e){return 0===t.getRelatedEdges(e.id,"in").length})).forEach((function(t){return r(t.id)}))},oe=function(t,e){return t.getNode(e.target).data.rank-t.getNode(e.source).data.rank-e.data.minlen},ie=function(t,e){var r=function(n){e.getRelatedEdges(n,"both").forEach((function(o){var i=o.source,a=n===i?o.target:i;t.hasNode(a)||oe(e,o)||(t.addNode({id:a,data:{}}),t.addEdge({id:o.id,source:n,target:a,data:{}}),r(a))}))};return t.getAllNodes().forEach((function(t){return r(t.id)})),t.getAllNodes().length},ae=function(t,e){var r=function(n){var o;null===(o=e.getRelatedEdges(n,"both"))||void 0===o||o.forEach((function(o){var i=o.source,a=n===i?o.target:i;t.hasNode(a)||void 0===e.getNode(a).data.layer&&oe(e,o)||(t.addNode({id:a,data:{}}),t.addEdge({id:o.id,source:n,target:a,data:{}}),r(a))}))};return t.getAllNodes().forEach((function(t){return r(t.id)})),t.getAllNodes().length},se=function(t,e){return Zt(e.getAllEdges(),(function(r){return t.hasNode(r.source)!==t.hasNode(r.target)?oe(e,r):1/0}))},ue=function(t,e,r){t.getAllNodes().forEach((function(t){var n=e.getNode(t.id);n.data.rank||(n.data.rank=0),n.data.rank+=r}))},de=function(t,e){var r=ee(t,t.getAllNodes(),"post",!1);(r=r.slice(0,(null==r?void 0:r.length)-1)).forEach((function(r){he(t,e,r)}))},he=function(t,e,r){var n=t.getNode(r).data.parent;t.getRelatedEdges(r,"both").find((function(t){return t.target===n||t.source===n})).data.cutvalue=ce(t,e,r)},ce=function(t,e,r){var n=t.getNode(r).data.parent,o=!0,i=e.getRelatedEdges(r,"out").find((function(t){return t.target===n})),a=0;return i||(o=!1,i=e.getRelatedEdges(n,"out").find((function(t){return t.target===r}))),a=i.data.weight,e.getRelatedEdges(r,"both").forEach((function(e){var i=e.source===r,s=i?e.target:e.source;if(s!==n){var u=i===o,d=e.data.weight;if(a+=u?d:-d,me(t,r,s)){var h=t.getRelatedEdges(r,"both").find((function(t){return t.source===s||t.target===s})).data.cutvalue;a+=u?-h:h}}})),a},le=function(t,e){void 0===e&&(e=t.getAllNodes()[0].id),fe(t,{},1,e)},fe=function(t,e,r,n,o){var i,a=r,s=r,u=t.getNode(n);return e[n]=!0,null===(i=t.getNeighbors(n))||void 0===i||i.forEach((function(r){e[r.id]||(s=fe(t,e,s,r.id,n))})),u.data.low=a,u.data.lim=s++,o?u.data.parent=o:delete u.data.parent,s},ge=function(t){return t.getAllEdges().find((function(t){return t.data.cutvalue<0}))},pe=function(t,e,r){var n=r.source,o=r.target;e.getRelatedEdges(n,"out").find((function(t){return t.target===o}))||(n=r.target,o=r.source);var i=t.getNode(n),a=t.getNode(o),s=i,u=!1;i.data.lim>a.data.lim&&(s=a,u=!0);var d=e.getAllEdges().filter((function(e){return u===we(t.getNode(e.source),s)&&u!==we(t.getNode(e.target),s)}));return Zt(d,(function(t){return oe(e,t)}))},ve=function(t,e,r,n){var o=t.getRelatedEdges(r.source,"both").find((function(t){return t.source===r.target||t.target===r.target}));o&&t.removeEdge(o.id),t.addEdge({id:"e".concat(Math.random()),source:n.source,target:n.target,data:{}}),le(t),de(t,e),ye(t,e)},ye=function(t,e){var r=t.getAllNodes().find((function(t){return!t.data.parent})),n=ee(t,r,"pre",!1);(n=n.slice(1)).forEach((function(r){var n=t.getNode(r).data.parent,o=e.getRelatedEdges(r,"out").find((function(t){return t.target===n})),i=!1;!o&&e.hasNode(n)&&(o=e.getRelatedEdges(n,"out").find((function(t){return t.target===r})),i=!0),e.getNode(r).data.rank=(e.hasNode(n)&&e.getNode(n).data.rank||0)+(i?null==o?void 0:o.data.minlen:-(null==o?void 0:o.data.minlen))}))},me=function(t,e,r){return t.getRelatedEdges(e,"both").find((function(t){return t.source===r||t.target===r}))},we=function(t,e){return e.data.low<=t.data.lim&&t.data.lim<=e.data.lim},xe=ne,Ee=function(t){!function(t){var e=function(t){var e=new f;return t.getAllNodes().forEach((function(t){e.addNode(n({},t))})),t.getAllEdges().forEach((function(t){var r=e.getRelatedEdges(t.source,"out").find((function(e){return e.target===t.target}));r?e.updateEdgeData(null==r?void 0:r.id,n(n({},r.data),{weight:r.data.weight+t.data.weight||0,minlen:Math.max(r.data.minlen,t.data.minlen||1)})):e.addEdge({id:t.id,source:t.source,target:t.target,data:{weight:t.data.weight||0,minlen:t.data.minlen||1}})})),e}(t);ne(e);var r,o,i=function(t){var e,r,n=new f({tree:[]}),o=t.getAllNodes()[0],i=t.getAllNodes().length;for(n.addNode(o);ie(n,t)<i;)e=se(n,t),r=n.hasNode(e.source)?oe(t,e):-oe(t,e),ue(n,t,r);return n}(e);for(le(i),de(i,e);r=ge(i);)o=pe(i,e,r),ve(i,e,r,o)}(t)},be=function(t,e,r,n,o,i,a){var s=t.getChildren(a);if(null==s?void 0:s.length){var u=Xt(t,"_bt"),d=Xt(t,"_bb"),h=t.getNode(a);t.setParent(u,a),h.data.borderTop=u,t.setParent(d,a),h.data.borderBottom=d,null==s||s.forEach((function(s){be(t,e,r,n,o,i,s.id);var h=s.data.borderTop?s.data.borderTop:s.id,c=s.data.borderBottom?s.data.borderBottom:s.id,l=s.data.borderTop?n:2*n,f=h!==c?1:o-i[a]+1;t.addEdge({id:"e".concat(Math.random()),source:u,target:h,data:{minlen:f,weight:l,nestingEdge:!0}}),t.addEdge({id:"e".concat(Math.random()),source:c,target:d,data:{minlen:f,weight:l,nestingEdge:!0}})})),t.getParent(a)||t.addEdge({id:"e".concat(Math.random()),source:e,target:u,data:{weight:0,minlen:o+i[a]}})}else a!==e&&t.addEdge({id:"e".concat(Math.random()),source:e,target:a,data:{weight:0,minlen:r}})},Ne=function(t,e,r,n,o,i){var a={rank:i,borderType:e,width:0,height:0},s=o.data[e][i-1],u=Ht(t,"border",a,r);o.data[e][i]=u,t.setParent(u,n),s&&t.addEdge({id:"e".concat(Math.random()),source:s,target:u,data:{weight:1}})},Me=function(t){t.getAllNodes().forEach((function(t){Se(t)})),t.getAllEdges().forEach((function(t){Se(t)}))},Se=function(t){var e=t.data.width;t.data.width=t.data.height,t.data.height=e},ke=function(t){(null==t?void 0:t.y)&&(t.y=-t.y)},Ae=function(t){var e=t.x;t.x=t.y,t.y=e},Re=function(t){for(var e={},r=t.getAllNodes(),n=r.map((function(t){var e;return null!==(e=t.data.rank)&&void 0!==e?e:-1/0})),o=Math.max.apply(Math,u([],s(n),!1)),i=[],a=0;a<o+1;a++)i.push([]);var d=r.sort((function(e,r){return t.getNode(e.id).data.rank-t.getNode(r.id).data.rank})),h=d.filter((function(e){return void 0!==t.getNode(e.id).data.fixorder})).sort((function(e,r){return t.getNode(e.id).data.fixorder-t.getNode(r.id).data.fixorder}));return null==h||h.forEach((function(r){isNaN(t.getNode(r.id).data.rank)||i[t.getNode(r.id).data.rank].push(r.id),e[r.id]=!0})),null==d||d.forEach((function(r){return t.dfsTree(r.id,(function(t){if(e.hasOwnProperty(t.id))return!0;e[t.id]=!0,isNaN(t.data.rank)||i[t.data.rank].push(t.id)}))})),i},Ie=function(t,e,r){for(var n=function(t,e){return null==t?void 0:t.reduce((function(t,r,n){return t[r]=e[n],t}),{})}(r,r.map((function(t,e){return e}))),o=e.map((function(e){var r=t.getRelatedEdges(e,"out").map((function(t){return{pos:n[t.target]||0,weight:t.data.weight}}));return null==r?void 0:r.sort((function(t,e){return t.pos-e.pos}))})),i=o.flat().filter((function(t){return void 0!==t})),a=1;a<r.length;)a<<=1;var s=2*a-1;a-=1;var u=Array(s).fill(0,0,s),d=0;return null==i||i.forEach((function(t){if(t){var e=t.pos+a;u[e]+=t.weight;for(var r=0;e>0;)e%2&&(r+=u[e+1]),u[e=e-1>>1]+=t.weight;d+=t.weight*r}})),d},_e=function(t,e){for(var r=0,n=1;n<(null==e?void 0:e.length);n+=1)r+=Ie(t,e[n-1],e[n]);return r},De=function(t,e){var r,n=0,o=0;t.weight&&(n+=t.barycenter*t.weight,o+=t.weight),e.weight&&(n+=e.barycenter*e.weight,o+=e.weight),t.vs=null===(r=e.vs)||void 0===r?void 0:r.concat(t.vs),t.barycenter=n/o,t.weight=o,t.i=Math.min(e.i,t.i),e.merged=!0};const Oe=function(t,e){var r,n,o,i={};return null==t||t.forEach((function(t,e){i[t.v]={i:e,indegree:0,in:[],out:[],vs:[t.v]};var r=i[t.v];void 0!==t.barycenter&&(r.barycenter=t.barycenter,r.weight=t.weight)})),null===(r=e.getAllEdges())||void 0===r||r.forEach((function(t){var e=i[t.source],r=i[t.target];void 0!==e&&void 0!==r&&(r.indegree++,e.out.push(i[t.target]))})),function(t){for(var e,r,n=[],o=function(){var o=t.pop();n.push(o),null===(e=o.in.reverse())||void 0===e||e.forEach((function(t){return(e=o,function(t){t.merged||(void 0===t.barycenter||void 0===e.barycenter||t.barycenter>=e.barycenter)&&De(e,t)})(t);var e})),null===(r=o.out)||void 0===r||r.forEach((function(e){return(r=o,function(e){e.in.push(r),0==--e.indegree&&t.push(e)})(e);var r}))};null==t?void 0:t.length;)o();var i=n.filter((function(t){return!t.merged})),a=["vs","i","barycenter","weight"];return i.map((function(t){var e={};return null==a||a.forEach((function(r){void 0!==t[r]&&(e[r]=t[r])})),e}))}(null===(o=(n=Object.values(i)).filter)||void 0===o?void 0:o.call(n,(function(t){return!t.indegree})))};var Pe=function(t,e,r){for(var n,o=r;e.length&&(n=e[e.length-1]).i<=o;)e.pop(),null==t||t.push(n.vs),o++;return o},Te=function(t,e,r,n,o,i){var a,s,u,d,h=t.getChildren(e).map((function(t){return t.id})),c=t.getNode(e),l=c?c.data.borderLeft:void 0,f=c?c.data.borderRight:void 0,g={};l&&(h=null==h?void 0:h.filter((function(t){return t!==l&&t!==f})));var p=function(t,e){return e.map((function(e){var r=t.getRelatedEdges(e,"in");if(!(null==r?void 0:r.length))return{v:e};var n={sum:0,weight:0};return null==r||r.forEach((function(e){var r=t.getNode(e.source);n.sum+=e.data.weight*r.data.order,n.weight+=e.data.weight})),{v:e,barycenter:n.sum/n.weight,weight:n.weight}}))}(t,h||[]);null==p||p.forEach((function(e){var o;if(null===(o=t.getChildren(e.v))||void 0===o?void 0:o.length){var a=Te(t,e.v,r,n,i);g[e.v]=a,a.hasOwnProperty("barycenter")&&Ce(e,a)}}));var v=Oe(p,r);ze(v,g),null===(a=v.filter((function(t){return t.vs.length>0})))||void 0===a||a.forEach((function(e){var r=t.getNode(e.vs[0]);r&&(e.fixorder=r.data.fixorder,e.order=r.data.order)}));var y=function(t,e,r,n){var o=function(t,e){var r={lhs:[],rhs:[]};return null==t||t.forEach((function(t){var e,o;o=(e=t).hasOwnProperty("fixorder")&&!isNaN(e.fixorder),(n?!o&&e.hasOwnProperty("barycenter"):o||e.hasOwnProperty("barycenter"))?r.lhs.push(t):r.rhs.push(t)})),r}(t),i=o.lhs,a=o.rhs.sort((function(t,e){return-t.i- -e.i})),s=[],u=0,d=0,h=0;null==i||i.sort(function(t,e){return function(r,n){if(void 0!==r.fixorder&&void 0!==n.fixorder)return r.fixorder-n.fixorder;if(r.barycenter<n.barycenter)return-1;if(r.barycenter>n.barycenter)return 1;if(e&&void 0!==r.order&&void 0!==n.order){if(r.order<n.order)return-1;if(r.order>n.order)return 1}return t?n.i-r.i:r.i-n.i}}(!!e,!!r)),h=Pe(s,a,h),null==i||i.forEach((function(t){var e;h+=null===(e=t.vs)||void 0===e?void 0:e.length,s.push(t.vs),u+=t.barycenter*t.weight,d+=t.weight,h=Pe(s,a,h)}));var c={vs:s.flat()};return d&&(c.barycenter=u/d,c.weight=d),c}(v,n,o,i);if(l&&(y.vs=[l,y.vs,f].flat(),null===(s=t.getPredecessors(l))||void 0===s?void 0:s.length)){var m=t.getNode((null===(u=t.getPredecessors(l))||void 0===u?void 0:u[0].id)||""),w=t.getNode((null===(d=t.getPredecessors(f))||void 0===d?void 0:d[0].id)||"");y.hasOwnProperty("barycenter")||(y.barycenter=0,y.weight=0),y.barycenter=(y.barycenter*y.weight+m.data.order+w.data.order)/(y.weight+2),y.weight+=2}return y},ze=function(t,e){null==t||t.forEach((function(t){var r,n=null===(r=t.vs)||void 0===r?void 0:r.map((function(t){return e[t]?e[t].vs:t}));t.vs=n.flat()}))},Ce=function(t,e){void 0!==t.barycenter?(t.barycenter=(t.barycenter*t.weight+e.barycenter*e.weight)/(t.weight+e.weight),t.weight+=e.weight):(t.barycenter=e.barycenter,t.weight=e.weight)},Le=function(t){if("object"!=typeof t||null===t)return t;var e,r;if(r=t,Array.isArray?Array.isArray(r):x(r,"Array")){e=[];for(var n=0,o=t.length;n<o;n++)"object"==typeof t[n]&&null!=t[n]?e[n]=Le(t[n]):e[n]=t[n]}else for(var i in e={},t)"object"==typeof t[i]&&null!=t[i]?e[i]=Le(t[i]):e[i]=t[i];return e};const qe=Le;var je=function(t,e,r){return e.map((function(e){return function(t,e,r){var o=function(t){for(var e;t.hasNode(e="_root".concat(Math.random())););return e}(t),i=new f({tree:[{id:o,children:[],data:{}}]});return t.getAllNodes().forEach((function(a){var s=t.getParent(a.id);(a.data.rank===e||a.data.minRank<=e&&e<=a.data.maxRank)&&(i.hasNode(a.id)||i.addNode(n({},a)),(null==s?void 0:s.id)&&!i.hasNode(null==s?void 0:s.id)&&i.addNode(n({},s)),i.setParent(a.id,(null==s?void 0:s.id)||o),t.getRelatedEdges(a.id,r).forEach((function(e){var r=e.source===a.id?e.target:e.source;i.hasNode(r)||i.addNode(n({},t.getNode(r)));var o=i.getRelatedEdges(r,"out").find((function(t){return t.target===a.id})),s=void 0!==o?o.data.weight:0;o?i.updateEdgeData(o.id,n(n({},o.data),{weight:e.data.weight+s})):i.addEdge({id:e.id,source:r,target:a.id,data:{weight:e.data.weight+s}})})),a.data.hasOwnProperty("minRank")&&i.updateNodeData(a.id,n(n({},a.data),{borderLeft:a.data.borderLeft[e],borderRight:a.data.borderRight[e]})))})),i}(t,e,r)}))},Fe=function(t,e,r,n){var o=new f;null==t||t.forEach((function(t){for(var i,a=t.getRoots()[0].id,s=Te(t,a,o,e,r,n),u=0;u<(null===(i=s.vs)||void 0===i?void 0:i.length);u++){var d=t.getNode(s.vs[u]);d&&(d.data.order=u)}!function(t,e,r){var n,o={};null==r||r.forEach((function(r){for(var i,a,s=t.getParent(r);s;){if((i=t.getParent(s.id))?(a=o[i.id],o[i.id]=s.id):(a=n,n=s.id),a&&a!==s.id)return e.addNodes([{id:a,data:{}},{id:s.id,data:{}}]),void e.addEdge({id:"e".concat(a,"-").concat(s.id),source:a,target:s.id,data:{}});s=i}}))}(t,o,s.vs)}))},Ve=function(t,e){null==e||e.forEach((function(e){null==e||e.forEach((function(e,r){t.getNode(e).data.order=r}))}))},Ge=function(t,e){var r={};function n(e,n,o,i,a){for(var s,u,d,h=n;h<o;h++)d=e[h],(null===(s=t.getNode(d))||void 0===s?void 0:s.data.dummy)&&(null===(u=t.getPredecessors(d))||void 0===u||u.forEach((function(e){var n=t.getNode(e.id);n.data.dummy&&(n.data.order<i||n.data.order>a)&&Be(r,e.id,d)})))}function o(t,e){var r=function(t){return JSON.stringify(t.slice(1))}(t);e.get(r)||(n.apply(void 0,u([],s(t),!1)),e.set(r,!0))}return(null==e?void 0:e.length)&&e.reduce((function(e,r){var n,i=-1,a=0,s=new Map;return null==r||r.forEach((function(u,d){var h;if("border"===(null===(h=t.getNode(u))||void 0===h?void 0:h.data.dummy)){var c=t.getPredecessors(u)||[];c.length&&(n=t.getNode(c[0].id).data.order,o([r,a,d,i,n],s),a=d,i=n)}o([r,a,r.length,n,e.length],s)})),r})),r},We=function(t,e){var r,n;if(null===(r=t.getNode(e))||void 0===r?void 0:r.data.dummy)return null===(n=t.getPredecessors(e))||void 0===n?void 0:n.find((function(e){return t.getNode(e.id).data.dummy}))},Be=function(t,e,r){var n=e,o=r;if(n>o){var i=n;n=o,o=i}var a=t[n];a||(t[n]=a={}),a[o]=!0},$e=function(t,e,r){var n=e;return n>r&&(n=r),!!t[n]},Ue=function(t,e,r,o,i,a){var s=new f,u=He(o,i,a);return null==e||e.forEach((function(e){var o;null==e||e.forEach((function(e){var i=r[e];if(s.hasNode(i)||s.addNode({id:i,data:{}}),o){var a=r[o],d=s.getRelatedEdges(a,"out").find((function(t){return t.target===i}));d?s.updateEdgeData(d.id,n(n({},d.data),{weight:Math.max(u(t,e,o),d.data.weight||0)})):s.addEdge({id:"e".concat(Math.random()),source:a,target:i,data:{weight:Math.max(u(t,e,o),0)}})}o=e}))})),s};var He=function(t,e,r){return function(n,o,i){var a=n.getNode(o),s=n.getNode(i),u=0,d=0;if(u+=a.data.width/2,a.data.hasOwnProperty("labelpos"))switch((a.data.labelpos||"").toLowerCase()){case"l":d=-a.data.width/2;break;case"r":d=a.data.width/2}if(d&&(u+=r?d:-d),d=0,u+=(a.data.dummy?e:t)/2,u+=(s.data.dummy?e:t)/2,u+=s.data.width/2,s.data.labelpos)switch((s.data.labelpos||"").toLowerCase()){case"l":d=s.data.width/2;break;case"r":d=-s.data.width/2}return d&&(u+=r?d:-d),d=0,u}},Ke=function(t,e){return t.getNode(e).data.width||0},Ye=function(t,e){var r,n=Kt(t);!function(t,e){var r=(e||{}).ranksep,n=void 0===r?0:r,o=Jt(t),i=0;null==o||o.forEach((function(e){var r=e.map((function(e){return t.getNode(e).data.height})),o=Math.max.apply(Math,u(u([],s(r),!1),[0],!1));null==e||e.forEach((function(e){t.getNode(e).data.y=i+o/2})),i+=o+n}))}(n,e);var o=function(t,e){var r=e||{},n=r.align,o=void 0===n?"":n,i=r.nodesep,a=void 0===i?0:i,d=r.edgesep,h=void 0===d?0:d,c=Jt(t),l=Object.assign(function(t,e){var r={};return(null==e?void 0:e.length)&&e.reduce((function(e,n){var o=0,i=0,a=e.length,s=null==n?void 0:n[(null==n?void 0:n.length)-1];return null==n||n.forEach((function(e,u){var d,h=We(t,e),c=h?t.getNode(h.id).data.order:a;(h||e===s)&&(null===(d=n.slice(i,u+1))||void 0===d||d.forEach((function(e){var n;null===(n=t.getPredecessors(e))||void 0===n||n.forEach((function(n){var i,a=t.getNode(n.id),s=a.data.order;!(s<o||c<s)||a.data.dummy&&(null===(i=t.getNode(e))||void 0===i?void 0:i.data.dummy)||Be(r,n.id,e)}))})),i=u+1,o=c)})),n})),r}(t,c),Ge(t,c)),f={},g=[];["u","d"].forEach((function(e){g="u"===e?c:Object.values(c).reverse(),["l","r"].forEach((function(r){"r"===r&&(g=g.map((function(t){return Object.values(t).reverse()})));var n=("u"===e?t.getPredecessors:t.getSuccessors).bind(t),o=function(t,e,r,n){var o={},i={},a={};return null==e||e.forEach((function(t){null==t||t.forEach((function(t,e){o[t]=t,i[t]=t,a[t]=e}))})),null==e||e.forEach((function(t){var e=-1;null==t||t.forEach((function(t){var s=n(t).map((function(t){return t.id}));if(s.length){s=s.sort((function(t,e){return a[t]-a[e]}));for(var u=(s.length-1)/2,d=Math.floor(u),h=Math.ceil(u);d<=h;++d){var c=s[d];i[t]===t&&e<a[c]&&!$e(r,t,c)&&(i[c]=t,i[t]=o[t]=o[c],e=a[c])}}}))})),{root:o,align:i}}(0,g,l,n),i=function(t,e,r,n,o,i,a){var s,u={},d=Ue(t,e,r,o,i,a),h=a?"borderLeft":"borderRight",c=function(t,e){for(var r=d.getAllNodes(),n=r.pop(),o={};n;)o[n.id]?t(n.id):(o[n.id]=!0,r.push(n),r=r.concat(e(n.id))),n=r.pop()};return c((function(t){u[t]=(d.getRelatedEdges(t,"in")||[]).reduce((function(t,e){return Math.max(t,(u[e.source]||0)+e.data.weight)}),0)}),d.getPredecessors.bind(d)),c((function(e){var r=(d.getRelatedEdges(e,"out")||[]).reduce((function(t,e){return Math.min(t,(u[e.target]||0)-e.data.weight)}),Number.POSITIVE_INFINITY),n=t.getNode(e);r!==Number.POSITIVE_INFINITY&&n.data.borderType!==h&&(u[e]=Math.max(u[e],r))}),d.getSuccessors.bind(d)),null===(s=Object.values(n))||void 0===s||s.forEach((function(t){u[t]=u[r[t]]})),u}(t,g,o.root,o.align,a,h,"r"===r);"r"===r&&Object.keys(i).forEach((function(t){return i[t]=-i[t]})),f[e+r]=i}))}));var p=function(t,e){return Zt(Object.values(e),(function(e){var r,n=Number.NEGATIVE_INFINITY,o=Number.POSITIVE_INFINITY;return null===(r=Object.keys(e))||void 0===r||r.forEach((function(r){var i=e[r],a=Ke(t,r)/2;n=Math.max(i+a,n),o=Math.min(i-a,o)})),n-o}))}(t,f);return p&&function(t,e){var r=Object.values(e),n=Math.min.apply(Math,u([],s(r),!1)),o=Math.max.apply(Math,u([],s(r),!1));["u","d"].forEach((function(r){["l","r"].forEach((function(i){var a,d=r+i,h=t[d];if(h!==e){var c=Object.values(h);(a="l"===i?n-Math.min.apply(Math,u([],s(c),!1)):o-Math.max.apply(Math,u([],s(c),!1)))&&(t[d]={},Object.keys(h).forEach((function(e){t[d][e]=h[e]+a})))}}))}))}(f,p),function(t,e){var r={};return Object.keys(t.ul).forEach((function(n){if(e)r[n]=t[e.toLowerCase()][n];else{var o=Object.values(t).map((function(t){return t[n]}));r[n]=(o[0]+o[1])/2}})),r}(f,o)}(n,e);null===(r=Object.keys(o))||void 0===r||r.forEach((function(t){n.getNode(t).data.x=o[t]}))},Je=function(t,e){var r=e.acyclicer,o=e.ranker,i=e.rankdir,a=void 0===i?"tb":i,d=e.nodeOrder,h=e.keepNodeOrder,c=e.align,l=void 0===c?"":c,g=e.nodesep,p=void 0===g?50:g,v=e.edgesep,y=void 0===v?20:v,m=e.ranksep,w=void 0===m?50:m;hr(t),$t(t,r);var x=function(t){var e=Ht(t,"root",{},"_root"),r=function(t){var e={},r=function(n,o){var i=t.getChildren(n);null==i||i.forEach((function(t){return r(t.id,o+1)})),e[n]=o};return t.getRoots().forEach((function(t){return r(t.id,1)})),e}(t),n=Math.max.apply(Math,u([],s(Object.values(r)),!1));Math.abs(n)===1/0&&(n=1);var o=n-1,i=2*o+1;t.getAllEdges().forEach((function(t){t.data.minlen*=i}));var a=function(t){var e=0;return t.getAllEdges().forEach((function(t){e+=t.data.weight})),e}(t)+1;return t.getRoots().forEach((function(n){be(t,e,i,a,o,r,n.id)})),{nestingRoot:e,nodeRankFactor:i}}(t),E=x.nestingRoot,b=x.nodeRankFactor;!function(t,e){switch(e){case"network-simplex":Ee(t);break;case"tight-tree":default:!function(t){!function(t){var e,r={},n=function(o){var i,a,s=t.getNode(o);return s?r[o]?s.data.rank:(r[o]=!0,null===(i=t.getRelatedEdges(o,"out"))||void 0===i||i.forEach((function(t){var e=n(t.target)-t.data.minlen;e&&(void 0===a||e<a)&&(a=e)})),a||(a=0),(void 0===e||a<e)&&(e=a),s.data.rank=a,a):0};t.getAllNodes().filter((function(e){return 0===t.getRelatedEdges(e.id,"in").length})).forEach((function(t){t&&n(t.id)})),void 0===e&&(e=0);var o={},i=function(e,r){var n,a=t.getNode(e),s=isNaN(a.data.layer)?r:a.data.layer;(void 0===a.data.rank||a.data.rank<s)&&(a.data.rank=s),o[e]||(o[e]=!0,null===(n=t.getRelatedEdges(e,"out"))||void 0===n||n.forEach((function(t){i(t.target,s+t.data.minlen)})))};t.getAllNodes().forEach((function(t){var r=t.data;r&&(isNaN(r.layer)?r.rank-=e:i(t.id,r.layer))}))}(t),function(t){var e,r,n=new f({tree:[]}),o=t.getAllNodes()[0],i=t.getAllNodes().length;for(n.addNode(o);ae(n,t)<i;)e=se(n,t),r=n.hasNode(e.source)?oe(t,e):-oe(t,e),ue(n,t,r)}(t)}(t);break;case"longest-path":xe(t)}}(Kt(t),o),rr(t),function(t,e){void 0===e&&(e=0);var r=t.getAllNodes(),n=r.filter((function(t){return void 0!==t.data.rank})).map((function(t){return t.data.rank})),o=Math.min.apply(Math,u([],s(n),!1)),i=[];r.forEach((function(t){var e=(t.data.rank||0)-o;i[e]||(i[e]=[]),i[e].push(t.id)}));for(var a=0,d=0;d<i.length;d++){var h=i[d];void 0===h?d%e!=0&&(a-=1):a&&(null==h||h.forEach((function(e){var r=t.getNode(e);r&&(r.data.rank=r.data.rank||0,r.data.rank+=a)})))}}(t,b),function(t,e){e&&t.removeNode(e),t.getAllEdges().forEach((function(e){e.data.nestingEdge&&t.removeEdge(e.id)}))}(t,E),function(t){var e=t.getAllNodes().filter((function(t){return void 0!==t.data.rank})).map((function(t){return t.data.rank})),r=Math.min.apply(Math,u([],s(e),!1));t.getAllNodes().forEach((function(t){t.data.hasOwnProperty("rank")&&r!==1/0&&(t.data.rank-=r)}))}(t),nr(t),or(t);var N=[];!function(t,e){t.getAllEdges().forEach((function(r){return function(t,e,r){var n=e.source,o=t.getNode(n).data.rank,i=e.target,a=t.getNode(i).data.rank,s=e.data.labelRank;if(a!==o+1){var u,d,h;for(t.removeEdge(e.id),h=0,++o;o<a;++h,++o)e.data.points=[],u=Ht(t,"edge",d={originalEdge:e,width:0,height:0,rank:o},"_d"),o===s&&(d.width=e.data.width,d.height=e.data.height,d.dummy=re,d.labelpos=e.data.labelpos),t.addEdge({id:"e".concat(Math.random()),source:n,target:u,data:{weight:e.data.weight}}),0===h&&r.push(u),n=u;t.addEdge({id:"e".concat(Math.random()),source:n,target:i,data:{weight:e.data.weight}})}}(t,r,e)}))}(t,N),function(t,e){var r=function(t){var e={},r=0,n=function(o){var i=r;t.getChildren(o).forEach((function(t){return n(t.id)})),e[o]={low:i,lim:r++}};return t.getRoots().forEach((function(t){return n(t.id)})),e}(t);e.forEach((function(e){var n,o,i=e,a=t.getNode(i),s=a.data.originalEdge;if(s)for(var u=function(t,e,r,n){var o,i,a,s,u=[],d=[],h=Math.min(e[r].low,e[n].low),c=Math.max(e[r].lim,e[n].lim);a=r;do{a=null===(o=t.getParent(a))||void 0===o?void 0:o.id,u.push(a)}while(a&&(e[a].low>h||c>e[a].lim));for(s=a,a=n;a&&a!==s;)d.push(a),a=null===(i=t.getParent(a))||void 0===i?void 0:i.id;return{lca:s,path:u.concat(d.reverse())}}(t,r,s.source,s.target),d=u.path,h=u.lca,c=0,l=d[c],f=!0;i!==s.target;){if(a=t.getNode(i),f){for(;l!==h&&(null===(n=t.getNode(l))||void 0===n?void 0:n.data.maxRank)<a.data.rank;)l=d[++c];l===h&&(f=!1)}if(!f){for(;c<d.length-1&&(null===(o=t.getNode(d[c+1]))||void 0===o?void 0:o.data.minRank)<=a.data.rank;)c++;l=d[c]}t.hasNode(l)&&t.setParent(i,l),i=t.getSuccessors(i)[0].id}}))}(t,N),function(t){var e=function(r){var n=t.getChildren(r),o=t.getNode(r);if((null==n?void 0:n.length)&&n.forEach((function(t){return e(t.id)})),o.data.hasOwnProperty("minRank")){o.data.borderLeft=[],o.data.borderRight=[];for(var i=o.data.minRank,a=o.data.maxRank+1;i<a;i+=1)Ne(t,"borderLeft","_bl",r,o,i),Ne(t,"borderRight","_br",r,o,i)}};t.getRoots().forEach((function(t){return e(t.id)}))}(t),h&&function(t,e){for(var r=t.getAllNodes().filter((function(e){var r;return!(null===(r=t.getChildren(e.id))||void 0===r?void 0:r.length)})).map((function(t){return t.data.rank})),n=Math.max.apply(Math,u([],s(r),!1)),o=[],i=0;i<n+1;i++)o[i]=[];null==e||e.forEach((function(e){var r=t.getNode(e);r&&!(null==r?void 0:r.data.dummy)&&(isNaN(r.data.rank)||(r.data.fixorder=o[r.data.rank].length,o[r.data.rank].push(e)))}))}(t,d),function(t,e){for(var r=Qt(t),n=[],o=[],i=1;i<r+1;i++)n.push(i);for(i=r-1;i>-1;i--)o.push(i);var a=je(t,n,"in"),s=je(t,o,"out"),u=Re(t);Ve(t,u);for(var d,h=Number.POSITIVE_INFINITY,c=(i=0,0);c<4;++i,++c)Fe(i%2?a:s,i%4>=2,!1,e),u=Jt(t),(l=_e(t,u))<h&&(c=0,d=qe(u),h=l);for(u=Re(t),Ve(t,u),i=0,c=0;c<4;++i,++c){var l;Fe(i%2?a:s,i%4>=2,!0,e),u=Jt(t),(l=_e(t,u))<h&&(c=0,d=qe(u),h=l)}Ve(t,d)}(t,h),cr(t),function(t,e){var r=e.toLowerCase();"lr"!==r&&"rl"!==r||Me(t)}(t,a),Ye(t,{align:l,nodesep:p,edgesep:y,ranksep:w}),lr(t),dr(t),function(t,e){e.forEach((function(e){var r,n=t.getNode(e),o=n.data.originalEdge;o&&t.addEdge(o);for(var i=e;n.data.dummy;)r=t.getSuccessors(i)[0],t.removeNode(i),o.data.points.push({x:n.data.x,y:n.data.y}),n.data.dummy===re&&(o.data.x=n.data.x,o.data.y=n.data.y,o.data.width=n.data.width,o.data.height=n.data.height),i=r.id,n=t.getNode(i)}))}(t,N),sr(t),function(t,e){var r=e.toLowerCase();"bt"!==r&&"rl"!==r||function(t){t.getAllNodes().forEach((function(t){ke(t.data)})),t.getAllEdges().forEach((function(t){var e;null===(e=t.data.points)||void 0===e||e.forEach((function(t){return ke(t)})),t.data.hasOwnProperty("y")&&ke(t.data)}))}(t),"lr"!==r&&"rl"!==r||(function(t){t.getAllNodes().forEach((function(t){Ae(t.data)})),t.getAllEdges().forEach((function(t){var e;null===(e=t.data.points)||void 0===e||e.forEach((function(t){return Ae(t)})),t.data.hasOwnProperty("x")&&Ae(t.data)}))}(t),Me(t))}(t,a);var M=ir(t),S=M.width,k=M.height;return ar(t),ur(t),function(t){t.getAllEdges().forEach((function(e){var r=e.data;if(r.reversed){t.removeEdge(e.id);var o=r.forwardName;delete r.reversed,delete r.forwardName,t.addEdge({id:e.id,source:e.target,target:e.source,data:n(n({},r),{forwardName:o})})}}))}(t),{width:S,height:k}},Xe=["width","height","layer","fixorder"],Qe={width:0,height:0},Ze=["minlen","weight","width","height","labeloffset"],tr={minlen:1,weight:1,width:0,height:0,labeloffset:10,labelpos:"r"},er=["labelpos"],rr=function(t){t.getAllEdges().forEach((function(e){if(e.data.width&&e.data.height){var r=t.getNode(e.source),n={e,rank:(t.getNode(e.target).data.rank-r.data.rank)/2+r.data.rank};Ht(t,"edge-proxy",n,"_ep")}}))},nr=function(t){var e=0;return t.getAllNodes().forEach((function(r){var n,o;r.data.borderTop&&(r.data.minRank=null===(n=t.getNode(r.data.borderTop))||void 0===n?void 0:n.data.rank,r.data.maxRank=null===(o=t.getNode(r.data.borderBottom))||void 0===o?void 0:o.data.rank,e=Math.max(e,r.data.maxRank||-1/0))})),e},or=function(t){t.getAllNodes().forEach((function(e){"edge-proxy"===e.data.dummy&&(t.getEdge(e.data.e.id).data.labelRank=e.data.rank,t.removeNode(e.id))}))},ir=function(t,e){var r,n,o=0,i=0,a=e||{},s=a.marginx,u=void 0===s?0:s,d=a.marginy,h=void 0===d?0:d,c=function(t){if(t.data){var e=t.data.x,a=t.data.y,s=t.data.width,u=t.data.height;isNaN(e)||isNaN(s)||(void 0===r&&(r=e-s/2),r=Math.min(r,e-s/2),o=Math.max(o,e+s/2)),isNaN(a)||isNaN(u)||(void 0===n&&(n=a-u/2),n=Math.min(n,a-u/2),i=Math.max(i,a+u/2))}};return t.getAllNodes().forEach((function(t){c(t)})),t.getAllEdges().forEach((function(t){(null==t?void 0:t.data.hasOwnProperty("x"))&&c(t)})),r-=u,n-=h,t.getAllNodes().forEach((function(t){t.data.x-=r,t.data.y-=n})),t.getAllEdges().forEach((function(t){var e;null===(e=t.data.points)||void 0===e||e.forEach((function(t){t.x-=r,t.y-=n})),t.data.hasOwnProperty("x")&&(t.data.x-=r),t.data.hasOwnProperty("y")&&(t.data.y-=n)})),{width:o-r+u,height:i-n+h}},ar=function(t){t.getAllEdges().forEach((function(e){var r,n,o=t.getNode(e.source),i=t.getNode(e.target);e.data.points?(r=e.data.points[0],n=e.data.points[e.data.points.length-1]):(e.data.points=[],r={x:i.data.x,y:i.data.y},n={x:o.data.x,y:o.data.y}),e.data.points.unshift(Yt(o.data,r)),e.data.points.push(Yt(i.data,n))}))},sr=function(t){t.getAllEdges().forEach((function(t){if(t.data.hasOwnProperty("x"))switch("l"!==t.data.labelpos&&"r"!==t.data.labelpos||(t.data.width-=t.data.labeloffset),t.data.labelpos){case"l":t.data.x-=t.data.width/2+t.data.labeloffset;break;case"r":t.data.x+=t.data.width/2+t.data.labeloffset}}))},ur=function(t){t.getAllEdges().forEach((function(t){var e;t.data.reversed&&(null===(e=t.data.points)||void 0===e||e.reverse())}))},dr=function(t){t.getAllNodes().forEach((function(e){var r,n,o;if(null===(r=t.getChildren(e.id))||void 0===r?void 0:r.length){var i=t.getNode(e.id),a=t.getNode(i.data.borderTop),s=t.getNode(i.data.borderBottom),u=t.getNode(i.data.borderLeft[(null===(n=i.data.borderLeft)||void 0===n?void 0:n.length)-1]),d=t.getNode(i.data.borderRight[(null===(o=i.data.borderRight)||void 0===o?void 0:o.length)-1]);i.data.width=Math.abs((null==d?void 0:d.data.x)-(null==u?void 0:u.data.x))||10,i.data.height=Math.abs((null==s?void 0:s.data.y)-(null==a?void 0:a.data.y))||10,i.data.x=((null==u?void 0:u.data.x)||0)+i.data.width/2,i.data.y=((null==a?void 0:a.data.y)||0)+i.data.height/2}})),t.getAllNodes().forEach((function(e){"border"===e.data.dummy&&t.removeNode(e.id)}))},hr=function(t){t.getAllEdges().forEach((function(e){if(e.source===e.target){var r=t.getNode(e.source);r.data.selfEdges||(r.data.selfEdges=[]),r.data.selfEdges.push(e),t.removeEdge(e.id)}}))},cr=function(t){var e=Jt(t);null==e||e.forEach((function(e){var r=0;null==e||e.forEach((function(e,n){var o,i=t.getNode(e);i.data.order=n+r,null===(o=i.data.selfEdges)||void 0===o||o.forEach((function(e){Ht(t,"selfedge",{width:e.data.width,height:e.data.height,rank:i.data.rank,order:n+ ++r,e},"_se")})),delete i.data.selfEdges}))}))},lr=function(t){t.getAllNodes().forEach((function(e){var r=t.getNode(e.id);if("selfedge"===r.data.dummy){var n=t.getNode(r.data.e.source),o=n.data.x+n.data.width/2,i=n.data.y,a=r.data.x-o,s=n.data.height/2;t.hasEdge(r.data.e.id)?t.updateEdgeData(r.data.e.id,r.data.e.data):t.addEdge({id:r.data.e.id,source:r.data.e.source,target:r.data.e.target,data:r.data.e.data}),t.removeNode(e.id),r.data.e.data.points=[{x:o+2*a/3,y:i-s},{x:o+5*a/6,y:i-s},{y:i,x:o+a},{x:o+5*a/6,y:i+s},{x:o+2*a/3,y:i+s}],r.data.e.data.x=r.data.x,r.data.e.data.y=r.data.y}}))},fr=function(t,e){var r={};return null==e||e.forEach((function(e){void 0!==t[e]&&(r[e]=+t[e])})),r},gr=function(t){void 0===t&&(t={});var e={};return Object.keys(t).forEach((function(r){e[r.toLowerCase()]=t[r]})),e},pr={rankdir:"TB",nodesep:50,ranksep:50,edgeLabelSpace:!0,controlPoints:!1,radial:!1,focusNode:null},vr=function(){function t(t){void 0===t&&(t={}),this.options=t,this.id="dagre",this.layoutNode=function(t){return!1!==t.data.layout},this.options=n(n({},pr),t)}return t.prototype.execute=function(t,e){return i(this,void 0,void 0,(function(){return a(this,(function(r){return[2,this.genericDagreLayout(!1,t,e)]}))}))},t.prototype.assign=function(t,e){return i(this,void 0,void 0,(function(){return a(this,(function(r){switch(r.label){case 0:return[4,this.genericDagreLayout(!0,t,e)];case 1:return r.sent(),[2]}}))}))},t.prototype.genericDagreLayout=function(t,e,r){return i(this,void 0,void 0,(function(){var o,i,s,u,d,h,c,l,g,p,v,y,m,w,x,b,M,S,A,I,_,D,O,P,T,z,C,L,q,j,F,V=this;return a(this,(function(a){return o=n(n({},this.options),r),i=o.nodeSize,s=o.rankdir,u=void 0===s?"TB":s,d=o.ranksep,h=o.nodesep,c=o.ranksepFunc,l=o.nodesepFunc,g=o.edgeLabelSpace,p=o.nodeOrder,v=o.begin,y=o.controlPoints,m=new f({tree:[]}),w=k(d||50,c),x=k(h||50,l),b=x,M=w,"LR"!==u&&"RL"!==u||(b=w,M=x),S=R(i,void 0),A=e.getAllNodes(),I=e.getAllEdges(),A.filter((function(t){return!1!==t.data.layout})).forEach((function(t){var e=S(t),r=M(t),n=e+2*b(t),o=e+2*r,i=t.data.layer;E(i)?m.addNode({id:t.id,data:{width:n,height:o,layer:i}}):m.addNode({id:t.id,data:{width:n,height:o}})})),I.forEach((function(t){V.layoutNode(m.getNode(t.source))&&V.layoutNode(m.getNode(t.target))&&m.addEdge({id:t.id,source:t.source,target:t.target,data:{weight:t.data.weight||1}})})),function(t,e){var r,o,i=e.edgeLabelSpace,a=e.keepNodeOrder,s=e.prevGraph,u=e.rankdir,d=e.ranksep;!a&&s&&(o=s,(r=t).getAllNodes().forEach((function(t){var e=r.getNode(t.id),n=o.getNode(t.id);void 0!==n?(e.data.fixorder=n.data._order,delete n.data._order):delete e.data.fixorder})));var h=function(t){var e=new f({tree:[]});return t.getAllNodes().forEach((function(r){var o=gr(t.getNode(r.id).data),i=n(n({},Qe),o),a=fr(i,Xe);e.hasNode(r.id)||e.addNode({id:r.id,data:n({},a)});var s=t.getParent(r.id);null==s||(e.hasNode(s.id)||e.addNode(n({},s)),e.setParent(r.id,s.id))})),t.getAllEdges().forEach((function(r){var n=gr(t.getEdge(r.id).data),o={};null==er||er.forEach((function(t){void 0!==n[t]&&(o[t]=n[t])})),e.addEdge({id:r.id,source:r.source,target:r.target,data:Object.assign({},tr,fr(n,Ze),o)})})),e}(t);!1!==i&&(e.ranksep=function(t,e){var r=e.ranksep,n=void 0===r?0:r,o=e.rankdir;return t.getAllNodes().forEach((function(t){isNaN(t.data.layer)||t.data.layer||(t.data.layer=0)})),t.getAllEdges().forEach((function(t){var e;t.data.minlen*=2,"c"!==(null===(e=t.data.labelpos)||void 0===e?void 0:e.toLowerCase())&&("TB"===o||"BT"===o?t.data.width+=t.data.labeloffset:t.data.height+=t.data.labeloffset)})),n/2}(h,{rankdir:u,ranksep:d}));try{Je(h,e)}catch(t){if("Not possible to find intersection inside of the rectangle"===t.message)return void 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:\\n",t);throw t}!function(t,e){t.getAllNodes().forEach((function(r){var n,o=t.getNode(r.id);if(o){var i=e.getNode(r.id);o.data.x=i.data.x,o.data.y=i.data.y,o.data._order=i.data.order,o.data._rank=i.data.rank,(null===(n=e.getChildren(r.id))||void 0===n?void 0:n.length)&&(o.data.width=i.data.width,o.data.height=i.data.height)}})),t.getAllEdges().forEach((function(r){var n=t.getEdge(r.id),o=e.getEdge(r.id);n.data.points=o?o.data.points:[],o&&o.data.hasOwnProperty("x")&&(n.data.x=o.data.x,n.data.y=o.data.y)}))}(t,h)}(m,{prevGraph:null,edgeLabelSpace:g,keepNodeOrder:!!p,nodeOrder:p||[],acyclicer:"greedy",ranker:"network-simplex",rankdir:u,nodesep:h}),_=[0,0],v&&(D=1/0,O=1/0,m.getAllNodes().forEach((function(t){D>t.data.x&&(D=t.data.x),O>t.data.y&&(O=t.data.y)})),m.getAllEdges().forEach((function(t){var e;null===(e=t.data.points)||void 0===e||e.forEach((function(t){D>t.x&&(D=t.x),O>t.y&&(O=t.y)}))})),_[0]=v[0]-D,_[1]=v[1]-O),P="LR"===u||"RL"===u,T=new Set,z="BT"===u||"RL"===u?function(t,e){return e-t}:function(t,e){return t-e},m.getAllNodes().forEach((function(t){t.data.x=t.data.x+_[0],t.data.y=t.data.y+_[1],T.add(P?t.data.x:t.data.y)})),C=Array.from(T).sort(z),L=P?function(t,e){return t.x!==e.x}:function(t,e){return t.y!==e.y},q=P?function(t,e,r){var n=Math.max(e.y,r.y),o=Math.min(e.y,r.y);return t.filter((function(t){return t.y<=n&&t.y>=o}))}:function(t,e,r){var n=Math.max(e.x,r.x),o=Math.min(e.x,r.x);return t.filter((function(t){return t.x<=n&&t.x>=o}))},m.getAllEdges().forEach((function(t,e){var r;g&&y&&"loop"!==t.data.type&&(t.data.controlPoints=yr(t.data.points,m.getNode(t.source),m.getNode(t.target),C,P,L,q),null===(r=t.data.controlPoints)||void 0===r||r.forEach((function(t){t.x+=_[0],t.y+=_[1]})))})),j=[],j=m.getAllNodes().map((function(t){return N(t)})),F=m.getAllEdges(),t&&(j.forEach((function(t){e.mergeNodeData(t.id,{x:t.data.x,y:t.data.y})})),F.forEach((function(t){e.mergeEdgeData(t.id,{controlPoints:t.data.controlPoints})}))),[2,{nodes:j,edges:F}]}))}))},t}(),yr=function(t,e,r,n,o,i,a){var s=(null==t?void 0:t.slice(1,t.length-1))||[];if(e&&r){var u=e.data,d=u.x,h=u.y,c=r.data,l=c.x,f=c.y;if(o&&(d=e.data.y,h=e.data.x,l=r.data.y,f=r.data.x),f!==h&&d!==l){var g=n.indexOf(h),p=n[g+1];if(p){var v=s[0],y=o?{x:(h+p)/2,y:(null==v?void 0:v.y)||l}:{x:(null==v?void 0:v.x)||l,y:(h+p)/2};v&&!i(v,y)||s.unshift(y)}var m=n.indexOf(f),w=Math.abs(m-g);if(1===w)(s=a(s,e.data,r.data)).length||s.push(o?{x:(h+f)/2,y:d}:{x:d,y:(h+f)/2});else if(w>1){var x=n[m-1];if(x){var E=s[s.length-1],b=o?{x:(f+x)/2,y:(null==E?void 0:E.y)||l}:{x:(null==E?void 0:E.x)||d,y:(f+x)/2};E&&!i(E,b)||s.push(b)}}}}return s};function mr(t){var e=0,r=0,n=0;if(t.length){for(var o=0;o<4;o++)(i=t[o])&&i.weight&&(e+=i.weight,r+=i.x*i.weight,n+=i.y*i.weight);t.x=r/e,t.y=n/e,t.weight=e}else{var i=t;t.x=i.data.x,t.y=i.data.y,t.weight=i.data.weight}}var wr=function(t,e,r,n,o,i){var a=i.x-t.x||.1,s=i.y-t.y||.1,u=n-e,d=a*a+s*s,h=Math.sqrt(d)*d;if(u*u*.81<d){var c=t.weight/h;return i.vx+=a*c,i.vy+=s*c,!0}if(t.length)return!1;t.data!==i&&(c=t.data.weight/h,i.vx+=a*c,i.vy+=s*c)},xr={maxIteration:500,gravity:10,factor:1,edgeStrength:200,nodeStrength:1e3,coulombDisScale:.005,damping:.9,maxSpeed:500,minMovement:.4,interval:.02,linkDistance:200,clusterNodeStrength:20,preventOverlap:!0,distanceThresholdMode:"mean"},Er=function(){function t(t){void 0===t&&(t={}),this.options=t,this.id="force",this.timeInterval=0,this.judgingDistance=0,this.running=!1,this.options=n(n({},xr),t)}return t.prototype.execute=function(t,e){return i(this,void 0,void 0,(function(){return a(this,(function(r){return[2,this.genericForceLayout(!1,t,e)]}))}))},t.prototype.assign=function(t,e){return i(this,void 0,void 0,(function(){return a(this,(function(r){return this.genericForceLayout(!0,t,e),[2]}))}))},t.prototype.stop=function(){this.timeInterval&&"undefined"!=typeof window&&window.clearInterval(this.timeInterval),this.running=!1},t.prototype.tick=function(t){var e=this;if(void 0===t&&(t=this.options.maxIteration||1),this.lastResult)return this.lastResult;for(var r=0;(this.judgingDistance>this.lastOptions.minMovement||r<1)&&r<t;r++)this.runOneStep(this.lastCalcGraph,this.lastGraph,r,this.lastVelMap,this.lastOptions),this.updatePosition(this.lastGraph,this.lastCalcGraph,this.lastVelMap,this.lastOptions);var n={nodes:this.lastLayoutNodes,edges:this.lastLayoutEdges};return this.lastAssign&&n.nodes.forEach((function(t){return e.lastGraph.mergeNodeData(t.id,{x:t.data.x,y:t.data.y})})),n},t.prototype.genericForceLayout=function(t,e,r){return i(this,void 0,void 0,(function(){var o,i,s,u,d,h,c,l,g,p,v,y,m,w,x,b,N,M,S,k=this;return a(this,(function(a){return o=n(n({},this.options),r),i=e.getAllNodes(),s=e.getAllEdges(),u=this.formatOptions(o,e),d=u.width,h=u.height,c=u.nodeSize,l=u.getMass,g=u.nodeStrength,p=u.edgeStrength,v=u.linkDistance,y=i.map((function(t){return n(n({},t),{data:n(n({},t.data),{x:E(t.data.x)?t.data.x:Math.random()*d,y:E(t.data.y)?t.data.y:Math.random()*h,size:c(t)||30,mass:l(t),nodeStrength:g(t)})})})),m=s.map((function(t){return n(n({},t),{data:n(n({},t.data),{edgeStrength:p(t),linkDistance:v(t,e.getNode(t.source),e.getNode(t.target))})})})),(null==i?void 0:i.length)?(w={},i.forEach((function(t,e){w[t.id]={x:0,y:0}})),x=new f({nodes:y,edges:m}),this.formatCentripetal(u,x),b=u.maxIteration,N=u.minMovement,M=u.onTick,this.lastLayoutNodes=y,this.lastLayoutEdges=m,this.lastAssign=t,this.lastGraph=e,this.lastCalcGraph=x,this.lastOptions=u,this.lastVelMap=w,"undefined"==typeof window?[2]:(S=0,[2,new Promise((function(r){k.timeInterval=window.setInterval((function(){i&&k.running||r({nodes:kr(e,y),edges:s}),k.runOneStep(x,e,S,w,u),k.updatePosition(e,x,w,u),t&&y.forEach((function(t){return e.mergeNodeData(t.id,{x:t.data.x,y:t.data.y})})),null==M||M({nodes:kr(e,y),edges:s}),(++S>=b||k.judgingDistance<N)&&(window.clearInterval(k.timeInterval),r({nodes:kr(e,y),edges:s}))}),0),k.running=!0}))])):(this.lastResult={nodes:[],edges:s},[2,{nodes:[],edges:s}])}))}))},t.prototype.formatOptions=function(t,e){var r=t,n=t.width,o=t.height,i=t.getMass;if(r.width=n||"undefined"==typeof window?n:window.innerWidth,r.height=o||"undefined"==typeof window?o:window.innerHeight,t.center||(r.center=[r.width/2,r.height/2]),i||(r.getMass=function(t){var r=1;E(null==t?void 0:t.data.mass)&&(r=null==t?void 0:t.data.mass);var n=e.getDegree(t.id,"both");return!n||n<5?r:5*n*r}),t.preventOverlap){var a=k(0,t.nodeSpacing);t.nodeSize?p(t.nodeSize)?r.nodeSize=function(e){var r=t.nodeSize;return Math.max(r[0],r[1])+a(e)}:r.nodeSize=function(e){return t.nodeSize+a(e)}:r.nodeSize=function(t){var e=((null==t?void 0:t.data)||{}).size;return e?p(e)?Math.max(e[0],e[1])+a(t):S(e)?Math.max(e.width,e.height)+a(t):e+a(t):10+a(t)}}return r.linkDistance=t.linkDistance?k(1,t.linkDistance):function(t){return 1+r.nodeSize(e.getNode(t.source))+r.nodeSize(e.getNode(t.target))},r.nodeStrength=k(1,t.nodeStrength),r.edgeStrength=k(1,t.edgeStrength),t},t.prototype.formatCentripetal=function(t,e){var r,n=t.centripetalOptions,o=t.center,i=t.clusterNodeStrength,a=t.leafCluster,s=t.clustering,u=t.nodeClusterBy,d=e.getAllNodes(),h=n||{leaf:2,single:2,others:1,center:function(t){return{x:o[0],y:o[1]}}};"function"!=typeof i&&(t.clusterNodeStrength=function(t){return i});var c=[];if(a&&u&&(r=br(e,u),c=Array.from(new Set(null==d?void 0:d.map((function(t){return t.data[u]}))))||[],t.centripetalOptions=Object.assign(h,{single:100,leaf:function(e){var n=r[e.id]||{},o=n.siblingLeaves,i=n.sameTypeLeaves;return(null==i?void 0:i.length)===(null==o?void 0:o.length)||1===(null==c?void 0:c.length)?1:t.clusterNodeStrength(e)},others:1,center:function(t){var n,o=e.getDegree(t.id,"both");if(!o)return{x:100,y:100};if(1===o){var i=(r[t.id]||{}).sameTypeLeaves,a=void 0===i?[]:i;1===a.length?n=void 0:a.length>1&&(n=Sr(a))}else n=void 0;return{x:null==n?void 0:n.x,y:null==n?void 0:n.y}}})),s&&u){r||(r=br(e,u)),c||(c=Array.from(new Set(d.map((function(t){return t.data[u]}))))),c=c.filter((function(t){return void 0!==t}));var l={};c.forEach((function(t){var r=d.filter((function(e){return e.data[u]===t})).map((function(t){return e.getNode(t.id)}));l[t]=Sr(r)})),t.centripetalOptions=Object.assign(h,{single:function(e){return t.clusterNodeStrength(e)},leaf:function(e){return t.clusterNodeStrength(e)},others:function(e){return t.clusterNodeStrength(e)},center:function(t){var e=l[t.data[u]];return{x:null==e?void 0:e.x,y:null==e?void 0:e.y}}})}var f=t.centripetalOptions||{},g=f.leaf,p=f.single,v=f.others;g&&"function"!=typeof g&&(t.centripetalOptions.leaf=function(){return g}),p&&"function"!=typeof p&&(t.centripetalOptions.single=function(){return p}),v&&"function"!=typeof v&&(t.centripetalOptions.others=function(){return v})},t.prototype.runOneStep=function(t,e,r,n,o){var i={},a=t.getAllNodes(),s=t.getAllEdges();if(null==a?void 0:a.length){var u=o.monitor;this.calRepulsive(t,i,o),s&&this.calAttractive(t,i),this.calGravity(t,e,i,o),this.updateVelocity(t,i,n,o),u&&u({energy:this.calTotalEnergy(i,a),nodes:e.getAllNodes(),edges:e.getAllEdges(),iterations:r})}},t.prototype.calTotalEnergy=function(t,e){if(!(null==e?void 0:e.length))return 0;var r=0;return e.forEach((function(e,n){var o=t[e.id].x,i=t[e.id].y,a=o*o+i*i,s=e.data.mass;r+=(void 0===s?1:s)*a*.5})),r},t.prototype.calRepulsive=function(t,e,r){var n=r.factor,o=r.coulombDisScale;!function(t,e,r,n){var o=e/r,i=t.getAllNodes(),a=i.map((function(t,e){var r=t.data,n=r.nodeStrength;return{x:r.x,y:r.y,size:r.size,index:e,vx:0,vy:0,weight:o*n}})),s=V(a,(function(t){return t.x}),(function(t){return t.y})).visitAfter(mr);a.forEach((function(t){!function(t,e){e.visit((function(e,r,n,o,i){return wr(e,r,n,o,i,t)}))}(t,s)})),a.map((function(t,e){var r=i[e],o=r.id,a=r.data.mass,s=void 0===a?1:a;n[o]={x:t.vx/s,y:t.vy/s}}))}(t,n,o*o,e)},t.prototype.calAttractive=function(t,e){t.getAllEdges().forEach((function(r,n){var o=r.source,i=r.target,a=t.getNode(o),s=t.getNode(i);if(a&&s){var u=s.data.x-a.data.x,d=s.data.y-a.data.y;u||d||(u=.01*Math.random(),d=.01*Math.random());var h=Math.sqrt(u*u+d*d),c=u/h,l=d/h,f=r.data||{},g=f.linkDistance,p=void 0===g?200:g,v=f.edgeStrength,y=(p-h)*(void 0===v?200:v),m=1/(a.data.mass||1),w=1/(s.data.mass||1),x=c*y,E=l*y;e[o].x-=x*m,e[o].y-=E*m,e[i].x+=x*w,e[i].y+=E*w}}))},t.prototype.calGravity=function(t,e,r,n){var o=n.getCenter,i=t.getAllNodes(),a=e.getAllNodes(),u=e.getAllEdges(),d=n.width,h=n.height,c=n.center,l=n.gravity,f=n.centripetalOptions;i&&i.forEach((function(n){var i=n.id,g=n.data,p=g.mass,v=g.x,y=g.y,m=e.getNode(i),w=0,x=0,b=l,N=t.getDegree(i,"in"),M=t.getDegree(i,"out"),S=t.getDegree(i,"both"),k=null==o?void 0:o(m,S);if(k){var A=s(k,3);w=v-A[0],x=y-A[1],b=A[2]}else w=v-c[0],x=y-c[1];if(b&&(r[i].x-=b*w/p,r[i].y-=b*x/p),f){var R=f.leaf,I=f.single,_=f.others,D=f.center,O=(null==D?void 0:D(m,a,u,d,h))||{x:0,y:0,centerStrength:0},P=O.x,T=O.y,z=O.centerStrength;if(!E(P)||!E(T))return;var C=(v-P)/p,L=(y-T)/p;if(z&&(r[i].x-=z*C,r[i].y-=z*L),0===S){var q=I(m);if(!q)return;return r[i].x-=q*C,void(r[i].y-=q*L)}if(0===N||0===M){var j=R(m,a,u);if(!j)return;return r[i].x-=j*C,void(r[i].y-=j*L)}var F=_(m);if(!F)return;r[i].x-=F*C,r[i].y-=F*L}}))},t.prototype.updateVelocity=function(t,e,r,n){var o=n.damping,i=n.maxSpeed,a=n.interval,s=t.getAllNodes();(null==s?void 0:s.length)&&s.forEach((function(t){var n=t.id,s=(r[n].x+e[n].x*a)*o||.01,u=(r[n].y+e[n].y*a)*o||.01,d=Math.sqrt(s*s+u*u);if(d>i){var h=i/d;s*=h,u*=h}r[n]={x:s,y:u}}))},t.prototype.updatePosition=function(t,e,r,n){var o=this,i=n.distanceThresholdMode,a=n.interval,s=e.getAllNodes();if(null==s?void 0:s.length){var u=0;"max"===i?this.judgingDistance=-1/0:"min"===i&&(this.judgingDistance=1/0),s.forEach((function(n){var s=n.id,d=t.getNode(s);if(E(d.data.fx)&&E(d.data.fy))e.mergeNodeData(s,{x:d.data.fx,y:d.data.fy});else{var h=r[s].x*a,c=r[s].y*a;e.mergeNodeData(s,{x:n.data.x+h,y:n.data.y+c});var l=Math.sqrt(h*h+c*c);switch(i){case"max":o.judgingDistance<l&&(o.judgingDistance=l);break;case"min":o.judgingDistance>l&&(o.judgingDistance=l);break;default:u+=l}}})),i&&"mean"!==i||(this.judgingDistance=u/s.length)}else this.judgingDistance=0},t}(),br=function(t,e){var r=t.getAllNodes();if(!(null==r?void 0:r.length))return{};var n={};return r.forEach((function(r,o){1===t.getDegree(r.id,"both")&&(n[r.id]=Nr(t,"leaf",r,e))})),n},Nr=function(t,e,r,n){var o=t.getDegree(r.id,"in"),i=t.getDegree(r.id,"out"),a=r,s=[];return 0===o?(a=t.getSuccessors(r.id)[0],s=t.getNeighbors(a.id)):0===i&&(a=t.getPredecessors(r.id)[0],s=t.getNeighbors(a.id)),s=s.filter((function(e){return 0===t.getDegree(e.id,"in")||0===t.getDegree(e.id,"out")})),{coreNode:a,siblingLeaves:s,sameTypeLeaves:Mr(t,e,n,r,s)}},Mr=function(t,e,r,n,o){var i=n.data[r]||"",a=(null==o?void 0:o.filter((function(t){return t.data[r]===i})))||[];return"leaf"===e&&(a=a.filter((function(e){return 0===t.getDegree(e.id,"in")||0===t.getDegree(e.id,"out")}))),a},Sr=function(t){var e={x:0,y:0};t.forEach((function(t){var r=t.data,n=r.x,o=r.y;e.x+=n||0,e.y+=o||0}));var r=t.length||1;return{x:e.x/r,y:e.y/r}},kr=function(t,e){return e.map((function(e){var r=e.id,o=e.data,i=t.getNode(r);return n(n({},i),{data:n(n({},i.data),{x:o.x,y:o.y})})}))},Ar=function(){function t(t){this.id=t.id||0,this.rx=t.rx,this.ry=t.ry,this.fx=0,this.fy=0,this.mass=t.mass,this.degree=t.degree,this.g=t.g||0}return t.prototype.distanceTo=function(t){var e=this.rx-t.rx,r=this.ry-t.ry;return Math.hypot(e,r)},t.prototype.setPos=function(t,e){this.rx=t,this.ry=e},t.prototype.resetForce=function(){this.fx=0,this.fy=0},t.prototype.addForce=function(t){var e=t.rx-this.rx,r=t.ry-this.ry,n=Math.hypot(e,r);n=n<1e-4?1e-4:n;var o=this.g*(this.degree+1)*(t.degree+1)/n;this.fx+=o*e/n,this.fy+=o*r/n},t.prototype.in=function(t){return t.contains(this.rx,this.ry)},t.prototype.add=function(e){var r=this.mass+e.mass;return new t({rx:(this.rx*this.mass+e.rx*e.mass)/r,ry:(this.ry*this.mass+e.ry*e.mass)/r,mass:r,degree:this.degree+e.degree})},t}();const Rr=Ar;const Ir=function(){function t(t){this.xmid=t.xmid,this.ymid=t.ymid,this.length=t.length,this.massCenter=t.massCenter||[0,0],this.mass=t.mass||1}return t.prototype.getLength=function(){return this.length},t.prototype.contains=function(t,e){var r=this.length/2;return t<=this.xmid+r&&t>=this.xmid-r&&e<=this.ymid+r&&e>=this.ymid-r},t.prototype.NW=function(){return new t({xmid:this.xmid-this.length/4,ymid:this.ymid+this.length/4,length:this.length/2})},t.prototype.NE=function(){return new t({xmid:this.xmid+this.length/4,ymid:this.ymid+this.length/4,length:this.length/2})},t.prototype.SW=function(){return new t({xmid:this.xmid-this.length/4,ymid:this.ymid-this.length/4,length:this.length/2})},t.prototype.SE=function(){return new t({xmid:this.xmid+this.length/4,ymid:this.ymid-this.length/4,length:this.length/2})},t}(),_r=function(){function t(t){this.body=null,this.quad=null,this.NW=null,this.NE=null,this.SW=null,this.SE=null,this.theta=.5,null!=t&&(this.quad=t)}return t.prototype.insert=function(e){null!=this.body?this._isExternal()?(this.quad&&(this.NW=new t(this.quad.NW()),this.NE=new t(this.quad.NE()),this.SW=new t(this.quad.SW()),this.SE=new t(this.quad.SE())),this._putBody(this.body),this._putBody(e),this.body=this.body.add(e)):(this.body=this.body.add(e),this._putBody(e)):this.body=e},t.prototype._putBody=function(t){this.quad&&(t.in(this.quad.NW())&&this.NW?this.NW.insert(t):t.in(this.quad.NE())&&this.NE?this.NE.insert(t):t.in(this.quad.SW())&&this.SW?this.SW.insert(t):t.in(this.quad.SE())&&this.SE&&this.SE.insert(t))},t.prototype._isExternal=function(){return null==this.NW&&null==this.NE&&null==this.SW&&null==this.SE},t.prototype.updateForce=function(t){null!=this.body&&t!==this.body&&(this._isExternal()||(this.quad?this.quad.getLength():0)/this.body.distanceTo(t)<this.theta?t.addForce(this.body):(this.NW&&this.NW.updateForce(t),this.NE&&this.NE.updateForce(t),this.SW&&this.SW.updateForce(t),this.SE&&this.SE.updateForce(t)))},t}();var Dr={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},Or=function(){function t(t){void 0===t&&(t={}),this.options=t,this.id="forceAtlas2",this.options=n(n({},Dr),t)}return t.prototype.execute=function(t,e){return i(this,void 0,void 0,(function(){return a(this,(function(r){return[2,this.genericForceAtlas2Layout(!1,t,e)]}))}))},t.prototype.assign=function(t,e){return i(this,void 0,void 0,(function(){return a(this,(function(r){return this.genericForceAtlas2Layout(!0,t,e),[2]}))}))},t.prototype.genericForceAtlas2Layout=function(t,e,r){return i(this,void 0,void 0,(function(){var o,i,s,u,d,h,c,l,g,p,v,y,m,w,x,E,b,M,S,k,A,R;return a(this,(function(a){if(o=e.getAllEdges(),i=e.getAllNodes(),s=this.formatOptions(r,i.length),u=s.width,d=s.height,h=s.prune,c=s.maxIteration,l=s.nodeSize,g=s.center,!(null==i?void 0:i.length)||1===i.length)return[2,I(e,t,g)];if(p=i.map((function(t){return N(t,[u,d])})),v=o.filter((function(t){return t.source!==t.target})),y=new f({nodes:p,edges:v}),m=this.getSizes(y,e,l),this.run(y,e,c,m,t,s),h){for(w=0;w<v.length;w+=1)x=v[w],E=x.source,b=x.target,M=y.getDegree(E),S=y.getDegree(E),M<=1?(k=y.getNode(b),y.mergeNodeData(E,{x:k.data.x,y:k.data.y})):S<=1&&(A=y.getNode(E),y.mergeNodeData(b,{x:A.data.x,y:A.data.y}));R=n(n({},s),{prune:!1,barnesHut:!1}),this.run(y,e,100,m,t,R)}return[2,{nodes:p,edges:o}]}))}))},t.prototype.getSizes=function(t,e,r){for(var n=t.getAllNodes(),o={},i=0;i<n.length;i+=1){var a=n[i],d=a.id,h=a.data;if(o[d]=10,E(h.size))o[d]=h.size;else if(p(h.size))isNaN(h.size[0])||(o[d]=Math.max(h.size[0])),isNaN(h.size[1])||(o[d]=Math.max(h.size[1]));else if(S(h.size))o[d]=Math.max(h.size.width,h.size.height);else if(M(r)){var c=r(e.getNode(d));p(c)?o[d]=Math.max.apply(Math,u([],s(c),!1)):o[d]=c}else p(r)?o[d]=Math.max.apply(Math,u([],s(r),!1)):E(r)&&(o[d]=r)}return o},t.prototype.formatOptions=function(t,e){void 0===t&&(t={});var r=n(n({},this.options),t),o=r.center,i=r.width,a=r.height,s=r.barnesHut,u=r.prune,d=r.maxIteration,h=r.kr,c=r.kg;return r.width=i||"undefined"==typeof window?i:window.innerWidth,r.height=a||"undefined"==typeof window?a:window.innerHeight,r.center=o||[r.width/2,r.height/2],void 0===s&&e>250&&(r.barnesHut=!0),void 0===u&&e>100&&(r.prune=!0),0!==d||u?0===d&&u&&(r.maxIteration=100,e<=200&&e>100?r.maxIteration=500:e>200&&(r.maxIteration=950)):(r.maxIteration=250,e<=200&&e>100?r.maxIteration=1e3:e>200&&(r.maxIteration=1200)),h||(r.kr=50,e>100&&e<=500?r.kr=20:e>500&&(r.kr=1)),c||(r.kg=20,e>100&&e<=500?r.kg=10:e>500&&(r.kg=1)),r},t.prototype.run=function(t,e,r,n,o,i){for(var a=i.kr,s=i.barnesHut,u=i.onTick,d=t.getAllNodes(),h=0,c=r,l={},f={},g={},p=0;p<d.length;p+=1){var v=d[p],y=v.data,m=v.id;if(l[m]=[0,0],s){var w={id:p,rx:y.x,ry:y.y,mass:1,g:a,degree:t.getDegree(m)};g[m]=new Rr(w)}}for(;c>0;)h=this.oneStep(t,{iter:c,preventOverlapIters:50,krPrime:100,sg:h,forces:l,preForces:f,bodies:g,sizes:n},i),c--,null==u||u({nodes:d,edges:e.getAllEdges()});return t},t.prototype.oneStep=function(t,e,r){for(var n=e.iter,o=e.preventOverlapIters,i=e.krPrime,a=e.sg,d=e.preForces,h=e.bodies,c=e.sizes,l=e.forces,f=r.preventOverlap,g=r.barnesHut,p=t.getAllNodes(),v=0;v<p.length;v+=1){var y=p[v].id;d[y]=u([],s(l[y]),!1),l[y]=[0,0]}return l=this.getAttrForces(t,n,o,c,l,r),l=g&&(f&&n>o||!f)?this.getOptRepGraForces(t,l,h,r):this.getRepGraForces(t,n,o,l,i,c,r),this.updatePos(t,l,d,a,r)},t.prototype.getAttrForces=function(t,e,r,n,o,i){for(var a=i.preventOverlap,s=i.dissuadeHubs,u=i.mode,d=i.prune,h=t.getAllEdges(),c=0;c<h.length;c+=1){var l=h[c],f=l.source,g=l.target,p=t.getNode(f),v=t.getNode(g),y=t.getDegree(f),m=t.getDegree(g);if(!d||!(y<=1||m<=1)){var w=[v.data.x-p.data.x,v.data.y-p.data.y],x=Math.hypot(w[0],w[1]);x=x<1e-4?1e-4:x,w[0]=w[0]/x,w[1]=w[1]/x,a&&e<r&&(x=x-n[f]-n[g]);var E=x,b=E;"linlog"===u&&(b=E=Math.log(1+x)),s&&(E=x/y,b=x/m),a&&e<r&&x<=0?(E=0,b=0):a&&e<r&&x>0&&(E=x,b=x),o[f][0]+=E*w[0],o[g][0]-=b*w[0],o[f][1]+=E*w[1],o[g][1]-=b*w[1]}}return o},t.prototype.getOptRepGraForces=function(t,e,r,n){for(var o=n.kg,i=n.center,a=n.prune,s=t.getAllNodes(),u=s.length,d=9e10,h=-9e10,c=9e10,l=-9e10,f=0;f<u;f+=1){var g=s[f],p=g.id,v=g.data;a&&t.getDegree(p)<=1||(r[p].setPos(v.x,v.y),v.x>=h&&(h=v.x),v.x<=d&&(d=v.x),v.y>=l&&(l=v.y),v.y<=c&&(c=v.y))}var y=Math.max(h-d,l-c),m=new Ir({xmid:(h+d)/2,ymid:(l+c)/2,length:y,massCenter:i,mass:u}),w=new _r(m);for(f=0;f<u;f+=1)p=s[f].id,a&&t.getDegree(p)<=1||r[p].in(m)&&w.insert(r[p]);for(f=0;f<u;f+=1){var x=s[f],E=(p=x.id,v=x.data,t.getDegree(p));if(!(a&&E<=1)){r[p].resetForce(),w.updateForce(r[p]),e[p][0]-=r[p].fx,e[p][1]-=r[p].fy;var b=[v.x-i[0],v.y-i[1]],N=Math.hypot(b[0],b[1]);N=N<1e-4?1e-4:N,b[0]=b[0]/N,b[1]=b[1]/N;var M=o*(E+1);e[p][0]-=M*b[0],e[p][1]-=M*b[1]}}return e},t.prototype.getRepGraForces=function(t,e,r,n,o,i,a){for(var s=a.preventOverlap,u=a.kr,d=a.kg,h=a.center,c=a.prune,l=t.getAllNodes(),f=l.length,g=0;g<f;g+=1){for(var p=l[g],v=t.getDegree(p.id),y=g+1;y<f;y+=1){var m=l[y],w=t.getDegree(m.id);if(!c||!(v<=1||w<=1)){var x=[m.data.x-p.data.x,m.data.y-p.data.y],E=Math.hypot(x[0],x[1]);E=E<1e-4?1e-4:E,x[0]=x[0]/E,x[1]=x[1]/E,s&&e<r&&(E=E-i[p.id]-i[m.id]);var b=u*(v+1)*(w+1)/E;s&&e<r&&E<0?b=o*(v+1)*(w+1):s&&e<r&&0===E?b=0:s&&e<r&&E>0&&(b=u*(v+1)*(w+1)/E),n[p.id][0]-=b*x[0],n[m.id][0]+=b*x[0],n[p.id][1]-=b*x[1],n[m.id][1]+=b*x[1]}}var N=[p.data.x-h[0],p.data.y-h[1]],M=Math.hypot(N[0],N[1]);N[0]=N[0]/M,N[1]=N[1]/M;var S=d*(v+1);n[p.id][0]-=S*N[0],n[p.id][1]-=S*N[1]}return n},t.prototype.updatePos=function(t,e,r,n,o){for(var i=o.ks,a=o.tao,s=o.prune,u=o.ksmax,d=t.getAllNodes(),h=d.length,c=[],l=[],f=0,g=0,p=n,v=0;v<h;v+=1){var y=d[v].id,m=t.getDegree(y);if(!(s&&m<=1)){var w=[e[y][0]-r[y][0],e[y][1]-r[y][1]],x=Math.hypot(w[0],w[1]),b=[e[y][0]+r[y][0],e[y][1]+r[y][1]],N=Math.hypot(b[0],b[1]);c[v]=x,l[v]=N/2,f+=(m+1)*c[v],g+=(m+1)*l[v]}}var M=p;for(p=a*g/f,0!==M&&(p=p>1.5*M?1.5*M:p),v=0;v<h;v+=1){var S=d[v],k=(y=S.id,S.data);if(m=t.getDegree(y),!(s&&m<=1||E(k.fx)&&E(k.fy))){var A=i*p/(1+p*Math.sqrt(c[v])),R=Math.hypot(e[y][0],e[y][1]),I=u/(R=R<1e-4?1e-4:R),_=(A=A>I?I:A)*e[y][0],D=A*e[y][1];t.mergeNodeData(y,{x:k.x+_,y:k.y+D})}}return p},t}(),Pr={maxIteration:1e3,gravity:10,speed:5,clustering:!1,clusterGravity:10,width:300,height:300,nodeClusterBy:"cluster"},Tr=function(){function t(t){void 0===t&&(t={}),this.options=t,this.id="fruchterman",this.timeInterval=0,this.running=!1,this.options=n(n({},Pr),t)}return t.prototype.execute=function(t,e){return i(this,void 0,void 0,(function(){return a(this,(function(r){return[2,this.genericFruchtermanLayout(!1,t,e)]}))}))},t.prototype.assign=function(t,e){return i(this,void 0,void 0,(function(){return a(this,(function(r){return this.genericFruchtermanLayout(!0,t,e),[2]}))}))},t.prototype.stop=function(){this.timeInterval&&"undefined"!=typeof window&&window.clearInterval(this.timeInterval),this.running=!1},t.prototype.tick=function(t){var e=this;if(void 0===t&&(t=this.options.maxIteration||1),this.lastResult)return this.lastResult;for(var r=0;r<t;r++)this.runOneStep(this.lastGraph,this.lastClusterMap,this.lastOptions);var n={nodes:this.lastLayoutNodes,edges:this.lastLayoutEdges};return this.lastAssign&&n.nodes.forEach((function(t){return e.lastGraph.mergeNodeData(t.id,{x:t.data.x,y:t.data.y})})),n},t.prototype.genericFruchtermanLayout=function(t,e,r){return i(this,void 0,void 0,(function(){var o,i,s,u,d,h,c,l,g,p,v,y,m,w,x,E=this;return a(this,(function(a){return this.running?[2]:(o=this.formatOptions(r),i=o.width,s=o.height,u=o.center,d=o.clustering,h=o.nodeClusterBy,c=o.maxIteration,l=o.onTick,g=e.getAllNodes(),p=e.getAllEdges(),(null==g?void 0:g.length)?1===g.length?(t&&e.mergeNodeData(g[0].id,{x:u[0],y:u[1]}),v={nodes:[n(n({},g[0]),{data:n(n({},g[0].data),{x:u[0],y:u[1]})})],edges:p},this.lastResult=v,[2,v]):(y=g.map((function(t){return N(t,[i,s])})),m=new f({nodes:y,edges:p}),w={},d&&y.forEach((function(t){var e=t.data[h];w[e]||(w[e]={name:e,cx:0,cy:0,count:0})})),this.lastLayoutNodes=y,this.lastLayoutEdges=p,this.lastAssign=t,this.lastGraph=m,this.lastOptions=o,this.lastClusterMap=w,"undefined"==typeof window?[2]:(x=0,[2,new Promise((function(r){E.timeInterval=window.setInterval((function(){E.running?(E.runOneStep(m,w,o),t&&y.forEach((function(t){var r=t.id,n=t.data;return e.mergeNodeData(r,{x:n.x,y:n.y})})),null==l||l({nodes:y,edges:p}),++x>=c&&(window.clearInterval(E.timeInterval),r({nodes:y,edges:p}))):r({nodes:y,edges:p})}),0),E.running=!0}))])):(v={nodes:[],edges:p},this.lastResult=v,[2,v]))}))}))},t.prototype.formatOptions=function(t){void 0===t&&(t={});var e=n(n({},this.options),t),r=e.clustering,o=e.nodeClusterBy,i=e.center,a=e.width,s=e.height;return e.width=a||"undefined"==typeof window?a:window.innerWidth,e.height=s||"undefined"==typeof window?s:window.innerHeight,e.center=i||[e.width/2,e.height/2],e.clustering=r&&!!o,e},t.prototype.runOneStep=function(t,e,r){var n=r.height,o=r.width,i=r.gravity,a=r.center,s=r.speed,u=r.clustering,d=r.nodeClusterBy,h=r.clusterGravity,c=n*o,l=Math.sqrt(c)/10,f=t.getAllNodes(),g=c/(f.length+1),p=Math.sqrt(g),v={};if(this.applyCalculate(t,v,p,g),u){for(var y in e)e[y].cx=0,e[y].cy=0,e[y].count=0;for(var y in f.forEach((function(t){var r=t.data,n=e[r[d]];E(r.x)&&(n.cx+=r.x),E(r.y)&&(n.cy+=r.y),n.count++})),e)e[y].cx/=e[y].count,e[y].cy/=e[y].count;var m=h||i;f.forEach((function(t,r){var n=t.id,o=t.data;if(E(o.x)&&E(o.y)){var i=e[o[d]],a=Math.sqrt((o.x-i.cx)*(o.x-i.cx)+(o.y-i.cy)*(o.y-i.cy)),s=p*m;v[n].x-=s*(o.x-i.cx)/a,v[n].y-=s*(o.y-i.cy)/a}}))}f.forEach((function(t,e){var r=t.id,n=t.data;if(E(n.x)&&E(n.y)){var o=.01*p*i;v[r].x-=o*(n.x-a[0]),v[r].y-=o*(n.y-a[1])}})),f.forEach((function(e,r){var n=e.id,o=e.data;if(E(o.fx)&&E(o.fy))return o.x=o.fx,void(o.y=o.fy);if(E(o.x)&&E(o.y)){var i=Math.sqrt(v[n].x*v[n].x+v[n].y*v[n].y);if(i>0){var a=Math.min(l*(s/800),i);t.mergeNodeData(n,{x:o.x+v[n].x/i*a,y:o.y+v[n].y/i*a})}}}))},t.prototype.applyCalculate=function(t,e,r,n){this.calRepulsive(t,e,n),this.calAttractive(t,e,r)},t.prototype.calRepulsive=function(t,e,r){var n=t.getAllNodes();n.forEach((function(t,o){var i=t.data,a=t.id;e[a]={x:0,y:0},n.forEach((function(t,n){var s=t.data,u=t.id;if(!(o<=n)&&E(i.x)&&E(s.x)&&E(i.y)&&E(s.y)){var d=i.x-s.x,h=i.y-s.y,c=d*d+h*h;0===c&&(c=1,d=.01,h=.01);var l=r/c,f=d*l,g=h*l;e[a].x+=f,e[a].y+=g,e[u].x-=f,e[u].y-=g}}))}))},t.prototype.calAttractive=function(t,e,r){t.getAllEdges().forEach((function(n){var o=n.source,i=n.target;if(o&&i&&o!==i){var a=t.getNode(o).data,s=t.getNode(i).data;if(E(s.x)&&E(a.x)&&E(s.y)&&E(a.y)){var u=s.x-a.x,d=s.y-a.y,h=Math.sqrt(u*u+d*d)/r,c=u*h,l=d*h;e[o].x+=c,e[o].y+=l,e[i].x-=c,e[i].y-=l}}}))},t}(),zr={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},Cr=function(){function t(t){void 0===t&&(t={}),this.options=t,this.id="grid",this.options=n(n({},zr),t)}return t.prototype.execute=function(t,e){return i(this,void 0,void 0,(function(){return a(this,(function(r){return[2,this.genericGridLayout(!1,t,e)]}))}))},t.prototype.assign=function(t,e){return i(this,void 0,void 0,(function(){return a(this,(function(r){return this.genericGridLayout(!0,t,e),[2]}))}))},t.prototype.genericGridLayout=function(t,e,r){return i(this,void 0,void 0,(function(){var o,i,s,u,d,h,c,l,f,g,v,y,m,w,x,b,M,S,R,_,D,O,P,z,C,L,q,j,F,V,G,W,B,$,U,H,K;return a(this,(function(a){if(o=n(n({},this.options),r),i=o.begin,s=void 0===i?[0,0]:i,u=o.condense,d=o.preventOverlapPadding,h=o.preventOverlap,c=o.rows,l=o.cols,f=o.nodeSpacing,g=o.nodeSize,v=o.width,y=o.height,m=o.position,w=o.sortBy,x=e.getAllNodes(),b=e.getAllEdges(),!(M=null==x?void 0:x.length)||1===M)return[2,I(e,t,s)];if(S=x.map((function(t){return N(t)})),"id"===w||T(w)&&void 0!==S[0].data[w]||(w="degree"),"degree"===w?S.sort((function(t,r){return e.getDegree(r.id,"both")-e.getDegree(t.id,"both")})):"id"===w?S.sort((function(t,e){return E(e.id)&&E(t.id)?e.id-t.id:"".concat(t.id).localeCompare("".concat(e.id))})):S.sort((function(t,e){return e.data[w]-t.data[w]})),R=v||"undefined"==typeof window?v:window.innerWidth,_=y||"undefined"==typeof window?y:window.innerHeight,D=M,O={rows:c,cols:l},null!=c&&null!=l?(O.rows=c,O.cols=l):null!=c&&null==l?(O.rows=c,O.cols=Math.ceil(D/O.rows)):null==c&&null!=l?(O.cols=l,O.rows=Math.ceil(D/O.cols)):(P=Math.sqrt(D*_/R),O.rows=Math.round(P),O.cols=Math.round(R/_*P)),O.rows=Math.max(O.rows,1),O.cols=Math.max(O.cols,1),O.cols*O.rows>D)z=Lr(O),C=qr(O),(z-1)*C>=D?Lr(O,z-1):(C-1)*z>=D&&qr(O,C-1);else for(;O.cols*O.rows<D;)z=Lr(O),((C=qr(O))+1)*z>=D?qr(O,C+1):Lr(O,z+1);for(L=u?0:R/O.cols,q=u?0:_/O.rows,(h||f)&&(j=k(10,f),F=A(30,g,!1),S.forEach((function(t){t.data.x&&t.data.y||(t.data.x=0,t.data.y=0);var r,n,o=e.getNode(t.id),i=F(o)||30;p(i)?(r=i[0],n=i[1]):(r=i,n=i);var a=void 0!==j?j(t):d,s=r+a,u=n+a;L=Math.max(L,s),q=Math.max(q,u)}))),V={},G={row:0,col:0},W={},B=0;B<S.length;B++){if($=S[B],U=void 0,m&&(U=m(e.getNode($.id))),U&&(void 0!==U.row||void 0!==U.col)){if(void 0===(H={row:U.row,col:U.col}).col)for(H.col=0;jr(V,H);)H.col++;else if(void 0===H.row)for(H.row=0;jr(V,H);)H.row++;W[$.id]=H,Fr(V,H)}Gr($,s,L,q,W,O,G,V)}return K={nodes:S,edges:b},t&&S.forEach((function(t){e.mergeNodeData(t.id,{x:t.data.x,y:t.data.y})})),[2,K]}))}))},t}(),Lr=function(t,e){var r,n=t.rows||5,o=t.cols||5;return null==e?r=Math.min(n,o):Math.min(n,o)===t.rows?t.rows=e:t.cols=e,r},qr=function(t,e){var r,n=t.rows||5,o=t.cols||5;return null==e?r=Math.max(n,o):Math.max(n,o)===t.rows?t.rows=e:t.cols=e,r},jr=function(t,e){return t["c-".concat(e.row,"-").concat(e.col)]||!1},Fr=function(t,e){return t["c-".concat(e.row,"-").concat(e.col)]=!0},Vr=function(t,e){var r=t.cols||5;e.col++,e.col>=r&&(e.col=0,e.row++)},Gr=function(t,e,r,n,o,i,a,s){var u,d,h=o[t.id];if(h)u=h.col*r+r/2+e[0],d=h.row*n+n/2+e[1];else{for(;jr(s,a);)Vr(i,a);u=a.col*r+r/2+e[0],d=a.row*n+n/2+e[1],Fr(s,a),Vr(i,a)}t.data.x=u,t.data.y=d};const Wr=Object.prototype.toString;function Br(t){return Wr.call(t).endsWith("Array]")}function $r(t){var e,r=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};if(!Br(t))throw new TypeError("input must be an array");if(0===t.length)throw new TypeError("input must not be empty");if(void 0!==r.output){if(!Br(r.output))throw new TypeError("output option must be an array if specified");e=r.output}else e=new Array(t.length);var n=function(t){var e=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};if(!Br(t))throw new TypeError("input must be an array");if(0===t.length)throw new TypeError("input must not be empty");var r=e.fromIndex,n=void 0===r?0:r,o=e.toIndex,i=void 0===o?t.length:o;if(n<0||n>=t.length||!Number.isInteger(n))throw new Error("fromIndex must be a positive integer smaller than length");if(i<=n||i>t.length||!Number.isInteger(i))throw new Error("toIndex must be an integer greater than fromIndex and at most equal to length");for(var a=t[n],s=n+1;s<i;s++)t[s]<a&&(a=t[s]);return a}(t),o=function(t){var e=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};if(!Br(t))throw new TypeError("input must be an array");if(0===t.length)throw new TypeError("input must not be empty");var r=e.fromIndex,n=void 0===r?0:r,o=e.toIndex,i=void 0===o?t.length:o;if(n<0||n>=t.length||!Number.isInteger(n))throw new Error("fromIndex must be a positive integer smaller than length");if(i<=n||i>t.length||!Number.isInteger(i))throw new Error("toIndex must be an integer greater than fromIndex and at most equal to length");for(var a=t[n],s=n+1;s<i;s++)t[s]>a&&(a=t[s]);return a}(t);if(n===o)throw new RangeError("minimum and maximum input values are equal. Cannot rescale a constant array");var i=r.min,a=void 0===i?r.autoMinMax?n:0:i,s=r.max,u=void 0===s?r.autoMinMax?o:1:s;if(a>=u)throw new RangeError("min option must be smaller than max option");for(var d=(u-a)/(o-n),h=0;h<t.length;h++)e[h]=(t[h]-n)*d+a;return e}const Ur=" ".repeat(2),Hr=" ".repeat(4);function Kr(t,e={}){const{maxRows:r=15,maxColumns:n=10,maxNumSize:o=8,padMinus:i="auto"}=e;return`${t.constructor.name} {\\n${Ur}[\\n${Hr}${function(t,e,r,n,o){const{rows:i,columns:a}=t,s=Math.min(i,e),u=Math.min(a,r),d=[];if("auto"===o){o=!1;t:for(let e=0;e<s;e++)for(let r=0;r<u;r++)if(t.get(e,r)<0){o=!0;break t}}for(let e=0;e<s;e++){let r=[];for(let i=0;i<u;i++)r.push(Yr(t.get(e,i),n,o));d.push(`${r.join(" ")}`)}return u!==a&&(d[d.length-1]+=` ... ${a-r} more columns`),s!==i&&d.push(`... ${i-e} more rows`),d.join(`\\n${Hr}`)}(t,r,n,o,i)}\\n${Ur}]\\n${Ur}rows: ${t.rows}\\n${Ur}columns: ${t.columns}\\n}`}function Yr(t,e,r){return(t>=0&&r?` ${Jr(t,e-1)}`:Jr(t,e)).padEnd(e)}function Jr(t,e){let r=t.toString();if(r.length<=e)return r;let n=t.toFixed(e);if(n.length>e&&(n=t.toFixed(Math.max(0,e-(n.length-e)))),n.length<=e&&!n.startsWith("0.000")&&!n.startsWith("-0.000"))return n;let o=t.toExponential(e);return o.length>e&&(o=t.toExponential(Math.max(0,e-(o.length-e)))),o.slice(0)}function Xr(t,e,r){let n=r?t.rows:t.rows-1;if(e<0||e>n)throw new RangeError("Row index out of range")}function Qr(t,e,r){let n=r?t.columns:t.columns-1;if(e<0||e>n)throw new RangeError("Column index out of range")}function Zr(t,e){if(e.to1DArray&&(e=e.to1DArray()),e.length!==t.columns)throw new RangeError("vector size must be the same as the number of columns");return e}function tn(t,e){if(e.to1DArray&&(e=e.to1DArray()),e.length!==t.rows)throw new RangeError("vector size must be the same as the number of rows");return e}function en(t,e,r,n,o){if(5!==arguments.length)throw new RangeError("expected 4 arguments");if(nn("startRow",e),nn("endRow",r),nn("startColumn",n),nn("endColumn",o),e>r||n>o||e<0||e>=t.rows||r<0||r>=t.rows||n<0||n>=t.columns||o<0||o>=t.columns)throw new RangeError("Submatrix indices are out of range")}function rn(t,e=0){let r=[];for(let n=0;n<t;n++)r.push(e);return r}function nn(t,e){if("number"!=typeof e)throw new TypeError(`${t} must be a number`)}function on(t){if(t.isEmpty())throw new Error("Empty matrix has no elements to index")}class an{static from1DArray(t,e,r){if(t*e!==r.length)throw new RangeError("data length does not match given dimensions");let n=new un(t,e);for(let o=0;o<t;o++)for(let t=0;t<e;t++)n.set(o,t,r[o*e+t]);return n}static rowVector(t){let e=new un(1,t.length);for(let r=0;r<t.length;r++)e.set(0,r,t[r]);return e}static columnVector(t){let e=new un(t.length,1);for(let r=0;r<t.length;r++)e.set(r,0,t[r]);return e}static zeros(t,e){return new un(t,e)}static ones(t,e){return new un(t,e).fill(1)}static rand(t,e,r={}){if("object"!=typeof r)throw new TypeError("options must be an object");const{random:n=Math.random}=r;let o=new un(t,e);for(let r=0;r<t;r++)for(let t=0;t<e;t++)o.set(r,t,n());return o}static randInt(t,e,r={}){if("object"!=typeof r)throw new TypeError("options must be an object");const{min:n=0,max:o=1e3,random:i=Math.random}=r;if(!Number.isInteger(n))throw new TypeError("min must be an integer");if(!Number.isInteger(o))throw new TypeError("max must be an integer");if(n>=o)throw new RangeError("min must be smaller than max");let a=o-n,s=new un(t,e);for(let r=0;r<t;r++)for(let t=0;t<e;t++){let e=n+Math.round(i()*a);s.set(r,t,e)}return s}static eye(t,e,r){void 0===e&&(e=t),void 0===r&&(r=1);let n=Math.min(t,e),o=this.zeros(t,e);for(let t=0;t<n;t++)o.set(t,t,r);return o}static diag(t,e,r){let n=t.length;void 0===e&&(e=n),void 0===r&&(r=e);let o=Math.min(n,e,r),i=this.zeros(e,r);for(let e=0;e<o;e++)i.set(e,e,t[e]);return i}static min(t,e){t=this.checkMatrix(t),e=this.checkMatrix(e);let r=t.rows,n=t.columns,o=new un(r,n);for(let i=0;i<r;i++)for(let r=0;r<n;r++)o.set(i,r,Math.min(t.get(i,r),e.get(i,r)));return o}static max(t,e){t=this.checkMatrix(t),e=this.checkMatrix(e);let r=t.rows,n=t.columns,o=new this(r,n);for(let i=0;i<r;i++)for(let r=0;r<n;r++)o.set(i,r,Math.max(t.get(i,r),e.get(i,r)));return o}static checkMatrix(t){return an.isMatrix(t)?t:new un(t)}static isMatrix(t){return null!=t&&"Matrix"===t.klass}get size(){return this.rows*this.columns}apply(t){if("function"!=typeof t)throw new TypeError("callback must be a function");for(let e=0;e<this.rows;e++)for(let r=0;r<this.columns;r++)t.call(this,e,r);return this}to1DArray(){let t=[];for(let e=0;e<this.rows;e++)for(let r=0;r<this.columns;r++)t.push(this.get(e,r));return t}to2DArray(){let t=[];for(let e=0;e<this.rows;e++){t.push([]);for(let r=0;r<this.columns;r++)t[e].push(this.get(e,r))}return t}toJSON(){return this.to2DArray()}isRowVector(){return 1===this.rows}isColumnVector(){return 1===this.columns}isVector(){return 1===this.rows||1===this.columns}isSquare(){return this.rows===this.columns}isEmpty(){return 0===this.rows||0===this.columns}isSymmetric(){if(this.isSquare()){for(let t=0;t<this.rows;t++)for(let e=0;e<=t;e++)if(this.get(t,e)!==this.get(e,t))return!1;return!0}return!1}isEchelonForm(){let t=0,e=0,r=-1,n=!0,o=!1;for(;t<this.rows&&n;){for(e=0,o=!1;e<this.columns&&!1===o;)0===this.get(t,e)?e++:1===this.get(t,e)&&e>r?(o=!0,r=e):(n=!1,o=!0);t++}return n}isReducedEchelonForm(){let t=0,e=0,r=-1,n=!0,o=!1;for(;t<this.rows&&n;){for(e=0,o=!1;e<this.columns&&!1===o;)0===this.get(t,e)?e++:1===this.get(t,e)&&e>r?(o=!0,r=e):(n=!1,o=!0);for(let r=e+1;r<this.rows;r++)0!==this.get(t,r)&&(n=!1);t++}return n}echelonForm(){let t=this.clone(),e=0,r=0;for(;e<t.rows&&r<t.columns;){let n=e;for(let o=e;o<t.rows;o++)t.get(o,r)>t.get(n,r)&&(n=o);if(0===t.get(n,r))r++;else{t.swapRows(e,n);let o=t.get(e,r);for(let n=r;n<t.columns;n++)t.set(e,n,t.get(e,n)/o);for(let n=e+1;n<t.rows;n++){let o=t.get(n,r)/t.get(e,r);t.set(n,r,0);for(let i=r+1;i<t.columns;i++)t.set(n,i,t.get(n,i)-t.get(e,i)*o)}e++,r++}}return t}reducedEchelonForm(){let t=this.echelonForm(),e=t.columns,r=t.rows,n=r-1;for(;n>=0;)if(0===t.maxRow(n))n--;else{let o=0,i=!1;for(;o<r&&!1===i;)1===t.get(n,o)?i=!0:o++;for(let r=0;r<n;r++){let i=t.get(r,o);for(let a=o;a<e;a++){let e=t.get(r,a)-i*t.get(n,a);t.set(r,a,e)}}n--}return t}set(){throw new Error("set method is unimplemented")}get(){throw new Error("get method is unimplemented")}repeat(t={}){if("object"!=typeof t)throw new TypeError("options must be an object");const{rows:e=1,columns:r=1}=t;if(!Number.isInteger(e)||e<=0)throw new TypeError("rows must be a positive integer");if(!Number.isInteger(r)||r<=0)throw new TypeError("columns must be a positive integer");let n=new un(this.rows*e,this.columns*r);for(let t=0;t<e;t++)for(let e=0;e<r;e++)n.setSubMatrix(this,this.rows*t,this.columns*e);return n}fill(t){for(let e=0;e<this.rows;e++)for(let r=0;r<this.columns;r++)this.set(e,r,t);return this}neg(){return this.mulS(-1)}getRow(t){Xr(this,t);let e=[];for(let r=0;r<this.columns;r++)e.push(this.get(t,r));return e}getRowVector(t){return un.rowVector(this.getRow(t))}setRow(t,e){Xr(this,t),e=Zr(this,e);for(let r=0;r<this.columns;r++)this.set(t,r,e[r]);return this}swapRows(t,e){Xr(this,t),Xr(this,e);for(let r=0;r<this.columns;r++){let n=this.get(t,r);this.set(t,r,this.get(e,r)),this.set(e,r,n)}return this}getColumn(t){Qr(this,t);let e=[];for(let r=0;r<this.rows;r++)e.push(this.get(r,t));return e}getColumnVector(t){return un.columnVector(this.getColumn(t))}setColumn(t,e){Qr(this,t),e=tn(this,e);for(let r=0;r<this.rows;r++)this.set(r,t,e[r]);return this}swapColumns(t,e){Qr(this,t),Qr(this,e);for(let r=0;r<this.rows;r++){let n=this.get(r,t);this.set(r,t,this.get(r,e)),this.set(r,e,n)}return this}addRowVector(t){t=Zr(this,t);for(let e=0;e<this.rows;e++)for(let r=0;r<this.columns;r++)this.set(e,r,this.get(e,r)+t[r]);return this}subRowVector(t){t=Zr(this,t);for(let e=0;e<this.rows;e++)for(let r=0;r<this.columns;r++)this.set(e,r,this.get(e,r)-t[r]);return this}mulRowVector(t){t=Zr(this,t);for(let e=0;e<this.rows;e++)for(let r=0;r<this.columns;r++)this.set(e,r,this.get(e,r)*t[r]);return this}divRowVector(t){t=Zr(this,t);for(let e=0;e<this.rows;e++)for(let r=0;r<this.columns;r++)this.set(e,r,this.get(e,r)/t[r]);return this}addColumnVector(t){t=tn(this,t);for(let e=0;e<this.rows;e++)for(let r=0;r<this.columns;r++)this.set(e,r,this.get(e,r)+t[e]);return this}subColumnVector(t){t=tn(this,t);for(let e=0;e<this.rows;e++)for(let r=0;r<this.columns;r++)this.set(e,r,this.get(e,r)-t[e]);return this}mulColumnVector(t){t=tn(this,t);for(let e=0;e<this.rows;e++)for(let r=0;r<this.columns;r++)this.set(e,r,this.get(e,r)*t[e]);return this}divColumnVector(t){t=tn(this,t);for(let e=0;e<this.rows;e++)for(let r=0;r<this.columns;r++)this.set(e,r,this.get(e,r)/t[e]);return this}mulRow(t,e){Xr(this,t);for(let r=0;r<this.columns;r++)this.set(t,r,this.get(t,r)*e);return this}mulColumn(t,e){Qr(this,t);for(let r=0;r<this.rows;r++)this.set(r,t,this.get(r,t)*e);return this}max(t){if(this.isEmpty())return NaN;switch(t){case"row":{const t=new Array(this.rows).fill(Number.NEGATIVE_INFINITY);for(let e=0;e<this.rows;e++)for(let r=0;r<this.columns;r++)this.get(e,r)>t[e]&&(t[e]=this.get(e,r));return t}case"column":{const t=new Array(this.columns).fill(Number.NEGATIVE_INFINITY);for(let e=0;e<this.rows;e++)for(let r=0;r<this.columns;r++)this.get(e,r)>t[r]&&(t[r]=this.get(e,r));return t}case void 0:{let t=this.get(0,0);for(let e=0;e<this.rows;e++)for(let r=0;r<this.columns;r++)this.get(e,r)>t&&(t=this.get(e,r));return t}default:throw new Error(`invalid option: ${t}`)}}maxIndex(){on(this);let t=this.get(0,0),e=[0,0];for(let r=0;r<this.rows;r++)for(let n=0;n<this.columns;n++)this.get(r,n)>t&&(t=this.get(r,n),e[0]=r,e[1]=n);return e}min(t){if(this.isEmpty())return NaN;switch(t){case"row":{const t=new Array(this.rows).fill(Number.POSITIVE_INFINITY);for(let e=0;e<this.rows;e++)for(let r=0;r<this.columns;r++)this.get(e,r)<t[e]&&(t[e]=this.get(e,r));return t}case"column":{const t=new Array(this.columns).fill(Number.POSITIVE_INFINITY);for(let e=0;e<this.rows;e++)for(let r=0;r<this.columns;r++)this.get(e,r)<t[r]&&(t[r]=this.get(e,r));return t}case void 0:{let t=this.get(0,0);for(let e=0;e<this.rows;e++)for(let r=0;r<this.columns;r++)this.get(e,r)<t&&(t=this.get(e,r));return t}default:throw new Error(`invalid option: ${t}`)}}minIndex(){on(this);let t=this.get(0,0),e=[0,0];for(let r=0;r<this.rows;r++)for(let n=0;n<this.columns;n++)this.get(r,n)<t&&(t=this.get(r,n),e[0]=r,e[1]=n);return e}maxRow(t){if(Xr(this,t),this.isEmpty())return NaN;let e=this.get(t,0);for(let r=1;r<this.columns;r++)this.get(t,r)>e&&(e=this.get(t,r));return e}maxRowIndex(t){Xr(this,t),on(this);let e=this.get(t,0),r=[t,0];for(let n=1;n<this.columns;n++)this.get(t,n)>e&&(e=this.get(t,n),r[1]=n);return r}minRow(t){if(Xr(this,t),this.isEmpty())return NaN;let e=this.get(t,0);for(let r=1;r<this.columns;r++)this.get(t,r)<e&&(e=this.get(t,r));return e}minRowIndex(t){Xr(this,t),on(this);let e=this.get(t,0),r=[t,0];for(let n=1;n<this.columns;n++)this.get(t,n)<e&&(e=this.get(t,n),r[1]=n);return r}maxColumn(t){if(Qr(this,t),this.isEmpty())return NaN;let e=this.get(0,t);for(let r=1;r<this.rows;r++)this.get(r,t)>e&&(e=this.get(r,t));return e}maxColumnIndex(t){Qr(this,t),on(this);let e=this.get(0,t),r=[0,t];for(let n=1;n<this.rows;n++)this.get(n,t)>e&&(e=this.get(n,t),r[0]=n);return r}minColumn(t){if(Qr(this,t),this.isEmpty())return NaN;let e=this.get(0,t);for(let r=1;r<this.rows;r++)this.get(r,t)<e&&(e=this.get(r,t));return e}minColumnIndex(t){Qr(this,t),on(this);let e=this.get(0,t),r=[0,t];for(let n=1;n<this.rows;n++)this.get(n,t)<e&&(e=this.get(n,t),r[0]=n);return r}diag(){let t=Math.min(this.rows,this.columns),e=[];for(let r=0;r<t;r++)e.push(this.get(r,r));return e}norm(t="frobenius"){let e=0;if("max"===t)return this.max();if("frobenius"===t){for(let t=0;t<this.rows;t++)for(let r=0;r<this.columns;r++)e+=this.get(t,r)*this.get(t,r);return Math.sqrt(e)}throw new RangeError(`unknown norm type: ${t}`)}cumulativeSum(){let t=0;for(let e=0;e<this.rows;e++)for(let r=0;r<this.columns;r++)t+=this.get(e,r),this.set(e,r,t);return this}dot(t){an.isMatrix(t)&&(t=t.to1DArray());let e=this.to1DArray();if(e.length!==t.length)throw new RangeError("vectors do not have the same size");let r=0;for(let n=0;n<e.length;n++)r+=e[n]*t[n];return r}mmul(t){t=un.checkMatrix(t);let e=this.rows,r=this.columns,n=t.columns,o=new un(e,n),i=new Float64Array(r);for(let a=0;a<n;a++){for(let e=0;e<r;e++)i[e]=t.get(e,a);for(let t=0;t<e;t++){let e=0;for(let n=0;n<r;n++)e+=this.get(t,n)*i[n];o.set(t,a,e)}}return o}strassen2x2(t){t=un.checkMatrix(t);let e=new un(2,2);const r=this.get(0,0),n=t.get(0,0),o=this.get(0,1),i=t.get(0,1),a=this.get(1,0),s=t.get(1,0),u=this.get(1,1),d=t.get(1,1),h=(r+u)*(n+d),c=(a+u)*n,l=r*(i-d),f=u*(s-n),g=(r+o)*d,p=h+f-g+(o-u)*(s+d),v=l+g,y=c+f,m=h-c+l+(a-r)*(n+i);return e.set(0,0,p),e.set(0,1,v),e.set(1,0,y),e.set(1,1,m),e}strassen3x3(t){t=un.checkMatrix(t);let e=new un(3,3);const r=this.get(0,0),n=this.get(0,1),o=this.get(0,2),i=this.get(1,0),a=this.get(1,1),s=this.get(1,2),u=this.get(2,0),d=this.get(2,1),h=this.get(2,2),c=t.get(0,0),l=t.get(0,1),f=t.get(0,2),g=t.get(1,0),p=t.get(1,1),v=t.get(1,2),y=t.get(2,0),m=t.get(2,1),w=t.get(2,2),x=(r-i)*(-l+p),E=(-r+i+a)*(c-l+p),b=(i+a)*(-c+l),N=r*c,M=(-r+u+d)*(c-f+v),S=(-r+u)*(f-v),k=(u+d)*(-c+f),A=(-o+d+h)*(p+y-m),R=(o-h)*(p-m),I=o*y,_=(d+h)*(-y+m),D=(-o+a+s)*(v+y-w),O=(o-s)*(v-w),P=(a+s)*(-y+w),T=N+I+n*g,z=(r+n+o-i-a-d-h)*p+E+b+N+A+I+_,C=N+M+k+(r+n+o-a-s-u-d)*v+I+D+P,L=x+a*(-c+l+g-p-v-y+w)+E+N+I+D+O,q=x+E+b+N+s*m,j=I+D+O+P+i*f,F=N+M+S+d*(-c+f+g-p-v-y+m)+A+R+I,V=A+R+I+_+u*l,G=N+M+S+k+h*w;return e.set(0,0,T),e.set(0,1,z),e.set(0,2,C),e.set(1,0,L),e.set(1,1,q),e.set(1,2,j),e.set(2,0,F),e.set(2,1,V),e.set(2,2,G),e}mmulStrassen(t){t=un.checkMatrix(t);let e=this.clone(),r=e.rows,n=e.columns,o=t.rows,i=t.columns;function a(t,e,r){let n=t.rows,o=t.columns;if(n===e&&o===r)return t;{let n=an.zeros(e,r);return n=n.setSubMatrix(t,0,0),n}}n!==o&&console.warn(`Multiplying ${r} x ${n} and ${o} x ${i} matrix: dimensions do not match.`);let s=Math.max(r,o),u=Math.max(n,i);return e=a(e,s,u),function t(e,r,n,o){if(n<=512||o<=512)return e.mmul(r);n%2==1&&o%2==1?(e=a(e,n+1,o+1),r=a(r,n+1,o+1)):n%2==1?(e=a(e,n+1,o),r=a(r,n+1,o)):o%2==1&&(e=a(e,n,o+1),r=a(r,n,o+1));let i=parseInt(e.rows/2,10),s=parseInt(e.columns/2,10),u=e.subMatrix(0,i-1,0,s-1),d=r.subMatrix(0,i-1,0,s-1),h=e.subMatrix(0,i-1,s,e.columns-1),c=r.subMatrix(0,i-1,s,r.columns-1),l=e.subMatrix(i,e.rows-1,0,s-1),f=r.subMatrix(i,r.rows-1,0,s-1),g=e.subMatrix(i,e.rows-1,s,e.columns-1),p=r.subMatrix(i,r.rows-1,s,r.columns-1),v=t(an.add(u,g),an.add(d,p),i,s),y=t(an.add(l,g),d,i,s),m=t(u,an.sub(c,p),i,s),w=t(g,an.sub(f,d),i,s),x=t(an.add(u,h),p,i,s),E=t(an.sub(l,u),an.add(d,c),i,s),b=t(an.sub(h,g),an.add(f,p),i,s),N=an.add(v,w);N.sub(x),N.add(b);let M=an.add(m,x),S=an.add(y,w),k=an.sub(v,y);k.add(m),k.add(E);let A=an.zeros(2*N.rows,2*N.columns);return A=A.setSubMatrix(N,0,0),A=A.setSubMatrix(M,N.rows,0),A=A.setSubMatrix(S,0,N.columns),A=A.setSubMatrix(k,N.rows,N.columns),A.subMatrix(0,n-1,0,o-1)}(e,t=a(t,s,u),s,u)}scaleRows(t={}){if("object"!=typeof t)throw new TypeError("options must be an object");const{min:e=0,max:r=1}=t;if(!Number.isFinite(e))throw new TypeError("min must be a number");if(!Number.isFinite(r))throw new TypeError("max must be a number");if(e>=r)throw new RangeError("min must be smaller than max");let n=new un(this.rows,this.columns);for(let t=0;t<this.rows;t++){const o=this.getRow(t);o.length>0&&$r(o,{min:e,max:r,output:o}),n.setRow(t,o)}return n}scaleColumns(t={}){if("object"!=typeof t)throw new TypeError("options must be an object");const{min:e=0,max:r=1}=t;if(!Number.isFinite(e))throw new TypeError("min must be a number");if(!Number.isFinite(r))throw new TypeError("max must be a number");if(e>=r)throw new RangeError("min must be smaller than max");let n=new un(this.rows,this.columns);for(let t=0;t<this.columns;t++){const o=this.getColumn(t);o.length&&$r(o,{min:e,max:r,output:o}),n.setColumn(t,o)}return n}flipRows(){const t=Math.ceil(this.columns/2);for(let e=0;e<this.rows;e++)for(let r=0;r<t;r++){let t=this.get(e,r),n=this.get(e,this.columns-1-r);this.set(e,r,n),this.set(e,this.columns-1-r,t)}return this}flipColumns(){const t=Math.ceil(this.rows/2);for(let e=0;e<this.columns;e++)for(let r=0;r<t;r++){let t=this.get(r,e),n=this.get(this.rows-1-r,e);this.set(r,e,n),this.set(this.rows-1-r,e,t)}return this}kroneckerProduct(t){t=un.checkMatrix(t);let e=this.rows,r=this.columns,n=t.rows,o=t.columns,i=new un(e*n,r*o);for(let a=0;a<e;a++)for(let e=0;e<r;e++)for(let r=0;r<n;r++)for(let s=0;s<o;s++)i.set(n*a+r,o*e+s,this.get(a,e)*t.get(r,s));return i}kroneckerSum(t){if(t=un.checkMatrix(t),!this.isSquare()||!t.isSquare())throw new Error("Kronecker Sum needs two Square Matrices");let e=this.rows,r=t.rows,n=this.kroneckerProduct(un.eye(r,r)),o=un.eye(e,e).kroneckerProduct(t);return n.add(o)}transpose(){let t=new un(this.columns,this.rows);for(let e=0;e<this.rows;e++)for(let r=0;r<this.columns;r++)t.set(r,e,this.get(e,r));return t}sortRows(t=sn){for(let e=0;e<this.rows;e++)this.setRow(e,this.getRow(e).sort(t));return this}sortColumns(t=sn){for(let e=0;e<this.columns;e++)this.setColumn(e,this.getColumn(e).sort(t));return this}subMatrix(t,e,r,n){en(this,t,e,r,n);let o=new un(e-t+1,n-r+1);for(let i=t;i<=e;i++)for(let e=r;e<=n;e++)o.set(i-t,e-r,this.get(i,e));return o}subMatrixRow(t,e,r){if(void 0===e&&(e=0),void 0===r&&(r=this.columns-1),e>r||e<0||e>=this.columns||r<0||r>=this.columns)throw new RangeError("Argument out of range");let n=new un(t.length,r-e+1);for(let o=0;o<t.length;o++)for(let i=e;i<=r;i++){if(t[o]<0||t[o]>=this.rows)throw new RangeError(`Row index out of range: ${t[o]}`);n.set(o,i-e,this.get(t[o],i))}return n}subMatrixColumn(t,e,r){if(void 0===e&&(e=0),void 0===r&&(r=this.rows-1),e>r||e<0||e>=this.rows||r<0||r>=this.rows)throw new RangeError("Argument out of range");let n=new un(r-e+1,t.length);for(let o=0;o<t.length;o++)for(let i=e;i<=r;i++){if(t[o]<0||t[o]>=this.columns)throw new RangeError(`Column index out of range: ${t[o]}`);n.set(i-e,o,this.get(i,t[o]))}return n}setSubMatrix(t,e,r){if((t=un.checkMatrix(t)).isEmpty())return this;en(this,e,e+t.rows-1,r,r+t.columns-1);for(let n=0;n<t.rows;n++)for(let o=0;o<t.columns;o++)this.set(e+n,r+o,t.get(n,o));return this}selection(t,e){!function(t,e){if(!Br(e))throw new TypeError("row indices must be an array");for(let r=0;r<e.length;r++)if(e[r]<0||e[r]>=t.rows)throw new RangeError("row indices are out of range")}(this,t),function(t,e){if(!Br(e))throw new TypeError("column indices must be an array");for(let r=0;r<e.length;r++)if(e[r]<0||e[r]>=t.columns)throw new RangeError("column indices are out of range")}(this,e);let r=new un(t.length,e.length);for(let n=0;n<t.length;n++){let o=t[n];for(let t=0;t<e.length;t++){let i=e[t];r.set(n,t,this.get(o,i))}}return r}trace(){let t=Math.min(this.rows,this.columns),e=0;for(let r=0;r<t;r++)e+=this.get(r,r);return e}clone(){let t=new un(this.rows,this.columns);for(let e=0;e<this.rows;e++)for(let r=0;r<this.columns;r++)t.set(e,r,this.get(e,r));return t}sum(t){switch(t){case"row":return function(t){let e=rn(t.rows);for(let r=0;r<t.rows;++r)for(let n=0;n<t.columns;++n)e[r]+=t.get(r,n);return e}(this);case"column":return function(t){let e=rn(t.columns);for(let r=0;r<t.rows;++r)for(let n=0;n<t.columns;++n)e[n]+=t.get(r,n);return e}(this);case void 0:return function(t){let e=0;for(let r=0;r<t.rows;r++)for(let n=0;n<t.columns;n++)e+=t.get(r,n);return e}(this);default:throw new Error(`invalid option: ${t}`)}}product(t){switch(t){case"row":return function(t){let e=rn(t.rows,1);for(let r=0;r<t.rows;++r)for(let n=0;n<t.columns;++n)e[r]*=t.get(r,n);return e}(this);case"column":return function(t){let e=rn(t.columns,1);for(let r=0;r<t.rows;++r)for(let n=0;n<t.columns;++n)e[n]*=t.get(r,n);return e}(this);case void 0:return function(t){let e=1;for(let r=0;r<t.rows;r++)for(let n=0;n<t.columns;n++)e*=t.get(r,n);return e}(this);default:throw new Error(`invalid option: ${t}`)}}mean(t){const e=this.sum(t);switch(t){case"row":for(let t=0;t<this.rows;t++)e[t]/=this.columns;return e;case"column":for(let t=0;t<this.columns;t++)e[t]/=this.rows;return e;case void 0:return e/this.size;default:throw new Error(`invalid option: ${t}`)}}variance(t,e={}){if("object"==typeof t&&(e=t,t=void 0),"object"!=typeof e)throw new TypeError("options must be an object");const{unbiased:r=!0,mean:n=this.mean(t)}=e;if("boolean"!=typeof r)throw new TypeError("unbiased must be a boolean");switch(t){case"row":if(!Br(n))throw new TypeError("mean must be an array");return function(t,e,r){const n=t.rows,o=t.columns,i=[];for(let a=0;a<n;a++){let n=0,s=0,u=0;for(let e=0;e<o;e++)u=t.get(a,e)-r[a],n+=u,s+=u*u;e?i.push((s-n*n/o)/(o-1)):i.push((s-n*n/o)/o)}return i}(this,r,n);case"column":if(!Br(n))throw new TypeError("mean must be an array");return function(t,e,r){const n=t.rows,o=t.columns,i=[];for(let a=0;a<o;a++){let o=0,s=0,u=0;for(let e=0;e<n;e++)u=t.get(e,a)-r[a],o+=u,s+=u*u;e?i.push((s-o*o/n)/(n-1)):i.push((s-o*o/n)/n)}return i}(this,r,n);case void 0:if("number"!=typeof n)throw new TypeError("mean must be a number");return function(t,e,r){const n=t.rows,o=t.columns,i=n*o;let a=0,s=0,u=0;for(let e=0;e<n;e++)for(let n=0;n<o;n++)u=t.get(e,n)-r,a+=u,s+=u*u;return e?(s-a*a/i)/(i-1):(s-a*a/i)/i}(this,r,n);default:throw new Error(`invalid option: ${t}`)}}standardDeviation(t,e){"object"==typeof t&&(e=t,t=void 0);const r=this.variance(t,e);if(void 0===t)return Math.sqrt(r);for(let t=0;t<r.length;t++)r[t]=Math.sqrt(r[t]);return r}center(t,e={}){if("object"==typeof t&&(e=t,t=void 0),"object"!=typeof e)throw new TypeError("options must be an object");const{center:r=this.mean(t)}=e;switch(t){case"row":if(!Br(r))throw new TypeError("center must be an array");return function(t,e){for(let r=0;r<t.rows;r++)for(let n=0;n<t.columns;n++)t.set(r,n,t.get(r,n)-e[r])}(this,r),this;case"column":if(!Br(r))throw new TypeError("center must be an array");return function(t,e){for(let r=0;r<t.rows;r++)for(let n=0;n<t.columns;n++)t.set(r,n,t.get(r,n)-e[n])}(this,r),this;case void 0:if("number"!=typeof r)throw new TypeError("center must be a number");return function(t,e){for(let r=0;r<t.rows;r++)for(let n=0;n<t.columns;n++)t.set(r,n,t.get(r,n)-e)}(this,r),this;default:throw new Error(`invalid option: ${t}`)}}scale(t,e={}){if("object"==typeof t&&(e=t,t=void 0),"object"!=typeof e)throw new TypeError("options must be an object");let r=e.scale;switch(t){case"row":if(void 0===r)r=function(t){const e=[];for(let r=0;r<t.rows;r++){let n=0;for(let e=0;e<t.columns;e++)n+=Math.pow(t.get(r,e),2)/(t.columns-1);e.push(Math.sqrt(n))}return e}(this);else if(!Br(r))throw new TypeError("scale must be an array");return function(t,e){for(let r=0;r<t.rows;r++)for(let n=0;n<t.columns;n++)t.set(r,n,t.get(r,n)/e[r])}(this,r),this;case"column":if(void 0===r)r=function(t){const e=[];for(let r=0;r<t.columns;r++){let n=0;for(let e=0;e<t.rows;e++)n+=Math.pow(t.get(e,r),2)/(t.rows-1);e.push(Math.sqrt(n))}return e}(this);else if(!Br(r))throw new TypeError("scale must be an array");return function(t,e){for(let r=0;r<t.rows;r++)for(let n=0;n<t.columns;n++)t.set(r,n,t.get(r,n)/e[n])}(this,r),this;case void 0:if(void 0===r)r=function(t){const e=t.size-1;let r=0;for(let n=0;n<t.columns;n++)for(let o=0;o<t.rows;o++)r+=Math.pow(t.get(o,n),2)/e;return Math.sqrt(r)}(this);else if("number"!=typeof r)throw new TypeError("scale must be a number");return function(t,e){for(let r=0;r<t.rows;r++)for(let n=0;n<t.columns;n++)t.set(r,n,t.get(r,n)/e)}(this,r),this;default:throw new Error(`invalid option: ${t}`)}}toString(t){return Kr(this,t)}}function sn(t,e){return t-e}an.prototype.klass="Matrix","undefined"!=typeof Symbol&&(an.prototype[Symbol.for("nodejs.util.inspect.custom")]=function(){return Kr(this)}),an.random=an.rand,an.randomInt=an.randInt,an.diagonal=an.diag,an.prototype.diagonal=an.prototype.diag,an.identity=an.eye,an.prototype.negate=an.prototype.neg,an.prototype.tensorProduct=an.prototype.kroneckerProduct;class un extends an{constructor(t,e){if(super(),un.isMatrix(t))return t.clone();if(Number.isInteger(t)&&t>=0){if(this.data=[],!(Number.isInteger(e)&&e>=0))throw new TypeError("nColumns must be a positive integer");for(let r=0;r<t;r++)this.data.push(new Float64Array(e))}else{if(!Br(t))throw new TypeError("First argument must be a positive number or an array");{const r=t;if("number"!=typeof(e=(t=r.length)?r[0].length:0))throw new TypeError("Data must be a 2D array with at least one element");this.data=[];for(let n=0;n<t;n++){if(r[n].length!==e)throw new RangeError("Inconsistent array dimensions");if(!r[n].every((t=>"number"==typeof t)))throw new TypeError("Input data contains non-numeric values");this.data.push(Float64Array.from(r[n]))}}}this.rows=t,this.columns=e}set(t,e,r){return this.data[t][e]=r,this}get(t,e){return this.data[t][e]}removeRow(t){return Xr(this,t),this.data.splice(t,1),this.rows-=1,this}addRow(t,e){return void 0===e&&(e=t,t=this.rows),Xr(this,t,!0),e=Float64Array.from(Zr(this,e)),this.data.splice(t,0,e),this.rows+=1,this}removeColumn(t){Qr(this,t);for(let e=0;e<this.rows;e++){const r=new Float64Array(this.columns-1);for(let n=0;n<t;n++)r[n]=this.data[e][n];for(let n=t+1;n<this.columns;n++)r[n-1]=this.data[e][n];this.data[e]=r}return this.columns-=1,this}addColumn(t,e){void 0===e&&(e=t,t=this.columns),Qr(this,t,!0),e=tn(this,e);for(let r=0;r<this.rows;r++){const n=new Float64Array(this.columns+1);let o=0;for(;o<t;o++)n[o]=this.data[r][o];for(n[o++]=e[r];o<this.columns+1;o++)n[o]=this.data[r][o-1];this.data[r]=n}return this.columns+=1,this}}!function(t,e){t.prototype.add=function(t){return"number"==typeof t?this.addS(t):this.addM(t)},t.prototype.addS=function(t){for(let e=0;e<this.rows;e++)for(let r=0;r<this.columns;r++)this.set(e,r,this.get(e,r)+t);return this},t.prototype.addM=function(t){if(t=e.checkMatrix(t),this.rows!==t.rows||this.columns!==t.columns)throw new RangeError("Matrices dimensions must be equal");for(let e=0;e<this.rows;e++)for(let r=0;r<this.columns;r++)this.set(e,r,this.get(e,r)+t.get(e,r));return this},t.add=function(t,r){return new e(t).add(r)},t.prototype.sub=function(t){return"number"==typeof t?this.subS(t):this.subM(t)},t.prototype.subS=function(t){for(let e=0;e<this.rows;e++)for(let r=0;r<this.columns;r++)this.set(e,r,this.get(e,r)-t);return this},t.prototype.subM=function(t){if(t=e.checkMatrix(t),this.rows!==t.rows||this.columns!==t.columns)throw new RangeError("Matrices dimensions must be equal");for(let e=0;e<this.rows;e++)for(let r=0;r<this.columns;r++)this.set(e,r,this.get(e,r)-t.get(e,r));return this},t.sub=function(t,r){return new e(t).sub(r)},t.prototype.subtract=t.prototype.sub,t.prototype.subtractS=t.prototype.subS,t.prototype.subtractM=t.prototype.subM,t.subtract=t.sub,t.prototype.mul=function(t){return"number"==typeof t?this.mulS(t):this.mulM(t)},t.prototype.mulS=function(t){for(let e=0;e<this.rows;e++)for(let r=0;r<this.columns;r++)this.set(e,r,this.get(e,r)*t);return this},t.prototype.mulM=function(t){if(t=e.checkMatrix(t),this.rows!==t.rows||this.columns!==t.columns)throw new RangeError("Matrices dimensions must be equal");for(let e=0;e<this.rows;e++)for(let r=0;r<this.columns;r++)this.set(e,r,this.get(e,r)*t.get(e,r));return this},t.mul=function(t,r){return new e(t).mul(r)},t.prototype.multiply=t.prototype.mul,t.prototype.multiplyS=t.prototype.mulS,t.prototype.multiplyM=t.prototype.mulM,t.multiply=t.mul,t.prototype.div=function(t){return"number"==typeof t?this.divS(t):this.divM(t)},t.prototype.divS=function(t){for(let e=0;e<this.rows;e++)for(let r=0;r<this.columns;r++)this.set(e,r,this.get(e,r)/t);return this},t.prototype.divM=function(t){if(t=e.checkMatrix(t),this.rows!==t.rows||this.columns!==t.columns)throw new RangeError("Matrices dimensions must be equal");for(let e=0;e<this.rows;e++)for(let r=0;r<this.columns;r++)this.set(e,r,this.get(e,r)/t.get(e,r));return this},t.div=function(t,r){return new e(t).div(r)},t.prototype.divide=t.prototype.div,t.prototype.divideS=t.prototype.divS,t.prototype.divideM=t.prototype.divM,t.divide=t.div,t.prototype.mod=function(t){return"number"==typeof t?this.modS(t):this.modM(t)},t.prototype.modS=function(t){for(let e=0;e<this.rows;e++)for(let r=0;r<this.columns;r++)this.set(e,r,this.get(e,r)%t);return this},t.prototype.modM=function(t){if(t=e.checkMatrix(t),this.rows!==t.rows||this.columns!==t.columns)throw new RangeError("Matrices dimensions must be equal");for(let e=0;e<this.rows;e++)for(let r=0;r<this.columns;r++)this.set(e,r,this.get(e,r)%t.get(e,r));return this},t.mod=function(t,r){return new e(t).mod(r)},t.prototype.modulus=t.prototype.mod,t.prototype.modulusS=t.prototype.modS,t.prototype.modulusM=t.prototype.modM,t.modulus=t.mod,t.prototype.and=function(t){return"number"==typeof t?this.andS(t):this.andM(t)},t.prototype.andS=function(t){for(let e=0;e<this.rows;e++)for(let r=0;r<this.columns;r++)this.set(e,r,this.get(e,r)&t);return this},t.prototype.andM=function(t){if(t=e.checkMatrix(t),this.rows!==t.rows||this.columns!==t.columns)throw new RangeError("Matrices dimensions must be equal");for(let e=0;e<this.rows;e++)for(let r=0;r<this.columns;r++)this.set(e,r,this.get(e,r)&t.get(e,r));return this},t.and=function(t,r){return new e(t).and(r)},t.prototype.or=function(t){return"number"==typeof t?this.orS(t):this.orM(t)},t.prototype.orS=function(t){for(let e=0;e<this.rows;e++)for(let r=0;r<this.columns;r++)this.set(e,r,this.get(e,r)|t);return this},t.prototype.orM=function(t){if(t=e.checkMatrix(t),this.rows!==t.rows||this.columns!==t.columns)throw new RangeError("Matrices dimensions must be equal");for(let e=0;e<this.rows;e++)for(let r=0;r<this.columns;r++)this.set(e,r,this.get(e,r)|t.get(e,r));return this},t.or=function(t,r){return new e(t).or(r)},t.prototype.xor=function(t){return"number"==typeof t?this.xorS(t):this.xorM(t)},t.prototype.xorS=function(t){for(let e=0;e<this.rows;e++)for(let r=0;r<this.columns;r++)this.set(e,r,this.get(e,r)^t);return this},t.prototype.xorM=function(t){if(t=e.checkMatrix(t),this.rows!==t.rows||this.columns!==t.columns)throw new RangeError("Matrices dimensions must be equal");for(let e=0;e<this.rows;e++)for(let r=0;r<this.columns;r++)this.set(e,r,this.get(e,r)^t.get(e,r));return this},t.xor=function(t,r){return new e(t).xor(r)},t.prototype.leftShift=function(t){return"number"==typeof t?this.leftShiftS(t):this.leftShiftM(t)},t.prototype.leftShiftS=function(t){for(let e=0;e<this.rows;e++)for(let r=0;r<this.columns;r++)this.set(e,r,this.get(e,r)<<t);return this},t.prototype.leftShiftM=function(t){if(t=e.checkMatrix(t),this.rows!==t.rows||this.columns!==t.columns)throw new RangeError("Matrices dimensions must be equal");for(let e=0;e<this.rows;e++)for(let r=0;r<this.columns;r++)this.set(e,r,this.get(e,r)<<t.get(e,r));return this},t.leftShift=function(t,r){return new e(t).leftShift(r)},t.prototype.signPropagatingRightShift=function(t){return"number"==typeof t?this.signPropagatingRightShiftS(t):this.signPropagatingRightShiftM(t)},t.prototype.signPropagatingRightShiftS=function(t){for(let e=0;e<this.rows;e++)for(let r=0;r<this.columns;r++)this.set(e,r,this.get(e,r)>>t);return this},t.prototype.signPropagatingRightShiftM=function(t){if(t=e.checkMatrix(t),this.rows!==t.rows||this.columns!==t.columns)throw new RangeError("Matrices dimensions must be equal");for(let e=0;e<this.rows;e++)for(let r=0;r<this.columns;r++)this.set(e,r,this.get(e,r)>>t.get(e,r));return this},t.signPropagatingRightShift=function(t,r){return new e(t).signPropagatingRightShift(r)},t.prototype.rightShift=function(t){return"number"==typeof t?this.rightShiftS(t):this.rightShiftM(t)},t.prototype.rightShiftS=function(t){for(let e=0;e<this.rows;e++)for(let r=0;r<this.columns;r++)this.set(e,r,this.get(e,r)>>>t);return this},t.prototype.rightShiftM=function(t){if(t=e.checkMatrix(t),this.rows!==t.rows||this.columns!==t.columns)throw new RangeError("Matrices dimensions must be equal");for(let e=0;e<this.rows;e++)for(let r=0;r<this.columns;r++)this.set(e,r,this.get(e,r)>>>t.get(e,r));return this},t.rightShift=function(t,r){return new e(t).rightShift(r)},t.prototype.zeroFillRightShift=t.prototype.rightShift,t.prototype.zeroFillRightShiftS=t.prototype.rightShiftS,t.prototype.zeroFillRightShiftM=t.prototype.rightShiftM,t.zeroFillRightShift=t.rightShift,t.prototype.not=function(){for(let t=0;t<this.rows;t++)for(let e=0;e<this.columns;e++)this.set(t,e,~this.get(t,e));return this},t.not=function(t){return new e(t).not()},t.prototype.abs=function(){for(let t=0;t<this.rows;t++)for(let e=0;e<this.columns;e++)this.set(t,e,Math.abs(this.get(t,e)));return this},t.abs=function(t){return new e(t).abs()},t.prototype.acos=function(){for(let t=0;t<this.rows;t++)for(let e=0;e<this.columns;e++)this.set(t,e,Math.acos(this.get(t,e)));return this},t.acos=function(t){return new e(t).acos()},t.prototype.acosh=function(){for(let t=0;t<this.rows;t++)for(let e=0;e<this.columns;e++)this.set(t,e,Math.acosh(this.get(t,e)));return this},t.acosh=function(t){return new e(t).acosh()},t.prototype.asin=function(){for(let t=0;t<this.rows;t++)for(let e=0;e<this.columns;e++)this.set(t,e,Math.asin(this.get(t,e)));return this},t.asin=function(t){return new e(t).asin()},t.prototype.asinh=function(){for(let t=0;t<this.rows;t++)for(let e=0;e<this.columns;e++)this.set(t,e,Math.asinh(this.get(t,e)));return this},t.asinh=function(t){return new e(t).asinh()},t.prototype.atan=function(){for(let t=0;t<this.rows;t++)for(let e=0;e<this.columns;e++)this.set(t,e,Math.atan(this.get(t,e)));return this},t.atan=function(t){return new e(t).atan()},t.prototype.atanh=function(){for(let t=0;t<this.rows;t++)for(let e=0;e<this.columns;e++)this.set(t,e,Math.atanh(this.get(t,e)));return this},t.atanh=function(t){return new e(t).atanh()},t.prototype.cbrt=function(){for(let t=0;t<this.rows;t++)for(let e=0;e<this.columns;e++)this.set(t,e,Math.cbrt(this.get(t,e)));return this},t.cbrt=function(t){return new e(t).cbrt()},t.prototype.ceil=function(){for(let t=0;t<this.rows;t++)for(let e=0;e<this.columns;e++)this.set(t,e,Math.ceil(this.get(t,e)));return this},t.ceil=function(t){return new e(t).ceil()},t.prototype.clz32=function(){for(let t=0;t<this.rows;t++)for(let e=0;e<this.columns;e++)this.set(t,e,Math.clz32(this.get(t,e)));return this},t.clz32=function(t){return new e(t).clz32()},t.prototype.cos=function(){for(let t=0;t<this.rows;t++)for(let e=0;e<this.columns;e++)this.set(t,e,Math.cos(this.get(t,e)));return this},t.cos=function(t){return new e(t).cos()},t.prototype.cosh=function(){for(let t=0;t<this.rows;t++)for(let e=0;e<this.columns;e++)this.set(t,e,Math.cosh(this.get(t,e)));return this},t.cosh=function(t){return new e(t).cosh()},t.prototype.exp=function(){for(let t=0;t<this.rows;t++)for(let e=0;e<this.columns;e++)this.set(t,e,Math.exp(this.get(t,e)));return this},t.exp=function(t){return new e(t).exp()},t.prototype.expm1=function(){for(let t=0;t<this.rows;t++)for(let e=0;e<this.columns;e++)this.set(t,e,Math.expm1(this.get(t,e)));return this},t.expm1=function(t){return new e(t).expm1()},t.prototype.floor=function(){for(let t=0;t<this.rows;t++)for(let e=0;e<this.columns;e++)this.set(t,e,Math.floor(this.get(t,e)));return this},t.floor=function(t){return new e(t).floor()},t.prototype.fround=function(){for(let t=0;t<this.rows;t++)for(let e=0;e<this.columns;e++)this.set(t,e,Math.fround(this.get(t,e)));return this},t.fround=function(t){return new e(t).fround()},t.prototype.log=function(){for(let t=0;t<this.rows;t++)for(let e=0;e<this.columns;e++)this.set(t,e,Math.log(this.get(t,e)));return this},t.log=function(t){return new e(t).log()},t.prototype.log1p=function(){for(let t=0;t<this.rows;t++)for(let e=0;e<this.columns;e++)this.set(t,e,Math.log1p(this.get(t,e)));return this},t.log1p=function(t){return new e(t).log1p()},t.prototype.log10=function(){for(let t=0;t<this.rows;t++)for(let e=0;e<this.columns;e++)this.set(t,e,Math.log10(this.get(t,e)));return this},t.log10=function(t){return new e(t).log10()},t.prototype.log2=function(){for(let t=0;t<this.rows;t++)for(let e=0;e<this.columns;e++)this.set(t,e,Math.log2(this.get(t,e)));return this},t.log2=function(t){return new e(t).log2()},t.prototype.round=function(){for(let t=0;t<this.rows;t++)for(let e=0;e<this.columns;e++)this.set(t,e,Math.round(this.get(t,e)));return this},t.round=function(t){return new e(t).round()},t.prototype.sign=function(){for(let t=0;t<this.rows;t++)for(let e=0;e<this.columns;e++)this.set(t,e,Math.sign(this.get(t,e)));return this},t.sign=function(t){return new e(t).sign()},t.prototype.sin=function(){for(let t=0;t<this.rows;t++)for(let e=0;e<this.columns;e++)this.set(t,e,Math.sin(this.get(t,e)));return this},t.sin=function(t){return new e(t).sin()},t.prototype.sinh=function(){for(let t=0;t<this.rows;t++)for(let e=0;e<this.columns;e++)this.set(t,e,Math.sinh(this.get(t,e)));return this},t.sinh=function(t){return new e(t).sinh()},t.prototype.sqrt=function(){for(let t=0;t<this.rows;t++)for(let e=0;e<this.columns;e++)this.set(t,e,Math.sqrt(this.get(t,e)));return this},t.sqrt=function(t){return new e(t).sqrt()},t.prototype.tan=function(){for(let t=0;t<this.rows;t++)for(let e=0;e<this.columns;e++)this.set(t,e,Math.tan(this.get(t,e)));return this},t.tan=function(t){return new e(t).tan()},t.prototype.tanh=function(){for(let t=0;t<this.rows;t++)for(let e=0;e<this.columns;e++)this.set(t,e,Math.tanh(this.get(t,e)));return this},t.tanh=function(t){return new e(t).tanh()},t.prototype.trunc=function(){for(let t=0;t<this.rows;t++)for(let e=0;e<this.columns;e++)this.set(t,e,Math.trunc(this.get(t,e)));return this},t.trunc=function(t){return new e(t).trunc()},t.pow=function(t,r){return new e(t).pow(r)},t.prototype.pow=function(t){return"number"==typeof t?this.powS(t):this.powM(t)},t.prototype.powS=function(t){for(let e=0;e<this.rows;e++)for(let r=0;r<this.columns;r++)this.set(e,r,Math.pow(this.get(e,r),t));return this},t.prototype.powM=function(t){if(t=e.checkMatrix(t),this.rows!==t.rows||this.columns!==t.columns)throw new RangeError("Matrices dimensions must be equal");for(let e=0;e<this.rows;e++)for(let r=0;r<this.columns;r++)this.set(e,r,Math.pow(this.get(e,r),t.get(e,r)));return this}}(an,un);class dn extends an{constructor(t){super(),this.data=t,this.rows=t.length,this.columns=t[0].length}set(t,e,r){return this.data[t][e]=r,this}get(t,e){return this.data[t][e]}}function hn(t,e){let r=0;return Math.abs(t)>Math.abs(e)?(r=e/t,Math.abs(t)*Math.sqrt(1+r*r)):0!==e?(r=t/e,Math.abs(e)*Math.sqrt(1+r*r)):0}class cn{constructor(t,e={}){if((t=dn.checkMatrix(t)).isEmpty())throw new Error("Matrix must be non-empty");let r=t.rows,n=t.columns;const{computeLeftSingularVectors:o=!0,computeRightSingularVectors:i=!0,autoTranspose:a=!1}=e;let s,u=Boolean(o),d=Boolean(i),h=!1;if(r<n)if(a){s=t.transpose(),r=s.rows,n=s.columns,h=!0;let e=u;u=d,d=e}else s=t.clone(),console.warn("Computing SVD on a matrix with more columns than rows. Consider enabling autoTranspose");else s=t.clone();let c=Math.min(r,n),l=Math.min(r+1,n),f=new Float64Array(l),g=new un(r,c),p=new un(n,n),v=new Float64Array(n),y=new Float64Array(r),m=new Float64Array(l);for(let t=0;t<l;t++)m[t]=t;let w=Math.min(r-1,n),x=Math.max(0,Math.min(n-2,r)),E=Math.max(w,x);for(let t=0;t<E;t++){if(t<w){f[t]=0;for(let e=t;e<r;e++)f[t]=hn(f[t],s.get(e,t));if(0!==f[t]){s.get(t,t)<0&&(f[t]=-f[t]);for(let e=t;e<r;e++)s.set(e,t,s.get(e,t)/f[t]);s.set(t,t,s.get(t,t)+1)}f[t]=-f[t]}for(let e=t+1;e<n;e++){if(t<w&&0!==f[t]){let n=0;for(let o=t;o<r;o++)n+=s.get(o,t)*s.get(o,e);n=-n/s.get(t,t);for(let o=t;o<r;o++)s.set(o,e,s.get(o,e)+n*s.get(o,t))}v[e]=s.get(t,e)}if(u&&t<w)for(let e=t;e<r;e++)g.set(e,t,s.get(e,t));if(t<x){v[t]=0;for(let e=t+1;e<n;e++)v[t]=hn(v[t],v[e]);if(0!==v[t]){v[t+1]<0&&(v[t]=0-v[t]);for(let e=t+1;e<n;e++)v[e]/=v[t];v[t+1]+=1}if(v[t]=-v[t],t+1<r&&0!==v[t]){for(let e=t+1;e<r;e++)y[e]=0;for(let e=t+1;e<r;e++)for(let r=t+1;r<n;r++)y[e]+=v[r]*s.get(e,r);for(let e=t+1;e<n;e++){let n=-v[e]/v[t+1];for(let o=t+1;o<r;o++)s.set(o,e,s.get(o,e)+n*y[o])}}if(d)for(let e=t+1;e<n;e++)p.set(e,t,v[e])}}let b=Math.min(n,r+1);if(w<n&&(f[w]=s.get(w,w)),r<b&&(f[b-1]=0),x+1<b&&(v[x]=s.get(x,b-1)),v[b-1]=0,u){for(let t=w;t<c;t++){for(let e=0;e<r;e++)g.set(e,t,0);g.set(t,t,1)}for(let t=w-1;t>=0;t--)if(0!==f[t]){for(let e=t+1;e<c;e++){let n=0;for(let o=t;o<r;o++)n+=g.get(o,t)*g.get(o,e);n=-n/g.get(t,t);for(let o=t;o<r;o++)g.set(o,e,g.get(o,e)+n*g.get(o,t))}for(let e=t;e<r;e++)g.set(e,t,-g.get(e,t));g.set(t,t,1+g.get(t,t));for(let e=0;e<t-1;e++)g.set(e,t,0)}else{for(let e=0;e<r;e++)g.set(e,t,0);g.set(t,t,1)}}if(d)for(let t=n-1;t>=0;t--){if(t<x&&0!==v[t])for(let e=t+1;e<n;e++){let r=0;for(let o=t+1;o<n;o++)r+=p.get(o,t)*p.get(o,e);r=-r/p.get(t+1,t);for(let o=t+1;o<n;o++)p.set(o,e,p.get(o,e)+r*p.get(o,t))}for(let e=0;e<n;e++)p.set(e,t,0);p.set(t,t,1)}let N=b-1,M=0,S=Number.EPSILON;for(;b>0;){let t,e;for(t=b-2;t>=-1&&-1!==t;t--){const e=Number.MIN_VALUE+S*Math.abs(f[t]+Math.abs(f[t+1]));if(Math.abs(v[t])<=e||Number.isNaN(v[t])){v[t]=0;break}}if(t===b-2)e=4;else{let r;for(r=b-1;r>=t&&r!==t;r--){let e=(r!==b?Math.abs(v[r]):0)+(r!==t+1?Math.abs(v[r-1]):0);if(Math.abs(f[r])<=S*e){f[r]=0;break}}r===t?e=3:r===b-1?e=1:(e=2,t=r)}switch(t++,e){case 1:{let e=v[b-2];v[b-2]=0;for(let r=b-2;r>=t;r--){let o=hn(f[r],e),i=f[r]/o,a=e/o;if(f[r]=o,r!==t&&(e=-a*v[r-1],v[r-1]=i*v[r-1]),d)for(let t=0;t<n;t++)o=i*p.get(t,r)+a*p.get(t,b-1),p.set(t,b-1,-a*p.get(t,r)+i*p.get(t,b-1)),p.set(t,r,o)}break}case 2:{let e=v[t-1];v[t-1]=0;for(let n=t;n<b;n++){let o=hn(f[n],e),i=f[n]/o,a=e/o;if(f[n]=o,e=-a*v[n],v[n]=i*v[n],u)for(let e=0;e<r;e++)o=i*g.get(e,n)+a*g.get(e,t-1),g.set(e,t-1,-a*g.get(e,n)+i*g.get(e,t-1)),g.set(e,n,o)}break}case 3:{const e=Math.max(Math.abs(f[b-1]),Math.abs(f[b-2]),Math.abs(v[b-2]),Math.abs(f[t]),Math.abs(v[t])),o=f[b-1]/e,i=f[b-2]/e,a=v[b-2]/e,s=f[t]/e,h=v[t]/e,c=((i+o)*(i-o)+a*a)/2,l=o*a*(o*a);let y=0;0===c&&0===l||(y=c<0?0-Math.sqrt(c*c+l):Math.sqrt(c*c+l),y=l/(c+y));let m=(s+o)*(s-o)+y,w=s*h;for(let e=t;e<b-1;e++){let o=hn(m,w);0===o&&(o=Number.MIN_VALUE);let i=m/o,a=w/o;if(e!==t&&(v[e-1]=o),m=i*f[e]+a*v[e],v[e]=i*v[e]-a*f[e],w=a*f[e+1],f[e+1]=i*f[e+1],d)for(let t=0;t<n;t++)o=i*p.get(t,e)+a*p.get(t,e+1),p.set(t,e+1,-a*p.get(t,e)+i*p.get(t,e+1)),p.set(t,e,o);if(o=hn(m,w),0===o&&(o=Number.MIN_VALUE),i=m/o,a=w/o,f[e]=o,m=i*v[e]+a*f[e+1],f[e+1]=-a*v[e]+i*f[e+1],w=a*v[e+1],v[e+1]=i*v[e+1],u&&e<r-1)for(let t=0;t<r;t++)o=i*g.get(t,e)+a*g.get(t,e+1),g.set(t,e+1,-a*g.get(t,e)+i*g.get(t,e+1)),g.set(t,e,o)}v[b-2]=m,M+=1;break}case 4:if(f[t]<=0&&(f[t]=f[t]<0?-f[t]:0,d))for(let e=0;e<=N;e++)p.set(e,t,-p.get(e,t));for(;t<N&&!(f[t]>=f[t+1]);){let e=f[t];if(f[t]=f[t+1],f[t+1]=e,d&&t<n-1)for(let r=0;r<n;r++)e=p.get(r,t+1),p.set(r,t+1,p.get(r,t)),p.set(r,t,e);if(u&&t<r-1)for(let n=0;n<r;n++)e=g.get(n,t+1),g.set(n,t+1,g.get(n,t)),g.set(n,t,e);t++}M=0,b--}}if(h){let t=p;p=g,g=t}this.m=r,this.n=n,this.s=f,this.U=g,this.V=p}solve(t){let e=t,r=this.threshold,n=this.s.length,o=un.zeros(n,n);for(let t=0;t<n;t++)Math.abs(this.s[t])<=r?o.set(t,t,0):o.set(t,t,1/this.s[t]);let i=this.U,a=this.rightSingularVectors,s=a.mmul(o),u=a.rows,d=i.rows,h=un.zeros(u,d);for(let t=0;t<u;t++)for(let e=0;e<d;e++){let r=0;for(let o=0;o<n;o++)r+=s.get(t,o)*i.get(e,o);h.set(t,e,r)}return h.mmul(e)}solveForDiagonal(t){return this.solve(un.diag(t))}inverse(){let t=this.V,e=this.threshold,r=t.rows,n=t.columns,o=new un(r,this.s.length);for(let i=0;i<r;i++)for(let r=0;r<n;r++)Math.abs(this.s[r])>e&&o.set(i,r,t.get(i,r)/this.s[r]);let i=this.U,a=i.rows,s=i.columns,u=new un(r,a);for(let t=0;t<r;t++)for(let e=0;e<a;e++){let r=0;for(let n=0;n<s;n++)r+=o.get(t,n)*i.get(e,n);u.set(t,e,r)}return u}get condition(){return this.s[0]/this.s[Math.min(this.m,this.n)-1]}get norm2(){return this.s[0]}get rank(){let t=Math.max(this.m,this.n)*this.s[0]*Number.EPSILON,e=0,r=this.s;for(let n=0,o=r.length;n<o;n++)r[n]>t&&e++;return e}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 un.diag(this.s)}}var ln,fn={center:[0,0],linkDistance:50},gn=function(){function t(t){void 0===t&&(t={}),this.options=t,this.id="mds",this.options=n(n({},fn),t)}return t.prototype.execute=function(t,e){return i(this,void 0,void 0,(function(){return a(this,(function(r){return[2,this.genericMDSLayout(!1,t,e)]}))}))},t.prototype.assign=function(t,e){return i(this,void 0,void 0,(function(){return a(this,(function(r){return this.genericMDSLayout(!0,t,e),[2]}))}))},t.prototype.genericMDSLayout=function(t,e,r){return i(this,void 0,void 0,(function(){var o,i,s,u,d,h,c,l,f,g,p;return a(this,(function(a){return o=n(n({},this.options),r),i=o.center,s=void 0===i?[0,0]:i,u=o.linkDistance,d=void 0===u?50:u,h=e.getAllNodes(),c=e.getAllEdges(),(null==h?void 0:h.length)&&1!==h.length?(l=y({nodes:h,edges:c},!1),f=v(l),pn(f),m=d,w=[],f.forEach((function(t){var e=[];t.forEach((function(t){e.push(t*m)})),w.push(e)})),g=vn(w),p=[],g.forEach((function(t,e){var r=N(h[e]);r.data.x=t[0]+s[0],r.data.y=t[1]+s[1],p.push(r)})),t&&p.forEach((function(t){return e.mergeNodeData(t.id,{x:t.data.x,y:t.data.y})})),[2,{nodes:p,edges:c}]):[2,I(e,t,s)];var m,w}))}))},t}(),pn=function(t){var e=-999999;t.forEach((function(t){t.forEach((function(t){t!==1/0&&e<t&&(e=t)}))})),t.forEach((function(r,n){r.forEach((function(r,o){r===1/0&&(t[n][o]=e)}))}))},vn=function(t){var e=un.mul(un.pow(t,2),-.5),r=e.mean("row"),n=e.mean("column"),o=e.mean();e.add(o).subRowVector(r).subColumnVector(n);var i=new cn(e),a=un.sqrt(i.diagonalMatrix).diagonal();return i.leftSingularVectors.toJSON().map((function(t){return un.mul([t],[a]).toJSON()[0].splice(0,2)}))},yn={iterations:10,height:10,width:10,speed:100,gravity:10,k:5},mn=function(t,e,r,n,o,i){e.forEach((function(a,s){r[s]={x:0,y:0},e.forEach((function(e,u){if(s!==u&&o[s]===o[u]){var d=a.x-e.x,h=a.y-e.y,c=Math.sqrt(d*d+h*h);if(0===c){c=1;var l=s>u?1:-1;d=.01*l,h=.01*l}if(c<i(t[s])/2+i(t[u])/2){var f=n*n/c;r[s].x+=d/c*f,r[s].y+=h/c*f}}}))}))},wn=function(t,e,r,n,o,i,a,s){var u=i||a/10;return n&&e.forEach((function(e,r){var n=t[r].x-t[o].x,i=t[r].y-t[o].y,a=Math.sqrt(n*n+i*i),s=i/a,u=-n/a,d=Math.sqrt(e.x*e.x+e.y*e.y),h=Math.acos((s*e.x+u*e.y)/d);h>Math.PI/2&&(h-=Math.PI/2,s*=-1,u*=-1);var c=Math.cos(h)*d;e.x=s*c,e.y=u*c})),t.forEach((function(i,a){if(a!==o){var d=Math.sqrt(e[a].x*e[a].x+e[a].y*e[a].y);if(d>0&&a!==o){var h=Math.min(u*(r/800),d);if(i.x+=e[a].x/d*h,i.y+=e[a].y/d*h,n){var c=i.x-t[o].x,l=i.y-t[o].y,f=Math.sqrt(c*c+l*l);c=c/f*s[a],l=l/f*s[a],i.x=t[o].x+c,i.y=t[o].y+l}}}})),t},xn={maxIteration:1e3,focusNode:null,unitRadius:null,linkDistance:50,preventOverlap:!1,strictRadial:!0,maxPreventOverlapIteration:200,sortStrength:10},En=function(){function t(t){void 0===t&&(t={}),this.options=t,this.id="radial",this.options=n(n({},xn),t)}return t.prototype.execute=function(t,e){return i(this,void 0,void 0,(function(){return a(this,(function(r){return[2,this.genericRadialLayout(!1,t,e)]}))}))},t.prototype.assign=function(t,e){return i(this,void 0,void 0,(function(){return a(this,(function(r){return this.genericRadialLayout(!0,t,e),[2]}))}))},t.prototype.genericRadialLayout=function(t,e,r){return i(this,void 0,void 0,(function(){var o,i,d,h,c,l,f,g,p,m,w,x,E,b,M,S,k,A,_,D,O,P,z,C,L,q,j,F,V,G,W,B,$,U,H,K,Y,J,X,Q,Z,tt,et;return a(this,(function(a){if(o=n(n({},this.options),r),i=o.width,d=o.height,h=o.center,c=o.focusNode,l=o.unitRadius,f=o.nodeSize,g=o.nodeSpacing,p=o.strictRadial,m=o.preventOverlap,w=o.maxPreventOverlapIteration,x=o.sortBy,E=o.linkDistance,b=void 0===E?50:E,M=o.sortStrength,S=void 0===M?10:M,k=o.maxIteration,A=void 0===k?1e3:k,_=e.getAllNodes(),D=e.getAllEdges(),O=i||"undefined"==typeof window?i:window.innerWidth,P=d||"undefined"==typeof window?d:window.innerHeight,z=h||[O/2,P/2],!(null==_?void 0:_.length)||1===_.length)return[2,I(e,t,z)];if(C=_[0],T(c)){for(L=0;L<_.length;L++)if(_[L].id===c){C=_[L];break}}else C=c||_[0];return q=Mn(_,C.id),j=y({nodes:_,edges:D},!1),F=v(j),V=kn(F,q),Sn(F,q,V+1),G=F[q],W=O-z[0]>z[0]?z[0]:O-z[0],B=P-z[1]>z[1]?z[1]:P-z[1],0===W&&(W=O/2),0===B&&(B=P/2),$=Math.min(W,B),U=Math.max.apply(Math,u([],s(G),!1)),H=[],K=l||$/U,G.forEach((function(t,e){H[e]=t*K})),Y=bn(_,F,b,H,K,x,S),J=Nn(Y),X=function(t,e,r){try{var n=un.mul(un.pow(e,2),-.5),o=n.mean("row"),i=n.mean("column"),a=n.mean();n.add(a).subRowVector(o).subColumnVector(i);var s=new cn(n),u=un.sqrt(s.diagonalMatrix).diagonal();return s.leftSingularVectors.toJSON().map((function(e){return un.mul([e],[u]).toJSON()[0].splice(0,t)}))}catch(t){for(var d=[],h=0;h<e.length;h++){var c=Math.random()*r,l=Math.random()*r;d.push([c,l])}return d}}(b,Y,b),Q=X.map((function(t){var e=s(t,2),r=e[0],n=e[1];return{x:(isNaN(r)?Math.random()*b:r)-X[q][0],y:(isNaN(n)?Math.random()*b:n)-X[q][1]}})),this.run(A,Q,J,Y,H,q),m&&(Z=R(f,g),tt={nodes:_,nodeSizeFunc:Z,positions:Q,radii:H,height:P,width:O,strictRadial:Boolean(p),focusIdx:q,iterations:w||200,k:Q.length/4.5},Q=function(t,e){for(var r=n(n({},yn),e),o=r.positions,i=r.iterations,a=r.width,s=r.k,u=r.speed,d=void 0===u?100:u,h=r.strictRadial,c=r.focusIdx,l=r.radii,f=void 0===l?[]:l,g=r.nodeSizeFunc,p=t.getAllNodes(),v=[],y=a/10,m=0;m<i;m++)o.forEach((function(t,e){v[e]={x:0,y:0}})),mn(p,o,v,s,f,g),wn(o,v,d,h,c,y,a,f);return o}(e,tt)),et=[],Q.forEach((function(t,e){var r=N(_[e]);r.data.x=t.x+z[0],r.data.y=t.y+z[1],et.push(r)})),t&&et.forEach((function(t){return e.mergeNodeData(t.id,{x:t.data.x,y:t.data.y})})),[2,{nodes:et,edges:D}]}))}))},t.prototype.run=function(t,e,r,n,o,i){for(var a=0;a<=t;a++){var s=a/t;this.oneIteration(s,e,o,n,r,i)}},t.prototype.oneIteration=function(t,e,r,n,o,i){var a=1-t;e.forEach((function(s,u){var d=m(s,{x:0,y:0}),h=0===d?0:1/d;if(u!==i){var c=0,l=0,f=0;e.forEach((function(t,e){if(u!==e){var r=m(s,t),i=0===r?0:1/r,a=n[e][u];f+=o[u][e],c+=o[u][e]*(t.x+a*(s.x-t.x)*i),l+=o[u][e]*(t.y+a*(s.y-t.y)*i)}}));var g=0===r[u]?0:1/r[u];f*=a,f+=t*g*g,c*=a,c+=t*g*s.x*h,s.x=c/f,l*=a,l+=t*g*s.y*h,s.y=l/f}}))},t}(),bn=function(t,e,r,n,o,i,a){if(!t)return[];var s=[];if(e){var u={};e.forEach((function(e,d){var h=[];e.forEach((function(e,s){var c,l;if(d===s)h.push(0);else if(n[d]===n[s])if("data"===i)h.push(e*(Math.abs(d-s)*a)/(n[d]/o));else if(i){var f=void 0,g=void 0;if(u[t[d].id])f=u[t[d].id];else{var p=("id"===i?t[d].id:null===(c=t[d].data)||void 0===c?void 0:c[i])||0;f=T(p)?p.charCodeAt(0):p,u[t[d].id]=f}u[t[s].id]?g=u[t[s].id]:(p=("id"===i?t[s].id:null===(l=t[s].data)||void 0===l?void 0:l[i])||0,g=T(p)?p.charCodeAt(0):p,u[t[s].id]=g),h.push(e*(Math.abs(f-g)*a)/(n[d]/o))}else h.push(e*r/(n[d]/o));else{var v=(r+o)/2;h.push(e*v)}})),s.push(h)}))}return s},Nn=function(t){for(var e=t.length,r=t[0].length,n=[],o=0;o<e;o++){for(var i=[],a=0;a<r;a++)0!==t[o][a]?i.push(1/(t[o][a]*t[o][a])):i.push(0);n.push(i)}return n},Mn=function(t,e){var r=-1;return t.forEach((function(t,n){t.id===e&&(r=n)})),Math.max(r,0)},Sn=function(t,e,r){for(var n=t.length,o=0;o<n;o++)if(t[e][o]===1/0){t[e][o]=r,t[o][e]=r;for(var i=0;i<n;i++)t[o][i]!==1/0&&t[e][i]===1/0&&(t[e][i]=r+t[o][i],t[i][e]=r+t[o][i])}for(o=0;o<n;o++)if(o!==e)for(i=0;i<n;i++)if(t[o][i]===1/0){var a=Math.abs(t[e][o]-t[e][i]);a=0===a?1:a,t[o][i]=a}},kn=function(t,e){for(var r=0,n=0;n<t[e].length;n++)t[e][n]!==1/0&&(r=t[e][n]>r?t[e][n]:r);return r},An={center:[0,0],width:300,height:300},Rn=function(){function t(t){void 0===t&&(t={}),this.options=t,this.id="random",this.options=n(n({},An),t)}return t.prototype.execute=function(t,e){return i(this,void 0,void 0,(function(){return a(this,(function(r){return[2,this.genericRandomLayout(!1,t,e)]}))}))},t.prototype.assign=function(t,e){return i(this,void 0,void 0,(function(){return a(this,(function(r){return this.genericRandomLayout(!0,t,e),[2]}))}))},t.prototype.genericRandomLayout=function(t,e,r){return i(this,void 0,void 0,(function(){var o,i,s,u,d,h,c,l,f;return a(this,(function(a){return o=n(n({},this.options),r),i=o.center,s=o.width,u=o.height,d=e.getAllNodes(),h=s||"undefined"==typeof window?s:window.innerWidth,c=u||"undefined"==typeof window?u:window.innerHeight,l=i||[h/2,c/2],f=[],d&&d.forEach((function(t){f.push({id:t.id,data:{x:.9*(Math.random()-.5)*h+l[0],y:.9*(Math.random()-.5)*c+l[1]}})})),t&&f.forEach((function(t){return e.mergeNodeData(t.id,{x:t.data.x,y:t.data.y})})),[2,{nodes:f,edges:e.getAllEdges()}]}))}))},t}(),In={circular:D,concentric:C,mds:gn,random:Rn,grid:Cr,radial:En,force:Er,d3force:Ct,fruchterman:Tr,forceAtlas2:Or,dagre:vr};function _n(){(null==ln?void 0:ln.stop)&&ln.stop()}function Dn(t,e){return i(this,void 0,void 0,(function(){var r,n,o,i,s,u,d,h,c;return a(this,(function(a){switch(a.label){case 0:if(r=t.layout,n=r.id,o=r.options,i=r.iterations,s=t.nodes,u=t.edges,d=new f({nodes:s,edges:u}),!(h=In[n]))throw new Error("Unknown layout id: ".concat(n));return[4,(ln=new h(o)).execute(d)];case 1:return c=a.sent(),!!(l=ln).tick&&!!l.stop&&(ln.stop(),c=ln.tick(i)),[2,[c,e]]}var l}))}))}addEventListener("message",(function(t){var r,n=t.data,o=n.type,i=n.method,a=n.id,s=n.params;"RPC"===o&&i&&((r=e[i])?Promise.resolve().then((function(){return r.apply(e,s)})):Promise.reject("No such method")).then((function(t){postMessage({type:"RPC",id:a,result:t})})).catch((function(t){var e={message:t};t.stack&&(e.message=t.message,e.stack=t.stack,e.name=t.name),postMessage({type:"RPC",id:a,error:e})}))})),postMessage({type:"RPC",method:"ready"});\n//# sourceMappingURL=5eff5240d48719e2c5a3.worker.js.map']))),n(t,o),t}},475:t=>{t.exports=function(t,e){var r=0,n={};t.addEventListener("message",(function(e){var r=e.data;if("RPC"===r.type)if(r.id){var o=n[r.id];o&&(delete n[r.id],r.error?o[1](Object.assign(Error(r.error.message),r.error)):o[0](r.result))}else{var i=document.createEvent("Event");i.initEvent(r.method,!1,!1),i.data=r.params,t.dispatchEvent(i)}})),e.forEach((function(e){t[e]=function(){var o=arguments;return new Promise((function(i,a){var s=++r;n[s]=[i,a],t.postMessage({type:"RPC",id:s,method:e,params:[].slice.call(o)})}))}}))}}},e={};function r(n){var o=e[n];if(void 0!==o)return o.exports;var i=e[n]={exports:{}};return t[n](i,i.exports,r),i.exports}r.n=t=>{var e=t&&t.__esModule?()=>t.default:()=>t;return r.d(e,{a:e}),e},r.d=(t,e)=>{for(var n in e)r.o(e,n)&&!r.o(t,n)&&Object.defineProperty(t,n,{enumerable:!0,get:e[n]})},r.o=(t,e)=>Object.prototype.hasOwnProperty.call(t,e);var n={};(()=>{r.d(n,{SB:()=>j,W1:()=>K,jA:()=>Kt,Vq:()=>zr,E9:()=>Jr,y7:()=>jr,O2:()=>Qr,Me:()=>tn,AI:()=>Dn,D4:()=>Ln,_5:()=>Un,y9:()=>G,_A:()=>f,d9:()=>O,ul:()=>D,qs:()=>w,gl:()=>C,jE:()=>z,tO:()=>T,zJ:()=>x,h$:()=>S,BI:()=>R,$y:()=>_,H0:()=>M,kJ:()=>g,hY:()=>Yn,qR:()=>Hn,i_:()=>Gn,nu:()=>E,He:()=>p,A3:()=>N});var t=function(e,r){return t=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(t,e){t.__proto__=e}||function(t,e){for(var r in e)Object.prototype.hasOwnProperty.call(e,r)&&(t[r]=e[r])},t(e,r)};function e(e,r){if("function"!=typeof r&&null!==r)throw new TypeError("Class extends value "+String(r)+" is not a constructor or null");function n(){this.constructor=e}t(e,r),e.prototype=null===r?Object.create(r):(n.prototype=r.prototype,new n)}var o=function(){return o=Object.assign||function(t){for(var e,r=1,n=arguments.length;r<n;r++)for(var o in e=arguments[r])Object.prototype.hasOwnProperty.call(e,o)&&(t[o]=e[o]);return t},o.apply(this,arguments)};function i(t,e){var r={};for(var n in t)Object.prototype.hasOwnProperty.call(t,n)&&e.indexOf(n)<0&&(r[n]=t[n]);if(null!=t&&"function"==typeof Object.getOwnPropertySymbols){var o=0;for(n=Object.getOwnPropertySymbols(t);o<n.length;o++)e.indexOf(n[o])<0&&Object.prototype.propertyIsEnumerable.call(t,n[o])&&(r[n[o]]=t[n[o]])}return r}function a(t,e,r,n){return new(r||(r=Promise))((function(o,i){function a(t){try{u(n.next(t))}catch(t){i(t)}}function s(t){try{u(n.throw(t))}catch(t){i(t)}}function u(t){var e;t.done?o(t.value):(e=t.value,e instanceof r?e:new r((function(t){t(e)}))).then(a,s)}u((n=n.apply(t,e||[])).next())}))}function s(t,e){var r,n,o,i,a={label:0,sent:function(){if(1&o[0])throw o[1];return o[1]},trys:[],ops:[]};return i={next:s(0),throw:s(1),return:s(2)},"function"==typeof Symbol&&(i[Symbol.iterator]=function(){return this}),i;function s(s){return function(u){return function(s){if(r)throw new TypeError("Generator is already executing.");for(;i&&(i=0,s[0]&&(a=0)),a;)try{if(r=1,n&&(o=2&s[0]?n.return:s[0]?n.throw||((o=n.return)&&o.call(n),0):n.next)&&!(o=o.call(n,s[1])).done)return o;switch(n=0,o&&(s=[2&s[0],o.value]),s[0]){case 0:case 1:o=s;break;case 4:return a.label++,{value:s[1],done:!1};case 5:a.label++,n=s[1],s=[0];continue;case 7:s=a.ops.pop(),a.trys.pop();continue;default:if(!((o=(o=a.trys).length>0&&o[o.length-1])||6!==s[0]&&2!==s[0])){a=0;continue}if(3===s[0]&&(!o||s[1]>o[0]&&s[1]<o[3])){a.label=s[1];break}if(6===s[0]&&a.label<o[1]){a.label=o[1],o=s;break}if(o&&a.label<o[2]){a.label=o[2],a.ops.push(s);break}o[2]&&a.ops.pop(),a.trys.pop();continue}s=e.call(t,a)}catch(t){s=[6,t],n=0}finally{r=o=0}if(5&s[0])throw s[1];return{value:s[0]?s[1]:void 0,done:!0}}([s,u])}}}function u(t,e){var r="function"==typeof Symbol&&t[Symbol.iterator];if(!r)return t;var n,o,i=r.call(t),a=[];try{for(;(void 0===e||e-- >0)&&!(n=i.next()).done;)a.push(n.value)}catch(t){o={error:t}}finally{try{n&&!n.done&&(r=i.return)&&r.call(i)}finally{if(o)throw o.error}}return a}function d(t,e,r){if(r||2===arguments.length)for(var n,o=0,i=e.length;o<i;o++)!n&&o in e||(n||(n=Array.prototype.slice.call(e,0,o)),n[o]=e[o]);return t.concat(n||Array.prototype.slice.call(e))}Object.create,Object.create;var h,c,l=/-(\w)/g,f=(h=function(t){return t.replace(l,(function(t,e){return e?e.toUpperCase():""}))},c=Object.create(null),function(t){return c[t]||(c[t]=h(t))}),g=Array.isArray,p=function(t){var e=parseFloat(t);return isNaN(e)?t:e},v={}.toString;const y=function(t,e){return v.call(t)==="[object "+e+"]"},m=function(t){return y(t,"Number")};var w=function(t){for(var e=[],r=t.length,n=0;n<r;n+=1){e[n]=[];for(var o=0;o<r;o+=1)n===o?e[n][o]=0:0!==t[n][o]&&t[n][o]?e[n][o]=t[n][o]:e[n][o]=1/0}for(var i=0;i<r;i+=1)for(n=0;n<r;n+=1)for(o=0;o<r;o+=1)e[n][o]>e[n][i]+e[i][o]&&(e[n][o]=e[n][i]+e[i][o]);return e},x=function(t,e){var r=t.nodes,n=t.edges,o=[],i={};if(!r)throw new Error("invalid nodes data!");return r&&r.forEach((function(t,e){i[t.id]=e,o.push([])})),null==n||n.forEach((function(t){var r=t.source,n=t.target,a=i[r],s=i[n];void 0!==a&&void 0!==s&&(o[a][s]=1,e||(o[s][a]=1))})),o},E=function(t,e){var r=[];return t.forEach((function(t){var n=[];t.forEach((function(t){n.push(t*e)})),r.push(n)})),r},b=function(t,e){if(t&&t.children)for(var r=t.children.length-1;r>=0;r--)if(!b(t.children[r],e))return;return!!e(t)},N=function(t,e){"function"==typeof e&&b(t,e)},M=function(t){var e=1/0,r=1/0,n=-1/0,o=-1/0;return t.forEach((function(t){var i=t.data.size;g(i)?1===i.length&&(i=[i[0],i[0]]):m(i)?i=[i,i]:(void 0===i||isNaN(i))&&(i=[30,30]);var a=[i[0]/2,i[1]/2],s=t.data.x-a[0],u=t.data.x+a[0],d=t.data.y-a[1],h=t.data.y+a[1];e>s&&(e=s),r>d&&(r=d),n<u&&(n=u),o<h&&(o=h)})),{minX:e,minY:r,maxX:n,maxY:o}},S=function(t){var e={x:0,y:0};t.forEach((function(t){e.x+=t.data.x||0,e.y+=t.data.y||0}));var r=t.length||1;return{x:e.x/r,y:e.y/r}},k=function(t,e,r){var n,o;return"source"===t?(null===(n=null==r?void 0:r.find((function(t){return t.target===e.id})))||void 0===n?void 0:n.source)||{}:(null===(o=null==r?void 0:r.find((function(t){return t.source===e.id})))||void 0===o?void 0:o.target)||{}},A=function(t,e,r){var n=[];switch(t){case"source":n=null==r?void 0:r.filter((function(t){return t.source===e.id})).map((function(t){return t.target}));break;case"target":n=null==r?void 0:r.filter((function(t){return t.target===e.id})).map((function(t){return t.source}));break;case"both":n=null==r?void 0:r.filter((function(t){return t.source===e.id})).map((function(t){return t.target})).concat(null==r?void 0:r.filter((function(t){return t.target===e.id})).map((function(t){return t.source})))}var o=new Set(n);return Array.from(o)},R=function(t,e,r,n,o,i){var a=o[e.id],s=a.in,u=a.out,d=e,h=[];0===s?(d=k("source",e,r),h=A("both",d,r).map((function(t){return i[t]}))):0===u&&(d=k("target",e,r),h=A("both",d,r).map((function(t){return i[t]}))),h=h.filter((function(t){return o[t.id]&&(0===o[t.id].in||0===o[t.id].out)}));var c=function(t,e,r,n,o){var i=r[e]||"",a=(null==n?void 0:n.filter((function(t){return t[e]===i})))||[];return"leaf"===t&&(a=a.filter((function(t){var e,r;return 0===(null===(e=o[t.id])||void 0===e?void 0:e.in)||0===(null===(r=o[t.id])||void 0===r?void 0:r.out)}))),a}(t,n,e,h,o);return{coreNode:d,relativeLeafNodes:h,sameTypeLeafNodes:c}},_=function(t,e){return Math.sqrt((t.x-e.x)*(t.x-e.x)+(t.y-e.y)*(t.y-e.y))},O=function(t){if(null===t)return t;if(t instanceof Date)return new Date(t.getTime());if(t instanceof Array){var e=[];return t.forEach((function(t){e.push(t)})),e.map((function(t){return O(t)}))}if("object"==typeof t){var r={};return Object.keys(t).forEach((function(e){r[e]=O(t[e])})),r}return t},D=function(t,e){var r=O(t);return r.data=r.data||{},e&&(m(r.data.x)||(r.data.x=Math.random()*e[0]),m(r.data.y)||(r.data.y=Math.random()*e[1])),r};const I=function(t){return"function"==typeof t},P=function(t){var e=typeof t;return null!==t&&"object"===e||"function"===e};function z(t,e){return I(e)?e:m(e)?function(){return e}:function(){return t}}function T(t,e,r){return void 0===r&&(r=!0),e||0===e?I(e)?e:m(e)?function(){return e}:g(e)?function(){if(r){var n=Math.max.apply(Math,d([],u(e),!1));return isNaN(n)?t:n}return e}:P(e)?function(){if(r){var n=Math.max(e.width,e.height);return isNaN(n)?t:n}return[e.width,e.height]}:function(){return t}:function(e){var r=(e.data||{}).size;return r?g(r)?r[0]>r[1]?r[0]:r[1]:P(r)?r.width>r.height?r.width:r.height:r:t}}var C=function(t,e){var r;return r=m(e)?function(){return e}:I(e)?e:function(){return 0},t?g(t)?function(e){return(t[0]>t[1]?t[0]:t[1])+r(e)}:function(e){return t+r(e)}:function(t){var e,n;if(null===(e=t.data)||void 0===e?void 0:e.bboxSize)return Math.max(t.data.bboxSize[0],t.data.bboxSize[1])+r(t);if(null===(n=t.data)||void 0===n?void 0:n.size){if(g(t.data.size))return Math.max(t.data.size[0],t.data.size[1])+r(t);var o=t.data.size;return P(o)?(o.width>o.height?o.width:o.height)+r(t):o+r(t)}return 10+r(t)}},q=function(t,e,r){var n=t.getAllNodes(),i=t.getAllEdges();return(null==n?void 0:n.length)?1===n.length?(e&&t.mergeNodeData(n[0].id,{x:r[0],y:r[1]}),{nodes:[o(o({},n[0]),{data:o(o({},n[0].data),{x:r[0],y:r[1]})})],edges:i}):void 0:{nodes:[],edges:i}},L={radius:null,startRadius:null,endRadius:null,startAngle:0,endAngle:2*Math.PI,clockwise:!0,divisions:1,ordering:null,angleRatio:1},j=function(){function t(t){void 0===t&&(t={}),this.options=t,this.id="circular",this.options=o(o({},L),t)}return t.prototype.execute=function(t,e){return a(this,void 0,void 0,(function(){return s(this,(function(r){return[2,this.genericCircularLayout(!1,t,e)]}))}))},t.prototype.assign=function(t,e){return a(this,void 0,void 0,(function(){return s(this,(function(r){switch(r.label){case 0:return[4,this.genericCircularLayout(!0,t,e)];case 1:return r.sent(),[2]}}))}))},t.prototype.genericCircularLayout=function(t,e,r){return a(this,void 0,void 0,(function(){var n,i,a,d,h,c,l,f,g,p,v,y,m,w,x,E,b,N,M,S,k,A,R,_,O,I,P,C,L,j,B,$,W,U,G;return s(this,(function(s){if(n=o(o({},this.options),r),i=n.width,a=n.height,d=n.center,h=n.divisions,c=n.startAngle,l=void 0===c?0:c,f=n.endAngle,g=void 0===f?2*Math.PI:f,p=n.angleRatio,v=n.ordering,y=n.clockwise,m=n.nodeSpacing,w=n.nodeSize,x=e.getAllNodes(),E=e.getAllEdges(),b=u(V(i,a,d),3),N=b[0],M=b[1],S=b[2],!(k=null==x?void 0:x.length)||1===k)return[2,q(e,t,S)];for(A=(g-l)/k,R=n.radius,_=n.startRadius,O=n.endRadius,m?(I=z(10,m),P=T(10,w),C=-1/0,x.forEach((function(t){var e=P(t);C<e&&(C=e)})),L=0,x.forEach((function(t,e){L+=0===e?C||10:(I(t)||0)+(C||10)})),R=L/(2*Math.PI)):R||_||O?!_&&O?_=O:_&&!O&&(O=_):R=Math.min(M,N)/2,j=A*p,B=[],B="topology"===v?F(e,x):"topology-directed"===v?F(e,x,!0):"degree"===v?function(t,e){var r=[];return e.forEach((function(t,e){r.push(D(t))})),r.sort((function(e,r){return t.getDegree(e.id,"both")-t.getDegree(r.id,"both")})),r}(e,x):x.map((function(t){return D(t)})),$=Math.ceil(k/h),W=0;W<k;++W)(U=R)||null===_||null===O||(U=_+W*(O-_)/(k-1)),U||(U=10+100*W/(k-1)),G=l+W%$*j+2*Math.PI/h*Math.floor(W/$),y||(G=g-W%$*j-2*Math.PI/h*Math.floor(W/$)),B[W].data.x=S[0]+Math.cos(G)*U,B[W].data.y=S[1]+Math.sin(G)*U;return t&&B.forEach((function(t){e.mergeNodeData(t.id,{x:t.data.x,y:t.data.y})})),[2,{nodes:B,edges:E}]}))}))},t}(),F=function(t,e,r){void 0===r&&(r=!1);var n=[D(e[0])],o={},i=e.length;o[e[0].id]=!0;var a=0;return e.forEach((function(s,u){if(0!==u)if(u!==i-1&&t.getDegree(s.id,"both")===t.getDegree(e[u+1].id,"both")&&!t.areNeighbors(n[a].id,s.id)||o[s.id]){for(var d=r?t.getSuccessors(n[a].id):t.getNeighbors(n[a].id),h=!1,c=0;c<d.length;c++){var l=d[c];if(t.getDegree(l.id)===t.getDegree(s.id)&&!o[l.id]){n.push(D(l)),o[l.id]=!0,h=!0;break}}for(var f=0;!h&&(o[e[f].id]||(n.push(D(e[f])),o[e[f].id]=!0,h=!0),++f!==i););}else n.push(D(s)),o[s.id]=!0,a++})),n},V=function(t,e,r){var n=t,o=e,i=r;return n||"undefined"==typeof window||(n=window.innerWidth),o||"undefined"==typeof window||(o=window.innerHeight),i||(i=[n/2,o/2]),[n,o,i]},B=r(161),$=r.n(B),W=r(825),U=r.n(W),G=function(t){function r(e,r,n){var o=t.call(this)||this;return o.graph=e,o.layout=r,o.options=n,o.spawnWorker(),o}return e(r,t),r.prototype.spawnWorker=function(){this.worker&&this.worker.terminate(),this.worker=U()(),this.running&&(this.running=!1,this.execute())},r.prototype.execute=function(){var t;return a(this,void 0,void 0,(function(){var e,r,n,o;return s(this,(function(a){switch(a.label){case 0:return this.running?[2,this]:(this.running=!0,(e=this.layout.options).onTick,r=i(e,["onTick"]),n={layout:{id:this.layout.id,options:r,iterations:null===(t=this.options)||void 0===t?void 0:t.iterations},nodes:this.graph.getAllNodes(),edges:this.graph.getAllEdges()},o=new Float32Array([0]),[4,this.worker.calculateLayout(n,[o])]);case 1:return[2,u.apply(void 0,[a.sent(),1])[0]]}}))}))},r.prototype.stop=function(){return this.running=!1,this.worker.stopLayout(),this},r.prototype.kill=function(){this.worker&&this.worker.terminate()},r.prototype.isRunning=function(){return this.running},r}($());const H=function(t){return y(t,"String")};var Y={nodeSize:30,nodeSpacing:10,preventOverlap:!1,sweep:void 0,equidistant:!1,startAngle:1.5*Math.PI,clockwise:!0,maxLevelDiff:void 0,sortBy:"degree"},K=function(){function t(t){void 0===t&&(t={}),this.options=t,this.id="concentric",this.options=o(o({},Y),t)}return t.prototype.execute=function(t,e){return a(this,void 0,void 0,(function(){return s(this,(function(r){return[2,this.genericConcentricLayout(!1,t,e)]}))}))},t.prototype.assign=function(t,e){return a(this,void 0,void 0,(function(){return s(this,(function(r){return this.genericConcentricLayout(!0,t,e),[2]}))}))},t.prototype.genericConcentricLayout=function(t,e,r){return a(this,void 0,void 0,(function(){var n,i,a,u,d,h,c,l,f,p,v,y,w,x,E,b,N,M,S,k,A,R,_,O,z,T,C,L,j,F,V,B,$,W,U,G,Y,K;return s(this,(function(s){if(n=o(o({},this.options),r),i=n.center,a=n.width,u=n.height,d=n.sortBy,h=n.maxLevelDiff,c=n.sweep,l=n.clockwise,f=n.equidistant,p=n.preventOverlap,v=n.startAngle,y=void 0===v?1.5*Math.PI:v,w=n.nodeSize,x=n.nodeSpacing,E=e.getAllNodes(),b=e.getAllEdges(),N=a||"undefined"==typeof window?a:window.innerWidth,M=u||"undefined"==typeof window?u:window.innerHeight,S=i||[N/2,M/2],!(null==E?void 0:E.length)||1===E.length)return[2,q(e,t,S)];if(k=[],R=0,A=g(w)?Math.max(w[0],w[1]):w,g(x)?R=Math.max(x[0],x[1]):m(x)&&(R=x),E.forEach((function(t){var e=D(t);k.push(e);var r=A,n=e.data;g(n.size)?r=Math.max(n.size[0],n.size[1]):m(n.size)?r=n.size:P(n.size)&&(r=Math.max(n.size.width,n.size.height)),A=Math.max(A,r),I(x)&&(R=Math.max(x(t),R))})),_={},k.forEach((function(t,e){_[t.id]=e})),H(O=d)&&void 0!==k[0].data[O]||(O="degree"),"degree"===O?k.sort((function(t,r){return e.getDegree(r.id,"both")-e.getDegree(t.id,"both")})):k.sort((function(t,e){return e.data[O]-t.data[O]})),z=k[0],T=(h||("degree"===O?e.getDegree(z.id,"both"):z.data[O]))/4,L=(C=[{nodes:[]}])[0],k.forEach((function(t){if(L.nodes.length>0){var r="degree"===O?Math.abs(e.getDegree(L.nodes[0].id,"both")-e.getDegree(t.id,"both")):Math.abs(L.nodes[0].data[O]-t.data[O]);T&&r>=T&&(L={nodes:[]},C.push(L))}L.nodes.push(t)})),j=A+R,p||(F=C.length>0&&C[0].nodes.length>1,V=Math.min(N,M)/2-j,B=V/(C.length+(F?1:0)),j=Math.min(j,B)),$=0,C.forEach((function(t){var e=void 0===c?2*Math.PI-2*Math.PI/t.nodes.length:c;if(t.dTheta=e/Math.max(1,t.nodes.length-1),t.nodes.length>1&&p){var r=Math.cos(t.dTheta)-Math.cos(0),n=Math.sin(t.dTheta)-Math.sin(0),o=Math.sqrt(j*j/(r*r+n*n));$=Math.max(o,$)}t.r=$,$+=j})),f){for(W=0,U=0,G=0;G<C.length;G++)Y=C[G],K=(Y.r||0)-U,W=Math.max(W,K);U=0,C.forEach((function(t,e){0===e&&(U=t.r||0),t.r=U,U+=W}))}return C.forEach((function(t){var e=t.dTheta||0,r=t.r||0;t.nodes.forEach((function(t,n){var o=y+(l?1:-1)*e*n;t.data.x=S[0]+r*Math.cos(o),t.data.y=S[1]+r*Math.sin(o)}))})),t&&k.forEach((function(t){return e.mergeNodeData(t.id,{x:t.data.x,y:t.data.y})})),[2,{nodes:k,edges:b}]}))}))},t}();function J(t,e,r,n){if(isNaN(e)||isNaN(r))return t;var o,i,a,s,u,d,h,c,l,f=t._root,g={data:n},p=t._x0,v=t._y0,y=t._x1,m=t._y1;if(!f)return t._root=g,t;for(;f.length;)if((d=e>=(i=(p+y)/2))?p=i:y=i,(h=r>=(a=(v+m)/2))?v=a:m=a,o=f,!(f=f[c=h<<1|d]))return o[c]=g,t;if(s=+t._x.call(null,f.data),u=+t._y.call(null,f.data),e===s&&r===u)return g.next=f,o?o[c]=g:t._root=g,t;do{o=o?o[c]=new Array(4):t._root=new Array(4),(d=e>=(i=(p+y)/2))?p=i:y=i,(h=r>=(a=(v+m)/2))?v=a:m=a}while((c=h<<1|d)==(l=(u>=a)<<1|s>=i));return o[l]=f,o[c]=g,t}function X(t,e,r,n,o){this.node=t,this.x0=e,this.y0=r,this.x1=n,this.y1=o}function Q(t){return t[0]}function Z(t){return t[1]}function tt(t,e,r){var n=new et(null==e?Q:e,null==r?Z:r,NaN,NaN,NaN,NaN);return null==t?n:n.addAll(t)}function et(t,e,r,n,o,i){this._x=t,this._y=e,this._x0=r,this._y0=n,this._x1=o,this._y1=i,this._root=void 0}function rt(t){for(var e={data:t.data},r=e;t=t.next;)r=r.next={data:t.data};return e}var nt=tt.prototype=et.prototype;function ot(t){return function(){return t}}function it(t){return 1e-6*(t()-.5)}nt.copy=function(){var t,e,r=new et(this._x,this._y,this._x0,this._y0,this._x1,this._y1),n=this._root;if(!n)return r;if(!n.length)return r._root=rt(n),r;for(t=[{source:n,target:r._root=new Array(4)}];n=t.pop();)for(var o=0;o<4;++o)(e=n.source[o])&&(e.length?t.push({source:e,target:n.target[o]=new Array(4)}):n.target[o]=rt(e));return r},nt.add=function(t){const e=+this._x.call(null,t),r=+this._y.call(null,t);return J(this.cover(e,r),e,r,t)},nt.addAll=function(t){var e,r,n,o,i=t.length,a=new Array(i),s=new Array(i),u=1/0,d=1/0,h=-1/0,c=-1/0;for(r=0;r<i;++r)isNaN(n=+this._x.call(null,e=t[r]))||isNaN(o=+this._y.call(null,e))||(a[r]=n,s[r]=o,n<u&&(u=n),n>h&&(h=n),o<d&&(d=o),o>c&&(c=o));if(u>h||d>c)return this;for(this.cover(u,d).cover(h,c),r=0;r<i;++r)J(this,a[r],s[r],t[r]);return this},nt.cover=function(t,e){if(isNaN(t=+t)||isNaN(e=+e))return this;var r=this._x0,n=this._y0,o=this._x1,i=this._y1;if(isNaN(r))o=(r=Math.floor(t))+1,i=(n=Math.floor(e))+1;else{for(var a,s,u=o-r||1,d=this._root;r>t||t>=o||n>e||e>=i;)switch(s=(e<n)<<1|t<r,(a=new Array(4))[s]=d,d=a,u*=2,s){case 0:o=r+u,i=n+u;break;case 1:r=o-u,i=n+u;break;case 2:o=r+u,n=i-u;break;case 3:r=o-u,n=i-u}this._root&&this._root.length&&(this._root=d)}return this._x0=r,this._y0=n,this._x1=o,this._y1=i,this},nt.data=function(){var t=[];return this.visit((function(e){if(!e.length)do{t.push(e.data)}while(e=e.next)})),t},nt.extent=function(t){return arguments.length?this.cover(+t[0][0],+t[0][1]).cover(+t[1][0],+t[1][1]):isNaN(this._x0)?void 0:[[this._x0,this._y0],[this._x1,this._y1]]},nt.find=function(t,e,r){var n,o,i,a,s,u,d,h=this._x0,c=this._y0,l=this._x1,f=this._y1,g=[],p=this._root;for(p&&g.push(new X(p,h,c,l,f)),null==r?r=1/0:(h=t-r,c=e-r,l=t+r,f=e+r,r*=r);u=g.pop();)if(!(!(p=u.node)||(o=u.x0)>l||(i=u.y0)>f||(a=u.x1)<h||(s=u.y1)<c))if(p.length){var v=(o+a)/2,y=(i+s)/2;g.push(new X(p[3],v,y,a,s),new X(p[2],o,y,v,s),new X(p[1],v,i,a,y),new X(p[0],o,i,v,y)),(d=(e>=y)<<1|t>=v)&&(u=g[g.length-1],g[g.length-1]=g[g.length-1-d],g[g.length-1-d]=u)}else{var m=t-+this._x.call(null,p.data),w=e-+this._y.call(null,p.data),x=m*m+w*w;if(x<r){var E=Math.sqrt(r=x);h=t-E,c=e-E,l=t+E,f=e+E,n=p.data}}return n},nt.remove=function(t){if(isNaN(i=+this._x.call(null,t))||isNaN(a=+this._y.call(null,t)))return this;var e,r,n,o,i,a,s,u,d,h,c,l,f=this._root,g=this._x0,p=this._y0,v=this._x1,y=this._y1;if(!f)return this;if(f.length)for(;;){if((d=i>=(s=(g+v)/2))?g=s:v=s,(h=a>=(u=(p+y)/2))?p=u:y=u,e=f,!(f=f[c=h<<1|d]))return this;if(!f.length)break;(e[c+1&3]||e[c+2&3]||e[c+3&3])&&(r=e,l=c)}for(;f.data!==t;)if(n=f,!(f=f.next))return this;return(o=f.next)&&delete f.next,n?(o?n.next=o:delete n.next,this):e?(o?e[c]=o:delete e[c],(f=e[0]||e[1]||e[2]||e[3])&&f===(e[3]||e[2]||e[1]||e[0])&&!f.length&&(r?r[l]=f:this._root=f),this):(this._root=o,this)},nt.removeAll=function(t){for(var e=0,r=t.length;e<r;++e)this.remove(t[e]);return this},nt.root=function(){return this._root},nt.size=function(){var t=0;return this.visit((function(e){if(!e.length)do{++t}while(e=e.next)})),t},nt.visit=function(t){var e,r,n,o,i,a,s=[],u=this._root;for(u&&s.push(new X(u,this._x0,this._y0,this._x1,this._y1));e=s.pop();)if(!t(u=e.node,n=e.x0,o=e.y0,i=e.x1,a=e.y1)&&u.length){var d=(n+i)/2,h=(o+a)/2;(r=u[3])&&s.push(new X(r,d,h,i,a)),(r=u[2])&&s.push(new X(r,n,h,d,a)),(r=u[1])&&s.push(new X(r,d,o,i,h)),(r=u[0])&&s.push(new X(r,n,o,d,h))}return this},nt.visitAfter=function(t){var e,r=[],n=[];for(this._root&&r.push(new X(this._root,this._x0,this._y0,this._x1,this._y1));e=r.pop();){var o=e.node;if(o.length){var i,a=e.x0,s=e.y0,u=e.x1,d=e.y1,h=(a+u)/2,c=(s+d)/2;(i=o[0])&&r.push(new X(i,a,s,h,c)),(i=o[1])&&r.push(new X(i,h,s,u,c)),(i=o[2])&&r.push(new X(i,a,c,h,d)),(i=o[3])&&r.push(new X(i,h,c,u,d))}n.push(e)}for(;e=n.pop();)t(e.node,e.x0,e.y0,e.x1,e.y1);return this},nt.x=function(t){return arguments.length?(this._x=t,this):this._x},nt.y=function(t){return arguments.length?(this._y=t,this):this._y};var at={value:()=>{}};function st(){for(var t,e=0,r=arguments.length,n={};e<r;++e){if(!(t=arguments[e]+"")||t in n||/[\s.]/.test(t))throw new Error("illegal type: "+t);n[t]=[]}return new ut(n)}function ut(t){this._=t}function dt(t,e){for(var r,n=0,o=t.length;n<o;++n)if((r=t[n]).name===e)return r.value}function ht(t,e,r){for(var n=0,o=t.length;n<o;++n)if(t[n].name===e){t[n]=at,t=t.slice(0,n).concat(t.slice(n+1));break}return null!=r&&t.push({name:e,value:r}),t}ut.prototype=st.prototype={constructor:ut,on:function(t,e){var r,n,o=this._,i=(n=o,(t+"").trim().split(/^|\s+/).map((function(t){var e="",r=t.indexOf(".");if(r>=0&&(e=t.slice(r+1),t=t.slice(0,r)),t&&!n.hasOwnProperty(t))throw new Error("unknown type: "+t);return{type:t,name:e}}))),a=-1,s=i.length;if(!(arguments.length<2)){if(null!=e&&"function"!=typeof e)throw new Error("invalid callback: "+e);for(;++a<s;)if(r=(t=i[a]).type)o[r]=ht(o[r],t.name,e);else if(null==e)for(r in o)o[r]=ht(o[r],t.name,null);return this}for(;++a<s;)if((r=(t=i[a]).type)&&(r=dt(o[r],t.name)))return r},copy:function(){var t={},e=this._;for(var r in e)t[r]=e[r].slice();return new ut(t)},call:function(t,e){if((r=arguments.length-2)>0)for(var r,n,o=new Array(r),i=0;i<r;++i)o[i]=arguments[i+2];if(!this._.hasOwnProperty(t))throw new Error("unknown type: "+t);for(i=0,r=(n=this._[t]).length;i<r;++i)n[i].value.apply(e,o)},apply:function(t,e,r){if(!this._.hasOwnProperty(t))throw new Error("unknown type: "+t);for(var n=this._[t],o=0,i=n.length;o<i;++o)n[o].value.apply(e,r)}};const ct=st;var lt,ft,gt=0,pt=0,vt=0,yt=1e3,mt=0,wt=0,xt=0,Et="object"==typeof performance&&performance.now?performance:Date,bt="object"==typeof window&&window.requestAnimationFrame?window.requestAnimationFrame.bind(window):function(t){setTimeout(t,17)};function Nt(){return wt||(bt(Mt),wt=Et.now()+xt)}function Mt(){wt=0}function St(){this._call=this._time=this._next=null}function kt(t,e,r){var n=new St;return n.restart(t,e,r),n}function At(){wt=(mt=Et.now())+xt,gt=pt=0;try{!function(){Nt(),++gt;for(var t,e=lt;e;)(t=wt-e._time)>=0&&e._call.call(void 0,t),e=e._next;--gt}()}finally{gt=0,function(){for(var t,e,r=lt,n=1/0;r;)r._call?(n>r._time&&(n=r._time),t=r,r=r._next):(e=r._next,r._next=null,r=t?t._next=e:lt=e);ft=t,_t(n)}(),wt=0}}function Rt(){var t=Et.now(),e=t-mt;e>yt&&(xt-=e,mt=t)}function _t(t){gt||(pt&&(pt=clearTimeout(pt)),t-wt>24?(t<1/0&&(pt=setTimeout(At,t-Et.now()-xt)),vt&&(vt=clearInterval(vt))):(vt||(mt=Et.now(),vt=setInterval(Rt,yt)),gt=1,bt(At)))}St.prototype=kt.prototype={constructor:St,restart:function(t,e,r){if("function"!=typeof t)throw new TypeError("callback is not a function");r=(null==r?Nt():+r)+(null==e?0:+e),this._next||ft===this||(ft?ft._next=this:lt=this,ft=this),this._call=t,this._time=r,_t()},stop:function(){this._call&&(this._call=null,this._time=1/0,_t())}};const Ot=1664525,Dt=1013904223,It=4294967296;function Pt(t){return t.x}function zt(t){return t.y}var Tt=10,Ct=Math.PI*(3-Math.sqrt(5));function qt(t){var e,r=1,n=.001,o=1-Math.pow(n,1/300),i=0,a=.6,s=new Map,u=kt(c),d=ct("tick","end"),h=function(){let t=1;return()=>(t=(Ot*t+Dt)%It)/It}();function c(){l(),d.call("tick",e),r<n&&(u.stop(),d.call("end",e))}function l(n){var u,d,h=t.length;void 0===n&&(n=1);for(var c=0;c<n;++c)for(r+=(i-r)*o,s.forEach((function(t){t(r)})),u=0;u<h;++u)null==(d=t[u]).fx?d.x+=d.vx*=a:(d.x=d.fx,d.vx=0),null==d.fy?d.y+=d.vy*=a:(d.y=d.fy,d.vy=0);return e}function f(){for(var e,r=0,n=t.length;r<n;++r){if((e=t[r]).index=r,null!=e.fx&&(e.x=e.fx),null!=e.fy&&(e.y=e.fy),isNaN(e.x)||isNaN(e.y)){var o=Tt*Math.sqrt(.5+r),i=r*Ct;e.x=o*Math.cos(i),e.y=o*Math.sin(i)}(isNaN(e.vx)||isNaN(e.vy))&&(e.vx=e.vy=0)}}function g(e){return e.initialize&&e.initialize(t,h),e}return null==t&&(t=[]),f(),e={tick:l,restart:function(){return u.restart(c),e},stop:function(){return u.stop(),e},nodes:function(r){return arguments.length?(t=r,f(),s.forEach(g),e):t},alpha:function(t){return arguments.length?(r=+t,e):r},alphaMin:function(t){return arguments.length?(n=+t,e):n},alphaDecay:function(t){return arguments.length?(o=+t,e):+o},alphaTarget:function(t){return arguments.length?(i=+t,e):i},velocityDecay:function(t){return arguments.length?(a=1-t,e):1-a},randomSource:function(t){return arguments.length?(h=t,s.forEach(g),e):h},force:function(t,r){return arguments.length>1?(null==r?s.delete(t):s.set(t,g(r)),e):s.get(t)},find:function(e,r,n){var o,i,a,s,u,d=0,h=t.length;for(null==n?n=1/0:n*=n,d=0;d<h;++d)(a=(o=e-(s=t[d]).x)*o+(i=r-s.y)*i)<n&&(u=s,n=a);return u},on:function(t,r){return arguments.length>1?(d.on(t,r),e):d.on(t)}}}function Lt(){var t,e,r,n,o,i=ot(-30),a=1,s=1/0,u=.81;function d(r){var o,i=t.length,a=tt(t,Pt,zt).visitAfter(c);for(n=r,o=0;o<i;++o)e=t[o],a.visit(l)}function h(){if(t){var e,r,n=t.length;for(o=new Array(n),e=0;e<n;++e)r=t[e],o[r.index]=+i(r,e,t)}}function c(t){var e,r,n,i,a,s=0,u=0;if(t.length){for(n=i=a=0;a<4;++a)(e=t[a])&&(r=Math.abs(e.value))&&(s+=e.value,u+=r,n+=r*e.x,i+=r*e.y);t.x=n/u,t.y=i/u}else{(e=t).x=e.data.x,e.y=e.data.y;do{s+=o[e.data.index]}while(e=e.next)}t.value=s}function l(t,i,d,h){if(!t.value)return!0;var c=t.x-e.x,l=t.y-e.y,f=h-i,g=c*c+l*l;if(f*f/u<g)return g<s&&(0===c&&(g+=(c=it(r))*c),0===l&&(g+=(l=it(r))*l),g<a&&(g=Math.sqrt(a*g)),e.vx+=c*t.value*n/g,e.vy+=l*t.value*n/g),!0;if(!(t.length||g>=s)){(t.data!==e||t.next)&&(0===c&&(g+=(c=it(r))*c),0===l&&(g+=(l=it(r))*l),g<a&&(g=Math.sqrt(a*g)));do{t.data!==e&&(f=o[t.data.index]*n/g,e.vx+=c*f,e.vy+=l*f)}while(t=t.next)}}return d.initialize=function(e,n){t=e,r=n,h()},d.strength=function(t){return arguments.length?(i="function"==typeof t?t:ot(+t),h(),d):i},d.distanceMin=function(t){return arguments.length?(a=t*t,d):Math.sqrt(a)},d.distanceMax=function(t){return arguments.length?(s=t*t,d):Math.sqrt(s)},d.theta=function(t){return arguments.length?(u=t*t,d):Math.sqrt(u)},d}function jt(t){return t.index}function Ft(t,e){var r=t.get(e);if(!r)throw new Error("node not found: "+e);return r}function Vt(t){var e,r,n,o,i,a,s=jt,u=function(t){return 1/Math.min(o[t.source.index],o[t.target.index])},d=ot(30),h=1;function c(n){for(var o=0,s=t.length;o<h;++o)for(var u,d,c,l,f,g,p,v=0;v<s;++v)d=(u=t[v]).source,l=(c=u.target).x+c.vx-d.x-d.vx||it(a),f=c.y+c.vy-d.y-d.vy||it(a),l*=g=((g=Math.sqrt(l*l+f*f))-r[v])/g*n*e[v],f*=g,c.vx-=l*(p=i[v]),c.vy-=f*p,d.vx+=l*(p=1-p),d.vy+=f*p}function l(){if(n){var a,u,d=n.length,h=t.length,c=new Map(n.map(((t,e)=>[s(t,e,n),t])));for(a=0,o=new Array(d);a<h;++a)(u=t[a]).index=a,"object"!=typeof u.source&&(u.source=Ft(c,u.source)),"object"!=typeof u.target&&(u.target=Ft(c,u.target)),o[u.source.index]=(o[u.source.index]||0)+1,o[u.target.index]=(o[u.target.index]||0)+1;for(a=0,i=new Array(h);a<h;++a)u=t[a],i[a]=o[u.source.index]/(o[u.source.index]+o[u.target.index]);e=new Array(h),f(),r=new Array(h),g()}}function f(){if(n)for(var r=0,o=t.length;r<o;++r)e[r]=+u(t[r],r,t)}function g(){if(n)for(var e=0,o=t.length;e<o;++e)r[e]=+d(t[e],e,t)}return null==t&&(t=[]),c.initialize=function(t,e){n=t,a=e,l()},c.links=function(e){return arguments.length?(t=e,l(),c):t},c.id=function(t){return arguments.length?(s=t,c):s},c.iterations=function(t){return arguments.length?(h=+t,c):h},c.strength=function(t){return arguments.length?(u="function"==typeof t?t:ot(+t),f(),c):u},c.distance=function(t){return arguments.length?(d="function"==typeof t?t:ot(+t),g(),c):d},c}function Bt(t){return t.x+t.vx}function $t(t){return t.y+t.vy}function Wt(t){var e,r,n,o=1,i=1;function a(){for(var t,a,u,d,h,c,l,f=e.length,g=0;g<i;++g)for(a=tt(e,Bt,$t).visitAfter(s),t=0;t<f;++t)u=e[t],c=r[u.index],l=c*c,d=u.x+u.vx,h=u.y+u.vy,a.visit(p);function p(t,e,r,i,a){var s=t.data,f=t.r,g=c+f;if(!s)return e>d+g||i<d-g||r>h+g||a<h-g;if(s.index>u.index){var p=d-s.x-s.vx,v=h-s.y-s.vy,y=p*p+v*v;y<g*g&&(0===p&&(y+=(p=it(n))*p),0===v&&(y+=(v=it(n))*v),y=(g-(y=Math.sqrt(y)))/y*o,u.vx+=(p*=y)*(g=(f*=f)/(l+f)),u.vy+=(v*=y)*g,s.vx-=p*(g=1-g),s.vy-=v*g)}}}function s(t){if(t.data)return t.r=r[t.data.index];for(var e=t.r=0;e<4;++e)t[e]&&t[e].r>t.r&&(t.r=t[e].r)}function u(){if(e){var n,o,i=e.length;for(r=new Array(i),n=0;n<i;++n)o=e[n],r[o.index]=+t(o,n,e)}}return"function"!=typeof t&&(t=ot(null==t?1:+t)),a.initialize=function(t,r){e=t,n=r,u()},a.iterations=function(t){return arguments.length?(i=+t,a):i},a.strength=function(t){return arguments.length?(o=+t,a):o},a.radius=function(e){return arguments.length?(t="function"==typeof e?e:ot(+e),u(),a):t},a}function Ut(t){var e,r,n,o=ot(.1);function i(t){for(var o,i=0,a=e.length;i<a;++i)(o=e[i]).vx+=(n[i]-o.x)*r[i]*t}function a(){if(e){var i,a=e.length;for(r=new Array(a),n=new Array(a),i=0;i<a;++i)r[i]=isNaN(n[i]=+t(e[i],i,e))?0:+o(e[i],i,e)}}return"function"!=typeof t&&(t=ot(null==t?0:+t)),i.initialize=function(t){e=t,a()},i.strength=function(t){return arguments.length?(o="function"==typeof t?t:ot(+t),a(),i):o},i.x=function(e){return arguments.length?(t="function"==typeof e?e:ot(+e),a(),i):t},i}function Gt(t){var e,r,n,o=ot(.1);function i(t){for(var o,i=0,a=e.length;i<a;++i)(o=e[i]).vy+=(n[i]-o.y)*r[i]*t}function a(){if(e){var i,a=e.length;for(r=new Array(a),n=new Array(a),i=0;i<a;++i)r[i]=isNaN(n[i]=+t(e[i],i,e))?0:+o(e[i],i,e)}}return"function"!=typeof t&&(t=ot(null==t?0:+t)),i.initialize=function(t){e=t,a()},i.strength=function(t){return arguments.length?(o="function"==typeof t?t:ot(+t),a(),i):o},i.y=function(e){return arguments.length?(t="function"==typeof e?e:ot(+e),a(),i):t},i}function Ht(){function t(t){return function(){return t}}var e,r=function(t){return t.cluster},n=t(1),o=t(-1),i=t(100),a=t(.1),s=[0,0],d=[],h={},c=[],l=100,f=100,g={none:{x:0,y:0}},p=[],v="force",y=!0,m=.1;function w(t){if(!y)return w;e.tick(),E();for(var n=0,o=d.length,i=void 0,a=t*m;n<o;++n)(i=d[n]).vx+=(g[r(i)].x-i.x)*a,i.vy+=(g[r(i)].y-i.y)*a}function x(){d&&function(){if(d&&d.length){if(void 0===r(d[0]))throw Error("Couldnt find the grouping attribute for the nodes. Make sure to set it up with forceInBox.groupBy('clusterAttr') before calling .links()");var t,s,g,v,y,m=(t=[],s=[],g={},{},y=[],v=function(t){var e={};return t.forEach((function(t){var n=r(t);e[n]||(e[n]={count:0,sumforceNodeSize:0})})),t.forEach((function(t){var o=r(t),i=n(t),a=e[o];a.count=a.count+1,a.sumforceNodeSize=a.sumforceNodeSize+Math.PI*(i*i)*1.3,e[o]=a})),e}(d),y=function(t){var e={},n=[];return t.forEach((function(t){var n,o,i,a,s,u=(o=(n=t).source,i=n.target,(a=r(h[o]))<=(s=r(h[i]))?"".concat(a,"~").concat(s):"".concat(s,"~").concat(a)),d=0;void 0!==e[u]&&(d=e[u]),d+=1,e[u]=d})),Object.entries(e).forEach((function(t){var e=u(t,2),r=e[0],o=e[1],i=r.split("~")[0],a=r.split("~")[1];void 0!==i&&void 0!==a&&n.push({source:i,target:a,count:o})})),n}(c),Object.keys(v).forEach((function(e,r){var n=v[e];t.push({id:e,size:n.count,r:Math.sqrt(n.sumforceNodeSize/Math.PI)}),g[e]=r})),y.forEach((function(t){var e=t.source,r=t.target,n=g[e],o=g[r];void 0!==n&&void 0!==o&&s.push({source:n,target:o,count:t.count})})),{nodes:t,links:s});e=qt(m.nodes).force("x",Ut(l).strength(.1)).force("y",Gt(f).strength(.1)).force("collide",Wt((function(t){return t.r})).iterations(4)).force("charge",Lt().strength(o)).force("links",Vt(m.nodes.length?m.links:[]).distance(i).strength(a)),p=e.nodes(),E()}}()}function E(){return g={none:{x:0,y:0}},p.forEach((function(t){g[t.id]={x:t.x-s[0],y:t.y-s[1]}})),g}return w.initialize=function(t){d=t,x()},w.template=function(t){return arguments.length?(v=t,x(),w):v},w.groupBy=function(t){return arguments.length?"string"==typeof t?(r=function(e){return e[t]},w):(r=t,w):r},w.enableGrouping=function(t){return arguments.length?(y=t,w):y},w.strength=function(t){return arguments.length?(m=t,w):m},w.centerX=function(t){return arguments.length?(l=t,w):l},w.centerY=function(t){return arguments.length?(f=t,w):f},w.nodes=function(t){return arguments.length?(function(t){h={},t.forEach((function(t){h[t.id]=t}))}(t||[]),d=t||[],w):d},w.links=function(t){return arguments.length?(c=t||[],x(),w):c},w.forceNodeSize=function(e){return arguments.length?(n="function"==typeof e?e:t(+e),x(),w):n},w.nodeSize=w.forceNodeSize,w.forceCharge=function(e){return arguments.length?(o="function"==typeof e?e:t(+e),x(),w):o},w.forceLinkDistance=function(e){return arguments.length?(i="function"==typeof e?e:t(+e),x(),w):i},w.forceLinkStrength=function(e){return arguments.length?(a="function"==typeof e?e:t(+e),x(),w):a},w.offset=function(t){return arguments.length?(s=t,w):s},w.getFocis=E,w}var Yt={center:[0,0],preventOverlap:!1,nodeSize:void 0,nodeSpacing:void 0,linkDistance:50,forceSimulation:null,alphaDecay:.028,alphaMin:.001,alpha:.3,collideStrength:1,clustering:!1,clusterNodeStrength:-1,clusterEdgeStrength:.1,clusterEdgeDistance:100,clusterFociStrength:.8,clusterNodeSize:10},Kt=function(){function t(t){void 0===t&&(t={}),this.options=t,this.id="d3force",this.options=o(o({},Yt),t)}return t.prototype.execute=function(t,e){return a(this,void 0,void 0,(function(){return s(this,(function(r){return[2,this.genericForceLayout(!1,t,e)]}))}))},t.prototype.assign=function(t,e){return a(this,void 0,void 0,(function(){return s(this,(function(r){return this.genericForceLayout(!0,t,e),[2]}))}))},t.prototype.stop=function(){var t;null===(t=this.forceSimulation)||void 0===t||t.stop()},t.prototype.tick=function(t){var e=this;void 0===t&&(t=1),this.forceSimulation.tick(t);var r={nodes:Jt(this.lastLayoutNodes),edges:Xt(this.lastLayoutEdges)};return this.lastAssign&&r.nodes.forEach((function(t){return e.lastGraph.mergeNodeData(t.id,{x:t.data.x,y:t.data.y})})),r},t.prototype.genericForceLayout=function(t,e,r){return a(this,void 0,void 0,(function(){var n,i,a,u,d,h,c,l,f,g,p,v,y,m,w,x,E,b,N,M,S,k,A,R,_,O,I=this;return s(this,(function(s){return n=o(o({},this.options),r),i=e.getAllNodes(),a=e.getAllEdges(),u=i.map((function(t){var e,r;return o(o({},D(t)),{x:null===(e=t.data)||void 0===e?void 0:e.x,y:null===(r=t.data)||void 0===r?void 0:r.y})})),d=a.map((function(t){return D(t)})),this.lastLayoutNodes=u,this.lastLayoutEdges=d,this.lastAssign=t,this.lastGraph=e,h=n.alphaMin,c=n.alphaDecay,l=n.alpha,f=n.nodeStrength,g=n.edgeStrength,p=n.linkDistance,v=n.clustering,y=n.clusterFociStrength,m=n.clusterEdgeDistance,w=n.clusterEdgeStrength,x=n.clusterNodeStrength,E=n.clusterNodeSize,b=n.collideStrength,N=void 0===b?1:b,M=n.center,S=void 0===M?[0,0]:M,k=n.preventOverlap,A=n.nodeSize,R=n.nodeSpacing,_=n.onTick,O=n.forceSimulation,[2,new Promise((function(r){if(O){v&&((i=Ht()).nodes(u),i.links(d)),O.nodes(u),d&&(s=Vt().id((function(t){return t.id})).links(d),g&&s.strength(g),p&&s.distance(p),O.force("link",s)),k&&I.overlapProcess(O,{nodeSize:A,nodeSpacing:R,collideStrength:N}),O.alpha(l).restart();var n=Jt(u),o=Xt(d);t&&n.forEach((function(t){return e.mergeNodeData(t.id,{x:t.data.x,y:t.data.y})})),r({nodes:n,edges:o})}else try{var i,a=Lt();if(f&&a.strength(f),O=qt().nodes(u),v&&((i=Ht()).centerX(S[0]).centerY(S[1]).template("force").strength(y),d&&i.links(d),u&&i.nodes(u),i.forceLinkDistance(m).forceLinkStrength(w).forceCharge(x).forceNodeSize(E),O.force("group",i)),O.force("center",function(t,e){var r,n=1;function o(){var o,i,a=r.length,s=0,u=0;for(o=0;o<a;++o)s+=(i=r[o]).x,u+=i.y;for(s=(s/a-t)*n,u=(u/a-e)*n,o=0;o<a;++o)(i=r[o]).x-=s,i.y-=u}return null==t&&(t=0),null==e&&(e=0),o.initialize=function(t){r=t},o.x=function(e){return arguments.length?(t=+e,o):t},o.y=function(t){return arguments.length?(e=+t,o):e},o.strength=function(t){return arguments.length?(n=+t,o):n},o}(S[0],S[1])).force("charge",a).alpha(l).alphaDecay(c).alphaMin(h),k&&I.overlapProcess(O,{nodeSize:A,nodeSpacing:R,collideStrength:N}),d){var s=Vt().id((function(t){return t.id})).links(d);g&&s.strength(g),p&&s.distance(p),O.force("link",s)}O.on("tick",(function(){var r=Jt(u);null==_||_({nodes:r,edges:Xt(d)}),t&&r.forEach((function(t){return e.mergeNodeData(t.id,{x:t.data.x,y:t.data.y})}))})).on("end",(function(){var n=Jt(u);t&&n.forEach((function(t){return e.mergeNodeData(t.id,{x:t.data.x,y:t.data.y})})),r({nodes:n,edges:Xt(d)})}))}catch(t){console.warn(t)}I.forceSimulation=O}))]}))}))},t.prototype.overlapProcess=function(t,e){var r,n,o=e.nodeSize,i=e.nodeSpacing,a=e.collideStrength;if(n=m(i)?function(){return i}:I(i)?i:function(){return 0},o)if(I(o))r=function(t){return o(t)+n(t)};else if(g(o)){var s=(o[0]>o[1]?o[0]:o[1])/2;r=function(t){return s+n(t)}}else if(m(o)){var u=o/2;r=function(t){return u+n(t)}}else r=function(){return 10};else r=function(t){return t.size?g(t.size)?(t.size[0]>t.size[1]?t.size[0]:t.size[1])/2+n(t):P(t.size)?(t.size.width>t.size.height?t.size.width:t.size.height)/2+n(t):t.size/2+n(t):10+n(t)};t.force("collisionForce",Wt(r).strength(a))},t}(),Jt=function(t){return t.map((function(t){var e=t.x,r=t.y,n=i(t,["x","y"]);return o(o({},n),{data:o(o({},n.data),{x:e,y:r})})}))},Xt=function(t){return t.map((function(t){var e=t.source,r=t.target,n=i(t,["source","target"]);return o(o({},n),{source:e.id,target:r.id})}))},Qt="*";const Zt=function(){function t(){this._events={}}return t.prototype.on=function(t,e,r){return this._events[t]||(this._events[t]=[]),this._events[t].push({callback:e,once:!!r}),this},t.prototype.once=function(t,e){return this.on(t,e,!0)},t.prototype.emit=function(t){for(var e=this,r=[],n=1;n<arguments.length;n++)r[n-1]=arguments[n];var o=this._events[t]||[],i=this._events[Qt]||[],a=function(n){for(var o=n.length,i=0;i<o;i++)if(n[i]){var a=n[i],s=a.callback;a.once&&(n.splice(i,1),0===n.length&&delete e._events[t],o--,i--),s.apply(e,r)}};a(o),a(i)},t.prototype.off=function(t,e){if(t)if(e){for(var r=this._events[t]||[],n=r.length,o=0;o<n;o++)r[o].callback===e&&(r.splice(o,1),n--,o--);0===r.length&&delete this._events[t]}else delete this._events[t];else this._events={};return this},t.prototype.getEvents=function(){return this._events},t}();function te(t,e,r,n){for(;t.length;){const o=t.shift();if(r(o))return!0;e.add(o.id),n(o.id).forEach((r=>{e.has(r.id)||(e.add(r.id),t.push(r))}))}return!1}function ee(t,e,r,n){if(r(t))return!0;e.add(t.id);for(const o of n(t.id))if(!e.has(o.id)&&ee(o,e,r,n))return!0;return!1}class re extends Zt{nodeMap=new Map;edgeMap=new Map;inEdgesMap=new Map;outEdgesMap=new Map;bothEdgesMap=new Map;treeIndices=new Map;changes=[];batchCount=0;onChanged=()=>{};constructor(t){super(),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))}batch=t=>{this.batchCount+=1,t(),this.batchCount-=1,this.batchCount||this.commit()};commit(){const t=this.changes;this.changes=[];const e={graph:this,changes:t};this.emit("changed",e),this.onChanged(e)}reduceChanges(t){let e=[];return t.forEach((t=>{switch(t.type){case"NodeRemoved":{let r=!1;e=e.filter((e=>{if("NodeAdded"===e.type){const n=e.value.id===t.value.id;return n&&(r=!0),!n}return"NodeDataUpdated"===e.type?e.id!==t.value.id:"TreeStructureChanged"!==e.type||e.nodeId!==t.value.id})),r||e.push(t);break}case"EdgeRemoved":{let r=!1;e=e.filter((e=>{if("EdgeAdded"===e.type){const n=e.value.id===t.value.id;return n&&(r=!0),!n}return"EdgeDataUpdated"!==e.type&&"EdgeUpdated"!==e.type||e.id!==t.value.id})),r||e.push(t);break}case"NodeDataUpdated":case"EdgeDataUpdated":case"EdgeUpdated":{const r=e.find((e=>e.type===t.type&&e.id===t.id&&e.propertyName===t.propertyName));r?r.newValue=t.newValue:e.push(t);break}case"TreeStructureDetached":e=e.filter((e=>"TreeStructureAttached"===e.type?e.treeKey!==t.treeKey:"TreeStructureChanged"!==e.type||e.treeKey!==t.treeKey)),e.push(t);break;case"TreeStructureChanged":{const r=e.find((e=>"TreeStructureChanged"===e.type&&e.treeKey===t.treeKey&&e.nodeId===t.nodeId));r?r.newParentId=t.newParentId:e.push(t);break}default:e.push(t)}})),e}checkNodeExistence(t){this.getNode(t)}hasNode(t){return this.nodeMap.has(t)}areNeighbors(t,e){return this.getNeighbors(e).some((e=>e.id===t))}getNode(t){const e=this.nodeMap.get(t);if(!e)throw new Error("Node not found for id: "+t);return e}getRelatedEdges(t,e){if(this.checkNodeExistence(t),"in"===e){const e=this.inEdgesMap.get(t);return Array.from(e)}if("out"===e){const e=this.outEdgesMap.get(t);return Array.from(e)}{const e=this.bothEdgesMap.get(t);return Array.from(e)}}getDegree(t,e){return this.getRelatedEdges(t,e).length}getSuccessors(t){const e=this.getRelatedEdges(t,"out").map((t=>this.getNode(t.target)));return Array.from(new Set(e))}getPredecessors(t){const e=this.getRelatedEdges(t,"in").map((t=>this.getNode(t.source)));return Array.from(new Set(e))}getNeighbors(t){const e=this.getPredecessors(t),r=this.getSuccessors(t);return Array.from(new Set([...e,...r]))}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((e=>{e.childrenMap.set(t.id,new Set)})),this.changes.push({type:"NodeAdded",value:t})}addNodes(t){this.batch((()=>{for(const e of t)this.doAddNode(e)}))}addNode(t){this.addNodes([t])}doRemoveNode(t){const e=this.getNode(t);this.bothEdgesMap.get(t)?.forEach((t=>this.doRemoveEdge(t.id))),this.nodeMap.delete(t),this.treeIndices.forEach((e=>{e.childrenMap.get(t)?.forEach((t=>{e.parentMap.delete(t.id)})),e.parentMap.delete(t),e.childrenMap.delete(t)})),this.changes.push({type:"NodeRemoved",value:e})}removeNodes(t){this.batch((()=>{t.forEach((t=>this.doRemoveNode(t)))}))}removeNode(t){this.removeNodes([t])}updateNodeDataProperty(t,e,r){const n=this.getNode(t);this.batch((()=>{const o=n.data[e],i=r;n.data[e]=i,this.changes.push({type:"NodeDataUpdated",id:t,propertyName:e,oldValue:o,newValue:i})}))}mergeNodeData(t,e){this.batch((()=>{Object.entries(e).forEach((([e,r])=>{this.updateNodeDataProperty(t,e,r)}))}))}updateNodeData(...t){const e=t[0],r=this.getNode(e);if("string"==typeof t[1])return void this.updateNodeDataProperty(e,t[1],t[2]);let n;if("function"==typeof t[1]){const e=t[1];n=e(r.data)}else"object"==typeof t[1]&&(n=t[1]);this.batch((()=>{const t=r.data,o=n;r.data=n,this.changes.push({type:"NodeDataUpdated",id:e,oldValue:t,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 e=this.getEdge(t);return{edge:e,source:this.getNode(e.source),target:this.getNode(e.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 e=this.inEdgesMap.get(t.target),r=this.outEdgesMap.get(t.source),n=this.bothEdgesMap.get(t.source),o=this.bothEdgesMap.get(t.target);e.add(t),r.add(t),n.add(t),o.add(t),this.changes.push({type:"EdgeAdded",value:t})}addEdges(t){this.batch((()=>{for(const e of t)this.doAddEdge(e)}))}addEdge(t){this.addEdges([t])}doRemoveEdge(t){const e=this.getEdge(t),r=this.outEdgesMap.get(e.source),n=this.inEdgesMap.get(e.target),o=this.bothEdgesMap.get(e.source),i=this.bothEdgesMap.get(e.target);r.delete(e),n.delete(e),o.delete(e),i.delete(e),this.edgeMap.delete(t),this.changes.push({type:"EdgeRemoved",value:e})}removeEdges(t){this.batch((()=>{t.forEach((t=>this.doRemoveEdge(t)))}))}removeEdge(t){this.removeEdges([t])}updateEdgeSource(t,e){const r=this.getEdge(t);this.checkNodeExistence(e);const n=r.source,o=e;this.outEdgesMap.get(n).delete(r),this.bothEdgesMap.get(n).delete(r),this.outEdgesMap.get(o).add(r),this.bothEdgesMap.get(o).add(r),r.source=e,this.batch((()=>{this.changes.push({type:"EdgeUpdated",id:t,propertyName:"source",oldValue:n,newValue:o})}))}updateEdgeTarget(t,e){const r=this.getEdge(t);this.checkNodeExistence(e);const n=r.target,o=e;this.inEdgesMap.get(n).delete(r),this.bothEdgesMap.get(n).delete(r),this.inEdgesMap.get(o).add(r),this.bothEdgesMap.get(o).add(r),r.target=e,this.batch((()=>{this.changes.push({type:"EdgeUpdated",id:t,propertyName:"target",oldValue:n,newValue:o})}))}updateEdgeDataProperty(t,e,r){const n=this.getEdge(t);this.batch((()=>{const o=n.data[e],i=r;n.data[e]=i,this.changes.push({type:"EdgeDataUpdated",id:t,propertyName:e,oldValue:o,newValue:i})}))}updateEdgeData(...t){const e=t[0],r=this.getEdge(e);if("string"==typeof t[1])return void this.updateEdgeDataProperty(e,t[1],t[2]);let n;if("function"==typeof t[1]){const e=t[1];n=e(r.data)}else"object"==typeof t[1]&&(n=t[1]);this.batch((()=>{const t=r.data,o=n;r.data=n,this.changes.push({type:"EdgeDataUpdated",id:e,oldValue:t,newValue:o})}))}mergeEdgeData(t,e){this.batch((()=>{Object.entries(e).forEach((([e,r])=>{this.updateEdgeDataProperty(t,e,r)}))}))}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,e){this.batch((()=>{this.attachTreeStructure(e);const r=[],n=Array.isArray(t)?t:[t];for(;n.length;){const t=n.shift();r.push(t),t.children&&n.push(...t.children)}this.addNodes(r),r.forEach((t=>{t.children?.forEach((r=>{this.setParent(r.id,t.id,e)}))}))}))}getRoots(t){return this.checkTreeExistence(t),this.getAllNodes().filter((e=>!this.getParent(e.id,t)))}getChildren(t,e){this.checkNodeExistence(t),this.checkTreeExistence(e);const r=this.treeIndices.get(e).childrenMap.get(t);return Array.from(r||[])}getParent(t,e){return this.checkNodeExistence(t),this.checkTreeExistence(e),this.treeIndices.get(e).parentMap.get(t)||null}getAncestors(t,e){const r=[];let n,o=this.getNode(t);for(;n=this.getParent(o.id,e);)r.push(n),o=n;return r}setParent(t,e,r){this.checkTreeExistence(r);const n=this.treeIndices.get(r),o=this.getNode(t),i=n.parentMap.get(t),a=this.getNode(e);n.parentMap.set(t,a),i&&n.childrenMap.get(i.id)?.delete(o);let s=n.childrenMap.get(a.id);s||(s=new Set,n.childrenMap.set(a.id,s)),s.add(o),this.batch((()=>{this.changes.push({type:"TreeStructureChanged",treeKey:r,nodeId:t,oldParentId:i?.id,newParentId:a.id})}))}dfsTree(t,e,r){return ee(this.getNode(t),new Set,e,(t=>this.getChildren(t,r)))}bfsTree(t,e,r){return te([this.getNode(t)],new Set,e,(t=>this.getChildren(t,r)))}getAllNodes(){return Array.from(this.nodeMap.values())}getAllEdges(){return Array.from(this.edgeMap.values())}bfs(t,e,r="out"){const n={in:this.getPredecessors.bind(this),out:this.getSuccessors.bind(this),both:this.getNeighbors.bind(this)}[r];return te([this.getNode(t)],new Set,e,n)}dfs(t,e,r="out"){const n={in:this.getPredecessors.bind(this),out:this.getSuccessors.bind(this),both:this.getNeighbors.bind(this)}[r];return ee(this.getNode(t),new Set,e,n)}clone(){const t=this.getAllNodes().map((t=>({...t,data:{...t.data}}))),e=this.getAllEdges().map((t=>({...t,data:{...t.data}}))),r=new re({nodes:t,edges:e});return this.treeIndices.forEach((({parentMap:t,childrenMap:e},n)=>{const o=new Map;t.forEach(((t,e)=>{o.set(e,r.getNode(t.id))}));const i=new Map;e.forEach(((t,e)=>{i.set(e,new Set(Array.from(t).map((t=>r.getNode(t.id)))))})),r.treeIndices.set(n,{parentMap:o,childrenMap:i})})),r}toJSON(){return JSON.stringify({nodes:this.getAllNodes(),edges:this.getAllEdges()})}}var ne=function(t,e){if("next"!==t&&"prev"!==t)return e},oe=function(t){t.prev.next=t.next,t.next.prev=t.prev,delete t.next,delete t.prev},ie=function(t){function r(){return null!==t&&t.apply(this,arguments)||this}return e(r,t),r}(function(){function t(){var t={};t.prev=t,t.next=t.prev,this.shortcut=t}return t.prototype.dequeue=function(){var t=this.shortcut,e=t.prev;if(e&&e!==t)return oe(e),e},t.prototype.enqueue=function(t){var e=this.shortcut;t.prev&&t.next&&oe(t),t.next=e.next,e.next.prev=t,e.next=t,t.prev=e},t.prototype.toString=function(){for(var t=[],e=this.shortcut,r=e.prev;r!==e;)t.push(JSON.stringify(r,ne)),r=null==r?void 0:r.prev;return"[".concat(t.join(", "),"]")},t}()),ae=function(){return 1},se=function(t,e,r,n,i){var a,s,u=[];return t.hasNode(n.v)&&(null===(a=t.getRelatedEdges(n.v,"in"))||void 0===a||a.forEach((function(n){var a=n.data.weight,s=t.getNode(n.source);i&&u.push({v:n.source,w:n.target,in:0,out:0}),void 0===s.data.out&&(s.data.out=0),s.data.out-=a,ue(e,r,o({v:s.id},s.data))})),null===(s=t.getRelatedEdges(n.v,"out"))||void 0===s||s.forEach((function(n){var i=n.data.weight,a=n.target,s=t.getNode(a);void 0===s.data.in&&(s.data.in=0),s.data.in-=i,ue(e,r,o({v:s.id},s.data))})),t.removeNode(n.v)),i?u:void 0},ue=function(t,e,r){r.out?r.in?t[r.out-r.in+e].enqueue(r):t[t.length-1].enqueue(r):t[0].enqueue(r)},de=function(t,e){var r="greedy"===e?function(t,e){var r;if(t.getAllNodes().length<=1)return[];var n=function(t,e){var r=new re,n=0,i=0;t.getAllNodes().forEach((function(t){r.addNode({id:t.id,data:{v:t.id,in:0,out:0}})})),t.getAllEdges().forEach((function(t){var a=r.getRelatedEdges(t.source,"out").find((function(e){return e.target===t.target})),s=(null==e?void 0:e(t))||1;a?r.updateEdgeData(null==a?void 0:a.id,o(o({},a.data),{weight:a.data.weight+s})):r.addEdge({id:t.id,source:t.source,target:t.target,data:{weight:s}}),i=Math.max(i,r.getNode(t.source).data.out+=s),n=Math.max(n,r.getNode(t.target).data.in+=s)}));for(var a=[],s=i+n+3,u=0;u<s;u++)a.push(new ie);var d=n+1;return r.getAllNodes().forEach((function(t){ue(a,d,o({v:t.id},r.getNode(t.id).data))})),{buckets:a,zeroIdx:d,graph:r}}(t,function(t){return t.data.weight||1}||ae);return null===(r=function(t,e,r){for(var n,o=[],i=e[e.length-1],a=e[0];t.getAllNodes().length;){for(;n=a.dequeue();)se(t,e,r,n);for(;n=i.dequeue();)se(t,e,r,n);if(t.getAllNodes().length)for(var s=e.length-2;s>0;--s)if(n=e[s].dequeue()){o=o.concat(se(t,e,r,n,!0));break}}return o}(n.graph,n.buckets,n.zeroIdx).map((function(e){return t.getRelatedEdges(e.v,"out").filter((function(t){return t.target===e.w}))})))||void 0===r?void 0:r.flat()}(t):he(t);null==r||r.forEach((function(e){var r=e.data;t.removeEdge(e.id),r.forwardName=e.data.name,r.reversed=!0,t.addEdge({id:e.id,source:e.target,target:e.source,data:o({},r)})}))},he=function(t){var e=[],r={},n={},o=function(i){n[i]||(n[i]=!0,r[i]=!0,t.getRelatedEdges(i,"out").forEach((function(t){r[t.target]?e.push(t):o(t.target)})),delete r[i])};return t.getAllNodes().forEach((function(t){return o(t.id)})),e},ce=function(t,e,r,n){var o;do{o="".concat(n).concat(Math.random())}while(t.hasNode(o));return r.dummy=e,t.addNode({id:o,data:r}),o},le=function(t){var e=new re;return t.getAllNodes().forEach((function(r){t.getChildren(r.id).length||e.addNode(o({},r))})),t.getAllEdges().forEach((function(t){e.addEdge(t)})),e},fe=function(t,e){var r,n,o=Number(t.x),i=Number(t.y),a=Number(e.x)-o,s=Number(e.y)-i,u=Number(t.width)/2,d=Number(t.height)/2;return a||s?(Math.abs(s)*u>Math.abs(a)*d?(s<0&&(d=-d),r=d*a/s,n=d):(a<0&&(u=-u),r=u,n=u*s/a),{x:o+r,y:i+n}):{x:0,y:0}},ge=function(t){for(var e=[],r=ve(t)+1,n=0;n<r;n++)e.push([]);for(t.getAllNodes().forEach((function(t){var r=t.data.rank;void 0!==r&&e[r]&&e[r].push(t.id)})),n=0;n<r;n++)e[n]=e[n].sort((function(e,r){return n=t.getNode(e).data.order,o=t.getNode(r).data.order,Number(n)-Number(o);var n,o}));return e},pe=function(t,e,r,n){var o={width:0,height:0};return m(r)&&m(n)&&(o.rank=r,o.order=n),ce(t,"border",o,e)},ve=function(t){var e;return t.getAllNodes().forEach((function(t){var r=t.data.rank;void 0!==r&&(void 0===e||r>e)&&(e=r)})),e||(e=0),e},ye=function(t,e){return t.reduce((function(t,r){return e(t)>e(r)?r:t}))},me=function(t,e,r,n,o,i){n.includes(e.id)||(n.push(e.id),r||i.push(e.id),o(e.id).forEach((function(e){return me(t,e,r,n,o,i)})),r&&i.push(e.id))},we=function(t,e,r,n){var o=Array.isArray(e)?e:[e],i=function(e){return n?t.getSuccessors(e):t.getNeighbors(e)},a=[],s=[];return o.forEach((function(e){if(!t.hasNode(e.id))throw new Error("Graph does not have node: "+e);me(t,e,"post"===r,s,i,a)})),a},xe="edge-label",Ee=function(t){var e={},r=function(n){var o,i,a=t.getNode(n);return a?e[n]?a.data.rank:(e[n]=!0,null===(o=t.getRelatedEdges(n,"out"))||void 0===o||o.forEach((function(t){var e=r(t.target)-t.data.minlen;e&&(void 0===i||e<i)&&(i=e)})),i||(i=0),a.data.rank=i,i):0};t.getAllNodes().filter((function(e){return 0===t.getRelatedEdges(e.id,"in").length})).forEach((function(t){return r(t.id)}))},be=function(t,e){return t.getNode(e.target).data.rank-t.getNode(e.source).data.rank-e.data.minlen},Ne=function(t,e){var r=function(n){e.getRelatedEdges(n,"both").forEach((function(o){var i=o.source,a=n===i?o.target:i;t.hasNode(a)||be(e,o)||(t.addNode({id:a,data:{}}),t.addEdge({id:o.id,source:n,target:a,data:{}}),r(a))}))};return t.getAllNodes().forEach((function(t){return r(t.id)})),t.getAllNodes().length},Me=function(t,e){var r=function(n){var o;null===(o=e.getRelatedEdges(n,"both"))||void 0===o||o.forEach((function(o){var i=o.source,a=n===i?o.target:i;t.hasNode(a)||void 0===e.getNode(a).data.layer&&be(e,o)||(t.addNode({id:a,data:{}}),t.addEdge({id:o.id,source:n,target:a,data:{}}),r(a))}))};return t.getAllNodes().forEach((function(t){return r(t.id)})),t.getAllNodes().length},Se=function(t,e){return ye(e.getAllEdges(),(function(r){return t.hasNode(r.source)!==t.hasNode(r.target)?be(e,r):1/0}))},ke=function(t,e,r){t.getAllNodes().forEach((function(t){var n=e.getNode(t.id);n.data.rank||(n.data.rank=0),n.data.rank+=r}))},Ae=function(t,e){var r=we(t,t.getAllNodes(),"post",!1);(r=r.slice(0,(null==r?void 0:r.length)-1)).forEach((function(r){Re(t,e,r)}))},Re=function(t,e,r){var n=t.getNode(r).data.parent;t.getRelatedEdges(r,"both").find((function(t){return t.target===n||t.source===n})).data.cutvalue=_e(t,e,r)},_e=function(t,e,r){var n=t.getNode(r).data.parent,o=!0,i=e.getRelatedEdges(r,"out").find((function(t){return t.target===n})),a=0;return i||(o=!1,i=e.getRelatedEdges(n,"out").find((function(t){return t.target===r}))),a=i.data.weight,e.getRelatedEdges(r,"both").forEach((function(e){var i=e.source===r,s=i?e.target:e.source;if(s!==n){var u=i===o,d=e.data.weight;if(a+=u?d:-d,Ce(t,r,s)){var h=t.getRelatedEdges(r,"both").find((function(t){return t.source===s||t.target===s})).data.cutvalue;a+=u?-h:h}}})),a},Oe=function(t,e){void 0===e&&(e=t.getAllNodes()[0].id),De(t,{},1,e)},De=function(t,e,r,n,o){var i,a=r,s=r,u=t.getNode(n);return e[n]=!0,null===(i=t.getNeighbors(n))||void 0===i||i.forEach((function(r){e[r.id]||(s=De(t,e,s,r.id,n))})),u.data.low=a,u.data.lim=s++,o?u.data.parent=o:delete u.data.parent,s},Ie=function(t){return t.getAllEdges().find((function(t){return t.data.cutvalue<0}))},Pe=function(t,e,r){var n=r.source,o=r.target;e.getRelatedEdges(n,"out").find((function(t){return t.target===o}))||(n=r.target,o=r.source);var i=t.getNode(n),a=t.getNode(o),s=i,u=!1;i.data.lim>a.data.lim&&(s=a,u=!0);var d=e.getAllEdges().filter((function(e){return u===qe(t.getNode(e.source),s)&&u!==qe(t.getNode(e.target),s)}));return ye(d,(function(t){return be(e,t)}))},ze=function(t,e,r,n){var o=t.getRelatedEdges(r.source,"both").find((function(t){return t.source===r.target||t.target===r.target}));o&&t.removeEdge(o.id),t.addEdge({id:"e".concat(Math.random()),source:n.source,target:n.target,data:{}}),Oe(t),Ae(t,e),Te(t,e)},Te=function(t,e){var r=t.getAllNodes().find((function(t){return!t.data.parent})),n=we(t,r,"pre",!1);(n=n.slice(1)).forEach((function(r){var n=t.getNode(r).data.parent,o=e.getRelatedEdges(r,"out").find((function(t){return t.target===n})),i=!1;!o&&e.hasNode(n)&&(o=e.getRelatedEdges(n,"out").find((function(t){return t.target===r})),i=!0),e.getNode(r).data.rank=(e.hasNode(n)&&e.getNode(n).data.rank||0)+(i?null==o?void 0:o.data.minlen:-(null==o?void 0:o.data.minlen))}))},Ce=function(t,e,r){return t.getRelatedEdges(e,"both").find((function(t){return t.source===r||t.target===r}))},qe=function(t,e){return e.data.low<=t.data.lim&&t.data.lim<=e.data.lim},Le=Ee,je=function(t){!function(t){var e=function(t){var e=new re;return t.getAllNodes().forEach((function(t){e.addNode(o({},t))})),t.getAllEdges().forEach((function(t){var r=e.getRelatedEdges(t.source,"out").find((function(e){return e.target===t.target}));r?e.updateEdgeData(null==r?void 0:r.id,o(o({},r.data),{weight:r.data.weight+t.data.weight||0,minlen:Math.max(r.data.minlen,t.data.minlen||1)})):e.addEdge({id:t.id,source:t.source,target:t.target,data:{weight:t.data.weight||0,minlen:t.data.minlen||1}})})),e}(t);Ee(e);var r,n,i=function(t){var e,r,n=new re({tree:[]}),o=t.getAllNodes()[0],i=t.getAllNodes().length;for(n.addNode(o);Ne(n,t)<i;)e=Se(n,t),r=n.hasNode(e.source)?be(t,e):-be(t,e),ke(n,t,r);return n}(e);for(Oe(i),Ae(i,e);r=Ie(i);)n=Pe(i,e,r),ze(i,e,r,n)}(t)},Fe=function(t,e,r,n,o,i,a){var s=t.getChildren(a);if(null==s?void 0:s.length){var u=pe(t,"_bt"),d=pe(t,"_bb"),h=t.getNode(a);t.setParent(u,a),h.data.borderTop=u,t.setParent(d,a),h.data.borderBottom=d,null==s||s.forEach((function(s){Fe(t,e,r,n,o,i,s.id);var h=s.data.borderTop?s.data.borderTop:s.id,c=s.data.borderBottom?s.data.borderBottom:s.id,l=s.data.borderTop?n:2*n,f=h!==c?1:o-i[a]+1;t.addEdge({id:"e".concat(Math.random()),source:u,target:h,data:{minlen:f,weight:l,nestingEdge:!0}}),t.addEdge({id:"e".concat(Math.random()),source:c,target:d,data:{minlen:f,weight:l,nestingEdge:!0}})})),t.getParent(a)||t.addEdge({id:"e".concat(Math.random()),source:e,target:u,data:{weight:0,minlen:o+i[a]}})}else a!==e&&t.addEdge({id:"e".concat(Math.random()),source:e,target:a,data:{weight:0,minlen:r}})},Ve=function(t,e,r,n,o,i){var a={rank:i,borderType:e,width:0,height:0},s=o.data[e][i-1],u=ce(t,"border",a,r);o.data[e][i]=u,t.setParent(u,n),s&&t.addEdge({id:"e".concat(Math.random()),source:s,target:u,data:{weight:1}})},Be=function(t){t.getAllNodes().forEach((function(t){$e(t)})),t.getAllEdges().forEach((function(t){$e(t)}))},$e=function(t){var e=t.data.width;t.data.width=t.data.height,t.data.height=e},We=function(t){(null==t?void 0:t.y)&&(t.y=-t.y)},Ue=function(t){var e=t.x;t.x=t.y,t.y=e},Ge=function(t){for(var e={},r=t.getAllNodes(),n=r.map((function(t){var e;return null!==(e=t.data.rank)&&void 0!==e?e:-1/0})),o=Math.max.apply(Math,d([],u(n),!1)),i=[],a=0;a<o+1;a++)i.push([]);var s=r.sort((function(e,r){return t.getNode(e.id).data.rank-t.getNode(r.id).data.rank})),h=s.filter((function(e){return void 0!==t.getNode(e.id).data.fixorder})).sort((function(e,r){return t.getNode(e.id).data.fixorder-t.getNode(r.id).data.fixorder}));return null==h||h.forEach((function(r){isNaN(t.getNode(r.id).data.rank)||i[t.getNode(r.id).data.rank].push(r.id),e[r.id]=!0})),null==s||s.forEach((function(r){return t.dfsTree(r.id,(function(t){if(e.hasOwnProperty(t.id))return!0;e[t.id]=!0,isNaN(t.data.rank)||i[t.data.rank].push(t.id)}))})),i},He=function(t,e,r){for(var n=function(t,e){return null==t?void 0:t.reduce((function(t,r,n){return t[r]=e[n],t}),{})}(r,r.map((function(t,e){return e}))),o=e.map((function(e){var r=t.getRelatedEdges(e,"out").map((function(t){return{pos:n[t.target]||0,weight:t.data.weight}}));return null==r?void 0:r.sort((function(t,e){return t.pos-e.pos}))})),i=o.flat().filter((function(t){return void 0!==t})),a=1;a<r.length;)a<<=1;var s=2*a-1;a-=1;var u=Array(s).fill(0,0,s),d=0;return null==i||i.forEach((function(t){if(t){var e=t.pos+a;u[e]+=t.weight;for(var r=0;e>0;)e%2&&(r+=u[e+1]),u[e=e-1>>1]+=t.weight;d+=t.weight*r}})),d},Ye=function(t,e){for(var r=0,n=1;n<(null==e?void 0:e.length);n+=1)r+=He(t,e[n-1],e[n]);return r},Ke=function(t,e){var r,n=0,o=0;t.weight&&(n+=t.barycenter*t.weight,o+=t.weight),e.weight&&(n+=e.barycenter*e.weight,o+=e.weight),t.vs=null===(r=e.vs)||void 0===r?void 0:r.concat(t.vs),t.barycenter=n/o,t.weight=o,t.i=Math.min(e.i,t.i),e.merged=!0};const Je=function(t,e){var r,n,o,i={};return null==t||t.forEach((function(t,e){i[t.v]={i:e,indegree:0,in:[],out:[],vs:[t.v]};var r=i[t.v];void 0!==t.barycenter&&(r.barycenter=t.barycenter,r.weight=t.weight)})),null===(r=e.getAllEdges())||void 0===r||r.forEach((function(t){var e=i[t.source],r=i[t.target];void 0!==e&&void 0!==r&&(r.indegree++,e.out.push(i[t.target]))})),function(t){for(var e,r,n=[],o=function(){var o=t.pop();n.push(o),null===(e=o.in.reverse())||void 0===e||e.forEach((function(t){return(e=o,function(t){t.merged||(void 0===t.barycenter||void 0===e.barycenter||t.barycenter>=e.barycenter)&&Ke(e,t)})(t);var e})),null===(r=o.out)||void 0===r||r.forEach((function(e){return(r=o,function(e){e.in.push(r),0==--e.indegree&&t.push(e)})(e);var r}))};null==t?void 0:t.length;)o();var i=n.filter((function(t){return!t.merged})),a=["vs","i","barycenter","weight"];return i.map((function(t){var e={};return null==a||a.forEach((function(r){void 0!==t[r]&&(e[r]=t[r])})),e}))}(null===(o=(n=Object.values(i)).filter)||void 0===o?void 0:o.call(n,(function(t){return!t.indegree})))};var Xe=function(t,e,r){for(var n,o=r;e.length&&(n=e[e.length-1]).i<=o;)e.pop(),null==t||t.push(n.vs),o++;return o},Qe=function(t,e,r,n,o,i){var a,s,u,d,h=t.getChildren(e).map((function(t){return t.id})),c=t.getNode(e),l=c?c.data.borderLeft:void 0,f=c?c.data.borderRight:void 0,g={};l&&(h=null==h?void 0:h.filter((function(t){return t!==l&&t!==f})));var p=function(t,e){return e.map((function(e){var r=t.getRelatedEdges(e,"in");if(!(null==r?void 0:r.length))return{v:e};var n={sum:0,weight:0};return null==r||r.forEach((function(e){var r=t.getNode(e.source);n.sum+=e.data.weight*r.data.order,n.weight+=e.data.weight})),{v:e,barycenter:n.sum/n.weight,weight:n.weight}}))}(t,h||[]);null==p||p.forEach((function(e){var o;if(null===(o=t.getChildren(e.v))||void 0===o?void 0:o.length){var a=Qe(t,e.v,r,n,i);g[e.v]=a,a.hasOwnProperty("barycenter")&&tr(e,a)}}));var v=Je(p,r);Ze(v,g),null===(a=v.filter((function(t){return t.vs.length>0})))||void 0===a||a.forEach((function(e){var r=t.getNode(e.vs[0]);r&&(e.fixorder=r.data.fixorder,e.order=r.data.order)}));var y=function(t,e,r,n){var o=function(t,e){var r={lhs:[],rhs:[]};return null==t||t.forEach((function(t){var e,o;o=(e=t).hasOwnProperty("fixorder")&&!isNaN(e.fixorder),(n?!o&&e.hasOwnProperty("barycenter"):o||e.hasOwnProperty("barycenter"))?r.lhs.push(t):r.rhs.push(t)})),r}(t),i=o.lhs,a=o.rhs.sort((function(t,e){return-t.i- -e.i})),s=[],u=0,d=0,h=0;null==i||i.sort(function(t,e){return function(r,n){if(void 0!==r.fixorder&&void 0!==n.fixorder)return r.fixorder-n.fixorder;if(r.barycenter<n.barycenter)return-1;if(r.barycenter>n.barycenter)return 1;if(e&&void 0!==r.order&&void 0!==n.order){if(r.order<n.order)return-1;if(r.order>n.order)return 1}return t?n.i-r.i:r.i-n.i}}(!!e,!!r)),h=Xe(s,a,h),null==i||i.forEach((function(t){var e;h+=null===(e=t.vs)||void 0===e?void 0:e.length,s.push(t.vs),u+=t.barycenter*t.weight,d+=t.weight,h=Xe(s,a,h)}));var c={vs:s.flat()};return d&&(c.barycenter=u/d,c.weight=d),c}(v,n,o,i);if(l&&(y.vs=[l,y.vs,f].flat(),null===(s=t.getPredecessors(l))||void 0===s?void 0:s.length)){var m=t.getNode((null===(u=t.getPredecessors(l))||void 0===u?void 0:u[0].id)||""),w=t.getNode((null===(d=t.getPredecessors(f))||void 0===d?void 0:d[0].id)||"");y.hasOwnProperty("barycenter")||(y.barycenter=0,y.weight=0),y.barycenter=(y.barycenter*y.weight+m.data.order+w.data.order)/(y.weight+2),y.weight+=2}return y},Ze=function(t,e){null==t||t.forEach((function(t){var r,n=null===(r=t.vs)||void 0===r?void 0:r.map((function(t){return e[t]?e[t].vs:t}));t.vs=n.flat()}))},tr=function(t,e){void 0!==t.barycenter?(t.barycenter=(t.barycenter*t.weight+e.barycenter*e.weight)/(t.weight+e.weight),t.weight+=e.weight):(t.barycenter=e.barycenter,t.weight=e.weight)},er=function(t){if("object"!=typeof t||null===t)return t;var e,r;if(r=t,Array.isArray?Array.isArray(r):y(r,"Array")){e=[];for(var n=0,o=t.length;n<o;n++)"object"==typeof t[n]&&null!=t[n]?e[n]=er(t[n]):e[n]=t[n]}else for(var i in e={},t)"object"==typeof t[i]&&null!=t[i]?e[i]=er(t[i]):e[i]=t[i];return e};const rr=er;var nr=function(t,e,r){return e.map((function(e){return function(t,e,r){var n=function(t){for(var e;t.hasNode(e="_root".concat(Math.random())););return e}(t),i=new re({tree:[{id:n,children:[],data:{}}]});return t.getAllNodes().forEach((function(a){var s=t.getParent(a.id);(a.data.rank===e||a.data.minRank<=e&&e<=a.data.maxRank)&&(i.hasNode(a.id)||i.addNode(o({},a)),(null==s?void 0:s.id)&&!i.hasNode(null==s?void 0:s.id)&&i.addNode(o({},s)),i.setParent(a.id,(null==s?void 0:s.id)||n),t.getRelatedEdges(a.id,r).forEach((function(e){var r=e.source===a.id?e.target:e.source;i.hasNode(r)||i.addNode(o({},t.getNode(r)));var n=i.getRelatedEdges(r,"out").find((function(t){return t.target===a.id})),s=void 0!==n?n.data.weight:0;n?i.updateEdgeData(n.id,o(o({},n.data),{weight:e.data.weight+s})):i.addEdge({id:e.id,source:r,target:a.id,data:{weight:e.data.weight+s}})})),a.data.hasOwnProperty("minRank")&&i.updateNodeData(a.id,o(o({},a.data),{borderLeft:a.data.borderLeft[e],borderRight:a.data.borderRight[e]})))})),i}(t,e,r)}))},or=function(t,e,r,n){var o=new re;null==t||t.forEach((function(t){for(var i,a=t.getRoots()[0].id,s=Qe(t,a,o,e,r,n),u=0;u<(null===(i=s.vs)||void 0===i?void 0:i.length);u++){var d=t.getNode(s.vs[u]);d&&(d.data.order=u)}!function(t,e,r){var n,o={};null==r||r.forEach((function(r){for(var i,a,s=t.getParent(r);s;){if((i=t.getParent(s.id))?(a=o[i.id],o[i.id]=s.id):(a=n,n=s.id),a&&a!==s.id)return e.addNodes([{id:a,data:{}},{id:s.id,data:{}}]),void e.addEdge({id:"e".concat(a,"-").concat(s.id),source:a,target:s.id,data:{}});s=i}}))}(t,o,s.vs)}))},ir=function(t,e){null==e||e.forEach((function(e){null==e||e.forEach((function(e,r){t.getNode(e).data.order=r}))}))},ar=function(t,e){var r={};function n(e,n,o,i,a){for(var s,u,d,h=n;h<o;h++)d=e[h],(null===(s=t.getNode(d))||void 0===s?void 0:s.data.dummy)&&(null===(u=t.getPredecessors(d))||void 0===u||u.forEach((function(e){var n=t.getNode(e.id);n.data.dummy&&(n.data.order<i||n.data.order>a)&&ur(r,e.id,d)})))}function o(t,e){var r=function(t){return JSON.stringify(t.slice(1))}(t);e.get(r)||(n.apply(void 0,d([],u(t),!1)),e.set(r,!0))}return(null==e?void 0:e.length)&&e.reduce((function(e,r){var n,i=-1,a=0,s=new Map;return null==r||r.forEach((function(u,d){var h;if("border"===(null===(h=t.getNode(u))||void 0===h?void 0:h.data.dummy)){var c=t.getPredecessors(u)||[];c.length&&(n=t.getNode(c[0].id).data.order,o([r,a,d,i,n],s),a=d,i=n)}o([r,a,r.length,n,e.length],s)})),r})),r},sr=function(t,e){var r,n;if(null===(r=t.getNode(e))||void 0===r?void 0:r.data.dummy)return null===(n=t.getPredecessors(e))||void 0===n?void 0:n.find((function(e){return t.getNode(e.id).data.dummy}))},ur=function(t,e,r){var n=e,o=r;if(n>o){var i=n;n=o,o=i}var a=t[n];a||(t[n]=a={}),a[o]=!0},dr=function(t,e,r){var n=e;return n>r&&(n=r),!!t[n]},hr=function(t,e,r,n,i,a){var s=new re,u=cr(n,i,a);return null==e||e.forEach((function(e){var n;null==e||e.forEach((function(e){var i=r[e];if(s.hasNode(i)||s.addNode({id:i,data:{}}),n){var a=r[n],d=s.getRelatedEdges(a,"out").find((function(t){return t.target===i}));d?s.updateEdgeData(d.id,o(o({},d.data),{weight:Math.max(u(t,e,n),d.data.weight||0)})):s.addEdge({id:"e".concat(Math.random()),source:a,target:i,data:{weight:Math.max(u(t,e,n),0)}})}n=e}))})),s};var cr=function(t,e,r){return function(n,o,i){var a=n.getNode(o),s=n.getNode(i),u=0,d=0;if(u+=a.data.width/2,a.data.hasOwnProperty("labelpos"))switch((a.data.labelpos||"").toLowerCase()){case"l":d=-a.data.width/2;break;case"r":d=a.data.width/2}if(d&&(u+=r?d:-d),d=0,u+=(a.data.dummy?e:t)/2,u+=(s.data.dummy?e:t)/2,u+=s.data.width/2,s.data.labelpos)switch((s.data.labelpos||"").toLowerCase()){case"l":d=s.data.width/2;break;case"r":d=-s.data.width/2}return d&&(u+=r?d:-d),d=0,u}},lr=function(t,e){return t.getNode(e).data.width||0},fr=function(t,e){var r,n=le(t);!function(t,e){var r=(e||{}).ranksep,n=void 0===r?0:r,o=ge(t),i=0;null==o||o.forEach((function(e){var r=e.map((function(e){return t.getNode(e).data.height})),o=Math.max.apply(Math,d(d([],u(r),!1),[0],!1));null==e||e.forEach((function(e){t.getNode(e).data.y=i+o/2})),i+=o+n}))}(n,e);var o=function(t,e){var r=e||{},n=r.align,o=void 0===n?"":n,i=r.nodesep,a=void 0===i?0:i,s=r.edgesep,h=void 0===s?0:s,c=ge(t),l=Object.assign(function(t,e){var r={};return(null==e?void 0:e.length)&&e.reduce((function(e,n){var o=0,i=0,a=e.length,s=null==n?void 0:n[(null==n?void 0:n.length)-1];return null==n||n.forEach((function(e,u){var d,h=sr(t,e),c=h?t.getNode(h.id).data.order:a;(h||e===s)&&(null===(d=n.slice(i,u+1))||void 0===d||d.forEach((function(e){var n;null===(n=t.getPredecessors(e))||void 0===n||n.forEach((function(n){var i,a=t.getNode(n.id),s=a.data.order;!(s<o||c<s)||a.data.dummy&&(null===(i=t.getNode(e))||void 0===i?void 0:i.data.dummy)||ur(r,n.id,e)}))})),i=u+1,o=c)})),n})),r}(t,c),ar(t,c)),f={},g=[];["u","d"].forEach((function(e){g="u"===e?c:Object.values(c).reverse(),["l","r"].forEach((function(r){"r"===r&&(g=g.map((function(t){return Object.values(t).reverse()})));var n=("u"===e?t.getPredecessors:t.getSuccessors).bind(t),o=function(t,e,r,n){var o={},i={},a={};return null==e||e.forEach((function(t){null==t||t.forEach((function(t,e){o[t]=t,i[t]=t,a[t]=e}))})),null==e||e.forEach((function(t){var e=-1;null==t||t.forEach((function(t){var s=n(t).map((function(t){return t.id}));if(s.length){s=s.sort((function(t,e){return a[t]-a[e]}));for(var u=(s.length-1)/2,d=Math.floor(u),h=Math.ceil(u);d<=h;++d){var c=s[d];i[t]===t&&e<a[c]&&!dr(r,t,c)&&(i[c]=t,i[t]=o[t]=o[c],e=a[c])}}}))})),{root:o,align:i}}(0,g,l,n),i=function(t,e,r,n,o,i,a){var s,u={},d=hr(t,e,r,o,i,a),h=a?"borderLeft":"borderRight",c=function(t,e){for(var r=d.getAllNodes(),n=r.pop(),o={};n;)o[n.id]?t(n.id):(o[n.id]=!0,r.push(n),r=r.concat(e(n.id))),n=r.pop()};return c((function(t){u[t]=(d.getRelatedEdges(t,"in")||[]).reduce((function(t,e){return Math.max(t,(u[e.source]||0)+e.data.weight)}),0)}),d.getPredecessors.bind(d)),c((function(e){var r=(d.getRelatedEdges(e,"out")||[]).reduce((function(t,e){return Math.min(t,(u[e.target]||0)-e.data.weight)}),Number.POSITIVE_INFINITY),n=t.getNode(e);r!==Number.POSITIVE_INFINITY&&n.data.borderType!==h&&(u[e]=Math.max(u[e],r))}),d.getSuccessors.bind(d)),null===(s=Object.values(n))||void 0===s||s.forEach((function(t){u[t]=u[r[t]]})),u}(t,g,o.root,o.align,a,h,"r"===r);"r"===r&&Object.keys(i).forEach((function(t){return i[t]=-i[t]})),f[e+r]=i}))}));var p=function(t,e){return ye(Object.values(e),(function(e){var r,n=Number.NEGATIVE_INFINITY,o=Number.POSITIVE_INFINITY;return null===(r=Object.keys(e))||void 0===r||r.forEach((function(r){var i=e[r],a=lr(t,r)/2;n=Math.max(i+a,n),o=Math.min(i-a,o)})),n-o}))}(t,f);return p&&function(t,e){var r=Object.values(e),n=Math.min.apply(Math,d([],u(r),!1)),o=Math.max.apply(Math,d([],u(r),!1));["u","d"].forEach((function(r){["l","r"].forEach((function(i){var a,s=r+i,h=t[s];if(h!==e){var c=Object.values(h);(a="l"===i?n-Math.min.apply(Math,d([],u(c),!1)):o-Math.max.apply(Math,d([],u(c),!1)))&&(t[s]={},Object.keys(h).forEach((function(e){t[s][e]=h[e]+a})))}}))}))}(f,p),function(t,e){var r={};return Object.keys(t.ul).forEach((function(n){if(e)r[n]=t[e.toLowerCase()][n];else{var o=Object.values(t).map((function(t){return t[n]}));r[n]=(o[0]+o[1])/2}})),r}(f,o)}(n,e);null===(r=Object.keys(o))||void 0===r||r.forEach((function(t){n.getNode(t).data.x=o[t]}))},gr=function(t,e){var r=e.acyclicer,n=e.ranker,i=e.rankdir,a=void 0===i?"tb":i,s=e.nodeOrder,h=e.keepNodeOrder,c=e.align,l=void 0===c?"":c,f=e.nodesep,g=void 0===f?50:f,p=e.edgesep,v=void 0===p?20:p,y=e.ranksep,m=void 0===y?50:y;Rr(t),de(t,r);var w=function(t){var e=ce(t,"root",{},"_root"),r=function(t){var e={},r=function(n,o){var i=t.getChildren(n);null==i||i.forEach((function(t){return r(t.id,o+1)})),e[n]=o};return t.getRoots().forEach((function(t){return r(t.id,1)})),e}(t),n=Math.max.apply(Math,d([],u(Object.values(r)),!1));Math.abs(n)===1/0&&(n=1);var o=n-1,i=2*o+1;t.getAllEdges().forEach((function(t){t.data.minlen*=i}));var a=function(t){var e=0;return t.getAllEdges().forEach((function(t){e+=t.data.weight})),e}(t)+1;return t.getRoots().forEach((function(n){Fe(t,e,i,a,o,r,n.id)})),{nestingRoot:e,nodeRankFactor:i}}(t),x=w.nestingRoot,E=w.nodeRankFactor;!function(t,e){switch(e){case"network-simplex":je(t);break;case"tight-tree":default:!function(t){!function(t){var e,r={},n=function(o){var i,a,s=t.getNode(o);return s?r[o]?s.data.rank:(r[o]=!0,null===(i=t.getRelatedEdges(o,"out"))||void 0===i||i.forEach((function(t){var e=n(t.target)-t.data.minlen;e&&(void 0===a||e<a)&&(a=e)})),a||(a=0),(void 0===e||a<e)&&(e=a),s.data.rank=a,a):0};t.getAllNodes().filter((function(e){return 0===t.getRelatedEdges(e.id,"in").length})).forEach((function(t){t&&n(t.id)})),void 0===e&&(e=0);var o={},i=function(e,r){var n,a=t.getNode(e),s=isNaN(a.data.layer)?r:a.data.layer;(void 0===a.data.rank||a.data.rank<s)&&(a.data.rank=s),o[e]||(o[e]=!0,null===(n=t.getRelatedEdges(e,"out"))||void 0===n||n.forEach((function(t){i(t.target,s+t.data.minlen)})))};t.getAllNodes().forEach((function(t){var r=t.data;r&&(isNaN(r.layer)?r.rank-=e:i(t.id,r.layer))}))}(t),function(t){var e,r,n=new re({tree:[]}),o=t.getAllNodes()[0],i=t.getAllNodes().length;for(n.addNode(o);Me(n,t)<i;)e=Se(n,t),r=n.hasNode(e.source)?be(t,e):-be(t,e),ke(n,t,r)}(t)}(t);break;case"longest-path":Le(t)}}(le(t),n),xr(t),function(t,e){void 0===e&&(e=0);var r=t.getAllNodes(),n=r.filter((function(t){return void 0!==t.data.rank})).map((function(t){return t.data.rank})),o=Math.min.apply(Math,d([],u(n),!1)),i=[];r.forEach((function(t){var e=(t.data.rank||0)-o;i[e]||(i[e]=[]),i[e].push(t.id)}));for(var a=0,s=0;s<i.length;s++){var h=i[s];void 0===h?s%e!=0&&(a-=1):a&&(null==h||h.forEach((function(e){var r=t.getNode(e);r&&(r.data.rank=r.data.rank||0,r.data.rank+=a)})))}}(t,E),function(t,e){e&&t.removeNode(e),t.getAllEdges().forEach((function(e){e.data.nestingEdge&&t.removeEdge(e.id)}))}(t,x),function(t){var e=t.getAllNodes().filter((function(t){return void 0!==t.data.rank})).map((function(t){return t.data.rank})),r=Math.min.apply(Math,d([],u(e),!1));t.getAllNodes().forEach((function(t){t.data.hasOwnProperty("rank")&&r!==1/0&&(t.data.rank-=r)}))}(t),Er(t),br(t);var b=[];!function(t,e){t.getAllEdges().forEach((function(r){return function(t,e,r){var n=e.source,o=t.getNode(n).data.rank,i=e.target,a=t.getNode(i).data.rank,s=e.data.labelRank;if(a!==o+1){var u,d,h;for(t.removeEdge(e.id),h=0,++o;o<a;++h,++o)e.data.points=[],u=ce(t,"edge",d={originalEdge:e,width:0,height:0,rank:o},"_d"),o===s&&(d.width=e.data.width,d.height=e.data.height,d.dummy=xe,d.labelpos=e.data.labelpos),t.addEdge({id:"e".concat(Math.random()),source:n,target:u,data:{weight:e.data.weight}}),0===h&&r.push(u),n=u;t.addEdge({id:"e".concat(Math.random()),source:n,target:i,data:{weight:e.data.weight}})}}(t,r,e)}))}(t,b),function(t,e){var r=function(t){var e={},r=0,n=function(o){var i=r;t.getChildren(o).forEach((function(t){return n(t.id)})),e[o]={low:i,lim:r++}};return t.getRoots().forEach((function(t){return n(t.id)})),e}(t);e.forEach((function(e){var n,o,i=e,a=t.getNode(i),s=a.data.originalEdge;if(s)for(var u=function(t,e,r,n){var o,i,a,s,u=[],d=[],h=Math.min(e[r].low,e[n].low),c=Math.max(e[r].lim,e[n].lim);a=r;do{a=null===(o=t.getParent(a))||void 0===o?void 0:o.id,u.push(a)}while(a&&(e[a].low>h||c>e[a].lim));for(s=a,a=n;a&&a!==s;)d.push(a),a=null===(i=t.getParent(a))||void 0===i?void 0:i.id;return{lca:s,path:u.concat(d.reverse())}}(t,r,s.source,s.target),d=u.path,h=u.lca,c=0,l=d[c],f=!0;i!==s.target;){if(a=t.getNode(i),f){for(;l!==h&&(null===(n=t.getNode(l))||void 0===n?void 0:n.data.maxRank)<a.data.rank;)l=d[++c];l===h&&(f=!1)}if(!f){for(;c<d.length-1&&(null===(o=t.getNode(d[c+1]))||void 0===o?void 0:o.data.minRank)<=a.data.rank;)c++;l=d[c]}t.hasNode(l)&&t.setParent(i,l),i=t.getSuccessors(i)[0].id}}))}(t,b),function(t){var e=function(r){var n=t.getChildren(r),o=t.getNode(r);if((null==n?void 0:n.length)&&n.forEach((function(t){return e(t.id)})),o.data.hasOwnProperty("minRank")){o.data.borderLeft=[],o.data.borderRight=[];for(var i=o.data.minRank,a=o.data.maxRank+1;i<a;i+=1)Ve(t,"borderLeft","_bl",r,o,i),Ve(t,"borderRight","_br",r,o,i)}};t.getRoots().forEach((function(t){return e(t.id)}))}(t),h&&function(t,e){for(var r=t.getAllNodes().filter((function(e){var r;return!(null===(r=t.getChildren(e.id))||void 0===r?void 0:r.length)})).map((function(t){return t.data.rank})),n=Math.max.apply(Math,d([],u(r),!1)),o=[],i=0;i<n+1;i++)o[i]=[];null==e||e.forEach((function(e){var r=t.getNode(e);r&&!(null==r?void 0:r.data.dummy)&&(isNaN(r.data.rank)||(r.data.fixorder=o[r.data.rank].length,o[r.data.rank].push(e)))}))}(t,s),function(t,e){for(var r=ve(t),n=[],o=[],i=1;i<r+1;i++)n.push(i);for(i=r-1;i>-1;i--)o.push(i);var a=nr(t,n,"in"),s=nr(t,o,"out"),u=Ge(t);ir(t,u);for(var d,h=Number.POSITIVE_INFINITY,c=(i=0,0);c<4;++i,++c)or(i%2?a:s,i%4>=2,!1,e),u=ge(t),(l=Ye(t,u))<h&&(c=0,d=rr(u),h=l);for(u=Ge(t),ir(t,u),i=0,c=0;c<4;++i,++c){var l;or(i%2?a:s,i%4>=2,!0,e),u=ge(t),(l=Ye(t,u))<h&&(c=0,d=rr(u),h=l)}ir(t,d)}(t,h),_r(t),function(t,e){var r=e.toLowerCase();"lr"!==r&&"rl"!==r||Be(t)}(t,a),fr(t,{align:l,nodesep:g,edgesep:v,ranksep:m}),Or(t),Ar(t),function(t,e){e.forEach((function(e){var r,n=t.getNode(e),o=n.data.originalEdge;o&&t.addEdge(o);for(var i=e;n.data.dummy;)r=t.getSuccessors(i)[0],t.removeNode(i),o.data.points.push({x:n.data.x,y:n.data.y}),n.data.dummy===xe&&(o.data.x=n.data.x,o.data.y=n.data.y,o.data.width=n.data.width,o.data.height=n.data.height),i=r.id,n=t.getNode(i)}))}(t,b),Sr(t),function(t,e){var r=e.toLowerCase();"bt"!==r&&"rl"!==r||function(t){t.getAllNodes().forEach((function(t){We(t.data)})),t.getAllEdges().forEach((function(t){var e;null===(e=t.data.points)||void 0===e||e.forEach((function(t){return We(t)})),t.data.hasOwnProperty("y")&&We(t.data)}))}(t),"lr"!==r&&"rl"!==r||(function(t){t.getAllNodes().forEach((function(t){Ue(t.data)})),t.getAllEdges().forEach((function(t){var e;null===(e=t.data.points)||void 0===e||e.forEach((function(t){return Ue(t)})),t.data.hasOwnProperty("x")&&Ue(t.data)}))}(t),Be(t))}(t,a);var N=Nr(t),M=N.width,S=N.height;return Mr(t),kr(t),function(t){t.getAllEdges().forEach((function(e){var r=e.data;if(r.reversed){t.removeEdge(e.id);var n=r.forwardName;delete r.reversed,delete r.forwardName,t.addEdge({id:e.id,source:e.target,target:e.source,data:o(o({},r),{forwardName:n})})}}))}(t),{width:M,height:S}},pr=["width","height","layer","fixorder"],vr={width:0,height:0},yr=["minlen","weight","width","height","labeloffset"],mr={minlen:1,weight:1,width:0,height:0,labeloffset:10,labelpos:"r"},wr=["labelpos"],xr=function(t){t.getAllEdges().forEach((function(e){if(e.data.width&&e.data.height){var r=t.getNode(e.source),n={e,rank:(t.getNode(e.target).data.rank-r.data.rank)/2+r.data.rank};ce(t,"edge-proxy",n,"_ep")}}))},Er=function(t){var e=0;return t.getAllNodes().forEach((function(r){var n,o;r.data.borderTop&&(r.data.minRank=null===(n=t.getNode(r.data.borderTop))||void 0===n?void 0:n.data.rank,r.data.maxRank=null===(o=t.getNode(r.data.borderBottom))||void 0===o?void 0:o.data.rank,e=Math.max(e,r.data.maxRank||-1/0))})),e},br=function(t){t.getAllNodes().forEach((function(e){"edge-proxy"===e.data.dummy&&(t.getEdge(e.data.e.id).data.labelRank=e.data.rank,t.removeNode(e.id))}))},Nr=function(t,e){var r,n,o=0,i=0,a=e||{},s=a.marginx,u=void 0===s?0:s,d=a.marginy,h=void 0===d?0:d,c=function(t){if(t.data){var e=t.data.x,a=t.data.y,s=t.data.width,u=t.data.height;isNaN(e)||isNaN(s)||(void 0===r&&(r=e-s/2),r=Math.min(r,e-s/2),o=Math.max(o,e+s/2)),isNaN(a)||isNaN(u)||(void 0===n&&(n=a-u/2),n=Math.min(n,a-u/2),i=Math.max(i,a+u/2))}};return t.getAllNodes().forEach((function(t){c(t)})),t.getAllEdges().forEach((function(t){(null==t?void 0:t.data.hasOwnProperty("x"))&&c(t)})),r-=u,n-=h,t.getAllNodes().forEach((function(t){t.data.x-=r,t.data.y-=n})),t.getAllEdges().forEach((function(t){var e;null===(e=t.data.points)||void 0===e||e.forEach((function(t){t.x-=r,t.y-=n})),t.data.hasOwnProperty("x")&&(t.data.x-=r),t.data.hasOwnProperty("y")&&(t.data.y-=n)})),{width:o-r+u,height:i-n+h}},Mr=function(t){t.getAllEdges().forEach((function(e){var r,n,o=t.getNode(e.source),i=t.getNode(e.target);e.data.points?(r=e.data.points[0],n=e.data.points[e.data.points.length-1]):(e.data.points=[],r={x:i.data.x,y:i.data.y},n={x:o.data.x,y:o.data.y}),e.data.points.unshift(fe(o.data,r)),e.data.points.push(fe(i.data,n))}))},Sr=function(t){t.getAllEdges().forEach((function(t){if(t.data.hasOwnProperty("x"))switch("l"!==t.data.labelpos&&"r"!==t.data.labelpos||(t.data.width-=t.data.labeloffset),t.data.labelpos){case"l":t.data.x-=t.data.width/2+t.data.labeloffset;break;case"r":t.data.x+=t.data.width/2+t.data.labeloffset}}))},kr=function(t){t.getAllEdges().forEach((function(t){var e;t.data.reversed&&(null===(e=t.data.points)||void 0===e||e.reverse())}))},Ar=function(t){t.getAllNodes().forEach((function(e){var r,n,o;if(null===(r=t.getChildren(e.id))||void 0===r?void 0:r.length){var i=t.getNode(e.id),a=t.getNode(i.data.borderTop),s=t.getNode(i.data.borderBottom),u=t.getNode(i.data.borderLeft[(null===(n=i.data.borderLeft)||void 0===n?void 0:n.length)-1]),d=t.getNode(i.data.borderRight[(null===(o=i.data.borderRight)||void 0===o?void 0:o.length)-1]);i.data.width=Math.abs((null==d?void 0:d.data.x)-(null==u?void 0:u.data.x))||10,i.data.height=Math.abs((null==s?void 0:s.data.y)-(null==a?void 0:a.data.y))||10,i.data.x=((null==u?void 0:u.data.x)||0)+i.data.width/2,i.data.y=((null==a?void 0:a.data.y)||0)+i.data.height/2}})),t.getAllNodes().forEach((function(e){"border"===e.data.dummy&&t.removeNode(e.id)}))},Rr=function(t){t.getAllEdges().forEach((function(e){if(e.source===e.target){var r=t.getNode(e.source);r.data.selfEdges||(r.data.selfEdges=[]),r.data.selfEdges.push(e),t.removeEdge(e.id)}}))},_r=function(t){var e=ge(t);null==e||e.forEach((function(e){var r=0;null==e||e.forEach((function(e,n){var o,i=t.getNode(e);i.data.order=n+r,null===(o=i.data.selfEdges)||void 0===o||o.forEach((function(e){ce(t,"selfedge",{width:e.data.width,height:e.data.height,rank:i.data.rank,order:n+ ++r,e},"_se")})),delete i.data.selfEdges}))}))},Or=function(t){t.getAllNodes().forEach((function(e){var r=t.getNode(e.id);if("selfedge"===r.data.dummy){var n=t.getNode(r.data.e.source),o=n.data.x+n.data.width/2,i=n.data.y,a=r.data.x-o,s=n.data.height/2;t.hasEdge(r.data.e.id)?t.updateEdgeData(r.data.e.id,r.data.e.data):t.addEdge({id:r.data.e.id,source:r.data.e.source,target:r.data.e.target,data:r.data.e.data}),t.removeNode(e.id),r.data.e.data.points=[{x:o+2*a/3,y:i-s},{x:o+5*a/6,y:i-s},{y:i,x:o+a},{x:o+5*a/6,y:i+s},{x:o+2*a/3,y:i+s}],r.data.e.data.x=r.data.x,r.data.e.data.y=r.data.y}}))},Dr=function(t,e){var r={};return null==e||e.forEach((function(e){void 0!==t[e]&&(r[e]=+t[e])})),r},Ir=function(t){void 0===t&&(t={});var e={};return Object.keys(t).forEach((function(r){e[r.toLowerCase()]=t[r]})),e},Pr={rankdir:"TB",nodesep:50,ranksep:50,edgeLabelSpace:!0,controlPoints:!1,radial:!1,focusNode:null},zr=function(){function t(t){void 0===t&&(t={}),this.options=t,this.id="dagre",this.layoutNode=function(t){return!1!==t.data.layout},this.options=o(o({},Pr),t)}return t.prototype.execute=function(t,e){return a(this,void 0,void 0,(function(){return s(this,(function(r){return[2,this.genericDagreLayout(!1,t,e)]}))}))},t.prototype.assign=function(t,e){return a(this,void 0,void 0,(function(){return s(this,(function(r){switch(r.label){case 0:return[4,this.genericDagreLayout(!0,t,e)];case 1:return r.sent(),[2]}}))}))},t.prototype.genericDagreLayout=function(t,e,r){return a(this,void 0,void 0,(function(){var n,i,a,u,d,h,c,l,f,g,p,v,y,w,x,E,b,N,M,S,k,A,R,_,O,I,P,T,q,L,j,F=this;return s(this,(function(s){return n=o(o({},this.options),r),i=n.nodeSize,a=n.rankdir,u=void 0===a?"TB":a,d=n.ranksep,h=n.nodesep,c=n.ranksepFunc,l=n.nodesepFunc,f=n.edgeLabelSpace,g=n.nodeOrder,p=n.begin,v=n.controlPoints,y=new re({tree:[]}),w=z(d||50,c),x=z(h||50,l),E=x,b=w,"LR"!==u&&"RL"!==u||(E=w,b=x),N=C(i,void 0),M=e.getAllNodes(),S=e.getAllEdges(),M.filter((function(t){return!1!==t.data.layout})).forEach((function(t){var e=N(t),r=b(t),n=e+2*E(t),o=e+2*r,i=t.data.layer;m(i)?y.addNode({id:t.id,data:{width:n,height:o,layer:i}}):y.addNode({id:t.id,data:{width:n,height:o}})})),S.forEach((function(t){F.layoutNode(y.getNode(t.source))&&F.layoutNode(y.getNode(t.target))&&y.addEdge({id:t.id,source:t.source,target:t.target,data:{weight:t.data.weight||1}})})),function(t,e){var r,n,i=e.edgeLabelSpace,a=e.keepNodeOrder,s=e.prevGraph,u=e.rankdir,d=e.ranksep;!a&&s&&(n=s,(r=t).getAllNodes().forEach((function(t){var e=r.getNode(t.id),o=n.getNode(t.id);void 0!==o?(e.data.fixorder=o.data._order,delete o.data._order):delete e.data.fixorder})));var h=function(t){var e=new re({tree:[]});return t.getAllNodes().forEach((function(r){var n=Ir(t.getNode(r.id).data),i=o(o({},vr),n),a=Dr(i,pr);e.hasNode(r.id)||e.addNode({id:r.id,data:o({},a)});var s=t.getParent(r.id);null==s||(e.hasNode(s.id)||e.addNode(o({},s)),e.setParent(r.id,s.id))})),t.getAllEdges().forEach((function(r){var n=Ir(t.getEdge(r.id).data),o={};null==wr||wr.forEach((function(t){void 0!==n[t]&&(o[t]=n[t])})),e.addEdge({id:r.id,source:r.source,target:r.target,data:Object.assign({},mr,Dr(n,yr),o)})})),e}(t);!1!==i&&(e.ranksep=function(t,e){var r=e.ranksep,n=void 0===r?0:r,o=e.rankdir;return t.getAllNodes().forEach((function(t){isNaN(t.data.layer)||t.data.layer||(t.data.layer=0)})),t.getAllEdges().forEach((function(t){var e;t.data.minlen*=2,"c"!==(null===(e=t.data.labelpos)||void 0===e?void 0:e.toLowerCase())&&("TB"===o||"BT"===o?t.data.width+=t.data.labeloffset:t.data.height+=t.data.labeloffset)})),n/2}(h,{rankdir:u,ranksep:d}));try{gr(h,e)}catch(t){if("Not possible to find intersection inside of the rectangle"===t.message)return void 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:\n",t);throw t}!function(t,e){t.getAllNodes().forEach((function(r){var n,o=t.getNode(r.id);if(o){var i=e.getNode(r.id);o.data.x=i.data.x,o.data.y=i.data.y,o.data._order=i.data.order,o.data._rank=i.data.rank,(null===(n=e.getChildren(r.id))||void 0===n?void 0:n.length)&&(o.data.width=i.data.width,o.data.height=i.data.height)}})),t.getAllEdges().forEach((function(r){var n=t.getEdge(r.id),o=e.getEdge(r.id);n.data.points=o?o.data.points:[],o&&o.data.hasOwnProperty("x")&&(n.data.x=o.data.x,n.data.y=o.data.y)}))}(t,h)}(y,{prevGraph:null,edgeLabelSpace:f,keepNodeOrder:!!g,nodeOrder:g||[],acyclicer:"greedy",ranker:"network-simplex",rankdir:u,nodesep:h}),k=[0,0],p&&(A=1/0,R=1/0,y.getAllNodes().forEach((function(t){A>t.data.x&&(A=t.data.x),R>t.data.y&&(R=t.data.y)})),y.getAllEdges().forEach((function(t){var e;null===(e=t.data.points)||void 0===e||e.forEach((function(t){A>t.x&&(A=t.x),R>t.y&&(R=t.y)}))})),k[0]=p[0]-A,k[1]=p[1]-R),_="LR"===u||"RL"===u,O=new Set,I="BT"===u||"RL"===u?function(t,e){return e-t}:function(t,e){return t-e},y.getAllNodes().forEach((function(t){t.data.x=t.data.x+k[0],t.data.y=t.data.y+k[1],O.add(_?t.data.x:t.data.y)})),P=Array.from(O).sort(I),T=_?function(t,e){return t.x!==e.x}:function(t,e){return t.y!==e.y},q=_?function(t,e,r){var n=Math.max(e.y,r.y),o=Math.min(e.y,r.y);return t.filter((function(t){return t.y<=n&&t.y>=o}))}:function(t,e,r){var n=Math.max(e.x,r.x),o=Math.min(e.x,r.x);return t.filter((function(t){return t.x<=n&&t.x>=o}))},y.getAllEdges().forEach((function(t,e){var r;f&&v&&"loop"!==t.data.type&&(t.data.controlPoints=Tr(t.data.points,y.getNode(t.source),y.getNode(t.target),P,_,T,q),null===(r=t.data.controlPoints)||void 0===r||r.forEach((function(t){t.x+=k[0],t.y+=k[1]})))})),L=[],L=y.getAllNodes().map((function(t){return D(t)})),j=y.getAllEdges(),t&&(L.forEach((function(t){e.mergeNodeData(t.id,{x:t.data.x,y:t.data.y})})),j.forEach((function(t){e.mergeEdgeData(t.id,{controlPoints:t.data.controlPoints})}))),[2,{nodes:L,edges:j}]}))}))},t}(),Tr=function(t,e,r,n,o,i,a){var s=(null==t?void 0:t.slice(1,t.length-1))||[];if(e&&r){var u=e.data,d=u.x,h=u.y,c=r.data,l=c.x,f=c.y;if(o&&(d=e.data.y,h=e.data.x,l=r.data.y,f=r.data.x),f!==h&&d!==l){var g=n.indexOf(h),p=n[g+1];if(p){var v=s[0],y=o?{x:(h+p)/2,y:(null==v?void 0:v.y)||l}:{x:(null==v?void 0:v.x)||l,y:(h+p)/2};v&&!i(v,y)||s.unshift(y)}var m=n.indexOf(f),w=Math.abs(m-g);if(1===w)(s=a(s,e.data,r.data)).length||s.push(o?{x:(h+f)/2,y:d}:{x:d,y:(h+f)/2});else if(w>1){var x=n[m-1];if(x){var E=s[s.length-1],b=o?{x:(f+x)/2,y:(null==E?void 0:E.y)||l}:{x:(null==E?void 0:E.x)||d,y:(f+x)/2};E&&!i(E,b)||s.push(b)}}}}return s};function Cr(t){var e=0,r=0,n=0;if(t.length){for(var o=0;o<4;o++)(i=t[o])&&i.weight&&(e+=i.weight,r+=i.x*i.weight,n+=i.y*i.weight);t.x=r/e,t.y=n/e,t.weight=e}else{var i=t;t.x=i.data.x,t.y=i.data.y,t.weight=i.data.weight}}var qr=function(t,e,r,n,o,i){var a=i.x-t.x||.1,s=i.y-t.y||.1,u=n-e,d=a*a+s*s,h=Math.sqrt(d)*d;if(u*u*.81<d){var c=t.weight/h;return i.vx+=a*c,i.vy+=s*c,!0}if(t.length)return!1;t.data!==i&&(c=t.data.weight/h,i.vx+=a*c,i.vy+=s*c)},Lr={maxIteration:500,gravity:10,factor:1,edgeStrength:200,nodeStrength:1e3,coulombDisScale:.005,damping:.9,maxSpeed:500,minMovement:.4,interval:.02,linkDistance:200,clusterNodeStrength:20,preventOverlap:!0,distanceThresholdMode:"mean"},jr=function(){function t(t){void 0===t&&(t={}),this.options=t,this.id="force",this.timeInterval=0,this.judgingDistance=0,this.running=!1,this.options=o(o({},Lr),t)}return t.prototype.execute=function(t,e){return a(this,void 0,void 0,(function(){return s(this,(function(r){return[2,this.genericForceLayout(!1,t,e)]}))}))},t.prototype.assign=function(t,e){return a(this,void 0,void 0,(function(){return s(this,(function(r){return this.genericForceLayout(!0,t,e),[2]}))}))},t.prototype.stop=function(){this.timeInterval&&"undefined"!=typeof window&&window.clearInterval(this.timeInterval),this.running=!1},t.prototype.tick=function(t){var e=this;if(void 0===t&&(t=this.options.maxIteration||1),this.lastResult)return this.lastResult;for(var r=0;(this.judgingDistance>this.lastOptions.minMovement||r<1)&&r<t;r++)this.runOneStep(this.lastCalcGraph,this.lastGraph,r,this.lastVelMap,this.lastOptions),this.updatePosition(this.lastGraph,this.lastCalcGraph,this.lastVelMap,this.lastOptions);var n={nodes:this.lastLayoutNodes,edges:this.lastLayoutEdges};return this.lastAssign&&n.nodes.forEach((function(t){return e.lastGraph.mergeNodeData(t.id,{x:t.data.x,y:t.data.y})})),n},t.prototype.genericForceLayout=function(t,e,r){return a(this,void 0,void 0,(function(){var n,i,a,u,d,h,c,l,f,g,p,v,y,w,x,E,b,N,M,S=this;return s(this,(function(s){return n=o(o({},this.options),r),i=e.getAllNodes(),a=e.getAllEdges(),u=this.formatOptions(n,e),d=u.width,h=u.height,c=u.nodeSize,l=u.getMass,f=u.nodeStrength,g=u.edgeStrength,p=u.linkDistance,v=i.map((function(t){return o(o({},t),{data:o(o({},t.data),{x:m(t.data.x)?t.data.x:Math.random()*d,y:m(t.data.y)?t.data.y:Math.random()*h,size:c(t)||30,mass:l(t),nodeStrength:f(t)})})})),y=a.map((function(t){return o(o({},t),{data:o(o({},t.data),{edgeStrength:g(t),linkDistance:p(t,e.getNode(t.source),e.getNode(t.target))})})})),(null==i?void 0:i.length)?(w={},i.forEach((function(t,e){w[t.id]={x:0,y:0}})),x=new re({nodes:v,edges:y}),this.formatCentripetal(u,x),E=u.maxIteration,b=u.minMovement,N=u.onTick,this.lastLayoutNodes=v,this.lastLayoutEdges=y,this.lastAssign=t,this.lastGraph=e,this.lastCalcGraph=x,this.lastOptions=u,this.lastVelMap=w,"undefined"==typeof window?[2]:(M=0,[2,new Promise((function(r){S.timeInterval=window.setInterval((function(){i&&S.running||r({nodes:Wr(e,v),edges:a}),S.runOneStep(x,e,M,w,u),S.updatePosition(e,x,w,u),t&&v.forEach((function(t){return e.mergeNodeData(t.id,{x:t.data.x,y:t.data.y})})),null==N||N({nodes:Wr(e,v),edges:a}),(++M>=E||S.judgingDistance<b)&&(window.clearInterval(S.timeInterval),r({nodes:Wr(e,v),edges:a}))}),0),S.running=!0}))])):(this.lastResult={nodes:[],edges:a},[2,{nodes:[],edges:a}])}))}))},t.prototype.formatOptions=function(t,e){var r=t,n=t.width,o=t.height,i=t.getMass;if(r.width=n||"undefined"==typeof window?n:window.innerWidth,r.height=o||"undefined"==typeof window?o:window.innerHeight,t.center||(r.center=[r.width/2,r.height/2]),i||(r.getMass=function(t){var r=1;m(null==t?void 0:t.data.mass)&&(r=null==t?void 0:t.data.mass);var n=e.getDegree(t.id,"both");return!n||n<5?r:5*n*r}),t.preventOverlap){var a=z(0,t.nodeSpacing);t.nodeSize?g(t.nodeSize)?r.nodeSize=function(e){var r=t.nodeSize;return Math.max(r[0],r[1])+a(e)}:r.nodeSize=function(e){return t.nodeSize+a(e)}:r.nodeSize=function(t){var e=((null==t?void 0:t.data)||{}).size;return e?g(e)?Math.max(e[0],e[1])+a(t):P(e)?Math.max(e.width,e.height)+a(t):e+a(t):10+a(t)}}return r.linkDistance=t.linkDistance?z(1,t.linkDistance):function(t){return 1+r.nodeSize(e.getNode(t.source))+r.nodeSize(e.getNode(t.target))},r.nodeStrength=z(1,t.nodeStrength),r.edgeStrength=z(1,t.edgeStrength),t},t.prototype.formatCentripetal=function(t,e){var r,n=t.centripetalOptions,o=t.center,i=t.clusterNodeStrength,a=t.leafCluster,s=t.clustering,u=t.nodeClusterBy,d=e.getAllNodes(),h=n||{leaf:2,single:2,others:1,center:function(t){return{x:o[0],y:o[1]}}};"function"!=typeof i&&(t.clusterNodeStrength=function(t){return i});var c=[];if(a&&u&&(r=Fr(e,u),c=Array.from(new Set(null==d?void 0:d.map((function(t){return t.data[u]}))))||[],t.centripetalOptions=Object.assign(h,{single:100,leaf:function(e){var n=r[e.id]||{},o=n.siblingLeaves,i=n.sameTypeLeaves;return(null==i?void 0:i.length)===(null==o?void 0:o.length)||1===(null==c?void 0:c.length)?1:t.clusterNodeStrength(e)},others:1,center:function(t){var n,o=e.getDegree(t.id,"both");if(!o)return{x:100,y:100};if(1===o){var i=(r[t.id]||{}).sameTypeLeaves,a=void 0===i?[]:i;1===a.length?n=void 0:a.length>1&&(n=$r(a))}else n=void 0;return{x:null==n?void 0:n.x,y:null==n?void 0:n.y}}})),s&&u){r||(r=Fr(e,u)),c||(c=Array.from(new Set(d.map((function(t){return t.data[u]}))))),c=c.filter((function(t){return void 0!==t}));var l={};c.forEach((function(t){var r=d.filter((function(e){return e.data[u]===t})).map((function(t){return e.getNode(t.id)}));l[t]=$r(r)})),t.centripetalOptions=Object.assign(h,{single:function(e){return t.clusterNodeStrength(e)},leaf:function(e){return t.clusterNodeStrength(e)},others:function(e){return t.clusterNodeStrength(e)},center:function(t){var e=l[t.data[u]];return{x:null==e?void 0:e.x,y:null==e?void 0:e.y}}})}var f=t.centripetalOptions||{},g=f.leaf,p=f.single,v=f.others;g&&"function"!=typeof g&&(t.centripetalOptions.leaf=function(){return g}),p&&"function"!=typeof p&&(t.centripetalOptions.single=function(){return p}),v&&"function"!=typeof v&&(t.centripetalOptions.others=function(){return v})},t.prototype.runOneStep=function(t,e,r,n,o){var i={},a=t.getAllNodes(),s=t.getAllEdges();if(null==a?void 0:a.length){var u=o.monitor;this.calRepulsive(t,i,o),s&&this.calAttractive(t,i),this.calGravity(t,e,i,o),this.updateVelocity(t,i,n,o),u&&u({energy:this.calTotalEnergy(i,a),nodes:e.getAllNodes(),edges:e.getAllEdges(),iterations:r})}},t.prototype.calTotalEnergy=function(t,e){if(!(null==e?void 0:e.length))return 0;var r=0;return e.forEach((function(e,n){var o=t[e.id].x,i=t[e.id].y,a=o*o+i*i,s=e.data.mass;r+=(void 0===s?1:s)*a*.5})),r},t.prototype.calRepulsive=function(t,e,r){var n=r.factor,o=r.coulombDisScale;!function(t,e,r,n){var o=e/r,i=t.getAllNodes(),a=i.map((function(t,e){var r=t.data,n=r.nodeStrength;return{x:r.x,y:r.y,size:r.size,index:e,vx:0,vy:0,weight:o*n}})),s=tt(a,(function(t){return t.x}),(function(t){return t.y})).visitAfter(Cr);a.forEach((function(t){!function(t,e){e.visit((function(e,r,n,o,i){return qr(e,r,n,o,i,t)}))}(t,s)})),a.map((function(t,e){var r=i[e],o=r.id,a=r.data.mass,s=void 0===a?1:a;n[o]={x:t.vx/s,y:t.vy/s}}))}(t,n,o*o,e)},t.prototype.calAttractive=function(t,e){t.getAllEdges().forEach((function(r,n){var o=r.source,i=r.target,a=t.getNode(o),s=t.getNode(i);if(a&&s){var u=s.data.x-a.data.x,d=s.data.y-a.data.y;u||d||(u=.01*Math.random(),d=.01*Math.random());var h=Math.sqrt(u*u+d*d),c=u/h,l=d/h,f=r.data||{},g=f.linkDistance,p=void 0===g?200:g,v=f.edgeStrength,y=(p-h)*(void 0===v?200:v),m=1/(a.data.mass||1),w=1/(s.data.mass||1),x=c*y,E=l*y;e[o].x-=x*m,e[o].y-=E*m,e[i].x+=x*w,e[i].y+=E*w}}))},t.prototype.calGravity=function(t,e,r,n){var o=n.getCenter,i=t.getAllNodes(),a=e.getAllNodes(),s=e.getAllEdges(),d=n.width,h=n.height,c=n.center,l=n.gravity,f=n.centripetalOptions;i&&i.forEach((function(n){var i=n.id,g=n.data,p=g.mass,v=g.x,y=g.y,w=e.getNode(i),x=0,E=0,b=l,N=t.getDegree(i,"in"),M=t.getDegree(i,"out"),S=t.getDegree(i,"both"),k=null==o?void 0:o(w,S);if(k){var A=u(k,3);x=v-A[0],E=y-A[1],b=A[2]}else x=v-c[0],E=y-c[1];if(b&&(r[i].x-=b*x/p,r[i].y-=b*E/p),f){var R=f.leaf,_=f.single,O=f.others,D=f.center,I=(null==D?void 0:D(w,a,s,d,h))||{x:0,y:0,centerStrength:0},P=I.x,z=I.y,T=I.centerStrength;if(!m(P)||!m(z))return;var C=(v-P)/p,q=(y-z)/p;if(T&&(r[i].x-=T*C,r[i].y-=T*q),0===S){var L=_(w);if(!L)return;return r[i].x-=L*C,void(r[i].y-=L*q)}if(0===N||0===M){var j=R(w,a,s);if(!j)return;return r[i].x-=j*C,void(r[i].y-=j*q)}var F=O(w);if(!F)return;r[i].x-=F*C,r[i].y-=F*q}}))},t.prototype.updateVelocity=function(t,e,r,n){var o=n.damping,i=n.maxSpeed,a=n.interval,s=t.getAllNodes();(null==s?void 0:s.length)&&s.forEach((function(t){var n=t.id,s=(r[n].x+e[n].x*a)*o||.01,u=(r[n].y+e[n].y*a)*o||.01,d=Math.sqrt(s*s+u*u);if(d>i){var h=i/d;s*=h,u*=h}r[n]={x:s,y:u}}))},t.prototype.updatePosition=function(t,e,r,n){var o=this,i=n.distanceThresholdMode,a=n.interval,s=e.getAllNodes();if(null==s?void 0:s.length){var u=0;"max"===i?this.judgingDistance=-1/0:"min"===i&&(this.judgingDistance=1/0),s.forEach((function(n){var s=n.id,d=t.getNode(s);if(m(d.data.fx)&&m(d.data.fy))e.mergeNodeData(s,{x:d.data.fx,y:d.data.fy});else{var h=r[s].x*a,c=r[s].y*a;e.mergeNodeData(s,{x:n.data.x+h,y:n.data.y+c});var l=Math.sqrt(h*h+c*c);switch(i){case"max":o.judgingDistance<l&&(o.judgingDistance=l);break;case"min":o.judgingDistance>l&&(o.judgingDistance=l);break;default:u+=l}}})),i&&"mean"!==i||(this.judgingDistance=u/s.length)}else this.judgingDistance=0},t}(),Fr=function(t,e){var r=t.getAllNodes();if(!(null==r?void 0:r.length))return{};var n={};return r.forEach((function(r,o){1===t.getDegree(r.id,"both")&&(n[r.id]=Vr(t,"leaf",r,e))})),n},Vr=function(t,e,r,n){var o=t.getDegree(r.id,"in"),i=t.getDegree(r.id,"out"),a=r,s=[];return 0===o?(a=t.getSuccessors(r.id)[0],s=t.getNeighbors(a.id)):0===i&&(a=t.getPredecessors(r.id)[0],s=t.getNeighbors(a.id)),s=s.filter((function(e){return 0===t.getDegree(e.id,"in")||0===t.getDegree(e.id,"out")})),{coreNode:a,siblingLeaves:s,sameTypeLeaves:Br(t,e,n,r,s)}},Br=function(t,e,r,n,o){var i=n.data[r]||"",a=(null==o?void 0:o.filter((function(t){return t.data[r]===i})))||[];return"leaf"===e&&(a=a.filter((function(e){return 0===t.getDegree(e.id,"in")||0===t.getDegree(e.id,"out")}))),a},$r=function(t){var e={x:0,y:0};t.forEach((function(t){var r=t.data,n=r.x,o=r.y;e.x+=n||0,e.y+=o||0}));var r=t.length||1;return{x:e.x/r,y:e.y/r}},Wr=function(t,e){return e.map((function(e){var r=e.id,n=e.data,i=t.getNode(r);return o(o({},i),{data:o(o({},i.data),{x:n.x,y:n.y})})}))},Ur=function(){function t(t){this.id=t.id||0,this.rx=t.rx,this.ry=t.ry,this.fx=0,this.fy=0,this.mass=t.mass,this.degree=t.degree,this.g=t.g||0}return t.prototype.distanceTo=function(t){var e=this.rx-t.rx,r=this.ry-t.ry;return Math.hypot(e,r)},t.prototype.setPos=function(t,e){this.rx=t,this.ry=e},t.prototype.resetForce=function(){this.fx=0,this.fy=0},t.prototype.addForce=function(t){var e=t.rx-this.rx,r=t.ry-this.ry,n=Math.hypot(e,r);n=n<1e-4?1e-4:n;var o=this.g*(this.degree+1)*(t.degree+1)/n;this.fx+=o*e/n,this.fy+=o*r/n},t.prototype.in=function(t){return t.contains(this.rx,this.ry)},t.prototype.add=function(e){var r=this.mass+e.mass;return new t({rx:(this.rx*this.mass+e.rx*e.mass)/r,ry:(this.ry*this.mass+e.ry*e.mass)/r,mass:r,degree:this.degree+e.degree})},t}();const Gr=Ur;const Hr=function(){function t(t){this.xmid=t.xmid,this.ymid=t.ymid,this.length=t.length,this.massCenter=t.massCenter||[0,0],this.mass=t.mass||1}return t.prototype.getLength=function(){return this.length},t.prototype.contains=function(t,e){var r=this.length/2;return t<=this.xmid+r&&t>=this.xmid-r&&e<=this.ymid+r&&e>=this.ymid-r},t.prototype.NW=function(){return new t({xmid:this.xmid-this.length/4,ymid:this.ymid+this.length/4,length:this.length/2})},t.prototype.NE=function(){return new t({xmid:this.xmid+this.length/4,ymid:this.ymid+this.length/4,length:this.length/2})},t.prototype.SW=function(){return new t({xmid:this.xmid-this.length/4,ymid:this.ymid-this.length/4,length:this.length/2})},t.prototype.SE=function(){return new t({xmid:this.xmid+this.length/4,ymid:this.ymid-this.length/4,length:this.length/2})},t}(),Yr=function(){function t(t){this.body=null,this.quad=null,this.NW=null,this.NE=null,this.SW=null,this.SE=null,this.theta=.5,null!=t&&(this.quad=t)}return t.prototype.insert=function(e){null!=this.body?this._isExternal()?(this.quad&&(this.NW=new t(this.quad.NW()),this.NE=new t(this.quad.NE()),this.SW=new t(this.quad.SW()),this.SE=new t(this.quad.SE())),this._putBody(this.body),this._putBody(e),this.body=this.body.add(e)):(this.body=this.body.add(e),this._putBody(e)):this.body=e},t.prototype._putBody=function(t){this.quad&&(t.in(this.quad.NW())&&this.NW?this.NW.insert(t):t.in(this.quad.NE())&&this.NE?this.NE.insert(t):t.in(this.quad.SW())&&this.SW?this.SW.insert(t):t.in(this.quad.SE())&&this.SE&&this.SE.insert(t))},t.prototype._isExternal=function(){return null==this.NW&&null==this.NE&&null==this.SW&&null==this.SE},t.prototype.updateForce=function(t){null!=this.body&&t!==this.body&&(this._isExternal()||(this.quad?this.quad.getLength():0)/this.body.distanceTo(t)<this.theta?t.addForce(this.body):(this.NW&&this.NW.updateForce(t),this.NE&&this.NE.updateForce(t),this.SW&&this.SW.updateForce(t),this.SE&&this.SE.updateForce(t)))},t}();var Kr={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},Jr=function(){function t(t){void 0===t&&(t={}),this.options=t,this.id="forceAtlas2",this.options=o(o({},Kr),t)}return t.prototype.execute=function(t,e){return a(this,void 0,void 0,(function(){return s(this,(function(r){return[2,this.genericForceAtlas2Layout(!1,t,e)]}))}))},t.prototype.assign=function(t,e){return a(this,void 0,void 0,(function(){return s(this,(function(r){return this.genericForceAtlas2Layout(!0,t,e),[2]}))}))},t.prototype.genericForceAtlas2Layout=function(t,e,r){return a(this,void 0,void 0,(function(){var n,i,a,u,d,h,c,l,f,g,p,v,y,m,w,x,E,b,N,M,S,k;return s(this,(function(s){if(n=e.getAllEdges(),i=e.getAllNodes(),a=this.formatOptions(r,i.length),u=a.width,d=a.height,h=a.prune,c=a.maxIteration,l=a.nodeSize,f=a.center,!(null==i?void 0:i.length)||1===i.length)return[2,q(e,t,f)];if(g=i.map((function(t){return D(t,[u,d])})),p=n.filter((function(t){return t.source!==t.target})),v=new re({nodes:g,edges:p}),y=this.getSizes(v,e,l),this.run(v,e,c,y,t,a),h){for(m=0;m<p.length;m+=1)w=p[m],x=w.source,E=w.target,b=v.getDegree(x),N=v.getDegree(x),b<=1?(M=v.getNode(E),v.mergeNodeData(x,{x:M.data.x,y:M.data.y})):N<=1&&(S=v.getNode(x),v.mergeNodeData(E,{x:S.data.x,y:S.data.y}));k=o(o({},a),{prune:!1,barnesHut:!1}),this.run(v,e,100,y,t,k)}return[2,{nodes:g,edges:n}]}))}))},t.prototype.getSizes=function(t,e,r){for(var n=t.getAllNodes(),o={},i=0;i<n.length;i+=1){var a=n[i],s=a.id,h=a.data;if(o[s]=10,m(h.size))o[s]=h.size;else if(g(h.size))isNaN(h.size[0])||(o[s]=Math.max(h.size[0])),isNaN(h.size[1])||(o[s]=Math.max(h.size[1]));else if(P(h.size))o[s]=Math.max(h.size.width,h.size.height);else if(I(r)){var c=r(e.getNode(s));g(c)?o[s]=Math.max.apply(Math,d([],u(c),!1)):o[s]=c}else g(r)?o[s]=Math.max.apply(Math,d([],u(r),!1)):m(r)&&(o[s]=r)}return o},t.prototype.formatOptions=function(t,e){void 0===t&&(t={});var r=o(o({},this.options),t),n=r.center,i=r.width,a=r.height,s=r.barnesHut,u=r.prune,d=r.maxIteration,h=r.kr,c=r.kg;return r.width=i||"undefined"==typeof window?i:window.innerWidth,r.height=a||"undefined"==typeof window?a:window.innerHeight,r.center=n||[r.width/2,r.height/2],void 0===s&&e>250&&(r.barnesHut=!0),void 0===u&&e>100&&(r.prune=!0),0!==d||u?0===d&&u&&(r.maxIteration=100,e<=200&&e>100?r.maxIteration=500:e>200&&(r.maxIteration=950)):(r.maxIteration=250,e<=200&&e>100?r.maxIteration=1e3:e>200&&(r.maxIteration=1200)),h||(r.kr=50,e>100&&e<=500?r.kr=20:e>500&&(r.kr=1)),c||(r.kg=20,e>100&&e<=500?r.kg=10:e>500&&(r.kg=1)),r},t.prototype.run=function(t,e,r,n,o,i){for(var a=i.kr,s=i.barnesHut,u=i.onTick,d=t.getAllNodes(),h=0,c=r,l={},f={},g={},p=0;p<d.length;p+=1){var v=d[p],y=v.data,m=v.id;if(l[m]=[0,0],s){var w={id:p,rx:y.x,ry:y.y,mass:1,g:a,degree:t.getDegree(m)};g[m]=new Gr(w)}}for(;c>0;)h=this.oneStep(t,{iter:c,preventOverlapIters:50,krPrime:100,sg:h,forces:l,preForces:f,bodies:g,sizes:n},i),c--,null==u||u({nodes:d,edges:e.getAllEdges()});return t},t.prototype.oneStep=function(t,e,r){for(var n=e.iter,o=e.preventOverlapIters,i=e.krPrime,a=e.sg,s=e.preForces,h=e.bodies,c=e.sizes,l=e.forces,f=r.preventOverlap,g=r.barnesHut,p=t.getAllNodes(),v=0;v<p.length;v+=1){var y=p[v].id;s[y]=d([],u(l[y]),!1),l[y]=[0,0]}return l=this.getAttrForces(t,n,o,c,l,r),l=g&&(f&&n>o||!f)?this.getOptRepGraForces(t,l,h,r):this.getRepGraForces(t,n,o,l,i,c,r),this.updatePos(t,l,s,a,r)},t.prototype.getAttrForces=function(t,e,r,n,o,i){for(var a=i.preventOverlap,s=i.dissuadeHubs,u=i.mode,d=i.prune,h=t.getAllEdges(),c=0;c<h.length;c+=1){var l=h[c],f=l.source,g=l.target,p=t.getNode(f),v=t.getNode(g),y=t.getDegree(f),m=t.getDegree(g);if(!d||!(y<=1||m<=1)){var w=[v.data.x-p.data.x,v.data.y-p.data.y],x=Math.hypot(w[0],w[1]);x=x<1e-4?1e-4:x,w[0]=w[0]/x,w[1]=w[1]/x,a&&e<r&&(x=x-n[f]-n[g]);var E=x,b=E;"linlog"===u&&(b=E=Math.log(1+x)),s&&(E=x/y,b=x/m),a&&e<r&&x<=0?(E=0,b=0):a&&e<r&&x>0&&(E=x,b=x),o[f][0]+=E*w[0],o[g][0]-=b*w[0],o[f][1]+=E*w[1],o[g][1]-=b*w[1]}}return o},t.prototype.getOptRepGraForces=function(t,e,r,n){for(var o=n.kg,i=n.center,a=n.prune,s=t.getAllNodes(),u=s.length,d=9e10,h=-9e10,c=9e10,l=-9e10,f=0;f<u;f+=1){var g=s[f],p=g.id,v=g.data;a&&t.getDegree(p)<=1||(r[p].setPos(v.x,v.y),v.x>=h&&(h=v.x),v.x<=d&&(d=v.x),v.y>=l&&(l=v.y),v.y<=c&&(c=v.y))}var y=Math.max(h-d,l-c),m=new Hr({xmid:(h+d)/2,ymid:(l+c)/2,length:y,massCenter:i,mass:u}),w=new Yr(m);for(f=0;f<u;f+=1)p=s[f].id,a&&t.getDegree(p)<=1||r[p].in(m)&&w.insert(r[p]);for(f=0;f<u;f+=1){var x=s[f],E=(p=x.id,v=x.data,t.getDegree(p));if(!(a&&E<=1)){r[p].resetForce(),w.updateForce(r[p]),e[p][0]-=r[p].fx,e[p][1]-=r[p].fy;var b=[v.x-i[0],v.y-i[1]],N=Math.hypot(b[0],b[1]);N=N<1e-4?1e-4:N,b[0]=b[0]/N,b[1]=b[1]/N;var M=o*(E+1);e[p][0]-=M*b[0],e[p][1]-=M*b[1]}}return e},t.prototype.getRepGraForces=function(t,e,r,n,o,i,a){for(var s=a.preventOverlap,u=a.kr,d=a.kg,h=a.center,c=a.prune,l=t.getAllNodes(),f=l.length,g=0;g<f;g+=1){for(var p=l[g],v=t.getDegree(p.id),y=g+1;y<f;y+=1){var m=l[y],w=t.getDegree(m.id);if(!c||!(v<=1||w<=1)){var x=[m.data.x-p.data.x,m.data.y-p.data.y],E=Math.hypot(x[0],x[1]);E=E<1e-4?1e-4:E,x[0]=x[0]/E,x[1]=x[1]/E,s&&e<r&&(E=E-i[p.id]-i[m.id]);var b=u*(v+1)*(w+1)/E;s&&e<r&&E<0?b=o*(v+1)*(w+1):s&&e<r&&0===E?b=0:s&&e<r&&E>0&&(b=u*(v+1)*(w+1)/E),n[p.id][0]-=b*x[0],n[m.id][0]+=b*x[0],n[p.id][1]-=b*x[1],n[m.id][1]+=b*x[1]}}var N=[p.data.x-h[0],p.data.y-h[1]],M=Math.hypot(N[0],N[1]);N[0]=N[0]/M,N[1]=N[1]/M;var S=d*(v+1);n[p.id][0]-=S*N[0],n[p.id][1]-=S*N[1]}return n},t.prototype.updatePos=function(t,e,r,n,o){for(var i=o.ks,a=o.tao,s=o.prune,u=o.ksmax,d=t.getAllNodes(),h=d.length,c=[],l=[],f=0,g=0,p=n,v=0;v<h;v+=1){var y=d[v].id,w=t.getDegree(y);if(!(s&&w<=1)){var x=[e[y][0]-r[y][0],e[y][1]-r[y][1]],E=Math.hypot(x[0],x[1]),b=[e[y][0]+r[y][0],e[y][1]+r[y][1]],N=Math.hypot(b[0],b[1]);c[v]=E,l[v]=N/2,f+=(w+1)*c[v],g+=(w+1)*l[v]}}var M=p;for(p=a*g/f,0!==M&&(p=p>1.5*M?1.5*M:p),v=0;v<h;v+=1){var S=d[v],k=(y=S.id,S.data);if(w=t.getDegree(y),!(s&&w<=1||m(k.fx)&&m(k.fy))){var A=i*p/(1+p*Math.sqrt(c[v])),R=Math.hypot(e[y][0],e[y][1]),_=u/(R=R<1e-4?1e-4:R),O=(A=A>_?_:A)*e[y][0],D=A*e[y][1];t.mergeNodeData(y,{x:k.x+O,y:k.y+D})}}return p},t}(),Xr={maxIteration:1e3,gravity:10,speed:5,clustering:!1,clusterGravity:10,width:300,height:300,nodeClusterBy:"cluster"},Qr=function(){function t(t){void 0===t&&(t={}),this.options=t,this.id="fruchterman",this.timeInterval=0,this.running=!1,this.options=o(o({},Xr),t)}return t.prototype.execute=function(t,e){return a(this,void 0,void 0,(function(){return s(this,(function(r){return[2,this.genericFruchtermanLayout(!1,t,e)]}))}))},t.prototype.assign=function(t,e){return a(this,void 0,void 0,(function(){return s(this,(function(r){return this.genericFruchtermanLayout(!0,t,e),[2]}))}))},t.prototype.stop=function(){this.timeInterval&&"undefined"!=typeof window&&window.clearInterval(this.timeInterval),this.running=!1},t.prototype.tick=function(t){var e=this;if(void 0===t&&(t=this.options.maxIteration||1),this.lastResult)return this.lastResult;for(var r=0;r<t;r++)this.runOneStep(this.lastGraph,this.lastClusterMap,this.lastOptions);var n={nodes:this.lastLayoutNodes,edges:this.lastLayoutEdges};return this.lastAssign&&n.nodes.forEach((function(t){return e.lastGraph.mergeNodeData(t.id,{x:t.data.x,y:t.data.y})})),n},t.prototype.genericFruchtermanLayout=function(t,e,r){return a(this,void 0,void 0,(function(){var n,i,a,u,d,h,c,l,f,g,p,v,y,m,w,x=this;return s(this,(function(s){return this.running?[2]:(n=this.formatOptions(r),i=n.width,a=n.height,u=n.center,d=n.clustering,h=n.nodeClusterBy,c=n.maxIteration,l=n.onTick,f=e.getAllNodes(),g=e.getAllEdges(),(null==f?void 0:f.length)?1===f.length?(t&&e.mergeNodeData(f[0].id,{x:u[0],y:u[1]}),p={nodes:[o(o({},f[0]),{data:o(o({},f[0].data),{x:u[0],y:u[1]})})],edges:g},this.lastResult=p,[2,p]):(v=f.map((function(t){return D(t,[i,a])})),y=new re({nodes:v,edges:g}),m={},d&&v.forEach((function(t){var e=t.data[h];m[e]||(m[e]={name:e,cx:0,cy:0,count:0})})),this.lastLayoutNodes=v,this.lastLayoutEdges=g,this.lastAssign=t,this.lastGraph=y,this.lastOptions=n,this.lastClusterMap=m,"undefined"==typeof window?[2]:(w=0,[2,new Promise((function(r){x.timeInterval=window.setInterval((function(){x.running?(x.runOneStep(y,m,n),t&&v.forEach((function(t){var r=t.id,n=t.data;return e.mergeNodeData(r,{x:n.x,y:n.y})})),null==l||l({nodes:v,edges:g}),++w>=c&&(window.clearInterval(x.timeInterval),r({nodes:v,edges:g}))):r({nodes:v,edges:g})}),0),x.running=!0}))])):(p={nodes:[],edges:g},this.lastResult=p,[2,p]))}))}))},t.prototype.formatOptions=function(t){void 0===t&&(t={});var e=o(o({},this.options),t),r=e.clustering,n=e.nodeClusterBy,i=e.center,a=e.width,s=e.height;return e.width=a||"undefined"==typeof window?a:window.innerWidth,e.height=s||"undefined"==typeof window?s:window.innerHeight,e.center=i||[e.width/2,e.height/2],e.clustering=r&&!!n,e},t.prototype.runOneStep=function(t,e,r){var n=r.height,o=r.width,i=r.gravity,a=r.center,s=r.speed,u=r.clustering,d=r.nodeClusterBy,h=r.clusterGravity,c=n*o,l=Math.sqrt(c)/10,f=t.getAllNodes(),g=c/(f.length+1),p=Math.sqrt(g),v={};if(this.applyCalculate(t,v,p,g),u){for(var y in e)e[y].cx=0,e[y].cy=0,e[y].count=0;for(var y in f.forEach((function(t){var r=t.data,n=e[r[d]];m(r.x)&&(n.cx+=r.x),m(r.y)&&(n.cy+=r.y),n.count++})),e)e[y].cx/=e[y].count,e[y].cy/=e[y].count;var w=h||i;f.forEach((function(t,r){var n=t.id,o=t.data;if(m(o.x)&&m(o.y)){var i=e[o[d]],a=Math.sqrt((o.x-i.cx)*(o.x-i.cx)+(o.y-i.cy)*(o.y-i.cy)),s=p*w;v[n].x-=s*(o.x-i.cx)/a,v[n].y-=s*(o.y-i.cy)/a}}))}f.forEach((function(t,e){var r=t.id,n=t.data;if(m(n.x)&&m(n.y)){var o=.01*p*i;v[r].x-=o*(n.x-a[0]),v[r].y-=o*(n.y-a[1])}})),f.forEach((function(e,r){var n=e.id,o=e.data;if(m(o.fx)&&m(o.fy))return o.x=o.fx,void(o.y=o.fy);if(m(o.x)&&m(o.y)){var i=Math.sqrt(v[n].x*v[n].x+v[n].y*v[n].y);if(i>0){var a=Math.min(l*(s/800),i);t.mergeNodeData(n,{x:o.x+v[n].x/i*a,y:o.y+v[n].y/i*a})}}}))},t.prototype.applyCalculate=function(t,e,r,n){this.calRepulsive(t,e,n),this.calAttractive(t,e,r)},t.prototype.calRepulsive=function(t,e,r){var n=t.getAllNodes();n.forEach((function(t,o){var i=t.data,a=t.id;e[a]={x:0,y:0},n.forEach((function(t,n){var s=t.data,u=t.id;if(!(o<=n)&&m(i.x)&&m(s.x)&&m(i.y)&&m(s.y)){var d=i.x-s.x,h=i.y-s.y,c=d*d+h*h;0===c&&(c=1,d=.01,h=.01);var l=r/c,f=d*l,g=h*l;e[a].x+=f,e[a].y+=g,e[u].x-=f,e[u].y-=g}}))}))},t.prototype.calAttractive=function(t,e,r){t.getAllEdges().forEach((function(n){var o=n.source,i=n.target;if(o&&i&&o!==i){var a=t.getNode(o).data,s=t.getNode(i).data;if(m(s.x)&&m(a.x)&&m(s.y)&&m(a.y)){var u=s.x-a.x,d=s.y-a.y,h=Math.sqrt(u*u+d*d)/r,c=u*h,l=d*h;e[o].x+=c,e[o].y+=l,e[i].x-=c,e[i].y-=l}}}))},t}(),Zr={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},tn=function(){function t(t){void 0===t&&(t={}),this.options=t,this.id="grid",this.options=o(o({},Zr),t)}return t.prototype.execute=function(t,e){return a(this,void 0,void 0,(function(){return s(this,(function(r){return[2,this.genericGridLayout(!1,t,e)]}))}))},t.prototype.assign=function(t,e){return a(this,void 0,void 0,(function(){return s(this,(function(r){return this.genericGridLayout(!0,t,e),[2]}))}))},t.prototype.genericGridLayout=function(t,e,r){return a(this,void 0,void 0,(function(){var n,i,a,u,d,h,c,l,f,p,v,y,w,x,E,b,N,M,S,k,A,R,_,O,I,P,C,L,j,F,V,B,$,W,U,G,Y;return s(this,(function(s){if(n=o(o({},this.options),r),i=n.begin,a=void 0===i?[0,0]:i,u=n.condense,d=n.preventOverlapPadding,h=n.preventOverlap,c=n.rows,l=n.cols,f=n.nodeSpacing,p=n.nodeSize,v=n.width,y=n.height,w=n.position,x=n.sortBy,E=e.getAllNodes(),b=e.getAllEdges(),!(N=null==E?void 0:E.length)||1===N)return[2,q(e,t,a)];if(M=E.map((function(t){return D(t)})),"id"===x||H(x)&&void 0!==M[0].data[x]||(x="degree"),"degree"===x?M.sort((function(t,r){return e.getDegree(r.id,"both")-e.getDegree(t.id,"both")})):"id"===x?M.sort((function(t,e){return m(e.id)&&m(t.id)?e.id-t.id:"".concat(t.id).localeCompare("".concat(e.id))})):M.sort((function(t,e){return e.data[x]-t.data[x]})),S=v||"undefined"==typeof window?v:window.innerWidth,k=y||"undefined"==typeof window?y:window.innerHeight,A=N,R={rows:c,cols:l},null!=c&&null!=l?(R.rows=c,R.cols=l):null!=c&&null==l?(R.rows=c,R.cols=Math.ceil(A/R.rows)):null==c&&null!=l?(R.cols=l,R.rows=Math.ceil(A/R.cols)):(_=Math.sqrt(A*k/S),R.rows=Math.round(_),R.cols=Math.round(S/k*_)),R.rows=Math.max(R.rows,1),R.cols=Math.max(R.cols,1),R.cols*R.rows>A)O=en(R),I=rn(R),(O-1)*I>=A?en(R,O-1):(I-1)*O>=A&&rn(R,I-1);else for(;R.cols*R.rows<A;)O=en(R),((I=rn(R))+1)*O>=A?rn(R,I+1):en(R,O+1);for(P=u?0:S/R.cols,C=u?0:k/R.rows,(h||f)&&(L=z(10,f),j=T(30,p,!1),M.forEach((function(t){t.data.x&&t.data.y||(t.data.x=0,t.data.y=0);var r,n,o=e.getNode(t.id),i=j(o)||30;g(i)?(r=i[0],n=i[1]):(r=i,n=i);var a=void 0!==L?L(t):d,s=r+a,u=n+a;P=Math.max(P,s),C=Math.max(C,u)}))),F={},V={row:0,col:0},B={},$=0;$<M.length;$++){if(W=M[$],U=void 0,w&&(U=w(e.getNode(W.id))),U&&(void 0!==U.row||void 0!==U.col)){if(void 0===(G={row:U.row,col:U.col}).col)for(G.col=0;nn(F,G);)G.col++;else if(void 0===G.row)for(G.row=0;nn(F,G);)G.row++;B[W.id]=G,on(F,G)}sn(W,a,P,C,B,R,V,F)}return Y={nodes:M,edges:b},t&&M.forEach((function(t){e.mergeNodeData(t.id,{x:t.data.x,y:t.data.y})})),[2,Y]}))}))},t}(),en=function(t,e){var r,n=t.rows||5,o=t.cols||5;return null==e?r=Math.min(n,o):Math.min(n,o)===t.rows?t.rows=e:t.cols=e,r},rn=function(t,e){var r,n=t.rows||5,o=t.cols||5;return null==e?r=Math.max(n,o):Math.max(n,o)===t.rows?t.rows=e:t.cols=e,r},nn=function(t,e){return t["c-".concat(e.row,"-").concat(e.col)]||!1},on=function(t,e){return t["c-".concat(e.row,"-").concat(e.col)]=!0},an=function(t,e){var r=t.cols||5;e.col++,e.col>=r&&(e.col=0,e.row++)},sn=function(t,e,r,n,o,i,a,s){var u,d,h=o[t.id];if(h)u=h.col*r+r/2+e[0],d=h.row*n+n/2+e[1];else{for(;nn(s,a);)an(i,a);u=a.col*r+r/2+e[0],d=a.row*n+n/2+e[1],on(s,a),an(i,a)}t.data.x=u,t.data.y=d};const un=Object.prototype.toString;function dn(t){return un.call(t).endsWith("Array]")}function hn(t){var e,r=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};if(!dn(t))throw new TypeError("input must be an array");if(0===t.length)throw new TypeError("input must not be empty");if(void 0!==r.output){if(!dn(r.output))throw new TypeError("output option must be an array if specified");e=r.output}else e=new Array(t.length);var n=function(t){var e=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};if(!dn(t))throw new TypeError("input must be an array");if(0===t.length)throw new TypeError("input must not be empty");var r=e.fromIndex,n=void 0===r?0:r,o=e.toIndex,i=void 0===o?t.length:o;if(n<0||n>=t.length||!Number.isInteger(n))throw new Error("fromIndex must be a positive integer smaller than length");if(i<=n||i>t.length||!Number.isInteger(i))throw new Error("toIndex must be an integer greater than fromIndex and at most equal to length");for(var a=t[n],s=n+1;s<i;s++)t[s]<a&&(a=t[s]);return a}(t),o=function(t){var e=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};if(!dn(t))throw new TypeError("input must be an array");if(0===t.length)throw new TypeError("input must not be empty");var r=e.fromIndex,n=void 0===r?0:r,o=e.toIndex,i=void 0===o?t.length:o;if(n<0||n>=t.length||!Number.isInteger(n))throw new Error("fromIndex must be a positive integer smaller than length");if(i<=n||i>t.length||!Number.isInteger(i))throw new Error("toIndex must be an integer greater than fromIndex and at most equal to length");for(var a=t[n],s=n+1;s<i;s++)t[s]>a&&(a=t[s]);return a}(t);if(n===o)throw new RangeError("minimum and maximum input values are equal. Cannot rescale a constant array");var i=r.min,a=void 0===i?r.autoMinMax?n:0:i,s=r.max,u=void 0===s?r.autoMinMax?o:1:s;if(a>=u)throw new RangeError("min option must be smaller than max option");for(var d=(u-a)/(o-n),h=0;h<t.length;h++)e[h]=(t[h]-n)*d+a;return e}const cn=" ".repeat(2),ln=" ".repeat(4);function fn(t,e={}){const{maxRows:r=15,maxColumns:n=10,maxNumSize:o=8,padMinus:i="auto"}=e;return`${t.constructor.name} {\n${cn}[\n${ln}${function(t,e,r,n,o){const{rows:i,columns:a}=t,s=Math.min(i,e),u=Math.min(a,r),d=[];if("auto"===o){o=!1;t:for(let e=0;e<s;e++)for(let r=0;r<u;r++)if(t.get(e,r)<0){o=!0;break t}}for(let e=0;e<s;e++){let r=[];for(let i=0;i<u;i++)r.push(gn(t.get(e,i),n,o));d.push(`${r.join(" ")}`)}return u!==a&&(d[d.length-1]+=` ... ${a-r} more columns`),s!==i&&d.push(`... ${i-e} more rows`),d.join(`\n${ln}`)}(t,r,n,o,i)}\n${cn}]\n${cn}rows: ${t.rows}\n${cn}columns: ${t.columns}\n}`}function gn(t,e,r){return(t>=0&&r?` ${pn(t,e-1)}`:pn(t,e)).padEnd(e)}function pn(t,e){let r=t.toString();if(r.length<=e)return r;let n=t.toFixed(e);if(n.length>e&&(n=t.toFixed(Math.max(0,e-(n.length-e)))),n.length<=e&&!n.startsWith("0.000")&&!n.startsWith("-0.000"))return n;let o=t.toExponential(e);return o.length>e&&(o=t.toExponential(Math.max(0,e-(o.length-e)))),o.slice(0)}function vn(t,e,r){let n=r?t.rows:t.rows-1;if(e<0||e>n)throw new RangeError("Row index out of range")}function yn(t,e,r){let n=r?t.columns:t.columns-1;if(e<0||e>n)throw new RangeError("Column index out of range")}function mn(t,e){if(e.to1DArray&&(e=e.to1DArray()),e.length!==t.columns)throw new RangeError("vector size must be the same as the number of columns");return e}function wn(t,e){if(e.to1DArray&&(e=e.to1DArray()),e.length!==t.rows)throw new RangeError("vector size must be the same as the number of rows");return e}function xn(t,e,r,n,o){if(5!==arguments.length)throw new RangeError("expected 4 arguments");if(bn("startRow",e),bn("endRow",r),bn("startColumn",n),bn("endColumn",o),e>r||n>o||e<0||e>=t.rows||r<0||r>=t.rows||n<0||n>=t.columns||o<0||o>=t.columns)throw new RangeError("Submatrix indices are out of range")}function En(t,e=0){let r=[];for(let n=0;n<t;n++)r.push(e);return r}function bn(t,e){if("number"!=typeof e)throw new TypeError(`${t} must be a number`)}function Nn(t){if(t.isEmpty())throw new Error("Empty matrix has no elements to index")}class Mn{static from1DArray(t,e,r){if(t*e!==r.length)throw new RangeError("data length does not match given dimensions");let n=new kn(t,e);for(let o=0;o<t;o++)for(let t=0;t<e;t++)n.set(o,t,r[o*e+t]);return n}static rowVector(t){let e=new kn(1,t.length);for(let r=0;r<t.length;r++)e.set(0,r,t[r]);return e}static columnVector(t){let e=new kn(t.length,1);for(let r=0;r<t.length;r++)e.set(r,0,t[r]);return e}static zeros(t,e){return new kn(t,e)}static ones(t,e){return new kn(t,e).fill(1)}static rand(t,e,r={}){if("object"!=typeof r)throw new TypeError("options must be an object");const{random:n=Math.random}=r;let o=new kn(t,e);for(let r=0;r<t;r++)for(let t=0;t<e;t++)o.set(r,t,n());return o}static randInt(t,e,r={}){if("object"!=typeof r)throw new TypeError("options must be an object");const{min:n=0,max:o=1e3,random:i=Math.random}=r;if(!Number.isInteger(n))throw new TypeError("min must be an integer");if(!Number.isInteger(o))throw new TypeError("max must be an integer");if(n>=o)throw new RangeError("min must be smaller than max");let a=o-n,s=new kn(t,e);for(let r=0;r<t;r++)for(let t=0;t<e;t++){let e=n+Math.round(i()*a);s.set(r,t,e)}return s}static eye(t,e,r){void 0===e&&(e=t),void 0===r&&(r=1);let n=Math.min(t,e),o=this.zeros(t,e);for(let t=0;t<n;t++)o.set(t,t,r);return o}static diag(t,e,r){let n=t.length;void 0===e&&(e=n),void 0===r&&(r=e);let o=Math.min(n,e,r),i=this.zeros(e,r);for(let e=0;e<o;e++)i.set(e,e,t[e]);return i}static min(t,e){t=this.checkMatrix(t),e=this.checkMatrix(e);let r=t.rows,n=t.columns,o=new kn(r,n);for(let i=0;i<r;i++)for(let r=0;r<n;r++)o.set(i,r,Math.min(t.get(i,r),e.get(i,r)));return o}static max(t,e){t=this.checkMatrix(t),e=this.checkMatrix(e);let r=t.rows,n=t.columns,o=new this(r,n);for(let i=0;i<r;i++)for(let r=0;r<n;r++)o.set(i,r,Math.max(t.get(i,r),e.get(i,r)));return o}static checkMatrix(t){return Mn.isMatrix(t)?t:new kn(t)}static isMatrix(t){return null!=t&&"Matrix"===t.klass}get size(){return this.rows*this.columns}apply(t){if("function"!=typeof t)throw new TypeError("callback must be a function");for(let e=0;e<this.rows;e++)for(let r=0;r<this.columns;r++)t.call(this,e,r);return this}to1DArray(){let t=[];for(let e=0;e<this.rows;e++)for(let r=0;r<this.columns;r++)t.push(this.get(e,r));return t}to2DArray(){let t=[];for(let e=0;e<this.rows;e++){t.push([]);for(let r=0;r<this.columns;r++)t[e].push(this.get(e,r))}return t}toJSON(){return this.to2DArray()}isRowVector(){return 1===this.rows}isColumnVector(){return 1===this.columns}isVector(){return 1===this.rows||1===this.columns}isSquare(){return this.rows===this.columns}isEmpty(){return 0===this.rows||0===this.columns}isSymmetric(){if(this.isSquare()){for(let t=0;t<this.rows;t++)for(let e=0;e<=t;e++)if(this.get(t,e)!==this.get(e,t))return!1;return!0}return!1}isEchelonForm(){let t=0,e=0,r=-1,n=!0,o=!1;for(;t<this.rows&&n;){for(e=0,o=!1;e<this.columns&&!1===o;)0===this.get(t,e)?e++:1===this.get(t,e)&&e>r?(o=!0,r=e):(n=!1,o=!0);t++}return n}isReducedEchelonForm(){let t=0,e=0,r=-1,n=!0,o=!1;for(;t<this.rows&&n;){for(e=0,o=!1;e<this.columns&&!1===o;)0===this.get(t,e)?e++:1===this.get(t,e)&&e>r?(o=!0,r=e):(n=!1,o=!0);for(let r=e+1;r<this.rows;r++)0!==this.get(t,r)&&(n=!1);t++}return n}echelonForm(){let t=this.clone(),e=0,r=0;for(;e<t.rows&&r<t.columns;){let n=e;for(let o=e;o<t.rows;o++)t.get(o,r)>t.get(n,r)&&(n=o);if(0===t.get(n,r))r++;else{t.swapRows(e,n);let o=t.get(e,r);for(let n=r;n<t.columns;n++)t.set(e,n,t.get(e,n)/o);for(let n=e+1;n<t.rows;n++){let o=t.get(n,r)/t.get(e,r);t.set(n,r,0);for(let i=r+1;i<t.columns;i++)t.set(n,i,t.get(n,i)-t.get(e,i)*o)}e++,r++}}return t}reducedEchelonForm(){let t=this.echelonForm(),e=t.columns,r=t.rows,n=r-1;for(;n>=0;)if(0===t.maxRow(n))n--;else{let o=0,i=!1;for(;o<r&&!1===i;)1===t.get(n,o)?i=!0:o++;for(let r=0;r<n;r++){let i=t.get(r,o);for(let a=o;a<e;a++){let e=t.get(r,a)-i*t.get(n,a);t.set(r,a,e)}}n--}return t}set(){throw new Error("set method is unimplemented")}get(){throw new Error("get method is unimplemented")}repeat(t={}){if("object"!=typeof t)throw new TypeError("options must be an object");const{rows:e=1,columns:r=1}=t;if(!Number.isInteger(e)||e<=0)throw new TypeError("rows must be a positive integer");if(!Number.isInteger(r)||r<=0)throw new TypeError("columns must be a positive integer");let n=new kn(this.rows*e,this.columns*r);for(let t=0;t<e;t++)for(let e=0;e<r;e++)n.setSubMatrix(this,this.rows*t,this.columns*e);return n}fill(t){for(let e=0;e<this.rows;e++)for(let r=0;r<this.columns;r++)this.set(e,r,t);return this}neg(){return this.mulS(-1)}getRow(t){vn(this,t);let e=[];for(let r=0;r<this.columns;r++)e.push(this.get(t,r));return e}getRowVector(t){return kn.rowVector(this.getRow(t))}setRow(t,e){vn(this,t),e=mn(this,e);for(let r=0;r<this.columns;r++)this.set(t,r,e[r]);return this}swapRows(t,e){vn(this,t),vn(this,e);for(let r=0;r<this.columns;r++){let n=this.get(t,r);this.set(t,r,this.get(e,r)),this.set(e,r,n)}return this}getColumn(t){yn(this,t);let e=[];for(let r=0;r<this.rows;r++)e.push(this.get(r,t));return e}getColumnVector(t){return kn.columnVector(this.getColumn(t))}setColumn(t,e){yn(this,t),e=wn(this,e);for(let r=0;r<this.rows;r++)this.set(r,t,e[r]);return this}swapColumns(t,e){yn(this,t),yn(this,e);for(let r=0;r<this.rows;r++){let n=this.get(r,t);this.set(r,t,this.get(r,e)),this.set(r,e,n)}return this}addRowVector(t){t=mn(this,t);for(let e=0;e<this.rows;e++)for(let r=0;r<this.columns;r++)this.set(e,r,this.get(e,r)+t[r]);return this}subRowVector(t){t=mn(this,t);for(let e=0;e<this.rows;e++)for(let r=0;r<this.columns;r++)this.set(e,r,this.get(e,r)-t[r]);return this}mulRowVector(t){t=mn(this,t);for(let e=0;e<this.rows;e++)for(let r=0;r<this.columns;r++)this.set(e,r,this.get(e,r)*t[r]);return this}divRowVector(t){t=mn(this,t);for(let e=0;e<this.rows;e++)for(let r=0;r<this.columns;r++)this.set(e,r,this.get(e,r)/t[r]);return this}addColumnVector(t){t=wn(this,t);for(let e=0;e<this.rows;e++)for(let r=0;r<this.columns;r++)this.set(e,r,this.get(e,r)+t[e]);return this}subColumnVector(t){t=wn(this,t);for(let e=0;e<this.rows;e++)for(let r=0;r<this.columns;r++)this.set(e,r,this.get(e,r)-t[e]);return this}mulColumnVector(t){t=wn(this,t);for(let e=0;e<this.rows;e++)for(let r=0;r<this.columns;r++)this.set(e,r,this.get(e,r)*t[e]);return this}divColumnVector(t){t=wn(this,t);for(let e=0;e<this.rows;e++)for(let r=0;r<this.columns;r++)this.set(e,r,this.get(e,r)/t[e]);return this}mulRow(t,e){vn(this,t);for(let r=0;r<this.columns;r++)this.set(t,r,this.get(t,r)*e);return this}mulColumn(t,e){yn(this,t);for(let r=0;r<this.rows;r++)this.set(r,t,this.get(r,t)*e);return this}max(t){if(this.isEmpty())return NaN;switch(t){case"row":{const t=new Array(this.rows).fill(Number.NEGATIVE_INFINITY);for(let e=0;e<this.rows;e++)for(let r=0;r<this.columns;r++)this.get(e,r)>t[e]&&(t[e]=this.get(e,r));return t}case"column":{const t=new Array(this.columns).fill(Number.NEGATIVE_INFINITY);for(let e=0;e<this.rows;e++)for(let r=0;r<this.columns;r++)this.get(e,r)>t[r]&&(t[r]=this.get(e,r));return t}case void 0:{let t=this.get(0,0);for(let e=0;e<this.rows;e++)for(let r=0;r<this.columns;r++)this.get(e,r)>t&&(t=this.get(e,r));return t}default:throw new Error(`invalid option: ${t}`)}}maxIndex(){Nn(this);let t=this.get(0,0),e=[0,0];for(let r=0;r<this.rows;r++)for(let n=0;n<this.columns;n++)this.get(r,n)>t&&(t=this.get(r,n),e[0]=r,e[1]=n);return e}min(t){if(this.isEmpty())return NaN;switch(t){case"row":{const t=new Array(this.rows).fill(Number.POSITIVE_INFINITY);for(let e=0;e<this.rows;e++)for(let r=0;r<this.columns;r++)this.get(e,r)<t[e]&&(t[e]=this.get(e,r));return t}case"column":{const t=new Array(this.columns).fill(Number.POSITIVE_INFINITY);for(let e=0;e<this.rows;e++)for(let r=0;r<this.columns;r++)this.get(e,r)<t[r]&&(t[r]=this.get(e,r));return t}case void 0:{let t=this.get(0,0);for(let e=0;e<this.rows;e++)for(let r=0;r<this.columns;r++)this.get(e,r)<t&&(t=this.get(e,r));return t}default:throw new Error(`invalid option: ${t}`)}}minIndex(){Nn(this);let t=this.get(0,0),e=[0,0];for(let r=0;r<this.rows;r++)for(let n=0;n<this.columns;n++)this.get(r,n)<t&&(t=this.get(r,n),e[0]=r,e[1]=n);return e}maxRow(t){if(vn(this,t),this.isEmpty())return NaN;let e=this.get(t,0);for(let r=1;r<this.columns;r++)this.get(t,r)>e&&(e=this.get(t,r));return e}maxRowIndex(t){vn(this,t),Nn(this);let e=this.get(t,0),r=[t,0];for(let n=1;n<this.columns;n++)this.get(t,n)>e&&(e=this.get(t,n),r[1]=n);return r}minRow(t){if(vn(this,t),this.isEmpty())return NaN;let e=this.get(t,0);for(let r=1;r<this.columns;r++)this.get(t,r)<e&&(e=this.get(t,r));return e}minRowIndex(t){vn(this,t),Nn(this);let e=this.get(t,0),r=[t,0];for(let n=1;n<this.columns;n++)this.get(t,n)<e&&(e=this.get(t,n),r[1]=n);return r}maxColumn(t){if(yn(this,t),this.isEmpty())return NaN;let e=this.get(0,t);for(let r=1;r<this.rows;r++)this.get(r,t)>e&&(e=this.get(r,t));return e}maxColumnIndex(t){yn(this,t),Nn(this);let e=this.get(0,t),r=[0,t];for(let n=1;n<this.rows;n++)this.get(n,t)>e&&(e=this.get(n,t),r[0]=n);return r}minColumn(t){if(yn(this,t),this.isEmpty())return NaN;let e=this.get(0,t);for(let r=1;r<this.rows;r++)this.get(r,t)<e&&(e=this.get(r,t));return e}minColumnIndex(t){yn(this,t),Nn(this);let e=this.get(0,t),r=[0,t];for(let n=1;n<this.rows;n++)this.get(n,t)<e&&(e=this.get(n,t),r[0]=n);return r}diag(){let t=Math.min(this.rows,this.columns),e=[];for(let r=0;r<t;r++)e.push(this.get(r,r));return e}norm(t="frobenius"){let e=0;if("max"===t)return this.max();if("frobenius"===t){for(let t=0;t<this.rows;t++)for(let r=0;r<this.columns;r++)e+=this.get(t,r)*this.get(t,r);return Math.sqrt(e)}throw new RangeError(`unknown norm type: ${t}`)}cumulativeSum(){let t=0;for(let e=0;e<this.rows;e++)for(let r=0;r<this.columns;r++)t+=this.get(e,r),this.set(e,r,t);return this}dot(t){Mn.isMatrix(t)&&(t=t.to1DArray());let e=this.to1DArray();if(e.length!==t.length)throw new RangeError("vectors do not have the same size");let r=0;for(let n=0;n<e.length;n++)r+=e[n]*t[n];return r}mmul(t){t=kn.checkMatrix(t);let e=this.rows,r=this.columns,n=t.columns,o=new kn(e,n),i=new Float64Array(r);for(let a=0;a<n;a++){for(let e=0;e<r;e++)i[e]=t.get(e,a);for(let t=0;t<e;t++){let e=0;for(let n=0;n<r;n++)e+=this.get(t,n)*i[n];o.set(t,a,e)}}return o}strassen2x2(t){t=kn.checkMatrix(t);let e=new kn(2,2);const r=this.get(0,0),n=t.get(0,0),o=this.get(0,1),i=t.get(0,1),a=this.get(1,0),s=t.get(1,0),u=this.get(1,1),d=t.get(1,1),h=(r+u)*(n+d),c=(a+u)*n,l=r*(i-d),f=u*(s-n),g=(r+o)*d,p=h+f-g+(o-u)*(s+d),v=l+g,y=c+f,m=h-c+l+(a-r)*(n+i);return e.set(0,0,p),e.set(0,1,v),e.set(1,0,y),e.set(1,1,m),e}strassen3x3(t){t=kn.checkMatrix(t);let e=new kn(3,3);const r=this.get(0,0),n=this.get(0,1),o=this.get(0,2),i=this.get(1,0),a=this.get(1,1),s=this.get(1,2),u=this.get(2,0),d=this.get(2,1),h=this.get(2,2),c=t.get(0,0),l=t.get(0,1),f=t.get(0,2),g=t.get(1,0),p=t.get(1,1),v=t.get(1,2),y=t.get(2,0),m=t.get(2,1),w=t.get(2,2),x=(r-i)*(-l+p),E=(-r+i+a)*(c-l+p),b=(i+a)*(-c+l),N=r*c,M=(-r+u+d)*(c-f+v),S=(-r+u)*(f-v),k=(u+d)*(-c+f),A=(-o+d+h)*(p+y-m),R=(o-h)*(p-m),_=o*y,O=(d+h)*(-y+m),D=(-o+a+s)*(v+y-w),I=(o-s)*(v-w),P=(a+s)*(-y+w),z=N+_+n*g,T=(r+n+o-i-a-d-h)*p+E+b+N+A+_+O,C=N+M+k+(r+n+o-a-s-u-d)*v+_+D+P,q=x+a*(-c+l+g-p-v-y+w)+E+N+_+D+I,L=x+E+b+N+s*m,j=_+D+I+P+i*f,F=N+M+S+d*(-c+f+g-p-v-y+m)+A+R+_,V=A+R+_+O+u*l,B=N+M+S+k+h*w;return e.set(0,0,z),e.set(0,1,T),e.set(0,2,C),e.set(1,0,q),e.set(1,1,L),e.set(1,2,j),e.set(2,0,F),e.set(2,1,V),e.set(2,2,B),e}mmulStrassen(t){t=kn.checkMatrix(t);let e=this.clone(),r=e.rows,n=e.columns,o=t.rows,i=t.columns;function a(t,e,r){let n=t.rows,o=t.columns;if(n===e&&o===r)return t;{let n=Mn.zeros(e,r);return n=n.setSubMatrix(t,0,0),n}}n!==o&&console.warn(`Multiplying ${r} x ${n} and ${o} x ${i} matrix: dimensions do not match.`);let s=Math.max(r,o),u=Math.max(n,i);return e=a(e,s,u),function t(e,r,n,o){if(n<=512||o<=512)return e.mmul(r);n%2==1&&o%2==1?(e=a(e,n+1,o+1),r=a(r,n+1,o+1)):n%2==1?(e=a(e,n+1,o),r=a(r,n+1,o)):o%2==1&&(e=a(e,n,o+1),r=a(r,n,o+1));let i=parseInt(e.rows/2,10),s=parseInt(e.columns/2,10),u=e.subMatrix(0,i-1,0,s-1),d=r.subMatrix(0,i-1,0,s-1),h=e.subMatrix(0,i-1,s,e.columns-1),c=r.subMatrix(0,i-1,s,r.columns-1),l=e.subMatrix(i,e.rows-1,0,s-1),f=r.subMatrix(i,r.rows-1,0,s-1),g=e.subMatrix(i,e.rows-1,s,e.columns-1),p=r.subMatrix(i,r.rows-1,s,r.columns-1),v=t(Mn.add(u,g),Mn.add(d,p),i,s),y=t(Mn.add(l,g),d,i,s),m=t(u,Mn.sub(c,p),i,s),w=t(g,Mn.sub(f,d),i,s),x=t(Mn.add(u,h),p,i,s),E=t(Mn.sub(l,u),Mn.add(d,c),i,s),b=t(Mn.sub(h,g),Mn.add(f,p),i,s),N=Mn.add(v,w);N.sub(x),N.add(b);let M=Mn.add(m,x),S=Mn.add(y,w),k=Mn.sub(v,y);k.add(m),k.add(E);let A=Mn.zeros(2*N.rows,2*N.columns);return A=A.setSubMatrix(N,0,0),A=A.setSubMatrix(M,N.rows,0),A=A.setSubMatrix(S,0,N.columns),A=A.setSubMatrix(k,N.rows,N.columns),A.subMatrix(0,n-1,0,o-1)}(e,t=a(t,s,u),s,u)}scaleRows(t={}){if("object"!=typeof t)throw new TypeError("options must be an object");const{min:e=0,max:r=1}=t;if(!Number.isFinite(e))throw new TypeError("min must be a number");if(!Number.isFinite(r))throw new TypeError("max must be a number");if(e>=r)throw new RangeError("min must be smaller than max");let n=new kn(this.rows,this.columns);for(let t=0;t<this.rows;t++){const o=this.getRow(t);o.length>0&&hn(o,{min:e,max:r,output:o}),n.setRow(t,o)}return n}scaleColumns(t={}){if("object"!=typeof t)throw new TypeError("options must be an object");const{min:e=0,max:r=1}=t;if(!Number.isFinite(e))throw new TypeError("min must be a number");if(!Number.isFinite(r))throw new TypeError("max must be a number");if(e>=r)throw new RangeError("min must be smaller than max");let n=new kn(this.rows,this.columns);for(let t=0;t<this.columns;t++){const o=this.getColumn(t);o.length&&hn(o,{min:e,max:r,output:o}),n.setColumn(t,o)}return n}flipRows(){const t=Math.ceil(this.columns/2);for(let e=0;e<this.rows;e++)for(let r=0;r<t;r++){let t=this.get(e,r),n=this.get(e,this.columns-1-r);this.set(e,r,n),this.set(e,this.columns-1-r,t)}return this}flipColumns(){const t=Math.ceil(this.rows/2);for(let e=0;e<this.columns;e++)for(let r=0;r<t;r++){let t=this.get(r,e),n=this.get(this.rows-1-r,e);this.set(r,e,n),this.set(this.rows-1-r,e,t)}return this}kroneckerProduct(t){t=kn.checkMatrix(t);let e=this.rows,r=this.columns,n=t.rows,o=t.columns,i=new kn(e*n,r*o);for(let a=0;a<e;a++)for(let e=0;e<r;e++)for(let r=0;r<n;r++)for(let s=0;s<o;s++)i.set(n*a+r,o*e+s,this.get(a,e)*t.get(r,s));return i}kroneckerSum(t){if(t=kn.checkMatrix(t),!this.isSquare()||!t.isSquare())throw new Error("Kronecker Sum needs two Square Matrices");let e=this.rows,r=t.rows,n=this.kroneckerProduct(kn.eye(r,r)),o=kn.eye(e,e).kroneckerProduct(t);return n.add(o)}transpose(){let t=new kn(this.columns,this.rows);for(let e=0;e<this.rows;e++)for(let r=0;r<this.columns;r++)t.set(r,e,this.get(e,r));return t}sortRows(t=Sn){for(let e=0;e<this.rows;e++)this.setRow(e,this.getRow(e).sort(t));return this}sortColumns(t=Sn){for(let e=0;e<this.columns;e++)this.setColumn(e,this.getColumn(e).sort(t));return this}subMatrix(t,e,r,n){xn(this,t,e,r,n);let o=new kn(e-t+1,n-r+1);for(let i=t;i<=e;i++)for(let e=r;e<=n;e++)o.set(i-t,e-r,this.get(i,e));return o}subMatrixRow(t,e,r){if(void 0===e&&(e=0),void 0===r&&(r=this.columns-1),e>r||e<0||e>=this.columns||r<0||r>=this.columns)throw new RangeError("Argument out of range");let n=new kn(t.length,r-e+1);for(let o=0;o<t.length;o++)for(let i=e;i<=r;i++){if(t[o]<0||t[o]>=this.rows)throw new RangeError(`Row index out of range: ${t[o]}`);n.set(o,i-e,this.get(t[o],i))}return n}subMatrixColumn(t,e,r){if(void 0===e&&(e=0),void 0===r&&(r=this.rows-1),e>r||e<0||e>=this.rows||r<0||r>=this.rows)throw new RangeError("Argument out of range");let n=new kn(r-e+1,t.length);for(let o=0;o<t.length;o++)for(let i=e;i<=r;i++){if(t[o]<0||t[o]>=this.columns)throw new RangeError(`Column index out of range: ${t[o]}`);n.set(i-e,o,this.get(i,t[o]))}return n}setSubMatrix(t,e,r){if((t=kn.checkMatrix(t)).isEmpty())return this;xn(this,e,e+t.rows-1,r,r+t.columns-1);for(let n=0;n<t.rows;n++)for(let o=0;o<t.columns;o++)this.set(e+n,r+o,t.get(n,o));return this}selection(t,e){!function(t,e){if(!dn(e))throw new TypeError("row indices must be an array");for(let r=0;r<e.length;r++)if(e[r]<0||e[r]>=t.rows)throw new RangeError("row indices are out of range")}(this,t),function(t,e){if(!dn(e))throw new TypeError("column indices must be an array");for(let r=0;r<e.length;r++)if(e[r]<0||e[r]>=t.columns)throw new RangeError("column indices are out of range")}(this,e);let r=new kn(t.length,e.length);for(let n=0;n<t.length;n++){let o=t[n];for(let t=0;t<e.length;t++){let i=e[t];r.set(n,t,this.get(o,i))}}return r}trace(){let t=Math.min(this.rows,this.columns),e=0;for(let r=0;r<t;r++)e+=this.get(r,r);return e}clone(){let t=new kn(this.rows,this.columns);for(let e=0;e<this.rows;e++)for(let r=0;r<this.columns;r++)t.set(e,r,this.get(e,r));return t}sum(t){switch(t){case"row":return function(t){let e=En(t.rows);for(let r=0;r<t.rows;++r)for(let n=0;n<t.columns;++n)e[r]+=t.get(r,n);return e}(this);case"column":return function(t){let e=En(t.columns);for(let r=0;r<t.rows;++r)for(let n=0;n<t.columns;++n)e[n]+=t.get(r,n);return e}(this);case void 0:return function(t){let e=0;for(let r=0;r<t.rows;r++)for(let n=0;n<t.columns;n++)e+=t.get(r,n);return e}(this);default:throw new Error(`invalid option: ${t}`)}}product(t){switch(t){case"row":return function(t){let e=En(t.rows,1);for(let r=0;r<t.rows;++r)for(let n=0;n<t.columns;++n)e[r]*=t.get(r,n);return e}(this);case"column":return function(t){let e=En(t.columns,1);for(let r=0;r<t.rows;++r)for(let n=0;n<t.columns;++n)e[n]*=t.get(r,n);return e}(this);case void 0:return function(t){let e=1;for(let r=0;r<t.rows;r++)for(let n=0;n<t.columns;n++)e*=t.get(r,n);return e}(this);default:throw new Error(`invalid option: ${t}`)}}mean(t){const e=this.sum(t);switch(t){case"row":for(let t=0;t<this.rows;t++)e[t]/=this.columns;return e;case"column":for(let t=0;t<this.columns;t++)e[t]/=this.rows;return e;case void 0:return e/this.size;default:throw new Error(`invalid option: ${t}`)}}variance(t,e={}){if("object"==typeof t&&(e=t,t=void 0),"object"!=typeof e)throw new TypeError("options must be an object");const{unbiased:r=!0,mean:n=this.mean(t)}=e;if("boolean"!=typeof r)throw new TypeError("unbiased must be a boolean");switch(t){case"row":if(!dn(n))throw new TypeError("mean must be an array");return function(t,e,r){const n=t.rows,o=t.columns,i=[];for(let a=0;a<n;a++){let n=0,s=0,u=0;for(let e=0;e<o;e++)u=t.get(a,e)-r[a],n+=u,s+=u*u;e?i.push((s-n*n/o)/(o-1)):i.push((s-n*n/o)/o)}return i}(this,r,n);case"column":if(!dn(n))throw new TypeError("mean must be an array");return function(t,e,r){const n=t.rows,o=t.columns,i=[];for(let a=0;a<o;a++){let o=0,s=0,u=0;for(let e=0;e<n;e++)u=t.get(e,a)-r[a],o+=u,s+=u*u;e?i.push((s-o*o/n)/(n-1)):i.push((s-o*o/n)/n)}return i}(this,r,n);case void 0:if("number"!=typeof n)throw new TypeError("mean must be a number");return function(t,e,r){const n=t.rows,o=t.columns,i=n*o;let a=0,s=0,u=0;for(let e=0;e<n;e++)for(let n=0;n<o;n++)u=t.get(e,n)-r,a+=u,s+=u*u;return e?(s-a*a/i)/(i-1):(s-a*a/i)/i}(this,r,n);default:throw new Error(`invalid option: ${t}`)}}standardDeviation(t,e){"object"==typeof t&&(e=t,t=void 0);const r=this.variance(t,e);if(void 0===t)return Math.sqrt(r);for(let t=0;t<r.length;t++)r[t]=Math.sqrt(r[t]);return r}center(t,e={}){if("object"==typeof t&&(e=t,t=void 0),"object"!=typeof e)throw new TypeError("options must be an object");const{center:r=this.mean(t)}=e;switch(t){case"row":if(!dn(r))throw new TypeError("center must be an array");return function(t,e){for(let r=0;r<t.rows;r++)for(let n=0;n<t.columns;n++)t.set(r,n,t.get(r,n)-e[r])}(this,r),this;case"column":if(!dn(r))throw new TypeError("center must be an array");return function(t,e){for(let r=0;r<t.rows;r++)for(let n=0;n<t.columns;n++)t.set(r,n,t.get(r,n)-e[n])}(this,r),this;case void 0:if("number"!=typeof r)throw new TypeError("center must be a number");return function(t,e){for(let r=0;r<t.rows;r++)for(let n=0;n<t.columns;n++)t.set(r,n,t.get(r,n)-e)}(this,r),this;default:throw new Error(`invalid option: ${t}`)}}scale(t,e={}){if("object"==typeof t&&(e=t,t=void 0),"object"!=typeof e)throw new TypeError("options must be an object");let r=e.scale;switch(t){case"row":if(void 0===r)r=function(t){const e=[];for(let r=0;r<t.rows;r++){let n=0;for(let e=0;e<t.columns;e++)n+=Math.pow(t.get(r,e),2)/(t.columns-1);e.push(Math.sqrt(n))}return e}(this);else if(!dn(r))throw new TypeError("scale must be an array");return function(t,e){for(let r=0;r<t.rows;r++)for(let n=0;n<t.columns;n++)t.set(r,n,t.get(r,n)/e[r])}(this,r),this;case"column":if(void 0===r)r=function(t){const e=[];for(let r=0;r<t.columns;r++){let n=0;for(let e=0;e<t.rows;e++)n+=Math.pow(t.get(e,r),2)/(t.rows-1);e.push(Math.sqrt(n))}return e}(this);else if(!dn(r))throw new TypeError("scale must be an array");return function(t,e){for(let r=0;r<t.rows;r++)for(let n=0;n<t.columns;n++)t.set(r,n,t.get(r,n)/e[n])}(this,r),this;case void 0:if(void 0===r)r=function(t){const e=t.size-1;let r=0;for(let n=0;n<t.columns;n++)for(let o=0;o<t.rows;o++)r+=Math.pow(t.get(o,n),2)/e;return Math.sqrt(r)}(this);else if("number"!=typeof r)throw new TypeError("scale must be a number");return function(t,e){for(let r=0;r<t.rows;r++)for(let n=0;n<t.columns;n++)t.set(r,n,t.get(r,n)/e)}(this,r),this;default:throw new Error(`invalid option: ${t}`)}}toString(t){return fn(this,t)}}function Sn(t,e){return t-e}Mn.prototype.klass="Matrix","undefined"!=typeof Symbol&&(Mn.prototype[Symbol.for("nodejs.util.inspect.custom")]=function(){return fn(this)}),Mn.random=Mn.rand,Mn.randomInt=Mn.randInt,Mn.diagonal=Mn.diag,Mn.prototype.diagonal=Mn.prototype.diag,Mn.identity=Mn.eye,Mn.prototype.negate=Mn.prototype.neg,Mn.prototype.tensorProduct=Mn.prototype.kroneckerProduct;class kn extends Mn{constructor(t,e){if(super(),kn.isMatrix(t))return t.clone();if(Number.isInteger(t)&&t>=0){if(this.data=[],!(Number.isInteger(e)&&e>=0))throw new TypeError("nColumns must be a positive integer");for(let r=0;r<t;r++)this.data.push(new Float64Array(e))}else{if(!dn(t))throw new TypeError("First argument must be a positive number or an array");{const r=t;if("number"!=typeof(e=(t=r.length)?r[0].length:0))throw new TypeError("Data must be a 2D array with at least one element");this.data=[];for(let n=0;n<t;n++){if(r[n].length!==e)throw new RangeError("Inconsistent array dimensions");if(!r[n].every((t=>"number"==typeof t)))throw new TypeError("Input data contains non-numeric values");this.data.push(Float64Array.from(r[n]))}}}this.rows=t,this.columns=e}set(t,e,r){return this.data[t][e]=r,this}get(t,e){return this.data[t][e]}removeRow(t){return vn(this,t),this.data.splice(t,1),this.rows-=1,this}addRow(t,e){return void 0===e&&(e=t,t=this.rows),vn(this,t,!0),e=Float64Array.from(mn(this,e)),this.data.splice(t,0,e),this.rows+=1,this}removeColumn(t){yn(this,t);for(let e=0;e<this.rows;e++){const r=new Float64Array(this.columns-1);for(let n=0;n<t;n++)r[n]=this.data[e][n];for(let n=t+1;n<this.columns;n++)r[n-1]=this.data[e][n];this.data[e]=r}return this.columns-=1,this}addColumn(t,e){void 0===e&&(e=t,t=this.columns),yn(this,t,!0),e=wn(this,e);for(let r=0;r<this.rows;r++){const n=new Float64Array(this.columns+1);let o=0;for(;o<t;o++)n[o]=this.data[r][o];for(n[o++]=e[r];o<this.columns+1;o++)n[o]=this.data[r][o-1];this.data[r]=n}return this.columns+=1,this}}!function(t,e){t.prototype.add=function(t){return"number"==typeof t?this.addS(t):this.addM(t)},t.prototype.addS=function(t){for(let e=0;e<this.rows;e++)for(let r=0;r<this.columns;r++)this.set(e,r,this.get(e,r)+t);return this},t.prototype.addM=function(t){if(t=e.checkMatrix(t),this.rows!==t.rows||this.columns!==t.columns)throw new RangeError("Matrices dimensions must be equal");for(let e=0;e<this.rows;e++)for(let r=0;r<this.columns;r++)this.set(e,r,this.get(e,r)+t.get(e,r));return this},t.add=function(t,r){return new e(t).add(r)},t.prototype.sub=function(t){return"number"==typeof t?this.subS(t):this.subM(t)},t.prototype.subS=function(t){for(let e=0;e<this.rows;e++)for(let r=0;r<this.columns;r++)this.set(e,r,this.get(e,r)-t);return this},t.prototype.subM=function(t){if(t=e.checkMatrix(t),this.rows!==t.rows||this.columns!==t.columns)throw new RangeError("Matrices dimensions must be equal");for(let e=0;e<this.rows;e++)for(let r=0;r<this.columns;r++)this.set(e,r,this.get(e,r)-t.get(e,r));return this},t.sub=function(t,r){return new e(t).sub(r)},t.prototype.subtract=t.prototype.sub,t.prototype.subtractS=t.prototype.subS,t.prototype.subtractM=t.prototype.subM,t.subtract=t.sub,t.prototype.mul=function(t){return"number"==typeof t?this.mulS(t):this.mulM(t)},t.prototype.mulS=function(t){for(let e=0;e<this.rows;e++)for(let r=0;r<this.columns;r++)this.set(e,r,this.get(e,r)*t);return this},t.prototype.mulM=function(t){if(t=e.checkMatrix(t),this.rows!==t.rows||this.columns!==t.columns)throw new RangeError("Matrices dimensions must be equal");for(let e=0;e<this.rows;e++)for(let r=0;r<this.columns;r++)this.set(e,r,this.get(e,r)*t.get(e,r));return this},t.mul=function(t,r){return new e(t).mul(r)},t.prototype.multiply=t.prototype.mul,t.prototype.multiplyS=t.prototype.mulS,t.prototype.multiplyM=t.prototype.mulM,t.multiply=t.mul,t.prototype.div=function(t){return"number"==typeof t?this.divS(t):this.divM(t)},t.prototype.divS=function(t){for(let e=0;e<this.rows;e++)for(let r=0;r<this.columns;r++)this.set(e,r,this.get(e,r)/t);return this},t.prototype.divM=function(t){if(t=e.checkMatrix(t),this.rows!==t.rows||this.columns!==t.columns)throw new RangeError("Matrices dimensions must be equal");for(let e=0;e<this.rows;e++)for(let r=0;r<this.columns;r++)this.set(e,r,this.get(e,r)/t.get(e,r));return this},t.div=function(t,r){return new e(t).div(r)},t.prototype.divide=t.prototype.div,t.prototype.divideS=t.prototype.divS,t.prototype.divideM=t.prototype.divM,t.divide=t.div,t.prototype.mod=function(t){return"number"==typeof t?this.modS(t):this.modM(t)},t.prototype.modS=function(t){for(let e=0;e<this.rows;e++)for(let r=0;r<this.columns;r++)this.set(e,r,this.get(e,r)%t);return this},t.prototype.modM=function(t){if(t=e.checkMatrix(t),this.rows!==t.rows||this.columns!==t.columns)throw new RangeError("Matrices dimensions must be equal");for(let e=0;e<this.rows;e++)for(let r=0;r<this.columns;r++)this.set(e,r,this.get(e,r)%t.get(e,r));return this},t.mod=function(t,r){return new e(t).mod(r)},t.prototype.modulus=t.prototype.mod,t.prototype.modulusS=t.prototype.modS,t.prototype.modulusM=t.prototype.modM,t.modulus=t.mod,t.prototype.and=function(t){return"number"==typeof t?this.andS(t):this.andM(t)},t.prototype.andS=function(t){for(let e=0;e<this.rows;e++)for(let r=0;r<this.columns;r++)this.set(e,r,this.get(e,r)&t);return this},t.prototype.andM=function(t){if(t=e.checkMatrix(t),this.rows!==t.rows||this.columns!==t.columns)throw new RangeError("Matrices dimensions must be equal");for(let e=0;e<this.rows;e++)for(let r=0;r<this.columns;r++)this.set(e,r,this.get(e,r)&t.get(e,r));return this},t.and=function(t,r){return new e(t).and(r)},t.prototype.or=function(t){return"number"==typeof t?this.orS(t):this.orM(t)},t.prototype.orS=function(t){for(let e=0;e<this.rows;e++)for(let r=0;r<this.columns;r++)this.set(e,r,this.get(e,r)|t);return this},t.prototype.orM=function(t){if(t=e.checkMatrix(t),this.rows!==t.rows||this.columns!==t.columns)throw new RangeError("Matrices dimensions must be equal");for(let e=0;e<this.rows;e++)for(let r=0;r<this.columns;r++)this.set(e,r,this.get(e,r)|t.get(e,r));return this},t.or=function(t,r){return new e(t).or(r)},t.prototype.xor=function(t){return"number"==typeof t?this.xorS(t):this.xorM(t)},t.prototype.xorS=function(t){for(let e=0;e<this.rows;e++)for(let r=0;r<this.columns;r++)this.set(e,r,this.get(e,r)^t);return this},t.prototype.xorM=function(t){if(t=e.checkMatrix(t),this.rows!==t.rows||this.columns!==t.columns)throw new RangeError("Matrices dimensions must be equal");for(let e=0;e<this.rows;e++)for(let r=0;r<this.columns;r++)this.set(e,r,this.get(e,r)^t.get(e,r));return this},t.xor=function(t,r){return new e(t).xor(r)},t.prototype.leftShift=function(t){return"number"==typeof t?this.leftShiftS(t):this.leftShiftM(t)},t.prototype.leftShiftS=function(t){for(let e=0;e<this.rows;e++)for(let r=0;r<this.columns;r++)this.set(e,r,this.get(e,r)<<t);return this},t.prototype.leftShiftM=function(t){if(t=e.checkMatrix(t),this.rows!==t.rows||this.columns!==t.columns)throw new RangeError("Matrices dimensions must be equal");for(let e=0;e<this.rows;e++)for(let r=0;r<this.columns;r++)this.set(e,r,this.get(e,r)<<t.get(e,r));return this},t.leftShift=function(t,r){return new e(t).leftShift(r)},t.prototype.signPropagatingRightShift=function(t){return"number"==typeof t?this.signPropagatingRightShiftS(t):this.signPropagatingRightShiftM(t)},t.prototype.signPropagatingRightShiftS=function(t){for(let e=0;e<this.rows;e++)for(let r=0;r<this.columns;r++)this.set(e,r,this.get(e,r)>>t);return this},t.prototype.signPropagatingRightShiftM=function(t){if(t=e.checkMatrix(t),this.rows!==t.rows||this.columns!==t.columns)throw new RangeError("Matrices dimensions must be equal");for(let e=0;e<this.rows;e++)for(let r=0;r<this.columns;r++)this.set(e,r,this.get(e,r)>>t.get(e,r));return this},t.signPropagatingRightShift=function(t,r){return new e(t).signPropagatingRightShift(r)},t.prototype.rightShift=function(t){return"number"==typeof t?this.rightShiftS(t):this.rightShiftM(t)},t.prototype.rightShiftS=function(t){for(let e=0;e<this.rows;e++)for(let r=0;r<this.columns;r++)this.set(e,r,this.get(e,r)>>>t);return this},t.prototype.rightShiftM=function(t){if(t=e.checkMatrix(t),this.rows!==t.rows||this.columns!==t.columns)throw new RangeError("Matrices dimensions must be equal");for(let e=0;e<this.rows;e++)for(let r=0;r<this.columns;r++)this.set(e,r,this.get(e,r)>>>t.get(e,r));return this},t.rightShift=function(t,r){return new e(t).rightShift(r)},t.prototype.zeroFillRightShift=t.prototype.rightShift,t.prototype.zeroFillRightShiftS=t.prototype.rightShiftS,t.prototype.zeroFillRightShiftM=t.prototype.rightShiftM,t.zeroFillRightShift=t.rightShift,t.prototype.not=function(){for(let t=0;t<this.rows;t++)for(let e=0;e<this.columns;e++)this.set(t,e,~this.get(t,e));return this},t.not=function(t){return new e(t).not()},t.prototype.abs=function(){for(let t=0;t<this.rows;t++)for(let e=0;e<this.columns;e++)this.set(t,e,Math.abs(this.get(t,e)));return this},t.abs=function(t){return new e(t).abs()},t.prototype.acos=function(){for(let t=0;t<this.rows;t++)for(let e=0;e<this.columns;e++)this.set(t,e,Math.acos(this.get(t,e)));return this},t.acos=function(t){return new e(t).acos()},t.prototype.acosh=function(){for(let t=0;t<this.rows;t++)for(let e=0;e<this.columns;e++)this.set(t,e,Math.acosh(this.get(t,e)));return this},t.acosh=function(t){return new e(t).acosh()},t.prototype.asin=function(){for(let t=0;t<this.rows;t++)for(let e=0;e<this.columns;e++)this.set(t,e,Math.asin(this.get(t,e)));return this},t.asin=function(t){return new e(t).asin()},t.prototype.asinh=function(){for(let t=0;t<this.rows;t++)for(let e=0;e<this.columns;e++)this.set(t,e,Math.asinh(this.get(t,e)));return this},t.asinh=function(t){return new e(t).asinh()},t.prototype.atan=function(){for(let t=0;t<this.rows;t++)for(let e=0;e<this.columns;e++)this.set(t,e,Math.atan(this.get(t,e)));return this},t.atan=function(t){return new e(t).atan()},t.prototype.atanh=function(){for(let t=0;t<this.rows;t++)for(let e=0;e<this.columns;e++)this.set(t,e,Math.atanh(this.get(t,e)));return this},t.atanh=function(t){return new e(t).atanh()},t.prototype.cbrt=function(){for(let t=0;t<this.rows;t++)for(let e=0;e<this.columns;e++)this.set(t,e,Math.cbrt(this.get(t,e)));return this},t.cbrt=function(t){return new e(t).cbrt()},t.prototype.ceil=function(){for(let t=0;t<this.rows;t++)for(let e=0;e<this.columns;e++)this.set(t,e,Math.ceil(this.get(t,e)));return this},t.ceil=function(t){return new e(t).ceil()},t.prototype.clz32=function(){for(let t=0;t<this.rows;t++)for(let e=0;e<this.columns;e++)this.set(t,e,Math.clz32(this.get(t,e)));return this},t.clz32=function(t){return new e(t).clz32()},t.prototype.cos=function(){for(let t=0;t<this.rows;t++)for(let e=0;e<this.columns;e++)this.set(t,e,Math.cos(this.get(t,e)));return this},t.cos=function(t){return new e(t).cos()},t.prototype.cosh=function(){for(let t=0;t<this.rows;t++)for(let e=0;e<this.columns;e++)this.set(t,e,Math.cosh(this.get(t,e)));return this},t.cosh=function(t){return new e(t).cosh()},t.prototype.exp=function(){for(let t=0;t<this.rows;t++)for(let e=0;e<this.columns;e++)this.set(t,e,Math.exp(this.get(t,e)));return this},t.exp=function(t){return new e(t).exp()},t.prototype.expm1=function(){for(let t=0;t<this.rows;t++)for(let e=0;e<this.columns;e++)this.set(t,e,Math.expm1(this.get(t,e)));return this},t.expm1=function(t){return new e(t).expm1()},t.prototype.floor=function(){for(let t=0;t<this.rows;t++)for(let e=0;e<this.columns;e++)this.set(t,e,Math.floor(this.get(t,e)));return this},t.floor=function(t){return new e(t).floor()},t.prototype.fround=function(){for(let t=0;t<this.rows;t++)for(let e=0;e<this.columns;e++)this.set(t,e,Math.fround(this.get(t,e)));return this},t.fround=function(t){return new e(t).fround()},t.prototype.log=function(){for(let t=0;t<this.rows;t++)for(let e=0;e<this.columns;e++)this.set(t,e,Math.log(this.get(t,e)));return this},t.log=function(t){return new e(t).log()},t.prototype.log1p=function(){for(let t=0;t<this.rows;t++)for(let e=0;e<this.columns;e++)this.set(t,e,Math.log1p(this.get(t,e)));return this},t.log1p=function(t){return new e(t).log1p()},t.prototype.log10=function(){for(let t=0;t<this.rows;t++)for(let e=0;e<this.columns;e++)this.set(t,e,Math.log10(this.get(t,e)));return this},t.log10=function(t){return new e(t).log10()},t.prototype.log2=function(){for(let t=0;t<this.rows;t++)for(let e=0;e<this.columns;e++)this.set(t,e,Math.log2(this.get(t,e)));return this},t.log2=function(t){return new e(t).log2()},t.prototype.round=function(){for(let t=0;t<this.rows;t++)for(let e=0;e<this.columns;e++)this.set(t,e,Math.round(this.get(t,e)));return this},t.round=function(t){return new e(t).round()},t.prototype.sign=function(){for(let t=0;t<this.rows;t++)for(let e=0;e<this.columns;e++)this.set(t,e,Math.sign(this.get(t,e)));return this},t.sign=function(t){return new e(t).sign()},t.prototype.sin=function(){for(let t=0;t<this.rows;t++)for(let e=0;e<this.columns;e++)this.set(t,e,Math.sin(this.get(t,e)));return this},t.sin=function(t){return new e(t).sin()},t.prototype.sinh=function(){for(let t=0;t<this.rows;t++)for(let e=0;e<this.columns;e++)this.set(t,e,Math.sinh(this.get(t,e)));return this},t.sinh=function(t){return new e(t).sinh()},t.prototype.sqrt=function(){for(let t=0;t<this.rows;t++)for(let e=0;e<this.columns;e++)this.set(t,e,Math.sqrt(this.get(t,e)));return this},t.sqrt=function(t){return new e(t).sqrt()},t.prototype.tan=function(){for(let t=0;t<this.rows;t++)for(let e=0;e<this.columns;e++)this.set(t,e,Math.tan(this.get(t,e)));return this},t.tan=function(t){return new e(t).tan()},t.prototype.tanh=function(){for(let t=0;t<this.rows;t++)for(let e=0;e<this.columns;e++)this.set(t,e,Math.tanh(this.get(t,e)));return this},t.tanh=function(t){return new e(t).tanh()},t.prototype.trunc=function(){for(let t=0;t<this.rows;t++)for(let e=0;e<this.columns;e++)this.set(t,e,Math.trunc(this.get(t,e)));return this},t.trunc=function(t){return new e(t).trunc()},t.pow=function(t,r){return new e(t).pow(r)},t.prototype.pow=function(t){return"number"==typeof t?this.powS(t):this.powM(t)},t.prototype.powS=function(t){for(let e=0;e<this.rows;e++)for(let r=0;r<this.columns;r++)this.set(e,r,Math.pow(this.get(e,r),t));return this},t.prototype.powM=function(t){if(t=e.checkMatrix(t),this.rows!==t.rows||this.columns!==t.columns)throw new RangeError("Matrices dimensions must be equal");for(let e=0;e<this.rows;e++)for(let r=0;r<this.columns;r++)this.set(e,r,Math.pow(this.get(e,r),t.get(e,r)));return this}}(Mn,kn);class An extends Mn{constructor(t){super(),this.data=t,this.rows=t.length,this.columns=t[0].length}set(t,e,r){return this.data[t][e]=r,this}get(t,e){return this.data[t][e]}}function Rn(t,e){let r=0;return Math.abs(t)>Math.abs(e)?(r=e/t,Math.abs(t)*Math.sqrt(1+r*r)):0!==e?(r=t/e,Math.abs(e)*Math.sqrt(1+r*r)):0}class _n{constructor(t,e={}){if((t=An.checkMatrix(t)).isEmpty())throw new Error("Matrix must be non-empty");let r=t.rows,n=t.columns;const{computeLeftSingularVectors:o=!0,computeRightSingularVectors:i=!0,autoTranspose:a=!1}=e;let s,u=Boolean(o),d=Boolean(i),h=!1;if(r<n)if(a){s=t.transpose(),r=s.rows,n=s.columns,h=!0;let e=u;u=d,d=e}else s=t.clone(),console.warn("Computing SVD on a matrix with more columns than rows. Consider enabling autoTranspose");else s=t.clone();let c=Math.min(r,n),l=Math.min(r+1,n),f=new Float64Array(l),g=new kn(r,c),p=new kn(n,n),v=new Float64Array(n),y=new Float64Array(r),m=new Float64Array(l);for(let t=0;t<l;t++)m[t]=t;let w=Math.min(r-1,n),x=Math.max(0,Math.min(n-2,r)),E=Math.max(w,x);for(let t=0;t<E;t++){if(t<w){f[t]=0;for(let e=t;e<r;e++)f[t]=Rn(f[t],s.get(e,t));if(0!==f[t]){s.get(t,t)<0&&(f[t]=-f[t]);for(let e=t;e<r;e++)s.set(e,t,s.get(e,t)/f[t]);s.set(t,t,s.get(t,t)+1)}f[t]=-f[t]}for(let e=t+1;e<n;e++){if(t<w&&0!==f[t]){let n=0;for(let o=t;o<r;o++)n+=s.get(o,t)*s.get(o,e);n=-n/s.get(t,t);for(let o=t;o<r;o++)s.set(o,e,s.get(o,e)+n*s.get(o,t))}v[e]=s.get(t,e)}if(u&&t<w)for(let e=t;e<r;e++)g.set(e,t,s.get(e,t));if(t<x){v[t]=0;for(let e=t+1;e<n;e++)v[t]=Rn(v[t],v[e]);if(0!==v[t]){v[t+1]<0&&(v[t]=0-v[t]);for(let e=t+1;e<n;e++)v[e]/=v[t];v[t+1]+=1}if(v[t]=-v[t],t+1<r&&0!==v[t]){for(let e=t+1;e<r;e++)y[e]=0;for(let e=t+1;e<r;e++)for(let r=t+1;r<n;r++)y[e]+=v[r]*s.get(e,r);for(let e=t+1;e<n;e++){let n=-v[e]/v[t+1];for(let o=t+1;o<r;o++)s.set(o,e,s.get(o,e)+n*y[o])}}if(d)for(let e=t+1;e<n;e++)p.set(e,t,v[e])}}let b=Math.min(n,r+1);if(w<n&&(f[w]=s.get(w,w)),r<b&&(f[b-1]=0),x+1<b&&(v[x]=s.get(x,b-1)),v[b-1]=0,u){for(let t=w;t<c;t++){for(let e=0;e<r;e++)g.set(e,t,0);g.set(t,t,1)}for(let t=w-1;t>=0;t--)if(0!==f[t]){for(let e=t+1;e<c;e++){let n=0;for(let o=t;o<r;o++)n+=g.get(o,t)*g.get(o,e);n=-n/g.get(t,t);for(let o=t;o<r;o++)g.set(o,e,g.get(o,e)+n*g.get(o,t))}for(let e=t;e<r;e++)g.set(e,t,-g.get(e,t));g.set(t,t,1+g.get(t,t));for(let e=0;e<t-1;e++)g.set(e,t,0)}else{for(let e=0;e<r;e++)g.set(e,t,0);g.set(t,t,1)}}if(d)for(let t=n-1;t>=0;t--){if(t<x&&0!==v[t])for(let e=t+1;e<n;e++){let r=0;for(let o=t+1;o<n;o++)r+=p.get(o,t)*p.get(o,e);r=-r/p.get(t+1,t);for(let o=t+1;o<n;o++)p.set(o,e,p.get(o,e)+r*p.get(o,t))}for(let e=0;e<n;e++)p.set(e,t,0);p.set(t,t,1)}let N=b-1,M=0,S=Number.EPSILON;for(;b>0;){let t,e;for(t=b-2;t>=-1&&-1!==t;t--){const e=Number.MIN_VALUE+S*Math.abs(f[t]+Math.abs(f[t+1]));if(Math.abs(v[t])<=e||Number.isNaN(v[t])){v[t]=0;break}}if(t===b-2)e=4;else{let r;for(r=b-1;r>=t&&r!==t;r--){let e=(r!==b?Math.abs(v[r]):0)+(r!==t+1?Math.abs(v[r-1]):0);if(Math.abs(f[r])<=S*e){f[r]=0;break}}r===t?e=3:r===b-1?e=1:(e=2,t=r)}switch(t++,e){case 1:{let e=v[b-2];v[b-2]=0;for(let r=b-2;r>=t;r--){let o=Rn(f[r],e),i=f[r]/o,a=e/o;if(f[r]=o,r!==t&&(e=-a*v[r-1],v[r-1]=i*v[r-1]),d)for(let t=0;t<n;t++)o=i*p.get(t,r)+a*p.get(t,b-1),p.set(t,b-1,-a*p.get(t,r)+i*p.get(t,b-1)),p.set(t,r,o)}break}case 2:{let e=v[t-1];v[t-1]=0;for(let n=t;n<b;n++){let o=Rn(f[n],e),i=f[n]/o,a=e/o;if(f[n]=o,e=-a*v[n],v[n]=i*v[n],u)for(let e=0;e<r;e++)o=i*g.get(e,n)+a*g.get(e,t-1),g.set(e,t-1,-a*g.get(e,n)+i*g.get(e,t-1)),g.set(e,n,o)}break}case 3:{const e=Math.max(Math.abs(f[b-1]),Math.abs(f[b-2]),Math.abs(v[b-2]),Math.abs(f[t]),Math.abs(v[t])),o=f[b-1]/e,i=f[b-2]/e,a=v[b-2]/e,s=f[t]/e,h=v[t]/e,c=((i+o)*(i-o)+a*a)/2,l=o*a*(o*a);let y=0;0===c&&0===l||(y=c<0?0-Math.sqrt(c*c+l):Math.sqrt(c*c+l),y=l/(c+y));let m=(s+o)*(s-o)+y,w=s*h;for(let e=t;e<b-1;e++){let o=Rn(m,w);0===o&&(o=Number.MIN_VALUE);let i=m/o,a=w/o;if(e!==t&&(v[e-1]=o),m=i*f[e]+a*v[e],v[e]=i*v[e]-a*f[e],w=a*f[e+1],f[e+1]=i*f[e+1],d)for(let t=0;t<n;t++)o=i*p.get(t,e)+a*p.get(t,e+1),p.set(t,e+1,-a*p.get(t,e)+i*p.get(t,e+1)),p.set(t,e,o);if(o=Rn(m,w),0===o&&(o=Number.MIN_VALUE),i=m/o,a=w/o,f[e]=o,m=i*v[e]+a*f[e+1],f[e+1]=-a*v[e]+i*f[e+1],w=a*v[e+1],v[e+1]=i*v[e+1],u&&e<r-1)for(let t=0;t<r;t++)o=i*g.get(t,e)+a*g.get(t,e+1),g.set(t,e+1,-a*g.get(t,e)+i*g.get(t,e+1)),g.set(t,e,o)}v[b-2]=m,M+=1;break}case 4:if(f[t]<=0&&(f[t]=f[t]<0?-f[t]:0,d))for(let e=0;e<=N;e++)p.set(e,t,-p.get(e,t));for(;t<N&&!(f[t]>=f[t+1]);){let e=f[t];if(f[t]=f[t+1],f[t+1]=e,d&&t<n-1)for(let r=0;r<n;r++)e=p.get(r,t+1),p.set(r,t+1,p.get(r,t)),p.set(r,t,e);if(u&&t<r-1)for(let n=0;n<r;n++)e=g.get(n,t+1),g.set(n,t+1,g.get(n,t)),g.set(n,t,e);t++}M=0,b--}}if(h){let t=p;p=g,g=t}this.m=r,this.n=n,this.s=f,this.U=g,this.V=p}solve(t){let e=t,r=this.threshold,n=this.s.length,o=kn.zeros(n,n);for(let t=0;t<n;t++)Math.abs(this.s[t])<=r?o.set(t,t,0):o.set(t,t,1/this.s[t]);let i=this.U,a=this.rightSingularVectors,s=a.mmul(o),u=a.rows,d=i.rows,h=kn.zeros(u,d);for(let t=0;t<u;t++)for(let e=0;e<d;e++){let r=0;for(let o=0;o<n;o++)r+=s.get(t,o)*i.get(e,o);h.set(t,e,r)}return h.mmul(e)}solveForDiagonal(t){return this.solve(kn.diag(t))}inverse(){let t=this.V,e=this.threshold,r=t.rows,n=t.columns,o=new kn(r,this.s.length);for(let i=0;i<r;i++)for(let r=0;r<n;r++)Math.abs(this.s[r])>e&&o.set(i,r,t.get(i,r)/this.s[r]);let i=this.U,a=i.rows,s=i.columns,u=new kn(r,a);for(let t=0;t<r;t++)for(let e=0;e<a;e++){let r=0;for(let n=0;n<s;n++)r+=o.get(t,n)*i.get(e,n);u.set(t,e,r)}return u}get condition(){return this.s[0]/this.s[Math.min(this.m,this.n)-1]}get norm2(){return this.s[0]}get rank(){let t=Math.max(this.m,this.n)*this.s[0]*Number.EPSILON,e=0,r=this.s;for(let n=0,o=r.length;n<o;n++)r[n]>t&&e++;return e}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 kn.diag(this.s)}}var On={center:[0,0],linkDistance:50},Dn=function(){function t(t){void 0===t&&(t={}),this.options=t,this.id="mds",this.options=o(o({},On),t)}return t.prototype.execute=function(t,e){return a(this,void 0,void 0,(function(){return s(this,(function(r){return[2,this.genericMDSLayout(!1,t,e)]}))}))},t.prototype.assign=function(t,e){return a(this,void 0,void 0,(function(){return s(this,(function(r){return this.genericMDSLayout(!0,t,e),[2]}))}))},t.prototype.genericMDSLayout=function(t,e,r){return a(this,void 0,void 0,(function(){var n,i,a,u,d,h,c,l,f,g,p,v;return s(this,(function(s){return n=o(o({},this.options),r),i=n.center,a=void 0===i?[0,0]:i,u=n.linkDistance,d=void 0===u?50:u,h=e.getAllNodes(),c=e.getAllEdges(),(null==h?void 0:h.length)&&1!==h.length?(l=x({nodes:h,edges:c},!1),f=w(l),In(f),g=E(f,d),p=Pn(g),v=[],p.forEach((function(t,e){var r=D(h[e]);r.data.x=t[0]+a[0],r.data.y=t[1]+a[1],v.push(r)})),t&&v.forEach((function(t){return e.mergeNodeData(t.id,{x:t.data.x,y:t.data.y})})),[2,{nodes:v,edges:c}]):[2,q(e,t,a)]}))}))},t}(),In=function(t){var e=-999999;t.forEach((function(t){t.forEach((function(t){t!==1/0&&e<t&&(e=t)}))})),t.forEach((function(r,n){r.forEach((function(r,o){r===1/0&&(t[n][o]=e)}))}))},Pn=function(t){var e=kn.mul(kn.pow(t,2),-.5),r=e.mean("row"),n=e.mean("column"),o=e.mean();e.add(o).subRowVector(r).subColumnVector(n);var i=new _n(e),a=kn.sqrt(i.diagonalMatrix).diagonal();return i.leftSingularVectors.toJSON().map((function(t){return kn.mul([t],[a]).toJSON()[0].splice(0,2)}))},zn={iterations:10,height:10,width:10,speed:100,gravity:10,k:5},Tn=function(t,e,r,n,o,i){e.forEach((function(a,s){r[s]={x:0,y:0},e.forEach((function(e,u){if(s!==u&&o[s]===o[u]){var d=a.x-e.x,h=a.y-e.y,c=Math.sqrt(d*d+h*h);if(0===c){c=1;var l=s>u?1:-1;d=.01*l,h=.01*l}if(c<i(t[s])/2+i(t[u])/2){var f=n*n/c;r[s].x+=d/c*f,r[s].y+=h/c*f}}}))}))},Cn=function(t,e,r,n,o,i,a,s){var u=i||a/10;return n&&e.forEach((function(e,r){var n=t[r].x-t[o].x,i=t[r].y-t[o].y,a=Math.sqrt(n*n+i*i),s=i/a,u=-n/a,d=Math.sqrt(e.x*e.x+e.y*e.y),h=Math.acos((s*e.x+u*e.y)/d);h>Math.PI/2&&(h-=Math.PI/2,s*=-1,u*=-1);var c=Math.cos(h)*d;e.x=s*c,e.y=u*c})),t.forEach((function(i,a){if(a!==o){var d=Math.sqrt(e[a].x*e[a].x+e[a].y*e[a].y);if(d>0&&a!==o){var h=Math.min(u*(r/800),d);if(i.x+=e[a].x/d*h,i.y+=e[a].y/d*h,n){var c=i.x-t[o].x,l=i.y-t[o].y,f=Math.sqrt(c*c+l*l);c=c/f*s[a],l=l/f*s[a],i.x=t[o].x+c,i.y=t[o].y+l}}}})),t},qn={maxIteration:1e3,focusNode:null,unitRadius:null,linkDistance:50,preventOverlap:!1,strictRadial:!0,maxPreventOverlapIteration:200,sortStrength:10},Ln=function(){function t(t){void 0===t&&(t={}),this.options=t,this.id="radial",this.options=o(o({},qn),t)}return t.prototype.execute=function(t,e){return a(this,void 0,void 0,(function(){return s(this,(function(r){return[2,this.genericRadialLayout(!1,t,e)]}))}))},t.prototype.assign=function(t,e){return a(this,void 0,void 0,(function(){return s(this,(function(r){return this.genericRadialLayout(!0,t,e),[2]}))}))},t.prototype.genericRadialLayout=function(t,e,r){return a(this,void 0,void 0,(function(){var n,i,a,h,c,l,f,g,p,v,y,m,E,b,N,M,S,k,A,R,_,O,I,P,z,T,L,j,F,V,B,$,W,U,G,Y,K,J,X,Q,Z,tt,et;return s(this,(function(s){if(n=o(o({},this.options),r),i=n.width,a=n.height,h=n.center,c=n.focusNode,l=n.unitRadius,f=n.nodeSize,g=n.nodeSpacing,p=n.strictRadial,v=n.preventOverlap,y=n.maxPreventOverlapIteration,m=n.sortBy,E=n.linkDistance,b=void 0===E?50:E,N=n.sortStrength,M=void 0===N?10:N,S=n.maxIteration,k=void 0===S?1e3:S,A=e.getAllNodes(),R=e.getAllEdges(),_=i||"undefined"==typeof window?i:window.innerWidth,O=a||"undefined"==typeof window?a:window.innerHeight,I=h||[_/2,O/2],!(null==A?void 0:A.length)||1===A.length)return[2,q(e,t,I)];if(P=A[0],H(c)){for(z=0;z<A.length;z++)if(A[z].id===c){P=A[z];break}}else P=c||A[0];return T=Vn(A,P.id),L=x({nodes:A,edges:R},!1),j=w(L),F=$n(j,T),Bn(j,T,F+1),V=j[T],B=_-I[0]>I[0]?I[0]:_-I[0],$=O-I[1]>I[1]?I[1]:O-I[1],0===B&&(B=_/2),0===$&&($=O/2),W=Math.min(B,$),U=Math.max.apply(Math,d([],u(V),!1)),G=[],Y=l||W/U,V.forEach((function(t,e){G[e]=t*Y})),K=jn(A,j,b,G,Y,m,M),J=Fn(K),X=function(t,e,r){try{var n=kn.mul(kn.pow(e,2),-.5),o=n.mean("row"),i=n.mean("column"),a=n.mean();n.add(a).subRowVector(o).subColumnVector(i);var s=new _n(n),u=kn.sqrt(s.diagonalMatrix).diagonal();return s.leftSingularVectors.toJSON().map((function(e){return kn.mul([e],[u]).toJSON()[0].splice(0,t)}))}catch(t){for(var d=[],h=0;h<e.length;h++){var c=Math.random()*r,l=Math.random()*r;d.push([c,l])}return d}}(b,K,b),Q=X.map((function(t){var e=u(t,2),r=e[0],n=e[1];return{x:(isNaN(r)?Math.random()*b:r)-X[T][0],y:(isNaN(n)?Math.random()*b:n)-X[T][1]}})),this.run(k,Q,J,K,G,T),v&&(Z=C(f,g),tt={nodes:A,nodeSizeFunc:Z,positions:Q,radii:G,height:O,width:_,strictRadial:Boolean(p),focusIdx:T,iterations:y||200,k:Q.length/4.5},Q=function(t,e){for(var r=o(o({},zn),e),n=r.positions,i=r.iterations,a=r.width,s=r.k,u=r.speed,d=void 0===u?100:u,h=r.strictRadial,c=r.focusIdx,l=r.radii,f=void 0===l?[]:l,g=r.nodeSizeFunc,p=t.getAllNodes(),v=[],y=a/10,m=0;m<i;m++)n.forEach((function(t,e){v[e]={x:0,y:0}})),Tn(p,n,v,s,f,g),Cn(n,v,d,h,c,y,a,f);return n}(e,tt)),et=[],Q.forEach((function(t,e){var r=D(A[e]);r.data.x=t.x+I[0],r.data.y=t.y+I[1],et.push(r)})),t&&et.forEach((function(t){return e.mergeNodeData(t.id,{x:t.data.x,y:t.data.y})})),[2,{nodes:et,edges:R}]}))}))},t.prototype.run=function(t,e,r,n,o,i){for(var a=0;a<=t;a++){var s=a/t;this.oneIteration(s,e,o,n,r,i)}},t.prototype.oneIteration=function(t,e,r,n,o,i){var a=1-t;e.forEach((function(s,u){var d=_(s,{x:0,y:0}),h=0===d?0:1/d;if(u!==i){var c=0,l=0,f=0;e.forEach((function(t,e){if(u!==e){var r=_(s,t),i=0===r?0:1/r,a=n[e][u];f+=o[u][e],c+=o[u][e]*(t.x+a*(s.x-t.x)*i),l+=o[u][e]*(t.y+a*(s.y-t.y)*i)}}));var g=0===r[u]?0:1/r[u];f*=a,f+=t*g*g,c*=a,c+=t*g*s.x*h,s.x=c/f,l*=a,l+=t*g*s.y*h,s.y=l/f}}))},t}(),jn=function(t,e,r,n,o,i,a){if(!t)return[];var s=[];if(e){var u={};e.forEach((function(e,d){var h=[];e.forEach((function(e,s){var c,l;if(d===s)h.push(0);else if(n[d]===n[s])if("data"===i)h.push(e*(Math.abs(d-s)*a)/(n[d]/o));else if(i){var f=void 0,g=void 0;if(u[t[d].id])f=u[t[d].id];else{var p=("id"===i?t[d].id:null===(c=t[d].data)||void 0===c?void 0:c[i])||0;f=H(p)?p.charCodeAt(0):p,u[t[d].id]=f}u[t[s].id]?g=u[t[s].id]:(p=("id"===i?t[s].id:null===(l=t[s].data)||void 0===l?void 0:l[i])||0,g=H(p)?p.charCodeAt(0):p,u[t[s].id]=g),h.push(e*(Math.abs(f-g)*a)/(n[d]/o))}else h.push(e*r/(n[d]/o));else{var v=(r+o)/2;h.push(e*v)}})),s.push(h)}))}return s},Fn=function(t){for(var e=t.length,r=t[0].length,n=[],o=0;o<e;o++){for(var i=[],a=0;a<r;a++)0!==t[o][a]?i.push(1/(t[o][a]*t[o][a])):i.push(0);n.push(i)}return n},Vn=function(t,e){var r=-1;return t.forEach((function(t,n){t.id===e&&(r=n)})),Math.max(r,0)},Bn=function(t,e,r){for(var n=t.length,o=0;o<n;o++)if(t[e][o]===1/0){t[e][o]=r,t[o][e]=r;for(var i=0;i<n;i++)t[o][i]!==1/0&&t[e][i]===1/0&&(t[e][i]=r+t[o][i],t[i][e]=r+t[o][i])}for(o=0;o<n;o++)if(o!==e)for(i=0;i<n;i++)if(t[o][i]===1/0){var a=Math.abs(t[e][o]-t[e][i]);a=0===a?1:a,t[o][i]=a}},$n=function(t,e){for(var r=0,n=0;n<t[e].length;n++)t[e][n]!==1/0&&(r=t[e][n]>r?t[e][n]:r);return r},Wn={center:[0,0],width:300,height:300},Un=function(){function t(t){void 0===t&&(t={}),this.options=t,this.id="random",this.options=o(o({},Wn),t)}return t.prototype.execute=function(t,e){return a(this,void 0,void 0,(function(){return s(this,(function(r){return[2,this.genericRandomLayout(!1,t,e)]}))}))},t.prototype.assign=function(t,e){return a(this,void 0,void 0,(function(){return s(this,(function(r){return this.genericRandomLayout(!0,t,e),[2]}))}))},t.prototype.genericRandomLayout=function(t,e,r){return a(this,void 0,void 0,(function(){var n,i,a,u,d,h,c,l,f;return s(this,(function(s){return n=o(o({},this.options),r),i=n.center,a=n.width,u=n.height,d=e.getAllNodes(),h=a||"undefined"==typeof window?a:window.innerWidth,c=u||"undefined"==typeof window?u:window.innerHeight,l=i||[h/2,c/2],f=[],d&&d.forEach((function(t){f.push({id:t.id,data:{x:.9*(Math.random()-.5)*h+l[0],y:.9*(Math.random()-.5)*c+l[1]}})})),t&&f.forEach((function(t){return e.mergeNodeData(t.id,{x:t.data.x,y:t.data.y})})),[2,{nodes:f,edges:e.getAllEdges()}]}))}))},t}(),Gn={circular:j,concentric:K,mds:Dn,random:Un,grid:tn,radial:Ln,force:jr,d3force:Kt,fruchterman:Qr,forceAtlas2:Jr,dagre:zr};function Hn(t,e){Gn[t]=e}function Yn(t){return!!t.tick&&!!t.stop}})();var o=n.SB,i=n.W1,a=n.jA,s=n.Vq,u=n.E9,d=n.y7,h=n.O2,c=n.Me,l=n.AI,f=n.D4,g=n._5,p=n.y9,v=n._A,y=n.d9,m=n.ul,w=n.qs,x=n.gl,E=n.jE,b=n.tO,N=n.zJ,M=n.h$,S=n.BI,k=n.$y,A=n.H0,R=n.kJ,_=n.hY,O=n.qR,D=n.i_,I=n.nu,P=n.He,z=n.A3;export{o as CircularLayout,i as ConcentricLayout,a as D3ForceLayout,s as DagreLayout,u as ForceAtlas2Layout,d as ForceLayout,h as FruchtermanLayout,c as GridLayout,l as MDSLayout,f as RadialLayout,g as RandomLayout,p as Supervisor,v as camelize,y as clone,m as cloneFormatData,w as floydWarshall,x as formatNodeSize,E as formatNumberFn,b as formatSizeFn,N as getAdjMatrix,M as getAvgNodePosition,S as getCoreNodeAndRelativeLeafNodes,k as getEuclideanDistance,A as getLayoutBBox,R as isArray,_ as isLayoutWithIterations,O as registerLayout,D as registry,I as scaleMatrix,P as toNumber,z as traverseTreeUp};
|
|
2
2
|
//# sourceMappingURL=index.esm.js.map
|