@antv/layout 1.0.0-alpha.13 → 1.0.0-alpha.14
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/README.md +213 -17
- package/dist/b6a955aaa104d7ff3f17.worker.js +2 -0
- package/dist/b6a955aaa104d7ff3f17.worker.js.map +1 -0
- package/dist/index.min.js +1 -1
- package/dist/index.min.js.map +1 -1
- package/esm/b6a955aaa104d7ff3f17.worker.js +2 -0
- package/esm/b6a955aaa104d7ff3f17.worker.js.map +1 -0
- package/esm/index.esm.js +1 -1
- package/esm/index.esm.js.map +1 -1
- package/lib/index.d.ts +3 -1
- package/lib/types.d.ts +2 -1
- package/lib/util/function.d.ts +0 -1
- package/lib/util/number.d.ts +0 -2
- package/lib/util/object.d.ts +0 -1
- package/lib/util/string.d.ts +0 -1
- package/package.json +5 -3
- package/dist/d869b88cfe3353e7436d.worker.js +0 -2
- package/dist/d869b88cfe3353e7436d.worker.js.map +0 -1
- package/esm/d869b88cfe3353e7436d.worker.js +0 -2
- package/esm/d869b88cfe3353e7436d.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),h=r?r+e:e;return t._events[h]?t._events[h].fn?t._events[h]=[t._events[h],a]:t._events[h].push(a):(t._events[h]=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 h,u,l=this._events[a],c=arguments.length;if(l.fn){switch(l.once&&this.removeListener(t,l.fn,void 0,!0),c){case 1:return l.fn.call(l.context),!0;case 2:return l.fn.call(l.context,e),!0;case 3:return l.fn.call(l.context,e,n),!0;case 4:return l.fn.call(l.context,e,n,o),!0;case 5:return l.fn.call(l.context,e,n,o,i),!0;case 6:return l.fn.call(l.context,e,n,o,i,s),!0}for(u=1,h=new Array(c-1);u<c;u++)h[u-1]=arguments[u];l.fn.apply(l.context,h)}else{var f,d=l.length;for(u=0;u<d;u++)switch(l[u].once&&this.removeListener(t,l[u].fn,void 0,!0),c){case 1:l[u].fn.call(l[u].context);break;case 2:l[u].fn.call(l[u].context,e);break;case 3:l[u].fn.call(l[u].context,e,n);break;case 4:l[u].fn.call(l[u].context,e,n,o);break;default:if(!h)for(f=1,h=new Array(c-1);f<c;f++)h[f-1]=arguments[f];l[u].fn.apply(l[u].context,h)}}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 h=0,u=[],l=a.length;h<l;h++)(a[h].fn!==e||o&&!a[h].once||n&&a[h].context!==n)&&u.push(a[h]);u.length?this._events[i]=1===u.length?u[0]:u: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:()=>Fe,stopLayout:()=>Pe});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){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 i(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;class s{nodeMap=new Map;edgeMap=new Map;inEdgesMap=new Map;outEdgesMap=new Map;treeIndices=new Map;changes=[];batchCount=0;onChanged=()=>{};constructor(t){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=[],this.onChanged({graph:this,changes:t})}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){if(!this.hasNode(t))throw new Error("Node not found for id: "+t)}hasNode(t){return this.nodeMap.has(t)}areNeighbors(t,e){return this.checkNodeExistence(t),this.getNeighbors(e).some((e=>e.id===t))}getNode(t){return this.checkNodeExistence(t),this.nodeMap.get(t)}getRelatedEdges(t,e){this.checkNodeExistence(t);const r=this.inEdgesMap.get(t),n=this.outEdgesMap.get(t);if("in"===e)return Array.from(r);if("out"===e)return Array.from(n);const o=new Set([...r,...n]);return Array.from(o)}getDegree(t,e){return this.getRelatedEdges(t,e).length}getSuccessors(t){const e=this.getRelatedEdges(t,"out").map((t=>t.target));return Array.from(new Set(e)).map((t=>this.getNode(t)))}getPredecessors(t){const e=this.getRelatedEdges(t,"in").map((t=>t.source));return Array.from(new Set(e)).map((t=>this.getNode(t)))}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.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),r=this.inEdgesMap.get(t),n=this.outEdgesMap.get(t);r?.forEach((t=>this.doRemoveEdge(t.id))),n?.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);e.add(t),r.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);r.delete(e),n.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.outEdgesMap.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.inEdgesMap.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.treeIndices.has(t))throw new Error("Tree structure not found for treeKey: "+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}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})}))}getAllNodes(){return Array.from(this.nodeMap.values())}getAllEdges(){return Array.from(this.edgeMap.values())}doBFS(t,e,r){for(;t.length;){const n=t.shift();r(n),e.add(n.id),this.getSuccessors(n.id).forEach((r=>{e.has(r.id)||(e.add(r.id),t.push(r))}))}}bfs(t,e){this.doBFS([this.getNode(t)],new Set,e)}doDFS(t,e,r){r(t),e.add(t.id),this.getSuccessors(t.id).forEach((t=>{e.has(t.id)||this.doDFS(t,e,r)}))}dfs(t,e){this.doDFS(this.getNode(t),new Set,e)}clone(){const t=this.getAllNodes().map((t=>({...t,data:{...t.data}}))),e=this.getAllEdges().map((t=>({...t,data:{...t.data}}))),r=new s({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 a=function(t){return"string"==typeof t},h=/-(\\w)/g,u=(function(t){return t.replace(h,(function(t,e){return e?e.toUpperCase():""}))},Object.create(null),Array.isArray),l=function(t){return"number"==typeof t},c=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},f=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},d=function(t,e){return Math.sqrt((t.x-e.x)*(t.x-e.x)+(t.y-e.y)*(t.y-e.y))},g=function(t){return null!==t&&"object"==typeof t},p=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 p(t)}))}if("object"==typeof t){var r={};return Object.keys(t).forEach((function(e){r[e]=p(t[e])})),r}return t},y=function(t,e){var r=p(t);return r.data=r.data||{},e&&(l(r.data.x)||(r.data.x=Math.random()*e[0]),l(r.data.y)||(r.data.y=Math.random()*e[1])),r},m=function(t){return"function"==typeof t};function w(t,e){return m(e)?e:l(e)?function(){return e}:function(){return t}}function v(t,e,r){return void 0===r&&(r=!0),e||0===e?m(e)?e:l(e)?function(){return e}:u(e)?function(){if(r){var n=Math.max.apply(Math,i([],o(e),!1));return isNaN(n)?t:n}return e}:g(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?u(r)?r[0]>r[1]?r[0]:r[1]:g(r)?r.width>r.height?r.width:r.height:r:t}}var x=function(t,e,n,o){var i=t.getAllNodes(),s=t.getAllEdges();if(!(null==i?void 0:i.length)){var a={nodes:[],edges:s};return null==o||o(a),a}if(1===i.length)return e&&t.mergeNodeData(i[0].id,{x:n[0],y:n[1]}),a={nodes:[r(r({},i[0]),{data:r(r({},i[0].data),{x:n[0],y:n[1]})})],edges:s},null==o||o(a),a},M={radius:null,startRadius:null,endRadius:null,startAngle:0,endAngle:2*Math.PI,clockwise:!0,divisions:1,ordering:null,angleRatio:1},b=function(){function t(t){void 0===t&&(t={}),this.options=t,this.id="circular",this.options=r(r({},M),t)}return t.prototype.execute=function(t,e){return this.genericCircularLayout(!1,t,e)},t.prototype.assign=function(t,e){this.genericCircularLayout(!0,t,e)},t.prototype.genericCircularLayout=function(t,e,n){var i=r(r({},this.options),n),s=i.width,a=i.height,h=i.center,u=i.divisions,l=i.startAngle,c=void 0===l?0:l,f=i.endAngle,d=void 0===f?2*Math.PI:f,g=i.angleRatio,p=i.ordering,m=i.clockwise,M=i.nodeSpacing,b=i.nodeSize,S=i.layoutInvisibles,A=i.onLayoutEnd,k=e.getAllNodes(),I=e.getAllEdges();S||(k=k.filter((function(t){var e=(t.data||{}).visible;return e||void 0===e})),I=I.filter((function(t){var e=(t.data||{}).visible;return e||void 0===e})));var D=o(N(s,a,h),3),R=D[0],_=D[1],z=D[2],O=null==k?void 0:k.length;if(!O||1===O)return x(e,t,z,A);var T=(d-c)/O,C=i.radius,q=i.startRadius,L=i.endRadius;if(M){var P=w(10,M),F=v(10,b),j=-1/0;k.forEach((function(t){var e=F(t);j<e&&(j=e)}));var V=0;k.forEach((function(t,e){V+=0===e?j||10:(P(t)||0)+(j||10)})),C=V/(2*Math.PI)}else C||q||L?!q&&L?q=L:q&&!L&&(L=q):C=Math.min(_,R)/2;var W=T*g,$=[];$="topology"===p?E(e,k):"topology-directed"===p?E(e,k,!0):"degree"===p?function(t,e){var r=[];return e.forEach((function(t,e){r.push(y(t))})),r.sort((function(e,r){return t.getDegree(e.id,"both")-t.getDegree(r.id,"both")})),r}(e,k):k.map((function(t){return y(t)}));for(var G=Math.ceil(O/u),B=0;B<O;++B){var U=C;U||null===q||null===L||(U=q+B*(L-q)/(O-1)),U||(U=10+100*B/(O-1));var H=c+B%G*W+2*Math.PI/u*Math.floor(B/G);m||(H=d-B%G*W-2*Math.PI/u*Math.floor(B/G)),$[B].data.x=z[0]+Math.cos(H)*U,$[B].data.y=z[1]+Math.sin(H)*U}t&&$.forEach((function(t){e.mergeNodeData(t.id,{x:t.data.x,y:t.data.y})}));var K={nodes:$,edges:I};return null==A||A(K),K},t}(),E=function(t,e,r){void 0===r&&(r=!1);var n=[y(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),l=!1,c=0;c<u.length;c++){var f=u[c];if(t.getDegree(f.id)===t.getDegree(a.id)&&!o[f.id]){n.push(y(f)),o[f.id]=!0,l=!0;break}}for(var d=0;!l&&(o[e[d].id]||(n.push(y(e[d])),o[e[d].id]=!0,l=!0),++d!==i););}else n.push(y(a)),o[a.id]=!0,s++})),n},N=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]},S={nodeSize:30,nodeSpacing:10,preventOverlap:!1,sweep:void 0,equidistant:!1,startAngle:1.5*Math.PI,clockwise:!0,maxLevelDiff:void 0,sortBy:"degree"},A=function(){function t(t){void 0===t&&(t={}),this.options=t,this.id="concentric",this.options=r(r({},S),t)}return t.prototype.execute=function(t,e){return this.genericConcentricLayout(!1,t,e)},t.prototype.assign=function(t,e){this.genericConcentricLayout(!0,t,e)},t.prototype.genericConcentricLayout=function(t,e,n){var o=r(r({},this.options),n),i=o.center,s=o.width,h=o.height,c=o.sortBy,f=o.maxLevelDiff,d=o.sweep,p=o.clockwise,w=o.equidistant,v=o.preventOverlap,M=o.startAngle,b=void 0===M?1.5*Math.PI:M,E=o.nodeSize,N=o.nodeSpacing,S=o.layoutInvisibles,A=o.onLayoutEnd,k=e.getAllNodes(),I=e.getAllEdges();S||(k=k.filter((function(t){var e=(t.data||{}).visible;return e||void 0===e})),I=I.filter((function(t){var e=(t.data||{}).visible;return e||void 0===e})));var D=s||"undefined"==typeof window?s:window.innerWidth,R=h||"undefined"==typeof window?h:window.innerHeight,_=i||[D/2,R/2];if(!(null==k?void 0:k.length)||1===k.length)return x(e,t,_,A);var z,O=[],T=0;z=u(E)?Math.max(E[0],E[1]):E,u(N)?T=Math.max(N[0],N[1]):l(N)&&(T=N),k.forEach((function(t){var e=y(t);O.push(e);var r=z,n=e.data;u(n.size)?r=Math.max(n.size[0],n.size[1]):l(n.size)?r=n.size:g(n.size)&&(r=Math.max(n.size.width,n.size.height)),z=Math.max(z,r),m(N)&&(T=Math.max(N(t),T))}));var C={};O.forEach((function(t,e){C[t.id]=e}));var q=c;a(q)&&void 0!==O[0].data[q]||(q="degree"),"degree"===q?O.sort((function(t,r){return e.getDegree(r.id,"both")-e.getDegree(t.id,"both")})):O.sort((function(t,e){return e.data[q]-t.data[q]}));var L=O[0],P=(f||("degree"===q?e.getDegree(L.id,"both"):L.data[q]))/4,F=[{nodes:[]}],j=F[0];O.forEach((function(t){if(j.nodes.length>0){var r="degree"===q?Math.abs(e.getDegree(j.nodes[0].id,"both")-e.getDegree(t.id,"both")):Math.abs(j.nodes[0].data[q]-t.data[q]);P&&r>=P&&(j={nodes:[]},F.push(j))}j.nodes.push(t)}));var V=z+T;if(!v){var W=F.length>0&&F[0].nodes.length>1,$=(Math.min(D,R)/2-V)/(F.length+(W?1:0));V=Math.min(V,$)}var G=0;if(F.forEach((function(t){var e=void 0===d?2*Math.PI-2*Math.PI/t.nodes.length:d;if(t.dTheta=e/Math.max(1,t.nodes.length-1),t.nodes.length>1&&v){var r=Math.cos(t.dTheta)-Math.cos(0),n=Math.sin(t.dTheta)-Math.sin(0),o=Math.sqrt(V*V/(r*r+n*n));G=Math.max(o,G)}t.r=G,G+=V})),w){for(var B=0,U=0,H=0;H<F.length;H++){var K=(F[H].r||0)-U;B=Math.max(B,K)}U=0,F.forEach((function(t,e){0===e&&(U=t.r||0),t.r=U,U+=B}))}F.forEach((function(t){var e=t.dTheta||0,r=t.r||0;t.nodes.forEach((function(t,n){var o=b+(p?1:-1)*e*n;t.data.x=_[0]+r*Math.cos(o),t.data.y=_[1]+r*Math.sin(o)}))})),t&&O.forEach((function(t){return e.mergeNodeData(t.id,{x:t.data.x,y:t.data.y})}));var J={nodes:O,edges:I};return null==A||A(J),J},t}();function k(t,e,r,n){if(isNaN(e)||isNaN(r))return t;var o,i,s,a,h,u,l,c,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,(l=r>=(s=(y+w)/2))?y=s:w=s,o=d,!(d=d[c=l<<1|u]))return o[c]=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[c]=g:t._root=g,t;do{o=o?o[c]=new Array(4):t._root=new Array(4),(u=e>=(i=(p+m)/2))?p=i:m=i,(l=r>=(s=(y+w)/2))?y=s:w=s}while((c=l<<1|u)==(f=(h>=s)<<1|a>=i));return o[f]=d,o[c]=g,t}function I(t,e,r,n,o){this.node=t,this.x0=e,this.y0=r,this.x1=n,this.y1=o}function D(t){return t[0]}function R(t){return t[1]}function _(t,e,r){var n=new z(null==e?D:e,null==r?R:r,NaN,NaN,NaN,NaN);return null==t?n:n.addAll(t)}function z(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 O(t){for(var e={data:t.data},r=e;t=t.next;)r=r.next={data:t.data};return e}var T=_.prototype=z.prototype;function C(t){return function(){return t}}function q(t){return 1e-6*(t()-.5)}T.copy=function(){var t,e,r=new z(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=O(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]=O(e));return r},T.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)},T.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,l=-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))||(s[r]=n,a[r]=o,n<h&&(h=n),n>l&&(l=n),o<u&&(u=o),o>c&&(c=o));if(h>l||u>c)return this;for(this.cover(h,u).cover(l,c),r=0;r<i;++r)k(this,s[r],a[r],t[r]);return this},T.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},T.data=function(){var t=[];return this.visit((function(e){if(!e.length)do{t.push(e.data)}while(e=e.next)})),t},T.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]]},T.find=function(t,e,r){var n,o,i,s,a,h,u,l=this._x0,c=this._y0,f=this._x1,d=this._y1,g=[],p=this._root;for(p&&g.push(new I(p,l,c,f,d)),null==r?r=1/0:(l=t-r,c=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)<l||(a=h.y1)<c))if(p.length){var y=(o+s)/2,m=(i+a)/2;g.push(new I(p[3],y,m,s,a),new I(p[2],o,m,y,a),new I(p[1],y,i,s,m),new I(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);l=t-M,c=e-M,f=t+M,d=e+M,n=p.data}}return n},T.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,l,c,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,(l=s>=(h=(p+m)/2))?p=h:m=h,e=d,!(d=d[c=l<<1|u]))return this;if(!d.length)break;(e[c+1&3]||e[c+2&3]||e[c+3&3])&&(r=e,f=c)}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[c]=o:delete e[c],(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)},T.removeAll=function(t){for(var e=0,r=t.length;e<r;++e)this.remove(t[e]);return this},T.root=function(){return this._root},T.size=function(){var t=0;return this.visit((function(e){if(!e.length)do{++t}while(e=e.next)})),t},T.visit=function(t){var e,r,n,o,i,s,a=[],h=this._root;for(h&&a.push(new I(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,l=(o+s)/2;(r=h[3])&&a.push(new I(r,u,l,i,s)),(r=h[2])&&a.push(new I(r,n,l,u,s)),(r=h[1])&&a.push(new I(r,u,o,i,l)),(r=h[0])&&a.push(new I(r,n,o,u,l))}return this},T.visitAfter=function(t){var e,r=[],n=[];for(this._root&&r.push(new I(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,l=(s+h)/2,c=(a+u)/2;(i=o[0])&&r.push(new I(i,s,a,l,c)),(i=o[1])&&r.push(new I(i,l,a,h,c)),(i=o[2])&&r.push(new I(i,s,c,l,u)),(i=o[3])&&r.push(new I(i,l,c,h,u))}n.push(e)}for(;e=n.pop();)t(e.node,e.x0,e.y0,e.x1,e.y1);return this},T.x=function(t){return arguments.length?(this._x=t,this):this._x},T.y=function(t){return arguments.length?(this._y=t,this):this._y};var L={value:()=>{}};function P(){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 F(n)}function F(t){this._=t}function j(t,e){return t.trim().split(/^|\\s+/).map((function(t){var r="",n=t.indexOf(".");if(n>=0&&(r=t.slice(n+1),t=t.slice(0,n)),t&&!e.hasOwnProperty(t))throw new Error("unknown type: "+t);return{type:t,name:r}}))}function V(t,e){for(var r,n=0,o=t.length;n<o;++n)if((r=t[n]).name===e)return r.value}function W(t,e,r){for(var n=0,o=t.length;n<o;++n)if(t[n].name===e){t[n]=L,t=t.slice(0,n).concat(t.slice(n+1));break}return null!=r&&t.push({name:e,value:r}),t}F.prototype=P.prototype={constructor:F,on:function(t,e){var r,n=this._,o=j(t+"",n),i=-1,s=o.length;if(!(arguments.length<2)){if(null!=e&&"function"!=typeof e)throw new Error("invalid callback: "+e);for(;++i<s;)if(r=(t=o[i]).type)n[r]=W(n[r],t.name,e);else if(null==e)for(r in n)n[r]=W(n[r],t.name,null);return this}for(;++i<s;)if((r=(t=o[i]).type)&&(r=V(n[r],t.name)))return r},copy:function(){var t={},e=this._;for(var r in e)t[r]=e[r].slice();return new F(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 $=P;var G,B,U=0,H=0,K=0,J=0,Y=0,X=0,Q="object"==typeof performance&&performance.now?performance:Date,Z="object"==typeof window&&window.requestAnimationFrame?window.requestAnimationFrame.bind(window):function(t){setTimeout(t,17)};function tt(){return Y||(Z(et),Y=Q.now()+X)}function et(){Y=0}function rt(){this._call=this._time=this._next=null}function nt(t,e,r){var n=new rt;return n.restart(t,e,r),n}function ot(){Y=(J=Q.now())+X,U=H=0;try{!function(){tt(),++U;for(var t,e=G;e;)(t=Y-e._time)>=0&&e._call.call(void 0,t),e=e._next;--U}()}finally{U=0,function(){for(var t,e,r=G,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:G=e);B=t,st(n)}(),Y=0}}function it(){var t=Q.now(),e=t-J;e>1e3&&(X-=e,J=t)}function st(t){U||(H&&(H=clearTimeout(H)),t-Y>24?(t<1/0&&(H=setTimeout(ot,t-Q.now()-X)),K&&(K=clearInterval(K))):(K||(J=Q.now(),K=setInterval(it,1e3)),U=1,Z(ot)))}rt.prototype=nt.prototype={constructor:rt,restart:function(t,e,r){if("function"!=typeof t)throw new TypeError("callback is not a function");r=(null==r?tt():+r)+(null==e?0:+e),this._next||B===this||(B?B._next=this:G=this,B=this),this._call=t,this._time=r,st()},stop:function(){this._call&&(this._call=null,this._time=1/0,st())}};const at=4294967296;function ht(t){return t.x}function ut(t){return t.y}var lt=Math.PI*(3-Math.sqrt(5));function ct(t){var e,r=1,n=.001,o=1-Math.pow(n,1/300),i=0,s=.6,a=new Map,h=nt(c),u=$("tick","end"),l=function(){let t=1;return()=>(t=(1664525*t+1013904223)%at)/at}();function c(){f(),u.call("tick",e),r<n&&(h.stop(),u.call("end",e))}function f(n){var h,u,l=t.length;void 0===n&&(n=1);for(var c=0;c<n;++c)for(r+=(i-r)*o,a.forEach((function(t){t(r)})),h=0;h<l;++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=10*Math.sqrt(.5+r),i=r*lt;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,l),e}return null==t&&(t=[]),d(),e={tick:f,restart:function(){return h.restart(c),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?(l=t,a.forEach(g),e):l},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,l=t.length;for(null==n?n=1/0:n*=n,u=0;u<l;++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 ft(){var t,e,r,n,o,i=C(-30),s=1,a=1/0,h=.81;function u(r){var o,i=t.length,s=_(t,ht,ut).visitAfter(c);for(n=r,o=0;o<i;++o)e=t[o],s.visit(f)}function l(){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,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,l){if(!t.value)return!0;var c=t.x-e.x,f=t.y-e.y,d=l-i,g=c*c+f*f;if(d*d/h<g)return g<a&&(0===c&&(g+=(c=q(r))*c),0===f&&(g+=(f=q(r))*f),g<s&&(g=Math.sqrt(s*g)),e.vx+=c*t.value*n/g,e.vy+=f*t.value*n/g),!0;if(!(t.length||g>=a)){(t.data!==e||t.next)&&(0===c&&(g+=(c=q(r))*c),0===f&&(g+=(f=q(r))*f),g<s&&(g=Math.sqrt(s*g)));do{t.data!==e&&(d=o[t.data.index]*n/g,e.vx+=c*d,e.vy+=f*d)}while(t=t.next)}}return u.initialize=function(e,n){t=e,r=n,l()},u.strength=function(t){return arguments.length?(i="function"==typeof t?t:C(+t),l(),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 dt(t){return t.index}function gt(t,e){var r=t.get(e);if(!r)throw new Error("node not found: "+e);return r}function pt(t){var e,r,n,o,i,s,a=dt,h=function(t){return 1/Math.min(o[t.source.index],o[t.target.index])},u=C(30),l=1;function c(n){for(var o=0,a=t.length;o<l;++o)for(var h,u,c,f,d,g,p,y=0;y<a;++y)u=(h=t[y]).source,f=(c=h.target).x+c.vx-u.x-u.vx||q(s),d=c.y+c.vy-u.y-u.vy||q(s),f*=g=((g=Math.sqrt(f*f+d*d))-r[y])/g*n*e[y],d*=g,c.vx-=f*(p=i[y]),c.vy-=d*p,u.vx+=f*(p=1-p),u.vy+=d*p}function f(){if(n){var s,h,u=n.length,l=t.length,c=new Map(n.map(((t,e)=>[a(t,e,n),t])));for(s=0,o=new Array(u);s<l;++s)(h=t[s]).index=s,"object"!=typeof h.source&&(h.source=gt(c,h.source)),"object"!=typeof h.target&&(h.target=gt(c,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(l);s<l;++s)h=t[s],i[s]=o[h.source.index]/(o[h.source.index]+o[h.target.index]);e=new Array(l),d(),r=new Array(l),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=[]),c.initialize=function(t,e){n=t,s=e,f()},c.links=function(e){return arguments.length?(t=e,f(),c):t},c.id=function(t){return arguments.length?(a=t,c):a},c.iterations=function(t){return arguments.length?(l=+t,c):l},c.strength=function(t){return arguments.length?(h="function"==typeof t?t:C(+t),d(),c):h},c.distance=function(t){return arguments.length?(u="function"==typeof t?t:C(+t),g(),c):u},c}function yt(t){return t.x+t.vx}function mt(t){return t.y+t.vy}function wt(t){var e,r,n,o=1,i=1;function s(){for(var t,s,h,u,l,c,f,d=e.length,g=0;g<i;++g)for(s=_(e,yt,mt).visitAfter(a),t=0;t<d;++t)h=e[t],c=r[h.index],f=c*c,u=h.x+h.vx,l=h.y+h.vy,s.visit(p);function p(t,e,r,i,s){var a=t.data,d=t.r,g=c+d;if(!a)return e>u+g||i<u-g||r>l+g||s<l-g;if(a.index>h.index){var p=u-a.x-a.vx,y=l-a.y-a.vy,m=p*p+y*y;m<g*g&&(0===p&&(m+=(p=q(n))*p),0===y&&(m+=(y=q(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=C(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:C(+e),h(),s):t},s}function vt(t){var e,r,n,o=C(.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=C(null==t?0:+t)),i.initialize=function(t){e=t,s()},i.strength=function(t){return arguments.length?(o="function"==typeof t?t:C(+t),s(),i):o},i.x=function(e){return arguments.length?(t="function"==typeof e?e:C(+e),s(),i):t},i}function xt(t){var e,r,n,o=C(.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=C(null==t?0:+t)),i.initialize=function(t){e=t,s()},i.strength=function(t){return arguments.length?(o="function"==typeof t?t:C(+t),s(),i):o},i.y=function(e){return arguments.length?(t="function"==typeof e?e:C(+e),s(),i):t},i}function Mt(){function t(t){return function(){return t}}var e,r=function(t){return t.cluster},n=t(1),i=t(-1),s=t(100),a=t(.1),h=[0,0],u=[],l={},c=[],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(l[o]))<=(a=r(l[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=o(t,2),r=e[0],i=e[1],s=r.split("~")[0],a=r.split("~")[1];void 0!==s&&void 0!==a&&n.push({source:s,target:a,count:i})})),n}(c),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=ct(w.nodes).force("x",vt(f).strength(.1)).force("y",xt(d).strength(.1)).force("collide",wt((function(t){return t.r})).iterations(4)).force("charge",ft().strength(i)).force("links",pt(w.nodes.length?w.links:[]).distance(s).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}function b(t){l={},t.forEach((function(t){l[t.id]=t}))}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?(b(t||[]),u=t||[],v):u},v.links=function(t){return arguments.length?(c=t||[],x(),v):c},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?(i="function"==typeof e?e:t(+e),x(),v):i},v.forceLinkDistance=function(e){return arguments.length?(s="function"==typeof e?e:t(+e),x(),v):s},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 bt={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},Et=function(){function t(t){void 0===t&&(t={}),this.options=t,this.id="d3force",this.running=!1,this.options=r(r({},bt),t)}return t.prototype.execute=function(t,e){return this.genericForceLayout(!1,t,e)},t.prototype.assign=function(t,e){this.genericForceLayout(!0,t,e)},t.prototype.stop=function(){var t;null===(t=this.forceSimulation)||void 0===t||t.stop(),this.running=!1},t.prototype.restart=function(){var t;null===(t=this.forceSimulation)||void 0===t||t.restart(),this.running=!0},t.prototype.tick=function(t){var e=this;void 0===t&&(t=1),this.forceSimulation.tick(t);var r={nodes:Nt(this.lastLayoutNodes),edges:St(this.lastLayoutEdges)};return this.lastAssign&&r.nodes.forEach((function(t){return e.lastGraph.mergeNodeData(t.id,{x:t.data.x,y:t.data.y})})),this.lastOptions.onLayoutEnd&&this.lastOptions.onLayoutEnd(r),r},t.prototype.genericForceLayout=function(t,e,n){var o=this,i=r(r({},this.options),n),s=i.layoutInvisibles,a=e.getAllNodes(),h=e.getAllEdges();s||(a=a.filter((function(t){var e=(t.data||{}).visible;return e||void 0===e})),h=h.filter((function(t){var e=(t.data||{}).visible;return e||void 0===e})));var u=a.map((function(t){var e,n;return r(r({},y(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})})),l=h.map((function(t){return y(t)}));if(this.lastLayoutNodes=u,this.lastLayoutEdges=l,this.lastAssign=t,this.lastGraph=e,this.lastOptions=i,!this.running){var c=i.alphaMin,f=i.alphaDecay,d=i.alpha,g=i.nodeStrength,p=i.edgeStrength,m=i.linkDistance,w=i.clustering,v=i.clusterFociStrength,x=i.clusterEdgeDistance,M=i.clusterEdgeStrength,b=i.clusterNodeStrength,E=i.clusterNodeSize,N=i.collideStrength,S=void 0===N?1:N,A=i.center,k=void 0===A?[0,0]:A,I=i.preventOverlap,D=i.nodeSize,R=i.nodeSpacing,_=i.onTick,z=i.onLayoutEnd,O=i.forceSimulation;if(O)w&&((T=Mt()).nodes(u),T.links(l)),O.nodes(u),l&&(q=pt().id((function(t){return t.id})).links(l),p&&q.strength(p),m&&q.distance(m),O.force("link",q)),I&&this.overlapProcess(O,{nodeSize:D,nodeSpacing:R,collideStrength:S}),O.alpha(d).restart(),this.running=!0;else try{var T,C=ft();if(g&&C.strength(g),O=ct().nodes(u),w&&((T=Mt()).centerX(k[0]).centerY(k[1]).template("force").strength(v),l&&T.links(l),u&&T.nodes(u),T.forceLinkDistance(x).forceLinkStrength(M).forceCharge(b).forceNodeSize(E),O.force("group",T)),O.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}(k[0],k[1])).force("charge",C).alpha(d).alphaDecay(f).alphaMin(c),I&&this.overlapProcess(O,{nodeSize:D,nodeSpacing:R,collideStrength:S}),l){var q=pt().id((function(t){return t.id})).links(l);p&&q.strength(p),m&&q.distance(m),O.force("link",q)}O.on("tick",(function(){var r=Nt(u);null==_||_({nodes:r,edges:St(l)}),t&&r.forEach((function(t){return e.mergeNodeData(t.id,{x:t.data.x,y:t.data.y})}))})).on("end",(function(){o.running=!1;var r=Nt(u);null==z||z({nodes:r,edges:St(l)}),t&&r.forEach((function(t){return e.mergeNodeData(t.id,{x:t.data.x,y:t.data.y})}))})),this.running=!0}catch(t){this.running=!1,console.warn(t)}this.forceSimulation=O;var L=Nt(u),P=St(l);return t&&L.forEach((function(t){return e.mergeNodeData(t.id,{x:t.data.x,y:t.data.y})})),{nodes:L,edges:P}}},t.prototype.overlapProcess=function(t,e){var r,n,o=e.nodeSize,i=e.nodeSpacing,s=e.collideStrength;if(n=l(i)?function(){return i}:m(i)?i:function(){return 0},o)if(m(o))r=function(t){return o(t)+n(t)};else if(u(o)){var a=(o[0]>o[1]?o[0]:o[1])/2;r=function(t){return a+n(t)}}else if(l(o)){var h=o/2;r=function(t){return h+n(t)}}else r=function(){return 10};else r=function(t){return t.size?u(t.size)?(t.size[0]>t.size[1]?t.size[0]:t.size[1])/2+n(t):g(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}(),Nt=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})})}))},St=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 At(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 kt={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"},It=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({},kt),t)}return t.prototype.execute=function(t,e){return this.genericForceLayout(!1,t,e)},t.prototype.assign=function(t,e){this.genericForceLayout(!0,t,e)},t.prototype.stop=function(){this.timeInterval&&"undefined"!=typeof window&&window.clearInterval(this.timeInterval),this.running=!1},t.prototype.restart=function(){this.running=!0},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})})),this.lastOptions.onLayoutEnd&&this.lastOptions.onLayoutEnd(n),n},t.prototype.genericForceLayout=function(t,e,n){var o=this,i=r(r({},this.options),n),a=e.getAllNodes(),h=e.getAllEdges();i.layoutInvisibles||(a=a.filter((function(t){return t.data.visible||void 0===t.data.visible})),h=h.filter((function(t){return t.data.visible||void 0===t.data.visible})));var u=this.formatOptions(i,e),c=u.width,f=u.height,d=u.nodeSize,g=u.getMass,p=u.nodeStrength,y=u.edgeStrength,m=u.linkDistance,w=a.map((function(t){return r(r({},t),{data:r(r({},t.data),{x:l(t.data.x)?t.data.x:Math.random()*c,y:l(t.data.y)?t.data.y:Math.random()*f,size:d(t)||30,mass:g(t),nodeStrength:p(t)})})})),v=h.map((function(t){return r(r({},t),{data:r(r({},t.data),{edgeStrength:y(t),linkDistance:m(t,e.getNode(t.source),e.getNode(t.target))})})}));if(!(null==a?void 0:a.length))return this.lastResult={nodes:[],edges:h},{nodes:[],edges:h};var x={};a.forEach((function(t,e){x[t.id]={x:0,y:0}}));var M=new s({nodes:w,edges:v});this.formatCentripetal(u,M);var b=u.maxIteration,E=u.minMovement,N=u.onLayoutEnd,S=u.onTick;if(this.lastLayoutNodes=w,this.lastLayoutEdges=v,this.lastAssign=t,this.lastGraph=e,this.lastCalcGraph=M,this.lastOptions=u,this.lastVelMap=x,"undefined"!=typeof window){var A=0;return this.timeInterval=window.setInterval((function(){a&&o.running&&(o.runOneStep(M,e,A,x,u),o.updatePosition(e,M,x,u),t&&w.forEach((function(t){return e.mergeNodeData(t.id,{x:t.data.x,y:t.data.y})})),null==S||S({nodes:Ot(e,w),edges:h}),(++A>=b||o.judgingDistance<E)&&(null==N||N({nodes:Ot(e,w),edges:h}),window.clearInterval(o.timeInterval)))}),0),this.running=!0,{nodes:Ot(e,w),edges:h}}},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;l(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=w(0,t.nodeSpacing);t.nodeSize?u(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?u(e)?Math.max(e[0],e[1])+s(t):g(e)?Math.max(e.width,e.height)+s(t):e+s(t):10+s(t)}}return r.linkDistance=t.linkDistance?w(1,t.linkDistance):function(t){return 1+r.nodeSize(e.getNode(t.source))+r.nodeSize(e.getNode(t.target))},r.nodeStrength=w(1,t.nodeStrength),r.edgeStrength=w(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(),l=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(s&&h&&(r=Dt(e,h),c=Array.from(new Set(null==u?void 0:u.map((function(t){return t.data[h]}))))||[],t.centripetalOptions=Object.assign(l,{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,s=void 0===i?[]:i;1===s.length?n=void 0:s.length>1&&(n=zt(s))}else n=void 0;return{x:null==n?void 0:n.x,y:null==n?void 0:n.y}}})),a&&h){r||(r=Dt(e,h)),c||(c=Array.from(new Set(u.map((function(t){return t.data[h]}))))),c=c.filter((function(t){return void 0!==t}));var f={};c.forEach((function(t){var r=u.filter((function(e){return e.data[h]===t})).map((function(t){return e.getNode(t.id)}));f[t]=zt(r)})),t.centripetalOptions=Object.assign(l,{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=_(s,(function(t){return t.x}),(function(t){return t.y})).visitAfter(At);s.forEach((function(t){!function(t,e){e.visit((function(e,r,n,o,i){return 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,l=Math.sqrt(u)*u;if(h*h*.81<u){var c=t.weight/l;return i.vx+=s*c,i.vy+=a*c,!0}if(t.length)return!1;t.data!==i&&(c=t.data.weight/l,i.vx+=s*c,i.vy+=a*c)}(e,r,0,o,0,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 l=Math.sqrt(h*h+u*u),c=h/l,f=u/l,d=r.data||{},g=d.linkDistance,p=void 0===g?200:g,y=d.edgeStrength,m=(p-l)*(void 0===y?200:y),w=1/(s.data.mass||1),v=1/(a.data.mass||1),x=c*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 i=n.getCenter,s=t.getAllNodes(),a=e.getAllNodes(),h=e.getAllEdges(),u=n.width,c=n.height,f=n.center,d=n.gravity,g=n.centripetalOptions;s&&s.forEach((function(n){var s=n.id,p=n.data,y=p.mass,m=p.x,w=p.y,v=e.getNode(s),x=0,M=0,b=d,E=t.getDegree(s,"in"),N=t.getDegree(s,"out"),S=t.getDegree(s,"both"),A=null==i?void 0:i(v,S);if(A){var k=o(A,3);x=m-k[0],M=w-k[1],b=k[2]}else x=m-f[0],M=w-f[1];if(b&&(r[s].x-=b*x/y,r[s].y-=b*M/y),g){var I=g.leaf,D=g.single,R=g.others,_=g.center,z=(null==_?void 0:_(v,a,h,u,c))||{x:0,y:0,centerStrength:0},O=z.x,T=z.y,C=z.centerStrength;if(!l(O)||!l(T))return;var q=(m-O)/y,L=(w-T)/y;if(C&&(r[s].x-=C*q,r[s].y-=C*L),0===S){var P=D(v);if(!P)return;return r[s].x-=P*q,void(r[s].y-=P*L)}if(0===E||0===N){var F=I(v,a,h);if(!F)return;return r[s].x-=F*q,void(r[s].y-=F*L)}var j=R(v);if(!j)return;r[s].x-=j*q,r[s].y-=j*L}}))},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 l=i/u;a*=l,h*=l}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(l(u.data.fx)&&l(u.data.fy))e.mergeNodeData(a,{x:u.data.fx,y:u.data.fy});else{var c=r[a].x*s,f=r[a].y*s;e.mergeNodeData(a,{x:n.data.x+c,y:n.data.y+f});var d=Math.sqrt(c*c+f*f);switch(i){case"max":o.judgingDistance<d&&(o.judgingDistance=d);break;case"min":o.judgingDistance>d&&(o.judgingDistance=d);break;default:h+=d}}})),i&&"mean"!==i||(this.judgingDistance=h/a.length)}else this.judgingDistance=0},t}(),Dt=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]=Rt(t,"leaf",r,e))})),n},Rt=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},zt=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}},Ot=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})})}))},Tt=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 Ct=Tt;const qt=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}(),Lt=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 Pt={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},Ft=function(){function t(t){void 0===t&&(t={}),this.options=t,this.id="forceAtlas2",this.options=r(r({},Pt),t)}return t.prototype.execute=function(t,e){return this.genericForceAtlas2Layout(!1,t,e)},t.prototype.assign=function(t,e){this.genericForceAtlas2Layout(!0,t,e)},t.prototype.genericForceAtlas2Layout=function(t,e,n){var o=e.getAllEdges(),i=e.getAllNodes(),a=this.formatOptions(n,i.length),h=a.width,u=a.height,l=a.prune,c=a.maxIteration,f=a.nodeSize,d=a.center,g=a.onLayoutEnd;if(!(null==i?void 0:i.length)||1===i.length)return x(e,t,d,g);var p=i.map((function(t){return y(t,[h,u])})),m=o.filter((function(t){return t.source!==t.target})),w=new s({nodes:p,edges:m}),v=this.getSizes(w,e,f);if(this.run(w,e,c,v,t,a),l){for(var M=0;M<m.length;M+=1){var b=m[M],E=b.source,N=b.target,S=w.getDegree(E),A=w.getDegree(E);if(S<=1){var k=w.getNode(N);w.mergeNodeData(E,{x:k.data.x,y:k.data.y})}else if(A<=1){var I=w.getNode(E);w.mergeNodeData(N,{x:I.data.x,y:I.data.y})}}var D=r(r({},a),{prune:!1,barnesHut:!1});this.run(w,e,100,v,t,D)}var R={nodes:p,edges:o};return null==g||g(R),R},t.prototype.getSizes=function(t,e,r){for(var n=t.getAllNodes(),s={},a=0;a<n.length;a+=1){var h=n[a],c=h.id,f=h.data;if(s[c]=10,l(f.size))s[c]=f.size;else if(u(f.size))isNaN(f.size[0])||(s[c]=Math.max(f.size[0])),isNaN(f.size[1])||(s[c]=Math.max(f.size[1]));else if(g(f.size))s[c]=Math.max(f.size.width,f.size.height);else if(m(r)){var d=r(e.getNode(c));u(d)?s[c]=Math.max.apply(Math,i([],o(d),!1)):s[c]=d}else u(r)?s[c]=Math.max.apply(Math,i([],o(r),!1)):l(r)&&(s[c]=r)}return s},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,l=n.kr,c=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)),l||(n.kr=50,e>100&&e<=500?n.kr=20:e>500&&(n.kr=1)),c||(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(),l=0,c=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 Ct(v)}}for(;c>0;)l=this.oneStep(t,{iter:c,preventOverlapIters:50,krPrime:100,sg:l,forces:f,preForces:d,bodies:g,sizes:n},i),c--,null==h||h({nodes:u,edges:e.getAllEdges()});return t},t.prototype.oneStep=function(t,e,r){for(var n=e.iter,s=e.preventOverlapIters,a=e.krPrime,h=e.sg,u=e.preForces,l=e.bodies,c=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]=i([],o(f[m]),!1),f[m]=[0,0]}return f=this.getAttrForces(t,n,s,c,f,r),f=g&&(d&&n>s||!d)?this.getOptRepGraForces(t,f,l,r):this.getRepGraForces(t,n,s,f,a,c,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,l=t.getAllEdges(),c=0;c<l.length;c+=1){var f=l[c],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,l=-9e10,c=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>=l&&(l=y.x),y.x<=u&&(u=y.x),y.y>=f&&(f=y.y),y.y<=c&&(c=y.y))}var m=Math.max(l-u,f-c),w=new qt({xmid:(l+u)/2,ymid:(f+c)/2,length:m,massCenter:i,mass:h}),v=new Lt(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,l=s.center,c=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(!c||!(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-l[0],p.data.y-l[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,f=[],d=[],g=0,p=0,y=n,m=0;m<c;m+=1){var w=u[m].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]);f[m]=M,d[m]=E/2,g+=(v+1)*f[m],p+=(v+1)*d[m]}}var N=y;for(y=s*p/g,0!==N&&(y=y>1.5*N?1.5*N:y),m=0;m<c;m+=1){var S=u[m],A=(w=S.id,S.data);if(v=t.getDegree(w),!(a&&v<=1||l(A.fx)&&l(A.fy))){var k=i*y/(1+y*Math.sqrt(f[m])),I=Math.hypot(e[w][0],e[w][1]),D=h/(I=I<1e-4?1e-4:I),R=(k=k>D?D:k)*e[w][0],_=k*e[w][1];t.mergeNodeData(w,{x:A.x+R,y:A.y+_})}}return y},t}(),jt={maxIteration:1e3,gravity:10,speed:5,clustering:!1,clusterGravity:10,width:300,height:300,nodeClusterBy:"cluster"},Vt=function(){function t(t){void 0===t&&(t={}),this.options=t,this.id="fruchterman",this.timeInterval=0,this.running=!1,this.options=r(r({},jt),t)}return t.prototype.execute=function(t,e){return this.genericFruchtermanLayout(!1,t,e)},t.prototype.assign=function(t,e){this.genericFruchtermanLayout(!0,t,e)},t.prototype.stop=function(){this.timeInterval&&"undefined"!=typeof window&&window.clearInterval(this.timeInterval),this.running=!1},t.prototype.restart=function(){this.running=!0},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})})),this.lastOptions.onLayoutEnd&&this.lastOptions.onLayoutEnd(n),n},t.prototype.genericFruchtermanLayout=function(t,e,n){var o=this;if(!this.running){var i=this.formatOptions(n),a=i.layoutInvisibles,h=i.width,u=i.height,l=i.center,c=i.clustering,f=i.nodeClusterBy,d=i.maxIteration,g=i.onTick,p=i.onLayoutEnd,m=e.getAllNodes(),w=e.getAllEdges();if(a||(m=m.filter((function(t){var e=(t.data||{}).visible;return e||void 0===e})),w=w.filter((function(t){var e=(t.data||{}).visible;return e||void 0===e}))),!(null==m?void 0:m.length)){var v={nodes:[],edges:w};return this.lastResult=v,null==p||p(v),v}if(1===m.length)return t&&e.mergeNodeData(m[0].id,{x:l[0],y:l[1]}),v={nodes:[r(r({},m[0]),{data:r(r({},m[0].data),{x:l[0],y:l[1]})})],edges:w},this.lastResult=v,null==p||p(v),v;var x=m.map((function(t){return y(t,[h,u])})),M=new s({nodes:x,edges:w}),b={};if(c&&x.forEach((function(t){var e=t.data[f];b[e]||(b[e]={name:e,cx:0,cy:0,count:0})})),this.lastLayoutNodes=x,this.lastLayoutEdges=w,this.lastAssign=t,this.lastGraph=M,this.lastOptions=i,this.lastClusterMap=b,"undefined"!=typeof window){var E=0;return this.timeInterval=window.setInterval((function(){if(o.running&&(o.runOneStep(M,b,i),t&&x.forEach((function(t){var r=t.id,n=t.data;return e.mergeNodeData(r,{x:n.x,y:n.y})})),null==g||g({nodes:x,edges:w}),++E>=d)){try{null==p||p({nodes:x,edges:w})}catch(t){console.warn("onLayoutEnd failed",t)}window.clearInterval(o.timeInterval)}}),0),this.running=!0,{nodes:x,edges:w}}}},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,f=n*o,d=Math.sqrt(f)/10,g=t.getAllNodes(),p=f/(g.length+1),y=Math.sqrt(p),m={};if(this.applyCalculate(t,m,y,p),h){for(var w in e)e[w].cx=0,e[w].cy=0,e[w].count=0;for(var w in g.forEach((function(t){var r=t.data,n=e[r[u]];l(r.x)&&(n.cx+=r.x),l(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;g.forEach((function(t,r){var n=t.id,o=t.data;if(l(o.x)&&l(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=y*v;m[n].x-=a*(o.x-i.cx)/s,m[n].y-=a*(o.y-i.cy)/s}}))}g.forEach((function(t,e){var r=t.id,n=t.data;if(l(n.x)&&l(n.y)){var o=.01*y*i;m[r].x-=o*(n.x-s[0]),m[r].y-=o*(n.y-s[1])}})),g.forEach((function(e,r){var n=e.id,o=e.data;if(l(o.fx)&&l(o.fy))return o.x=o.fx,void(o.y=o.fy);if(l(o.x)&&l(o.y)){var i=Math.sqrt(m[n].x*m[n].x+m[n].y*m[n].y);if(i>0){var s=Math.min(d*(a/800),i);t.mergeNodeData(n,{x:o.x+m[n].x/i*s,y:o.y+m[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)&&l(i.x)&&l(a.x)&&l(i.y)&&l(a.y)){var u=i.x-a.x,c=i.y-a.y,f=u*u+c*c;0===f&&(f=1,u=.01,c=.01);var d=r/f,g=u*d,p=c*d;e[s].x+=g,e[s].y+=p,e[h].x-=g,e[h].y-=p}}))}))},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(l(a.x)&&l(s.x)&&l(a.y)&&l(s.y)){var h=a.x-s.x,u=a.y-s.y,c=Math.sqrt(h*h+u*u)/r,f=h*c,d=u*c;e[o].x+=f,e[o].y+=d,e[i].x-=f,e[i].y-=d}}}))},t}(),Wt={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},$t=function(){function t(t){void 0===t&&(t={}),this.options=t,this.id="grid",this.options=r(r({},Wt),t)}return t.prototype.execute=function(t,e){return this.genericGridLayout(!1,t,e)},t.prototype.assign=function(t,e){this.genericGridLayout(!0,t,e)},t.prototype.genericGridLayout=function(t,e,n){var o=r(r({},this.options),n),i=o.begin,s=void 0===i?[0,0]:i,h=o.condense,c=o.preventOverlapPadding,f=o.preventOverlap,d=o.rows,g=o.cols,p=o.nodeSpacing,m=o.nodeSize,M=o.width,b=o.height,E=o.layoutInvisibles,N=o.onLayoutEnd,S=o.position,A=o.sortBy,k=e.getAllNodes(),I=e.getAllEdges();E||(k=k.filter((function(t){var e=(t.data||{}).visible;return e||void 0===e})),I=I.filter((function(t){var e=(t.data||{}).visible;return e||void 0===e})));var D=null==k?void 0:k.length;if(!D||1===D)return x(e,t,s,N);var R=k.map((function(t){return y(t)}));"id"===A||a(A)&&void 0!==R[0].data[A]||(A="degree"),"degree"===A?R.sort((function(t,r){return e.getDegree(r.id,"both")-e.getDegree(t.id,"both")})):"id"===A?R.sort((function(t,e){return l(e.id)&&l(t.id)?e.id-t.id:"".concat(t.id).localeCompare("".concat(e.id))})):R.sort((function(t,e){return e.data[A]-t.data[A]}));var _=M||"undefined"==typeof window?M:window.innerWidth,z=b||"undefined"==typeof window?b:window.innerHeight,O=D,T={rows:d,cols:g};if(null!=d&&null!=g)T.rows=d,T.cols=g;else if(null!=d&&null==g)T.rows=d,T.cols=Math.ceil(O/T.rows);else if(null==d&&null!=g)T.cols=g,T.rows=Math.ceil(O/T.cols);else{var C=Math.sqrt(O*z/_);T.rows=Math.round(C),T.cols=Math.round(_/z*C)}if(T.rows=Math.max(T.rows,1),T.cols=Math.max(T.cols,1),T.cols*T.rows>O)((L=Gt(T))-1)*(q=Bt(T))>=O?Gt(T,L-1):(q-1)*L>=O&&Bt(T,q-1);else for(;T.cols*T.rows<O;){var q,L=Gt(T);((q=Bt(T))+1)*L>=O?Bt(T,q+1):Gt(T,L+1)}var P=h?0:_/T.cols,F=h?0:z/T.rows;if(f||p){var j=w(10,p),V=v(30,m,!1);R.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=V(o)||30;u(i)?(r=i[0],n=i[1]):(r=i,n=i);var s=void 0!==j?j(t):c,a=r+s,h=n+s;P=Math.max(P,a),F=Math.max(F,h)}))}for(var W={},$={row:0,col:0},G={},B=0;B<R.length;B++){var U=R[B],H=void 0;if(S&&(H=S(e.getNode(U.id))),H&&(void 0!==H.row||void 0!==H.col)){var K={row:H.row,col:H.col};if(void 0===K.col)for(K.col=0;Ut(W,K);)K.col++;else if(void 0===K.row)for(K.row=0;Ut(W,K);)K.row++;G[U.id]=K,Ht(W,K)}Jt(U,s,P,F,G,T,$,W)}var J={nodes:R,edges:I};return null==N||N(J),t&&R.forEach((function(t){e.mergeNodeData(t.id,{x:t.data.x,y:t.data.y})})),J},t}(),Gt=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},Bt=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},Ut=function(t,e){return t["c-".concat(e.row,"-").concat(e.col)]||!1},Ht=function(t,e){return t["c-".concat(e.row,"-").concat(e.col)]=!0},Kt=function(t,e){var r=t.cols||5;e.col++,e.col>=r&&(e.col=0,e.row++)},Jt=function(t,e,r,n,o,i,s,a){var h,u,l=o[t.id];if(l)h=l.col*r+r/2+e[0],u=l.row*n+n/2+e[1];else{for(;Ut(a,s);)Kt(i,s);h=s.col*r+r/2+e[0],u=s.row*n+n/2+e[1],Ht(a,s),Kt(i,s)}t.data.x=h,t.data.y=u};const Yt=Object.prototype.toString;function Xt(t){return Yt.call(t).endsWith("Array]")}function Qt(t){var e=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};if(!Xt(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}function Zt(t){var e=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};if(!Xt(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}function te(t){var e,r=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};if(!Xt(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(!Xt(r.output))throw new TypeError("output option must be an array if specified");e=r.output}else e=new Array(t.length);var n=Zt(t),o=Qt(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),l=0;l<t.length;l++)e[l]=(t[l]-n)*u+s;return e}const ee=" ".repeat(2),re=" ".repeat(4);function ne(t,e={}){const{maxRows:r=15,maxColumns:n=10,maxNumSize:o=8,padMinus:i="auto"}=e;return`${t.constructor.name} {\\n${ee}[\\n${re}${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(oe(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${re}`)}(t,r,n,o,i)}\\n${ee}]\\n${ee}rows: ${t.rows}\\n${ee}columns: ${t.columns}\\n}`}function oe(t,e,r){return(t>=0&&r?` ${ie(t,e-1)}`:ie(t,e)).padEnd(e)}function ie(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 se(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 ae(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 he(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 ue(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(fe("startRow",e),fe("endRow",r),fe("startColumn",n),fe("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 ce(t,e=0){let r=[];for(let n=0;n<t;n++)r.push(e);return r}function fe(t,e){if("number"!=typeof e)throw new TypeError(`${t} must be a number`)}function de(t){if(t.isEmpty())throw new Error("Empty matrix has no elements to index")}class ge{static from1DArray(t,e,r){if(t*e!==r.length)throw new RangeError("data length does not match given dimensions");let n=new ye(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 ye(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 ye(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 ye(t,e)}static ones(t,e){return new ye(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 ye(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 ye(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 ye(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 ge.isMatrix(t)?t:new ye(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 ye(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){se(this,t);let e=[];for(let r=0;r<this.columns;r++)e.push(this.get(t,r));return e}getRowVector(t){return ye.rowVector(this.getRow(t))}setRow(t,e){se(this,t),e=he(this,e);for(let r=0;r<this.columns;r++)this.set(t,r,e[r]);return this}swapRows(t,e){se(this,t),se(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){ae(this,t);let e=[];for(let r=0;r<this.rows;r++)e.push(this.get(r,t));return e}getColumnVector(t){return ye.columnVector(this.getColumn(t))}setColumn(t,e){ae(this,t),e=ue(this,e);for(let r=0;r<this.rows;r++)this.set(r,t,e[r]);return this}swapColumns(t,e){ae(this,t),ae(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=he(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=he(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=he(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=he(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=ue(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=ue(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=ue(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=ue(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){se(this,t);for(let r=0;r<this.columns;r++)this.set(t,r,this.get(t,r)*e);return this}mulColumn(t,e){ae(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(){de(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(){de(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(se(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){se(this,t),de(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(se(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){se(this,t),de(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(ae(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){ae(this,t),de(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(ae(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){ae(this,t),de(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){ge.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=ye.checkMatrix(t);let e=this.rows,r=this.columns,n=t.columns,o=new ye(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=ye.checkMatrix(t);let e=new ye(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),l=(r+h)*(n+u),c=(s+h)*n,f=r*(i-u),d=h*(a-n),g=(r+o)*u,p=l+d-g+(o-h)*(a+u),y=f+g,m=c+d,w=l-c+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=ye.checkMatrix(t);let e=new ye(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),l=this.get(2,2),c=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)*(c-f+p),b=(i+s)*(-c+f),E=r*c,N=(-r+h+u)*(c-d+y),S=(-r+h)*(d-y),A=(h+u)*(-c+d),k=(-o+u+l)*(p+m-w),I=(o-l)*(p-w),D=o*m,R=(u+l)*(-m+w),_=(-o+s+a)*(y+m-v),z=(o-a)*(y-v),O=(s+a)*(-m+v),T=E+D+n*g,C=(r+n+o-i-s-u-l)*p+M+b+E+k+D+R,q=E+N+A+(r+n+o-s-a-h-u)*y+D+_+O,L=x+s*(-c+f+g-p-y-m+v)+M+E+D+_+z,P=x+M+b+E+a*w,F=D+_+z+O+i*d,j=E+N+S+u*(-c+d+g-p-y-m+w)+k+I+D,V=k+I+D+R+h*f,W=E+N+S+A+l*v;return e.set(0,0,T),e.set(0,1,C),e.set(0,2,q),e.set(1,0,L),e.set(1,1,P),e.set(1,2,F),e.set(2,0,j),e.set(2,1,V),e.set(2,2,W),e}mmulStrassen(t){t=ye.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=ge.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),l=e.subMatrix(0,i-1,a,e.columns-1),c=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(ge.add(h,g),ge.add(u,p),i,a),m=t(ge.add(f,g),u,i,a),w=t(h,ge.sub(c,p),i,a),v=t(g,ge.sub(d,u),i,a),x=t(ge.add(h,l),p,i,a),M=t(ge.sub(f,h),ge.add(u,c),i,a),b=t(ge.sub(l,g),ge.add(d,p),i,a),E=ge.add(y,v);E.sub(x),E.add(b);let N=ge.add(w,x),S=ge.add(m,v),A=ge.sub(y,m);A.add(w),A.add(M);let k=ge.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 ye(this.rows,this.columns);for(let t=0;t<this.rows;t++){const o=this.getRow(t);o.length>0&&te(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 ye(this.rows,this.columns);for(let t=0;t<this.columns;t++){const o=this.getColumn(t);o.length&&te(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=ye.checkMatrix(t);let e=this.rows,r=this.columns,n=t.rows,o=t.columns,i=new ye(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=ye.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(ye.eye(r,r)),o=ye.eye(e,e).kroneckerProduct(t);return n.add(o)}transpose(){let t=new ye(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=pe){for(let e=0;e<this.rows;e++)this.setRow(e,this.getRow(e).sort(t));return this}sortColumns(t=pe){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 ye(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 ye(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 ye(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=ye.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(!Xt(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(!Xt(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 ye(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 ye(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=ce(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=ce(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=ce(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=ce(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(!Xt(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(!Xt(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(!Xt(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(!Xt(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(!Xt(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(!Xt(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 ne(this,t)}}function pe(t,e){return t-e}ge.prototype.klass="Matrix","undefined"!=typeof Symbol&&(ge.prototype[Symbol.for("nodejs.util.inspect.custom")]=function(){return ne(this)}),ge.random=ge.rand,ge.randomInt=ge.randInt,ge.diagonal=ge.diag,ge.prototype.diagonal=ge.prototype.diag,ge.identity=ge.eye,ge.prototype.negate=ge.prototype.neg,ge.prototype.tensorProduct=ge.prototype.kroneckerProduct;class ye extends ge{constructor(t,e){if(super(),ye.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(!Xt(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 se(this,t),this.data.splice(t,1),this.rows-=1,this}addRow(t,e){return void 0===e&&(e=t,t=this.rows),se(this,t,!0),e=Float64Array.from(he(this,e)),this.data.splice(t,0,e),this.rows+=1,this}removeColumn(t){ae(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),ae(this,t,!0),e=ue(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}}(ge,ye);class me extends ge{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 we(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 ve{constructor(t,e={}){if((t=me.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),l=!1;if(r<n)if(s){a=t.transpose(),r=a.rows,n=a.columns,l=!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 c=Math.min(r,n),f=Math.min(r+1,n),d=new Float64Array(f),g=new ye(r,c),p=new ye(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]=we(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]=we(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<c;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<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(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=we(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=we(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,l=y[t]/e,c=((i+o)*(i-o)+s*s)/2,f=o*s*(o*s);let m=0;0===c&&0===f||(m=c<0?0-Math.sqrt(c*c+f):Math.sqrt(c*c+f),m=f/(c+m));let w=(a+o)*(a-o)+m,v=a*l;for(let e=t;e<b-1;e++){let o=we(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=we(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(l){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=ye.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,l=ye.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);l.set(t,e,r)}return l.mmul(e)}solveForDiagonal(t){return this.solve(ye.diag(t))}inverse(){let t=this.V,e=this.threshold,r=t.rows,n=t.columns,o=new ye(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 ye(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 ye.diag(this.s)}}var xe,Me={center:[0,0],linkDistance:50},be=function(){function t(t){void 0===t&&(t={}),this.options=t,this.id="mds",this.options=r(r({},Me),t)}return t.prototype.execute=function(t,e){return this.genericMDSLayout(!1,t,e)},t.prototype.assign=function(t,e){this.genericMDSLayout(!0,t,e)},t.prototype.genericMDSLayout=function(t,e,n){var o=r(r({},this.options),n),i=o.center,s=void 0===i?[0,0]:i,a=o.linkDistance,h=void 0===a?50:a,u=o.layoutInvisibles,l=o.onLayoutEnd,d=e.getAllNodes(),g=e.getAllEdges();if(u||(d=d.filter((function(t){var e=(t.data||{}).visible;return e||void 0===e})),g=g.filter((function(t){var e=(t.data||{}).visible;return e||void 0===e}))),!(null==d?void 0:d.length)||1===d.length)return x(e,t,s,l);var p=f({nodes:d,edges:g},!1),m=c(p);Ee(m);var w=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,h),v=Ne(w),M=[];v.forEach((function(t,e){var r=y(d[e]);r.data.x=t[0]+s[0],r.data.y=t[1]+s[1],M.push(r)})),t&&M.forEach((function(t){return e.mergeNodeData(t.id,{x:t.data.x,y:t.data.y})}));var b={nodes:M,edges:g};return null==l||l(b),b},t}(),Ee=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)}))}))},Ne=function(t){var e=ye.mul(ye.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 ve(e),s=ye.sqrt(i.diagonalMatrix).diagonal();return i.leftSingularVectors.toJSON().map((function(t){return ye.mul([t],[s]).toJSON()[0].splice(0,2)}))},Se={iterations:10,height:10,width:10,speed:100,gravity:10,k:5},Ae=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,l=s.y-e.y,c=Math.sqrt(u*u+l*l);if(0===c){c=1;var f=a>h?1:-1;u=.01*f,l=.01*f}if(c<i(t[a])/2+i(t[h])/2){var d=n*n/c;r[a].x+=u/c*d,r[a].y+=l/c*d}}}))}))},ke=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),l=Math.acos((a*e.x+h*e.y)/u);l>Math.PI/2&&(l-=Math.PI/2,a*=-1,h*=-1);var c=Math.cos(l)*u;e.x=a*c,e.y=h*c})),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 l=Math.min(h*(r/800),u);if(i.x+=e[s].x/u*l,i.y+=e[s].y/u*l,n){var c=i.x-t[o].x,f=i.y-t[o].y,d=Math.sqrt(c*c+f*f);c=c/d*a[s],f=f/d*a[s],i.x=t[o].x+c,i.y=t[o].y+f}}}})),t},Ie={maxIteration:1e3,focusNode:null,unitRadius:null,linkDistance:50,preventOverlap:!1,strictRadial:!0,maxPreventOverlapIteration:200,sortStrength:10},De=function(){function t(t){void 0===t&&(t={}),this.options=t,this.id="radial",this.options=r(r({},Ie),t)}return t.prototype.execute=function(t,e){return this.genericRadialLayout(!1,t,e)},t.prototype.assign=function(t,e){this.genericRadialLayout(!0,t,e)},t.prototype.genericRadialLayout=function(t,e,n){var s=r(r({},this.options),n),h=s.width,u=s.height,l=s.center,d=s.focusNode,g=s.unitRadius,p=s.nodeSize,m=s.nodeSpacing,w=s.strictRadial,v=s.preventOverlap,M=s.maxPreventOverlapIteration,b=s.sortBy,E=s.linkDistance,N=void 0===E?50:E,S=s.sortStrength,A=void 0===S?10:S,k=s.maxIteration,I=void 0===k?1e3:k,D=s.layoutInvisibles,R=s.onLayoutEnd,_=e.getAllNodes(),z=e.getAllEdges();D||(_=_.filter((function(t){var e=(t.data||{}).visible;return e||void 0===e})),z=z.filter((function(t){var e=(t.data||{}).visible;return e||void 0===e})));var O=h||"undefined"==typeof window?h:window.innerWidth,T=u||"undefined"==typeof window?u:window.innerHeight,C=l||[O/2,T/2];if(!(null==_?void 0:_.length)||1===_.length)return x(e,t,C,R);var q=_[0];if(a(d)){for(var L=0;L<_.length;L++)if(_[L].id===d){q=_[L];break}}else q=d||_[0];var P=ze(_,q.id),F=f({nodes:_,edges:z},!1),j=c(F),V=Te(j,P);Oe(j,P,V+1);var W=j[P],$=O-C[0]>C[0]?C[0]:O-C[0],G=T-C[1]>C[1]?C[1]:T-C[1];0===$&&($=O/2),0===G&&(G=T/2);var B=Math.min($,G),U=Math.max.apply(Math,i([],o(W),!1)),H=[],K=g||B/U;W.forEach((function(t,e){H[e]=t*K}));var J,Y=Re(_,j,N,H,K,b,A),X=_e(Y),Q=function(t,e,r){try{var n=ye.mul(ye.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 ve(n),h=ye.sqrt(a.diagonalMatrix).diagonal();return a.leftSingularVectors.toJSON().map((function(e){return ye.mul([e],[h]).toJSON()[0].splice(0,t)}))}catch(t){for(var u=[],l=0;l<e.length;l++){var c=Math.random()*r,f=Math.random()*r;u.push([c,f])}return u}}(N,Y,N),Z=Q.map((function(t){var e=o(t,2),r=e[0],n=e[1];return{x:(isNaN(r)?Math.random()*N:r)-Q[P][0],y:(isNaN(n)?Math.random()*N:n)-Q[P][1]}}));if(this.run(I,Z,X,Y,H,P),v){J=Ce(p,m);var tt={nodes:_,nodeSizeFunc:J,positions:Z,radii:H,height:T,width:O,strictRadial:Boolean(w),focusIdx:P,iterations:M||200,k:Z.length/4.5};Z=function(t,e){for(var n=r(r({},Se),e),o=n.positions,i=n.iterations,s=n.width,a=n.k,h=n.speed,u=void 0===h?100:h,l=n.strictRadial,c=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}})),Ae(p,o,y,a,d,g),ke(o,y,u,l,c,m,s,d);return o}(e,tt)}var et=[];Z.forEach((function(t,e){var r=y(_[e]);r.data.x=t.x+C[0],r.data.y=t.y+C[1],et.push(r)})),t&&et.forEach((function(t){return e.mergeNodeData(t.id,{x:t.data.x,y:t.data.y})}));var rt={nodes:et,edges:z};return null==R||R(rt),rt},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=d(a,{x:0,y:0}),l=0===u?0:1/u;if(h!==i){var c=0,f=0,g=0;e.forEach((function(t,e){if(h!==e){var r=d(a,t),i=0===r?0:1/r,s=n[e][h];g+=o[h][e],c+=o[h][e]*(t.x+s*(a.x-t.x)*i),f+=o[h][e]*(t.y+s*(a.y-t.y)*i)}}));var p=0===r[h]?0:1/r[h];g*=s,g+=t*p*p,c*=s,c+=t*p*a.x*l,a.x=c/g,f*=s,f+=t*p*a.y*l,a.y=f/g}}))},t}(),Re=function(t,e,r,n,o,i,s){if(!t)return[];var h=[];if(e){var u={};e.forEach((function(e,l){var c=[];e.forEach((function(e,h){var f,d;if(l===h)c.push(0);else if(n[l]===n[h])if("data"===i)c.push(e*(Math.abs(l-h)*s)/(n[l]/o));else if(i){var g=void 0,p=void 0;if(u[t[l].id])g=u[t[l].id];else{var y=("id"===i?t[l].id:null===(f=t[l].data)||void 0===f?void 0:f[i])||0;g=a(y)?y.charCodeAt(0):y,u[t[l].id]=g}u[t[h].id]?p=u[t[h].id]:(y=("id"===i?t[h].id:null===(d=t[h].data)||void 0===d?void 0:d[i])||0,p=a(y)?y.charCodeAt(0):y,u[t[h].id]=p),c.push(e*(Math.abs(g-p)*s)/(n[l]/o))}else c.push(e*r/(n[l]/o));else{var m=(r+o)/2;c.push(e*m)}})),h.push(c)}))}return h},_e=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},ze=function(t,e){var r=-1;return t.forEach((function(t,n){t.id===e&&(r=n)})),Math.max(r,0)},Oe=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}},Te=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},Ce=function(t,e){var r;return r=l(e)?function(){return e}:m(e)?e:function(){return 0},t?u(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;return(null===(e=t.data)||void 0===e?void 0:e.bboxSize)?Math.max(t.data.bboxSize[0],t.data.bboxSize[1])+r(t):(null===(n=t.data)||void 0===n?void 0:n.size)?u(t.data.size)?Math.max(t.data.size[0],t.data.size[1])+r(t):g(t.data.size)?(t.data.size.width>t.data.size.height?t.data.size.width:t.data.size.height)+r(t):t.data.size+r(t):10+r(t)}},qe={center:[0,0],width:300,height:300},Le={circular:b,concentric:A,mds:be,random:function(){function t(t){void 0===t&&(t={}),this.options=t,this.id="random",this.options=r(r({},qe),t)}return t.prototype.execute=function(t,e){return this.genericRandomLayout(!1,t,e)},t.prototype.assign=function(t,e){this.genericRandomLayout(!0,t,e)},t.prototype.genericRandomLayout=function(t,e,n){var o=r(r({},this.options),n),i=o.center,s=o.width,a=o.height,h=o.layoutInvisibles,u=o.onLayoutEnd,l=e.getAllNodes();h||(l=l.filter((function(t){var e=(t.data||{}).visible;return e||void 0===e})));var c=s||"undefined"==typeof window?s:window.innerWidth,f=a||"undefined"==typeof window?a:window.innerHeight,d=i||[c/2,f/2],g=[];l&&l.forEach((function(t){g.push({id:t.id,data:{x:.9*(Math.random()-.5)*c+d[0],y:.9*(Math.random()-.5)*f+d[1]}})})),t&&g.forEach((function(t){return e.mergeNodeData(t.id,{x:t.data.x,y:t.data.y})}));var p={nodes:g,edges:e.getAllEdges()};return null==u||u(p),p},t}(),grid:$t,radial:De,force:It,d3force:Et,fruchterman:Vt,forceAtlas2:Ft};function Pe(){(null==xe?void 0:xe.stop)&&xe.stop()}function Fe(t,e){return r=this,n=void 0,i=function(){var r,n,o,i,a,h,u,l;return function(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])}}}(this,(function(c){if(r=t.layout,n=r.id,o=r.options,i=r.iterations,a=t.nodes,h=t.edges,u=new s({nodes:a,edges:h}),!(l=Le[n]))throw new Error("Unknown layout id: ".concat(n));return xe=new l(o),[2,new Promise((function(t){var r;xe.assign(u,{onLayoutEnd:function(r){t([r,e])}}),(r=xe).tick&&r.stop&&r.restart&&(xe.stop(),xe.tick(i))}))]}))},new((o=void 0)||(o=Promise))((function(t,e){function s(t){try{h(i.next(t))}catch(t){e(t)}}function a(t){try{h(i.throw(t))}catch(t){e(t)}}function h(e){var r;e.done?t(e.value):(r=e.value,r instanceof o?r:new o((function(t){t(r)}))).then(s,a)}h((i=i.apply(r,n||[])).next())}));var r,n,o,i}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=d869b88cfe3353e7436d.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:()=>Fe,stopLayout:()=>Pe});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){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 i(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;class s{nodeMap=new Map;edgeMap=new Map;inEdgesMap=new Map;outEdgesMap=new Map;treeIndices=new Map;changes=[];batchCount=0;onChanged=()=>{};constructor(t){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=[],this.onChanged({graph:this,changes:t})}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){if(!this.hasNode(t))throw new Error("Node not found for id: "+t)}hasNode(t){return this.nodeMap.has(t)}areNeighbors(t,e){return this.checkNodeExistence(t),this.getNeighbors(e).some((e=>e.id===t))}getNode(t){return this.checkNodeExistence(t),this.nodeMap.get(t)}getRelatedEdges(t,e){this.checkNodeExistence(t);const r=this.inEdgesMap.get(t),n=this.outEdgesMap.get(t);if("in"===e)return Array.from(r);if("out"===e)return Array.from(n);const o=new Set([...r,...n]);return Array.from(o)}getDegree(t,e){return this.getRelatedEdges(t,e).length}getSuccessors(t){const e=this.getRelatedEdges(t,"out").map((t=>t.target));return Array.from(new Set(e)).map((t=>this.getNode(t)))}getPredecessors(t){const e=this.getRelatedEdges(t,"in").map((t=>t.source));return Array.from(new Set(e)).map((t=>this.getNode(t)))}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.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),r=this.inEdgesMap.get(t),n=this.outEdgesMap.get(t);r?.forEach((t=>this.doRemoveEdge(t.id))),n?.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);e.add(t),r.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);r.delete(e),n.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.outEdgesMap.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.inEdgesMap.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.treeIndices.has(t))throw new Error("Tree structure not found for treeKey: "+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}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})}))}getAllNodes(){return Array.from(this.nodeMap.values())}getAllEdges(){return Array.from(this.edgeMap.values())}doBFS(t,e,r){for(;t.length;){const n=t.shift();r(n),e.add(n.id),this.getSuccessors(n.id).forEach((r=>{e.has(r.id)||(e.add(r.id),t.push(r))}))}}bfs(t,e){this.doBFS([this.getNode(t)],new Set,e)}doDFS(t,e,r){r(t),e.add(t.id),this.getSuccessors(t.id).forEach((t=>{e.has(t.id)||this.doDFS(t,e,r)}))}dfs(t,e){this.doDFS(this.getNode(t),new Set,e)}clone(){const t=this.getAllNodes().map((t=>({...t,data:{...t.data}}))),e=this.getAllEdges().map((t=>({...t,data:{...t.data}}))),r=new s({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 a=function(t){return"string"==typeof t},h=/-(\\w)/g,u=(function(t){return t.replace(h,(function(t,e){return e?e.toUpperCase():""}))},Object.create(null),Array.isArray),l=function(t){return"number"==typeof t},c=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},f=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},d=function(t,e){return Math.sqrt((t.x-e.x)*(t.x-e.x)+(t.y-e.y)*(t.y-e.y))},g=function(t){return null!==t&&"object"==typeof t},p=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 p(t)}))}if("object"==typeof t){var r={};return Object.keys(t).forEach((function(e){r[e]=p(t[e])})),r}return t},y=function(t,e){var r=p(t);return r.data=r.data||{},e&&(l(r.data.x)||(r.data.x=Math.random()*e[0]),l(r.data.y)||(r.data.y=Math.random()*e[1])),r},m=function(t){return"function"==typeof t};function w(t,e){return m(e)?e:l(e)?function(){return e}:function(){return t}}function v(t,e,r){return void 0===r&&(r=!0),e||0===e?m(e)?e:l(e)?function(){return e}:u(e)?function(){if(r){var n=Math.max.apply(Math,i([],o(e),!1));return isNaN(n)?t:n}return e}:g(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?u(r)?r[0]>r[1]?r[0]:r[1]:g(r)?r.width>r.height?r.width:r.height:r:t}}var x=function(t,e,n,o){var i=t.getAllNodes(),s=t.getAllEdges();if(!(null==i?void 0:i.length)){var a={nodes:[],edges:s};return null==o||o(a),a}if(1===i.length)return e&&t.mergeNodeData(i[0].id,{x:n[0],y:n[1]}),a={nodes:[r(r({},i[0]),{data:r(r({},i[0].data),{x:n[0],y:n[1]})})],edges:s},null==o||o(a),a},M={radius:null,startRadius:null,endRadius:null,startAngle:0,endAngle:2*Math.PI,clockwise:!0,divisions:1,ordering:null,angleRatio:1},b=function(){function t(t){void 0===t&&(t={}),this.options=t,this.id="circular",this.options=r(r({},M),t)}return t.prototype.execute=function(t,e){return this.genericCircularLayout(!1,t,e)},t.prototype.assign=function(t,e){this.genericCircularLayout(!0,t,e)},t.prototype.genericCircularLayout=function(t,e,n){var i=r(r({},this.options),n),s=i.width,a=i.height,h=i.center,u=i.divisions,l=i.startAngle,c=void 0===l?0:l,f=i.endAngle,d=void 0===f?2*Math.PI:f,g=i.angleRatio,p=i.ordering,m=i.clockwise,M=i.nodeSpacing,b=i.nodeSize,S=i.layoutInvisibles,A=i.onLayoutEnd,k=e.getAllNodes(),I=e.getAllEdges();S||(k=k.filter((function(t){var e=(t.data||{}).visible;return e||void 0===e})),I=I.filter((function(t){var e=(t.data||{}).visible;return e||void 0===e})));var D=o(N(s,a,h),3),R=D[0],_=D[1],z=D[2],O=null==k?void 0:k.length;if(!O||1===O)return x(e,t,z,A);var T=(d-c)/O,C=i.radius,q=i.startRadius,L=i.endRadius;if(M){var P=w(10,M),F=v(10,b),j=-1/0;k.forEach((function(t){var e=F(t);j<e&&(j=e)}));var V=0;k.forEach((function(t,e){V+=0===e?j||10:(P(t)||0)+(j||10)})),C=V/(2*Math.PI)}else C||q||L?!q&&L?q=L:q&&!L&&(L=q):C=Math.min(_,R)/2;var W=T*g,$=[];$="topology"===p?E(e,k):"topology-directed"===p?E(e,k,!0):"degree"===p?function(t,e){var r=[];return e.forEach((function(t,e){r.push(y(t))})),r.sort((function(e,r){return t.getDegree(e.id,"both")-t.getDegree(r.id,"both")})),r}(e,k):k.map((function(t){return y(t)}));for(var G=Math.ceil(O/u),B=0;B<O;++B){var U=C;U||null===q||null===L||(U=q+B*(L-q)/(O-1)),U||(U=10+100*B/(O-1));var H=c+B%G*W+2*Math.PI/u*Math.floor(B/G);m||(H=d-B%G*W-2*Math.PI/u*Math.floor(B/G)),$[B].data.x=z[0]+Math.cos(H)*U,$[B].data.y=z[1]+Math.sin(H)*U}t&&$.forEach((function(t){e.mergeNodeData(t.id,{x:t.data.x,y:t.data.y})}));var K={nodes:$,edges:I};return null==A||A(K),K},t}(),E=function(t,e,r){void 0===r&&(r=!1);var n=[y(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),l=!1,c=0;c<u.length;c++){var f=u[c];if(t.getDegree(f.id)===t.getDegree(a.id)&&!o[f.id]){n.push(y(f)),o[f.id]=!0,l=!0;break}}for(var d=0;!l&&(o[e[d].id]||(n.push(y(e[d])),o[e[d].id]=!0,l=!0),++d!==i););}else n.push(y(a)),o[a.id]=!0,s++})),n},N=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]},S={nodeSize:30,nodeSpacing:10,preventOverlap:!1,sweep:void 0,equidistant:!1,startAngle:1.5*Math.PI,clockwise:!0,maxLevelDiff:void 0,sortBy:"degree"},A=function(){function t(t){void 0===t&&(t={}),this.options=t,this.id="concentric",this.options=r(r({},S),t)}return t.prototype.execute=function(t,e){return this.genericConcentricLayout(!1,t,e)},t.prototype.assign=function(t,e){this.genericConcentricLayout(!0,t,e)},t.prototype.genericConcentricLayout=function(t,e,n){var o=r(r({},this.options),n),i=o.center,s=o.width,h=o.height,c=o.sortBy,f=o.maxLevelDiff,d=o.sweep,p=o.clockwise,w=o.equidistant,v=o.preventOverlap,M=o.startAngle,b=void 0===M?1.5*Math.PI:M,E=o.nodeSize,N=o.nodeSpacing,S=o.layoutInvisibles,A=o.onLayoutEnd,k=e.getAllNodes(),I=e.getAllEdges();S||(k=k.filter((function(t){var e=(t.data||{}).visible;return e||void 0===e})),I=I.filter((function(t){var e=(t.data||{}).visible;return e||void 0===e})));var D=s||"undefined"==typeof window?s:window.innerWidth,R=h||"undefined"==typeof window?h:window.innerHeight,_=i||[D/2,R/2];if(!(null==k?void 0:k.length)||1===k.length)return x(e,t,_,A);var z,O=[],T=0;z=u(E)?Math.max(E[0],E[1]):E,u(N)?T=Math.max(N[0],N[1]):l(N)&&(T=N),k.forEach((function(t){var e=y(t);O.push(e);var r=z,n=e.data;u(n.size)?r=Math.max(n.size[0],n.size[1]):l(n.size)?r=n.size:g(n.size)&&(r=Math.max(n.size.width,n.size.height)),z=Math.max(z,r),m(N)&&(T=Math.max(N(t),T))}));var C={};O.forEach((function(t,e){C[t.id]=e}));var q=c;a(q)&&void 0!==O[0].data[q]||(q="degree"),"degree"===q?O.sort((function(t,r){return e.getDegree(r.id,"both")-e.getDegree(t.id,"both")})):O.sort((function(t,e){return e.data[q]-t.data[q]}));var L=O[0],P=(f||("degree"===q?e.getDegree(L.id,"both"):L.data[q]))/4,F=[{nodes:[]}],j=F[0];O.forEach((function(t){if(j.nodes.length>0){var r="degree"===q?Math.abs(e.getDegree(j.nodes[0].id,"both")-e.getDegree(t.id,"both")):Math.abs(j.nodes[0].data[q]-t.data[q]);P&&r>=P&&(j={nodes:[]},F.push(j))}j.nodes.push(t)}));var V=z+T;if(!v){var W=F.length>0&&F[0].nodes.length>1,$=(Math.min(D,R)/2-V)/(F.length+(W?1:0));V=Math.min(V,$)}var G=0;if(F.forEach((function(t){var e=void 0===d?2*Math.PI-2*Math.PI/t.nodes.length:d;if(t.dTheta=e/Math.max(1,t.nodes.length-1),t.nodes.length>1&&v){var r=Math.cos(t.dTheta)-Math.cos(0),n=Math.sin(t.dTheta)-Math.sin(0),o=Math.sqrt(V*V/(r*r+n*n));G=Math.max(o,G)}t.r=G,G+=V})),w){for(var B=0,U=0,H=0;H<F.length;H++){var K=(F[H].r||0)-U;B=Math.max(B,K)}U=0,F.forEach((function(t,e){0===e&&(U=t.r||0),t.r=U,U+=B}))}F.forEach((function(t){var e=t.dTheta||0,r=t.r||0;t.nodes.forEach((function(t,n){var o=b+(p?1:-1)*e*n;t.data.x=_[0]+r*Math.cos(o),t.data.y=_[1]+r*Math.sin(o)}))})),t&&O.forEach((function(t){return e.mergeNodeData(t.id,{x:t.data.x,y:t.data.y})}));var J={nodes:O,edges:I};return null==A||A(J),J},t}();function k(t,e,r,n){if(isNaN(e)||isNaN(r))return t;var o,i,s,a,h,u,l,c,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,(l=r>=(s=(y+w)/2))?y=s:w=s,o=d,!(d=d[c=l<<1|u]))return o[c]=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[c]=g:t._root=g,t;do{o=o?o[c]=new Array(4):t._root=new Array(4),(u=e>=(i=(p+m)/2))?p=i:m=i,(l=r>=(s=(y+w)/2))?y=s:w=s}while((c=l<<1|u)==(f=(h>=s)<<1|a>=i));return o[f]=d,o[c]=g,t}function I(t,e,r,n,o){this.node=t,this.x0=e,this.y0=r,this.x1=n,this.y1=o}function D(t){return t[0]}function R(t){return t[1]}function _(t,e,r){var n=new z(null==e?D:e,null==r?R:r,NaN,NaN,NaN,NaN);return null==t?n:n.addAll(t)}function z(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 O(t){for(var e={data:t.data},r=e;t=t.next;)r=r.next={data:t.data};return e}var T=_.prototype=z.prototype;function C(t){return function(){return t}}function q(t){return 1e-6*(t()-.5)}T.copy=function(){var t,e,r=new z(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=O(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]=O(e));return r},T.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)},T.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,l=-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))||(s[r]=n,a[r]=o,n<h&&(h=n),n>l&&(l=n),o<u&&(u=o),o>c&&(c=o));if(h>l||u>c)return this;for(this.cover(h,u).cover(l,c),r=0;r<i;++r)k(this,s[r],a[r],t[r]);return this},T.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},T.data=function(){var t=[];return this.visit((function(e){if(!e.length)do{t.push(e.data)}while(e=e.next)})),t},T.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]]},T.find=function(t,e,r){var n,o,i,s,a,h,u,l=this._x0,c=this._y0,f=this._x1,d=this._y1,g=[],p=this._root;for(p&&g.push(new I(p,l,c,f,d)),null==r?r=1/0:(l=t-r,c=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)<l||(a=h.y1)<c))if(p.length){var y=(o+s)/2,m=(i+a)/2;g.push(new I(p[3],y,m,s,a),new I(p[2],o,m,y,a),new I(p[1],y,i,s,m),new I(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);l=t-M,c=e-M,f=t+M,d=e+M,n=p.data}}return n},T.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,l,c,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,(l=s>=(h=(p+m)/2))?p=h:m=h,e=d,!(d=d[c=l<<1|u]))return this;if(!d.length)break;(e[c+1&3]||e[c+2&3]||e[c+3&3])&&(r=e,f=c)}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[c]=o:delete e[c],(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)},T.removeAll=function(t){for(var e=0,r=t.length;e<r;++e)this.remove(t[e]);return this},T.root=function(){return this._root},T.size=function(){var t=0;return this.visit((function(e){if(!e.length)do{++t}while(e=e.next)})),t},T.visit=function(t){var e,r,n,o,i,s,a=[],h=this._root;for(h&&a.push(new I(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,l=(o+s)/2;(r=h[3])&&a.push(new I(r,u,l,i,s)),(r=h[2])&&a.push(new I(r,n,l,u,s)),(r=h[1])&&a.push(new I(r,u,o,i,l)),(r=h[0])&&a.push(new I(r,n,o,u,l))}return this},T.visitAfter=function(t){var e,r=[],n=[];for(this._root&&r.push(new I(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,l=(s+h)/2,c=(a+u)/2;(i=o[0])&&r.push(new I(i,s,a,l,c)),(i=o[1])&&r.push(new I(i,l,a,h,c)),(i=o[2])&&r.push(new I(i,s,c,l,u)),(i=o[3])&&r.push(new I(i,l,c,h,u))}n.push(e)}for(;e=n.pop();)t(e.node,e.x0,e.y0,e.x1,e.y1);return this},T.x=function(t){return arguments.length?(this._x=t,this):this._x},T.y=function(t){return arguments.length?(this._y=t,this):this._y};var L={value:()=>{}};function P(){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 F(n)}function F(t){this._=t}function j(t,e){return t.trim().split(/^|\\s+/).map((function(t){var r="",n=t.indexOf(".");if(n>=0&&(r=t.slice(n+1),t=t.slice(0,n)),t&&!e.hasOwnProperty(t))throw new Error("unknown type: "+t);return{type:t,name:r}}))}function V(t,e){for(var r,n=0,o=t.length;n<o;++n)if((r=t[n]).name===e)return r.value}function W(t,e,r){for(var n=0,o=t.length;n<o;++n)if(t[n].name===e){t[n]=L,t=t.slice(0,n).concat(t.slice(n+1));break}return null!=r&&t.push({name:e,value:r}),t}F.prototype=P.prototype={constructor:F,on:function(t,e){var r,n=this._,o=j(t+"",n),i=-1,s=o.length;if(!(arguments.length<2)){if(null!=e&&"function"!=typeof e)throw new Error("invalid callback: "+e);for(;++i<s;)if(r=(t=o[i]).type)n[r]=W(n[r],t.name,e);else if(null==e)for(r in n)n[r]=W(n[r],t.name,null);return this}for(;++i<s;)if((r=(t=o[i]).type)&&(r=V(n[r],t.name)))return r},copy:function(){var t={},e=this._;for(var r in e)t[r]=e[r].slice();return new F(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 $=P;var G,B,U=0,H=0,K=0,J=0,Y=0,X=0,Q="object"==typeof performance&&performance.now?performance:Date,Z="object"==typeof window&&window.requestAnimationFrame?window.requestAnimationFrame.bind(window):function(t){setTimeout(t,17)};function tt(){return Y||(Z(et),Y=Q.now()+X)}function et(){Y=0}function rt(){this._call=this._time=this._next=null}function nt(t,e,r){var n=new rt;return n.restart(t,e,r),n}function ot(){Y=(J=Q.now())+X,U=H=0;try{!function(){tt(),++U;for(var t,e=G;e;)(t=Y-e._time)>=0&&e._call.call(void 0,t),e=e._next;--U}()}finally{U=0,function(){for(var t,e,r=G,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:G=e);B=t,st(n)}(),Y=0}}function it(){var t=Q.now(),e=t-J;e>1e3&&(X-=e,J=t)}function st(t){U||(H&&(H=clearTimeout(H)),t-Y>24?(t<1/0&&(H=setTimeout(ot,t-Q.now()-X)),K&&(K=clearInterval(K))):(K||(J=Q.now(),K=setInterval(it,1e3)),U=1,Z(ot)))}rt.prototype=nt.prototype={constructor:rt,restart:function(t,e,r){if("function"!=typeof t)throw new TypeError("callback is not a function");r=(null==r?tt():+r)+(null==e?0:+e),this._next||B===this||(B?B._next=this:G=this,B=this),this._call=t,this._time=r,st()},stop:function(){this._call&&(this._call=null,this._time=1/0,st())}};const at=4294967296;function ht(t){return t.x}function ut(t){return t.y}var lt=Math.PI*(3-Math.sqrt(5));function ct(t){var e,r=1,n=.001,o=1-Math.pow(n,1/300),i=0,s=.6,a=new Map,h=nt(c),u=$("tick","end"),l=function(){let t=1;return()=>(t=(1664525*t+1013904223)%at)/at}();function c(){f(),u.call("tick",e),r<n&&(h.stop(),u.call("end",e))}function f(n){var h,u,l=t.length;void 0===n&&(n=1);for(var c=0;c<n;++c)for(r+=(i-r)*o,a.forEach((function(t){t(r)})),h=0;h<l;++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=10*Math.sqrt(.5+r),i=r*lt;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,l),e}return null==t&&(t=[]),d(),e={tick:f,restart:function(){return h.restart(c),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?(l=t,a.forEach(g),e):l},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,l=t.length;for(null==n?n=1/0:n*=n,u=0;u<l;++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 ft(){var t,e,r,n,o,i=C(-30),s=1,a=1/0,h=.81;function u(r){var o,i=t.length,s=_(t,ht,ut).visitAfter(c);for(n=r,o=0;o<i;++o)e=t[o],s.visit(f)}function l(){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,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,l){if(!t.value)return!0;var c=t.x-e.x,f=t.y-e.y,d=l-i,g=c*c+f*f;if(d*d/h<g)return g<a&&(0===c&&(g+=(c=q(r))*c),0===f&&(g+=(f=q(r))*f),g<s&&(g=Math.sqrt(s*g)),e.vx+=c*t.value*n/g,e.vy+=f*t.value*n/g),!0;if(!(t.length||g>=a)){(t.data!==e||t.next)&&(0===c&&(g+=(c=q(r))*c),0===f&&(g+=(f=q(r))*f),g<s&&(g=Math.sqrt(s*g)));do{t.data!==e&&(d=o[t.data.index]*n/g,e.vx+=c*d,e.vy+=f*d)}while(t=t.next)}}return u.initialize=function(e,n){t=e,r=n,l()},u.strength=function(t){return arguments.length?(i="function"==typeof t?t:C(+t),l(),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 dt(t){return t.index}function gt(t,e){var r=t.get(e);if(!r)throw new Error("node not found: "+e);return r}function pt(t){var e,r,n,o,i,s,a=dt,h=function(t){return 1/Math.min(o[t.source.index],o[t.target.index])},u=C(30),l=1;function c(n){for(var o=0,a=t.length;o<l;++o)for(var h,u,c,f,d,g,p,y=0;y<a;++y)u=(h=t[y]).source,f=(c=h.target).x+c.vx-u.x-u.vx||q(s),d=c.y+c.vy-u.y-u.vy||q(s),f*=g=((g=Math.sqrt(f*f+d*d))-r[y])/g*n*e[y],d*=g,c.vx-=f*(p=i[y]),c.vy-=d*p,u.vx+=f*(p=1-p),u.vy+=d*p}function f(){if(n){var s,h,u=n.length,l=t.length,c=new Map(n.map(((t,e)=>[a(t,e,n),t])));for(s=0,o=new Array(u);s<l;++s)(h=t[s]).index=s,"object"!=typeof h.source&&(h.source=gt(c,h.source)),"object"!=typeof h.target&&(h.target=gt(c,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(l);s<l;++s)h=t[s],i[s]=o[h.source.index]/(o[h.source.index]+o[h.target.index]);e=new Array(l),d(),r=new Array(l),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=[]),c.initialize=function(t,e){n=t,s=e,f()},c.links=function(e){return arguments.length?(t=e,f(),c):t},c.id=function(t){return arguments.length?(a=t,c):a},c.iterations=function(t){return arguments.length?(l=+t,c):l},c.strength=function(t){return arguments.length?(h="function"==typeof t?t:C(+t),d(),c):h},c.distance=function(t){return arguments.length?(u="function"==typeof t?t:C(+t),g(),c):u},c}function yt(t){return t.x+t.vx}function mt(t){return t.y+t.vy}function wt(t){var e,r,n,o=1,i=1;function s(){for(var t,s,h,u,l,c,f,d=e.length,g=0;g<i;++g)for(s=_(e,yt,mt).visitAfter(a),t=0;t<d;++t)h=e[t],c=r[h.index],f=c*c,u=h.x+h.vx,l=h.y+h.vy,s.visit(p);function p(t,e,r,i,s){var a=t.data,d=t.r,g=c+d;if(!a)return e>u+g||i<u-g||r>l+g||s<l-g;if(a.index>h.index){var p=u-a.x-a.vx,y=l-a.y-a.vy,m=p*p+y*y;m<g*g&&(0===p&&(m+=(p=q(n))*p),0===y&&(m+=(y=q(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=C(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:C(+e),h(),s):t},s}function vt(t){var e,r,n,o=C(.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=C(null==t?0:+t)),i.initialize=function(t){e=t,s()},i.strength=function(t){return arguments.length?(o="function"==typeof t?t:C(+t),s(),i):o},i.x=function(e){return arguments.length?(t="function"==typeof e?e:C(+e),s(),i):t},i}function xt(t){var e,r,n,o=C(.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=C(null==t?0:+t)),i.initialize=function(t){e=t,s()},i.strength=function(t){return arguments.length?(o="function"==typeof t?t:C(+t),s(),i):o},i.y=function(e){return arguments.length?(t="function"==typeof e?e:C(+e),s(),i):t},i}function Mt(){function t(t){return function(){return t}}var e,r=function(t){return t.cluster},n=t(1),i=t(-1),s=t(100),a=t(.1),h=[0,0],u=[],l={},c=[],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(l[o]))<=(a=r(l[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=o(t,2),r=e[0],i=e[1],s=r.split("~")[0],a=r.split("~")[1];void 0!==s&&void 0!==a&&n.push({source:s,target:a,count:i})})),n}(c),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=ct(w.nodes).force("x",vt(f).strength(.1)).force("y",xt(d).strength(.1)).force("collide",wt((function(t){return t.r})).iterations(4)).force("charge",ft().strength(i)).force("links",pt(w.nodes.length?w.links:[]).distance(s).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}function b(t){l={},t.forEach((function(t){l[t.id]=t}))}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?(b(t||[]),u=t||[],v):u},v.links=function(t){return arguments.length?(c=t||[],x(),v):c},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?(i="function"==typeof e?e:t(+e),x(),v):i},v.forceLinkDistance=function(e){return arguments.length?(s="function"==typeof e?e:t(+e),x(),v):s},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 bt={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},Et=function(){function t(t){void 0===t&&(t={}),this.options=t,this.id="d3force",this.running=!1,this.options=r(r({},bt),t)}return t.prototype.execute=function(t,e){return this.genericForceLayout(!1,t,e)},t.prototype.assign=function(t,e){this.genericForceLayout(!0,t,e)},t.prototype.stop=function(){var t;null===(t=this.forceSimulation)||void 0===t||t.stop(),this.running=!1},t.prototype.restart=function(){var t;null===(t=this.forceSimulation)||void 0===t||t.restart(),this.running=!0},t.prototype.tick=function(t){var e=this;void 0===t&&(t=1),this.forceSimulation.tick(t);var r={nodes:Nt(this.lastLayoutNodes),edges:St(this.lastLayoutEdges)};return this.lastAssign&&r.nodes.forEach((function(t){return e.lastGraph.mergeNodeData(t.id,{x:t.data.x,y:t.data.y})})),this.lastOptions.onLayoutEnd&&this.lastOptions.onLayoutEnd(r),r},t.prototype.genericForceLayout=function(t,e,n){var o=this,i=r(r({},this.options),n),s=i.layoutInvisibles,a=e.getAllNodes(),h=e.getAllEdges();s||(a=a.filter((function(t){var e=(t.data||{}).visible;return e||void 0===e})),h=h.filter((function(t){var e=(t.data||{}).visible;return e||void 0===e})));var u=a.map((function(t){var e,n;return r(r({},y(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})})),l=h.map((function(t){return y(t)}));if(this.lastLayoutNodes=u,this.lastLayoutEdges=l,this.lastAssign=t,this.lastGraph=e,this.lastOptions=i,!this.running){var c=i.alphaMin,f=i.alphaDecay,d=i.alpha,g=i.nodeStrength,p=i.edgeStrength,m=i.linkDistance,w=i.clustering,v=i.clusterFociStrength,x=i.clusterEdgeDistance,M=i.clusterEdgeStrength,b=i.clusterNodeStrength,E=i.clusterNodeSize,N=i.collideStrength,S=void 0===N?1:N,A=i.center,k=void 0===A?[0,0]:A,I=i.preventOverlap,D=i.nodeSize,R=i.nodeSpacing,_=i.onTick,z=i.onLayoutEnd,O=i.forceSimulation;if(O)w&&((T=Mt()).nodes(u),T.links(l)),O.nodes(u),l&&(q=pt().id((function(t){return t.id})).links(l),p&&q.strength(p),m&&q.distance(m),O.force("link",q)),I&&this.overlapProcess(O,{nodeSize:D,nodeSpacing:R,collideStrength:S}),O.alpha(d).restart(),this.running=!0;else try{var T,C=ft();if(g&&C.strength(g),O=ct().nodes(u),w&&((T=Mt()).centerX(k[0]).centerY(k[1]).template("force").strength(v),l&&T.links(l),u&&T.nodes(u),T.forceLinkDistance(x).forceLinkStrength(M).forceCharge(b).forceNodeSize(E),O.force("group",T)),O.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}(k[0],k[1])).force("charge",C).alpha(d).alphaDecay(f).alphaMin(c),I&&this.overlapProcess(O,{nodeSize:D,nodeSpacing:R,collideStrength:S}),l){var q=pt().id((function(t){return t.id})).links(l);p&&q.strength(p),m&&q.distance(m),O.force("link",q)}O.on("tick",(function(){var r=Nt(u);null==_||_({nodes:r,edges:St(l)}),t&&r.forEach((function(t){return e.mergeNodeData(t.id,{x:t.data.x,y:t.data.y})}))})).on("end",(function(){o.running=!1;var r=Nt(u);null==z||z({nodes:r,edges:St(l)}),t&&r.forEach((function(t){return e.mergeNodeData(t.id,{x:t.data.x,y:t.data.y})}))})),this.running=!0}catch(t){this.running=!1,console.warn(t)}this.forceSimulation=O;var L=Nt(u),P=St(l);return t&&L.forEach((function(t){return e.mergeNodeData(t.id,{x:t.data.x,y:t.data.y})})),{nodes:L,edges:P}}},t.prototype.overlapProcess=function(t,e){var r,n,o=e.nodeSize,i=e.nodeSpacing,s=e.collideStrength;if(n=l(i)?function(){return i}:m(i)?i:function(){return 0},o)if(m(o))r=function(t){return o(t)+n(t)};else if(u(o)){var a=(o[0]>o[1]?o[0]:o[1])/2;r=function(t){return a+n(t)}}else if(l(o)){var h=o/2;r=function(t){return h+n(t)}}else r=function(){return 10};else r=function(t){return t.size?u(t.size)?(t.size[0]>t.size[1]?t.size[0]:t.size[1])/2+n(t):g(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}(),Nt=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})})}))},St=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 At(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 kt={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"},It=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({},kt),t)}return t.prototype.execute=function(t,e){return this.genericForceLayout(!1,t,e)},t.prototype.assign=function(t,e){this.genericForceLayout(!0,t,e)},t.prototype.stop=function(){this.timeInterval&&"undefined"!=typeof window&&window.clearInterval(this.timeInterval),this.running=!1},t.prototype.restart=function(){this.running=!0},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})})),this.lastOptions.onLayoutEnd&&this.lastOptions.onLayoutEnd(n),n},t.prototype.genericForceLayout=function(t,e,n){var o=this,i=r(r({},this.options),n),a=e.getAllNodes(),h=e.getAllEdges();i.layoutInvisibles||(a=a.filter((function(t){return t.data.visible||void 0===t.data.visible})),h=h.filter((function(t){return t.data.visible||void 0===t.data.visible})));var u=this.formatOptions(i,e),c=u.width,f=u.height,d=u.nodeSize,g=u.getMass,p=u.nodeStrength,y=u.edgeStrength,m=u.linkDistance,w=a.map((function(t){return r(r({},t),{data:r(r({},t.data),{x:l(t.data.x)?t.data.x:Math.random()*c,y:l(t.data.y)?t.data.y:Math.random()*f,size:d(t)||30,mass:g(t),nodeStrength:p(t)})})})),v=h.map((function(t){return r(r({},t),{data:r(r({},t.data),{edgeStrength:y(t),linkDistance:m(t,e.getNode(t.source),e.getNode(t.target))})})}));if(!(null==a?void 0:a.length))return this.lastResult={nodes:[],edges:h},{nodes:[],edges:h};var x={};a.forEach((function(t,e){x[t.id]={x:0,y:0}}));var M=new s({nodes:w,edges:v});this.formatCentripetal(u,M);var b=u.maxIteration,E=u.minMovement,N=u.onLayoutEnd,S=u.onTick;if(this.lastLayoutNodes=w,this.lastLayoutEdges=v,this.lastAssign=t,this.lastGraph=e,this.lastCalcGraph=M,this.lastOptions=u,this.lastVelMap=x,"undefined"!=typeof window){var A=0;return this.timeInterval=window.setInterval((function(){a&&o.running&&(o.runOneStep(M,e,A,x,u),o.updatePosition(e,M,x,u),t&&w.forEach((function(t){return e.mergeNodeData(t.id,{x:t.data.x,y:t.data.y})})),null==S||S({nodes:Ot(e,w),edges:h}),(++A>=b||o.judgingDistance<E)&&(null==N||N({nodes:Ot(e,w),edges:h}),window.clearInterval(o.timeInterval)))}),0),this.running=!0,{nodes:Ot(e,w),edges:h}}},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;l(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=w(0,t.nodeSpacing);t.nodeSize?u(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?u(e)?Math.max(e[0],e[1])+s(t):g(e)?Math.max(e.width,e.height)+s(t):e+s(t):10+s(t)}}return r.linkDistance=t.linkDistance?w(1,t.linkDistance):function(t){return 1+r.nodeSize(e.getNode(t.source))+r.nodeSize(e.getNode(t.target))},r.nodeStrength=w(1,t.nodeStrength),r.edgeStrength=w(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(),l=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(s&&h&&(r=Dt(e,h),c=Array.from(new Set(null==u?void 0:u.map((function(t){return t.data[h]}))))||[],t.centripetalOptions=Object.assign(l,{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,s=void 0===i?[]:i;1===s.length?n=void 0:s.length>1&&(n=zt(s))}else n=void 0;return{x:null==n?void 0:n.x,y:null==n?void 0:n.y}}})),a&&h){r||(r=Dt(e,h)),c||(c=Array.from(new Set(u.map((function(t){return t.data[h]}))))),c=c.filter((function(t){return void 0!==t}));var f={};c.forEach((function(t){var r=u.filter((function(e){return e.data[h]===t})).map((function(t){return e.getNode(t.id)}));f[t]=zt(r)})),t.centripetalOptions=Object.assign(l,{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=_(s,(function(t){return t.x}),(function(t){return t.y})).visitAfter(At);s.forEach((function(t){!function(t,e){e.visit((function(e,r,n,o,i){return 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,l=Math.sqrt(u)*u;if(h*h*.81<u){var c=t.weight/l;return i.vx+=s*c,i.vy+=a*c,!0}if(t.length)return!1;t.data!==i&&(c=t.data.weight/l,i.vx+=s*c,i.vy+=a*c)}(e,r,0,o,0,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 l=Math.sqrt(h*h+u*u),c=h/l,f=u/l,d=r.data||{},g=d.linkDistance,p=void 0===g?200:g,y=d.edgeStrength,m=(p-l)*(void 0===y?200:y),w=1/(s.data.mass||1),v=1/(a.data.mass||1),x=c*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 i=n.getCenter,s=t.getAllNodes(),a=e.getAllNodes(),h=e.getAllEdges(),u=n.width,c=n.height,f=n.center,d=n.gravity,g=n.centripetalOptions;s&&s.forEach((function(n){var s=n.id,p=n.data,y=p.mass,m=p.x,w=p.y,v=e.getNode(s),x=0,M=0,b=d,E=t.getDegree(s,"in"),N=t.getDegree(s,"out"),S=t.getDegree(s,"both"),A=null==i?void 0:i(v,S);if(A){var k=o(A,3);x=m-k[0],M=w-k[1],b=k[2]}else x=m-f[0],M=w-f[1];if(b&&(r[s].x-=b*x/y,r[s].y-=b*M/y),g){var I=g.leaf,D=g.single,R=g.others,_=g.center,z=(null==_?void 0:_(v,a,h,u,c))||{x:0,y:0,centerStrength:0},O=z.x,T=z.y,C=z.centerStrength;if(!l(O)||!l(T))return;var q=(m-O)/y,L=(w-T)/y;if(C&&(r[s].x-=C*q,r[s].y-=C*L),0===S){var P=D(v);if(!P)return;return r[s].x-=P*q,void(r[s].y-=P*L)}if(0===E||0===N){var F=I(v,a,h);if(!F)return;return r[s].x-=F*q,void(r[s].y-=F*L)}var j=R(v);if(!j)return;r[s].x-=j*q,r[s].y-=j*L}}))},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 l=i/u;a*=l,h*=l}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(l(u.data.fx)&&l(u.data.fy))e.mergeNodeData(a,{x:u.data.fx,y:u.data.fy});else{var c=r[a].x*s,f=r[a].y*s;e.mergeNodeData(a,{x:n.data.x+c,y:n.data.y+f});var d=Math.sqrt(c*c+f*f);switch(i){case"max":o.judgingDistance<d&&(o.judgingDistance=d);break;case"min":o.judgingDistance>d&&(o.judgingDistance=d);break;default:h+=d}}})),i&&"mean"!==i||(this.judgingDistance=h/a.length)}else this.judgingDistance=0},t}(),Dt=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]=Rt(t,"leaf",r,e))})),n},Rt=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},zt=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}},Ot=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})})}))},Tt=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 Ct=Tt;const qt=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}(),Lt=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 Pt={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},Ft=function(){function t(t){void 0===t&&(t={}),this.options=t,this.id="forceAtlas2",this.options=r(r({},Pt),t)}return t.prototype.execute=function(t,e){return this.genericForceAtlas2Layout(!1,t,e)},t.prototype.assign=function(t,e){this.genericForceAtlas2Layout(!0,t,e)},t.prototype.genericForceAtlas2Layout=function(t,e,n){var o=e.getAllEdges(),i=e.getAllNodes(),a=this.formatOptions(n,i.length),h=a.width,u=a.height,l=a.prune,c=a.maxIteration,f=a.nodeSize,d=a.center,g=a.onLayoutEnd;if(!(null==i?void 0:i.length)||1===i.length)return x(e,t,d,g);var p=i.map((function(t){return y(t,[h,u])})),m=o.filter((function(t){return t.source!==t.target})),w=new s({nodes:p,edges:m}),v=this.getSizes(w,e,f);if(this.run(w,e,c,v,t,a),l){for(var M=0;M<m.length;M+=1){var b=m[M],E=b.source,N=b.target,S=w.getDegree(E),A=w.getDegree(E);if(S<=1){var k=w.getNode(N);w.mergeNodeData(E,{x:k.data.x,y:k.data.y})}else if(A<=1){var I=w.getNode(E);w.mergeNodeData(N,{x:I.data.x,y:I.data.y})}}var D=r(r({},a),{prune:!1,barnesHut:!1});this.run(w,e,100,v,t,D)}var R={nodes:p,edges:o};return null==g||g(R),R},t.prototype.getSizes=function(t,e,r){for(var n=t.getAllNodes(),s={},a=0;a<n.length;a+=1){var h=n[a],c=h.id,f=h.data;if(s[c]=10,l(f.size))s[c]=f.size;else if(u(f.size))isNaN(f.size[0])||(s[c]=Math.max(f.size[0])),isNaN(f.size[1])||(s[c]=Math.max(f.size[1]));else if(g(f.size))s[c]=Math.max(f.size.width,f.size.height);else if(m(r)){var d=r(e.getNode(c));u(d)?s[c]=Math.max.apply(Math,i([],o(d),!1)):s[c]=d}else u(r)?s[c]=Math.max.apply(Math,i([],o(r),!1)):l(r)&&(s[c]=r)}return s},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,l=n.kr,c=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)),l||(n.kr=50,e>100&&e<=500?n.kr=20:e>500&&(n.kr=1)),c||(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(),l=0,c=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 Ct(v)}}for(;c>0;)l=this.oneStep(t,{iter:c,preventOverlapIters:50,krPrime:100,sg:l,forces:f,preForces:d,bodies:g,sizes:n},i),c--,null==h||h({nodes:u,edges:e.getAllEdges()});return t},t.prototype.oneStep=function(t,e,r){for(var n=e.iter,s=e.preventOverlapIters,a=e.krPrime,h=e.sg,u=e.preForces,l=e.bodies,c=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]=i([],o(f[m]),!1),f[m]=[0,0]}return f=this.getAttrForces(t,n,s,c,f,r),f=g&&(d&&n>s||!d)?this.getOptRepGraForces(t,f,l,r):this.getRepGraForces(t,n,s,f,a,c,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,l=t.getAllEdges(),c=0;c<l.length;c+=1){var f=l[c],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,l=-9e10,c=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>=l&&(l=y.x),y.x<=u&&(u=y.x),y.y>=f&&(f=y.y),y.y<=c&&(c=y.y))}var m=Math.max(l-u,f-c),w=new qt({xmid:(l+u)/2,ymid:(f+c)/2,length:m,massCenter:i,mass:h}),v=new Lt(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,l=s.center,c=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(!c||!(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-l[0],p.data.y-l[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,f=[],d=[],g=0,p=0,y=n,m=0;m<c;m+=1){var w=u[m].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]);f[m]=M,d[m]=E/2,g+=(v+1)*f[m],p+=(v+1)*d[m]}}var N=y;for(y=s*p/g,0!==N&&(y=y>1.5*N?1.5*N:y),m=0;m<c;m+=1){var S=u[m],A=(w=S.id,S.data);if(v=t.getDegree(w),!(a&&v<=1||l(A.fx)&&l(A.fy))){var k=i*y/(1+y*Math.sqrt(f[m])),I=Math.hypot(e[w][0],e[w][1]),D=h/(I=I<1e-4?1e-4:I),R=(k=k>D?D:k)*e[w][0],_=k*e[w][1];t.mergeNodeData(w,{x:A.x+R,y:A.y+_})}}return y},t}(),jt={maxIteration:1e3,gravity:10,speed:5,clustering:!1,clusterGravity:10,width:300,height:300,nodeClusterBy:"cluster"},Vt=function(){function t(t){void 0===t&&(t={}),this.options=t,this.id="fruchterman",this.timeInterval=0,this.running=!1,this.options=r(r({},jt),t)}return t.prototype.execute=function(t,e){return this.genericFruchtermanLayout(!1,t,e)},t.prototype.assign=function(t,e){this.genericFruchtermanLayout(!0,t,e)},t.prototype.stop=function(){this.timeInterval&&"undefined"!=typeof window&&window.clearInterval(this.timeInterval),this.running=!1},t.prototype.restart=function(){this.running=!0},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})})),this.lastOptions.onLayoutEnd&&this.lastOptions.onLayoutEnd(n),n},t.prototype.genericFruchtermanLayout=function(t,e,n){var o=this;if(!this.running){var i=this.formatOptions(n),a=i.layoutInvisibles,h=i.width,u=i.height,l=i.center,c=i.clustering,f=i.nodeClusterBy,d=i.maxIteration,g=i.onTick,p=i.onLayoutEnd,m=e.getAllNodes(),w=e.getAllEdges();if(a||(m=m.filter((function(t){var e=(t.data||{}).visible;return e||void 0===e})),w=w.filter((function(t){var e=(t.data||{}).visible;return e||void 0===e}))),!(null==m?void 0:m.length)){var v={nodes:[],edges:w};return this.lastResult=v,null==p||p(v),v}if(1===m.length)return t&&e.mergeNodeData(m[0].id,{x:l[0],y:l[1]}),v={nodes:[r(r({},m[0]),{data:r(r({},m[0].data),{x:l[0],y:l[1]})})],edges:w},this.lastResult=v,null==p||p(v),v;var x=m.map((function(t){return y(t,[h,u])})),M=new s({nodes:x,edges:w}),b={};if(c&&x.forEach((function(t){var e=t.data[f];b[e]||(b[e]={name:e,cx:0,cy:0,count:0})})),this.lastLayoutNodes=x,this.lastLayoutEdges=w,this.lastAssign=t,this.lastGraph=M,this.lastOptions=i,this.lastClusterMap=b,"undefined"!=typeof window){var E=0;return this.timeInterval=window.setInterval((function(){if(o.running&&(o.runOneStep(M,b,i),t&&x.forEach((function(t){var r=t.id,n=t.data;return e.mergeNodeData(r,{x:n.x,y:n.y})})),null==g||g({nodes:x,edges:w}),++E>=d)){try{null==p||p({nodes:x,edges:w})}catch(t){console.warn("onLayoutEnd failed",t)}window.clearInterval(o.timeInterval)}}),0),this.running=!0,{nodes:x,edges:w}}}},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,f=n*o,d=Math.sqrt(f)/10,g=t.getAllNodes(),p=f/(g.length+1),y=Math.sqrt(p),m={};if(this.applyCalculate(t,m,y,p),h){for(var w in e)e[w].cx=0,e[w].cy=0,e[w].count=0;for(var w in g.forEach((function(t){var r=t.data,n=e[r[u]];l(r.x)&&(n.cx+=r.x),l(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;g.forEach((function(t,r){var n=t.id,o=t.data;if(l(o.x)&&l(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=y*v;m[n].x-=a*(o.x-i.cx)/s,m[n].y-=a*(o.y-i.cy)/s}}))}g.forEach((function(t,e){var r=t.id,n=t.data;if(l(n.x)&&l(n.y)){var o=.01*y*i;m[r].x-=o*(n.x-s[0]),m[r].y-=o*(n.y-s[1])}})),g.forEach((function(e,r){var n=e.id,o=e.data;if(l(o.fx)&&l(o.fy))return o.x=o.fx,void(o.y=o.fy);if(l(o.x)&&l(o.y)){var i=Math.sqrt(m[n].x*m[n].x+m[n].y*m[n].y);if(i>0){var s=Math.min(d*(a/800),i);t.mergeNodeData(n,{x:o.x+m[n].x/i*s,y:o.y+m[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)&&l(i.x)&&l(a.x)&&l(i.y)&&l(a.y)){var u=i.x-a.x,c=i.y-a.y,f=u*u+c*c;0===f&&(f=1,u=.01,c=.01);var d=r/f,g=u*d,p=c*d;e[s].x+=g,e[s].y+=p,e[h].x-=g,e[h].y-=p}}))}))},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(l(a.x)&&l(s.x)&&l(a.y)&&l(s.y)){var h=a.x-s.x,u=a.y-s.y,c=Math.sqrt(h*h+u*u)/r,f=h*c,d=u*c;e[o].x+=f,e[o].y+=d,e[i].x-=f,e[i].y-=d}}}))},t}(),Wt={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},$t=function(){function t(t){void 0===t&&(t={}),this.options=t,this.id="grid",this.options=r(r({},Wt),t)}return t.prototype.execute=function(t,e){return this.genericGridLayout(!1,t,e)},t.prototype.assign=function(t,e){this.genericGridLayout(!0,t,e)},t.prototype.genericGridLayout=function(t,e,n){var o=r(r({},this.options),n),i=o.begin,s=void 0===i?[0,0]:i,h=o.condense,c=o.preventOverlapPadding,f=o.preventOverlap,d=o.rows,g=o.cols,p=o.nodeSpacing,m=o.nodeSize,M=o.width,b=o.height,E=o.layoutInvisibles,N=o.onLayoutEnd,S=o.position,A=o.sortBy,k=e.getAllNodes(),I=e.getAllEdges();E||(k=k.filter((function(t){var e=(t.data||{}).visible;return e||void 0===e})),I=I.filter((function(t){var e=(t.data||{}).visible;return e||void 0===e})));var D=null==k?void 0:k.length;if(!D||1===D)return x(e,t,s,N);var R=k.map((function(t){return y(t)}));"id"===A||a(A)&&void 0!==R[0].data[A]||(A="degree"),"degree"===A?R.sort((function(t,r){return e.getDegree(r.id,"both")-e.getDegree(t.id,"both")})):"id"===A?R.sort((function(t,e){return l(e.id)&&l(t.id)?e.id-t.id:"".concat(t.id).localeCompare("".concat(e.id))})):R.sort((function(t,e){return e.data[A]-t.data[A]}));var _=M||"undefined"==typeof window?M:window.innerWidth,z=b||"undefined"==typeof window?b:window.innerHeight,O=D,T={rows:d,cols:g};if(null!=d&&null!=g)T.rows=d,T.cols=g;else if(null!=d&&null==g)T.rows=d,T.cols=Math.ceil(O/T.rows);else if(null==d&&null!=g)T.cols=g,T.rows=Math.ceil(O/T.cols);else{var C=Math.sqrt(O*z/_);T.rows=Math.round(C),T.cols=Math.round(_/z*C)}if(T.rows=Math.max(T.rows,1),T.cols=Math.max(T.cols,1),T.cols*T.rows>O)((L=Gt(T))-1)*(q=Bt(T))>=O?Gt(T,L-1):(q-1)*L>=O&&Bt(T,q-1);else for(;T.cols*T.rows<O;){var q,L=Gt(T);((q=Bt(T))+1)*L>=O?Bt(T,q+1):Gt(T,L+1)}var P=h?0:_/T.cols,F=h?0:z/T.rows;if(f||p){var j=w(10,p),V=v(30,m,!1);R.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=V(o)||30;u(i)?(r=i[0],n=i[1]):(r=i,n=i);var s=void 0!==j?j(t):c,a=r+s,h=n+s;P=Math.max(P,a),F=Math.max(F,h)}))}for(var W={},$={row:0,col:0},G={},B=0;B<R.length;B++){var U=R[B],H=void 0;if(S&&(H=S(e.getNode(U.id))),H&&(void 0!==H.row||void 0!==H.col)){var K={row:H.row,col:H.col};if(void 0===K.col)for(K.col=0;Ut(W,K);)K.col++;else if(void 0===K.row)for(K.row=0;Ut(W,K);)K.row++;G[U.id]=K,Ht(W,K)}Jt(U,s,P,F,G,T,$,W)}var J={nodes:R,edges:I};return null==N||N(J),t&&R.forEach((function(t){e.mergeNodeData(t.id,{x:t.data.x,y:t.data.y})})),J},t}(),Gt=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},Bt=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},Ut=function(t,e){return t["c-".concat(e.row,"-").concat(e.col)]||!1},Ht=function(t,e){return t["c-".concat(e.row,"-").concat(e.col)]=!0},Kt=function(t,e){var r=t.cols||5;e.col++,e.col>=r&&(e.col=0,e.row++)},Jt=function(t,e,r,n,o,i,s,a){var h,u,l=o[t.id];if(l)h=l.col*r+r/2+e[0],u=l.row*n+n/2+e[1];else{for(;Ut(a,s);)Kt(i,s);h=s.col*r+r/2+e[0],u=s.row*n+n/2+e[1],Ht(a,s),Kt(i,s)}t.data.x=h,t.data.y=u};const Yt=Object.prototype.toString;function Xt(t){return Yt.call(t).endsWith("Array]")}function Qt(t){var e=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};if(!Xt(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}function Zt(t){var e=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};if(!Xt(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}function te(t){var e,r=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};if(!Xt(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(!Xt(r.output))throw new TypeError("output option must be an array if specified");e=r.output}else e=new Array(t.length);var n=Zt(t),o=Qt(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),l=0;l<t.length;l++)e[l]=(t[l]-n)*u+s;return e}const ee=" ".repeat(2),re=" ".repeat(4);function ne(t,e={}){const{maxRows:r=15,maxColumns:n=10,maxNumSize:o=8,padMinus:i="auto"}=e;return`${t.constructor.name} {\\n${ee}[\\n${re}${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(oe(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${re}`)}(t,r,n,o,i)}\\n${ee}]\\n${ee}rows: ${t.rows}\\n${ee}columns: ${t.columns}\\n}`}function oe(t,e,r){return(t>=0&&r?` ${ie(t,e-1)}`:ie(t,e)).padEnd(e)}function ie(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 se(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 ae(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 he(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 ue(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(fe("startRow",e),fe("endRow",r),fe("startColumn",n),fe("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 ce(t,e=0){let r=[];for(let n=0;n<t;n++)r.push(e);return r}function fe(t,e){if("number"!=typeof e)throw new TypeError(`${t} must be a number`)}function de(t){if(t.isEmpty())throw new Error("Empty matrix has no elements to index")}class ge{static from1DArray(t,e,r){if(t*e!==r.length)throw new RangeError("data length does not match given dimensions");let n=new ye(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 ye(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 ye(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 ye(t,e)}static ones(t,e){return new ye(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 ye(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 ye(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 ye(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 ge.isMatrix(t)?t:new ye(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 ye(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){se(this,t);let e=[];for(let r=0;r<this.columns;r++)e.push(this.get(t,r));return e}getRowVector(t){return ye.rowVector(this.getRow(t))}setRow(t,e){se(this,t),e=he(this,e);for(let r=0;r<this.columns;r++)this.set(t,r,e[r]);return this}swapRows(t,e){se(this,t),se(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){ae(this,t);let e=[];for(let r=0;r<this.rows;r++)e.push(this.get(r,t));return e}getColumnVector(t){return ye.columnVector(this.getColumn(t))}setColumn(t,e){ae(this,t),e=ue(this,e);for(let r=0;r<this.rows;r++)this.set(r,t,e[r]);return this}swapColumns(t,e){ae(this,t),ae(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=he(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=he(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=he(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=he(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=ue(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=ue(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=ue(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=ue(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){se(this,t);for(let r=0;r<this.columns;r++)this.set(t,r,this.get(t,r)*e);return this}mulColumn(t,e){ae(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(){de(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(){de(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(se(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){se(this,t),de(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(se(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){se(this,t),de(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(ae(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){ae(this,t),de(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(ae(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){ae(this,t),de(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){ge.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=ye.checkMatrix(t);let e=this.rows,r=this.columns,n=t.columns,o=new ye(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=ye.checkMatrix(t);let e=new ye(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),l=(r+h)*(n+u),c=(s+h)*n,f=r*(i-u),d=h*(a-n),g=(r+o)*u,p=l+d-g+(o-h)*(a+u),y=f+g,m=c+d,w=l-c+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=ye.checkMatrix(t);let e=new ye(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),l=this.get(2,2),c=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)*(c-f+p),b=(i+s)*(-c+f),E=r*c,N=(-r+h+u)*(c-d+y),S=(-r+h)*(d-y),A=(h+u)*(-c+d),k=(-o+u+l)*(p+m-w),I=(o-l)*(p-w),D=o*m,R=(u+l)*(-m+w),_=(-o+s+a)*(y+m-v),z=(o-a)*(y-v),O=(s+a)*(-m+v),T=E+D+n*g,C=(r+n+o-i-s-u-l)*p+M+b+E+k+D+R,q=E+N+A+(r+n+o-s-a-h-u)*y+D+_+O,L=x+s*(-c+f+g-p-y-m+v)+M+E+D+_+z,P=x+M+b+E+a*w,F=D+_+z+O+i*d,j=E+N+S+u*(-c+d+g-p-y-m+w)+k+I+D,V=k+I+D+R+h*f,W=E+N+S+A+l*v;return e.set(0,0,T),e.set(0,1,C),e.set(0,2,q),e.set(1,0,L),e.set(1,1,P),e.set(1,2,F),e.set(2,0,j),e.set(2,1,V),e.set(2,2,W),e}mmulStrassen(t){t=ye.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=ge.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),l=e.subMatrix(0,i-1,a,e.columns-1),c=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(ge.add(h,g),ge.add(u,p),i,a),m=t(ge.add(f,g),u,i,a),w=t(h,ge.sub(c,p),i,a),v=t(g,ge.sub(d,u),i,a),x=t(ge.add(h,l),p,i,a),M=t(ge.sub(f,h),ge.add(u,c),i,a),b=t(ge.sub(l,g),ge.add(d,p),i,a),E=ge.add(y,v);E.sub(x),E.add(b);let N=ge.add(w,x),S=ge.add(m,v),A=ge.sub(y,m);A.add(w),A.add(M);let k=ge.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 ye(this.rows,this.columns);for(let t=0;t<this.rows;t++){const o=this.getRow(t);o.length>0&&te(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 ye(this.rows,this.columns);for(let t=0;t<this.columns;t++){const o=this.getColumn(t);o.length&&te(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=ye.checkMatrix(t);let e=this.rows,r=this.columns,n=t.rows,o=t.columns,i=new ye(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=ye.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(ye.eye(r,r)),o=ye.eye(e,e).kroneckerProduct(t);return n.add(o)}transpose(){let t=new ye(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=pe){for(let e=0;e<this.rows;e++)this.setRow(e,this.getRow(e).sort(t));return this}sortColumns(t=pe){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 ye(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 ye(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 ye(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=ye.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(!Xt(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(!Xt(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 ye(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 ye(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=ce(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=ce(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=ce(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=ce(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(!Xt(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(!Xt(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(!Xt(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(!Xt(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(!Xt(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(!Xt(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 ne(this,t)}}function pe(t,e){return t-e}ge.prototype.klass="Matrix","undefined"!=typeof Symbol&&(ge.prototype[Symbol.for("nodejs.util.inspect.custom")]=function(){return ne(this)}),ge.random=ge.rand,ge.randomInt=ge.randInt,ge.diagonal=ge.diag,ge.prototype.diagonal=ge.prototype.diag,ge.identity=ge.eye,ge.prototype.negate=ge.prototype.neg,ge.prototype.tensorProduct=ge.prototype.kroneckerProduct;class ye extends ge{constructor(t,e){if(super(),ye.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(!Xt(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 se(this,t),this.data.splice(t,1),this.rows-=1,this}addRow(t,e){return void 0===e&&(e=t,t=this.rows),se(this,t,!0),e=Float64Array.from(he(this,e)),this.data.splice(t,0,e),this.rows+=1,this}removeColumn(t){ae(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),ae(this,t,!0),e=ue(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}}(ge,ye);class me extends ge{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 we(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 ve{constructor(t,e={}){if((t=me.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),l=!1;if(r<n)if(s){a=t.transpose(),r=a.rows,n=a.columns,l=!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 c=Math.min(r,n),f=Math.min(r+1,n),d=new Float64Array(f),g=new ye(r,c),p=new ye(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]=we(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]=we(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<c;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<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(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=we(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=we(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,l=y[t]/e,c=((i+o)*(i-o)+s*s)/2,f=o*s*(o*s);let m=0;0===c&&0===f||(m=c<0?0-Math.sqrt(c*c+f):Math.sqrt(c*c+f),m=f/(c+m));let w=(a+o)*(a-o)+m,v=a*l;for(let e=t;e<b-1;e++){let o=we(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=we(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(l){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=ye.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,l=ye.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);l.set(t,e,r)}return l.mmul(e)}solveForDiagonal(t){return this.solve(ye.diag(t))}inverse(){let t=this.V,e=this.threshold,r=t.rows,n=t.columns,o=new ye(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 ye(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 ye.diag(this.s)}}var xe,Me={center:[0,0],linkDistance:50},be=function(){function t(t){void 0===t&&(t={}),this.options=t,this.id="mds",this.options=r(r({},Me),t)}return t.prototype.execute=function(t,e){return this.genericMDSLayout(!1,t,e)},t.prototype.assign=function(t,e){this.genericMDSLayout(!0,t,e)},t.prototype.genericMDSLayout=function(t,e,n){var o=r(r({},this.options),n),i=o.center,s=void 0===i?[0,0]:i,a=o.linkDistance,h=void 0===a?50:a,u=o.layoutInvisibles,l=o.onLayoutEnd,d=e.getAllNodes(),g=e.getAllEdges();if(u||(d=d.filter((function(t){var e=(t.data||{}).visible;return e||void 0===e})),g=g.filter((function(t){var e=(t.data||{}).visible;return e||void 0===e}))),!(null==d?void 0:d.length)||1===d.length)return x(e,t,s,l);var p=f({nodes:d,edges:g},!1),m=c(p);Ee(m);var w=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,h),v=Ne(w),M=[];v.forEach((function(t,e){var r=y(d[e]);r.data.x=t[0]+s[0],r.data.y=t[1]+s[1],M.push(r)})),t&&M.forEach((function(t){return e.mergeNodeData(t.id,{x:t.data.x,y:t.data.y})}));var b={nodes:M,edges:g};return null==l||l(b),b},t}(),Ee=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)}))}))},Ne=function(t){var e=ye.mul(ye.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 ve(e),s=ye.sqrt(i.diagonalMatrix).diagonal();return i.leftSingularVectors.toJSON().map((function(t){return ye.mul([t],[s]).toJSON()[0].splice(0,2)}))},Se={iterations:10,height:10,width:10,speed:100,gravity:10,k:5},Ae=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,l=s.y-e.y,c=Math.sqrt(u*u+l*l);if(0===c){c=1;var f=a>h?1:-1;u=.01*f,l=.01*f}if(c<i(t[a])/2+i(t[h])/2){var d=n*n/c;r[a].x+=u/c*d,r[a].y+=l/c*d}}}))}))},ke=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),l=Math.acos((a*e.x+h*e.y)/u);l>Math.PI/2&&(l-=Math.PI/2,a*=-1,h*=-1);var c=Math.cos(l)*u;e.x=a*c,e.y=h*c})),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 l=Math.min(h*(r/800),u);if(i.x+=e[s].x/u*l,i.y+=e[s].y/u*l,n){var c=i.x-t[o].x,f=i.y-t[o].y,d=Math.sqrt(c*c+f*f);c=c/d*a[s],f=f/d*a[s],i.x=t[o].x+c,i.y=t[o].y+f}}}})),t},Ie={maxIteration:1e3,focusNode:null,unitRadius:null,linkDistance:50,preventOverlap:!1,strictRadial:!0,maxPreventOverlapIteration:200,sortStrength:10},De=function(){function t(t){void 0===t&&(t={}),this.options=t,this.id="radial",this.options=r(r({},Ie),t)}return t.prototype.execute=function(t,e){return this.genericRadialLayout(!1,t,e)},t.prototype.assign=function(t,e){this.genericRadialLayout(!0,t,e)},t.prototype.genericRadialLayout=function(t,e,n){var s=r(r({},this.options),n),h=s.width,u=s.height,l=s.center,d=s.focusNode,g=s.unitRadius,p=s.nodeSize,m=s.nodeSpacing,w=s.strictRadial,v=s.preventOverlap,M=s.maxPreventOverlapIteration,b=s.sortBy,E=s.linkDistance,N=void 0===E?50:E,S=s.sortStrength,A=void 0===S?10:S,k=s.maxIteration,I=void 0===k?1e3:k,D=s.layoutInvisibles,R=s.onLayoutEnd,_=e.getAllNodes(),z=e.getAllEdges();D||(_=_.filter((function(t){var e=(t.data||{}).visible;return e||void 0===e})),z=z.filter((function(t){var e=(t.data||{}).visible;return e||void 0===e})));var O=h||"undefined"==typeof window?h:window.innerWidth,T=u||"undefined"==typeof window?u:window.innerHeight,C=l||[O/2,T/2];if(!(null==_?void 0:_.length)||1===_.length)return x(e,t,C,R);var q=_[0];if(a(d)){for(var L=0;L<_.length;L++)if(_[L].id===d){q=_[L];break}}else q=d||_[0];var P=ze(_,q.id),F=f({nodes:_,edges:z},!1),j=c(F),V=Te(j,P);Oe(j,P,V+1);var W=j[P],$=O-C[0]>C[0]?C[0]:O-C[0],G=T-C[1]>C[1]?C[1]:T-C[1];0===$&&($=O/2),0===G&&(G=T/2);var B=Math.min($,G),U=Math.max.apply(Math,i([],o(W),!1)),H=[],K=g||B/U;W.forEach((function(t,e){H[e]=t*K}));var J,Y=Re(_,j,N,H,K,b,A),X=_e(Y),Q=function(t,e,r){try{var n=ye.mul(ye.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 ve(n),h=ye.sqrt(a.diagonalMatrix).diagonal();return a.leftSingularVectors.toJSON().map((function(e){return ye.mul([e],[h]).toJSON()[0].splice(0,t)}))}catch(t){for(var u=[],l=0;l<e.length;l++){var c=Math.random()*r,f=Math.random()*r;u.push([c,f])}return u}}(N,Y,N),Z=Q.map((function(t){var e=o(t,2),r=e[0],n=e[1];return{x:(isNaN(r)?Math.random()*N:r)-Q[P][0],y:(isNaN(n)?Math.random()*N:n)-Q[P][1]}}));if(this.run(I,Z,X,Y,H,P),v){J=Ce(p,m);var tt={nodes:_,nodeSizeFunc:J,positions:Z,radii:H,height:T,width:O,strictRadial:Boolean(w),focusIdx:P,iterations:M||200,k:Z.length/4.5};Z=function(t,e){for(var n=r(r({},Se),e),o=n.positions,i=n.iterations,s=n.width,a=n.k,h=n.speed,u=void 0===h?100:h,l=n.strictRadial,c=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}})),Ae(p,o,y,a,d,g),ke(o,y,u,l,c,m,s,d);return o}(e,tt)}var et=[];Z.forEach((function(t,e){var r=y(_[e]);r.data.x=t.x+C[0],r.data.y=t.y+C[1],et.push(r)})),t&&et.forEach((function(t){return e.mergeNodeData(t.id,{x:t.data.x,y:t.data.y})}));var rt={nodes:et,edges:z};return null==R||R(rt),rt},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=d(a,{x:0,y:0}),l=0===u?0:1/u;if(h!==i){var c=0,f=0,g=0;e.forEach((function(t,e){if(h!==e){var r=d(a,t),i=0===r?0:1/r,s=n[e][h];g+=o[h][e],c+=o[h][e]*(t.x+s*(a.x-t.x)*i),f+=o[h][e]*(t.y+s*(a.y-t.y)*i)}}));var p=0===r[h]?0:1/r[h];g*=s,g+=t*p*p,c*=s,c+=t*p*a.x*l,a.x=c/g,f*=s,f+=t*p*a.y*l,a.y=f/g}}))},t}(),Re=function(t,e,r,n,o,i,s){if(!t)return[];var h=[];if(e){var u={};e.forEach((function(e,l){var c=[];e.forEach((function(e,h){var f,d;if(l===h)c.push(0);else if(n[l]===n[h])if("data"===i)c.push(e*(Math.abs(l-h)*s)/(n[l]/o));else if(i){var g=void 0,p=void 0;if(u[t[l].id])g=u[t[l].id];else{var y=("id"===i?t[l].id:null===(f=t[l].data)||void 0===f?void 0:f[i])||0;g=a(y)?y.charCodeAt(0):y,u[t[l].id]=g}u[t[h].id]?p=u[t[h].id]:(y=("id"===i?t[h].id:null===(d=t[h].data)||void 0===d?void 0:d[i])||0,p=a(y)?y.charCodeAt(0):y,u[t[h].id]=p),c.push(e*(Math.abs(g-p)*s)/(n[l]/o))}else c.push(e*r/(n[l]/o));else{var m=(r+o)/2;c.push(e*m)}})),h.push(c)}))}return h},_e=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},ze=function(t,e){var r=-1;return t.forEach((function(t,n){t.id===e&&(r=n)})),Math.max(r,0)},Oe=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}},Te=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},Ce=function(t,e){var r;return r=l(e)?function(){return e}:m(e)?e:function(){return 0},t?u(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;return(null===(e=t.data)||void 0===e?void 0:e.bboxSize)?Math.max(t.data.bboxSize[0],t.data.bboxSize[1])+r(t):(null===(n=t.data)||void 0===n?void 0:n.size)?u(t.data.size)?Math.max(t.data.size[0],t.data.size[1])+r(t):g(t.data.size)?(t.data.size.width>t.data.size.height?t.data.size.width:t.data.size.height)+r(t):t.data.size+r(t):10+r(t)}},qe={center:[0,0],width:300,height:300},Le={circular:b,concentric:A,mds:be,random:function(){function t(t){void 0===t&&(t={}),this.options=t,this.id="random",this.options=r(r({},qe),t)}return t.prototype.execute=function(t,e){return this.genericRandomLayout(!1,t,e)},t.prototype.assign=function(t,e){this.genericRandomLayout(!0,t,e)},t.prototype.genericRandomLayout=function(t,e,n){var o=r(r({},this.options),n),i=o.center,s=o.width,a=o.height,h=o.layoutInvisibles,u=o.onLayoutEnd,l=e.getAllNodes();h||(l=l.filter((function(t){var e=(t.data||{}).visible;return e||void 0===e})));var c=s||"undefined"==typeof window?s:window.innerWidth,f=a||"undefined"==typeof window?a:window.innerHeight,d=i||[c/2,f/2],g=[];l&&l.forEach((function(t){g.push({id:t.id,data:{x:.9*(Math.random()-.5)*c+d[0],y:.9*(Math.random()-.5)*f+d[1]}})})),t&&g.forEach((function(t){return e.mergeNodeData(t.id,{x:t.data.x,y:t.data.y})}));var p={nodes:g,edges:e.getAllEdges()};return null==u||u(p),p},t}(),grid:$t,radial:De,force:It,d3force:Et,fruchterman:Vt,forceAtlas2:Ft};function Pe(){(null==xe?void 0:xe.stop)&&xe.stop()}function Fe(t,e){return r=this,n=void 0,i=function(){var r,n,o,i,a,h,u,l;return function(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])}}}(this,(function(c){if(r=t.layout,n=r.id,o=r.options,i=r.iterations,a=t.nodes,h=t.edges,u=new s({nodes:a,edges:h}),!(l=Le[n]))throw new Error("Unknown layout id: ".concat(n));return xe=new l(o),[2,new Promise((function(t){var r;xe.assign(u,{onLayoutEnd:function(r){t([r,e])}}),(r=xe).tick&&r.stop&&r.restart&&(xe.stop(),xe.tick(i))}))]}))},new((o=void 0)||(o=Promise))((function(t,e){function s(t){try{h(i.next(t))}catch(t){e(t)}}function a(t){try{h(i.throw(t))}catch(t){e(t)}}function h(e){var r;e.done?t(e.value):(r=e.value,r instanceof o?r:new o((function(t){t(r)}))).then(s,a)}h((i=i.apply(r,n||[])).next())}));var r,n,o,i}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=d869b88cfe3353e7436d.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:()=>b,W1:()=>T,jA:()=>Dt,E9:()=>$t,y7:()=>Ct,O2:()=>Kt,Me:()=>Xt,AI:()=>Ie,D4:()=>Ce,_5:()=>Ge,y9:()=>_,Xp:()=>D,qR:()=>Ue,i_:()=>Be});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){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 s(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 a=function(t){return"string"==typeof t},h=/-(\w)/g,u=(function(t){return t.replace(h,(function(t,e){return e?e.toUpperCase():""}))},Object.create(null),Array.isArray),l=function(t){return"number"==typeof t},c=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},f=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},d=function(t,e){return Math.sqrt((t.x-e.x)*(t.x-e.x)+(t.y-e.y)*(t.y-e.y))},g=function(t){return null!==t&&"object"==typeof t},p=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 p(t)}))}if("object"==typeof t){var r={};return Object.keys(t).forEach((function(e){r[e]=p(t[e])})),r}return t},y=function(t,e){var r=p(t);return r.data=r.data||{},e&&(l(r.data.x)||(r.data.x=Math.random()*e[0]),l(r.data.y)||(r.data.y=Math.random()*e[1])),r},m=function(t){return"function"==typeof t};function w(t,e){return m(e)?e:l(e)?function(){return e}:function(){return t}}function v(t,e,r){return void 0===r&&(r=!0),e||0===e?m(e)?e:l(e)?function(){return e}:u(e)?function(){if(r){var n=Math.max.apply(Math,s([],i(e),!1));return isNaN(n)?t:n}return e}:g(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?u(r)?r[0]>r[1]?r[0]:r[1]:g(r)?r.width>r.height?r.width:r.height:r:t}}var x=function(t,r,n,o){var i=t.getAllNodes(),s=t.getAllEdges();if(!(null==i?void 0:i.length)){var a={nodes:[],edges:s};return null==o||o(a),a}if(1===i.length)return r&&t.mergeNodeData(i[0].id,{x:n[0],y:n[1]}),a={nodes:[e(e({},i[0]),{data:e(e({},i[0].data),{x:n[0],y:n[1]})})],edges:s},null==o||o(a),a},M={radius:null,startRadius:null,endRadius:null,startAngle:0,endAngle:2*Math.PI,clockwise:!0,divisions:1,ordering:null,angleRatio:1},b=function(){function t(t){void 0===t&&(t={}),this.options=t,this.id="circular",this.options=e(e({},M),t)}return t.prototype.execute=function(t,e){return this.genericCircularLayout(!1,t,e)},t.prototype.assign=function(t,e){this.genericCircularLayout(!0,t,e)},t.prototype.genericCircularLayout=function(t,r,n){var o=e(e({},this.options),n),s=o.width,a=o.height,h=o.center,u=o.divisions,l=o.startAngle,c=void 0===l?0:l,f=o.endAngle,d=void 0===f?2*Math.PI:f,g=o.angleRatio,p=o.ordering,m=o.clockwise,M=o.nodeSpacing,b=o.nodeSize,S=o.layoutInvisibles,k=o.onLayoutEnd,A=r.getAllNodes(),I=r.getAllEdges();S||(A=A.filter((function(t){var e=(t.data||{}).visible;return e||void 0===e})),I=I.filter((function(t){var e=(t.data||{}).visible;return e||void 0===e})));var D=i(N(s,a,h),3),_=D[0],R=D[1],T=D[2],O=null==A?void 0:A.length;if(!O||1===O)return x(r,t,T,k);var z=(d-c)/O,C=o.radius,q=o.startRadius,L=o.endRadius;if(M){var P=w(10,M),F=v(10,b),j=-1/0;A.forEach((function(t){var e=F(t);j<e&&(j=e)}));var V=0;A.forEach((function(t,e){V+=0===e?j||10:(P(t)||0)+(j||10)})),C=V/(2*Math.PI)}else C||q||L?!q&&L?q=L:q&&!L&&(L=q):C=Math.min(R,_)/2;var W=z*g,G=[];G="topology"===p?E(r,A):"topology-directed"===p?E(r,A,!0):"degree"===p?function(t,e){var r=[];return e.forEach((function(t,e){r.push(y(t))})),r.sort((function(e,r){return t.getDegree(e.id,"both")-t.getDegree(r.id,"both")})),r}(r,A):A.map((function(t){return y(t)}));for(var B=Math.ceil(O/u),U=0;U<O;++U){var $=C;$||null===q||null===L||($=q+U*(L-q)/(O-1)),$||($=10+100*U/(O-1));var H=c+U%B*W+2*Math.PI/u*Math.floor(U/B);m||(H=d-U%B*W-2*Math.PI/u*Math.floor(U/B)),G[U].data.x=T[0]+Math.cos(H)*$,G[U].data.y=T[1]+Math.sin(H)*$}t&&G.forEach((function(t){r.mergeNodeData(t.id,{x:t.data.x,y:t.data.y})}));var K={nodes:G,edges:I};return null==k||k(K),K},t}(),E=function(t,e,r){void 0===r&&(r=!1);var n=[y(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),l=!1,c=0;c<u.length;c++){var f=u[c];if(t.getDegree(f.id)===t.getDegree(a.id)&&!o[f.id]){n.push(y(f)),o[f.id]=!0,l=!0;break}}for(var d=0;!l&&(o[e[d].id]||(n.push(y(e[d])),o[e[d].id]=!0,l=!0),++d!==i););}else n.push(y(a)),o[a.id]=!0,s++})),n},N=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]},S=r(161),k=r.n(S),A=r(825),I=r.n(A),D={LAYOUT_ITERATION:"tick",LAYOUT_END:"layoutend"},_=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=I()(),this.running&&(this.running=!1,this.start())},r.prototype.start=function(){var t,e=this;if(this.running)return this;this.running=!0;var r=this.layout.options,n=(r.onLayoutEnd,r.onTick,o(r,["onLayoutEnd","onTick"])),s={layout:{id:this.layout.id,options:n,iterations:null===(t=this.options)||void 0===t?void 0:t.iterations},nodes:this.graph.getAllNodes(),edges:this.graph.getAllEdges()},a=new Float32Array([0]);return this.worker.calculateLayout(s,[a]).then((function(t){var r=i(t,2),n=r[0];r[1],e.emit(D.LAYOUT_END,n),e.layout.options.onLayoutEnd&&e.layout.options.onLayoutEnd(n)})),this},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}(k()),R={nodeSize:30,nodeSpacing:10,preventOverlap:!1,sweep:void 0,equidistant:!1,startAngle:1.5*Math.PI,clockwise:!0,maxLevelDiff:void 0,sortBy:"degree"},T=function(){function t(t){void 0===t&&(t={}),this.options=t,this.id="concentric",this.options=e(e({},R),t)}return t.prototype.execute=function(t,e){return this.genericConcentricLayout(!1,t,e)},t.prototype.assign=function(t,e){this.genericConcentricLayout(!0,t,e)},t.prototype.genericConcentricLayout=function(t,r,n){var o=e(e({},this.options),n),i=o.center,s=o.width,h=o.height,c=o.sortBy,f=o.maxLevelDiff,d=o.sweep,p=o.clockwise,w=o.equidistant,v=o.preventOverlap,M=o.startAngle,b=void 0===M?1.5*Math.PI:M,E=o.nodeSize,N=o.nodeSpacing,S=o.layoutInvisibles,k=o.onLayoutEnd,A=r.getAllNodes(),I=r.getAllEdges();S||(A=A.filter((function(t){var e=(t.data||{}).visible;return e||void 0===e})),I=I.filter((function(t){var e=(t.data||{}).visible;return e||void 0===e})));var D=s||"undefined"==typeof window?s:window.innerWidth,_=h||"undefined"==typeof window?h:window.innerHeight,R=i||[D/2,_/2];if(!(null==A?void 0:A.length)||1===A.length)return x(r,t,R,k);var T,O=[],z=0;T=u(E)?Math.max(E[0],E[1]):E,u(N)?z=Math.max(N[0],N[1]):l(N)&&(z=N),A.forEach((function(t){var e=y(t);O.push(e);var r=T,n=e.data;u(n.size)?r=Math.max(n.size[0],n.size[1]):l(n.size)?r=n.size:g(n.size)&&(r=Math.max(n.size.width,n.size.height)),T=Math.max(T,r),m(N)&&(z=Math.max(N(t),z))}));var C={};O.forEach((function(t,e){C[t.id]=e}));var q=c;a(q)&&void 0!==O[0].data[q]||(q="degree"),"degree"===q?O.sort((function(t,e){return r.getDegree(e.id,"both")-r.getDegree(t.id,"both")})):O.sort((function(t,e){return e.data[q]-t.data[q]}));var L=O[0],P=(f||("degree"===q?r.getDegree(L.id,"both"):L.data[q]))/4,F=[{nodes:[]}],j=F[0];O.forEach((function(t){if(j.nodes.length>0){var e="degree"===q?Math.abs(r.getDegree(j.nodes[0].id,"both")-r.getDegree(t.id,"both")):Math.abs(j.nodes[0].data[q]-t.data[q]);P&&e>=P&&(j={nodes:[]},F.push(j))}j.nodes.push(t)}));var V=T+z;if(!v){var W=F.length>0&&F[0].nodes.length>1,G=(Math.min(D,_)/2-V)/(F.length+(W?1:0));V=Math.min(V,G)}var B=0;if(F.forEach((function(t){var e=void 0===d?2*Math.PI-2*Math.PI/t.nodes.length:d;if(t.dTheta=e/Math.max(1,t.nodes.length-1),t.nodes.length>1&&v){var r=Math.cos(t.dTheta)-Math.cos(0),n=Math.sin(t.dTheta)-Math.sin(0),o=Math.sqrt(V*V/(r*r+n*n));B=Math.max(o,B)}t.r=B,B+=V})),w){for(var U=0,$=0,H=0;H<F.length;H++){var K=(F[H].r||0)-$;U=Math.max(U,K)}$=0,F.forEach((function(t,e){0===e&&($=t.r||0),t.r=$,$+=U}))}F.forEach((function(t){var e=t.dTheta||0,r=t.r||0;t.nodes.forEach((function(t,n){var o=b+(p?1:-1)*e*n;t.data.x=R[0]+r*Math.cos(o),t.data.y=R[1]+r*Math.sin(o)}))})),t&&O.forEach((function(t){return r.mergeNodeData(t.id,{x:t.data.x,y:t.data.y})}));var J={nodes:O,edges:I};return null==k||k(J),J},t}();function O(t,e,r,n){if(isNaN(e)||isNaN(r))return t;var o,i,s,a,h,u,l,c,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,(l=r>=(s=(y+w)/2))?y=s:w=s,o=d,!(d=d[c=l<<1|u]))return o[c]=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[c]=g:t._root=g,t;do{o=o?o[c]=new Array(4):t._root=new Array(4),(u=e>=(i=(p+m)/2))?p=i:m=i,(l=r>=(s=(y+w)/2))?y=s:w=s}while((c=l<<1|u)==(f=(h>=s)<<1|a>=i));return o[f]=d,o[c]=g,t}function z(t,e,r,n,o){this.node=t,this.x0=e,this.y0=r,this.x1=n,this.y1=o}function C(t){return t[0]}function q(t){return t[1]}function L(t,e,r){var n=new P(null==e?C:e,null==r?q:r,NaN,NaN,NaN,NaN);return null==t?n:n.addAll(t)}function P(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 F(t){for(var e={data:t.data},r=e;t=t.next;)r=r.next={data:t.data};return e}var j=L.prototype=P.prototype;function V(t){return function(){return t}}function W(t){return 1e-6*(t()-.5)}j.copy=function(){var t,e,r=new P(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=F(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]=F(e));return r},j.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)},j.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,l=-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))||(s[r]=n,a[r]=o,n<h&&(h=n),n>l&&(l=n),o<u&&(u=o),o>c&&(c=o));if(h>l||u>c)return this;for(this.cover(h,u).cover(l,c),r=0;r<i;++r)O(this,s[r],a[r],t[r]);return this},j.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},j.data=function(){var t=[];return this.visit((function(e){if(!e.length)do{t.push(e.data)}while(e=e.next)})),t},j.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]]},j.find=function(t,e,r){var n,o,i,s,a,h,u,l=this._x0,c=this._y0,f=this._x1,d=this._y1,g=[],p=this._root;for(p&&g.push(new z(p,l,c,f,d)),null==r?r=1/0:(l=t-r,c=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)<l||(a=h.y1)<c))if(p.length){var y=(o+s)/2,m=(i+a)/2;g.push(new z(p[3],y,m,s,a),new z(p[2],o,m,y,a),new z(p[1],y,i,s,m),new z(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);l=t-M,c=e-M,f=t+M,d=e+M,n=p.data}}return n},j.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,l,c,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,(l=s>=(h=(p+m)/2))?p=h:m=h,e=d,!(d=d[c=l<<1|u]))return this;if(!d.length)break;(e[c+1&3]||e[c+2&3]||e[c+3&3])&&(r=e,f=c)}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[c]=o:delete e[c],(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)},j.removeAll=function(t){for(var e=0,r=t.length;e<r;++e)this.remove(t[e]);return this},j.root=function(){return this._root},j.size=function(){var t=0;return this.visit((function(e){if(!e.length)do{++t}while(e=e.next)})),t},j.visit=function(t){var e,r,n,o,i,s,a=[],h=this._root;for(h&&a.push(new z(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,l=(o+s)/2;(r=h[3])&&a.push(new z(r,u,l,i,s)),(r=h[2])&&a.push(new z(r,n,l,u,s)),(r=h[1])&&a.push(new z(r,u,o,i,l)),(r=h[0])&&a.push(new z(r,n,o,u,l))}return this},j.visitAfter=function(t){var e,r=[],n=[];for(this._root&&r.push(new z(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,l=(s+h)/2,c=(a+u)/2;(i=o[0])&&r.push(new z(i,s,a,l,c)),(i=o[1])&&r.push(new z(i,l,a,h,c)),(i=o[2])&&r.push(new z(i,s,c,l,u)),(i=o[3])&&r.push(new z(i,l,c,h,u))}n.push(e)}for(;e=n.pop();)t(e.node,e.x0,e.y0,e.x1,e.y1);return this},j.x=function(t){return arguments.length?(this._x=t,this):this._x},j.y=function(t){return arguments.length?(this._y=t,this):this._y};var G={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 U(n)}function U(t){this._=t}function $(t,e){return t.trim().split(/^|\s+/).map((function(t){var r="",n=t.indexOf(".");if(n>=0&&(r=t.slice(n+1),t=t.slice(0,n)),t&&!e.hasOwnProperty(t))throw new Error("unknown type: "+t);return{type:t,name:r}}))}function H(t,e){for(var r,n=0,o=t.length;n<o;++n)if((r=t[n]).name===e)return r.value}function K(t,e,r){for(var n=0,o=t.length;n<o;++n)if(t[n].name===e){t[n]=G,t=t.slice(0,n).concat(t.slice(n+1));break}return null!=r&&t.push({name:e,value:r}),t}U.prototype=B.prototype={constructor:U,on:function(t,e){var r,n=this._,o=$(t+"",n),i=-1,s=o.length;if(!(arguments.length<2)){if(null!=e&&"function"!=typeof e)throw new Error("invalid callback: "+e);for(;++i<s;)if(r=(t=o[i]).type)n[r]=K(n[r],t.name,e);else if(null==e)for(r in n)n[r]=K(n[r],t.name,null);return this}for(;++i<s;)if((r=(t=o[i]).type)&&(r=H(n[r],t.name)))return r},copy:function(){var t={},e=this._;for(var r in e)t[r]=e[r].slice();return new U(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 J=B;var X,Y,Q=0,Z=0,tt=0,et=0,rt=0,nt=0,ot="object"==typeof performance&&performance.now?performance:Date,it="object"==typeof window&&window.requestAnimationFrame?window.requestAnimationFrame.bind(window):function(t){setTimeout(t,17)};function st(){return rt||(it(at),rt=ot.now()+nt)}function at(){rt=0}function ht(){this._call=this._time=this._next=null}function ut(t,e,r){var n=new ht;return n.restart(t,e,r),n}function lt(){rt=(et=ot.now())+nt,Q=Z=0;try{!function(){st(),++Q;for(var t,e=X;e;)(t=rt-e._time)>=0&&e._call.call(void 0,t),e=e._next;--Q}()}finally{Q=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);Y=t,ft(n)}(),rt=0}}function ct(){var t=ot.now(),e=t-et;e>1e3&&(nt-=e,et=t)}function ft(t){Q||(Z&&(Z=clearTimeout(Z)),t-rt>24?(t<1/0&&(Z=setTimeout(lt,t-ot.now()-nt)),tt&&(tt=clearInterval(tt))):(tt||(et=ot.now(),tt=setInterval(ct,1e3)),Q=1,it(lt)))}ht.prototype=ut.prototype={constructor:ht,restart:function(t,e,r){if("function"!=typeof t)throw new TypeError("callback is not a function");r=(null==r?st():+r)+(null==e?0:+e),this._next||Y===this||(Y?Y._next=this:X=this,Y=this),this._call=t,this._time=r,ft()},stop:function(){this._call&&(this._call=null,this._time=1/0,ft())}};const dt=4294967296;function gt(t){return t.x}function pt(t){return t.y}var yt=Math.PI*(3-Math.sqrt(5));function mt(t){var e,r=1,n=.001,o=1-Math.pow(n,1/300),i=0,s=.6,a=new Map,h=ut(c),u=J("tick","end"),l=function(){let t=1;return()=>(t=(1664525*t+1013904223)%dt)/dt}();function c(){f(),u.call("tick",e),r<n&&(h.stop(),u.call("end",e))}function f(n){var h,u,l=t.length;void 0===n&&(n=1);for(var c=0;c<n;++c)for(r+=(i-r)*o,a.forEach((function(t){t(r)})),h=0;h<l;++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=10*Math.sqrt(.5+r),i=r*yt;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,l),e}return null==t&&(t=[]),d(),e={tick:f,restart:function(){return h.restart(c),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?(l=t,a.forEach(g),e):l},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,l=t.length;for(null==n?n=1/0:n*=n,u=0;u<l;++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 wt(){var t,e,r,n,o,i=V(-30),s=1,a=1/0,h=.81;function u(r){var o,i=t.length,s=L(t,gt,pt).visitAfter(c);for(n=r,o=0;o<i;++o)e=t[o],s.visit(f)}function l(){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,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,l){if(!t.value)return!0;var c=t.x-e.x,f=t.y-e.y,d=l-i,g=c*c+f*f;if(d*d/h<g)return g<a&&(0===c&&(g+=(c=W(r))*c),0===f&&(g+=(f=W(r))*f),g<s&&(g=Math.sqrt(s*g)),e.vx+=c*t.value*n/g,e.vy+=f*t.value*n/g),!0;if(!(t.length||g>=a)){(t.data!==e||t.next)&&(0===c&&(g+=(c=W(r))*c),0===f&&(g+=(f=W(r))*f),g<s&&(g=Math.sqrt(s*g)));do{t.data!==e&&(d=o[t.data.index]*n/g,e.vx+=c*d,e.vy+=f*d)}while(t=t.next)}}return u.initialize=function(e,n){t=e,r=n,l()},u.strength=function(t){return arguments.length?(i="function"==typeof t?t:V(+t),l(),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 vt(t){return t.index}function xt(t,e){var r=t.get(e);if(!r)throw new Error("node not found: "+e);return r}function Mt(t){var e,r,n,o,i,s,a=vt,h=function(t){return 1/Math.min(o[t.source.index],o[t.target.index])},u=V(30),l=1;function c(n){for(var o=0,a=t.length;o<l;++o)for(var h,u,c,f,d,g,p,y=0;y<a;++y)u=(h=t[y]).source,f=(c=h.target).x+c.vx-u.x-u.vx||W(s),d=c.y+c.vy-u.y-u.vy||W(s),f*=g=((g=Math.sqrt(f*f+d*d))-r[y])/g*n*e[y],d*=g,c.vx-=f*(p=i[y]),c.vy-=d*p,u.vx+=f*(p=1-p),u.vy+=d*p}function f(){if(n){var s,h,u=n.length,l=t.length,c=new Map(n.map(((t,e)=>[a(t,e,n),t])));for(s=0,o=new Array(u);s<l;++s)(h=t[s]).index=s,"object"!=typeof h.source&&(h.source=xt(c,h.source)),"object"!=typeof h.target&&(h.target=xt(c,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(l);s<l;++s)h=t[s],i[s]=o[h.source.index]/(o[h.source.index]+o[h.target.index]);e=new Array(l),d(),r=new Array(l),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=[]),c.initialize=function(t,e){n=t,s=e,f()},c.links=function(e){return arguments.length?(t=e,f(),c):t},c.id=function(t){return arguments.length?(a=t,c):a},c.iterations=function(t){return arguments.length?(l=+t,c):l},c.strength=function(t){return arguments.length?(h="function"==typeof t?t:V(+t),d(),c):h},c.distance=function(t){return arguments.length?(u="function"==typeof t?t:V(+t),g(),c):u},c}function bt(t){return t.x+t.vx}function Et(t){return t.y+t.vy}function Nt(t){var e,r,n,o=1,i=1;function s(){for(var t,s,h,u,l,c,f,d=e.length,g=0;g<i;++g)for(s=L(e,bt,Et).visitAfter(a),t=0;t<d;++t)h=e[t],c=r[h.index],f=c*c,u=h.x+h.vx,l=h.y+h.vy,s.visit(p);function p(t,e,r,i,s){var a=t.data,d=t.r,g=c+d;if(!a)return e>u+g||i<u-g||r>l+g||s<l-g;if(a.index>h.index){var p=u-a.x-a.vx,y=l-a.y-a.vy,m=p*p+y*y;m<g*g&&(0===p&&(m+=(p=W(n))*p),0===y&&(m+=(y=W(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=V(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:V(+e),h(),s):t},s}function St(t){var e,r,n,o=V(.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=V(null==t?0:+t)),i.initialize=function(t){e=t,s()},i.strength=function(t){return arguments.length?(o="function"==typeof t?t:V(+t),s(),i):o},i.x=function(e){return arguments.length?(t="function"==typeof e?e:V(+e),s(),i):t},i}function kt(t){var e,r,n,o=V(.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=V(null==t?0:+t)),i.initialize=function(t){e=t,s()},i.strength=function(t){return arguments.length?(o="function"==typeof t?t:V(+t),s(),i):o},i.y=function(e){return arguments.length?(t="function"==typeof e?e:V(+e),s(),i):t},i}function At(){function t(t){return function(){return t}}var e,r=function(t){return t.cluster},n=t(1),o=t(-1),s=t(100),a=t(.1),h=[0,0],u=[],l={},c=[],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(l[o]))<=(a=r(l[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=i(t,2),r=e[0],o=e[1],s=r.split("~")[0],a=r.split("~")[1];void 0!==s&&void 0!==a&&n.push({source:s,target:a,count:o})})),n}(c),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=mt(w.nodes).force("x",St(f).strength(.1)).force("y",kt(d).strength(.1)).force("collide",Nt((function(t){return t.r})).iterations(4)).force("charge",wt().strength(o)).force("links",Mt(w.nodes.length?w.links:[]).distance(s).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}function b(t){l={},t.forEach((function(t){l[t.id]=t}))}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?(b(t||[]),u=t||[],v):u},v.links=function(t){return arguments.length?(c=t||[],x(),v):c},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?(s="function"==typeof e?e:t(+e),x(),v):s},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 It={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},Dt=function(){function t(t){void 0===t&&(t={}),this.options=t,this.id="d3force",this.running=!1,this.options=e(e({},It),t)}return t.prototype.execute=function(t,e){return this.genericForceLayout(!1,t,e)},t.prototype.assign=function(t,e){this.genericForceLayout(!0,t,e)},t.prototype.stop=function(){var t;null===(t=this.forceSimulation)||void 0===t||t.stop(),this.running=!1},t.prototype.restart=function(){var t;null===(t=this.forceSimulation)||void 0===t||t.restart(),this.running=!0},t.prototype.tick=function(t){var e=this;void 0===t&&(t=1),this.forceSimulation.tick(t);var r={nodes:_t(this.lastLayoutNodes),edges:Rt(this.lastLayoutEdges)};return this.lastAssign&&r.nodes.forEach((function(t){return e.lastGraph.mergeNodeData(t.id,{x:t.data.x,y:t.data.y})})),this.lastOptions.onLayoutEnd&&this.lastOptions.onLayoutEnd(r),r},t.prototype.genericForceLayout=function(t,r,n){var o=this,i=e(e({},this.options),n),s=i.layoutInvisibles,a=r.getAllNodes(),h=r.getAllEdges();s||(a=a.filter((function(t){var e=(t.data||{}).visible;return e||void 0===e})),h=h.filter((function(t){var e=(t.data||{}).visible;return e||void 0===e})));var u=a.map((function(t){var r,n;return e(e({},y(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})})),l=h.map((function(t){return y(t)}));if(this.lastLayoutNodes=u,this.lastLayoutEdges=l,this.lastAssign=t,this.lastGraph=r,this.lastOptions=i,!this.running){var c=i.alphaMin,f=i.alphaDecay,d=i.alpha,g=i.nodeStrength,p=i.edgeStrength,m=i.linkDistance,w=i.clustering,v=i.clusterFociStrength,x=i.clusterEdgeDistance,M=i.clusterEdgeStrength,b=i.clusterNodeStrength,E=i.clusterNodeSize,N=i.collideStrength,S=void 0===N?1:N,k=i.center,A=void 0===k?[0,0]:k,I=i.preventOverlap,D=i.nodeSize,_=i.nodeSpacing,R=i.onTick,T=i.onLayoutEnd,O=i.forceSimulation;if(O)w&&((z=At()).nodes(u),z.links(l)),O.nodes(u),l&&(q=Mt().id((function(t){return t.id})).links(l),p&&q.strength(p),m&&q.distance(m),O.force("link",q)),I&&this.overlapProcess(O,{nodeSize:D,nodeSpacing:_,collideStrength:S}),O.alpha(d).restart(),this.running=!0;else try{var z,C=wt();if(g&&C.strength(g),O=mt().nodes(u),w&&((z=At()).centerX(A[0]).centerY(A[1]).template("force").strength(v),l&&z.links(l),u&&z.nodes(u),z.forceLinkDistance(x).forceLinkStrength(M).forceCharge(b).forceNodeSize(E),O.force("group",z)),O.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",C).alpha(d).alphaDecay(f).alphaMin(c),I&&this.overlapProcess(O,{nodeSize:D,nodeSpacing:_,collideStrength:S}),l){var q=Mt().id((function(t){return t.id})).links(l);p&&q.strength(p),m&&q.distance(m),O.force("link",q)}O.on("tick",(function(){var e=_t(u);null==R||R({nodes:e,edges:Rt(l)}),t&&e.forEach((function(t){return r.mergeNodeData(t.id,{x:t.data.x,y:t.data.y})}))})).on("end",(function(){o.running=!1;var e=_t(u);null==T||T({nodes:e,edges:Rt(l)}),t&&e.forEach((function(t){return r.mergeNodeData(t.id,{x:t.data.x,y:t.data.y})}))})),this.running=!0}catch(t){this.running=!1,console.warn(t)}this.forceSimulation=O;var L=_t(u),P=Rt(l);return t&&L.forEach((function(t){return r.mergeNodeData(t.id,{x:t.data.x,y:t.data.y})})),{nodes:L,edges:P}}},t.prototype.overlapProcess=function(t,e){var r,n,o=e.nodeSize,i=e.nodeSpacing,s=e.collideStrength;if(n=l(i)?function(){return i}:m(i)?i:function(){return 0},o)if(m(o))r=function(t){return o(t)+n(t)};else if(u(o)){var a=(o[0]>o[1]?o[0]:o[1])/2;r=function(t){return a+n(t)}}else if(l(o)){var h=o/2;r=function(t){return h+n(t)}}else r=function(){return 10};else r=function(t){return t.size?u(t.size)?(t.size[0]>t.size[1]?t.size[0]:t.size[1])/2+n(t):g(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",Nt(r).strength(s))},t}(),_t=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})})}))},Rt=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})}))};class Tt{nodeMap=new Map;edgeMap=new Map;inEdgesMap=new Map;outEdgesMap=new Map;treeIndices=new Map;changes=[];batchCount=0;onChanged=()=>{};constructor(t){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=[],this.onChanged({graph:this,changes:t})}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){if(!this.hasNode(t))throw new Error("Node not found for id: "+t)}hasNode(t){return this.nodeMap.has(t)}areNeighbors(t,e){return this.checkNodeExistence(t),this.getNeighbors(e).some((e=>e.id===t))}getNode(t){return this.checkNodeExistence(t),this.nodeMap.get(t)}getRelatedEdges(t,e){this.checkNodeExistence(t);const r=this.inEdgesMap.get(t),n=this.outEdgesMap.get(t);if("in"===e)return Array.from(r);if("out"===e)return Array.from(n);const o=new Set([...r,...n]);return Array.from(o)}getDegree(t,e){return this.getRelatedEdges(t,e).length}getSuccessors(t){const e=this.getRelatedEdges(t,"out").map((t=>t.target));return Array.from(new Set(e)).map((t=>this.getNode(t)))}getPredecessors(t){const e=this.getRelatedEdges(t,"in").map((t=>t.source));return Array.from(new Set(e)).map((t=>this.getNode(t)))}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.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),r=this.inEdgesMap.get(t),n=this.outEdgesMap.get(t);r?.forEach((t=>this.doRemoveEdge(t.id))),n?.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);e.add(t),r.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);r.delete(e),n.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.outEdgesMap.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.inEdgesMap.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.treeIndices.has(t))throw new Error("Tree structure not found for treeKey: "+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}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})}))}getAllNodes(){return Array.from(this.nodeMap.values())}getAllEdges(){return Array.from(this.edgeMap.values())}doBFS(t,e,r){for(;t.length;){const n=t.shift();r(n),e.add(n.id),this.getSuccessors(n.id).forEach((r=>{e.has(r.id)||(e.add(r.id),t.push(r))}))}}bfs(t,e){this.doBFS([this.getNode(t)],new Set,e)}doDFS(t,e,r){r(t),e.add(t.id),this.getSuccessors(t.id).forEach((t=>{e.has(t.id)||this.doDFS(t,e,r)}))}dfs(t,e){this.doDFS(this.getNode(t),new Set,e)}clone(){const t=this.getAllNodes().map((t=>({...t,data:{...t.data}}))),e=this.getAllEdges().map((t=>({...t,data:{...t.data}}))),r=new Tt({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 Ot(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 zt={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"},Ct=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({},zt),t)}return t.prototype.execute=function(t,e){return this.genericForceLayout(!1,t,e)},t.prototype.assign=function(t,e){this.genericForceLayout(!0,t,e)},t.prototype.stop=function(){this.timeInterval&&"undefined"!=typeof window&&window.clearInterval(this.timeInterval),this.running=!1},t.prototype.restart=function(){this.running=!0},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})})),this.lastOptions.onLayoutEnd&&this.lastOptions.onLayoutEnd(n),n},t.prototype.genericForceLayout=function(t,r,n){var o=this,i=e(e({},this.options),n),s=r.getAllNodes(),a=r.getAllEdges();i.layoutInvisibles||(s=s.filter((function(t){return t.data.visible||void 0===t.data.visible})),a=a.filter((function(t){return t.data.visible||void 0===t.data.visible})));var h=this.formatOptions(i,r),u=h.width,c=h.height,f=h.nodeSize,d=h.getMass,g=h.nodeStrength,p=h.edgeStrength,y=h.linkDistance,m=s.map((function(t){return e(e({},t),{data:e(e({},t.data),{x:l(t.data.x)?t.data.x:Math.random()*u,y:l(t.data.y)?t.data.y:Math.random()*c,size:f(t)||30,mass:d(t),nodeStrength:g(t)})})})),w=a.map((function(t){return e(e({},t),{data:e(e({},t.data),{edgeStrength:p(t),linkDistance:y(t,r.getNode(t.source),r.getNode(t.target))})})}));if(!(null==s?void 0:s.length))return this.lastResult={nodes:[],edges:a},{nodes:[],edges:a};var v={};s.forEach((function(t,e){v[t.id]={x:0,y:0}}));var x=new Tt({nodes:m,edges:w});this.formatCentripetal(h,x);var M=h.maxIteration,b=h.minMovement,E=h.onLayoutEnd,N=h.onTick;if(this.lastLayoutNodes=m,this.lastLayoutEdges=w,this.lastAssign=t,this.lastGraph=r,this.lastCalcGraph=x,this.lastOptions=h,this.lastVelMap=v,"undefined"!=typeof window){var S=0;return this.timeInterval=window.setInterval((function(){s&&o.running&&(o.runOneStep(x,r,S,v,h),o.updatePosition(r,x,v,h),t&&m.forEach((function(t){return r.mergeNodeData(t.id,{x:t.data.x,y:t.data.y})})),null==N||N({nodes:jt(r,m),edges:a}),(++S>=M||o.judgingDistance<b)&&(null==E||E({nodes:jt(r,m),edges:a}),window.clearInterval(o.timeInterval)))}),0),this.running=!0,{nodes:jt(r,m),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;l(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=w(0,t.nodeSpacing);t.nodeSize?u(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?u(e)?Math.max(e[0],e[1])+s(t):g(e)?Math.max(e.width,e.height)+s(t):e+s(t):10+s(t)}}return r.linkDistance=t.linkDistance?w(1,t.linkDistance):function(t){return 1+r.nodeSize(e.getNode(t.source))+r.nodeSize(e.getNode(t.target))},r.nodeStrength=w(1,t.nodeStrength),r.edgeStrength=w(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(),l=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(s&&h&&(r=qt(e,h),c=Array.from(new Set(null==u?void 0:u.map((function(t){return t.data[h]}))))||[],t.centripetalOptions=Object.assign(l,{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,s=void 0===i?[]:i;1===s.length?n=void 0:s.length>1&&(n=Ft(s))}else n=void 0;return{x:null==n?void 0:n.x,y:null==n?void 0:n.y}}})),a&&h){r||(r=qt(e,h)),c||(c=Array.from(new Set(u.map((function(t){return t.data[h]}))))),c=c.filter((function(t){return void 0!==t}));var f={};c.forEach((function(t){var r=u.filter((function(e){return e.data[h]===t})).map((function(t){return e.getNode(t.id)}));f[t]=Ft(r)})),t.centripetalOptions=Object.assign(l,{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(Ot);s.forEach((function(t){!function(t,e){e.visit((function(e,r,n,o,i){return 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,l=Math.sqrt(u)*u;if(h*h*.81<u){var c=t.weight/l;return i.vx+=s*c,i.vy+=a*c,!0}if(t.length)return!1;t.data!==i&&(c=t.data.weight/l,i.vx+=s*c,i.vy+=a*c)}(e,r,0,o,0,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 l=Math.sqrt(h*h+u*u),c=h/l,f=u/l,d=r.data||{},g=d.linkDistance,p=void 0===g?200:g,y=d.edgeStrength,m=(p-l)*(void 0===y?200:y),w=1/(s.data.mass||1),v=1/(a.data.mass||1),x=c*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,s=t.getAllNodes(),a=e.getAllNodes(),h=e.getAllEdges(),u=n.width,c=n.height,f=n.center,d=n.gravity,g=n.centripetalOptions;s&&s.forEach((function(n){var s=n.id,p=n.data,y=p.mass,m=p.x,w=p.y,v=e.getNode(s),x=0,M=0,b=d,E=t.getDegree(s,"in"),N=t.getDegree(s,"out"),S=t.getDegree(s,"both"),k=null==o?void 0:o(v,S);if(k){var A=i(k,3);x=m-A[0],M=w-A[1],b=A[2]}else x=m-f[0],M=w-f[1];if(b&&(r[s].x-=b*x/y,r[s].y-=b*M/y),g){var I=g.leaf,D=g.single,_=g.others,R=g.center,T=(null==R?void 0:R(v,a,h,u,c))||{x:0,y:0,centerStrength:0},O=T.x,z=T.y,C=T.centerStrength;if(!l(O)||!l(z))return;var q=(m-O)/y,L=(w-z)/y;if(C&&(r[s].x-=C*q,r[s].y-=C*L),0===S){var P=D(v);if(!P)return;return r[s].x-=P*q,void(r[s].y-=P*L)}if(0===E||0===N){var F=I(v,a,h);if(!F)return;return r[s].x-=F*q,void(r[s].y-=F*L)}var j=_(v);if(!j)return;r[s].x-=j*q,r[s].y-=j*L}}))},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 l=i/u;a*=l,h*=l}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(l(u.data.fx)&&l(u.data.fy))e.mergeNodeData(a,{x:u.data.fx,y:u.data.fy});else{var c=r[a].x*s,f=r[a].y*s;e.mergeNodeData(a,{x:n.data.x+c,y:n.data.y+f});var d=Math.sqrt(c*c+f*f);switch(i){case"max":o.judgingDistance<d&&(o.judgingDistance=d);break;case"min":o.judgingDistance>d&&(o.judgingDistance=d);break;default:h+=d}}})),i&&"mean"!==i||(this.judgingDistance=h/a.length)}else this.judgingDistance=0},t}(),qt=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]=Lt(t,"leaf",r,e))})),n},Lt=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:Pt(t,e,n,r,a)}},Pt=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},Ft=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}},jt=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})})}))},Vt=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 Wt=Vt;const Gt=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}(),Bt=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 Ut={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},$t=function(){function t(t){void 0===t&&(t={}),this.options=t,this.id="forceAtlas2",this.options=e(e({},Ut),t)}return t.prototype.execute=function(t,e){return this.genericForceAtlas2Layout(!1,t,e)},t.prototype.assign=function(t,e){this.genericForceAtlas2Layout(!0,t,e)},t.prototype.genericForceAtlas2Layout=function(t,r,n){var o=r.getAllEdges(),i=r.getAllNodes(),s=this.formatOptions(n,i.length),a=s.width,h=s.height,u=s.prune,l=s.maxIteration,c=s.nodeSize,f=s.center,d=s.onLayoutEnd;if(!(null==i?void 0:i.length)||1===i.length)return x(r,t,f,d);var g=i.map((function(t){return y(t,[a,h])})),p=o.filter((function(t){return t.source!==t.target})),m=new Tt({nodes:g,edges:p}),w=this.getSizes(m,r,c);if(this.run(m,r,l,w,t,s),u){for(var v=0;v<p.length;v+=1){var M=p[v],b=M.source,E=M.target,N=m.getDegree(b),S=m.getDegree(b);if(N<=1){var k=m.getNode(E);m.mergeNodeData(b,{x:k.data.x,y:k.data.y})}else if(S<=1){var A=m.getNode(b);m.mergeNodeData(E,{x:A.data.x,y:A.data.y})}}var I=e(e({},s),{prune:!1,barnesHut:!1});this.run(m,r,100,w,t,I)}var D={nodes:g,edges:o};return null==d||d(D),D},t.prototype.getSizes=function(t,e,r){for(var n=t.getAllNodes(),o={},a=0;a<n.length;a+=1){var h=n[a],c=h.id,f=h.data;if(o[c]=10,l(f.size))o[c]=f.size;else if(u(f.size))isNaN(f.size[0])||(o[c]=Math.max(f.size[0])),isNaN(f.size[1])||(o[c]=Math.max(f.size[1]));else if(g(f.size))o[c]=Math.max(f.size.width,f.size.height);else if(m(r)){var d=r(e.getNode(c));u(d)?o[c]=Math.max.apply(Math,s([],i(d),!1)):o[c]=d}else u(r)?o[c]=Math.max.apply(Math,s([],i(r),!1)):l(r)&&(o[c]=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,h=n.prune,u=n.maxIteration,l=n.kr,c=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===h&&r>100&&(n.prune=!0),0!==u||h?0===u&&h&&(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)),l||(n.kr=50,r>100&&r<=500?n.kr=20:r>500&&(n.kr=1)),c||(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,h=i.onTick,u=t.getAllNodes(),l=0,c=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 Wt(v)}}for(;c>0;)l=this.oneStep(t,{iter:c,preventOverlapIters:50,krPrime:100,sg:l,forces:f,preForces:d,bodies:g,sizes:n},i),c--,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,a=e.krPrime,h=e.sg,u=e.preForces,l=e.bodies,c=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]=s([],i(f[m]),!1),f[m]=[0,0]}return f=this.getAttrForces(t,n,o,c,f,r),f=g&&(d&&n>o||!d)?this.getOptRepGraForces(t,f,l,r):this.getRepGraForces(t,n,o,f,a,c,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,l=t.getAllEdges(),c=0;c<l.length;c+=1){var f=l[c],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,l=-9e10,c=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>=l&&(l=y.x),y.x<=u&&(u=y.x),y.y>=f&&(f=y.y),y.y<=c&&(c=y.y))}var m=Math.max(l-u,f-c),w=new Gt({xmid:(l+u)/2,ymid:(f+c)/2,length:m,massCenter:i,mass:h}),v=new Bt(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,l=s.center,c=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(!c||!(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-l[0],p.data.y-l[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,f=[],d=[],g=0,p=0,y=n,m=0;m<c;m+=1){var w=u[m].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]);f[m]=M,d[m]=E/2,g+=(v+1)*f[m],p+=(v+1)*d[m]}}var N=y;for(y=s*p/g,0!==N&&(y=y>1.5*N?1.5*N:y),m=0;m<c;m+=1){var S=u[m],k=(w=S.id,S.data);if(v=t.getDegree(w),!(a&&v<=1||l(k.fx)&&l(k.fy))){var A=i*y/(1+y*Math.sqrt(f[m])),I=Math.hypot(e[w][0],e[w][1]),D=h/(I=I<1e-4?1e-4:I),_=(A=A>D?D:A)*e[w][0],R=A*e[w][1];t.mergeNodeData(w,{x:k.x+_,y:k.y+R})}}return y},t}(),Ht={maxIteration:1e3,gravity:10,speed:5,clustering:!1,clusterGravity:10,width:300,height:300,nodeClusterBy:"cluster"},Kt=function(){function t(t){void 0===t&&(t={}),this.options=t,this.id="fruchterman",this.timeInterval=0,this.running=!1,this.options=e(e({},Ht),t)}return t.prototype.execute=function(t,e){return this.genericFruchtermanLayout(!1,t,e)},t.prototype.assign=function(t,e){this.genericFruchtermanLayout(!0,t,e)},t.prototype.stop=function(){this.timeInterval&&"undefined"!=typeof window&&window.clearInterval(this.timeInterval),this.running=!1},t.prototype.restart=function(){this.running=!0},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})})),this.lastOptions.onLayoutEnd&&this.lastOptions.onLayoutEnd(n),n},t.prototype.genericFruchtermanLayout=function(t,r,n){var o=this;if(!this.running){var i=this.formatOptions(n),s=i.layoutInvisibles,a=i.width,h=i.height,u=i.center,l=i.clustering,c=i.nodeClusterBy,f=i.maxIteration,d=i.onTick,g=i.onLayoutEnd,p=r.getAllNodes(),m=r.getAllEdges();if(s||(p=p.filter((function(t){var e=(t.data||{}).visible;return e||void 0===e})),m=m.filter((function(t){var e=(t.data||{}).visible;return e||void 0===e}))),!(null==p?void 0:p.length)){var w={nodes:[],edges:m};return this.lastResult=w,null==g||g(w),w}if(1===p.length)return t&&r.mergeNodeData(p[0].id,{x:u[0],y:u[1]}),w={nodes:[e(e({},p[0]),{data:e(e({},p[0].data),{x:u[0],y:u[1]})})],edges:m},this.lastResult=w,null==g||g(w),w;var v=p.map((function(t){return y(t,[a,h])})),x=new Tt({nodes:v,edges:m}),M={};if(l&&v.forEach((function(t){var e=t.data[c];M[e]||(M[e]={name:e,cx:0,cy:0,count:0})})),this.lastLayoutNodes=v,this.lastLayoutEdges=m,this.lastAssign=t,this.lastGraph=x,this.lastOptions=i,this.lastClusterMap=M,"undefined"!=typeof window){var b=0;return this.timeInterval=window.setInterval((function(){if(o.running&&(o.runOneStep(x,M,i),t&&v.forEach((function(t){var e=t.id,n=t.data;return r.mergeNodeData(e,{x:n.x,y:n.y})})),null==d||d({nodes:v,edges:m}),++b>=f)){try{null==g||g({nodes:v,edges:m})}catch(t){console.warn("onLayoutEnd failed",t)}window.clearInterval(o.timeInterval)}}),0),this.running=!0,{nodes:v,edges:m}}}},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,h=r.clustering,u=r.nodeClusterBy,c=r.clusterGravity,f=n*o,d=Math.sqrt(f)/10,g=t.getAllNodes(),p=f/(g.length+1),y=Math.sqrt(p),m={};if(this.applyCalculate(t,m,y,p),h){for(var w in e)e[w].cx=0,e[w].cy=0,e[w].count=0;for(var w in g.forEach((function(t){var r=t.data,n=e[r[u]];l(r.x)&&(n.cx+=r.x),l(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;g.forEach((function(t,r){var n=t.id,o=t.data;if(l(o.x)&&l(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=y*v;m[n].x-=a*(o.x-i.cx)/s,m[n].y-=a*(o.y-i.cy)/s}}))}g.forEach((function(t,e){var r=t.id,n=t.data;if(l(n.x)&&l(n.y)){var o=.01*y*i;m[r].x-=o*(n.x-s[0]),m[r].y-=o*(n.y-s[1])}})),g.forEach((function(e,r){var n=e.id,o=e.data;if(l(o.fx)&&l(o.fy))return o.x=o.fx,void(o.y=o.fy);if(l(o.x)&&l(o.y)){var i=Math.sqrt(m[n].x*m[n].x+m[n].y*m[n].y);if(i>0){var s=Math.min(d*(a/800),i);t.mergeNodeData(n,{x:o.x+m[n].x/i*s,y:o.y+m[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)&&l(i.x)&&l(a.x)&&l(i.y)&&l(a.y)){var u=i.x-a.x,c=i.y-a.y,f=u*u+c*c;0===f&&(f=1,u=.01,c=.01);var d=r/f,g=u*d,p=c*d;e[s].x+=g,e[s].y+=p,e[h].x-=g,e[h].y-=p}}))}))},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(l(a.x)&&l(s.x)&&l(a.y)&&l(s.y)){var h=a.x-s.x,u=a.y-s.y,c=Math.sqrt(h*h+u*u)/r,f=h*c,d=u*c;e[o].x+=f,e[o].y+=d,e[i].x-=f,e[i].y-=d}}}))},t}(),Jt={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},Xt=function(){function t(t){void 0===t&&(t={}),this.options=t,this.id="grid",this.options=e(e({},Jt),t)}return t.prototype.execute=function(t,e){return this.genericGridLayout(!1,t,e)},t.prototype.assign=function(t,e){this.genericGridLayout(!0,t,e)},t.prototype.genericGridLayout=function(t,r,n){var o=e(e({},this.options),n),i=o.begin,s=void 0===i?[0,0]:i,h=o.condense,c=o.preventOverlapPadding,f=o.preventOverlap,d=o.rows,g=o.cols,p=o.nodeSpacing,m=o.nodeSize,M=o.width,b=o.height,E=o.layoutInvisibles,N=o.onLayoutEnd,S=o.position,k=o.sortBy,A=r.getAllNodes(),I=r.getAllEdges();E||(A=A.filter((function(t){var e=(t.data||{}).visible;return e||void 0===e})),I=I.filter((function(t){var e=(t.data||{}).visible;return e||void 0===e})));var D=null==A?void 0:A.length;if(!D||1===D)return x(r,t,s,N);var _=A.map((function(t){return y(t)}));"id"===k||a(k)&&void 0!==_[0].data[k]||(k="degree"),"degree"===k?_.sort((function(t,e){return r.getDegree(e.id,"both")-r.getDegree(t.id,"both")})):"id"===k?_.sort((function(t,e){return l(e.id)&&l(t.id)?e.id-t.id:"".concat(t.id).localeCompare("".concat(e.id))})):_.sort((function(t,e){return e.data[k]-t.data[k]}));var R=M||"undefined"==typeof window?M:window.innerWidth,T=b||"undefined"==typeof window?b:window.innerHeight,O=D,z={rows:d,cols:g};if(null!=d&&null!=g)z.rows=d,z.cols=g;else if(null!=d&&null==g)z.rows=d,z.cols=Math.ceil(O/z.rows);else if(null==d&&null!=g)z.cols=g,z.rows=Math.ceil(O/z.cols);else{var C=Math.sqrt(O*T/R);z.rows=Math.round(C),z.cols=Math.round(R/T*C)}if(z.rows=Math.max(z.rows,1),z.cols=Math.max(z.cols,1),z.cols*z.rows>O)((L=Yt(z))-1)*(q=Qt(z))>=O?Yt(z,L-1):(q-1)*L>=O&&Qt(z,q-1);else for(;z.cols*z.rows<O;){var q,L=Yt(z);((q=Qt(z))+1)*L>=O?Qt(z,q+1):Yt(z,L+1)}var P=h?0:R/z.cols,F=h?0:T/z.rows;if(f||p){var j=w(10,p),V=v(30,m,!1);_.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=V(o)||30;u(i)?(e=i[0],n=i[1]):(e=i,n=i);var s=void 0!==j?j(t):c,a=e+s,h=n+s;P=Math.max(P,a),F=Math.max(F,h)}))}for(var W={},G={row:0,col:0},B={},U=0;U<_.length;U++){var $=_[U],H=void 0;if(S&&(H=S(r.getNode($.id))),H&&(void 0!==H.row||void 0!==H.col)){var K={row:H.row,col:H.col};if(void 0===K.col)for(K.col=0;Zt(W,K);)K.col++;else if(void 0===K.row)for(K.row=0;Zt(W,K);)K.row++;B[$.id]=K,te(W,K)}re($,s,P,F,B,z,G,W)}var J={nodes:_,edges:I};return null==N||N(J),t&&_.forEach((function(t){r.mergeNodeData(t.id,{x:t.data.x,y:t.data.y})})),J},t}(),Yt=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},Qt=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},Zt=function(t,e){return t["c-".concat(e.row,"-").concat(e.col)]||!1},te=function(t,e){return t["c-".concat(e.row,"-").concat(e.col)]=!0},ee=function(t,e){var r=t.cols||5;e.col++,e.col>=r&&(e.col=0,e.row++)},re=function(t,e,r,n,o,i,s,a){var h,u,l=o[t.id];if(l)h=l.col*r+r/2+e[0],u=l.row*n+n/2+e[1];else{for(;Zt(a,s);)ee(i,s);h=s.col*r+r/2+e[0],u=s.row*n+n/2+e[1],te(a,s),ee(i,s)}t.data.x=h,t.data.y=u};const ne=Object.prototype.toString;function oe(t){return ne.call(t).endsWith("Array]")}function ie(t){var e=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};if(!oe(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}function se(t){var e=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};if(!oe(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}function ae(t){var e,r=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};if(!oe(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(!oe(r.output))throw new TypeError("output option must be an array if specified");e=r.output}else e=new Array(t.length);var n=se(t),o=ie(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),l=0;l<t.length;l++)e[l]=(t[l]-n)*u+s;return e}const he=" ".repeat(2),ue=" ".repeat(4);function le(t,e={}){const{maxRows:r=15,maxColumns:n=10,maxNumSize:o=8,padMinus:i="auto"}=e;return`${t.constructor.name} {\n${he}[\n${ue}${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(ce(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${ue}`)}(t,r,n,o,i)}\n${he}]\n${he}rows: ${t.rows}\n${he}columns: ${t.columns}\n}`}function ce(t,e,r){return(t>=0&&r?` ${fe(t,e-1)}`:fe(t,e)).padEnd(e)}function fe(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 de(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 ge(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 pe(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 ye(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 me(t,e,r,n,o){if(5!==arguments.length)throw new RangeError("expected 4 arguments");if(ve("startRow",e),ve("endRow",r),ve("startColumn",n),ve("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 we(t,e=0){let r=[];for(let n=0;n<t;n++)r.push(e);return r}function ve(t,e){if("number"!=typeof e)throw new TypeError(`${t} must be a number`)}function xe(t){if(t.isEmpty())throw new Error("Empty matrix has no elements to index")}class Me{static from1DArray(t,e,r){if(t*e!==r.length)throw new RangeError("data length does not match given dimensions");let n=new Ee(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 Ee(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 Ee(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 Ee(t,e)}static ones(t,e){return new Ee(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 Ee(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 Ee(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 Ee(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 Me.isMatrix(t)?t:new Ee(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 Ee(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){de(this,t);let e=[];for(let r=0;r<this.columns;r++)e.push(this.get(t,r));return e}getRowVector(t){return Ee.rowVector(this.getRow(t))}setRow(t,e){de(this,t),e=pe(this,e);for(let r=0;r<this.columns;r++)this.set(t,r,e[r]);return this}swapRows(t,e){de(this,t),de(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){ge(this,t);let e=[];for(let r=0;r<this.rows;r++)e.push(this.get(r,t));return e}getColumnVector(t){return Ee.columnVector(this.getColumn(t))}setColumn(t,e){ge(this,t),e=ye(this,e);for(let r=0;r<this.rows;r++)this.set(r,t,e[r]);return this}swapColumns(t,e){ge(this,t),ge(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=pe(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=pe(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=pe(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=pe(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=ye(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=ye(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=ye(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=ye(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){de(this,t);for(let r=0;r<this.columns;r++)this.set(t,r,this.get(t,r)*e);return this}mulColumn(t,e){ge(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(){xe(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(){xe(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(de(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){de(this,t),xe(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(de(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){de(this,t),xe(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(ge(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){ge(this,t),xe(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(ge(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){ge(this,t),xe(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){Me.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=Ee.checkMatrix(t);let e=this.rows,r=this.columns,n=t.columns,o=new Ee(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=Ee.checkMatrix(t);let e=new Ee(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),l=(r+h)*(n+u),c=(s+h)*n,f=r*(i-u),d=h*(a-n),g=(r+o)*u,p=l+d-g+(o-h)*(a+u),y=f+g,m=c+d,w=l-c+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=Ee.checkMatrix(t);let e=new Ee(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),l=this.get(2,2),c=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)*(c-f+p),b=(i+s)*(-c+f),E=r*c,N=(-r+h+u)*(c-d+y),S=(-r+h)*(d-y),k=(h+u)*(-c+d),A=(-o+u+l)*(p+m-w),I=(o-l)*(p-w),D=o*m,_=(u+l)*(-m+w),R=(-o+s+a)*(y+m-v),T=(o-a)*(y-v),O=(s+a)*(-m+v),z=E+D+n*g,C=(r+n+o-i-s-u-l)*p+M+b+E+A+D+_,q=E+N+k+(r+n+o-s-a-h-u)*y+D+R+O,L=x+s*(-c+f+g-p-y-m+v)+M+E+D+R+T,P=x+M+b+E+a*w,F=D+R+T+O+i*d,j=E+N+S+u*(-c+d+g-p-y-m+w)+A+I+D,V=A+I+D+_+h*f,W=E+N+S+k+l*v;return e.set(0,0,z),e.set(0,1,C),e.set(0,2,q),e.set(1,0,L),e.set(1,1,P),e.set(1,2,F),e.set(2,0,j),e.set(2,1,V),e.set(2,2,W),e}mmulStrassen(t){t=Ee.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=Me.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),l=e.subMatrix(0,i-1,a,e.columns-1),c=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(Me.add(h,g),Me.add(u,p),i,a),m=t(Me.add(f,g),u,i,a),w=t(h,Me.sub(c,p),i,a),v=t(g,Me.sub(d,u),i,a),x=t(Me.add(h,l),p,i,a),M=t(Me.sub(f,h),Me.add(u,c),i,a),b=t(Me.sub(l,g),Me.add(d,p),i,a),E=Me.add(y,v);E.sub(x),E.add(b);let N=Me.add(w,x),S=Me.add(m,v),k=Me.sub(y,m);k.add(w),k.add(M);let A=Me.zeros(2*E.rows,2*E.columns);return A=A.setSubMatrix(E,0,0),A=A.setSubMatrix(N,E.rows,0),A=A.setSubMatrix(S,0,E.columns),A=A.setSubMatrix(k,E.rows,E.columns),A.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 Ee(this.rows,this.columns);for(let t=0;t<this.rows;t++){const o=this.getRow(t);o.length>0&&ae(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 Ee(this.rows,this.columns);for(let t=0;t<this.columns;t++){const o=this.getColumn(t);o.length&&ae(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=Ee.checkMatrix(t);let e=this.rows,r=this.columns,n=t.rows,o=t.columns,i=new Ee(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=Ee.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(Ee.eye(r,r)),o=Ee.eye(e,e).kroneckerProduct(t);return n.add(o)}transpose(){let t=new Ee(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=be){for(let e=0;e<this.rows;e++)this.setRow(e,this.getRow(e).sort(t));return this}sortColumns(t=be){for(let e=0;e<this.columns;e++)this.setColumn(e,this.getColumn(e).sort(t));return this}subMatrix(t,e,r,n){me(this,t,e,r,n);let o=new Ee(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 Ee(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 Ee(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=Ee.checkMatrix(t)).isEmpty())return this;me(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(!oe(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(!oe(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 Ee(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 Ee(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=we(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=we(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=we(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=we(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(!oe(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(!oe(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(!oe(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(!oe(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(!oe(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(!oe(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 le(this,t)}}function be(t,e){return t-e}Me.prototype.klass="Matrix","undefined"!=typeof Symbol&&(Me.prototype[Symbol.for("nodejs.util.inspect.custom")]=function(){return le(this)}),Me.random=Me.rand,Me.randomInt=Me.randInt,Me.diagonal=Me.diag,Me.prototype.diagonal=Me.prototype.diag,Me.identity=Me.eye,Me.prototype.negate=Me.prototype.neg,Me.prototype.tensorProduct=Me.prototype.kroneckerProduct;class Ee extends Me{constructor(t,e){if(super(),Ee.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(!oe(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 de(this,t),this.data.splice(t,1),this.rows-=1,this}addRow(t,e){return void 0===e&&(e=t,t=this.rows),de(this,t,!0),e=Float64Array.from(pe(this,e)),this.data.splice(t,0,e),this.rows+=1,this}removeColumn(t){ge(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),ge(this,t,!0),e=ye(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}}(Me,Ee);class Ne extends Me{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 Se(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 ke{constructor(t,e={}){if((t=Ne.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),l=!1;if(r<n)if(s){a=t.transpose(),r=a.rows,n=a.columns,l=!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 c=Math.min(r,n),f=Math.min(r+1,n),d=new Float64Array(f),g=new Ee(r,c),p=new Ee(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]=Se(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]=Se(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<c;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<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(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=Se(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=Se(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,l=y[t]/e,c=((i+o)*(i-o)+s*s)/2,f=o*s*(o*s);let m=0;0===c&&0===f||(m=c<0?0-Math.sqrt(c*c+f):Math.sqrt(c*c+f),m=f/(c+m));let w=(a+o)*(a-o)+m,v=a*l;for(let e=t;e<b-1;e++){let o=Se(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=Se(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(l){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=Ee.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,l=Ee.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);l.set(t,e,r)}return l.mmul(e)}solveForDiagonal(t){return this.solve(Ee.diag(t))}inverse(){let t=this.V,e=this.threshold,r=t.rows,n=t.columns,o=new Ee(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 Ee(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 Ee.diag(this.s)}}var Ae={center:[0,0],linkDistance:50},Ie=function(){function t(t){void 0===t&&(t={}),this.options=t,this.id="mds",this.options=e(e({},Ae),t)}return t.prototype.execute=function(t,e){return this.genericMDSLayout(!1,t,e)},t.prototype.assign=function(t,e){this.genericMDSLayout(!0,t,e)},t.prototype.genericMDSLayout=function(t,r,n){var o=e(e({},this.options),n),i=o.center,s=void 0===i?[0,0]:i,a=o.linkDistance,h=void 0===a?50:a,u=o.layoutInvisibles,l=o.onLayoutEnd,d=r.getAllNodes(),g=r.getAllEdges();if(u||(d=d.filter((function(t){var e=(t.data||{}).visible;return e||void 0===e})),g=g.filter((function(t){var e=(t.data||{}).visible;return e||void 0===e}))),!(null==d?void 0:d.length)||1===d.length)return x(r,t,s,l);var p=f({nodes:d,edges:g},!1),m=c(p);De(m);var w=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,h),v=_e(w),M=[];v.forEach((function(t,e){var r=y(d[e]);r.data.x=t[0]+s[0],r.data.y=t[1]+s[1],M.push(r)})),t&&M.forEach((function(t){return r.mergeNodeData(t.id,{x:t.data.x,y:t.data.y})}));var b={nodes:M,edges:g};return null==l||l(b),b},t}(),De=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)}))}))},_e=function(t){var e=Ee.mul(Ee.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 ke(e),s=Ee.sqrt(i.diagonalMatrix).diagonal();return i.leftSingularVectors.toJSON().map((function(t){return Ee.mul([t],[s]).toJSON()[0].splice(0,2)}))},Re={iterations:10,height:10,width:10,speed:100,gravity:10,k:5},Te=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,l=s.y-e.y,c=Math.sqrt(u*u+l*l);if(0===c){c=1;var f=a>h?1:-1;u=.01*f,l=.01*f}if(c<i(t[a])/2+i(t[h])/2){var d=n*n/c;r[a].x+=u/c*d,r[a].y+=l/c*d}}}))}))},Oe=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),l=Math.acos((a*e.x+h*e.y)/u);l>Math.PI/2&&(l-=Math.PI/2,a*=-1,h*=-1);var c=Math.cos(l)*u;e.x=a*c,e.y=h*c})),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 l=Math.min(h*(r/800),u);if(i.x+=e[s].x/u*l,i.y+=e[s].y/u*l,n){var c=i.x-t[o].x,f=i.y-t[o].y,d=Math.sqrt(c*c+f*f);c=c/d*a[s],f=f/d*a[s],i.x=t[o].x+c,i.y=t[o].y+f}}}})),t},ze={maxIteration:1e3,focusNode:null,unitRadius:null,linkDistance:50,preventOverlap:!1,strictRadial:!0,maxPreventOverlapIteration:200,sortStrength:10},Ce=function(){function t(t){void 0===t&&(t={}),this.options=t,this.id="radial",this.options=e(e({},ze),t)}return t.prototype.execute=function(t,e){return this.genericRadialLayout(!1,t,e)},t.prototype.assign=function(t,e){this.genericRadialLayout(!0,t,e)},t.prototype.genericRadialLayout=function(t,r,n){var o=e(e({},this.options),n),h=o.width,u=o.height,l=o.center,d=o.focusNode,g=o.unitRadius,p=o.nodeSize,m=o.nodeSpacing,w=o.strictRadial,v=o.preventOverlap,M=o.maxPreventOverlapIteration,b=o.sortBy,E=o.linkDistance,N=void 0===E?50:E,S=o.sortStrength,k=void 0===S?10:S,A=o.maxIteration,I=void 0===A?1e3:A,D=o.layoutInvisibles,_=o.onLayoutEnd,R=r.getAllNodes(),T=r.getAllEdges();D||(R=R.filter((function(t){var e=(t.data||{}).visible;return e||void 0===e})),T=T.filter((function(t){var e=(t.data||{}).visible;return e||void 0===e})));var O=h||"undefined"==typeof window?h:window.innerWidth,z=u||"undefined"==typeof window?u:window.innerHeight,C=l||[O/2,z/2];if(!(null==R?void 0:R.length)||1===R.length)return x(r,t,C,_);var q=R[0];if(a(d)){for(var L=0;L<R.length;L++)if(R[L].id===d){q=R[L];break}}else q=d||R[0];var P=Pe(R,q.id),F=f({nodes:R,edges:T},!1),j=c(F),V=je(j,P);Fe(j,P,V+1);var W=j[P],G=O-C[0]>C[0]?C[0]:O-C[0],B=z-C[1]>C[1]?C[1]:z-C[1];0===G&&(G=O/2),0===B&&(B=z/2);var U=Math.min(G,B),$=Math.max.apply(Math,s([],i(W),!1)),H=[],K=g||U/$;W.forEach((function(t,e){H[e]=t*K}));var J,X=qe(R,j,N,H,K,b,k),Y=Le(X),Q=function(t,e,r){try{var n=Ee.mul(Ee.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 ke(n),h=Ee.sqrt(a.diagonalMatrix).diagonal();return a.leftSingularVectors.toJSON().map((function(e){return Ee.mul([e],[h]).toJSON()[0].splice(0,t)}))}catch(t){for(var u=[],l=0;l<e.length;l++){var c=Math.random()*r,f=Math.random()*r;u.push([c,f])}return u}}(N,X,N),Z=Q.map((function(t){var e=i(t,2),r=e[0],n=e[1];return{x:(isNaN(r)?Math.random()*N:r)-Q[P][0],y:(isNaN(n)?Math.random()*N:n)-Q[P][1]}}));if(this.run(I,Z,Y,X,H,P),v){J=Ve(p,m);var tt={nodes:R,nodeSizeFunc:J,positions:Z,radii:H,height:z,width:O,strictRadial:Boolean(w),focusIdx:P,iterations:M||200,k:Z.length/4.5};Z=function(t,r){for(var n=e(e({},Re),r),o=n.positions,i=n.iterations,s=n.width,a=n.k,h=n.speed,u=void 0===h?100:h,l=n.strictRadial,c=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}})),Te(p,o,y,a,d,g),Oe(o,y,u,l,c,m,s,d);return o}(r,tt)}var et=[];Z.forEach((function(t,e){var r=y(R[e]);r.data.x=t.x+C[0],r.data.y=t.y+C[1],et.push(r)})),t&&et.forEach((function(t){return r.mergeNodeData(t.id,{x:t.data.x,y:t.data.y})}));var rt={nodes:et,edges:T};return null==_||_(rt),rt},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=d(a,{x:0,y:0}),l=0===u?0:1/u;if(h!==i){var c=0,f=0,g=0;e.forEach((function(t,e){if(h!==e){var r=d(a,t),i=0===r?0:1/r,s=n[e][h];g+=o[h][e],c+=o[h][e]*(t.x+s*(a.x-t.x)*i),f+=o[h][e]*(t.y+s*(a.y-t.y)*i)}}));var p=0===r[h]?0:1/r[h];g*=s,g+=t*p*p,c*=s,c+=t*p*a.x*l,a.x=c/g,f*=s,f+=t*p*a.y*l,a.y=f/g}}))},t}(),qe=function(t,e,r,n,o,i,s){if(!t)return[];var h=[];if(e){var u={};e.forEach((function(e,l){var c=[];e.forEach((function(e,h){var f,d;if(l===h)c.push(0);else if(n[l]===n[h])if("data"===i)c.push(e*(Math.abs(l-h)*s)/(n[l]/o));else if(i){var g=void 0,p=void 0;if(u[t[l].id])g=u[t[l].id];else{var y=("id"===i?t[l].id:null===(f=t[l].data)||void 0===f?void 0:f[i])||0;g=a(y)?y.charCodeAt(0):y,u[t[l].id]=g}u[t[h].id]?p=u[t[h].id]:(y=("id"===i?t[h].id:null===(d=t[h].data)||void 0===d?void 0:d[i])||0,p=a(y)?y.charCodeAt(0):y,u[t[h].id]=p),c.push(e*(Math.abs(g-p)*s)/(n[l]/o))}else c.push(e*r/(n[l]/o));else{var m=(r+o)/2;c.push(e*m)}})),h.push(c)}))}return h},Le=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},Pe=function(t,e){var r=-1;return t.forEach((function(t,n){t.id===e&&(r=n)})),Math.max(r,0)},Fe=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}},je=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},Ve=function(t,e){var r;return r=l(e)?function(){return e}:m(e)?e:function(){return 0},t?u(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;return(null===(e=t.data)||void 0===e?void 0:e.bboxSize)?Math.max(t.data.bboxSize[0],t.data.bboxSize[1])+r(t):(null===(n=t.data)||void 0===n?void 0:n.size)?u(t.data.size)?Math.max(t.data.size[0],t.data.size[1])+r(t):g(t.data.size)?(t.data.size.width>t.data.size.height?t.data.size.width:t.data.size.height)+r(t):t.data.size+r(t):10+r(t)}},We={center:[0,0],width:300,height:300},Ge=function(){function t(t){void 0===t&&(t={}),this.options=t,this.id="random",this.options=e(e({},We),t)}return t.prototype.execute=function(t,e){return this.genericRandomLayout(!1,t,e)},t.prototype.assign=function(t,e){this.genericRandomLayout(!0,t,e)},t.prototype.genericRandomLayout=function(t,r,n){var o=e(e({},this.options),n),i=o.center,s=o.width,a=o.height,h=o.layoutInvisibles,u=o.onLayoutEnd,l=r.getAllNodes();h||(l=l.filter((function(t){var e=(t.data||{}).visible;return e||void 0===e})));var c=s||"undefined"==typeof window?s:window.innerWidth,f=a||"undefined"==typeof window?a:window.innerHeight,d=i||[c/2,f/2],g=[];l&&l.forEach((function(t){g.push({id:t.id,data:{x:.9*(Math.random()-.5)*c+d[0],y:.9*(Math.random()-.5)*f+d[1]}})})),t&&g.forEach((function(t){return r.mergeNodeData(t.id,{x:t.data.x,y:t.data.y})}));var p={nodes:g,edges:r.getAllEdges()};return null==u||u(p),p},t}(),Be={circular:b,concentric:T,mds:Ie,random:Ge,grid:Xt,radial:Ce,force:Ct,d3force:Dt,fruchterman:Kt,forceAtlas2:$t};function Ue(t,e){Be[t]=e}})();var o=n.SB,i=n.W1,s=n.jA,a=n.E9,h=n.y7,u=n.O2,l=n.Me,c=n.AI,f=n.D4,d=n._5,g=n.y9,p=n.Xp,y=n.qR,m=n.i_;export{o as CircularLayout,i as ConcentricLayout,s as D3ForceLayout,a as ForceAtlas2Layout,h as ForceLayout,u as FruchtermanLayout,l as GridLayout,c as MDSLayout,f as RadialLayout,d as RandomLayout,g as Supervisor,p as SupervisorEvent,y as registerLayout,m as registry};
|
|
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),h=r?r+e:e;return t._events[h]?t._events[h].fn?t._events[h]=[t._events[h],a]:t._events[h].push(a):(t._events[h]=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 h,u,l=this._events[a],c=arguments.length;if(l.fn){switch(l.once&&this.removeListener(t,l.fn,void 0,!0),c){case 1:return l.fn.call(l.context),!0;case 2:return l.fn.call(l.context,e),!0;case 3:return l.fn.call(l.context,e,n),!0;case 4:return l.fn.call(l.context,e,n,o),!0;case 5:return l.fn.call(l.context,e,n,o,i),!0;case 6:return l.fn.call(l.context,e,n,o,i,s),!0}for(u=1,h=new Array(c-1);u<c;u++)h[u-1]=arguments[u];l.fn.apply(l.context,h)}else{var f,d=l.length;for(u=0;u<d;u++)switch(l[u].once&&this.removeListener(t,l[u].fn,void 0,!0),c){case 1:l[u].fn.call(l[u].context);break;case 2:l[u].fn.call(l[u].context,e);break;case 3:l[u].fn.call(l[u].context,e,n);break;case 4:l[u].fn.call(l[u].context,e,n,o);break;default:if(!h)for(f=1,h=new Array(c-1);f<c;f++)h[f-1]=arguments[f];l[u].fn.apply(l[u].context,h)}}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 h=0,u=[],l=a.length;h<l;h++)(a[h].fn!==e||o&&!a[h].once||n&&a[h].context!==n)&&u.push(a[h]);u.length?this._events[i]=1===u.length?u[0]:u: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:()=>Ge,stopLayout:()=>$e});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){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 i(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;const s=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["*"]||[],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 a(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 h(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)&&h(o,e,r,n))return!0;return!1}class u extends s{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 h(this.getNode(t),new Set,e,(t=>this.getChildren(t,r)))}bfsTree(t,e,r){return a([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 a([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 h(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 u({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 l=/-(\\w)/g,c=(function(t){return t.replace(l,(function(t,e){return e?e.toUpperCase():""}))},Object.create(null),Array.isArray),f=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},d=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},g=function(t,e){return Math.sqrt((t.x-e.x)*(t.x-e.x)+(t.y-e.y)*(t.y-e.y))},p={}.toString;const y=function(t,e){return p.call(t)==="[object "+e+"]"},m=function(t){return y(t,"Number")};var w=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 w(t)}))}if("object"==typeof t){var r={};return Object.keys(t).forEach((function(e){r[e]=w(t[e])})),r}return t},v=function(t,e){var r=w(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 x=function(t){return"function"==typeof t},b=function(t){var e=typeof t;return null!==t&&"object"===e||"function"===e};function M(t,e){return x(e)?e:m(e)?function(){return e}:function(){return t}}function E(t,e,r){return void 0===r&&(r=!0),e||0===e?x(e)?e:m(e)?function(){return e}:c(e)?function(){if(r){var n=Math.max.apply(Math,i([],o(e),!1));return isNaN(n)?t:n}return e}:b(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?c(r)?r[0]>r[1]?r[0]:r[1]:b(r)?r.width>r.height?r.width:r.height:r:t}}var N=function(t,e,n,o){var i=t.getAllNodes(),s=t.getAllEdges();if(!(null==i?void 0:i.length)){var a={nodes:[],edges:s};return null==o||o(a),a}if(1===i.length)return e&&t.mergeNodeData(i[0].id,{x:n[0],y:n[1]}),a={nodes:[r(r({},i[0]),{data:r(r({},i[0].data),{x:n[0],y:n[1]})})],edges:s},null==o||o(a),a},S={radius:null,startRadius:null,endRadius:null,startAngle:0,endAngle:2*Math.PI,clockwise:!0,divisions:1,ordering:null,angleRatio:1},A=function(){function t(t){void 0===t&&(t={}),this.options=t,this.id="circular",this.options=r(r({},S),t)}return t.prototype.execute=function(t,e){return this.genericCircularLayout(!1,t,e)},t.prototype.assign=function(t,e){this.genericCircularLayout(!0,t,e)},t.prototype.genericCircularLayout=function(t,e,n){var i=r(r({},this.options),n),s=i.width,a=i.height,h=i.center,u=i.divisions,l=i.startAngle,c=void 0===l?0:l,f=i.endAngle,d=void 0===f?2*Math.PI:f,g=i.angleRatio,p=i.ordering,y=i.clockwise,m=i.nodeSpacing,w=i.nodeSize,x=i.layoutInvisibles,b=i.onLayoutEnd,S=e.getAllNodes(),A=e.getAllEdges();x||(S=S.filter((function(t){var e=(t.data||{}).visible;return e||void 0===e})),A=A.filter((function(t){var e=(t.data||{}).visible;return e||void 0===e})));var D=o(I(s,a,h),3),_=D[0],R=D[1],z=D[2],T=null==S?void 0:S.length;if(!T||1===T)return N(e,t,z,b);var O=(d-c)/T,C=i.radius,P=i.startRadius,q=i.endRadius;if(m){var L=M(10,m),F=E(10,w),j=-1/0;S.forEach((function(t){var e=F(t);j<e&&(j=e)}));var V=0;S.forEach((function(t,e){V+=0===e?j||10:(L(t)||0)+(j||10)})),C=V/(2*Math.PI)}else C||P||q?!P&&q?P=q:P&&!q&&(q=P):C=Math.min(R,_)/2;var W=O*g,$=[];$="topology"===p?k(e,S):"topology-directed"===p?k(e,S,!0):"degree"===p?function(t,e){var r=[];return e.forEach((function(t,e){r.push(v(t))})),r.sort((function(e,r){return t.getDegree(e.id,"both")-t.getDegree(r.id,"both")})),r}(e,S):S.map((function(t){return v(t)}));for(var G=Math.ceil(T/u),U=0;U<T;++U){var B=C;B||null===P||null===q||(B=P+U*(q-P)/(T-1)),B||(B=10+100*U/(T-1));var H=c+U%G*W+2*Math.PI/u*Math.floor(U/G);y||(H=d-U%G*W-2*Math.PI/u*Math.floor(U/G)),$[U].data.x=z[0]+Math.cos(H)*B,$[U].data.y=z[1]+Math.sin(H)*B}t&&$.forEach((function(t){e.mergeNodeData(t.id,{x:t.data.x,y:t.data.y})}));var K={nodes:$,edges:A};return null==b||b(K),K},t}(),k=function(t,e,r){void 0===r&&(r=!1);var n=[v(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),l=!1,c=0;c<u.length;c++){var f=u[c];if(t.getDegree(f.id)===t.getDegree(a.id)&&!o[f.id]){n.push(v(f)),o[f.id]=!0,l=!0;break}}for(var d=0;!l&&(o[e[d].id]||(n.push(v(e[d])),o[e[d].id]=!0,l=!0),++d!==i););}else n.push(v(a)),o[a.id]=!0,s++})),n},I=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 D=function(t){return y(t,"String")};var _={nodeSize:30,nodeSpacing:10,preventOverlap:!1,sweep:void 0,equidistant:!1,startAngle:1.5*Math.PI,clockwise:!0,maxLevelDiff:void 0,sortBy:"degree"},R=function(){function t(t){void 0===t&&(t={}),this.options=t,this.id="concentric",this.options=r(r({},_),t)}return t.prototype.execute=function(t,e){return this.genericConcentricLayout(!1,t,e)},t.prototype.assign=function(t,e){this.genericConcentricLayout(!0,t,e)},t.prototype.genericConcentricLayout=function(t,e,n){var o=r(r({},this.options),n),i=o.center,s=o.width,a=o.height,h=o.sortBy,u=o.maxLevelDiff,l=o.sweep,f=o.clockwise,d=o.equidistant,g=o.preventOverlap,p=o.startAngle,y=void 0===p?1.5*Math.PI:p,w=o.nodeSize,M=o.nodeSpacing,E=o.layoutInvisibles,S=o.onLayoutEnd,A=e.getAllNodes(),k=e.getAllEdges();E||(A=A.filter((function(t){var e=(t.data||{}).visible;return e||void 0===e})),k=k.filter((function(t){var e=(t.data||{}).visible;return e||void 0===e})));var I=s||"undefined"==typeof window?s:window.innerWidth,_=a||"undefined"==typeof window?a:window.innerHeight,R=i||[I/2,_/2];if(!(null==A?void 0:A.length)||1===A.length)return N(e,t,R,S);var z,T=[],O=0;z=c(w)?Math.max(w[0],w[1]):w,c(M)?O=Math.max(M[0],M[1]):m(M)&&(O=M),A.forEach((function(t){var e=v(t);T.push(e);var r=z,n=e.data;c(n.size)?r=Math.max(n.size[0],n.size[1]):m(n.size)?r=n.size:b(n.size)&&(r=Math.max(n.size.width,n.size.height)),z=Math.max(z,r),x(M)&&(O=Math.max(M(t),O))}));var C={};T.forEach((function(t,e){C[t.id]=e}));var P=h;D(P)&&void 0!==T[0].data[P]||(P="degree"),"degree"===P?T.sort((function(t,r){return e.getDegree(r.id,"both")-e.getDegree(t.id,"both")})):T.sort((function(t,e){return e.data[P]-t.data[P]}));var q=T[0],L=(u||("degree"===P?e.getDegree(q.id,"both"):q.data[P]))/4,F=[{nodes:[]}],j=F[0];T.forEach((function(t){if(j.nodes.length>0){var r="degree"===P?Math.abs(e.getDegree(j.nodes[0].id,"both")-e.getDegree(t.id,"both")):Math.abs(j.nodes[0].data[P]-t.data[P]);L&&r>=L&&(j={nodes:[]},F.push(j))}j.nodes.push(t)}));var V=z+O;if(!g){var W=F.length>0&&F[0].nodes.length>1,$=(Math.min(I,_)/2-V)/(F.length+(W?1:0));V=Math.min(V,$)}var G=0;if(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&&g){var r=Math.cos(t.dTheta)-Math.cos(0),n=Math.sin(t.dTheta)-Math.sin(0),o=Math.sqrt(V*V/(r*r+n*n));G=Math.max(o,G)}t.r=G,G+=V})),d){for(var U=0,B=0,H=0;H<F.length;H++){var K=(F[H].r||0)-B;U=Math.max(U,K)}B=0,F.forEach((function(t,e){0===e&&(B=t.r||0),t.r=B,B+=U}))}F.forEach((function(t){var e=t.dTheta||0,r=t.r||0;t.nodes.forEach((function(t,n){var o=y+(f?1:-1)*e*n;t.data.x=R[0]+r*Math.cos(o),t.data.y=R[1]+r*Math.sin(o)}))})),t&&T.forEach((function(t){return e.mergeNodeData(t.id,{x:t.data.x,y:t.data.y})}));var J={nodes:T,edges:k};return null==S||S(J),J},t}();function z(t,e,r,n){if(isNaN(e)||isNaN(r))return t;var o,i,s,a,h,u,l,c,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,(l=r>=(s=(y+w)/2))?y=s:w=s,o=d,!(d=d[c=l<<1|u]))return o[c]=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[c]=g:t._root=g,t;do{o=o?o[c]=new Array(4):t._root=new Array(4),(u=e>=(i=(p+m)/2))?p=i:m=i,(l=r>=(s=(y+w)/2))?y=s:w=s}while((c=l<<1|u)==(f=(h>=s)<<1|a>=i));return o[f]=d,o[c]=g,t}function T(t,e,r,n,o){this.node=t,this.x0=e,this.y0=r,this.x1=n,this.y1=o}function O(t){return t[0]}function C(t){return t[1]}function P(t,e,r){var n=new q(null==e?O:e,null==r?C: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 L(t){for(var e={data:t.data},r=e;t=t.next;)r=r.next={data:t.data};return e}var F=P.prototype=q.prototype;function j(t){return function(){return t}}function V(t){return 1e-6*(t()-.5)}F.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=L(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]=L(e));return r},F.add=function(t){const e=+this._x.call(null,t),r=+this._y.call(null,t);return z(this.cover(e,r),e,r,t)},F.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,l=-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))||(s[r]=n,a[r]=o,n<h&&(h=n),n>l&&(l=n),o<u&&(u=o),o>c&&(c=o));if(h>l||u>c)return this;for(this.cover(h,u).cover(l,c),r=0;r<i;++r)z(this,s[r],a[r],t[r]);return this},F.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},F.data=function(){var t=[];return this.visit((function(e){if(!e.length)do{t.push(e.data)}while(e=e.next)})),t},F.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]]},F.find=function(t,e,r){var n,o,i,s,a,h,u,l=this._x0,c=this._y0,f=this._x1,d=this._y1,g=[],p=this._root;for(p&&g.push(new T(p,l,c,f,d)),null==r?r=1/0:(l=t-r,c=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)<l||(a=h.y1)<c))if(p.length){var y=(o+s)/2,m=(i+a)/2;g.push(new T(p[3],y,m,s,a),new T(p[2],o,m,y,a),new T(p[1],y,i,s,m),new T(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 b=Math.sqrt(r=x);l=t-b,c=e-b,f=t+b,d=e+b,n=p.data}}return n},F.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,l,c,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,(l=s>=(h=(p+m)/2))?p=h:m=h,e=d,!(d=d[c=l<<1|u]))return this;if(!d.length)break;(e[c+1&3]||e[c+2&3]||e[c+3&3])&&(r=e,f=c)}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[c]=o:delete e[c],(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)},F.removeAll=function(t){for(var e=0,r=t.length;e<r;++e)this.remove(t[e]);return this},F.root=function(){return this._root},F.size=function(){var t=0;return this.visit((function(e){if(!e.length)do{++t}while(e=e.next)})),t},F.visit=function(t){var e,r,n,o,i,s,a=[],h=this._root;for(h&&a.push(new T(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,l=(o+s)/2;(r=h[3])&&a.push(new T(r,u,l,i,s)),(r=h[2])&&a.push(new T(r,n,l,u,s)),(r=h[1])&&a.push(new T(r,u,o,i,l)),(r=h[0])&&a.push(new T(r,n,o,u,l))}return this},F.visitAfter=function(t){var e,r=[],n=[];for(this._root&&r.push(new T(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,l=(s+h)/2,c=(a+u)/2;(i=o[0])&&r.push(new T(i,s,a,l,c)),(i=o[1])&&r.push(new T(i,l,a,h,c)),(i=o[2])&&r.push(new T(i,s,c,l,u)),(i=o[3])&&r.push(new T(i,l,c,h,u))}n.push(e)}for(;e=n.pop();)t(e.node,e.x0,e.y0,e.x1,e.y1);return this},F.x=function(t){return arguments.length?(this._x=t,this):this._x},F.y=function(t){return arguments.length?(this._y=t,this):this._y};var W={value:()=>{}};function $(){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 G(n)}function G(t){this._=t}function U(t,e){return t.trim().split(/^|\\s+/).map((function(t){var r="",n=t.indexOf(".");if(n>=0&&(r=t.slice(n+1),t=t.slice(0,n)),t&&!e.hasOwnProperty(t))throw new Error("unknown type: "+t);return{type:t,name:r}}))}function B(t,e){for(var r,n=0,o=t.length;n<o;++n)if((r=t[n]).name===e)return r.value}function H(t,e,r){for(var n=0,o=t.length;n<o;++n)if(t[n].name===e){t[n]=W,t=t.slice(0,n).concat(t.slice(n+1));break}return null!=r&&t.push({name:e,value:r}),t}G.prototype=$.prototype={constructor:G,on:function(t,e){var r,n=this._,o=U(t+"",n),i=-1,s=o.length;if(!(arguments.length<2)){if(null!=e&&"function"!=typeof e)throw new Error("invalid callback: "+e);for(;++i<s;)if(r=(t=o[i]).type)n[r]=H(n[r],t.name,e);else if(null==e)for(r in n)n[r]=H(n[r],t.name,null);return this}for(;++i<s;)if((r=(t=o[i]).type)&&(r=B(n[r],t.name)))return r},copy:function(){var t={},e=this._;for(var r in e)t[r]=e[r].slice();return new G(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 K=$;var J,Y,X=0,Q=0,Z=0,tt=0,et=0,rt=0,nt="object"==typeof performance&&performance.now?performance:Date,ot="object"==typeof window&&window.requestAnimationFrame?window.requestAnimationFrame.bind(window):function(t){setTimeout(t,17)};function it(){return et||(ot(st),et=nt.now()+rt)}function st(){et=0}function at(){this._call=this._time=this._next=null}function ht(t,e,r){var n=new at;return n.restart(t,e,r),n}function ut(){et=(tt=nt.now())+rt,X=Q=0;try{!function(){it(),++X;for(var t,e=J;e;)(t=et-e._time)>=0&&e._call.call(void 0,t),e=e._next;--X}()}finally{X=0,function(){for(var t,e,r=J,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:J=e);Y=t,ct(n)}(),et=0}}function lt(){var t=nt.now(),e=t-tt;e>1e3&&(rt-=e,tt=t)}function ct(t){X||(Q&&(Q=clearTimeout(Q)),t-et>24?(t<1/0&&(Q=setTimeout(ut,t-nt.now()-rt)),Z&&(Z=clearInterval(Z))):(Z||(tt=nt.now(),Z=setInterval(lt,1e3)),X=1,ot(ut)))}at.prototype=ht.prototype={constructor:at,restart:function(t,e,r){if("function"!=typeof t)throw new TypeError("callback is not a function");r=(null==r?it():+r)+(null==e?0:+e),this._next||Y===this||(Y?Y._next=this:J=this,Y=this),this._call=t,this._time=r,ct()},stop:function(){this._call&&(this._call=null,this._time=1/0,ct())}};const ft=4294967296;function dt(t){return t.x}function gt(t){return t.y}var pt=Math.PI*(3-Math.sqrt(5));function yt(t){var e,r=1,n=.001,o=1-Math.pow(n,1/300),i=0,s=.6,a=new Map,h=ht(c),u=K("tick","end"),l=function(){let t=1;return()=>(t=(1664525*t+1013904223)%ft)/ft}();function c(){f(),u.call("tick",e),r<n&&(h.stop(),u.call("end",e))}function f(n){var h,u,l=t.length;void 0===n&&(n=1);for(var c=0;c<n;++c)for(r+=(i-r)*o,a.forEach((function(t){t(r)})),h=0;h<l;++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=10*Math.sqrt(.5+r),i=r*pt;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,l),e}return null==t&&(t=[]),d(),e={tick:f,restart:function(){return h.restart(c),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?(l=t,a.forEach(g),e):l},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,l=t.length;for(null==n?n=1/0:n*=n,u=0;u<l;++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 mt(){var t,e,r,n,o,i=j(-30),s=1,a=1/0,h=.81;function u(r){var o,i=t.length,s=P(t,dt,gt).visitAfter(c);for(n=r,o=0;o<i;++o)e=t[o],s.visit(f)}function l(){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,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,l){if(!t.value)return!0;var c=t.x-e.x,f=t.y-e.y,d=l-i,g=c*c+f*f;if(d*d/h<g)return g<a&&(0===c&&(g+=(c=V(r))*c),0===f&&(g+=(f=V(r))*f),g<s&&(g=Math.sqrt(s*g)),e.vx+=c*t.value*n/g,e.vy+=f*t.value*n/g),!0;if(!(t.length||g>=a)){(t.data!==e||t.next)&&(0===c&&(g+=(c=V(r))*c),0===f&&(g+=(f=V(r))*f),g<s&&(g=Math.sqrt(s*g)));do{t.data!==e&&(d=o[t.data.index]*n/g,e.vx+=c*d,e.vy+=f*d)}while(t=t.next)}}return u.initialize=function(e,n){t=e,r=n,l()},u.strength=function(t){return arguments.length?(i="function"==typeof t?t:j(+t),l(),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 wt(t){return t.index}function vt(t,e){var r=t.get(e);if(!r)throw new Error("node not found: "+e);return r}function xt(t){var e,r,n,o,i,s,a=wt,h=function(t){return 1/Math.min(o[t.source.index],o[t.target.index])},u=j(30),l=1;function c(n){for(var o=0,a=t.length;o<l;++o)for(var h,u,c,f,d,g,p,y=0;y<a;++y)u=(h=t[y]).source,f=(c=h.target).x+c.vx-u.x-u.vx||V(s),d=c.y+c.vy-u.y-u.vy||V(s),f*=g=((g=Math.sqrt(f*f+d*d))-r[y])/g*n*e[y],d*=g,c.vx-=f*(p=i[y]),c.vy-=d*p,u.vx+=f*(p=1-p),u.vy+=d*p}function f(){if(n){var s,h,u=n.length,l=t.length,c=new Map(n.map(((t,e)=>[a(t,e,n),t])));for(s=0,o=new Array(u);s<l;++s)(h=t[s]).index=s,"object"!=typeof h.source&&(h.source=vt(c,h.source)),"object"!=typeof h.target&&(h.target=vt(c,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(l);s<l;++s)h=t[s],i[s]=o[h.source.index]/(o[h.source.index]+o[h.target.index]);e=new Array(l),d(),r=new Array(l),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=[]),c.initialize=function(t,e){n=t,s=e,f()},c.links=function(e){return arguments.length?(t=e,f(),c):t},c.id=function(t){return arguments.length?(a=t,c):a},c.iterations=function(t){return arguments.length?(l=+t,c):l},c.strength=function(t){return arguments.length?(h="function"==typeof t?t:j(+t),d(),c):h},c.distance=function(t){return arguments.length?(u="function"==typeof t?t:j(+t),g(),c):u},c}function bt(t){return t.x+t.vx}function Mt(t){return t.y+t.vy}function Et(t){var e,r,n,o=1,i=1;function s(){for(var t,s,h,u,l,c,f,d=e.length,g=0;g<i;++g)for(s=P(e,bt,Mt).visitAfter(a),t=0;t<d;++t)h=e[t],c=r[h.index],f=c*c,u=h.x+h.vx,l=h.y+h.vy,s.visit(p);function p(t,e,r,i,s){var a=t.data,d=t.r,g=c+d;if(!a)return e>u+g||i<u-g||r>l+g||s<l-g;if(a.index>h.index){var p=u-a.x-a.vx,y=l-a.y-a.vy,m=p*p+y*y;m<g*g&&(0===p&&(m+=(p=V(n))*p),0===y&&(m+=(y=V(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=j(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:j(+e),h(),s):t},s}function Nt(t){var e,r,n,o=j(.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=j(null==t?0:+t)),i.initialize=function(t){e=t,s()},i.strength=function(t){return arguments.length?(o="function"==typeof t?t:j(+t),s(),i):o},i.x=function(e){return arguments.length?(t="function"==typeof e?e:j(+e),s(),i):t},i}function St(t){var e,r,n,o=j(.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=j(null==t?0:+t)),i.initialize=function(t){e=t,s()},i.strength=function(t){return arguments.length?(o="function"==typeof t?t:j(+t),s(),i):o},i.y=function(e){return arguments.length?(t="function"==typeof e?e:j(+e),s(),i):t},i}function At(){function t(t){return function(){return t}}var e,r=function(t){return t.cluster},n=t(1),i=t(-1),s=t(100),a=t(.1),h=[0,0],u=[],l={},c=[],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(),b();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(l[o]))<=(a=r(l[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=o(t,2),r=e[0],i=e[1],s=r.split("~")[0],a=r.split("~")[1];void 0!==s&&void 0!==a&&n.push({source:s,target:a,count:i})})),n}(c),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=yt(w.nodes).force("x",Nt(f).strength(.1)).force("y",St(d).strength(.1)).force("collide",Et((function(t){return t.r})).iterations(4)).force("charge",mt().strength(i)).force("links",xt(w.nodes.length?w.links:[]).distance(s).strength(a)),p=e.nodes(),b()}}()}function b(){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}function M(t){l={},t.forEach((function(t){l[t.id]=t}))}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?(M(t||[]),u=t||[],v):u},v.links=function(t){return arguments.length?(c=t||[],x(),v):c},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?(i="function"==typeof e?e:t(+e),x(),v):i},v.forceLinkDistance=function(e){return arguments.length?(s="function"==typeof e?e:t(+e),x(),v):s},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=b,v}var kt={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},It=function(){function t(t){void 0===t&&(t={}),this.options=t,this.id="d3force",this.running=!1,this.options=r(r({},kt),t)}return t.prototype.execute=function(t,e){return this.genericForceLayout(!1,t,e)},t.prototype.assign=function(t,e){this.genericForceLayout(!0,t,e)},t.prototype.stop=function(){var t;null===(t=this.forceSimulation)||void 0===t||t.stop(),this.running=!1},t.prototype.restart=function(){var t;null===(t=this.forceSimulation)||void 0===t||t.restart(),this.running=!0},t.prototype.tick=function(t){var e=this;void 0===t&&(t=1),this.forceSimulation.tick(t);var r={nodes:Dt(this.lastLayoutNodes),edges:_t(this.lastLayoutEdges)};return this.lastAssign&&r.nodes.forEach((function(t){return e.lastGraph.mergeNodeData(t.id,{x:t.data.x,y:t.data.y})})),this.lastOptions.onLayoutEnd&&this.lastOptions.onLayoutEnd(r),r},t.prototype.genericForceLayout=function(t,e,n){var o=this,i=r(r({},this.options),n),s=i.layoutInvisibles,a=e.getAllNodes(),h=e.getAllEdges();s||(a=a.filter((function(t){var e=(t.data||{}).visible;return e||void 0===e})),h=h.filter((function(t){var e=(t.data||{}).visible;return e||void 0===e})));var u=a.map((function(t){var e,n;return r(r({},v(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})})),l=h.map((function(t){return v(t)}));if(this.lastLayoutNodes=u,this.lastLayoutEdges=l,this.lastAssign=t,this.lastGraph=e,this.lastOptions=i,!this.running){var c=i.alphaMin,f=i.alphaDecay,d=i.alpha,g=i.nodeStrength,p=i.edgeStrength,y=i.linkDistance,m=i.clustering,w=i.clusterFociStrength,x=i.clusterEdgeDistance,b=i.clusterEdgeStrength,M=i.clusterNodeStrength,E=i.clusterNodeSize,N=i.collideStrength,S=void 0===N?1:N,A=i.center,k=void 0===A?[0,0]:A,I=i.preventOverlap,D=i.nodeSize,_=i.nodeSpacing,R=i.onTick,z=i.onLayoutEnd,T=i.forceSimulation;if(T)m&&((O=At()).nodes(u),O.links(l)),T.nodes(u),l&&(P=xt().id((function(t){return t.id})).links(l),p&&P.strength(p),y&&P.distance(y),T.force("link",P)),I&&this.overlapProcess(T,{nodeSize:D,nodeSpacing:_,collideStrength:S}),T.alpha(d).restart(),this.running=!0;else try{var O,C=mt();if(g&&C.strength(g),T=yt().nodes(u),m&&((O=At()).centerX(k[0]).centerY(k[1]).template("force").strength(w),l&&O.links(l),u&&O.nodes(u),O.forceLinkDistance(x).forceLinkStrength(b).forceCharge(M).forceNodeSize(E),T.force("group",O)),T.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}(k[0],k[1])).force("charge",C).alpha(d).alphaDecay(f).alphaMin(c),I&&this.overlapProcess(T,{nodeSize:D,nodeSpacing:_,collideStrength:S}),l){var P=xt().id((function(t){return t.id})).links(l);p&&P.strength(p),y&&P.distance(y),T.force("link",P)}T.on("tick",(function(){var r=Dt(u);null==R||R({nodes:r,edges:_t(l)}),t&&r.forEach((function(t){return e.mergeNodeData(t.id,{x:t.data.x,y:t.data.y})}))})).on("end",(function(){o.running=!1;var r=Dt(u);null==z||z({nodes:r,edges:_t(l)}),t&&r.forEach((function(t){return e.mergeNodeData(t.id,{x:t.data.x,y:t.data.y})}))})),this.running=!0}catch(t){this.running=!1,console.warn(t)}this.forceSimulation=T;var q=Dt(u),L=_t(l);return t&&q.forEach((function(t){return e.mergeNodeData(t.id,{x:t.data.x,y:t.data.y})})),{nodes:q,edges:L}}},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}:x(i)?i:function(){return 0},o)if(x(o))r=function(t){return o(t)+n(t)};else if(c(o)){var a=(o[0]>o[1]?o[0]:o[1])/2;r=function(t){return a+n(t)}}else if(m(o)){var h=o/2;r=function(t){return h+n(t)}}else r=function(){return 10};else r=function(t){return t.size?c(t.size)?(t.size[0]>t.size[1]?t.size[0]:t.size[1])/2+n(t):b(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",Et(r).strength(s))},t}(),Dt=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})})}))},_t=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 Rt(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 zt={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"},Tt=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({},zt),t)}return t.prototype.execute=function(t,e){return this.genericForceLayout(!1,t,e)},t.prototype.assign=function(t,e){this.genericForceLayout(!0,t,e)},t.prototype.stop=function(){this.timeInterval&&"undefined"!=typeof window&&window.clearInterval(this.timeInterval),this.running=!1},t.prototype.restart=function(){this.running=!0},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})})),this.lastOptions.onLayoutEnd&&this.lastOptions.onLayoutEnd(n),n},t.prototype.genericForceLayout=function(t,e,n){var o=this,i=r(r({},this.options),n),s=e.getAllNodes(),a=e.getAllEdges();i.layoutInvisibles||(s=s.filter((function(t){return t.data.visible||void 0===t.data.visible})),a=a.filter((function(t){return t.data.visible||void 0===t.data.visible})));var h=this.formatOptions(i,e),l=h.width,c=h.height,f=h.nodeSize,d=h.getMass,g=h.nodeStrength,p=h.edgeStrength,y=h.linkDistance,w=s.map((function(t){return r(r({},t),{data:r(r({},t.data),{x:m(t.data.x)?t.data.x:Math.random()*l,y:m(t.data.y)?t.data.y:Math.random()*c,size:f(t)||30,mass:d(t),nodeStrength:g(t)})})})),v=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))})})}));if(!(null==s?void 0:s.length))return this.lastResult={nodes:[],edges:a},{nodes:[],edges:a};var x={};s.forEach((function(t,e){x[t.id]={x:0,y:0}}));var b=new u({nodes:w,edges:v});this.formatCentripetal(h,b);var M=h.maxIteration,E=h.minMovement,N=h.onLayoutEnd,S=h.onTick;if(this.lastLayoutNodes=w,this.lastLayoutEdges=v,this.lastAssign=t,this.lastGraph=e,this.lastCalcGraph=b,this.lastOptions=h,this.lastVelMap=x,"undefined"!=typeof window){var A=0;return this.timeInterval=window.setInterval((function(){s&&o.running&&(o.runOneStep(b,e,A,x,h),o.updatePosition(e,b,x,h),t&&w.forEach((function(t){return e.mergeNodeData(t.id,{x:t.data.x,y:t.data.y})})),null==S||S({nodes:Lt(e,w),edges:a}),(++A>=M||o.judgingDistance<E)&&(null==N||N({nodes:Lt(e,w),edges:a}),window.clearInterval(o.timeInterval)))}),0),this.running=!0,{nodes:Lt(e,w),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=M(0,t.nodeSpacing);t.nodeSize?c(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?c(e)?Math.max(e[0],e[1])+s(t):b(e)?Math.max(e.width,e.height)+s(t):e+s(t):10+s(t)}}return r.linkDistance=t.linkDistance?M(1,t.linkDistance):function(t){return 1+r.nodeSize(e.getNode(t.source))+r.nodeSize(e.getNode(t.target))},r.nodeStrength=M(1,t.nodeStrength),r.edgeStrength=M(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(),l=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(s&&h&&(r=Ot(e,h),c=Array.from(new Set(null==u?void 0:u.map((function(t){return t.data[h]}))))||[],t.centripetalOptions=Object.assign(l,{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,s=void 0===i?[]:i;1===s.length?n=void 0:s.length>1&&(n=qt(s))}else n=void 0;return{x:null==n?void 0:n.x,y:null==n?void 0:n.y}}})),a&&h){r||(r=Ot(e,h)),c||(c=Array.from(new Set(u.map((function(t){return t.data[h]}))))),c=c.filter((function(t){return void 0!==t}));var f={};c.forEach((function(t){var r=u.filter((function(e){return e.data[h]===t})).map((function(t){return e.getNode(t.id)}));f[t]=qt(r)})),t.centripetalOptions=Object.assign(l,{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=P(s,(function(t){return t.x}),(function(t){return t.y})).visitAfter(Rt);s.forEach((function(t){!function(t,e){e.visit((function(e,r,n,o,i){return 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,l=Math.sqrt(u)*u;if(h*h*.81<u){var c=t.weight/l;return i.vx+=s*c,i.vy+=a*c,!0}if(t.length)return!1;t.data!==i&&(c=t.data.weight/l,i.vx+=s*c,i.vy+=a*c)}(e,r,0,o,0,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 l=Math.sqrt(h*h+u*u),c=h/l,f=u/l,d=r.data||{},g=d.linkDistance,p=void 0===g?200:g,y=d.edgeStrength,m=(p-l)*(void 0===y?200:y),w=1/(s.data.mass||1),v=1/(a.data.mass||1),x=c*m,b=f*m;e[o].x-=x*w,e[o].y-=b*w,e[i].x+=x*v,e[i].y+=b*v}}))},t.prototype.calGravity=function(t,e,r,n){var i=n.getCenter,s=t.getAllNodes(),a=e.getAllNodes(),h=e.getAllEdges(),u=n.width,l=n.height,c=n.center,f=n.gravity,d=n.centripetalOptions;s&&s.forEach((function(n){var s=n.id,g=n.data,p=g.mass,y=g.x,w=g.y,v=e.getNode(s),x=0,b=0,M=f,E=t.getDegree(s,"in"),N=t.getDegree(s,"out"),S=t.getDegree(s,"both"),A=null==i?void 0:i(v,S);if(A){var k=o(A,3);x=y-k[0],b=w-k[1],M=k[2]}else x=y-c[0],b=w-c[1];if(M&&(r[s].x-=M*x/p,r[s].y-=M*b/p),d){var I=d.leaf,D=d.single,_=d.others,R=d.center,z=(null==R?void 0:R(v,a,h,u,l))||{x:0,y:0,centerStrength:0},T=z.x,O=z.y,C=z.centerStrength;if(!m(T)||!m(O))return;var P=(y-T)/p,q=(w-O)/p;if(C&&(r[s].x-=C*P,r[s].y-=C*q),0===S){var L=D(v);if(!L)return;return r[s].x-=L*P,void(r[s].y-=L*q)}if(0===E||0===N){var F=I(v,a,h);if(!F)return;return r[s].x-=F*P,void(r[s].y-=F*q)}var j=_(v);if(!j)return;r[s].x-=j*P,r[s].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 l=i/u;a*=l,h*=l}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(m(u.data.fx)&&m(u.data.fy))e.mergeNodeData(a,{x:u.data.fx,y:u.data.fy});else{var l=r[a].x*s,c=r[a].y*s;e.mergeNodeData(a,{x:n.data.x+l,y:n.data.y+c});var f=Math.sqrt(l*l+c*c);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}(),Ot=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]=Ct(t,"leaf",r,e))})),n},Ct=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:Pt(t,e,n,r,a)}},Pt=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},qt=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}},Lt=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})})}))},Ft=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 jt=Ft;const Vt=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}(),Wt=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 $t={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},Gt=function(){function t(t){void 0===t&&(t={}),this.options=t,this.id="forceAtlas2",this.options=r(r({},$t),t)}return t.prototype.execute=function(t,e){return this.genericForceAtlas2Layout(!1,t,e)},t.prototype.assign=function(t,e){this.genericForceAtlas2Layout(!0,t,e)},t.prototype.genericForceAtlas2Layout=function(t,e,n){var o=e.getAllEdges(),i=e.getAllNodes(),s=this.formatOptions(n,i.length),a=s.width,h=s.height,l=s.prune,c=s.maxIteration,f=s.nodeSize,d=s.center,g=s.onLayoutEnd;if(!(null==i?void 0:i.length)||1===i.length)return N(e,t,d,g);var p=i.map((function(t){return v(t,[a,h])})),y=o.filter((function(t){return t.source!==t.target})),m=new u({nodes:p,edges:y}),w=this.getSizes(m,e,f);if(this.run(m,e,c,w,t,s),l){for(var x=0;x<y.length;x+=1){var b=y[x],M=b.source,E=b.target,S=m.getDegree(M),A=m.getDegree(M);if(S<=1){var k=m.getNode(E);m.mergeNodeData(M,{x:k.data.x,y:k.data.y})}else if(A<=1){var I=m.getNode(M);m.mergeNodeData(E,{x:I.data.x,y:I.data.y})}}var D=r(r({},s),{prune:!1,barnesHut:!1});this.run(m,e,100,w,t,D)}var _={nodes:p,edges:o};return null==g||g(_),_},t.prototype.getSizes=function(t,e,r){for(var n=t.getAllNodes(),s={},a=0;a<n.length;a+=1){var h=n[a],u=h.id,l=h.data;if(s[u]=10,m(l.size))s[u]=l.size;else if(c(l.size))isNaN(l.size[0])||(s[u]=Math.max(l.size[0])),isNaN(l.size[1])||(s[u]=Math.max(l.size[1]));else if(b(l.size))s[u]=Math.max(l.size.width,l.size.height);else if(x(r)){var f=r(e.getNode(u));c(f)?s[u]=Math.max.apply(Math,i([],o(f),!1)):s[u]=f}else c(r)?s[u]=Math.max.apply(Math,i([],o(r),!1)):m(r)&&(s[u]=r)}return s},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,l=n.kr,c=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)),l||(n.kr=50,e>100&&e<=500?n.kr=20:e>500&&(n.kr=1)),c||(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(),l=0,c=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 jt(v)}}for(;c>0;)l=this.oneStep(t,{iter:c,preventOverlapIters:50,krPrime:100,sg:l,forces:f,preForces:d,bodies:g,sizes:n},i),c--,null==h||h({nodes:u,edges:e.getAllEdges()});return t},t.prototype.oneStep=function(t,e,r){for(var n=e.iter,s=e.preventOverlapIters,a=e.krPrime,h=e.sg,u=e.preForces,l=e.bodies,c=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]=i([],o(f[m]),!1),f[m]=[0,0]}return f=this.getAttrForces(t,n,s,c,f,r),f=g&&(d&&n>s||!d)?this.getOptRepGraForces(t,f,l,r):this.getRepGraForces(t,n,s,f,a,c,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,l=t.getAllEdges(),c=0;c<l.length;c+=1){var f=l[c],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 b=x,M=b;"linlog"===h&&(M=b=Math.log(1+x)),a&&(b=x/m,M=x/w),s&&e<r&&x<=0?(b=0,M=0):s&&e<r&&x>0&&(b=x,M=x),o[d][0]+=b*v[0],o[g][0]-=M*v[0],o[d][1]+=b*v[1],o[g][1]-=M*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,l=-9e10,c=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>=l&&(l=y.x),y.x<=u&&(u=y.x),y.y>=f&&(f=y.y),y.y<=c&&(c=y.y))}var m=Math.max(l-u,f-c),w=new Vt({xmid:(l+u)/2,ymid:(f+c)/2,length:m,massCenter:i,mass:h}),v=new Wt(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],b=(p=x.id,y=x.data,t.getDegree(p));if(!(s&&b<=1)){r[p].resetForce(),v.updateForce(r[p]),e[p][0]-=r[p].fx,e[p][1]-=r[p].fy;var M=[y.x-i[0],y.y-i[1]],E=Math.hypot(M[0],M[1]);E=E<1e-4?1e-4:E,M[0]=M[0]/E,M[1]=M[1]/E;var N=o*(b+1);e[p][0]-=N*M[0],e[p][1]-=N*M[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,l=s.center,c=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(!c||!(y<=1||v<=1)){var x=[w.data.x-p.data.x,w.data.y-p.data.y],b=Math.hypot(x[0],x[1]);b=b<1e-4?1e-4:b,x[0]=x[0]/b,x[1]=x[1]/b,a&&e<r&&(b=b-i[p.id]-i[w.id]);var M=h*(y+1)*(v+1)/b;a&&e<r&&b<0?M=o*(y+1)*(v+1):a&&e<r&&0===b?M=0:a&&e<r&&b>0&&(M=h*(y+1)*(v+1)/b),n[p.id][0]-=M*x[0],n[w.id][0]+=M*x[0],n[p.id][1]-=M*x[1],n[w.id][1]+=M*x[1]}}var E=[p.data.x-l[0],p.data.y-l[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(),l=u.length,c=[],f=[],d=0,g=0,p=n,y=0;y<l;y+=1){var w=u[y].id,v=t.getDegree(w);if(!(a&&v<=1)){var x=[e[w][0]-r[w][0],e[w][1]-r[w][1]],b=Math.hypot(x[0],x[1]),M=[e[w][0]+r[w][0],e[w][1]+r[w][1]],E=Math.hypot(M[0],M[1]);c[y]=b,f[y]=E/2,d+=(v+1)*c[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<l;y+=1){var S=u[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(c[y])),I=Math.hypot(e[w][0],e[w][1]),D=h/(I=I<1e-4?1e-4:I),_=(k=k>D?D:k)*e[w][0],R=k*e[w][1];t.mergeNodeData(w,{x:A.x+_,y:A.y+R})}}return p},t}(),Ut={maxIteration:1e3,gravity:10,speed:5,clustering:!1,clusterGravity:10,width:300,height:300,nodeClusterBy:"cluster"},Bt=function(){function t(t){void 0===t&&(t={}),this.options=t,this.id="fruchterman",this.timeInterval=0,this.running=!1,this.options=r(r({},Ut),t)}return t.prototype.execute=function(t,e){return this.genericFruchtermanLayout(!1,t,e)},t.prototype.assign=function(t,e){this.genericFruchtermanLayout(!0,t,e)},t.prototype.stop=function(){this.timeInterval&&"undefined"!=typeof window&&window.clearInterval(this.timeInterval),this.running=!1},t.prototype.restart=function(){this.running=!0},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})})),this.lastOptions.onLayoutEnd&&this.lastOptions.onLayoutEnd(n),n},t.prototype.genericFruchtermanLayout=function(t,e,n){var o=this;if(!this.running){var i=this.formatOptions(n),s=i.layoutInvisibles,a=i.width,h=i.height,l=i.center,c=i.clustering,f=i.nodeClusterBy,d=i.maxIteration,g=i.onTick,p=i.onLayoutEnd,y=e.getAllNodes(),m=e.getAllEdges();if(s||(y=y.filter((function(t){var e=(t.data||{}).visible;return e||void 0===e})),m=m.filter((function(t){var e=(t.data||{}).visible;return e||void 0===e}))),!(null==y?void 0:y.length)){var w={nodes:[],edges:m};return this.lastResult=w,null==p||p(w),w}if(1===y.length)return t&&e.mergeNodeData(y[0].id,{x:l[0],y:l[1]}),w={nodes:[r(r({},y[0]),{data:r(r({},y[0].data),{x:l[0],y:l[1]})})],edges:m},this.lastResult=w,null==p||p(w),w;var x=y.map((function(t){return v(t,[a,h])})),b=new u({nodes:x,edges:m}),M={};if(c&&x.forEach((function(t){var e=t.data[f];M[e]||(M[e]={name:e,cx:0,cy:0,count:0})})),this.lastLayoutNodes=x,this.lastLayoutEdges=m,this.lastAssign=t,this.lastGraph=b,this.lastOptions=i,this.lastClusterMap=M,"undefined"!=typeof window){var E=0;return this.timeInterval=window.setInterval((function(){if(o.running&&(o.runOneStep(b,M,i),t&&x.forEach((function(t){var r=t.id,n=t.data;return e.mergeNodeData(r,{x:n.x,y:n.y})})),null==g||g({nodes:x,edges:m}),++E>=d)){try{null==p||p({nodes:x,edges:m})}catch(t){console.warn("onLayoutEnd failed",t)}window.clearInterval(o.timeInterval)}}),0),this.running=!0,{nodes:x,edges:m}}}},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,l=r.clusterGravity,c=n*o,f=Math.sqrt(c)/10,d=t.getAllNodes(),g=c/(d.length+1),p=Math.sqrt(g),y={};if(this.applyCalculate(t,y,p,g),h){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[u]];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=l||i;d.forEach((function(t,r){var n=t.id,o=t.data;if(m(o.x)&&m(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*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,h=t.id;if(!(o<=n)&&m(i.x)&&m(a.x)&&m(i.y)&&m(a.y)){var u=i.x-a.x,l=i.y-a.y,c=u*u+l*l;0===c&&(c=1,u=.01,l=.01);var f=r/c,d=u*f,g=l*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(m(a.x)&&m(s.x)&&m(a.y)&&m(s.y)){var h=a.x-s.x,u=a.y-s.y,l=Math.sqrt(h*h+u*u)/r,c=h*l,f=u*l;e[o].x+=c,e[o].y+=f,e[i].x-=c,e[i].y-=f}}}))},t}(),Ht={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},Kt=function(){function t(t){void 0===t&&(t={}),this.options=t,this.id="grid",this.options=r(r({},Ht),t)}return t.prototype.execute=function(t,e){return this.genericGridLayout(!1,t,e)},t.prototype.assign=function(t,e){this.genericGridLayout(!0,t,e)},t.prototype.genericGridLayout=function(t,e,n){var o=r(r({},this.options),n),i=o.begin,s=void 0===i?[0,0]:i,a=o.condense,h=o.preventOverlapPadding,u=o.preventOverlap,l=o.rows,f=o.cols,d=o.nodeSpacing,g=o.nodeSize,p=o.width,y=o.height,w=o.layoutInvisibles,x=o.onLayoutEnd,b=o.position,S=o.sortBy,A=e.getAllNodes(),k=e.getAllEdges();w||(A=A.filter((function(t){var e=(t.data||{}).visible;return e||void 0===e})),k=k.filter((function(t){var e=(t.data||{}).visible;return e||void 0===e})));var I=null==A?void 0:A.length;if(!I||1===I)return N(e,t,s,x);var _=A.map((function(t){return v(t)}));"id"===S||D(S)&&void 0!==_[0].data[S]||(S="degree"),"degree"===S?_.sort((function(t,r){return e.getDegree(r.id,"both")-e.getDegree(t.id,"both")})):"id"===S?_.sort((function(t,e){return m(e.id)&&m(t.id)?e.id-t.id:"".concat(t.id).localeCompare("".concat(e.id))})):_.sort((function(t,e){return e.data[S]-t.data[S]}));var R=p||"undefined"==typeof window?p:window.innerWidth,z=y||"undefined"==typeof window?y:window.innerHeight,T=I,O={rows:l,cols:f};if(null!=l&&null!=f)O.rows=l,O.cols=f;else if(null!=l&&null==f)O.rows=l,O.cols=Math.ceil(T/O.rows);else if(null==l&&null!=f)O.cols=f,O.rows=Math.ceil(T/O.cols);else{var C=Math.sqrt(T*z/R);O.rows=Math.round(C),O.cols=Math.round(R/z*C)}if(O.rows=Math.max(O.rows,1),O.cols=Math.max(O.cols,1),O.cols*O.rows>T)((q=Jt(O))-1)*(P=Yt(O))>=T?Jt(O,q-1):(P-1)*q>=T&&Yt(O,P-1);else for(;O.cols*O.rows<T;){var P,q=Jt(O);((P=Yt(O))+1)*q>=T?Yt(O,P+1):Jt(O,q+1)}var L=a?0:R/O.cols,F=a?0:z/O.rows;if(u||d){var j=M(10,d),V=E(30,g,!1);_.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=V(o)||30;c(i)?(r=i[0],n=i[1]):(r=i,n=i);var s=void 0!==j?j(t):h,a=r+s,u=n+s;L=Math.max(L,a),F=Math.max(F,u)}))}for(var W={},$={row:0,col:0},G={},U=0;U<_.length;U++){var B=_[U],H=void 0;if(b&&(H=b(e.getNode(B.id))),H&&(void 0!==H.row||void 0!==H.col)){var K={row:H.row,col:H.col};if(void 0===K.col)for(K.col=0;Xt(W,K);)K.col++;else if(void 0===K.row)for(K.row=0;Xt(W,K);)K.row++;G[B.id]=K,Qt(W,K)}te(B,s,L,F,G,O,$,W)}var J={nodes:_,edges:k};return null==x||x(J),t&&_.forEach((function(t){e.mergeNodeData(t.id,{x:t.data.x,y:t.data.y})})),J},t}(),Jt=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},Yt=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},Xt=function(t,e){return t["c-".concat(e.row,"-").concat(e.col)]||!1},Qt=function(t,e){return t["c-".concat(e.row,"-").concat(e.col)]=!0},Zt=function(t,e){var r=t.cols||5;e.col++,e.col>=r&&(e.col=0,e.row++)},te=function(t,e,r,n,o,i,s,a){var h,u,l=o[t.id];if(l)h=l.col*r+r/2+e[0],u=l.row*n+n/2+e[1];else{for(;Xt(a,s);)Zt(i,s);h=s.col*r+r/2+e[0],u=s.row*n+n/2+e[1],Qt(a,s),Zt(i,s)}t.data.x=h,t.data.y=u};const ee=Object.prototype.toString;function re(t){return ee.call(t).endsWith("Array]")}function ne(t){var e=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};if(!re(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}function oe(t){var e=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};if(!re(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}function ie(t){var e,r=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};if(!re(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(!re(r.output))throw new TypeError("output option must be an array if specified");e=r.output}else e=new Array(t.length);var n=oe(t),o=ne(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),l=0;l<t.length;l++)e[l]=(t[l]-n)*u+s;return e}const se=" ".repeat(2),ae=" ".repeat(4);function he(t,e={}){const{maxRows:r=15,maxColumns:n=10,maxNumSize:o=8,padMinus:i="auto"}=e;return`${t.constructor.name} {\\n${se}[\\n${ae}${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(ue(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${ae}`)}(t,r,n,o,i)}\\n${se}]\\n${se}rows: ${t.rows}\\n${se}columns: ${t.columns}\\n}`}function ue(t,e,r){return(t>=0&&r?` ${le(t,e-1)}`:le(t,e)).padEnd(e)}function le(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 ce(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 fe(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 de(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 ge(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 pe(t,e,r,n,o){if(5!==arguments.length)throw new RangeError("expected 4 arguments");if(me("startRow",e),me("endRow",r),me("startColumn",n),me("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 ye(t,e=0){let r=[];for(let n=0;n<t;n++)r.push(e);return r}function me(t,e){if("number"!=typeof e)throw new TypeError(`${t} must be a number`)}function we(t){if(t.isEmpty())throw new Error("Empty matrix has no elements to index")}class ve{static from1DArray(t,e,r){if(t*e!==r.length)throw new RangeError("data length does not match given dimensions");let n=new be(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 be(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 be(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 be(t,e)}static ones(t,e){return new be(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 be(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 be(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 be(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 ve.isMatrix(t)?t:new be(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 be(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){ce(this,t);let e=[];for(let r=0;r<this.columns;r++)e.push(this.get(t,r));return e}getRowVector(t){return be.rowVector(this.getRow(t))}setRow(t,e){ce(this,t),e=de(this,e);for(let r=0;r<this.columns;r++)this.set(t,r,e[r]);return this}swapRows(t,e){ce(this,t),ce(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){fe(this,t);let e=[];for(let r=0;r<this.rows;r++)e.push(this.get(r,t));return e}getColumnVector(t){return be.columnVector(this.getColumn(t))}setColumn(t,e){fe(this,t),e=ge(this,e);for(let r=0;r<this.rows;r++)this.set(r,t,e[r]);return this}swapColumns(t,e){fe(this,t),fe(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=de(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=de(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=de(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=de(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=ge(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=ge(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=ge(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=ge(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){ce(this,t);for(let r=0;r<this.columns;r++)this.set(t,r,this.get(t,r)*e);return this}mulColumn(t,e){fe(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(){we(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(){we(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(ce(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){ce(this,t),we(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(ce(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){ce(this,t),we(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(fe(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){fe(this,t),we(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(fe(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){fe(this,t),we(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){ve.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=be.checkMatrix(t);let e=this.rows,r=this.columns,n=t.columns,o=new be(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=be.checkMatrix(t);let e=new be(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),l=(r+h)*(n+u),c=(s+h)*n,f=r*(i-u),d=h*(a-n),g=(r+o)*u,p=l+d-g+(o-h)*(a+u),y=f+g,m=c+d,w=l-c+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=be.checkMatrix(t);let e=new be(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),l=this.get(2,2),c=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),b=(-r+i+s)*(c-f+p),M=(i+s)*(-c+f),E=r*c,N=(-r+h+u)*(c-d+y),S=(-r+h)*(d-y),A=(h+u)*(-c+d),k=(-o+u+l)*(p+m-w),I=(o-l)*(p-w),D=o*m,_=(u+l)*(-m+w),R=(-o+s+a)*(y+m-v),z=(o-a)*(y-v),T=(s+a)*(-m+v),O=E+D+n*g,C=(r+n+o-i-s-u-l)*p+b+M+E+k+D+_,P=E+N+A+(r+n+o-s-a-h-u)*y+D+R+T,q=x+s*(-c+f+g-p-y-m+v)+b+E+D+R+z,L=x+b+M+E+a*w,F=D+R+z+T+i*d,j=E+N+S+u*(-c+d+g-p-y-m+w)+k+I+D,V=k+I+D+_+h*f,W=E+N+S+A+l*v;return e.set(0,0,O),e.set(0,1,C),e.set(0,2,P),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=be.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=ve.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),l=e.subMatrix(0,i-1,a,e.columns-1),c=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(ve.add(h,g),ve.add(u,p),i,a),m=t(ve.add(f,g),u,i,a),w=t(h,ve.sub(c,p),i,a),v=t(g,ve.sub(d,u),i,a),x=t(ve.add(h,l),p,i,a),b=t(ve.sub(f,h),ve.add(u,c),i,a),M=t(ve.sub(l,g),ve.add(d,p),i,a),E=ve.add(y,v);E.sub(x),E.add(M);let N=ve.add(w,x),S=ve.add(m,v),A=ve.sub(y,m);A.add(w),A.add(b);let k=ve.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 be(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 be(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=be.checkMatrix(t);let e=this.rows,r=this.columns,n=t.rows,o=t.columns,i=new be(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=be.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(be.eye(r,r)),o=be.eye(e,e).kroneckerProduct(t);return n.add(o)}transpose(){let t=new be(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=xe){for(let e=0;e<this.rows;e++)this.setRow(e,this.getRow(e).sort(t));return this}sortColumns(t=xe){for(let e=0;e<this.columns;e++)this.setColumn(e,this.getColumn(e).sort(t));return this}subMatrix(t,e,r,n){pe(this,t,e,r,n);let o=new be(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 be(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 be(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=be.checkMatrix(t)).isEmpty())return this;pe(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(!re(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(!re(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 be(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 be(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=ye(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=ye(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=ye(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=ye(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(!re(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(!re(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(!re(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(!re(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(!re(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(!re(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 he(this,t)}}function xe(t,e){return t-e}ve.prototype.klass="Matrix","undefined"!=typeof Symbol&&(ve.prototype[Symbol.for("nodejs.util.inspect.custom")]=function(){return he(this)}),ve.random=ve.rand,ve.randomInt=ve.randInt,ve.diagonal=ve.diag,ve.prototype.diagonal=ve.prototype.diag,ve.identity=ve.eye,ve.prototype.negate=ve.prototype.neg,ve.prototype.tensorProduct=ve.prototype.kroneckerProduct;class be extends ve{constructor(t,e){if(super(),be.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(!re(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 ce(this,t),this.data.splice(t,1),this.rows-=1,this}addRow(t,e){return void 0===e&&(e=t,t=this.rows),ce(this,t,!0),e=Float64Array.from(de(this,e)),this.data.splice(t,0,e),this.rows+=1,this}removeColumn(t){fe(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),fe(this,t,!0),e=ge(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}}(ve,be);class Me extends ve{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 Ee(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 Ne{constructor(t,e={}){if((t=Me.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),l=!1;if(r<n)if(s){a=t.transpose(),r=a.rows,n=a.columns,l=!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 c=Math.min(r,n),f=Math.min(r+1,n),d=new Float64Array(f),g=new be(r,c),p=new be(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)),b=Math.max(v,x);for(let t=0;t<b;t++){if(t<v){d[t]=0;for(let e=t;e<r;e++)d[t]=Ee(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]=Ee(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 M=Math.min(n,r+1);if(v<n&&(d[v]=a.get(v,v)),r<M&&(d[M-1]=0),x+1<M&&(y[x]=a.get(x,M-1)),y[M-1]=0,h){for(let t=v;t<c;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<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(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=M-1,N=0,S=Number.EPSILON;for(;M>0;){let t,e;for(t=M-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===M-2)e=4;else{let r;for(r=M-1;r>=t&&r!==t;r--){let e=(r!==M?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===M-1?e=1:(e=2,t=r)}switch(t++,e){case 1:{let e=y[M-2];y[M-2]=0;for(let r=M-2;r>=t;r--){let o=Ee(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,M-1),p.set(t,M-1,-s*p.get(t,r)+i*p.get(t,M-1)),p.set(t,r,o)}break}case 2:{let e=y[t-1];y[t-1]=0;for(let n=t;n<M;n++){let o=Ee(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[M-1]),Math.abs(d[M-2]),Math.abs(y[M-2]),Math.abs(d[t]),Math.abs(y[t])),o=d[M-1]/e,i=d[M-2]/e,s=y[M-2]/e,a=d[t]/e,l=y[t]/e,c=((i+o)*(i-o)+s*s)/2,f=o*s*(o*s);let m=0;0===c&&0===f||(m=c<0?0-Math.sqrt(c*c+f):Math.sqrt(c*c+f),m=f/(c+m));let w=(a+o)*(a-o)+m,v=a*l;for(let e=t;e<M-1;e++){let o=Ee(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=Ee(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[M-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,M--}}if(l){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=be.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,l=be.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);l.set(t,e,r)}return l.mmul(e)}solveForDiagonal(t){return this.solve(be.diag(t))}inverse(){let t=this.V,e=this.threshold,r=t.rows,n=t.columns,o=new be(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 be(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 be.diag(this.s)}}var Se,Ae={center:[0,0],linkDistance:50},ke=function(){function t(t){void 0===t&&(t={}),this.options=t,this.id="mds",this.options=r(r({},Ae),t)}return t.prototype.execute=function(t,e){return this.genericMDSLayout(!1,t,e)},t.prototype.assign=function(t,e){this.genericMDSLayout(!0,t,e)},t.prototype.genericMDSLayout=function(t,e,n){var o=r(r({},this.options),n),i=o.center,s=void 0===i?[0,0]:i,a=o.linkDistance,h=void 0===a?50:a,u=o.layoutInvisibles,l=o.onLayoutEnd,c=e.getAllNodes(),g=e.getAllEdges();if(u||(c=c.filter((function(t){var e=(t.data||{}).visible;return e||void 0===e})),g=g.filter((function(t){var e=(t.data||{}).visible;return e||void 0===e}))),!(null==c?void 0:c.length)||1===c.length)return N(e,t,s,l);var p=d({nodes:c,edges:g},!1),y=f(p);Ie(y);var m=function(t,e){var r=[];return t.forEach((function(t){var n=[];t.forEach((function(t){n.push(t*e)})),r.push(n)})),r}(y,h),w=De(m),x=[];w.forEach((function(t,e){var r=v(c[e]);r.data.x=t[0]+s[0],r.data.y=t[1]+s[1],x.push(r)})),t&&x.forEach((function(t){return e.mergeNodeData(t.id,{x:t.data.x,y:t.data.y})}));var b={nodes:x,edges:g};return null==l||l(b),b},t}(),Ie=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)}))}))},De=function(t){var e=be.mul(be.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 Ne(e),s=be.sqrt(i.diagonalMatrix).diagonal();return i.leftSingularVectors.toJSON().map((function(t){return be.mul([t],[s]).toJSON()[0].splice(0,2)}))},_e={iterations:10,height:10,width:10,speed:100,gravity:10,k:5},Re=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,l=s.y-e.y,c=Math.sqrt(u*u+l*l);if(0===c){c=1;var f=a>h?1:-1;u=.01*f,l=.01*f}if(c<i(t[a])/2+i(t[h])/2){var d=n*n/c;r[a].x+=u/c*d,r[a].y+=l/c*d}}}))}))},ze=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),l=Math.acos((a*e.x+h*e.y)/u);l>Math.PI/2&&(l-=Math.PI/2,a*=-1,h*=-1);var c=Math.cos(l)*u;e.x=a*c,e.y=h*c})),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 l=Math.min(h*(r/800),u);if(i.x+=e[s].x/u*l,i.y+=e[s].y/u*l,n){var c=i.x-t[o].x,f=i.y-t[o].y,d=Math.sqrt(c*c+f*f);c=c/d*a[s],f=f/d*a[s],i.x=t[o].x+c,i.y=t[o].y+f}}}})),t},Te={maxIteration:1e3,focusNode:null,unitRadius:null,linkDistance:50,preventOverlap:!1,strictRadial:!0,maxPreventOverlapIteration:200,sortStrength:10},Oe=function(){function t(t){void 0===t&&(t={}),this.options=t,this.id="radial",this.options=r(r({},Te),t)}return t.prototype.execute=function(t,e){return this.genericRadialLayout(!1,t,e)},t.prototype.assign=function(t,e){this.genericRadialLayout(!0,t,e)},t.prototype.genericRadialLayout=function(t,e,n){var s=r(r({},this.options),n),a=s.width,h=s.height,u=s.center,l=s.focusNode,c=s.unitRadius,g=s.nodeSize,p=s.nodeSpacing,y=s.strictRadial,m=s.preventOverlap,w=s.maxPreventOverlapIteration,x=s.sortBy,b=s.linkDistance,M=void 0===b?50:b,E=s.sortStrength,S=void 0===E?10:E,A=s.maxIteration,k=void 0===A?1e3:A,I=s.layoutInvisibles,_=s.onLayoutEnd,R=e.getAllNodes(),z=e.getAllEdges();I||(R=R.filter((function(t){var e=(t.data||{}).visible;return e||void 0===e})),z=z.filter((function(t){var e=(t.data||{}).visible;return e||void 0===e})));var T=a||"undefined"==typeof window?a:window.innerWidth,O=h||"undefined"==typeof window?h:window.innerHeight,C=u||[T/2,O/2];if(!(null==R?void 0:R.length)||1===R.length)return N(e,t,C,_);var P=R[0];if(D(l)){for(var q=0;q<R.length;q++)if(R[q].id===l){P=R[q];break}}else P=l||R[0];var L=qe(R,P.id),F=d({nodes:R,edges:z},!1),j=f(F),V=Fe(j,L);Le(j,L,V+1);var W=j[L],$=T-C[0]>C[0]?C[0]:T-C[0],G=O-C[1]>C[1]?C[1]:O-C[1];0===$&&($=T/2),0===G&&(G=O/2);var U=Math.min($,G),B=Math.max.apply(Math,i([],o(W),!1)),H=[],K=c||U/B;W.forEach((function(t,e){H[e]=t*K}));var J,Y=Ce(R,j,M,H,K,x,S),X=Pe(Y),Q=function(t,e,r){try{var n=be.mul(be.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 Ne(n),h=be.sqrt(a.diagonalMatrix).diagonal();return a.leftSingularVectors.toJSON().map((function(e){return be.mul([e],[h]).toJSON()[0].splice(0,t)}))}catch(t){for(var u=[],l=0;l<e.length;l++){var c=Math.random()*r,f=Math.random()*r;u.push([c,f])}return u}}(M,Y,M),Z=Q.map((function(t){var e=o(t,2),r=e[0],n=e[1];return{x:(isNaN(r)?Math.random()*M:r)-Q[L][0],y:(isNaN(n)?Math.random()*M:n)-Q[L][1]}}));if(this.run(k,Z,X,Y,H,L),m){J=je(g,p);var tt={nodes:R,nodeSizeFunc:J,positions:Z,radii:H,height:O,width:T,strictRadial:Boolean(y),focusIdx:L,iterations:w||200,k:Z.length/4.5};Z=function(t,e){for(var n=r(r({},_e),e),o=n.positions,i=n.iterations,s=n.width,a=n.k,h=n.speed,u=void 0===h?100:h,l=n.strictRadial,c=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}})),Re(p,o,y,a,d,g),ze(o,y,u,l,c,m,s,d);return o}(e,tt)}var et=[];Z.forEach((function(t,e){var r=v(R[e]);r.data.x=t.x+C[0],r.data.y=t.y+C[1],et.push(r)})),t&&et.forEach((function(t){return e.mergeNodeData(t.id,{x:t.data.x,y:t.data.y})}));var rt={nodes:et,edges:z};return null==_||_(rt),rt},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=g(a,{x:0,y:0}),l=0===u?0:1/u;if(h!==i){var c=0,f=0,d=0;e.forEach((function(t,e){if(h!==e){var r=g(a,t),i=0===r?0:1/r,s=n[e][h];d+=o[h][e],c+=o[h][e]*(t.x+s*(a.x-t.x)*i),f+=o[h][e]*(t.y+s*(a.y-t.y)*i)}}));var p=0===r[h]?0:1/r[h];d*=s,d+=t*p*p,c*=s,c+=t*p*a.x*l,a.x=c/d,f*=s,f+=t*p*a.y*l,a.y=f/d}}))},t}(),Ce=function(t,e,r,n,o,i,s){if(!t)return[];var a=[];if(e){var h={};e.forEach((function(e,u){var l=[];e.forEach((function(e,a){var c,f;if(u===a)l.push(0);else if(n[u]===n[a])if("data"===i)l.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===(c=t[u].data)||void 0===c?void 0:c[i])||0;d=D(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=D(p)?p.charCodeAt(0):p,h[t[a].id]=g),l.push(e*(Math.abs(d-g)*s)/(n[u]/o))}else l.push(e*r/(n[u]/o));else{var y=(r+o)/2;l.push(e*y)}})),a.push(l)}))}return a},Pe=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},qe=function(t,e){var r=-1;return t.forEach((function(t,n){t.id===e&&(r=n)})),Math.max(r,0)},Le=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}},Fe=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},je=function(t,e){var r;return r=m(e)?function(){return e}:x(e)?e:function(){return 0},t?c(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(c(t.data.size))return Math.max(t.data.size[0],t.data.size[1])+r(t);var o=t.data.size;return b(o)?(o.width>o.height?o.width:o.height)+r(t):o+r(t)}return 10+r(t)}},Ve={center:[0,0],width:300,height:300},We={circular:A,concentric:R,mds:ke,random:function(){function t(t){void 0===t&&(t={}),this.options=t,this.id="random",this.options=r(r({},Ve),t)}return t.prototype.execute=function(t,e){return this.genericRandomLayout(!1,t,e)},t.prototype.assign=function(t,e){this.genericRandomLayout(!0,t,e)},t.prototype.genericRandomLayout=function(t,e,n){var o=r(r({},this.options),n),i=o.center,s=o.width,a=o.height,h=o.layoutInvisibles,u=o.onLayoutEnd,l=e.getAllNodes();h||(l=l.filter((function(t){var e=(t.data||{}).visible;return e||void 0===e})));var c=s||"undefined"==typeof window?s:window.innerWidth,f=a||"undefined"==typeof window?a:window.innerHeight,d=i||[c/2,f/2],g=[];l&&l.forEach((function(t){g.push({id:t.id,data:{x:.9*(Math.random()-.5)*c+d[0],y:.9*(Math.random()-.5)*f+d[1]}})})),t&&g.forEach((function(t){return e.mergeNodeData(t.id,{x:t.data.x,y:t.data.y})}));var p={nodes:g,edges:e.getAllEdges()};return null==u||u(p),p},t}(),grid:Kt,radial:Oe,force:Tt,d3force:It,fruchterman:Bt,forceAtlas2:Gt};function $e(){(null==Se?void 0:Se.stop)&&Se.stop()}function Ge(t,e){return r=this,n=void 0,i=function(){var r,n,o,i,s,a,h,l;return function(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])}}}(this,(function(c){if(r=t.layout,n=r.id,o=r.options,i=r.iterations,s=t.nodes,a=t.edges,h=new u({nodes:s,edges:a}),!(l=We[n]))throw new Error("Unknown layout id: ".concat(n));return Se=new l(o),[2,new Promise((function(t){var r;Se.assign(h,{onLayoutEnd:function(r){t([r,e])}}),(r=Se).tick&&r.stop&&r.restart&&(Se.stop(),Se.tick(i))}))]}))},new((o=void 0)||(o=Promise))((function(t,e){function s(t){try{h(i.next(t))}catch(t){e(t)}}function a(t){try{h(i.throw(t))}catch(t){e(t)}}function h(e){var r;e.done?t(e.value):(r=e.value,r instanceof o?r:new o((function(t){t(r)}))).then(s,a)}h((i=i.apply(r,n||[])).next())}));var r,n,o,i}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=b6a955aaa104d7ff3f17.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:()=>Ge,stopLayout:()=>$e});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){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 i(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;const s=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["*"]||[],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 a(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 h(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)&&h(o,e,r,n))return!0;return!1}class u extends s{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 h(this.getNode(t),new Set,e,(t=>this.getChildren(t,r)))}bfsTree(t,e,r){return a([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 a([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 h(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 u({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 l=/-(\\w)/g,c=(function(t){return t.replace(l,(function(t,e){return e?e.toUpperCase():""}))},Object.create(null),Array.isArray),f=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},d=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},g=function(t,e){return Math.sqrt((t.x-e.x)*(t.x-e.x)+(t.y-e.y)*(t.y-e.y))},p={}.toString;const y=function(t,e){return p.call(t)==="[object "+e+"]"},m=function(t){return y(t,"Number")};var w=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 w(t)}))}if("object"==typeof t){var r={};return Object.keys(t).forEach((function(e){r[e]=w(t[e])})),r}return t},v=function(t,e){var r=w(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 x=function(t){return"function"==typeof t},b=function(t){var e=typeof t;return null!==t&&"object"===e||"function"===e};function M(t,e){return x(e)?e:m(e)?function(){return e}:function(){return t}}function E(t,e,r){return void 0===r&&(r=!0),e||0===e?x(e)?e:m(e)?function(){return e}:c(e)?function(){if(r){var n=Math.max.apply(Math,i([],o(e),!1));return isNaN(n)?t:n}return e}:b(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?c(r)?r[0]>r[1]?r[0]:r[1]:b(r)?r.width>r.height?r.width:r.height:r:t}}var N=function(t,e,n,o){var i=t.getAllNodes(),s=t.getAllEdges();if(!(null==i?void 0:i.length)){var a={nodes:[],edges:s};return null==o||o(a),a}if(1===i.length)return e&&t.mergeNodeData(i[0].id,{x:n[0],y:n[1]}),a={nodes:[r(r({},i[0]),{data:r(r({},i[0].data),{x:n[0],y:n[1]})})],edges:s},null==o||o(a),a},S={radius:null,startRadius:null,endRadius:null,startAngle:0,endAngle:2*Math.PI,clockwise:!0,divisions:1,ordering:null,angleRatio:1},A=function(){function t(t){void 0===t&&(t={}),this.options=t,this.id="circular",this.options=r(r({},S),t)}return t.prototype.execute=function(t,e){return this.genericCircularLayout(!1,t,e)},t.prototype.assign=function(t,e){this.genericCircularLayout(!0,t,e)},t.prototype.genericCircularLayout=function(t,e,n){var i=r(r({},this.options),n),s=i.width,a=i.height,h=i.center,u=i.divisions,l=i.startAngle,c=void 0===l?0:l,f=i.endAngle,d=void 0===f?2*Math.PI:f,g=i.angleRatio,p=i.ordering,y=i.clockwise,m=i.nodeSpacing,w=i.nodeSize,x=i.layoutInvisibles,b=i.onLayoutEnd,S=e.getAllNodes(),A=e.getAllEdges();x||(S=S.filter((function(t){var e=(t.data||{}).visible;return e||void 0===e})),A=A.filter((function(t){var e=(t.data||{}).visible;return e||void 0===e})));var D=o(I(s,a,h),3),_=D[0],R=D[1],z=D[2],T=null==S?void 0:S.length;if(!T||1===T)return N(e,t,z,b);var O=(d-c)/T,C=i.radius,P=i.startRadius,q=i.endRadius;if(m){var L=M(10,m),F=E(10,w),j=-1/0;S.forEach((function(t){var e=F(t);j<e&&(j=e)}));var V=0;S.forEach((function(t,e){V+=0===e?j||10:(L(t)||0)+(j||10)})),C=V/(2*Math.PI)}else C||P||q?!P&&q?P=q:P&&!q&&(q=P):C=Math.min(R,_)/2;var W=O*g,$=[];$="topology"===p?k(e,S):"topology-directed"===p?k(e,S,!0):"degree"===p?function(t,e){var r=[];return e.forEach((function(t,e){r.push(v(t))})),r.sort((function(e,r){return t.getDegree(e.id,"both")-t.getDegree(r.id,"both")})),r}(e,S):S.map((function(t){return v(t)}));for(var G=Math.ceil(T/u),U=0;U<T;++U){var B=C;B||null===P||null===q||(B=P+U*(q-P)/(T-1)),B||(B=10+100*U/(T-1));var H=c+U%G*W+2*Math.PI/u*Math.floor(U/G);y||(H=d-U%G*W-2*Math.PI/u*Math.floor(U/G)),$[U].data.x=z[0]+Math.cos(H)*B,$[U].data.y=z[1]+Math.sin(H)*B}t&&$.forEach((function(t){e.mergeNodeData(t.id,{x:t.data.x,y:t.data.y})}));var K={nodes:$,edges:A};return null==b||b(K),K},t}(),k=function(t,e,r){void 0===r&&(r=!1);var n=[v(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),l=!1,c=0;c<u.length;c++){var f=u[c];if(t.getDegree(f.id)===t.getDegree(a.id)&&!o[f.id]){n.push(v(f)),o[f.id]=!0,l=!0;break}}for(var d=0;!l&&(o[e[d].id]||(n.push(v(e[d])),o[e[d].id]=!0,l=!0),++d!==i););}else n.push(v(a)),o[a.id]=!0,s++})),n},I=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 D=function(t){return y(t,"String")};var _={nodeSize:30,nodeSpacing:10,preventOverlap:!1,sweep:void 0,equidistant:!1,startAngle:1.5*Math.PI,clockwise:!0,maxLevelDiff:void 0,sortBy:"degree"},R=function(){function t(t){void 0===t&&(t={}),this.options=t,this.id="concentric",this.options=r(r({},_),t)}return t.prototype.execute=function(t,e){return this.genericConcentricLayout(!1,t,e)},t.prototype.assign=function(t,e){this.genericConcentricLayout(!0,t,e)},t.prototype.genericConcentricLayout=function(t,e,n){var o=r(r({},this.options),n),i=o.center,s=o.width,a=o.height,h=o.sortBy,u=o.maxLevelDiff,l=o.sweep,f=o.clockwise,d=o.equidistant,g=o.preventOverlap,p=o.startAngle,y=void 0===p?1.5*Math.PI:p,w=o.nodeSize,M=o.nodeSpacing,E=o.layoutInvisibles,S=o.onLayoutEnd,A=e.getAllNodes(),k=e.getAllEdges();E||(A=A.filter((function(t){var e=(t.data||{}).visible;return e||void 0===e})),k=k.filter((function(t){var e=(t.data||{}).visible;return e||void 0===e})));var I=s||"undefined"==typeof window?s:window.innerWidth,_=a||"undefined"==typeof window?a:window.innerHeight,R=i||[I/2,_/2];if(!(null==A?void 0:A.length)||1===A.length)return N(e,t,R,S);var z,T=[],O=0;z=c(w)?Math.max(w[0],w[1]):w,c(M)?O=Math.max(M[0],M[1]):m(M)&&(O=M),A.forEach((function(t){var e=v(t);T.push(e);var r=z,n=e.data;c(n.size)?r=Math.max(n.size[0],n.size[1]):m(n.size)?r=n.size:b(n.size)&&(r=Math.max(n.size.width,n.size.height)),z=Math.max(z,r),x(M)&&(O=Math.max(M(t),O))}));var C={};T.forEach((function(t,e){C[t.id]=e}));var P=h;D(P)&&void 0!==T[0].data[P]||(P="degree"),"degree"===P?T.sort((function(t,r){return e.getDegree(r.id,"both")-e.getDegree(t.id,"both")})):T.sort((function(t,e){return e.data[P]-t.data[P]}));var q=T[0],L=(u||("degree"===P?e.getDegree(q.id,"both"):q.data[P]))/4,F=[{nodes:[]}],j=F[0];T.forEach((function(t){if(j.nodes.length>0){var r="degree"===P?Math.abs(e.getDegree(j.nodes[0].id,"both")-e.getDegree(t.id,"both")):Math.abs(j.nodes[0].data[P]-t.data[P]);L&&r>=L&&(j={nodes:[]},F.push(j))}j.nodes.push(t)}));var V=z+O;if(!g){var W=F.length>0&&F[0].nodes.length>1,$=(Math.min(I,_)/2-V)/(F.length+(W?1:0));V=Math.min(V,$)}var G=0;if(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&&g){var r=Math.cos(t.dTheta)-Math.cos(0),n=Math.sin(t.dTheta)-Math.sin(0),o=Math.sqrt(V*V/(r*r+n*n));G=Math.max(o,G)}t.r=G,G+=V})),d){for(var U=0,B=0,H=0;H<F.length;H++){var K=(F[H].r||0)-B;U=Math.max(U,K)}B=0,F.forEach((function(t,e){0===e&&(B=t.r||0),t.r=B,B+=U}))}F.forEach((function(t){var e=t.dTheta||0,r=t.r||0;t.nodes.forEach((function(t,n){var o=y+(f?1:-1)*e*n;t.data.x=R[0]+r*Math.cos(o),t.data.y=R[1]+r*Math.sin(o)}))})),t&&T.forEach((function(t){return e.mergeNodeData(t.id,{x:t.data.x,y:t.data.y})}));var J={nodes:T,edges:k};return null==S||S(J),J},t}();function z(t,e,r,n){if(isNaN(e)||isNaN(r))return t;var o,i,s,a,h,u,l,c,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,(l=r>=(s=(y+w)/2))?y=s:w=s,o=d,!(d=d[c=l<<1|u]))return o[c]=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[c]=g:t._root=g,t;do{o=o?o[c]=new Array(4):t._root=new Array(4),(u=e>=(i=(p+m)/2))?p=i:m=i,(l=r>=(s=(y+w)/2))?y=s:w=s}while((c=l<<1|u)==(f=(h>=s)<<1|a>=i));return o[f]=d,o[c]=g,t}function T(t,e,r,n,o){this.node=t,this.x0=e,this.y0=r,this.x1=n,this.y1=o}function O(t){return t[0]}function C(t){return t[1]}function P(t,e,r){var n=new q(null==e?O:e,null==r?C: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 L(t){for(var e={data:t.data},r=e;t=t.next;)r=r.next={data:t.data};return e}var F=P.prototype=q.prototype;function j(t){return function(){return t}}function V(t){return 1e-6*(t()-.5)}F.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=L(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]=L(e));return r},F.add=function(t){const e=+this._x.call(null,t),r=+this._y.call(null,t);return z(this.cover(e,r),e,r,t)},F.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,l=-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))||(s[r]=n,a[r]=o,n<h&&(h=n),n>l&&(l=n),o<u&&(u=o),o>c&&(c=o));if(h>l||u>c)return this;for(this.cover(h,u).cover(l,c),r=0;r<i;++r)z(this,s[r],a[r],t[r]);return this},F.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},F.data=function(){var t=[];return this.visit((function(e){if(!e.length)do{t.push(e.data)}while(e=e.next)})),t},F.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]]},F.find=function(t,e,r){var n,o,i,s,a,h,u,l=this._x0,c=this._y0,f=this._x1,d=this._y1,g=[],p=this._root;for(p&&g.push(new T(p,l,c,f,d)),null==r?r=1/0:(l=t-r,c=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)<l||(a=h.y1)<c))if(p.length){var y=(o+s)/2,m=(i+a)/2;g.push(new T(p[3],y,m,s,a),new T(p[2],o,m,y,a),new T(p[1],y,i,s,m),new T(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 b=Math.sqrt(r=x);l=t-b,c=e-b,f=t+b,d=e+b,n=p.data}}return n},F.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,l,c,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,(l=s>=(h=(p+m)/2))?p=h:m=h,e=d,!(d=d[c=l<<1|u]))return this;if(!d.length)break;(e[c+1&3]||e[c+2&3]||e[c+3&3])&&(r=e,f=c)}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[c]=o:delete e[c],(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)},F.removeAll=function(t){for(var e=0,r=t.length;e<r;++e)this.remove(t[e]);return this},F.root=function(){return this._root},F.size=function(){var t=0;return this.visit((function(e){if(!e.length)do{++t}while(e=e.next)})),t},F.visit=function(t){var e,r,n,o,i,s,a=[],h=this._root;for(h&&a.push(new T(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,l=(o+s)/2;(r=h[3])&&a.push(new T(r,u,l,i,s)),(r=h[2])&&a.push(new T(r,n,l,u,s)),(r=h[1])&&a.push(new T(r,u,o,i,l)),(r=h[0])&&a.push(new T(r,n,o,u,l))}return this},F.visitAfter=function(t){var e,r=[],n=[];for(this._root&&r.push(new T(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,l=(s+h)/2,c=(a+u)/2;(i=o[0])&&r.push(new T(i,s,a,l,c)),(i=o[1])&&r.push(new T(i,l,a,h,c)),(i=o[2])&&r.push(new T(i,s,c,l,u)),(i=o[3])&&r.push(new T(i,l,c,h,u))}n.push(e)}for(;e=n.pop();)t(e.node,e.x0,e.y0,e.x1,e.y1);return this},F.x=function(t){return arguments.length?(this._x=t,this):this._x},F.y=function(t){return arguments.length?(this._y=t,this):this._y};var W={value:()=>{}};function $(){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 G(n)}function G(t){this._=t}function U(t,e){return t.trim().split(/^|\\s+/).map((function(t){var r="",n=t.indexOf(".");if(n>=0&&(r=t.slice(n+1),t=t.slice(0,n)),t&&!e.hasOwnProperty(t))throw new Error("unknown type: "+t);return{type:t,name:r}}))}function B(t,e){for(var r,n=0,o=t.length;n<o;++n)if((r=t[n]).name===e)return r.value}function H(t,e,r){for(var n=0,o=t.length;n<o;++n)if(t[n].name===e){t[n]=W,t=t.slice(0,n).concat(t.slice(n+1));break}return null!=r&&t.push({name:e,value:r}),t}G.prototype=$.prototype={constructor:G,on:function(t,e){var r,n=this._,o=U(t+"",n),i=-1,s=o.length;if(!(arguments.length<2)){if(null!=e&&"function"!=typeof e)throw new Error("invalid callback: "+e);for(;++i<s;)if(r=(t=o[i]).type)n[r]=H(n[r],t.name,e);else if(null==e)for(r in n)n[r]=H(n[r],t.name,null);return this}for(;++i<s;)if((r=(t=o[i]).type)&&(r=B(n[r],t.name)))return r},copy:function(){var t={},e=this._;for(var r in e)t[r]=e[r].slice();return new G(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 K=$;var J,Y,X=0,Q=0,Z=0,tt=0,et=0,rt=0,nt="object"==typeof performance&&performance.now?performance:Date,ot="object"==typeof window&&window.requestAnimationFrame?window.requestAnimationFrame.bind(window):function(t){setTimeout(t,17)};function it(){return et||(ot(st),et=nt.now()+rt)}function st(){et=0}function at(){this._call=this._time=this._next=null}function ht(t,e,r){var n=new at;return n.restart(t,e,r),n}function ut(){et=(tt=nt.now())+rt,X=Q=0;try{!function(){it(),++X;for(var t,e=J;e;)(t=et-e._time)>=0&&e._call.call(void 0,t),e=e._next;--X}()}finally{X=0,function(){for(var t,e,r=J,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:J=e);Y=t,ct(n)}(),et=0}}function lt(){var t=nt.now(),e=t-tt;e>1e3&&(rt-=e,tt=t)}function ct(t){X||(Q&&(Q=clearTimeout(Q)),t-et>24?(t<1/0&&(Q=setTimeout(ut,t-nt.now()-rt)),Z&&(Z=clearInterval(Z))):(Z||(tt=nt.now(),Z=setInterval(lt,1e3)),X=1,ot(ut)))}at.prototype=ht.prototype={constructor:at,restart:function(t,e,r){if("function"!=typeof t)throw new TypeError("callback is not a function");r=(null==r?it():+r)+(null==e?0:+e),this._next||Y===this||(Y?Y._next=this:J=this,Y=this),this._call=t,this._time=r,ct()},stop:function(){this._call&&(this._call=null,this._time=1/0,ct())}};const ft=4294967296;function dt(t){return t.x}function gt(t){return t.y}var pt=Math.PI*(3-Math.sqrt(5));function yt(t){var e,r=1,n=.001,o=1-Math.pow(n,1/300),i=0,s=.6,a=new Map,h=ht(c),u=K("tick","end"),l=function(){let t=1;return()=>(t=(1664525*t+1013904223)%ft)/ft}();function c(){f(),u.call("tick",e),r<n&&(h.stop(),u.call("end",e))}function f(n){var h,u,l=t.length;void 0===n&&(n=1);for(var c=0;c<n;++c)for(r+=(i-r)*o,a.forEach((function(t){t(r)})),h=0;h<l;++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=10*Math.sqrt(.5+r),i=r*pt;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,l),e}return null==t&&(t=[]),d(),e={tick:f,restart:function(){return h.restart(c),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?(l=t,a.forEach(g),e):l},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,l=t.length;for(null==n?n=1/0:n*=n,u=0;u<l;++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 mt(){var t,e,r,n,o,i=j(-30),s=1,a=1/0,h=.81;function u(r){var o,i=t.length,s=P(t,dt,gt).visitAfter(c);for(n=r,o=0;o<i;++o)e=t[o],s.visit(f)}function l(){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,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,l){if(!t.value)return!0;var c=t.x-e.x,f=t.y-e.y,d=l-i,g=c*c+f*f;if(d*d/h<g)return g<a&&(0===c&&(g+=(c=V(r))*c),0===f&&(g+=(f=V(r))*f),g<s&&(g=Math.sqrt(s*g)),e.vx+=c*t.value*n/g,e.vy+=f*t.value*n/g),!0;if(!(t.length||g>=a)){(t.data!==e||t.next)&&(0===c&&(g+=(c=V(r))*c),0===f&&(g+=(f=V(r))*f),g<s&&(g=Math.sqrt(s*g)));do{t.data!==e&&(d=o[t.data.index]*n/g,e.vx+=c*d,e.vy+=f*d)}while(t=t.next)}}return u.initialize=function(e,n){t=e,r=n,l()},u.strength=function(t){return arguments.length?(i="function"==typeof t?t:j(+t),l(),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 wt(t){return t.index}function vt(t,e){var r=t.get(e);if(!r)throw new Error("node not found: "+e);return r}function xt(t){var e,r,n,o,i,s,a=wt,h=function(t){return 1/Math.min(o[t.source.index],o[t.target.index])},u=j(30),l=1;function c(n){for(var o=0,a=t.length;o<l;++o)for(var h,u,c,f,d,g,p,y=0;y<a;++y)u=(h=t[y]).source,f=(c=h.target).x+c.vx-u.x-u.vx||V(s),d=c.y+c.vy-u.y-u.vy||V(s),f*=g=((g=Math.sqrt(f*f+d*d))-r[y])/g*n*e[y],d*=g,c.vx-=f*(p=i[y]),c.vy-=d*p,u.vx+=f*(p=1-p),u.vy+=d*p}function f(){if(n){var s,h,u=n.length,l=t.length,c=new Map(n.map(((t,e)=>[a(t,e,n),t])));for(s=0,o=new Array(u);s<l;++s)(h=t[s]).index=s,"object"!=typeof h.source&&(h.source=vt(c,h.source)),"object"!=typeof h.target&&(h.target=vt(c,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(l);s<l;++s)h=t[s],i[s]=o[h.source.index]/(o[h.source.index]+o[h.target.index]);e=new Array(l),d(),r=new Array(l),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=[]),c.initialize=function(t,e){n=t,s=e,f()},c.links=function(e){return arguments.length?(t=e,f(),c):t},c.id=function(t){return arguments.length?(a=t,c):a},c.iterations=function(t){return arguments.length?(l=+t,c):l},c.strength=function(t){return arguments.length?(h="function"==typeof t?t:j(+t),d(),c):h},c.distance=function(t){return arguments.length?(u="function"==typeof t?t:j(+t),g(),c):u},c}function bt(t){return t.x+t.vx}function Mt(t){return t.y+t.vy}function Et(t){var e,r,n,o=1,i=1;function s(){for(var t,s,h,u,l,c,f,d=e.length,g=0;g<i;++g)for(s=P(e,bt,Mt).visitAfter(a),t=0;t<d;++t)h=e[t],c=r[h.index],f=c*c,u=h.x+h.vx,l=h.y+h.vy,s.visit(p);function p(t,e,r,i,s){var a=t.data,d=t.r,g=c+d;if(!a)return e>u+g||i<u-g||r>l+g||s<l-g;if(a.index>h.index){var p=u-a.x-a.vx,y=l-a.y-a.vy,m=p*p+y*y;m<g*g&&(0===p&&(m+=(p=V(n))*p),0===y&&(m+=(y=V(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=j(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:j(+e),h(),s):t},s}function Nt(t){var e,r,n,o=j(.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=j(null==t?0:+t)),i.initialize=function(t){e=t,s()},i.strength=function(t){return arguments.length?(o="function"==typeof t?t:j(+t),s(),i):o},i.x=function(e){return arguments.length?(t="function"==typeof e?e:j(+e),s(),i):t},i}function St(t){var e,r,n,o=j(.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=j(null==t?0:+t)),i.initialize=function(t){e=t,s()},i.strength=function(t){return arguments.length?(o="function"==typeof t?t:j(+t),s(),i):o},i.y=function(e){return arguments.length?(t="function"==typeof e?e:j(+e),s(),i):t},i}function At(){function t(t){return function(){return t}}var e,r=function(t){return t.cluster},n=t(1),i=t(-1),s=t(100),a=t(.1),h=[0,0],u=[],l={},c=[],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(),b();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(l[o]))<=(a=r(l[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=o(t,2),r=e[0],i=e[1],s=r.split("~")[0],a=r.split("~")[1];void 0!==s&&void 0!==a&&n.push({source:s,target:a,count:i})})),n}(c),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=yt(w.nodes).force("x",Nt(f).strength(.1)).force("y",St(d).strength(.1)).force("collide",Et((function(t){return t.r})).iterations(4)).force("charge",mt().strength(i)).force("links",xt(w.nodes.length?w.links:[]).distance(s).strength(a)),p=e.nodes(),b()}}()}function b(){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}function M(t){l={},t.forEach((function(t){l[t.id]=t}))}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?(M(t||[]),u=t||[],v):u},v.links=function(t){return arguments.length?(c=t||[],x(),v):c},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?(i="function"==typeof e?e:t(+e),x(),v):i},v.forceLinkDistance=function(e){return arguments.length?(s="function"==typeof e?e:t(+e),x(),v):s},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=b,v}var kt={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},It=function(){function t(t){void 0===t&&(t={}),this.options=t,this.id="d3force",this.running=!1,this.options=r(r({},kt),t)}return t.prototype.execute=function(t,e){return this.genericForceLayout(!1,t,e)},t.prototype.assign=function(t,e){this.genericForceLayout(!0,t,e)},t.prototype.stop=function(){var t;null===(t=this.forceSimulation)||void 0===t||t.stop(),this.running=!1},t.prototype.restart=function(){var t;null===(t=this.forceSimulation)||void 0===t||t.restart(),this.running=!0},t.prototype.tick=function(t){var e=this;void 0===t&&(t=1),this.forceSimulation.tick(t);var r={nodes:Dt(this.lastLayoutNodes),edges:_t(this.lastLayoutEdges)};return this.lastAssign&&r.nodes.forEach((function(t){return e.lastGraph.mergeNodeData(t.id,{x:t.data.x,y:t.data.y})})),this.lastOptions.onLayoutEnd&&this.lastOptions.onLayoutEnd(r),r},t.prototype.genericForceLayout=function(t,e,n){var o=this,i=r(r({},this.options),n),s=i.layoutInvisibles,a=e.getAllNodes(),h=e.getAllEdges();s||(a=a.filter((function(t){var e=(t.data||{}).visible;return e||void 0===e})),h=h.filter((function(t){var e=(t.data||{}).visible;return e||void 0===e})));var u=a.map((function(t){var e,n;return r(r({},v(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})})),l=h.map((function(t){return v(t)}));if(this.lastLayoutNodes=u,this.lastLayoutEdges=l,this.lastAssign=t,this.lastGraph=e,this.lastOptions=i,!this.running){var c=i.alphaMin,f=i.alphaDecay,d=i.alpha,g=i.nodeStrength,p=i.edgeStrength,y=i.linkDistance,m=i.clustering,w=i.clusterFociStrength,x=i.clusterEdgeDistance,b=i.clusterEdgeStrength,M=i.clusterNodeStrength,E=i.clusterNodeSize,N=i.collideStrength,S=void 0===N?1:N,A=i.center,k=void 0===A?[0,0]:A,I=i.preventOverlap,D=i.nodeSize,_=i.nodeSpacing,R=i.onTick,z=i.onLayoutEnd,T=i.forceSimulation;if(T)m&&((O=At()).nodes(u),O.links(l)),T.nodes(u),l&&(P=xt().id((function(t){return t.id})).links(l),p&&P.strength(p),y&&P.distance(y),T.force("link",P)),I&&this.overlapProcess(T,{nodeSize:D,nodeSpacing:_,collideStrength:S}),T.alpha(d).restart(),this.running=!0;else try{var O,C=mt();if(g&&C.strength(g),T=yt().nodes(u),m&&((O=At()).centerX(k[0]).centerY(k[1]).template("force").strength(w),l&&O.links(l),u&&O.nodes(u),O.forceLinkDistance(x).forceLinkStrength(b).forceCharge(M).forceNodeSize(E),T.force("group",O)),T.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}(k[0],k[1])).force("charge",C).alpha(d).alphaDecay(f).alphaMin(c),I&&this.overlapProcess(T,{nodeSize:D,nodeSpacing:_,collideStrength:S}),l){var P=xt().id((function(t){return t.id})).links(l);p&&P.strength(p),y&&P.distance(y),T.force("link",P)}T.on("tick",(function(){var r=Dt(u);null==R||R({nodes:r,edges:_t(l)}),t&&r.forEach((function(t){return e.mergeNodeData(t.id,{x:t.data.x,y:t.data.y})}))})).on("end",(function(){o.running=!1;var r=Dt(u);null==z||z({nodes:r,edges:_t(l)}),t&&r.forEach((function(t){return e.mergeNodeData(t.id,{x:t.data.x,y:t.data.y})}))})),this.running=!0}catch(t){this.running=!1,console.warn(t)}this.forceSimulation=T;var q=Dt(u),L=_t(l);return t&&q.forEach((function(t){return e.mergeNodeData(t.id,{x:t.data.x,y:t.data.y})})),{nodes:q,edges:L}}},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}:x(i)?i:function(){return 0},o)if(x(o))r=function(t){return o(t)+n(t)};else if(c(o)){var a=(o[0]>o[1]?o[0]:o[1])/2;r=function(t){return a+n(t)}}else if(m(o)){var h=o/2;r=function(t){return h+n(t)}}else r=function(){return 10};else r=function(t){return t.size?c(t.size)?(t.size[0]>t.size[1]?t.size[0]:t.size[1])/2+n(t):b(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",Et(r).strength(s))},t}(),Dt=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})})}))},_t=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 Rt(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 zt={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"},Tt=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({},zt),t)}return t.prototype.execute=function(t,e){return this.genericForceLayout(!1,t,e)},t.prototype.assign=function(t,e){this.genericForceLayout(!0,t,e)},t.prototype.stop=function(){this.timeInterval&&"undefined"!=typeof window&&window.clearInterval(this.timeInterval),this.running=!1},t.prototype.restart=function(){this.running=!0},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})})),this.lastOptions.onLayoutEnd&&this.lastOptions.onLayoutEnd(n),n},t.prototype.genericForceLayout=function(t,e,n){var o=this,i=r(r({},this.options),n),s=e.getAllNodes(),a=e.getAllEdges();i.layoutInvisibles||(s=s.filter((function(t){return t.data.visible||void 0===t.data.visible})),a=a.filter((function(t){return t.data.visible||void 0===t.data.visible})));var h=this.formatOptions(i,e),l=h.width,c=h.height,f=h.nodeSize,d=h.getMass,g=h.nodeStrength,p=h.edgeStrength,y=h.linkDistance,w=s.map((function(t){return r(r({},t),{data:r(r({},t.data),{x:m(t.data.x)?t.data.x:Math.random()*l,y:m(t.data.y)?t.data.y:Math.random()*c,size:f(t)||30,mass:d(t),nodeStrength:g(t)})})})),v=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))})})}));if(!(null==s?void 0:s.length))return this.lastResult={nodes:[],edges:a},{nodes:[],edges:a};var x={};s.forEach((function(t,e){x[t.id]={x:0,y:0}}));var b=new u({nodes:w,edges:v});this.formatCentripetal(h,b);var M=h.maxIteration,E=h.minMovement,N=h.onLayoutEnd,S=h.onTick;if(this.lastLayoutNodes=w,this.lastLayoutEdges=v,this.lastAssign=t,this.lastGraph=e,this.lastCalcGraph=b,this.lastOptions=h,this.lastVelMap=x,"undefined"!=typeof window){var A=0;return this.timeInterval=window.setInterval((function(){s&&o.running&&(o.runOneStep(b,e,A,x,h),o.updatePosition(e,b,x,h),t&&w.forEach((function(t){return e.mergeNodeData(t.id,{x:t.data.x,y:t.data.y})})),null==S||S({nodes:Lt(e,w),edges:a}),(++A>=M||o.judgingDistance<E)&&(null==N||N({nodes:Lt(e,w),edges:a}),window.clearInterval(o.timeInterval)))}),0),this.running=!0,{nodes:Lt(e,w),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=M(0,t.nodeSpacing);t.nodeSize?c(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?c(e)?Math.max(e[0],e[1])+s(t):b(e)?Math.max(e.width,e.height)+s(t):e+s(t):10+s(t)}}return r.linkDistance=t.linkDistance?M(1,t.linkDistance):function(t){return 1+r.nodeSize(e.getNode(t.source))+r.nodeSize(e.getNode(t.target))},r.nodeStrength=M(1,t.nodeStrength),r.edgeStrength=M(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(),l=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(s&&h&&(r=Ot(e,h),c=Array.from(new Set(null==u?void 0:u.map((function(t){return t.data[h]}))))||[],t.centripetalOptions=Object.assign(l,{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,s=void 0===i?[]:i;1===s.length?n=void 0:s.length>1&&(n=qt(s))}else n=void 0;return{x:null==n?void 0:n.x,y:null==n?void 0:n.y}}})),a&&h){r||(r=Ot(e,h)),c||(c=Array.from(new Set(u.map((function(t){return t.data[h]}))))),c=c.filter((function(t){return void 0!==t}));var f={};c.forEach((function(t){var r=u.filter((function(e){return e.data[h]===t})).map((function(t){return e.getNode(t.id)}));f[t]=qt(r)})),t.centripetalOptions=Object.assign(l,{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=P(s,(function(t){return t.x}),(function(t){return t.y})).visitAfter(Rt);s.forEach((function(t){!function(t,e){e.visit((function(e,r,n,o,i){return 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,l=Math.sqrt(u)*u;if(h*h*.81<u){var c=t.weight/l;return i.vx+=s*c,i.vy+=a*c,!0}if(t.length)return!1;t.data!==i&&(c=t.data.weight/l,i.vx+=s*c,i.vy+=a*c)}(e,r,0,o,0,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 l=Math.sqrt(h*h+u*u),c=h/l,f=u/l,d=r.data||{},g=d.linkDistance,p=void 0===g?200:g,y=d.edgeStrength,m=(p-l)*(void 0===y?200:y),w=1/(s.data.mass||1),v=1/(a.data.mass||1),x=c*m,b=f*m;e[o].x-=x*w,e[o].y-=b*w,e[i].x+=x*v,e[i].y+=b*v}}))},t.prototype.calGravity=function(t,e,r,n){var i=n.getCenter,s=t.getAllNodes(),a=e.getAllNodes(),h=e.getAllEdges(),u=n.width,l=n.height,c=n.center,f=n.gravity,d=n.centripetalOptions;s&&s.forEach((function(n){var s=n.id,g=n.data,p=g.mass,y=g.x,w=g.y,v=e.getNode(s),x=0,b=0,M=f,E=t.getDegree(s,"in"),N=t.getDegree(s,"out"),S=t.getDegree(s,"both"),A=null==i?void 0:i(v,S);if(A){var k=o(A,3);x=y-k[0],b=w-k[1],M=k[2]}else x=y-c[0],b=w-c[1];if(M&&(r[s].x-=M*x/p,r[s].y-=M*b/p),d){var I=d.leaf,D=d.single,_=d.others,R=d.center,z=(null==R?void 0:R(v,a,h,u,l))||{x:0,y:0,centerStrength:0},T=z.x,O=z.y,C=z.centerStrength;if(!m(T)||!m(O))return;var P=(y-T)/p,q=(w-O)/p;if(C&&(r[s].x-=C*P,r[s].y-=C*q),0===S){var L=D(v);if(!L)return;return r[s].x-=L*P,void(r[s].y-=L*q)}if(0===E||0===N){var F=I(v,a,h);if(!F)return;return r[s].x-=F*P,void(r[s].y-=F*q)}var j=_(v);if(!j)return;r[s].x-=j*P,r[s].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 l=i/u;a*=l,h*=l}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(m(u.data.fx)&&m(u.data.fy))e.mergeNodeData(a,{x:u.data.fx,y:u.data.fy});else{var l=r[a].x*s,c=r[a].y*s;e.mergeNodeData(a,{x:n.data.x+l,y:n.data.y+c});var f=Math.sqrt(l*l+c*c);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}(),Ot=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]=Ct(t,"leaf",r,e))})),n},Ct=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:Pt(t,e,n,r,a)}},Pt=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},qt=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}},Lt=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})})}))},Ft=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 jt=Ft;const Vt=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}(),Wt=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 $t={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},Gt=function(){function t(t){void 0===t&&(t={}),this.options=t,this.id="forceAtlas2",this.options=r(r({},$t),t)}return t.prototype.execute=function(t,e){return this.genericForceAtlas2Layout(!1,t,e)},t.prototype.assign=function(t,e){this.genericForceAtlas2Layout(!0,t,e)},t.prototype.genericForceAtlas2Layout=function(t,e,n){var o=e.getAllEdges(),i=e.getAllNodes(),s=this.formatOptions(n,i.length),a=s.width,h=s.height,l=s.prune,c=s.maxIteration,f=s.nodeSize,d=s.center,g=s.onLayoutEnd;if(!(null==i?void 0:i.length)||1===i.length)return N(e,t,d,g);var p=i.map((function(t){return v(t,[a,h])})),y=o.filter((function(t){return t.source!==t.target})),m=new u({nodes:p,edges:y}),w=this.getSizes(m,e,f);if(this.run(m,e,c,w,t,s),l){for(var x=0;x<y.length;x+=1){var b=y[x],M=b.source,E=b.target,S=m.getDegree(M),A=m.getDegree(M);if(S<=1){var k=m.getNode(E);m.mergeNodeData(M,{x:k.data.x,y:k.data.y})}else if(A<=1){var I=m.getNode(M);m.mergeNodeData(E,{x:I.data.x,y:I.data.y})}}var D=r(r({},s),{prune:!1,barnesHut:!1});this.run(m,e,100,w,t,D)}var _={nodes:p,edges:o};return null==g||g(_),_},t.prototype.getSizes=function(t,e,r){for(var n=t.getAllNodes(),s={},a=0;a<n.length;a+=1){var h=n[a],u=h.id,l=h.data;if(s[u]=10,m(l.size))s[u]=l.size;else if(c(l.size))isNaN(l.size[0])||(s[u]=Math.max(l.size[0])),isNaN(l.size[1])||(s[u]=Math.max(l.size[1]));else if(b(l.size))s[u]=Math.max(l.size.width,l.size.height);else if(x(r)){var f=r(e.getNode(u));c(f)?s[u]=Math.max.apply(Math,i([],o(f),!1)):s[u]=f}else c(r)?s[u]=Math.max.apply(Math,i([],o(r),!1)):m(r)&&(s[u]=r)}return s},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,l=n.kr,c=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)),l||(n.kr=50,e>100&&e<=500?n.kr=20:e>500&&(n.kr=1)),c||(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(),l=0,c=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 jt(v)}}for(;c>0;)l=this.oneStep(t,{iter:c,preventOverlapIters:50,krPrime:100,sg:l,forces:f,preForces:d,bodies:g,sizes:n},i),c--,null==h||h({nodes:u,edges:e.getAllEdges()});return t},t.prototype.oneStep=function(t,e,r){for(var n=e.iter,s=e.preventOverlapIters,a=e.krPrime,h=e.sg,u=e.preForces,l=e.bodies,c=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]=i([],o(f[m]),!1),f[m]=[0,0]}return f=this.getAttrForces(t,n,s,c,f,r),f=g&&(d&&n>s||!d)?this.getOptRepGraForces(t,f,l,r):this.getRepGraForces(t,n,s,f,a,c,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,l=t.getAllEdges(),c=0;c<l.length;c+=1){var f=l[c],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 b=x,M=b;"linlog"===h&&(M=b=Math.log(1+x)),a&&(b=x/m,M=x/w),s&&e<r&&x<=0?(b=0,M=0):s&&e<r&&x>0&&(b=x,M=x),o[d][0]+=b*v[0],o[g][0]-=M*v[0],o[d][1]+=b*v[1],o[g][1]-=M*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,l=-9e10,c=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>=l&&(l=y.x),y.x<=u&&(u=y.x),y.y>=f&&(f=y.y),y.y<=c&&(c=y.y))}var m=Math.max(l-u,f-c),w=new Vt({xmid:(l+u)/2,ymid:(f+c)/2,length:m,massCenter:i,mass:h}),v=new Wt(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],b=(p=x.id,y=x.data,t.getDegree(p));if(!(s&&b<=1)){r[p].resetForce(),v.updateForce(r[p]),e[p][0]-=r[p].fx,e[p][1]-=r[p].fy;var M=[y.x-i[0],y.y-i[1]],E=Math.hypot(M[0],M[1]);E=E<1e-4?1e-4:E,M[0]=M[0]/E,M[1]=M[1]/E;var N=o*(b+1);e[p][0]-=N*M[0],e[p][1]-=N*M[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,l=s.center,c=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(!c||!(y<=1||v<=1)){var x=[w.data.x-p.data.x,w.data.y-p.data.y],b=Math.hypot(x[0],x[1]);b=b<1e-4?1e-4:b,x[0]=x[0]/b,x[1]=x[1]/b,a&&e<r&&(b=b-i[p.id]-i[w.id]);var M=h*(y+1)*(v+1)/b;a&&e<r&&b<0?M=o*(y+1)*(v+1):a&&e<r&&0===b?M=0:a&&e<r&&b>0&&(M=h*(y+1)*(v+1)/b),n[p.id][0]-=M*x[0],n[w.id][0]+=M*x[0],n[p.id][1]-=M*x[1],n[w.id][1]+=M*x[1]}}var E=[p.data.x-l[0],p.data.y-l[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(),l=u.length,c=[],f=[],d=0,g=0,p=n,y=0;y<l;y+=1){var w=u[y].id,v=t.getDegree(w);if(!(a&&v<=1)){var x=[e[w][0]-r[w][0],e[w][1]-r[w][1]],b=Math.hypot(x[0],x[1]),M=[e[w][0]+r[w][0],e[w][1]+r[w][1]],E=Math.hypot(M[0],M[1]);c[y]=b,f[y]=E/2,d+=(v+1)*c[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<l;y+=1){var S=u[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(c[y])),I=Math.hypot(e[w][0],e[w][1]),D=h/(I=I<1e-4?1e-4:I),_=(k=k>D?D:k)*e[w][0],R=k*e[w][1];t.mergeNodeData(w,{x:A.x+_,y:A.y+R})}}return p},t}(),Ut={maxIteration:1e3,gravity:10,speed:5,clustering:!1,clusterGravity:10,width:300,height:300,nodeClusterBy:"cluster"},Bt=function(){function t(t){void 0===t&&(t={}),this.options=t,this.id="fruchterman",this.timeInterval=0,this.running=!1,this.options=r(r({},Ut),t)}return t.prototype.execute=function(t,e){return this.genericFruchtermanLayout(!1,t,e)},t.prototype.assign=function(t,e){this.genericFruchtermanLayout(!0,t,e)},t.prototype.stop=function(){this.timeInterval&&"undefined"!=typeof window&&window.clearInterval(this.timeInterval),this.running=!1},t.prototype.restart=function(){this.running=!0},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})})),this.lastOptions.onLayoutEnd&&this.lastOptions.onLayoutEnd(n),n},t.prototype.genericFruchtermanLayout=function(t,e,n){var o=this;if(!this.running){var i=this.formatOptions(n),s=i.layoutInvisibles,a=i.width,h=i.height,l=i.center,c=i.clustering,f=i.nodeClusterBy,d=i.maxIteration,g=i.onTick,p=i.onLayoutEnd,y=e.getAllNodes(),m=e.getAllEdges();if(s||(y=y.filter((function(t){var e=(t.data||{}).visible;return e||void 0===e})),m=m.filter((function(t){var e=(t.data||{}).visible;return e||void 0===e}))),!(null==y?void 0:y.length)){var w={nodes:[],edges:m};return this.lastResult=w,null==p||p(w),w}if(1===y.length)return t&&e.mergeNodeData(y[0].id,{x:l[0],y:l[1]}),w={nodes:[r(r({},y[0]),{data:r(r({},y[0].data),{x:l[0],y:l[1]})})],edges:m},this.lastResult=w,null==p||p(w),w;var x=y.map((function(t){return v(t,[a,h])})),b=new u({nodes:x,edges:m}),M={};if(c&&x.forEach((function(t){var e=t.data[f];M[e]||(M[e]={name:e,cx:0,cy:0,count:0})})),this.lastLayoutNodes=x,this.lastLayoutEdges=m,this.lastAssign=t,this.lastGraph=b,this.lastOptions=i,this.lastClusterMap=M,"undefined"!=typeof window){var E=0;return this.timeInterval=window.setInterval((function(){if(o.running&&(o.runOneStep(b,M,i),t&&x.forEach((function(t){var r=t.id,n=t.data;return e.mergeNodeData(r,{x:n.x,y:n.y})})),null==g||g({nodes:x,edges:m}),++E>=d)){try{null==p||p({nodes:x,edges:m})}catch(t){console.warn("onLayoutEnd failed",t)}window.clearInterval(o.timeInterval)}}),0),this.running=!0,{nodes:x,edges:m}}}},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,l=r.clusterGravity,c=n*o,f=Math.sqrt(c)/10,d=t.getAllNodes(),g=c/(d.length+1),p=Math.sqrt(g),y={};if(this.applyCalculate(t,y,p,g),h){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[u]];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=l||i;d.forEach((function(t,r){var n=t.id,o=t.data;if(m(o.x)&&m(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*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,h=t.id;if(!(o<=n)&&m(i.x)&&m(a.x)&&m(i.y)&&m(a.y)){var u=i.x-a.x,l=i.y-a.y,c=u*u+l*l;0===c&&(c=1,u=.01,l=.01);var f=r/c,d=u*f,g=l*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(m(a.x)&&m(s.x)&&m(a.y)&&m(s.y)){var h=a.x-s.x,u=a.y-s.y,l=Math.sqrt(h*h+u*u)/r,c=h*l,f=u*l;e[o].x+=c,e[o].y+=f,e[i].x-=c,e[i].y-=f}}}))},t}(),Ht={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},Kt=function(){function t(t){void 0===t&&(t={}),this.options=t,this.id="grid",this.options=r(r({},Ht),t)}return t.prototype.execute=function(t,e){return this.genericGridLayout(!1,t,e)},t.prototype.assign=function(t,e){this.genericGridLayout(!0,t,e)},t.prototype.genericGridLayout=function(t,e,n){var o=r(r({},this.options),n),i=o.begin,s=void 0===i?[0,0]:i,a=o.condense,h=o.preventOverlapPadding,u=o.preventOverlap,l=o.rows,f=o.cols,d=o.nodeSpacing,g=o.nodeSize,p=o.width,y=o.height,w=o.layoutInvisibles,x=o.onLayoutEnd,b=o.position,S=o.sortBy,A=e.getAllNodes(),k=e.getAllEdges();w||(A=A.filter((function(t){var e=(t.data||{}).visible;return e||void 0===e})),k=k.filter((function(t){var e=(t.data||{}).visible;return e||void 0===e})));var I=null==A?void 0:A.length;if(!I||1===I)return N(e,t,s,x);var _=A.map((function(t){return v(t)}));"id"===S||D(S)&&void 0!==_[0].data[S]||(S="degree"),"degree"===S?_.sort((function(t,r){return e.getDegree(r.id,"both")-e.getDegree(t.id,"both")})):"id"===S?_.sort((function(t,e){return m(e.id)&&m(t.id)?e.id-t.id:"".concat(t.id).localeCompare("".concat(e.id))})):_.sort((function(t,e){return e.data[S]-t.data[S]}));var R=p||"undefined"==typeof window?p:window.innerWidth,z=y||"undefined"==typeof window?y:window.innerHeight,T=I,O={rows:l,cols:f};if(null!=l&&null!=f)O.rows=l,O.cols=f;else if(null!=l&&null==f)O.rows=l,O.cols=Math.ceil(T/O.rows);else if(null==l&&null!=f)O.cols=f,O.rows=Math.ceil(T/O.cols);else{var C=Math.sqrt(T*z/R);O.rows=Math.round(C),O.cols=Math.round(R/z*C)}if(O.rows=Math.max(O.rows,1),O.cols=Math.max(O.cols,1),O.cols*O.rows>T)((q=Jt(O))-1)*(P=Yt(O))>=T?Jt(O,q-1):(P-1)*q>=T&&Yt(O,P-1);else for(;O.cols*O.rows<T;){var P,q=Jt(O);((P=Yt(O))+1)*q>=T?Yt(O,P+1):Jt(O,q+1)}var L=a?0:R/O.cols,F=a?0:z/O.rows;if(u||d){var j=M(10,d),V=E(30,g,!1);_.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=V(o)||30;c(i)?(r=i[0],n=i[1]):(r=i,n=i);var s=void 0!==j?j(t):h,a=r+s,u=n+s;L=Math.max(L,a),F=Math.max(F,u)}))}for(var W={},$={row:0,col:0},G={},U=0;U<_.length;U++){var B=_[U],H=void 0;if(b&&(H=b(e.getNode(B.id))),H&&(void 0!==H.row||void 0!==H.col)){var K={row:H.row,col:H.col};if(void 0===K.col)for(K.col=0;Xt(W,K);)K.col++;else if(void 0===K.row)for(K.row=0;Xt(W,K);)K.row++;G[B.id]=K,Qt(W,K)}te(B,s,L,F,G,O,$,W)}var J={nodes:_,edges:k};return null==x||x(J),t&&_.forEach((function(t){e.mergeNodeData(t.id,{x:t.data.x,y:t.data.y})})),J},t}(),Jt=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},Yt=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},Xt=function(t,e){return t["c-".concat(e.row,"-").concat(e.col)]||!1},Qt=function(t,e){return t["c-".concat(e.row,"-").concat(e.col)]=!0},Zt=function(t,e){var r=t.cols||5;e.col++,e.col>=r&&(e.col=0,e.row++)},te=function(t,e,r,n,o,i,s,a){var h,u,l=o[t.id];if(l)h=l.col*r+r/2+e[0],u=l.row*n+n/2+e[1];else{for(;Xt(a,s);)Zt(i,s);h=s.col*r+r/2+e[0],u=s.row*n+n/2+e[1],Qt(a,s),Zt(i,s)}t.data.x=h,t.data.y=u};const ee=Object.prototype.toString;function re(t){return ee.call(t).endsWith("Array]")}function ne(t){var e=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};if(!re(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}function oe(t){var e=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};if(!re(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}function ie(t){var e,r=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};if(!re(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(!re(r.output))throw new TypeError("output option must be an array if specified");e=r.output}else e=new Array(t.length);var n=oe(t),o=ne(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),l=0;l<t.length;l++)e[l]=(t[l]-n)*u+s;return e}const se=" ".repeat(2),ae=" ".repeat(4);function he(t,e={}){const{maxRows:r=15,maxColumns:n=10,maxNumSize:o=8,padMinus:i="auto"}=e;return`${t.constructor.name} {\\n${se}[\\n${ae}${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(ue(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${ae}`)}(t,r,n,o,i)}\\n${se}]\\n${se}rows: ${t.rows}\\n${se}columns: ${t.columns}\\n}`}function ue(t,e,r){return(t>=0&&r?` ${le(t,e-1)}`:le(t,e)).padEnd(e)}function le(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 ce(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 fe(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 de(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 ge(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 pe(t,e,r,n,o){if(5!==arguments.length)throw new RangeError("expected 4 arguments");if(me("startRow",e),me("endRow",r),me("startColumn",n),me("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 ye(t,e=0){let r=[];for(let n=0;n<t;n++)r.push(e);return r}function me(t,e){if("number"!=typeof e)throw new TypeError(`${t} must be a number`)}function we(t){if(t.isEmpty())throw new Error("Empty matrix has no elements to index")}class ve{static from1DArray(t,e,r){if(t*e!==r.length)throw new RangeError("data length does not match given dimensions");let n=new be(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 be(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 be(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 be(t,e)}static ones(t,e){return new be(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 be(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 be(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 be(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 ve.isMatrix(t)?t:new be(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 be(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){ce(this,t);let e=[];for(let r=0;r<this.columns;r++)e.push(this.get(t,r));return e}getRowVector(t){return be.rowVector(this.getRow(t))}setRow(t,e){ce(this,t),e=de(this,e);for(let r=0;r<this.columns;r++)this.set(t,r,e[r]);return this}swapRows(t,e){ce(this,t),ce(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){fe(this,t);let e=[];for(let r=0;r<this.rows;r++)e.push(this.get(r,t));return e}getColumnVector(t){return be.columnVector(this.getColumn(t))}setColumn(t,e){fe(this,t),e=ge(this,e);for(let r=0;r<this.rows;r++)this.set(r,t,e[r]);return this}swapColumns(t,e){fe(this,t),fe(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=de(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=de(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=de(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=de(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=ge(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=ge(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=ge(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=ge(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){ce(this,t);for(let r=0;r<this.columns;r++)this.set(t,r,this.get(t,r)*e);return this}mulColumn(t,e){fe(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(){we(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(){we(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(ce(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){ce(this,t),we(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(ce(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){ce(this,t),we(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(fe(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){fe(this,t),we(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(fe(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){fe(this,t),we(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){ve.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=be.checkMatrix(t);let e=this.rows,r=this.columns,n=t.columns,o=new be(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=be.checkMatrix(t);let e=new be(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),l=(r+h)*(n+u),c=(s+h)*n,f=r*(i-u),d=h*(a-n),g=(r+o)*u,p=l+d-g+(o-h)*(a+u),y=f+g,m=c+d,w=l-c+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=be.checkMatrix(t);let e=new be(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),l=this.get(2,2),c=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),b=(-r+i+s)*(c-f+p),M=(i+s)*(-c+f),E=r*c,N=(-r+h+u)*(c-d+y),S=(-r+h)*(d-y),A=(h+u)*(-c+d),k=(-o+u+l)*(p+m-w),I=(o-l)*(p-w),D=o*m,_=(u+l)*(-m+w),R=(-o+s+a)*(y+m-v),z=(o-a)*(y-v),T=(s+a)*(-m+v),O=E+D+n*g,C=(r+n+o-i-s-u-l)*p+b+M+E+k+D+_,P=E+N+A+(r+n+o-s-a-h-u)*y+D+R+T,q=x+s*(-c+f+g-p-y-m+v)+b+E+D+R+z,L=x+b+M+E+a*w,F=D+R+z+T+i*d,j=E+N+S+u*(-c+d+g-p-y-m+w)+k+I+D,V=k+I+D+_+h*f,W=E+N+S+A+l*v;return e.set(0,0,O),e.set(0,1,C),e.set(0,2,P),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=be.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=ve.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),l=e.subMatrix(0,i-1,a,e.columns-1),c=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(ve.add(h,g),ve.add(u,p),i,a),m=t(ve.add(f,g),u,i,a),w=t(h,ve.sub(c,p),i,a),v=t(g,ve.sub(d,u),i,a),x=t(ve.add(h,l),p,i,a),b=t(ve.sub(f,h),ve.add(u,c),i,a),M=t(ve.sub(l,g),ve.add(d,p),i,a),E=ve.add(y,v);E.sub(x),E.add(M);let N=ve.add(w,x),S=ve.add(m,v),A=ve.sub(y,m);A.add(w),A.add(b);let k=ve.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 be(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 be(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=be.checkMatrix(t);let e=this.rows,r=this.columns,n=t.rows,o=t.columns,i=new be(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=be.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(be.eye(r,r)),o=be.eye(e,e).kroneckerProduct(t);return n.add(o)}transpose(){let t=new be(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=xe){for(let e=0;e<this.rows;e++)this.setRow(e,this.getRow(e).sort(t));return this}sortColumns(t=xe){for(let e=0;e<this.columns;e++)this.setColumn(e,this.getColumn(e).sort(t));return this}subMatrix(t,e,r,n){pe(this,t,e,r,n);let o=new be(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 be(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 be(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=be.checkMatrix(t)).isEmpty())return this;pe(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(!re(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(!re(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 be(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 be(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=ye(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=ye(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=ye(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=ye(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(!re(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(!re(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(!re(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(!re(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(!re(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(!re(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 he(this,t)}}function xe(t,e){return t-e}ve.prototype.klass="Matrix","undefined"!=typeof Symbol&&(ve.prototype[Symbol.for("nodejs.util.inspect.custom")]=function(){return he(this)}),ve.random=ve.rand,ve.randomInt=ve.randInt,ve.diagonal=ve.diag,ve.prototype.diagonal=ve.prototype.diag,ve.identity=ve.eye,ve.prototype.negate=ve.prototype.neg,ve.prototype.tensorProduct=ve.prototype.kroneckerProduct;class be extends ve{constructor(t,e){if(super(),be.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(!re(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 ce(this,t),this.data.splice(t,1),this.rows-=1,this}addRow(t,e){return void 0===e&&(e=t,t=this.rows),ce(this,t,!0),e=Float64Array.from(de(this,e)),this.data.splice(t,0,e),this.rows+=1,this}removeColumn(t){fe(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),fe(this,t,!0),e=ge(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}}(ve,be);class Me extends ve{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 Ee(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 Ne{constructor(t,e={}){if((t=Me.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),l=!1;if(r<n)if(s){a=t.transpose(),r=a.rows,n=a.columns,l=!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 c=Math.min(r,n),f=Math.min(r+1,n),d=new Float64Array(f),g=new be(r,c),p=new be(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)),b=Math.max(v,x);for(let t=0;t<b;t++){if(t<v){d[t]=0;for(let e=t;e<r;e++)d[t]=Ee(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]=Ee(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 M=Math.min(n,r+1);if(v<n&&(d[v]=a.get(v,v)),r<M&&(d[M-1]=0),x+1<M&&(y[x]=a.get(x,M-1)),y[M-1]=0,h){for(let t=v;t<c;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<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(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=M-1,N=0,S=Number.EPSILON;for(;M>0;){let t,e;for(t=M-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===M-2)e=4;else{let r;for(r=M-1;r>=t&&r!==t;r--){let e=(r!==M?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===M-1?e=1:(e=2,t=r)}switch(t++,e){case 1:{let e=y[M-2];y[M-2]=0;for(let r=M-2;r>=t;r--){let o=Ee(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,M-1),p.set(t,M-1,-s*p.get(t,r)+i*p.get(t,M-1)),p.set(t,r,o)}break}case 2:{let e=y[t-1];y[t-1]=0;for(let n=t;n<M;n++){let o=Ee(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[M-1]),Math.abs(d[M-2]),Math.abs(y[M-2]),Math.abs(d[t]),Math.abs(y[t])),o=d[M-1]/e,i=d[M-2]/e,s=y[M-2]/e,a=d[t]/e,l=y[t]/e,c=((i+o)*(i-o)+s*s)/2,f=o*s*(o*s);let m=0;0===c&&0===f||(m=c<0?0-Math.sqrt(c*c+f):Math.sqrt(c*c+f),m=f/(c+m));let w=(a+o)*(a-o)+m,v=a*l;for(let e=t;e<M-1;e++){let o=Ee(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=Ee(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[M-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,M--}}if(l){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=be.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,l=be.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);l.set(t,e,r)}return l.mmul(e)}solveForDiagonal(t){return this.solve(be.diag(t))}inverse(){let t=this.V,e=this.threshold,r=t.rows,n=t.columns,o=new be(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 be(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 be.diag(this.s)}}var Se,Ae={center:[0,0],linkDistance:50},ke=function(){function t(t){void 0===t&&(t={}),this.options=t,this.id="mds",this.options=r(r({},Ae),t)}return t.prototype.execute=function(t,e){return this.genericMDSLayout(!1,t,e)},t.prototype.assign=function(t,e){this.genericMDSLayout(!0,t,e)},t.prototype.genericMDSLayout=function(t,e,n){var o=r(r({},this.options),n),i=o.center,s=void 0===i?[0,0]:i,a=o.linkDistance,h=void 0===a?50:a,u=o.layoutInvisibles,l=o.onLayoutEnd,c=e.getAllNodes(),g=e.getAllEdges();if(u||(c=c.filter((function(t){var e=(t.data||{}).visible;return e||void 0===e})),g=g.filter((function(t){var e=(t.data||{}).visible;return e||void 0===e}))),!(null==c?void 0:c.length)||1===c.length)return N(e,t,s,l);var p=d({nodes:c,edges:g},!1),y=f(p);Ie(y);var m=function(t,e){var r=[];return t.forEach((function(t){var n=[];t.forEach((function(t){n.push(t*e)})),r.push(n)})),r}(y,h),w=De(m),x=[];w.forEach((function(t,e){var r=v(c[e]);r.data.x=t[0]+s[0],r.data.y=t[1]+s[1],x.push(r)})),t&&x.forEach((function(t){return e.mergeNodeData(t.id,{x:t.data.x,y:t.data.y})}));var b={nodes:x,edges:g};return null==l||l(b),b},t}(),Ie=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)}))}))},De=function(t){var e=be.mul(be.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 Ne(e),s=be.sqrt(i.diagonalMatrix).diagonal();return i.leftSingularVectors.toJSON().map((function(t){return be.mul([t],[s]).toJSON()[0].splice(0,2)}))},_e={iterations:10,height:10,width:10,speed:100,gravity:10,k:5},Re=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,l=s.y-e.y,c=Math.sqrt(u*u+l*l);if(0===c){c=1;var f=a>h?1:-1;u=.01*f,l=.01*f}if(c<i(t[a])/2+i(t[h])/2){var d=n*n/c;r[a].x+=u/c*d,r[a].y+=l/c*d}}}))}))},ze=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),l=Math.acos((a*e.x+h*e.y)/u);l>Math.PI/2&&(l-=Math.PI/2,a*=-1,h*=-1);var c=Math.cos(l)*u;e.x=a*c,e.y=h*c})),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 l=Math.min(h*(r/800),u);if(i.x+=e[s].x/u*l,i.y+=e[s].y/u*l,n){var c=i.x-t[o].x,f=i.y-t[o].y,d=Math.sqrt(c*c+f*f);c=c/d*a[s],f=f/d*a[s],i.x=t[o].x+c,i.y=t[o].y+f}}}})),t},Te={maxIteration:1e3,focusNode:null,unitRadius:null,linkDistance:50,preventOverlap:!1,strictRadial:!0,maxPreventOverlapIteration:200,sortStrength:10},Oe=function(){function t(t){void 0===t&&(t={}),this.options=t,this.id="radial",this.options=r(r({},Te),t)}return t.prototype.execute=function(t,e){return this.genericRadialLayout(!1,t,e)},t.prototype.assign=function(t,e){this.genericRadialLayout(!0,t,e)},t.prototype.genericRadialLayout=function(t,e,n){var s=r(r({},this.options),n),a=s.width,h=s.height,u=s.center,l=s.focusNode,c=s.unitRadius,g=s.nodeSize,p=s.nodeSpacing,y=s.strictRadial,m=s.preventOverlap,w=s.maxPreventOverlapIteration,x=s.sortBy,b=s.linkDistance,M=void 0===b?50:b,E=s.sortStrength,S=void 0===E?10:E,A=s.maxIteration,k=void 0===A?1e3:A,I=s.layoutInvisibles,_=s.onLayoutEnd,R=e.getAllNodes(),z=e.getAllEdges();I||(R=R.filter((function(t){var e=(t.data||{}).visible;return e||void 0===e})),z=z.filter((function(t){var e=(t.data||{}).visible;return e||void 0===e})));var T=a||"undefined"==typeof window?a:window.innerWidth,O=h||"undefined"==typeof window?h:window.innerHeight,C=u||[T/2,O/2];if(!(null==R?void 0:R.length)||1===R.length)return N(e,t,C,_);var P=R[0];if(D(l)){for(var q=0;q<R.length;q++)if(R[q].id===l){P=R[q];break}}else P=l||R[0];var L=qe(R,P.id),F=d({nodes:R,edges:z},!1),j=f(F),V=Fe(j,L);Le(j,L,V+1);var W=j[L],$=T-C[0]>C[0]?C[0]:T-C[0],G=O-C[1]>C[1]?C[1]:O-C[1];0===$&&($=T/2),0===G&&(G=O/2);var U=Math.min($,G),B=Math.max.apply(Math,i([],o(W),!1)),H=[],K=c||U/B;W.forEach((function(t,e){H[e]=t*K}));var J,Y=Ce(R,j,M,H,K,x,S),X=Pe(Y),Q=function(t,e,r){try{var n=be.mul(be.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 Ne(n),h=be.sqrt(a.diagonalMatrix).diagonal();return a.leftSingularVectors.toJSON().map((function(e){return be.mul([e],[h]).toJSON()[0].splice(0,t)}))}catch(t){for(var u=[],l=0;l<e.length;l++){var c=Math.random()*r,f=Math.random()*r;u.push([c,f])}return u}}(M,Y,M),Z=Q.map((function(t){var e=o(t,2),r=e[0],n=e[1];return{x:(isNaN(r)?Math.random()*M:r)-Q[L][0],y:(isNaN(n)?Math.random()*M:n)-Q[L][1]}}));if(this.run(k,Z,X,Y,H,L),m){J=je(g,p);var tt={nodes:R,nodeSizeFunc:J,positions:Z,radii:H,height:O,width:T,strictRadial:Boolean(y),focusIdx:L,iterations:w||200,k:Z.length/4.5};Z=function(t,e){for(var n=r(r({},_e),e),o=n.positions,i=n.iterations,s=n.width,a=n.k,h=n.speed,u=void 0===h?100:h,l=n.strictRadial,c=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}})),Re(p,o,y,a,d,g),ze(o,y,u,l,c,m,s,d);return o}(e,tt)}var et=[];Z.forEach((function(t,e){var r=v(R[e]);r.data.x=t.x+C[0],r.data.y=t.y+C[1],et.push(r)})),t&&et.forEach((function(t){return e.mergeNodeData(t.id,{x:t.data.x,y:t.data.y})}));var rt={nodes:et,edges:z};return null==_||_(rt),rt},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=g(a,{x:0,y:0}),l=0===u?0:1/u;if(h!==i){var c=0,f=0,d=0;e.forEach((function(t,e){if(h!==e){var r=g(a,t),i=0===r?0:1/r,s=n[e][h];d+=o[h][e],c+=o[h][e]*(t.x+s*(a.x-t.x)*i),f+=o[h][e]*(t.y+s*(a.y-t.y)*i)}}));var p=0===r[h]?0:1/r[h];d*=s,d+=t*p*p,c*=s,c+=t*p*a.x*l,a.x=c/d,f*=s,f+=t*p*a.y*l,a.y=f/d}}))},t}(),Ce=function(t,e,r,n,o,i,s){if(!t)return[];var a=[];if(e){var h={};e.forEach((function(e,u){var l=[];e.forEach((function(e,a){var c,f;if(u===a)l.push(0);else if(n[u]===n[a])if("data"===i)l.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===(c=t[u].data)||void 0===c?void 0:c[i])||0;d=D(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=D(p)?p.charCodeAt(0):p,h[t[a].id]=g),l.push(e*(Math.abs(d-g)*s)/(n[u]/o))}else l.push(e*r/(n[u]/o));else{var y=(r+o)/2;l.push(e*y)}})),a.push(l)}))}return a},Pe=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},qe=function(t,e){var r=-1;return t.forEach((function(t,n){t.id===e&&(r=n)})),Math.max(r,0)},Le=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}},Fe=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},je=function(t,e){var r;return r=m(e)?function(){return e}:x(e)?e:function(){return 0},t?c(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(c(t.data.size))return Math.max(t.data.size[0],t.data.size[1])+r(t);var o=t.data.size;return b(o)?(o.width>o.height?o.width:o.height)+r(t):o+r(t)}return 10+r(t)}},Ve={center:[0,0],width:300,height:300},We={circular:A,concentric:R,mds:ke,random:function(){function t(t){void 0===t&&(t={}),this.options=t,this.id="random",this.options=r(r({},Ve),t)}return t.prototype.execute=function(t,e){return this.genericRandomLayout(!1,t,e)},t.prototype.assign=function(t,e){this.genericRandomLayout(!0,t,e)},t.prototype.genericRandomLayout=function(t,e,n){var o=r(r({},this.options),n),i=o.center,s=o.width,a=o.height,h=o.layoutInvisibles,u=o.onLayoutEnd,l=e.getAllNodes();h||(l=l.filter((function(t){var e=(t.data||{}).visible;return e||void 0===e})));var c=s||"undefined"==typeof window?s:window.innerWidth,f=a||"undefined"==typeof window?a:window.innerHeight,d=i||[c/2,f/2],g=[];l&&l.forEach((function(t){g.push({id:t.id,data:{x:.9*(Math.random()-.5)*c+d[0],y:.9*(Math.random()-.5)*f+d[1]}})})),t&&g.forEach((function(t){return e.mergeNodeData(t.id,{x:t.data.x,y:t.data.y})}));var p={nodes:g,edges:e.getAllEdges()};return null==u||u(p),p},t}(),grid:Kt,radial:Oe,force:Tt,d3force:It,fruchterman:Bt,forceAtlas2:Gt};function $e(){(null==Se?void 0:Se.stop)&&Se.stop()}function Ge(t,e){return r=this,n=void 0,i=function(){var r,n,o,i,s,a,h,l;return function(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])}}}(this,(function(c){if(r=t.layout,n=r.id,o=r.options,i=r.iterations,s=t.nodes,a=t.edges,h=new u({nodes:s,edges:a}),!(l=We[n]))throw new Error("Unknown layout id: ".concat(n));return Se=new l(o),[2,new Promise((function(t){var r;Se.assign(h,{onLayoutEnd:function(r){t([r,e])}}),(r=Se).tick&&r.stop&&r.restart&&(Se.stop(),Se.tick(i))}))]}))},new((o=void 0)||(o=Promise))((function(t,e){function s(t){try{h(i.next(t))}catch(t){e(t)}}function a(t){try{h(i.throw(t))}catch(t){e(t)}}function h(e){var r;e.done?t(e.value):(r=e.value,r instanceof o?r:new o((function(t){t(r)}))).then(s,a)}h((i=i.apply(r,n||[])).next())}));var r,n,o,i}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=b6a955aaa104d7ff3f17.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:()=>P,W1:()=>B,jA:()=>$t,E9:()=>ue,y7:()=>Zt,O2:()=>ce,Me:()=>de,AI:()=>Ue,D4:()=>Ze,_5:()=>sr,y9:()=>$,Xp:()=>W,_A:()=>l,d9:()=>k,ul:()=>_,qs:()=>y,jE:()=>R,tO:()=>T,zJ:()=>m,h$:()=>M,BI:()=>S,$y:()=>A,H0:()=>b,kJ:()=>c,hY:()=>ur,qR:()=>hr,i_:()=>ar,nu:()=>v,He:()=>f,A3:()=>x});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){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 s(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 a,h,u=/-(\w)/g,l=(a=function(t){return t.replace(u,(function(t,e){return e?e.toUpperCase():""}))},h=Object.create(null),function(t){return h[t]||(h[t]=a(t))}),c=Array.isArray,f=function(t){var e=parseFloat(t);return isNaN(e)?t:e},d={}.toString;const g=function(t,e){return d.call(t)==="[object "+e+"]"},p=function(t){return g(t,"Number")};var y=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},m=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},v=function(t,e){var r=[];return t.forEach((function(t){var n=[];t.forEach((function(t){n.push(t*e)})),r.push(n)})),r},w=function(t,e){if(t&&t.children)for(var r=t.children.length-1;r>=0;r--)if(!w(t.children[r],e))return;return!!e(t)},x=function(t,e){"function"==typeof e&&w(t,e)},b=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;c(i)?1===i.length&&(i=[i[0],i[0]]):p(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],h=t.data.x+s[0],u=t.data.y-s[1],l=t.data.y+s[1];e>a&&(e=a),r>u&&(r=u),n<h&&(n=h),o<l&&(o=l)})),{minX:e,minY:r,maxX:n,maxY:o}},M=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}},E=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)||{}},N=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)},S=function(t,e,r,n,o,i){var s=o[e.id],a=s.in,h=s.out,u=e,l=[];0===a?(u=E("source",e,r),l=N("both",u,r).map((function(t){return i[t]}))):0===h&&(u=E("target",e,r),l=N("both",u,r).map((function(t){return i[t]}))),l=l.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]||"",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,l,o);return{coreNode:u,relativeLeafNodes:l,sameTypeLeafNodes:c}},A=function(t,e){return Math.sqrt((t.x-e.x)*(t.x-e.x)+(t.y-e.y)*(t.y-e.y))},k=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 k(t)}))}if("object"==typeof t){var r={};return Object.keys(t).forEach((function(e){r[e]=k(t[e])})),r}return t},_=function(t,e){var r=k(t);return r.data=r.data||{},e&&(p(r.data.x)||(r.data.x=Math.random()*e[0]),p(r.data.y)||(r.data.y=Math.random()*e[1])),r};const I=function(t){return"function"==typeof t},D=function(t){var e=typeof t;return null!==t&&"object"===e||"function"===e};function R(t,e){return I(e)?e:p(e)?function(){return e}:function(){return t}}function T(t,e,r){return void 0===r&&(r=!0),e||0===e?I(e)?e:p(e)?function(){return e}:c(e)?function(){if(r){var n=Math.max.apply(Math,s([],i(e),!1));return isNaN(n)?t:n}return e}:D(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?c(r)?r[0]>r[1]?r[0]:r[1]:D(r)?r.width>r.height?r.width:r.height:r:t}}var O=function(t,r,n,o){var i=t.getAllNodes(),s=t.getAllEdges();if(!(null==i?void 0:i.length)){var a={nodes:[],edges:s};return null==o||o(a),a}if(1===i.length)return r&&t.mergeNodeData(i[0].id,{x:n[0],y:n[1]}),a={nodes:[e(e({},i[0]),{data:e(e({},i[0].data),{x:n[0],y:n[1]})})],edges:s},null==o||o(a),a},z={radius:null,startRadius:null,endRadius:null,startAngle:0,endAngle:2*Math.PI,clockwise:!0,divisions:1,ordering:null,angleRatio:1},P=function(){function t(t){void 0===t&&(t={}),this.options=t,this.id="circular",this.options=e(e({},z),t)}return t.prototype.execute=function(t,e){return this.genericCircularLayout(!1,t,e)},t.prototype.assign=function(t,e){this.genericCircularLayout(!0,t,e)},t.prototype.genericCircularLayout=function(t,r,n){var o=e(e({},this.options),n),s=o.width,a=o.height,h=o.center,u=o.divisions,l=o.startAngle,c=void 0===l?0:l,f=o.endAngle,d=void 0===f?2*Math.PI:f,g=o.angleRatio,p=o.ordering,y=o.clockwise,m=o.nodeSpacing,v=o.nodeSize,w=o.layoutInvisibles,x=o.onLayoutEnd,b=r.getAllNodes(),M=r.getAllEdges();w||(b=b.filter((function(t){var e=(t.data||{}).visible;return e||void 0===e})),M=M.filter((function(t){var e=(t.data||{}).visible;return e||void 0===e})));var E=i(C(s,a,h),3),N=E[0],S=E[1],A=E[2],k=null==b?void 0:b.length;if(!k||1===k)return O(r,t,A,x);var I=(d-c)/k,D=o.radius,z=o.startRadius,P=o.endRadius;if(m){var q=R(10,m),F=T(10,v),j=-1/0;b.forEach((function(t){var e=F(t);j<e&&(j=e)}));var V=0;b.forEach((function(t,e){V+=0===e?j||10:(q(t)||0)+(j||10)})),D=V/(2*Math.PI)}else D||z||P?!z&&P?z=P:z&&!P&&(P=z):D=Math.min(S,N)/2;var W=I*g,$=[];$="topology"===p?L(r,b):"topology-directed"===p?L(r,b,!0):"degree"===p?function(t,e){var r=[];return e.forEach((function(t,e){r.push(_(t))})),r.sort((function(e,r){return t.getDegree(e.id,"both")-t.getDegree(r.id,"both")})),r}(r,b):b.map((function(t){return _(t)}));for(var G=Math.ceil(k/u),U=0;U<k;++U){var B=D;B||null===z||null===P||(B=z+U*(P-z)/(k-1)),B||(B=10+100*U/(k-1));var H=c+U%G*W+2*Math.PI/u*Math.floor(U/G);y||(H=d-U%G*W-2*Math.PI/u*Math.floor(U/G)),$[U].data.x=A[0]+Math.cos(H)*B,$[U].data.y=A[1]+Math.sin(H)*B}t&&$.forEach((function(t){r.mergeNodeData(t.id,{x:t.data.x,y:t.data.y})}));var K={nodes:$,edges:M};return null==x||x(K),K},t}(),L=function(t,e,r){void 0===r&&(r=!1);var n=[_(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),l=!1,c=0;c<u.length;c++){var f=u[c];if(t.getDegree(f.id)===t.getDegree(a.id)&&!o[f.id]){n.push(_(f)),o[f.id]=!0,l=!0;break}}for(var d=0;!l&&(o[e[d].id]||(n.push(_(e[d])),o[e[d].id]=!0,l=!0),++d!==i););}else n.push(_(a)),o[a.id]=!0,s++})),n},C=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]},q=r(161),F=r.n(q),j=r(825),V=r.n(j),W={LAYOUT_ITERATION:"tick",LAYOUT_END:"layoutend"},$=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=V()(),this.running&&(this.running=!1,this.start())},r.prototype.start=function(){var t,e=this;if(this.running)return this;this.running=!0;var r=this.layout.options,n=(r.onLayoutEnd,r.onTick,o(r,["onLayoutEnd","onTick"])),s={layout:{id:this.layout.id,options:n,iterations:null===(t=this.options)||void 0===t?void 0:t.iterations},nodes:this.graph.getAllNodes(),edges:this.graph.getAllEdges()},a=new Float32Array([0]);return this.worker.calculateLayout(s,[a]).then((function(t){var r=i(t,2),n=r[0];r[1],e.emit(W.LAYOUT_END,n),e.layout.options.onLayoutEnd&&e.layout.options.onLayoutEnd(n)})),this},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}(F());const G=function(t){return g(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"},B=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 this.genericConcentricLayout(!1,t,e)},t.prototype.assign=function(t,e){this.genericConcentricLayout(!0,t,e)},t.prototype.genericConcentricLayout=function(t,r,n){var o=e(e({},this.options),n),i=o.center,s=o.width,a=o.height,h=o.sortBy,u=o.maxLevelDiff,l=o.sweep,f=o.clockwise,d=o.equidistant,g=o.preventOverlap,y=o.startAngle,m=void 0===y?1.5*Math.PI:y,v=o.nodeSize,w=o.nodeSpacing,x=o.layoutInvisibles,b=o.onLayoutEnd,M=r.getAllNodes(),E=r.getAllEdges();x||(M=M.filter((function(t){var e=(t.data||{}).visible;return e||void 0===e})),E=E.filter((function(t){var e=(t.data||{}).visible;return e||void 0===e})));var N=s||"undefined"==typeof window?s:window.innerWidth,S=a||"undefined"==typeof window?a:window.innerHeight,A=i||[N/2,S/2];if(!(null==M?void 0:M.length)||1===M.length)return O(r,t,A,b);var k,R=[],T=0;k=c(v)?Math.max(v[0],v[1]):v,c(w)?T=Math.max(w[0],w[1]):p(w)&&(T=w),M.forEach((function(t){var e=_(t);R.push(e);var r=k,n=e.data;c(n.size)?r=Math.max(n.size[0],n.size[1]):p(n.size)?r=n.size:D(n.size)&&(r=Math.max(n.size.width,n.size.height)),k=Math.max(k,r),I(w)&&(T=Math.max(w(t),T))}));var z={};R.forEach((function(t,e){z[t.id]=e}));var P=h;G(P)&&void 0!==R[0].data[P]||(P="degree"),"degree"===P?R.sort((function(t,e){return r.getDegree(e.id,"both")-r.getDegree(t.id,"both")})):R.sort((function(t,e){return e.data[P]-t.data[P]}));var L=R[0],C=(u||("degree"===P?r.getDegree(L.id,"both"):L.data[P]))/4,q=[{nodes:[]}],F=q[0];R.forEach((function(t){if(F.nodes.length>0){var e="degree"===P?Math.abs(r.getDegree(F.nodes[0].id,"both")-r.getDegree(t.id,"both")):Math.abs(F.nodes[0].data[P]-t.data[P]);C&&e>=C&&(F={nodes:[]},q.push(F))}F.nodes.push(t)}));var j=k+T;if(!g){var V=q.length>0&&q[0].nodes.length>1,W=(Math.min(N,S)/2-j)/(q.length+(V?1:0));j=Math.min(j,W)}var $=0;if(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&&g){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})),d){for(var U=0,B=0,H=0;H<q.length;H++){var K=(q[H].r||0)-B;U=Math.max(U,K)}B=0,q.forEach((function(t,e){0===e&&(B=t.r||0),t.r=B,B+=U}))}q.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=A[0]+r*Math.cos(o),t.data.y=A[1]+r*Math.sin(o)}))})),t&&R.forEach((function(t){return r.mergeNodeData(t.id,{x:t.data.x,y:t.data.y})}));var J={nodes:R,edges:E};return null==b||b(J),J},t}();function H(t,e,r,n){if(isNaN(e)||isNaN(r))return t;var o,i,s,a,h,u,l,c,f,d=t._root,g={data:n},p=t._x0,y=t._y0,m=t._x1,v=t._y1;if(!d)return t._root=g,t;for(;d.length;)if((u=e>=(i=(p+m)/2))?p=i:m=i,(l=r>=(s=(y+v)/2))?y=s:v=s,o=d,!(d=d[c=l<<1|u]))return o[c]=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[c]=g:t._root=g,t;do{o=o?o[c]=new Array(4):t._root=new Array(4),(u=e>=(i=(p+m)/2))?p=i:m=i,(l=r>=(s=(y+v)/2))?y=s:v=s}while((c=l<<1|u)==(f=(h>=s)<<1|a>=i));return o[f]=d,o[c]=g,t}function K(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 Y(t){return t[1]}function X(t,e,r){var n=new Z(null==e?J:e,null==r?Y:r,NaN,NaN,NaN,NaN);return null==t?n:n.addAll(t)}function Z(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 Q(t){for(var e={data:t.data},r=e;t=t.next;)r=r.next={data:t.data};return e}var tt=X.prototype=Z.prototype;function et(t){return function(){return t}}function rt(t){return 1e-6*(t()-.5)}tt.copy=function(){var t,e,r=new Z(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=Q(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]=Q(e));return r},tt.add=function(t){const e=+this._x.call(null,t),r=+this._y.call(null,t);return H(this.cover(e,r),e,r,t)},tt.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,l=-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))||(s[r]=n,a[r]=o,n<h&&(h=n),n>l&&(l=n),o<u&&(u=o),o>c&&(c=o));if(h>l||u>c)return this;for(this.cover(h,u).cover(l,c),r=0;r<i;++r)H(this,s[r],a[r],t[r]);return this},tt.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},tt.data=function(){var t=[];return this.visit((function(e){if(!e.length)do{t.push(e.data)}while(e=e.next)})),t},tt.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]]},tt.find=function(t,e,r){var n,o,i,s,a,h,u,l=this._x0,c=this._y0,f=this._x1,d=this._y1,g=[],p=this._root;for(p&&g.push(new K(p,l,c,f,d)),null==r?r=1/0:(l=t-r,c=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)<l||(a=h.y1)<c))if(p.length){var y=(o+s)/2,m=(i+a)/2;g.push(new K(p[3],y,m,s,a),new K(p[2],o,m,y,a),new K(p[1],y,i,s,m),new K(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 v=t-+this._x.call(null,p.data),w=e-+this._y.call(null,p.data),x=v*v+w*w;if(x<r){var b=Math.sqrt(r=x);l=t-b,c=e-b,f=t+b,d=e+b,n=p.data}}return n},tt.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,l,c,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,(l=s>=(h=(p+m)/2))?p=h:m=h,e=d,!(d=d[c=l<<1|u]))return this;if(!d.length)break;(e[c+1&3]||e[c+2&3]||e[c+3&3])&&(r=e,f=c)}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[c]=o:delete e[c],(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)},tt.removeAll=function(t){for(var e=0,r=t.length;e<r;++e)this.remove(t[e]);return this},tt.root=function(){return this._root},tt.size=function(){var t=0;return this.visit((function(e){if(!e.length)do{++t}while(e=e.next)})),t},tt.visit=function(t){var e,r,n,o,i,s,a=[],h=this._root;for(h&&a.push(new K(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,l=(o+s)/2;(r=h[3])&&a.push(new K(r,u,l,i,s)),(r=h[2])&&a.push(new K(r,n,l,u,s)),(r=h[1])&&a.push(new K(r,u,o,i,l)),(r=h[0])&&a.push(new K(r,n,o,u,l))}return this},tt.visitAfter=function(t){var e,r=[],n=[];for(this._root&&r.push(new K(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,l=(s+h)/2,c=(a+u)/2;(i=o[0])&&r.push(new K(i,s,a,l,c)),(i=o[1])&&r.push(new K(i,l,a,h,c)),(i=o[2])&&r.push(new K(i,s,c,l,u)),(i=o[3])&&r.push(new K(i,l,c,h,u))}n.push(e)}for(;e=n.pop();)t(e.node,e.x0,e.y0,e.x1,e.y1);return this},tt.x=function(t){return arguments.length?(this._x=t,this):this._x},tt.y=function(t){return arguments.length?(this._y=t,this):this._y};var nt={value:()=>{}};function ot(){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 it(n)}function it(t){this._=t}function st(t,e){return t.trim().split(/^|\s+/).map((function(t){var r="",n=t.indexOf(".");if(n>=0&&(r=t.slice(n+1),t=t.slice(0,n)),t&&!e.hasOwnProperty(t))throw new Error("unknown type: "+t);return{type:t,name:r}}))}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 ht(t,e,r){for(var n=0,o=t.length;n<o;++n)if(t[n].name===e){t[n]=nt,t=t.slice(0,n).concat(t.slice(n+1));break}return null!=r&&t.push({name:e,value:r}),t}it.prototype=ot.prototype={constructor:it,on:function(t,e){var r,n=this._,o=st(t+"",n),i=-1,s=o.length;if(!(arguments.length<2)){if(null!=e&&"function"!=typeof e)throw new Error("invalid callback: "+e);for(;++i<s;)if(r=(t=o[i]).type)n[r]=ht(n[r],t.name,e);else if(null==e)for(r in n)n[r]=ht(n[r],t.name,null);return this}for(;++i<s;)if((r=(t=o[i]).type)&&(r=at(n[r],t.name)))return r},copy:function(){var t={},e=this._;for(var r in e)t[r]=e[r].slice();return new it(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 ut=ot;var lt,ct,ft=0,dt=0,gt=0,pt=0,yt=0,mt=0,vt="object"==typeof performance&&performance.now?performance:Date,wt="object"==typeof window&&window.requestAnimationFrame?window.requestAnimationFrame.bind(window):function(t){setTimeout(t,17)};function xt(){return yt||(wt(bt),yt=vt.now()+mt)}function bt(){yt=0}function Mt(){this._call=this._time=this._next=null}function Et(t,e,r){var n=new Mt;return n.restart(t,e,r),n}function Nt(){yt=(pt=vt.now())+mt,ft=dt=0;try{!function(){xt(),++ft;for(var t,e=lt;e;)(t=yt-e._time)>=0&&e._call.call(void 0,t),e=e._next;--ft}()}finally{ft=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);ct=t,At(n)}(),yt=0}}function St(){var t=vt.now(),e=t-pt;e>1e3&&(mt-=e,pt=t)}function At(t){ft||(dt&&(dt=clearTimeout(dt)),t-yt>24?(t<1/0&&(dt=setTimeout(Nt,t-vt.now()-mt)),gt&&(gt=clearInterval(gt))):(gt||(pt=vt.now(),gt=setInterval(St,1e3)),ft=1,wt(Nt)))}Mt.prototype=Et.prototype={constructor:Mt,restart:function(t,e,r){if("function"!=typeof t)throw new TypeError("callback is not a function");r=(null==r?xt():+r)+(null==e?0:+e),this._next||ct===this||(ct?ct._next=this:lt=this,ct=this),this._call=t,this._time=r,At()},stop:function(){this._call&&(this._call=null,this._time=1/0,At())}};const kt=4294967296;function _t(t){return t.x}function It(t){return t.y}var Dt=Math.PI*(3-Math.sqrt(5));function Rt(t){var e,r=1,n=.001,o=1-Math.pow(n,1/300),i=0,s=.6,a=new Map,h=Et(c),u=ut("tick","end"),l=function(){let t=1;return()=>(t=(1664525*t+1013904223)%kt)/kt}();function c(){f(),u.call("tick",e),r<n&&(h.stop(),u.call("end",e))}function f(n){var h,u,l=t.length;void 0===n&&(n=1);for(var c=0;c<n;++c)for(r+=(i-r)*o,a.forEach((function(t){t(r)})),h=0;h<l;++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=10*Math.sqrt(.5+r),i=r*Dt;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,l),e}return null==t&&(t=[]),d(),e={tick:f,restart:function(){return h.restart(c),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?(l=t,a.forEach(g),e):l},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,l=t.length;for(null==n?n=1/0:n*=n,u=0;u<l;++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 Tt(){var t,e,r,n,o,i=et(-30),s=1,a=1/0,h=.81;function u(r){var o,i=t.length,s=X(t,_t,It).visitAfter(c);for(n=r,o=0;o<i;++o)e=t[o],s.visit(f)}function l(){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,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,l){if(!t.value)return!0;var c=t.x-e.x,f=t.y-e.y,d=l-i,g=c*c+f*f;if(d*d/h<g)return g<a&&(0===c&&(g+=(c=rt(r))*c),0===f&&(g+=(f=rt(r))*f),g<s&&(g=Math.sqrt(s*g)),e.vx+=c*t.value*n/g,e.vy+=f*t.value*n/g),!0;if(!(t.length||g>=a)){(t.data!==e||t.next)&&(0===c&&(g+=(c=rt(r))*c),0===f&&(g+=(f=rt(r))*f),g<s&&(g=Math.sqrt(s*g)));do{t.data!==e&&(d=o[t.data.index]*n/g,e.vx+=c*d,e.vy+=f*d)}while(t=t.next)}}return u.initialize=function(e,n){t=e,r=n,l()},u.strength=function(t){return arguments.length?(i="function"==typeof t?t:et(+t),l(),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 Ot(t){return t.index}function zt(t,e){var r=t.get(e);if(!r)throw new Error("node not found: "+e);return r}function Pt(t){var e,r,n,o,i,s,a=Ot,h=function(t){return 1/Math.min(o[t.source.index],o[t.target.index])},u=et(30),l=1;function c(n){for(var o=0,a=t.length;o<l;++o)for(var h,u,c,f,d,g,p,y=0;y<a;++y)u=(h=t[y]).source,f=(c=h.target).x+c.vx-u.x-u.vx||rt(s),d=c.y+c.vy-u.y-u.vy||rt(s),f*=g=((g=Math.sqrt(f*f+d*d))-r[y])/g*n*e[y],d*=g,c.vx-=f*(p=i[y]),c.vy-=d*p,u.vx+=f*(p=1-p),u.vy+=d*p}function f(){if(n){var s,h,u=n.length,l=t.length,c=new Map(n.map(((t,e)=>[a(t,e,n),t])));for(s=0,o=new Array(u);s<l;++s)(h=t[s]).index=s,"object"!=typeof h.source&&(h.source=zt(c,h.source)),"object"!=typeof h.target&&(h.target=zt(c,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(l);s<l;++s)h=t[s],i[s]=o[h.source.index]/(o[h.source.index]+o[h.target.index]);e=new Array(l),d(),r=new Array(l),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=[]),c.initialize=function(t,e){n=t,s=e,f()},c.links=function(e){return arguments.length?(t=e,f(),c):t},c.id=function(t){return arguments.length?(a=t,c):a},c.iterations=function(t){return arguments.length?(l=+t,c):l},c.strength=function(t){return arguments.length?(h="function"==typeof t?t:et(+t),d(),c):h},c.distance=function(t){return arguments.length?(u="function"==typeof t?t:et(+t),g(),c):u},c}function Lt(t){return t.x+t.vx}function Ct(t){return t.y+t.vy}function qt(t){var e,r,n,o=1,i=1;function s(){for(var t,s,h,u,l,c,f,d=e.length,g=0;g<i;++g)for(s=X(e,Lt,Ct).visitAfter(a),t=0;t<d;++t)h=e[t],c=r[h.index],f=c*c,u=h.x+h.vx,l=h.y+h.vy,s.visit(p);function p(t,e,r,i,s){var a=t.data,d=t.r,g=c+d;if(!a)return e>u+g||i<u-g||r>l+g||s<l-g;if(a.index>h.index){var p=u-a.x-a.vx,y=l-a.y-a.vy,m=p*p+y*y;m<g*g&&(0===p&&(m+=(p=rt(n))*p),0===y&&(m+=(y=rt(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=et(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:et(+e),h(),s):t},s}function Ft(t){var e,r,n,o=et(.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=et(null==t?0:+t)),i.initialize=function(t){e=t,s()},i.strength=function(t){return arguments.length?(o="function"==typeof t?t:et(+t),s(),i):o},i.x=function(e){return arguments.length?(t="function"==typeof e?e:et(+e),s(),i):t},i}function jt(t){var e,r,n,o=et(.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=et(null==t?0:+t)),i.initialize=function(t){e=t,s()},i.strength=function(t){return arguments.length?(o="function"==typeof t?t:et(+t),s(),i):o},i.y=function(e){return arguments.length?(t="function"==typeof e?e:et(+e),s(),i):t},i}function Vt(){function t(t){return function(){return t}}var e,r=function(t){return t.cluster},n=t(1),o=t(-1),s=t(100),a=t(.1),h=[0,0],u=[],l={},c=[],f=100,d=100,g={none:{x:0,y:0}},p=[],y="force",m=!0,v=.1;function w(t){if(!m)return w;e.tick(),b();for(var n=0,o=u.length,i=void 0,s=t*v;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,v=(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(l[o]))<=(a=r(l[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=i(t,2),r=e[0],o=e[1],s=r.split("~")[0],a=r.split("~")[1];void 0!==s&&void 0!==a&&n.push({source:s,target:a,count:o})})),n}(c),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=Rt(v.nodes).force("x",Ft(f).strength(.1)).force("y",jt(d).strength(.1)).force("collide",qt((function(t){return t.r})).iterations(4)).force("charge",Tt().strength(o)).force("links",Pt(v.nodes.length?v.links:[]).distance(s).strength(a)),p=e.nodes(),b()}}()}function b(){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}function M(t){l={},t.forEach((function(t){l[t.id]=t}))}return w.initialize=function(t){u=t,x()},w.template=function(t){return arguments.length?(y=t,x(),w):y},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?(m=t,w):m},w.strength=function(t){return arguments.length?(v=t,w):v},w.centerX=function(t){return arguments.length?(f=t,w):f},w.centerY=function(t){return arguments.length?(d=t,w):d},w.nodes=function(t){return arguments.length?(M(t||[]),u=t||[],w):u},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?(s="function"==typeof e?e:t(+e),x(),w):s},w.forceLinkStrength=function(e){return arguments.length?(a="function"==typeof e?e:t(+e),x(),w):a},w.offset=function(t){return arguments.length?(h=t,w):h},w.getFocis=b,w}var Wt={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},$t=function(){function t(t){void 0===t&&(t={}),this.options=t,this.id="d3force",this.running=!1,this.options=e(e({},Wt),t)}return t.prototype.execute=function(t,e){return this.genericForceLayout(!1,t,e)},t.prototype.assign=function(t,e){this.genericForceLayout(!0,t,e)},t.prototype.stop=function(){var t;null===(t=this.forceSimulation)||void 0===t||t.stop(),this.running=!1},t.prototype.restart=function(){var t;null===(t=this.forceSimulation)||void 0===t||t.restart(),this.running=!0},t.prototype.tick=function(t){var e=this;void 0===t&&(t=1),this.forceSimulation.tick(t);var r={nodes:Gt(this.lastLayoutNodes),edges:Ut(this.lastLayoutEdges)};return this.lastAssign&&r.nodes.forEach((function(t){return e.lastGraph.mergeNodeData(t.id,{x:t.data.x,y:t.data.y})})),this.lastOptions.onLayoutEnd&&this.lastOptions.onLayoutEnd(r),r},t.prototype.genericForceLayout=function(t,r,n){var o=this,i=e(e({},this.options),n),s=i.layoutInvisibles,a=r.getAllNodes(),h=r.getAllEdges();s||(a=a.filter((function(t){var e=(t.data||{}).visible;return e||void 0===e})),h=h.filter((function(t){var e=(t.data||{}).visible;return e||void 0===e})));var u=a.map((function(t){var r,n;return e(e({},_(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})})),l=h.map((function(t){return _(t)}));if(this.lastLayoutNodes=u,this.lastLayoutEdges=l,this.lastAssign=t,this.lastGraph=r,this.lastOptions=i,!this.running){var c=i.alphaMin,f=i.alphaDecay,d=i.alpha,g=i.nodeStrength,p=i.edgeStrength,y=i.linkDistance,m=i.clustering,v=i.clusterFociStrength,w=i.clusterEdgeDistance,x=i.clusterEdgeStrength,b=i.clusterNodeStrength,M=i.clusterNodeSize,E=i.collideStrength,N=void 0===E?1:E,S=i.center,A=void 0===S?[0,0]:S,k=i.preventOverlap,I=i.nodeSize,D=i.nodeSpacing,R=i.onTick,T=i.onLayoutEnd,O=i.forceSimulation;if(O)m&&((z=Vt()).nodes(u),z.links(l)),O.nodes(u),l&&(L=Pt().id((function(t){return t.id})).links(l),p&&L.strength(p),y&&L.distance(y),O.force("link",L)),k&&this.overlapProcess(O,{nodeSize:I,nodeSpacing:D,collideStrength:N}),O.alpha(d).restart(),this.running=!0;else try{var z,P=Tt();if(g&&P.strength(g),O=Rt().nodes(u),m&&((z=Vt()).centerX(A[0]).centerY(A[1]).template("force").strength(v),l&&z.links(l),u&&z.nodes(u),z.forceLinkDistance(w).forceLinkStrength(x).forceCharge(b).forceNodeSize(M),O.force("group",z)),O.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",P).alpha(d).alphaDecay(f).alphaMin(c),k&&this.overlapProcess(O,{nodeSize:I,nodeSpacing:D,collideStrength:N}),l){var L=Pt().id((function(t){return t.id})).links(l);p&&L.strength(p),y&&L.distance(y),O.force("link",L)}O.on("tick",(function(){var e=Gt(u);null==R||R({nodes:e,edges:Ut(l)}),t&&e.forEach((function(t){return r.mergeNodeData(t.id,{x:t.data.x,y:t.data.y})}))})).on("end",(function(){o.running=!1;var e=Gt(u);null==T||T({nodes:e,edges:Ut(l)}),t&&e.forEach((function(t){return r.mergeNodeData(t.id,{x:t.data.x,y:t.data.y})}))})),this.running=!0}catch(t){this.running=!1,console.warn(t)}this.forceSimulation=O;var C=Gt(u),q=Ut(l);return t&&C.forEach((function(t){return r.mergeNodeData(t.id,{x:t.data.x,y:t.data.y})})),{nodes:C,edges:q}}},t.prototype.overlapProcess=function(t,e){var r,n,o=e.nodeSize,i=e.nodeSpacing,s=e.collideStrength;if(n=p(i)?function(){return i}:I(i)?i:function(){return 0},o)if(I(o))r=function(t){return o(t)+n(t)};else if(c(o)){var a=(o[0]>o[1]?o[0]:o[1])/2;r=function(t){return a+n(t)}}else if(p(o)){var h=o/2;r=function(t){return h+n(t)}}else r=function(){return 10};else r=function(t){return t.size?c(t.size)?(t.size[0]>t.size[1]?t.size[0]:t.size[1])/2+n(t):D(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",qt(r).strength(s))},t}(),Gt=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})})}))},Ut=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})}))};const Bt=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["*"]||[],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 Ht(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 Kt(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)&&Kt(o,e,r,n))return!0;return!1}class Jt extends Bt{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 Kt(this.getNode(t),new Set,e,(t=>this.getChildren(t,r)))}bfsTree(t,e,r){return Ht([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 Ht([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 Kt(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 Jt({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 Yt(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 Xt={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"},Zt=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({},Xt),t)}return t.prototype.execute=function(t,e){return this.genericForceLayout(!1,t,e)},t.prototype.assign=function(t,e){this.genericForceLayout(!0,t,e)},t.prototype.stop=function(){this.timeInterval&&"undefined"!=typeof window&&window.clearInterval(this.timeInterval),this.running=!1},t.prototype.restart=function(){this.running=!0},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})})),this.lastOptions.onLayoutEnd&&this.lastOptions.onLayoutEnd(n),n},t.prototype.genericForceLayout=function(t,r,n){var o=this,i=e(e({},this.options),n),s=r.getAllNodes(),a=r.getAllEdges();i.layoutInvisibles||(s=s.filter((function(t){return t.data.visible||void 0===t.data.visible})),a=a.filter((function(t){return t.data.visible||void 0===t.data.visible})));var h=this.formatOptions(i,r),u=h.width,l=h.height,c=h.nodeSize,f=h.getMass,d=h.nodeStrength,g=h.edgeStrength,y=h.linkDistance,m=s.map((function(t){return e(e({},t),{data:e(e({},t.data),{x:p(t.data.x)?t.data.x:Math.random()*u,y:p(t.data.y)?t.data.y:Math.random()*l,size:c(t)||30,mass:f(t),nodeStrength:d(t)})})})),v=a.map((function(t){return e(e({},t),{data:e(e({},t.data),{edgeStrength:g(t),linkDistance:y(t,r.getNode(t.source),r.getNode(t.target))})})}));if(!(null==s?void 0:s.length))return this.lastResult={nodes:[],edges:a},{nodes:[],edges:a};var w={};s.forEach((function(t,e){w[t.id]={x:0,y:0}}));var x=new Jt({nodes:m,edges:v});this.formatCentripetal(h,x);var b=h.maxIteration,M=h.minMovement,E=h.onLayoutEnd,N=h.onTick;if(this.lastLayoutNodes=m,this.lastLayoutEdges=v,this.lastAssign=t,this.lastGraph=r,this.lastCalcGraph=x,this.lastOptions=h,this.lastVelMap=w,"undefined"!=typeof window){var S=0;return this.timeInterval=window.setInterval((function(){s&&o.running&&(o.runOneStep(x,r,S,w,h),o.updatePosition(r,x,w,h),t&&m.forEach((function(t){return r.mergeNodeData(t.id,{x:t.data.x,y:t.data.y})})),null==N||N({nodes:ne(r,m),edges:a}),(++S>=b||o.judgingDistance<M)&&(null==E||E({nodes:ne(r,m),edges:a}),window.clearInterval(o.timeInterval)))}),0),this.running=!0,{nodes:ne(r,m),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;p(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=R(0,t.nodeSpacing);t.nodeSize?c(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?c(e)?Math.max(e[0],e[1])+s(t):D(e)?Math.max(e.width,e.height)+s(t):e+s(t):10+s(t)}}return r.linkDistance=t.linkDistance?R(1,t.linkDistance):function(t){return 1+r.nodeSize(e.getNode(t.source))+r.nodeSize(e.getNode(t.target))},r.nodeStrength=R(1,t.nodeStrength),r.edgeStrength=R(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(),l=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(s&&h&&(r=Qt(e,h),c=Array.from(new Set(null==u?void 0:u.map((function(t){return t.data[h]}))))||[],t.centripetalOptions=Object.assign(l,{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,s=void 0===i?[]:i;1===s.length?n=void 0:s.length>1&&(n=re(s))}else n=void 0;return{x:null==n?void 0:n.x,y:null==n?void 0:n.y}}})),a&&h){r||(r=Qt(e,h)),c||(c=Array.from(new Set(u.map((function(t){return t.data[h]}))))),c=c.filter((function(t){return void 0!==t}));var f={};c.forEach((function(t){var r=u.filter((function(e){return e.data[h]===t})).map((function(t){return e.getNode(t.id)}));f[t]=re(r)})),t.centripetalOptions=Object.assign(l,{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=X(s,(function(t){return t.x}),(function(t){return t.y})).visitAfter(Yt);s.forEach((function(t){!function(t,e){e.visit((function(e,r,n,o,i){return 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,l=Math.sqrt(u)*u;if(h*h*.81<u){var c=t.weight/l;return i.vx+=s*c,i.vy+=a*c,!0}if(t.length)return!1;t.data!==i&&(c=t.data.weight/l,i.vx+=s*c,i.vy+=a*c)}(e,r,0,o,0,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 l=Math.sqrt(h*h+u*u),c=h/l,f=u/l,d=r.data||{},g=d.linkDistance,p=void 0===g?200:g,y=d.edgeStrength,m=(p-l)*(void 0===y?200:y),v=1/(s.data.mass||1),w=1/(a.data.mass||1),x=c*m,b=f*m;e[o].x-=x*v,e[o].y-=b*v,e[i].x+=x*w,e[i].y+=b*w}}))},t.prototype.calGravity=function(t,e,r,n){var o=n.getCenter,s=t.getAllNodes(),a=e.getAllNodes(),h=e.getAllEdges(),u=n.width,l=n.height,c=n.center,f=n.gravity,d=n.centripetalOptions;s&&s.forEach((function(n){var s=n.id,g=n.data,y=g.mass,m=g.x,v=g.y,w=e.getNode(s),x=0,b=0,M=f,E=t.getDegree(s,"in"),N=t.getDegree(s,"out"),S=t.getDegree(s,"both"),A=null==o?void 0:o(w,S);if(A){var k=i(A,3);x=m-k[0],b=v-k[1],M=k[2]}else x=m-c[0],b=v-c[1];if(M&&(r[s].x-=M*x/y,r[s].y-=M*b/y),d){var _=d.leaf,I=d.single,D=d.others,R=d.center,T=(null==R?void 0:R(w,a,h,u,l))||{x:0,y:0,centerStrength:0},O=T.x,z=T.y,P=T.centerStrength;if(!p(O)||!p(z))return;var L=(m-O)/y,C=(v-z)/y;if(P&&(r[s].x-=P*L,r[s].y-=P*C),0===S){var q=I(w);if(!q)return;return r[s].x-=q*L,void(r[s].y-=q*C)}if(0===E||0===N){var F=_(w,a,h);if(!F)return;return r[s].x-=F*L,void(r[s].y-=F*C)}var j=D(w);if(!j)return;r[s].x-=j*L,r[s].y-=j*C}}))},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 l=i/u;a*=l,h*=l}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(p(u.data.fx)&&p(u.data.fy))e.mergeNodeData(a,{x:u.data.fx,y:u.data.fy});else{var l=r[a].x*s,c=r[a].y*s;e.mergeNodeData(a,{x:n.data.x+l,y:n.data.y+c});var f=Math.sqrt(l*l+c*c);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}(),Qt=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]=te(t,"leaf",r,e))})),n},te=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:ee(t,e,n,r,a)}},ee=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},re=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}},ne=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})})}))},oe=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 ie=oe;const se=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}(),ae=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 he={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},ue=function(){function t(t){void 0===t&&(t={}),this.options=t,this.id="forceAtlas2",this.options=e(e({},he),t)}return t.prototype.execute=function(t,e){return this.genericForceAtlas2Layout(!1,t,e)},t.prototype.assign=function(t,e){this.genericForceAtlas2Layout(!0,t,e)},t.prototype.genericForceAtlas2Layout=function(t,r,n){var o=r.getAllEdges(),i=r.getAllNodes(),s=this.formatOptions(n,i.length),a=s.width,h=s.height,u=s.prune,l=s.maxIteration,c=s.nodeSize,f=s.center,d=s.onLayoutEnd;if(!(null==i?void 0:i.length)||1===i.length)return O(r,t,f,d);var g=i.map((function(t){return _(t,[a,h])})),p=o.filter((function(t){return t.source!==t.target})),y=new Jt({nodes:g,edges:p}),m=this.getSizes(y,r,c);if(this.run(y,r,l,m,t,s),u){for(var v=0;v<p.length;v+=1){var w=p[v],x=w.source,b=w.target,M=y.getDegree(x),E=y.getDegree(x);if(M<=1){var N=y.getNode(b);y.mergeNodeData(x,{x:N.data.x,y:N.data.y})}else if(E<=1){var S=y.getNode(x);y.mergeNodeData(b,{x:S.data.x,y:S.data.y})}}var A=e(e({},s),{prune:!1,barnesHut:!1});this.run(y,r,100,m,t,A)}var k={nodes:g,edges:o};return null==d||d(k),k},t.prototype.getSizes=function(t,e,r){for(var n=t.getAllNodes(),o={},a=0;a<n.length;a+=1){var h=n[a],u=h.id,l=h.data;if(o[u]=10,p(l.size))o[u]=l.size;else if(c(l.size))isNaN(l.size[0])||(o[u]=Math.max(l.size[0])),isNaN(l.size[1])||(o[u]=Math.max(l.size[1]));else if(D(l.size))o[u]=Math.max(l.size.width,l.size.height);else if(I(r)){var f=r(e.getNode(u));c(f)?o[u]=Math.max.apply(Math,s([],i(f),!1)):o[u]=f}else c(r)?o[u]=Math.max.apply(Math,s([],i(r),!1)):p(r)&&(o[u]=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,h=n.prune,u=n.maxIteration,l=n.kr,c=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===h&&r>100&&(n.prune=!0),0!==u||h?0===u&&h&&(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)),l||(n.kr=50,r>100&&r<=500?n.kr=20:r>500&&(n.kr=1)),c||(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,h=i.onTick,u=t.getAllNodes(),l=0,c=r,f={},d={},g={},p=0;p<u.length;p+=1){var y=u[p],m=y.data,v=y.id;if(f[v]=[0,0],a){var w={id:p,rx:m.x,ry:m.y,mass:1,g:s,degree:t.getDegree(v)};g[v]=new ie(w)}}for(;c>0;)l=this.oneStep(t,{iter:c,preventOverlapIters:50,krPrime:100,sg:l,forces:f,preForces:d,bodies:g,sizes:n},i),c--,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,a=e.krPrime,h=e.sg,u=e.preForces,l=e.bodies,c=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]=s([],i(f[m]),!1),f[m]=[0,0]}return f=this.getAttrForces(t,n,o,c,f,r),f=g&&(d&&n>o||!d)?this.getOptRepGraForces(t,f,l,r):this.getRepGraForces(t,n,o,f,a,c,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,l=t.getAllEdges(),c=0;c<l.length;c+=1){var f=l[c],d=f.source,g=f.target,p=t.getNode(d),y=t.getNode(g),m=t.getDegree(d),v=t.getDegree(g);if(!u||!(m<=1||v<=1)){var w=[y.data.x-p.data.x,y.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,s&&e<r&&(x=x-n[d]-n[g]);var b=x,M=b;"linlog"===h&&(M=b=Math.log(1+x)),a&&(b=x/m,M=x/v),s&&e<r&&x<=0?(b=0,M=0):s&&e<r&&x>0&&(b=x,M=x),o[d][0]+=b*w[0],o[g][0]-=M*w[0],o[d][1]+=b*w[1],o[g][1]-=M*w[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,l=-9e10,c=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>=l&&(l=y.x),y.x<=u&&(u=y.x),y.y>=f&&(f=y.y),y.y<=c&&(c=y.y))}var m=Math.max(l-u,f-c),v=new se({xmid:(l+u)/2,ymid:(f+c)/2,length:m,massCenter:i,mass:h}),w=new ae(v);for(d=0;d<h;d+=1)p=a[d].id,s&&t.getDegree(p)<=1||r[p].in(v)&&w.insert(r[p]);for(d=0;d<h;d+=1){var x=a[d],b=(p=x.id,y=x.data,t.getDegree(p));if(!(s&&b<=1)){r[p].resetForce(),w.updateForce(r[p]),e[p][0]-=r[p].fx,e[p][1]-=r[p].fy;var M=[y.x-i[0],y.y-i[1]],E=Math.hypot(M[0],M[1]);E=E<1e-4?1e-4:E,M[0]=M[0]/E,M[1]=M[1]/E;var N=o*(b+1);e[p][0]-=N*M[0],e[p][1]-=N*M[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,l=s.center,c=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 v=f[m],w=t.getDegree(v.id);if(!c||!(y<=1||w<=1)){var x=[v.data.x-p.data.x,v.data.y-p.data.y],b=Math.hypot(x[0],x[1]);b=b<1e-4?1e-4:b,x[0]=x[0]/b,x[1]=x[1]/b,a&&e<r&&(b=b-i[p.id]-i[v.id]);var M=h*(y+1)*(w+1)/b;a&&e<r&&b<0?M=o*(y+1)*(w+1):a&&e<r&&0===b?M=0:a&&e<r&&b>0&&(M=h*(y+1)*(w+1)/b),n[p.id][0]-=M*x[0],n[v.id][0]+=M*x[0],n[p.id][1]-=M*x[1],n[v.id][1]+=M*x[1]}}var E=[p.data.x-l[0],p.data.y-l[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(),l=u.length,c=[],f=[],d=0,g=0,y=n,m=0;m<l;m+=1){var v=u[m].id,w=t.getDegree(v);if(!(a&&w<=1)){var x=[e[v][0]-r[v][0],e[v][1]-r[v][1]],b=Math.hypot(x[0],x[1]),M=[e[v][0]+r[v][0],e[v][1]+r[v][1]],E=Math.hypot(M[0],M[1]);c[m]=b,f[m]=E/2,d+=(w+1)*c[m],g+=(w+1)*f[m]}}var N=y;for(y=s*g/d,0!==N&&(y=y>1.5*N?1.5*N:y),m=0;m<l;m+=1){var S=u[m],A=(v=S.id,S.data);if(w=t.getDegree(v),!(a&&w<=1||p(A.fx)&&p(A.fy))){var k=i*y/(1+y*Math.sqrt(c[m])),_=Math.hypot(e[v][0],e[v][1]),I=h/(_=_<1e-4?1e-4:_),D=(k=k>I?I:k)*e[v][0],R=k*e[v][1];t.mergeNodeData(v,{x:A.x+D,y:A.y+R})}}return y},t}(),le={maxIteration:1e3,gravity:10,speed:5,clustering:!1,clusterGravity:10,width:300,height:300,nodeClusterBy:"cluster"},ce=function(){function t(t){void 0===t&&(t={}),this.options=t,this.id="fruchterman",this.timeInterval=0,this.running=!1,this.options=e(e({},le),t)}return t.prototype.execute=function(t,e){return this.genericFruchtermanLayout(!1,t,e)},t.prototype.assign=function(t,e){this.genericFruchtermanLayout(!0,t,e)},t.prototype.stop=function(){this.timeInterval&&"undefined"!=typeof window&&window.clearInterval(this.timeInterval),this.running=!1},t.prototype.restart=function(){this.running=!0},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})})),this.lastOptions.onLayoutEnd&&this.lastOptions.onLayoutEnd(n),n},t.prototype.genericFruchtermanLayout=function(t,r,n){var o=this;if(!this.running){var i=this.formatOptions(n),s=i.layoutInvisibles,a=i.width,h=i.height,u=i.center,l=i.clustering,c=i.nodeClusterBy,f=i.maxIteration,d=i.onTick,g=i.onLayoutEnd,p=r.getAllNodes(),y=r.getAllEdges();if(s||(p=p.filter((function(t){var e=(t.data||{}).visible;return e||void 0===e})),y=y.filter((function(t){var e=(t.data||{}).visible;return e||void 0===e}))),!(null==p?void 0:p.length)){var m={nodes:[],edges:y};return this.lastResult=m,null==g||g(m),m}if(1===p.length)return t&&r.mergeNodeData(p[0].id,{x:u[0],y:u[1]}),m={nodes:[e(e({},p[0]),{data:e(e({},p[0].data),{x:u[0],y:u[1]})})],edges:y},this.lastResult=m,null==g||g(m),m;var v=p.map((function(t){return _(t,[a,h])})),w=new Jt({nodes:v,edges:y}),x={};if(l&&v.forEach((function(t){var e=t.data[c];x[e]||(x[e]={name:e,cx:0,cy:0,count:0})})),this.lastLayoutNodes=v,this.lastLayoutEdges=y,this.lastAssign=t,this.lastGraph=w,this.lastOptions=i,this.lastClusterMap=x,"undefined"!=typeof window){var b=0;return this.timeInterval=window.setInterval((function(){if(o.running&&(o.runOneStep(w,x,i),t&&v.forEach((function(t){var e=t.id,n=t.data;return r.mergeNodeData(e,{x:n.x,y:n.y})})),null==d||d({nodes:v,edges:y}),++b>=f)){try{null==g||g({nodes:v,edges:y})}catch(t){console.warn("onLayoutEnd failed",t)}window.clearInterval(o.timeInterval)}}),0),this.running=!0,{nodes:v,edges:y}}}},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,h=r.clustering,u=r.nodeClusterBy,l=r.clusterGravity,c=n*o,f=Math.sqrt(c)/10,d=t.getAllNodes(),g=c/(d.length+1),y=Math.sqrt(g),m={};if(this.applyCalculate(t,m,y,g),h){for(var v in e)e[v].cx=0,e[v].cy=0,e[v].count=0;for(var v in d.forEach((function(t){var r=t.data,n=e[r[u]];p(r.x)&&(n.cx+=r.x),p(r.y)&&(n.cy+=r.y),n.count++})),e)e[v].cx/=e[v].count,e[v].cy/=e[v].count;var w=l||i;d.forEach((function(t,r){var n=t.id,o=t.data;if(p(o.x)&&p(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=y*w;m[n].x-=a*(o.x-i.cx)/s,m[n].y-=a*(o.y-i.cy)/s}}))}d.forEach((function(t,e){var r=t.id,n=t.data;if(p(n.x)&&p(n.y)){var o=.01*y*i;m[r].x-=o*(n.x-s[0]),m[r].y-=o*(n.y-s[1])}})),d.forEach((function(e,r){var n=e.id,o=e.data;if(p(o.fx)&&p(o.fy))return o.x=o.fx,void(o.y=o.fy);if(p(o.x)&&p(o.y)){var i=Math.sqrt(m[n].x*m[n].x+m[n].y*m[n].y);if(i>0){var s=Math.min(f*(a/800),i);t.mergeNodeData(n,{x:o.x+m[n].x/i*s,y:o.y+m[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)&&p(i.x)&&p(a.x)&&p(i.y)&&p(a.y)){var u=i.x-a.x,l=i.y-a.y,c=u*u+l*l;0===c&&(c=1,u=.01,l=.01);var f=r/c,d=u*f,g=l*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(p(a.x)&&p(s.x)&&p(a.y)&&p(s.y)){var h=a.x-s.x,u=a.y-s.y,l=Math.sqrt(h*h+u*u)/r,c=h*l,f=u*l;e[o].x+=c,e[o].y+=f,e[i].x-=c,e[i].y-=f}}}))},t}(),fe={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},de=function(){function t(t){void 0===t&&(t={}),this.options=t,this.id="grid",this.options=e(e({},fe),t)}return t.prototype.execute=function(t,e){return this.genericGridLayout(!1,t,e)},t.prototype.assign=function(t,e){this.genericGridLayout(!0,t,e)},t.prototype.genericGridLayout=function(t,r,n){var o=e(e({},this.options),n),i=o.begin,s=void 0===i?[0,0]:i,a=o.condense,h=o.preventOverlapPadding,u=o.preventOverlap,l=o.rows,f=o.cols,d=o.nodeSpacing,g=o.nodeSize,y=o.width,m=o.height,v=o.layoutInvisibles,w=o.onLayoutEnd,x=o.position,b=o.sortBy,M=r.getAllNodes(),E=r.getAllEdges();v||(M=M.filter((function(t){var e=(t.data||{}).visible;return e||void 0===e})),E=E.filter((function(t){var e=(t.data||{}).visible;return e||void 0===e})));var N=null==M?void 0:M.length;if(!N||1===N)return O(r,t,s,w);var S=M.map((function(t){return _(t)}));"id"===b||G(b)&&void 0!==S[0].data[b]||(b="degree"),"degree"===b?S.sort((function(t,e){return r.getDegree(e.id,"both")-r.getDegree(t.id,"both")})):"id"===b?S.sort((function(t,e){return p(e.id)&&p(t.id)?e.id-t.id:"".concat(t.id).localeCompare("".concat(e.id))})):S.sort((function(t,e){return e.data[b]-t.data[b]}));var A=y||"undefined"==typeof window?y:window.innerWidth,k=m||"undefined"==typeof window?m:window.innerHeight,I=N,D={rows:l,cols:f};if(null!=l&&null!=f)D.rows=l,D.cols=f;else if(null!=l&&null==f)D.rows=l,D.cols=Math.ceil(I/D.rows);else if(null==l&&null!=f)D.cols=f,D.rows=Math.ceil(I/D.cols);else{var z=Math.sqrt(I*k/A);D.rows=Math.round(z),D.cols=Math.round(A/k*z)}if(D.rows=Math.max(D.rows,1),D.cols=Math.max(D.cols,1),D.cols*D.rows>I)((L=ge(D))-1)*(P=pe(D))>=I?ge(D,L-1):(P-1)*L>=I&&pe(D,P-1);else for(;D.cols*D.rows<I;){var P,L=ge(D);((P=pe(D))+1)*L>=I?pe(D,P+1):ge(D,L+1)}var C=a?0:A/D.cols,q=a?0:k/D.rows;if(u||d){var F=R(10,d),j=T(30,g,!1);S.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=j(o)||30;c(i)?(e=i[0],n=i[1]):(e=i,n=i);var s=void 0!==F?F(t):h,a=e+s,u=n+s;C=Math.max(C,a),q=Math.max(q,u)}))}for(var V={},W={row:0,col:0},$={},U=0;U<S.length;U++){var B=S[U],H=void 0;if(x&&(H=x(r.getNode(B.id))),H&&(void 0!==H.row||void 0!==H.col)){var K={row:H.row,col:H.col};if(void 0===K.col)for(K.col=0;ye(V,K);)K.col++;else if(void 0===K.row)for(K.row=0;ye(V,K);)K.row++;$[B.id]=K,me(V,K)}we(B,s,C,q,$,D,W,V)}var J={nodes:S,edges:E};return null==w||w(J),t&&S.forEach((function(t){r.mergeNodeData(t.id,{x:t.data.x,y:t.data.y})})),J},t}(),ge=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},pe=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},ye=function(t,e){return t["c-".concat(e.row,"-").concat(e.col)]||!1},me=function(t,e){return t["c-".concat(e.row,"-").concat(e.col)]=!0},ve=function(t,e){var r=t.cols||5;e.col++,e.col>=r&&(e.col=0,e.row++)},we=function(t,e,r,n,o,i,s,a){var h,u,l=o[t.id];if(l)h=l.col*r+r/2+e[0],u=l.row*n+n/2+e[1];else{for(;ye(a,s);)ve(i,s);h=s.col*r+r/2+e[0],u=s.row*n+n/2+e[1],me(a,s),ve(i,s)}t.data.x=h,t.data.y=u};const xe=Object.prototype.toString;function be(t){return xe.call(t).endsWith("Array]")}function Me(t){var e=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};if(!be(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}function Ee(t){var e=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};if(!be(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}function Ne(t){var e,r=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};if(!be(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(!be(r.output))throw new TypeError("output option must be an array if specified");e=r.output}else e=new Array(t.length);var n=Ee(t),o=Me(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),l=0;l<t.length;l++)e[l]=(t[l]-n)*u+s;return e}const Se=" ".repeat(2),Ae=" ".repeat(4);function ke(t,e={}){const{maxRows:r=15,maxColumns:n=10,maxNumSize:o=8,padMinus:i="auto"}=e;return`${t.constructor.name} {\n${Se}[\n${Ae}${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(_e(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${Ae}`)}(t,r,n,o,i)}\n${Se}]\n${Se}rows: ${t.rows}\n${Se}columns: ${t.columns}\n}`}function _e(t,e,r){return(t>=0&&r?` ${Ie(t,e-1)}`:Ie(t,e)).padEnd(e)}function Ie(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 De(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 Re(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 Te(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 Oe(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 ze(t,e,r,n,o){if(5!==arguments.length)throw new RangeError("expected 4 arguments");if(Le("startRow",e),Le("endRow",r),Le("startColumn",n),Le("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 Pe(t,e=0){let r=[];for(let n=0;n<t;n++)r.push(e);return r}function Le(t,e){if("number"!=typeof e)throw new TypeError(`${t} must be a number`)}function Ce(t){if(t.isEmpty())throw new Error("Empty matrix has no elements to index")}class qe{static from1DArray(t,e,r){if(t*e!==r.length)throw new RangeError("data length does not match given dimensions");let n=new je(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 je(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 je(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 je(t,e)}static ones(t,e){return new je(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 je(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 je(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 je(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 qe.isMatrix(t)?t:new je(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 je(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){De(this,t);let e=[];for(let r=0;r<this.columns;r++)e.push(this.get(t,r));return e}getRowVector(t){return je.rowVector(this.getRow(t))}setRow(t,e){De(this,t),e=Te(this,e);for(let r=0;r<this.columns;r++)this.set(t,r,e[r]);return this}swapRows(t,e){De(this,t),De(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){Re(this,t);let e=[];for(let r=0;r<this.rows;r++)e.push(this.get(r,t));return e}getColumnVector(t){return je.columnVector(this.getColumn(t))}setColumn(t,e){Re(this,t),e=Oe(this,e);for(let r=0;r<this.rows;r++)this.set(r,t,e[r]);return this}swapColumns(t,e){Re(this,t),Re(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=Te(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=Te(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=Te(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=Te(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=Oe(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=Oe(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=Oe(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=Oe(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){De(this,t);for(let r=0;r<this.columns;r++)this.set(t,r,this.get(t,r)*e);return this}mulColumn(t,e){Re(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(){Ce(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(){Ce(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(De(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){De(this,t),Ce(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(De(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){De(this,t),Ce(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(Re(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){Re(this,t),Ce(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(Re(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){Re(this,t),Ce(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){qe.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=je.checkMatrix(t);let e=this.rows,r=this.columns,n=t.columns,o=new je(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=je.checkMatrix(t);let e=new je(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),l=(r+h)*(n+u),c=(s+h)*n,f=r*(i-u),d=h*(a-n),g=(r+o)*u,p=l+d-g+(o-h)*(a+u),y=f+g,m=c+d,v=l-c+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,v),e}strassen3x3(t){t=je.checkMatrix(t);let e=new je(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),l=this.get(2,2),c=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),v=t.get(2,1),w=t.get(2,2),x=(r-i)*(-f+p),b=(-r+i+s)*(c-f+p),M=(i+s)*(-c+f),E=r*c,N=(-r+h+u)*(c-d+y),S=(-r+h)*(d-y),A=(h+u)*(-c+d),k=(-o+u+l)*(p+m-v),_=(o-l)*(p-v),I=o*m,D=(u+l)*(-m+v),R=(-o+s+a)*(y+m-w),T=(o-a)*(y-w),O=(s+a)*(-m+w),z=E+I+n*g,P=(r+n+o-i-s-u-l)*p+b+M+E+k+I+D,L=E+N+A+(r+n+o-s-a-h-u)*y+I+R+O,C=x+s*(-c+f+g-p-y-m+w)+b+E+I+R+T,q=x+b+M+E+a*v,F=I+R+T+O+i*d,j=E+N+S+u*(-c+d+g-p-y-m+v)+k+_+I,V=k+_+I+D+h*f,W=E+N+S+A+l*w;return e.set(0,0,z),e.set(0,1,P),e.set(0,2,L),e.set(1,0,C),e.set(1,1,q),e.set(1,2,F),e.set(2,0,j),e.set(2,1,V),e.set(2,2,W),e}mmulStrassen(t){t=je.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=qe.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),l=e.subMatrix(0,i-1,a,e.columns-1),c=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(qe.add(h,g),qe.add(u,p),i,a),m=t(qe.add(f,g),u,i,a),v=t(h,qe.sub(c,p),i,a),w=t(g,qe.sub(d,u),i,a),x=t(qe.add(h,l),p,i,a),b=t(qe.sub(f,h),qe.add(u,c),i,a),M=t(qe.sub(l,g),qe.add(d,p),i,a),E=qe.add(y,w);E.sub(x),E.add(M);let N=qe.add(v,x),S=qe.add(m,w),A=qe.sub(y,m);A.add(v),A.add(b);let k=qe.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 je(this.rows,this.columns);for(let t=0;t<this.rows;t++){const o=this.getRow(t);o.length>0&&Ne(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 je(this.rows,this.columns);for(let t=0;t<this.columns;t++){const o=this.getColumn(t);o.length&&Ne(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=je.checkMatrix(t);let e=this.rows,r=this.columns,n=t.rows,o=t.columns,i=new je(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=je.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(je.eye(r,r)),o=je.eye(e,e).kroneckerProduct(t);return n.add(o)}transpose(){let t=new je(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=Fe){for(let e=0;e<this.rows;e++)this.setRow(e,this.getRow(e).sort(t));return this}sortColumns(t=Fe){for(let e=0;e<this.columns;e++)this.setColumn(e,this.getColumn(e).sort(t));return this}subMatrix(t,e,r,n){ze(this,t,e,r,n);let o=new je(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 je(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 je(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=je.checkMatrix(t)).isEmpty())return this;ze(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(!be(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(!be(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 je(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 je(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=Pe(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=Pe(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=Pe(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=Pe(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(!be(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(!be(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(!be(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(!be(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(!be(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(!be(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 ke(this,t)}}function Fe(t,e){return t-e}qe.prototype.klass="Matrix","undefined"!=typeof Symbol&&(qe.prototype[Symbol.for("nodejs.util.inspect.custom")]=function(){return ke(this)}),qe.random=qe.rand,qe.randomInt=qe.randInt,qe.diagonal=qe.diag,qe.prototype.diagonal=qe.prototype.diag,qe.identity=qe.eye,qe.prototype.negate=qe.prototype.neg,qe.prototype.tensorProduct=qe.prototype.kroneckerProduct;class je extends qe{constructor(t,e){if(super(),je.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(!be(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 De(this,t),this.data.splice(t,1),this.rows-=1,this}addRow(t,e){return void 0===e&&(e=t,t=this.rows),De(this,t,!0),e=Float64Array.from(Te(this,e)),this.data.splice(t,0,e),this.rows+=1,this}removeColumn(t){Re(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),Re(this,t,!0),e=Oe(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}}(qe,je);class Ve extends qe{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 We(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 $e{constructor(t,e={}){if((t=Ve.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),l=!1;if(r<n)if(s){a=t.transpose(),r=a.rows,n=a.columns,l=!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 c=Math.min(r,n),f=Math.min(r+1,n),d=new Float64Array(f),g=new je(r,c),p=new je(n,n),y=new Float64Array(n),m=new Float64Array(r),v=new Float64Array(f);for(let t=0;t<f;t++)v[t]=t;let w=Math.min(r-1,n),x=Math.max(0,Math.min(n-2,r)),b=Math.max(w,x);for(let t=0;t<b;t++){if(t<w){d[t]=0;for(let e=t;e<r;e++)d[t]=We(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<w&&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<w)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]=We(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 M=Math.min(n,r+1);if(w<n&&(d[w]=a.get(w,w)),r<M&&(d[M-1]=0),x+1<M&&(y[x]=a.get(x,M-1)),y[M-1]=0,h){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!==d[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(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=M-1,N=0,S=Number.EPSILON;for(;M>0;){let t,e;for(t=M-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===M-2)e=4;else{let r;for(r=M-1;r>=t&&r!==t;r--){let e=(r!==M?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===M-1?e=1:(e=2,t=r)}switch(t++,e){case 1:{let e=y[M-2];y[M-2]=0;for(let r=M-2;r>=t;r--){let o=We(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,M-1),p.set(t,M-1,-s*p.get(t,r)+i*p.get(t,M-1)),p.set(t,r,o)}break}case 2:{let e=y[t-1];y[t-1]=0;for(let n=t;n<M;n++){let o=We(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[M-1]),Math.abs(d[M-2]),Math.abs(y[M-2]),Math.abs(d[t]),Math.abs(y[t])),o=d[M-1]/e,i=d[M-2]/e,s=y[M-2]/e,a=d[t]/e,l=y[t]/e,c=((i+o)*(i-o)+s*s)/2,f=o*s*(o*s);let m=0;0===c&&0===f||(m=c<0?0-Math.sqrt(c*c+f):Math.sqrt(c*c+f),m=f/(c+m));let v=(a+o)*(a-o)+m,w=a*l;for(let e=t;e<M-1;e++){let o=We(v,w);0===o&&(o=Number.MIN_VALUE);let i=v/o,s=w/o;if(e!==t&&(y[e-1]=o),v=i*d[e]+s*y[e],y[e]=i*y[e]-s*d[e],w=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=We(v,w),0===o&&(o=Number.MIN_VALUE),i=v/o,s=w/o,d[e]=o,v=i*y[e]+s*d[e+1],d[e+1]=-s*y[e]+i*d[e+1],w=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[M-2]=v,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,M--}}if(l){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=je.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,l=je.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);l.set(t,e,r)}return l.mmul(e)}solveForDiagonal(t){return this.solve(je.diag(t))}inverse(){let t=this.V,e=this.threshold,r=t.rows,n=t.columns,o=new je(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 je(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 je.diag(this.s)}}var Ge={center:[0,0],linkDistance:50},Ue=function(){function t(t){void 0===t&&(t={}),this.options=t,this.id="mds",this.options=e(e({},Ge),t)}return t.prototype.execute=function(t,e){return this.genericMDSLayout(!1,t,e)},t.prototype.assign=function(t,e){this.genericMDSLayout(!0,t,e)},t.prototype.genericMDSLayout=function(t,r,n){var o=e(e({},this.options),n),i=o.center,s=void 0===i?[0,0]:i,a=o.linkDistance,h=void 0===a?50:a,u=o.layoutInvisibles,l=o.onLayoutEnd,c=r.getAllNodes(),f=r.getAllEdges();if(u||(c=c.filter((function(t){var e=(t.data||{}).visible;return e||void 0===e})),f=f.filter((function(t){var e=(t.data||{}).visible;return e||void 0===e}))),!(null==c?void 0:c.length)||1===c.length)return O(r,t,s,l);var d=m({nodes:c,edges:f},!1),g=y(d);Be(g);var p=v(g,h),w=He(p),x=[];w.forEach((function(t,e){var r=_(c[e]);r.data.x=t[0]+s[0],r.data.y=t[1]+s[1],x.push(r)})),t&&x.forEach((function(t){return r.mergeNodeData(t.id,{x:t.data.x,y:t.data.y})}));var b={nodes:x,edges:f};return null==l||l(b),b},t}(),Be=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)}))}))},He=function(t){var e=je.mul(je.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 $e(e),s=je.sqrt(i.diagonalMatrix).diagonal();return i.leftSingularVectors.toJSON().map((function(t){return je.mul([t],[s]).toJSON()[0].splice(0,2)}))},Ke={iterations:10,height:10,width:10,speed:100,gravity:10,k:5},Je=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,l=s.y-e.y,c=Math.sqrt(u*u+l*l);if(0===c){c=1;var f=a>h?1:-1;u=.01*f,l=.01*f}if(c<i(t[a])/2+i(t[h])/2){var d=n*n/c;r[a].x+=u/c*d,r[a].y+=l/c*d}}}))}))},Ye=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),l=Math.acos((a*e.x+h*e.y)/u);l>Math.PI/2&&(l-=Math.PI/2,a*=-1,h*=-1);var c=Math.cos(l)*u;e.x=a*c,e.y=h*c})),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 l=Math.min(h*(r/800),u);if(i.x+=e[s].x/u*l,i.y+=e[s].y/u*l,n){var c=i.x-t[o].x,f=i.y-t[o].y,d=Math.sqrt(c*c+f*f);c=c/d*a[s],f=f/d*a[s],i.x=t[o].x+c,i.y=t[o].y+f}}}})),t},Xe={maxIteration:1e3,focusNode:null,unitRadius:null,linkDistance:50,preventOverlap:!1,strictRadial:!0,maxPreventOverlapIteration:200,sortStrength:10},Ze=function(){function t(t){void 0===t&&(t={}),this.options=t,this.id="radial",this.options=e(e({},Xe),t)}return t.prototype.execute=function(t,e){return this.genericRadialLayout(!1,t,e)},t.prototype.assign=function(t,e){this.genericRadialLayout(!0,t,e)},t.prototype.genericRadialLayout=function(t,r,n){var o=e(e({},this.options),n),a=o.width,h=o.height,u=o.center,l=o.focusNode,c=o.unitRadius,f=o.nodeSize,d=o.nodeSpacing,g=o.strictRadial,p=o.preventOverlap,v=o.maxPreventOverlapIteration,w=o.sortBy,x=o.linkDistance,b=void 0===x?50:x,M=o.sortStrength,E=void 0===M?10:M,N=o.maxIteration,S=void 0===N?1e3:N,A=o.layoutInvisibles,k=o.onLayoutEnd,I=r.getAllNodes(),D=r.getAllEdges();A||(I=I.filter((function(t){var e=(t.data||{}).visible;return e||void 0===e})),D=D.filter((function(t){var e=(t.data||{}).visible;return e||void 0===e})));var R=a||"undefined"==typeof window?a:window.innerWidth,T=h||"undefined"==typeof window?h:window.innerHeight,z=u||[R/2,T/2];if(!(null==I?void 0:I.length)||1===I.length)return O(r,t,z,k);var P=I[0];if(G(l)){for(var L=0;L<I.length;L++)if(I[L].id===l){P=I[L];break}}else P=l||I[0];var C=er(I,P.id),q=m({nodes:I,edges:D},!1),F=y(q),j=nr(F,C);rr(F,C,j+1);var V=F[C],W=R-z[0]>z[0]?z[0]:R-z[0],$=T-z[1]>z[1]?z[1]:T-z[1];0===W&&(W=R/2),0===$&&($=T/2);var U=Math.min(W,$),B=Math.max.apply(Math,s([],i(V),!1)),H=[],K=c||U/B;V.forEach((function(t,e){H[e]=t*K}));var J,Y=Qe(I,F,b,H,K,w,E),X=tr(Y),Z=function(t,e,r){try{var n=je.mul(je.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 $e(n),h=je.sqrt(a.diagonalMatrix).diagonal();return a.leftSingularVectors.toJSON().map((function(e){return je.mul([e],[h]).toJSON()[0].splice(0,t)}))}catch(t){for(var u=[],l=0;l<e.length;l++){var c=Math.random()*r,f=Math.random()*r;u.push([c,f])}return u}}(b,Y,b),Q=Z.map((function(t){var e=i(t,2),r=e[0],n=e[1];return{x:(isNaN(r)?Math.random()*b:r)-Z[C][0],y:(isNaN(n)?Math.random()*b:n)-Z[C][1]}}));if(this.run(S,Q,X,Y,H,C),p){J=or(f,d);var tt={nodes:I,nodeSizeFunc:J,positions:Q,radii:H,height:T,width:R,strictRadial:Boolean(g),focusIdx:C,iterations:v||200,k:Q.length/4.5};Q=function(t,r){for(var n=e(e({},Ke),r),o=n.positions,i=n.iterations,s=n.width,a=n.k,h=n.speed,u=void 0===h?100:h,l=n.strictRadial,c=n.focusIdx,f=n.radii,d=void 0===f?[]:f,g=n.nodeSizeFunc,p=t.getAllNodes(),y=[],m=s/10,v=0;v<i;v++)o.forEach((function(t,e){y[e]={x:0,y:0}})),Je(p,o,y,a,d,g),Ye(o,y,u,l,c,m,s,d);return o}(r,tt)}var et=[];Q.forEach((function(t,e){var r=_(I[e]);r.data.x=t.x+z[0],r.data.y=t.y+z[1],et.push(r)})),t&&et.forEach((function(t){return r.mergeNodeData(t.id,{x:t.data.x,y:t.data.y})}));var rt={nodes:et,edges:D};return null==k||k(rt),rt},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=A(a,{x:0,y:0}),l=0===u?0:1/u;if(h!==i){var c=0,f=0,d=0;e.forEach((function(t,e){if(h!==e){var r=A(a,t),i=0===r?0:1/r,s=n[e][h];d+=o[h][e],c+=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,c*=s,c+=t*g*a.x*l,a.x=c/d,f*=s,f+=t*g*a.y*l,a.y=f/d}}))},t}(),Qe=function(t,e,r,n,o,i,s){if(!t)return[];var a=[];if(e){var h={};e.forEach((function(e,u){var l=[];e.forEach((function(e,a){var c,f;if(u===a)l.push(0);else if(n[u]===n[a])if("data"===i)l.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===(c=t[u].data)||void 0===c?void 0:c[i])||0;d=G(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=G(p)?p.charCodeAt(0):p,h[t[a].id]=g),l.push(e*(Math.abs(d-g)*s)/(n[u]/o))}else l.push(e*r/(n[u]/o));else{var y=(r+o)/2;l.push(e*y)}})),a.push(l)}))}return a},tr=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},er=function(t,e){var r=-1;return t.forEach((function(t,n){t.id===e&&(r=n)})),Math.max(r,0)},rr=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}},nr=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},or=function(t,e){var r;return r=p(e)?function(){return e}:I(e)?e:function(){return 0},t?c(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(c(t.data.size))return Math.max(t.data.size[0],t.data.size[1])+r(t);var o=t.data.size;return D(o)?(o.width>o.height?o.width:o.height)+r(t):o+r(t)}return 10+r(t)}},ir={center:[0,0],width:300,height:300},sr=function(){function t(t){void 0===t&&(t={}),this.options=t,this.id="random",this.options=e(e({},ir),t)}return t.prototype.execute=function(t,e){return this.genericRandomLayout(!1,t,e)},t.prototype.assign=function(t,e){this.genericRandomLayout(!0,t,e)},t.prototype.genericRandomLayout=function(t,r,n){var o=e(e({},this.options),n),i=o.center,s=o.width,a=o.height,h=o.layoutInvisibles,u=o.onLayoutEnd,l=r.getAllNodes();h||(l=l.filter((function(t){var e=(t.data||{}).visible;return e||void 0===e})));var c=s||"undefined"==typeof window?s:window.innerWidth,f=a||"undefined"==typeof window?a:window.innerHeight,d=i||[c/2,f/2],g=[];l&&l.forEach((function(t){g.push({id:t.id,data:{x:.9*(Math.random()-.5)*c+d[0],y:.9*(Math.random()-.5)*f+d[1]}})})),t&&g.forEach((function(t){return r.mergeNodeData(t.id,{x:t.data.x,y:t.data.y})}));var p={nodes:g,edges:r.getAllEdges()};return null==u||u(p),p},t}(),ar={circular:P,concentric:B,mds:Ue,random:sr,grid:de,radial:Ze,force:Zt,d3force:$t,fruchterman:ce,forceAtlas2:ue};function hr(t,e){ar[t]=e}function ur(t){return!!t.tick&&!!t.stop&&!!t.restart}})();var o=n.SB,i=n.W1,s=n.jA,a=n.E9,h=n.y7,u=n.O2,l=n.Me,c=n.AI,f=n.D4,d=n._5,g=n.y9,p=n.Xp,y=n._A,m=n.d9,v=n.ul,w=n.qs,x=n.jE,b=n.tO,M=n.zJ,E=n.h$,N=n.BI,S=n.$y,A=n.H0,k=n.kJ,_=n.hY,I=n.qR,D=n.i_,R=n.nu,T=n.He,O=n.A3;export{o as CircularLayout,i as ConcentricLayout,s as D3ForceLayout,a as ForceAtlas2Layout,h as ForceLayout,u as FruchtermanLayout,l as GridLayout,c as MDSLayout,f as RadialLayout,d as RandomLayout,g as Supervisor,p as SupervisorEvent,y as camelize,m as clone,v as cloneFormatData,w as floydWarshall,x as formatNumberFn,b as formatSizeFn,M as getAdjMatrix,E as getAvgNodePosition,N as getCoreNodeAndRelativeLeafNodes,S as getEuclideanDistance,A as getLayoutBBox,k as isArray,_ as isLayoutWithIterations,I as registerLayout,D as registry,R as scaleMatrix,T as toNumber,O as traverseTreeUp};
|
|
2
2
|
//# sourceMappingURL=index.esm.js.map
|