@antv/layout 1.0.0-alpha.6 → 1.0.0-alpha.7

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/index.min.js CHANGED
@@ -1,2 +1,2 @@
1
- !function(t,e){"object"==typeof exports&&"object"==typeof module?module.exports=e():"function"==typeof define&&define.amd?define([],e):"object"==typeof exports?exports.Layout=e():t.Layout=e()}(self,(()=>(()=>{var t={161:t=>{"use strict";var e=Object.prototype.hasOwnProperty,r="~";function n(){}function o(t,e,r){this.fn=t,this.context=e,this.once=r||!1}function i(t,e,n,i,s){if("function"!=typeof n)throw new TypeError("The listener must be a function");var a=new o(n,i||t,s),u=r?r+e:e;return t._events[u]?t._events[u].fn?t._events[u]=[t._events[u],a]:t._events[u].push(a):(t._events[u]=a,t._eventsCount++),t}function s(t,e){0==--t._eventsCount?t._events=new n:delete t._events[e]}function a(){this._events=new n,this._eventsCount=0}Object.create&&(n.prototype=Object.create(null),(new n).__proto__||(r=!1)),a.prototype.eventNames=function(){var t,n,o=[];if(0===this._eventsCount)return o;for(n in t=this._events)e.call(t,n)&&o.push(r?n.slice(1):n);return Object.getOwnPropertySymbols?o.concat(Object.getOwnPropertySymbols(t)):o},a.prototype.listeners=function(t){var e=r?r+t:t,n=this._events[e];if(!n)return[];if(n.fn)return[n.fn];for(var o=0,i=n.length,s=new Array(i);o<i;o++)s[o]=n[o].fn;return s},a.prototype.listenerCount=function(t){var e=r?r+t:t,n=this._events[e];return n?n.fn?1:n.length:0},a.prototype.emit=function(t,e,n,o,i,s){var a=r?r+t:t;if(!this._events[a])return!1;var u,h,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(h=1,u=new Array(c-1);h<c;h++)u[h-1]=arguments[h];l.fn.apply(l.context,u)}else{var f,d=l.length;for(h=0;h<d;h++)switch(l[h].once&&this.removeListener(t,l[h].fn,void 0,!0),c){case 1:l[h].fn.call(l[h].context);break;case 2:l[h].fn.call(l[h].context,e);break;case 3:l[h].fn.call(l[h].context,e,n);break;case 4:l[h].fn.call(l[h].context,e,n,o);break;default:if(!u)for(f=1,u=new Array(c-1);f<c;f++)u[f-1]=arguments[f];l[h].fn.apply(l[h].context,u)}}return!0},a.prototype.on=function(t,e,r){return i(this,t,e,r,!1)},a.prototype.once=function(t,e,r){return i(this,t,e,r,!0)},a.prototype.removeListener=function(t,e,n,o){var i=r?r+t:t;if(!this._events[i])return this;if(!e)return s(this,i),this;var a=this._events[i];if(a.fn)a.fn!==e||o&&!a.once||n&&a.context!==n||s(this,i);else{for(var u=0,h=[],l=a.length;u<l;u++)(a[u].fn!==e||o&&!a[u].once||n&&a[u].context!==n)&&h.push(a[u]);h.length?this._events[i]=1===h.length?h[0]:h:s(this,i)}return this},a.prototype.removeAllListeners=function(t){var e;return t?(e=r?r+t:t,this._events[e]&&s(this,e)):(this._events=new n,this._eventsCount=0),this},a.prototype.off=a.prototype.removeListener,a.prototype.addListener=a.prototype.on,a.prefixed=r,a.EventEmitter=a,t.exports=a},825:(t,e,r)=>{var n=r(475),o=["calculateLayout"];t.exports=function(){var t=new Worker(URL.createObjectURL(new Blob(['(()=>{"use strict";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:()=>De});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},u=/-(\\w)/g,h=(function(t){return t.replace(u,(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&&Object.keys(t).length){var n=r({},t);return Object.keys(n).forEach((function(t){n[t]=p(n[t])})),n}return t},m=function(t){var e=p(t);return e.data=e.data||{},e},w=function(t){return"function"==typeof t};function y(t,e){return w(e)?e:l(e)?function(){return e}:function(){return t}}function v(t,e,r){return void 0===r&&(r=!0),e||0===e?w(e)?e:l(e)?function(){return e}:h(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?h(r)?r[0]>r[1]?r[0]:r[1]:g(r)?r.width>r.height?r.width:r.height:r:t}}var x={radius:null,startRadius:null,endRadius:null,startAngle:0,endAngle:2*Math.PI,clockwise:!0,divisions:1,ordering:null,angleRatio:1},M=function(){function t(t){void 0===t&&(t={}),this.options=t,this.id="circular",this.options=r(r({},x),t)}return t.prototype.execute=function(t,e){return this.genericCircularLayout(!1,t,e)},t.prototype.assign=function(t,e){var r=this;t.batch((function(){r.genericCircularLayout(!0,t,e)}))},t.prototype.genericCircularLayout=function(t,e,n){var i=r(r({},this.options),n),s=i.width,a=i.height,u=i.center,h=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,w=i.clockwise,x=i.nodeSpacing,M=i.nodeSize,N=i.layoutInvisibles,S=i.onLayoutEnd,k=e.getAllNodes(),A=e.getAllEdges();N||(k=k.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=k.length;if(0===D)return null==S||S({nodes:[],edges:[]}),{nodes:[],edges:[]};var I=o(E(s,a,u),3),R=I[0],_=I[1],z=I[2];if(1===D){t&&e.mergeNodeData(k[0].id,{x:z[0],y:z[1]});var T={nodes:[r(r({},k[0]),{data:r(r({},k[0].data),{x:z[0],y:z[1]})})],edges:A};return null==S||S(T),T}var P=(d-c)/D,C=i.radius,O=i.startRadius,j=i.endRadius;if(x){var q=y(10,x),V=v(10,M),L=-1/0;k.forEach((function(t){var e=V(t);L<e&&(L=e)}));var F=0;k.forEach((function(t,e){F+=0===e?L||10:(q(t)||0)+(L||10)})),C=F/(2*Math.PI)}else C||O||j?!O&&j?O=j:O&&!j&&(j=O):C=Math.min(_,R)/2;var $=P*g,U=[];U="topology"===p?b(e,k):"topology-directed"===p?b(e,k,!0):"degree"===p?function(t,e){var r=[];return e.forEach((function(t,e){r.push(m(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 m(t)}));for(var B=Math.ceil(D/h),K=0;K<D;++K){var G=C;G||null===O||null===j||(G=O+K*(j-O)/(D-1)),G||(G=10+100*K/(D-1));var W=c+K%B*$+2*Math.PI/h*Math.floor(K/B);w||(W=d-K%B*$-2*Math.PI/h*Math.floor(K/B)),U[K].data.x=z[0]+Math.cos(W)*G,U[K].data.y=z[1]+Math.sin(W)*G}t&&U.forEach((function(t){e.mergeNodeData(t.id,{x:t.data.x,y:t.data.y})}));var J={nodes:U,edges:A};return null==S||S(J),J},t}(),b=function(t,e,r){void 0===r&&(r=!1);var n=[m(e[0])],o={},i=e.length;o[e[0].id]=!0;var s=0;return e.forEach((function(a,u){if(0!==u)if(u!==i-1&&t.getDegree(a.id,"both")===t.getDegree(e[u+1].id,"both")&&!t.areNeighbors(n[s].id,a.id)||o[a.id]){for(var h=r?t.getSuccessors(n[s].id):t.getNeighbors(n[s].id),l=!1,c=0;c<h.length;c++){var f=h[c];if(t.getDegree(f.id)===t.getDegree(a.id)&&!o[f.id]){n.push(m(f)),o[f.id]=!0,l=!0;break}}for(var d=0;!l&&(o[e[d].id]||(n.push(m(e[d])),o[e[d].id]=!0,l=!0),++d!==i););}else n.push(m(a)),o[a.id]=!0,s++})),n},E=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]},N={nodeSize:30,minNodeSpacing:10,nodeSpacing:10,preventOverlap:!1,sweep:void 0,equidistant:!1,startAngle:1.5*Math.PI,clockwise:!0,maxLevelDiff:void 0,sortBy:"degree"},S=function(){function t(t){void 0===t&&(t={}),this.options=t,this.id="concentric",this.options=r(r({},N),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,u=o.height,c=o.sortBy,f=o.maxLevelDiff,d=o.sweep,p=o.clockwise,y=o.equidistant,v=o.minNodeSpacing,x=void 0===v?10:v,M=o.preventOverlap,b=o.startAngle,E=void 0===b?1.5*Math.PI:b,N=o.nodeSize,S=o.nodeSpacing,k=o.layoutInvisibles,A=o.onLayoutEnd,D=e.getAllNodes(),I=e.getAllEdges();k||(D=D.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 R=D.length;if(0===R){var _={nodes:[],edges:I};return null==A||A(_),_}var z=s||"undefined"==typeof window?s:window.innerWidth,T=u||"undefined"==typeof window?u:window.innerHeight,P=i||[z/2,T/2];if(1===R){t&&e.mergeNodeData(D[0].id,{x:P[0],y:P[1]});var C={nodes:[r(r({},D[0]),{data:r(r({},D[0].data),{x:P[0],y:P[1]})})],edges:I};return null==A||A(C),C}var O,j=[],q=0;O=h(N)?Math.max(N[0],N[1]):N,h(S)?q=Math.max(S[0],S[1]):l(S)&&(q=S),D.forEach((function(t){var e=m(t);j.push(e);var r=O,n=e.data;h(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)),O=Math.max(O,r),w(S)&&(q=Math.max(S(t),q))}));var V={};j.forEach((function(t,e){V[t.id]=e}));var L=c;a(L)&&void 0!==j[0].data[L]||(L="degree"),"degree"===L?j.sort((function(t,r){return e.getDegree(r.id,"both")-e.getDegree(t.id,"both")})):j.sort((function(t,e){return e.data[L]-t.data[L]}));var F=j[0],$=(f||("degree"===L?e.getDegree(F.id,"both"):F.data[L]))/4,U=[{nodes:[]}],B=U[0];j.forEach((function(t){if(B.nodes.length>0){var r="degree"===L?Math.abs(e.getDegree(B.nodes[0].id,"both")-e.getDegree(t.id,"both")):Math.abs(B.nodes[0].data[L]-t.data[L]);$&&r>=$&&(B={nodes:[]},U.push(B))}B.nodes.push(t)}));var K=O+(q||x);if(!M){var G=U.length>0&&U[0].nodes.length>1,W=(Math.min(z,T)/2-K)/(U.length+(G?1:0));K=Math.min(K,W)}var J=0;if(U.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&&M){var r=Math.cos(t.dTheta)-Math.cos(0),n=Math.sin(t.dTheta)-Math.sin(0),o=Math.sqrt(K*K/(r*r+n*n));J=Math.max(o,J)}t.r=J,J+=K})),y){for(var H=0,Y=0,X=0;X<U.length;X++){var Q=(U[X].r||0)-Y;H=Math.max(H,Q)}Y=0,U.forEach((function(t,e){0===e&&(Y=t.r||0),t.r=Y,Y+=H}))}U.forEach((function(t){var e=t.dTheta||0,r=t.r||0;t.nodes.forEach((function(t,n){var o=E+(p?1:-1)*e*n;t.data.x=P[0]+r*Math.cos(o),t.data.y=P[1]+r*Math.sin(o)}))})),t&&j.forEach((function(t){return e.mergeNodeData(t.id,{x:t.data.x,y:t.data.y})}));var Z={nodes:j,edges:I};return null==A||A(Z),Z},t}();function k(t,e,r,n){if(isNaN(e)||isNaN(r))return t;var o,i,s,a,u,h,l,c,f,d=t._root,g={data:n},p=t._x0,m=t._y0,w=t._x1,y=t._y1;if(!d)return t._root=g,t;for(;d.length;)if((h=e>=(i=(p+w)/2))?p=i:w=i,(l=r>=(s=(m+y)/2))?m=s:y=s,o=d,!(d=d[c=l<<1|h]))return o[c]=g,t;if(a=+t._x.call(null,d.data),u=+t._y.call(null,d.data),e===a&&r===u)return g.next=d,o?o[c]=g:t._root=g,t;do{o=o?o[c]=new Array(4):t._root=new Array(4),(h=e>=(i=(p+w)/2))?p=i:w=i,(l=r>=(s=(m+y)/2))?m=s:y=s}while((c=l<<1|h)==(f=(u>=s)<<1|a>=i));return o[f]=d,o[c]=g,t}function A(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 I(t){return t[1]}function R(t,e,r){var n=new _(null==e?D:e,null==r?I:r,NaN,NaN,NaN,NaN);return null==t?n:n.addAll(t)}function _(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 z(t){for(var e={data:t.data},r=e;t=t.next;)r=r.next={data:t.data};return e}var T=R.prototype=_.prototype;function P(t){return function(){return t}}function C(t){return 1e-6*(t()-.5)}T.copy=function(){var t,e,r=new _(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=z(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]=z(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),u=1/0,h=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<u&&(u=n),n>l&&(l=n),o<h&&(h=o),o>c&&(c=o));if(u>l||h>c)return this;for(this.cover(u,h).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,u=o-r||1,h=this._root;r>t||t>=o||n>e||e>=i;)switch(a=(e<n)<<1|t<r,(s=new Array(4))[a]=h,h=s,u*=2,a){case 0:o=r+u,i=n+u;break;case 1:r=o-u,i=n+u;break;case 2:o=r+u,n=i-u;break;case 3:r=o-u,n=i-u}this._root&&this._root.length&&(this._root=h)}return this._x0=r,this._y0=n,this._x1=o,this._y1=i,this},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,u,h,l=this._x0,c=this._y0,f=this._x1,d=this._y1,g=[],p=this._root;for(p&&g.push(new A(p,l,c,f,d)),null==r?r=1/0:(l=t-r,c=e-r,f=t+r,d=e+r,r*=r);u=g.pop();)if(!(!(p=u.node)||(o=u.x0)>f||(i=u.y0)>d||(s=u.x1)<l||(a=u.y1)<c))if(p.length){var m=(o+s)/2,w=(i+a)/2;g.push(new A(p[3],m,w,s,a),new A(p[2],o,w,m,a),new A(p[1],m,i,s,w),new A(p[0],o,i,m,w)),(h=(e>=w)<<1|t>=m)&&(u=g[g.length-1],g[g.length-1]=g[g.length-1-h],g[g.length-1-h]=u)}else{var y=t-+this._x.call(null,p.data),v=e-+this._y.call(null,p.data),x=y*y+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,u,h,l,c,f,d=this._root,g=this._x0,p=this._y0,m=this._x1,w=this._y1;if(!d)return this;if(d.length)for(;;){if((h=i>=(a=(g+m)/2))?g=a:m=a,(l=s>=(u=(p+w)/2))?p=u:w=u,e=d,!(d=d[c=l<<1|h]))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=[],u=this._root;for(u&&a.push(new A(u,this._x0,this._y0,this._x1,this._y1));e=a.pop();)if(!t(u=e.node,n=e.x0,o=e.y0,i=e.x1,s=e.y1)&&u.length){var h=(n+i)/2,l=(o+s)/2;(r=u[3])&&a.push(new A(r,h,l,i,s)),(r=u[2])&&a.push(new A(r,n,l,h,s)),(r=u[1])&&a.push(new A(r,h,o,i,l)),(r=u[0])&&a.push(new A(r,n,o,h,l))}return this},T.visitAfter=function(t){var e,r=[],n=[];for(this._root&&r.push(new A(this._root,this._x0,this._y0,this._x1,this._y1));e=r.pop();){var o=e.node;if(o.length){var i,s=e.x0,a=e.y0,u=e.x1,h=e.y1,l=(s+u)/2,c=(a+h)/2;(i=o[0])&&r.push(new A(i,s,a,l,c)),(i=o[1])&&r.push(new A(i,l,a,u,c)),(i=o[2])&&r.push(new A(i,s,c,l,h)),(i=o[3])&&r.push(new A(i,l,c,u,h))}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 O={value:()=>{}};function j(){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 q(n)}function q(t){this._=t}function V(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 L(t,e){for(var r,n=0,o=t.length;n<o;++n)if((r=t[n]).name===e)return r.value}function F(t,e,r){for(var n=0,o=t.length;n<o;++n)if(t[n].name===e){t[n]=O,t=t.slice(0,n).concat(t.slice(n+1));break}return null!=r&&t.push({name:e,value:r}),t}q.prototype=j.prototype={constructor:q,on:function(t,e){var r,n=this._,o=V(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]=F(n[r],t.name,e);else if(null==e)for(r in n)n[r]=F(n[r],t.name,null);return this}for(;++i<s;)if((r=(t=o[i]).type)&&(r=L(n[r],t.name)))return r},copy:function(){var t={},e=this._;for(var r in e)t[r]=e[r].slice();return new q(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;var U,B,K=0,G=0,W=0,J=0,H=0,Y=0,X="object"==typeof performance&&performance.now?performance:Date,Q="object"==typeof window&&window.requestAnimationFrame?window.requestAnimationFrame.bind(window):function(t){setTimeout(t,17)};function Z(){return H||(Q(tt),H=X.now()+Y)}function tt(){H=0}function et(){this._call=this._time=this._next=null}function rt(t,e,r){var n=new et;return n.restart(t,e,r),n}function nt(){H=(J=X.now())+Y,K=G=0;try{!function(){Z(),++K;for(var t,e=U;e;)(t=H-e._time)>=0&&e._call.call(void 0,t),e=e._next;--K}()}finally{K=0,function(){for(var t,e,r=U,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:U=e);B=t,it(n)}(),H=0}}function ot(){var t=X.now(),e=t-J;e>1e3&&(Y-=e,J=t)}function it(t){K||(G&&(G=clearTimeout(G)),t-H>24?(t<1/0&&(G=setTimeout(nt,t-X.now()-Y)),W&&(W=clearInterval(W))):(W||(J=X.now(),W=setInterval(ot,1e3)),K=1,Q(nt)))}et.prototype=rt.prototype={constructor:et,restart:function(t,e,r){if("function"!=typeof t)throw new TypeError("callback is not a function");r=(null==r?Z():+r)+(null==e?0:+e),this._next||B===this||(B?B._next=this:U=this,B=this),this._call=t,this._time=r,it()},stop:function(){this._call&&(this._call=null,this._time=1/0,it())}};const st=4294967296;function at(t){return t.x}function ut(t){return t.y}var ht=Math.PI*(3-Math.sqrt(5));function lt(t){var e,r=1,n=.001,o=1-Math.pow(n,1/300),i=0,s=.6,a=new Map,u=rt(c),h=$("tick","end"),l=function(){let t=1;return()=>(t=(1664525*t+1013904223)%st)/st}();function c(){f(),h.call("tick",e),r<n&&(u.stop(),h.call("end",e))}function f(n){var u,h,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)})),u=0;u<l;++u)null==(h=t[u]).fx?h.x+=h.vx*=s:(h.x=h.fx,h.vx=0),null==h.fy?h.y+=h.vy*=s:(h.y=h.fy,h.vy=0);return e}function d(){for(var e,r=0,n=t.length;r<n;++r){if((e=t[r]).index=r,null!=e.fx&&(e.x=e.fx),null!=e.fy&&(e.y=e.fy),isNaN(e.x)||isNaN(e.y)){var o=10*Math.sqrt(.5+r),i=r*ht;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 u.restart(c),e},stop:function(){return u.stop(),e},nodes:function(r){return arguments.length?(t=r,d(),a.forEach(g),e):t},alpha:function(t){return arguments.length?(r=+t,e):r},alphaMin:function(t){return arguments.length?(n=+t,e):n},alphaDecay:function(t){return arguments.length?(o=+t,e):+o},alphaTarget:function(t){return arguments.length?(i=+t,e):i},velocityDecay:function(t){return arguments.length?(s=1-t,e):1-s},randomSource:function(t){return arguments.length?(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,u,h=0,l=t.length;for(null==n?n=1/0:n*=n,h=0;h<l;++h)(s=(o=e-(a=t[h]).x)*o+(i=r-a.y)*i)<n&&(u=a,n=s);return u},on:function(t,r){return arguments.length>1?(h.on(t,r),e):h.on(t)}}}function ct(){var t,e,r,n,o,i=P(-30),s=1,a=1/0,u=.81;function h(r){var o,i=t.length,s=R(t,at,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,u=0;if(t.length){for(n=i=s=0;s<4;++s)(e=t[s])&&(r=Math.abs(e.value))&&(a+=e.value,u+=r,n+=r*e.x,i+=r*e.y);t.x=n/u,t.y=i/u}else{(e=t).x=e.data.x,e.y=e.data.y;do{a+=o[e.data.index]}while(e=e.next)}t.value=a}function f(t,i,h,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/u<g)return g<a&&(0===c&&(g+=(c=C(r))*c),0===f&&(g+=(f=C(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=C(r))*c),0===f&&(g+=(f=C(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 h.initialize=function(e,n){t=e,r=n,l()},h.strength=function(t){return arguments.length?(i="function"==typeof t?t:P(+t),l(),h):i},h.distanceMin=function(t){return arguments.length?(s=t*t,h):Math.sqrt(s)},h.distanceMax=function(t){return arguments.length?(a=t*t,h):Math.sqrt(a)},h.theta=function(t){return arguments.length?(u=t*t,h):Math.sqrt(u)},h}function ft(t){return t.index}function dt(t,e){var r=t.get(e);if(!r)throw new Error("node not found: "+e);return r}function gt(t){var e,r,n,o,i,s,a=ft,u=function(t){return 1/Math.min(o[t.source.index],o[t.target.index])},h=P(30),l=1;function c(n){for(var o=0,a=t.length;o<l;++o)for(var u,h,c,f,d,g,p,m=0;m<a;++m)h=(u=t[m]).source,f=(c=u.target).x+c.vx-h.x-h.vx||C(s),d=c.y+c.vy-h.y-h.vy||C(s),f*=g=((g=Math.sqrt(f*f+d*d))-r[m])/g*n*e[m],d*=g,c.vx-=f*(p=i[m]),c.vy-=d*p,h.vx+=f*(p=1-p),h.vy+=d*p}function f(){if(n){var s,u,h=n.length,l=t.length,c=new Map(n.map(((t,e)=>[a(t,e,n),t])));for(s=0,o=new Array(h);s<l;++s)(u=t[s]).index=s,"object"!=typeof u.source&&(u.source=dt(c,u.source)),"object"!=typeof u.target&&(u.target=dt(c,u.target)),o[u.source.index]=(o[u.source.index]||0)+1,o[u.target.index]=(o[u.target.index]||0)+1;for(s=0,i=new Array(l);s<l;++s)u=t[s],i[s]=o[u.source.index]/(o[u.source.index]+o[u.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]=+u(t[r],r,t)}function g(){if(n)for(var e=0,o=t.length;e<o;++e)r[e]=+h(t[e],e,t)}return null==t&&(t=[]),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?(u="function"==typeof t?t:P(+t),d(),c):u},c.distance=function(t){return arguments.length?(h="function"==typeof t?t:P(+t),g(),c):h},c}function pt(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,u,h,l,c,f,d=e.length,g=0;g<i;++g)for(s=R(e,pt,mt).visitAfter(a),t=0;t<d;++t)u=e[t],c=r[u.index],f=c*c,h=u.x+u.vx,l=u.y+u.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>h+g||i<h-g||r>l+g||s<l-g;if(a.index>u.index){var p=h-a.x-a.vx,m=l-a.y-a.vy,w=p*p+m*m;w<g*g&&(0===p&&(w+=(p=C(n))*p),0===m&&(w+=(m=C(n))*m),w=(g-(w=Math.sqrt(w)))/w*o,u.vx+=(p*=w)*(g=(d*=d)/(f+d)),u.vy+=(m*=w)*g,a.vx-=p*(g=1-g),a.vy-=m*g)}}}function a(t){if(t.data)return t.r=r[t.data.index];for(var e=t.r=0;e<4;++e)t[e]&&t[e].r>t.r&&(t.r=t[e].r)}function u(){if(e){var n,o,i=e.length;for(r=new Array(i),n=0;n<i;++n)o=e[n],r[o.index]=+t(o,n,e)}}return"function"!=typeof t&&(t=P(null==t?1:+t)),s.initialize=function(t,r){e=t,n=r,u()},s.iterations=function(t){return arguments.length?(i=+t,s):i},s.strength=function(t){return arguments.length?(o=+t,s):o},s.radius=function(e){return arguments.length?(t="function"==typeof e?e:P(+e),u(),s):t},s}function yt(t){var e,r,n,o=P(.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=P(null==t?0:+t)),i.initialize=function(t){e=t,s()},i.strength=function(t){return arguments.length?(o="function"==typeof t?t:P(+t),s(),i):o},i.x=function(e){return arguments.length?(t="function"==typeof e?e:P(+e),s(),i):t},i}function vt(t){var e,r,n,o=P(.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=P(null==t?0:+t)),i.initialize=function(t){e=t,s()},i.strength=function(t){return arguments.length?(o="function"==typeof t?t:P(+t),s(),i):o},i.y=function(e){return arguments.length?(t="function"==typeof e?e:P(+e),s(),i):t},i}function xt(){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),u=[0,0],h=[],l={},c=[],f=100,d=100,g={none:{x:0,y:0}},p=[],m="force",w=!0,y=.1;function v(t){if(!w)return v;e.tick(),M();for(var n=0,o=h.length,i=void 0,s=t*y;n<o;++n)(i=h[n]).vx+=(g[r(i)].x-i.x)*s,i.vy+=(g[r(i)].y-i.y)*s}function x(){h&&function(){if(h&&h.length){if(void 0===r(h[0]))throw Error("Couldnt find the grouping attribute for the nodes. Make sure to set it up with forceInBox.groupBy(\'clusterAttr\') before calling .links()");var t,u,g,m,w,y=(t=[],u=[],g={},{},w=[],m=function(t){var e={};return t.forEach((function(t){var n=r(t);e[n]||(e[n]={count:0,sumforceNodeSize:0})})),t.forEach((function(t){var o=r(t),i=n(t),s=e[o];s.count=s.count+1,s.sumforceNodeSize=s.sumforceNodeSize+Math.PI*(i*i)*1.3,e[o]=s})),e}(h),w=function(t){var e={},n=[];return t.forEach((function(t){var n,o,i,s,a,u=(o=(n=t).source,i=n.target,(s=r(l[o]))<=(a=r(l[i]))?"".concat(s,"~").concat(a):"".concat(a,"~").concat(s)),h=0;void 0!==e[u]&&(h=e[u]),h+=1,e[u]=h})),Object.entries(e).forEach((function(t){var e=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(m).forEach((function(e,r){var n=m[e];t.push({id:e,size:n.count,r:Math.sqrt(n.sumforceNodeSize/Math.PI)}),g[e]=r})),w.forEach((function(t){var e=t.source,r=t.target,n=g[e],o=g[r];void 0!==n&&void 0!==o&&u.push({source:n,target:o,count:t.count})})),{nodes:t,links:u});e=lt(y.nodes).force("x",yt(f).strength(.1)).force("y",vt(d).strength(.1)).force("collide",wt((function(t){return t.r})).iterations(4)).force("charge",ct().strength(i)).force("links",gt(y.nodes.length?y.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-u[0],y:t.y-u[1]}})),g}function b(t){l={},t.forEach((function(t){l[t.id]=t}))}return v.initialize=function(t){h=t,x()},v.template=function(t){return arguments.length?(m=t,x(),v):m},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?(w=t,v):w},v.strength=function(t){return arguments.length?(y=t,v):y},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||[]),h=t||[],v):h},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?(u=t,v):u},v.getFocis=M,v}var Mt={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},bt=function(){function t(t){void 0===t&&(t={}),this.options=t,this.id="d3force",this.options=r(r({},Mt),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.genericForceLayout=function(t,e,n){var o=this,i=r(r({},this.options),n),s=i.layoutInvisibles,a=e.getAllNodes(),u=e.getAllEdges();s||(a=a.filter((function(t){var e=(t.data||{}).visible;return e||void 0===e})),u=u.filter((function(t){var e=(t.data||{}).visible;return e||void 0===e})));var h=a.map((function(t){var e,n;return r(r({},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})}));if(!this.running){var l=i.alphaMin,c=i.alphaDecay,f=i.alpha,d=i.nodeStrength,g=i.edgeStrength,p=i.linkDistance,m=i.clustering,w=i.clusterFociStrength,y=i.clusterEdgeDistance,v=i.clusterEdgeStrength,x=i.clusterNodeStrength,M=i.clusterNodeSize,b=i.collideStrength,E=void 0===b?1:b,N=i.center,S=void 0===N?[0,0]:N,k=i.preventOverlap,A=i.nodeSize,D=i.nodeSpacing,I=i.onTick,R=i.onLayoutEnd,_=i.forceSimulation;if(_)m&&((z=xt()).nodes(h),z.links(u)),_.nodes(h),u&&(P=gt().id((function(t){return t.id})).links(u),g&&P.strength(g),p&&P.distance(p),_.force("link",P)),k&&this.overlapProcess(_,{nodeSize:A,nodeSpacing:D,collideStrength:E}),_.alpha(f).restart(),this.running=!0;else try{var z,T=ct();if(d&&T.strength(d),_=lt().nodes(h),m&&((z=xt()).centerX(S[0]).centerY(S[1]).template("force").strength(w),u&&z.links(u),h&&z.nodes(h),z.forceLinkDistance(y).forceLinkStrength(v).forceCharge(x).forceNodeSize(M),_.force("group",z)),_.force("center",function(t,e){var r,n=1;function o(){var o,i,s=r.length,a=0,u=0;for(o=0;o<s;++o)a+=(i=r[o]).x,u+=i.y;for(a=(a/s-t)*n,u=(u/s-e)*n,o=0;o<s;++o)(i=r[o]).x-=a,i.y-=u}return null==t&&(t=0),null==e&&(e=0),o.initialize=function(t){r=t},o.x=function(e){return arguments.length?(t=+e,o):t},o.y=function(t){return arguments.length?(e=+t,o):e},o.strength=function(t){return arguments.length?(n=+t,o):n},o}(S[0],S[1])).force("charge",T).alpha(f).alphaDecay(c).alphaMin(l),k&&this.overlapProcess(_,{nodeSize:A,nodeSpacing:D,collideStrength:E}),u){var P=gt().id((function(t){return t.id})).links(u);g&&P.strength(g),p&&P.distance(p),_.force("link",P)}_.on("tick",(function(){null==I||I({nodes:Et(h),edges:Nt(u)})})).on("end",(function(){o.running=!1,null==R||R({nodes:Et(h),edges:Nt(u)})})),this.running=!0}catch(t){this.running=!1,console.warn(t)}var C=Et(h);return t&&C.forEach((function(t){return e.mergeNodeData(t.id,{x:t.data.x,y:t.data.y})})),{nodes:C,edges:u}}},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}:w(i)?i:function(){return 0},o)if(w(o))r=function(t){return o(t)+n(t)};else if(h(o)){var a=(o[0]>o[1]?o[0]:o[1])/2;r=function(t){return a+n(t)}}else if(l(o)){var u=o/2;r=function(t){return u+n(t)}}else r=function(){return 10};else r=function(t){return t.size?h(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}(),Et=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})})}))},Nt=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 St(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,animate:!0,factor:1,edgeStrength:200,nodeStrength:1e3,coulombDisScale:.005,damping:.9,maxSpeed:500,minMovement:.4,interval:.02,linkDistance:200,clusterNodeStrength:20,preventOverlap:!0,distanceThresholdMode:"mean"},At=function(){function t(t){void 0===t&&(t={}),this.options=t,this.id="force",this.timeInterval=0,this.judgingDistance=0,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.genericForceLayout=function(t,e,n){var o=this,i=r(r({},this.options),n),a=e.getAllNodes(),u=e.getAllEdges();i.layoutInvisibles||(a=a.filter((function(t){return t.data.visible||void 0===t.data.visible})),u=u.filter((function(t){return t.data.visible||void 0===t.data.visible})));var h=this.formatOptions(i,e),c=h.width,f=h.height,d=h.nodeSize,g=h.getMass,p=h.nodeStrength,m=h.edgeStrength,w=h.linkDistance,y=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=u.map((function(t){return r(r({},t),{data:r(r({},t.data),{edgeStrength:m(t),linkDistance:w(t,e.getNode(t.source),e.getNode(t.target))})})}));if(!(null==a?void 0:a.length))return{nodes:[],edges:u};var x={};a.forEach((function(t,e){x[t.id]={x:0,y:0}}));var M=new s({nodes:y,edges:v});this.formatCentripetal(h,M);var b=h.maxIteration,E=h.animate,N=h.minMovement,S=h.onLayoutEnd,k=h.onTick;if(!E){for(var A=0;(this.judgingDistance>N||A<1)&&A<b;A++)this.runOneStep(M,e,A,x,h),this.updatePosition(e,M,x,h),t&&y.forEach((function(t){return e.mergeNodeData(t.id,{x:t.data.x,y:t.data.y})})),null==k||k({nodes:zt(e,y),edges:u});t&&y.forEach((function(t){return e.mergeNodeData(t.id,{x:t.data.x,y:t.data.y})}));var D={nodes:zt(e,y),edges:u};return null==S||S(D),D}if("undefined"!=typeof window){var I=0;return this.timeInterval=window.setInterval((function(){a&&(o.runOneStep(M,e,I,x,h),o.updatePosition(e,M,x,h),t&&y.forEach((function(t){return e.mergeNodeData(t.id,{x:t.data.x,y:t.data.y})})),null==k||k({nodes:zt(e,y),edges:u}),(++I>=b||o.judgingDistance<N)&&(null==S||S({nodes:zt(e,y),edges:u}),window.clearInterval(o.timeInterval)))}),0),{nodes:zt(e,y),edges:u}}},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=y(0,t.nodeSpacing);t.nodeSize?h(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?h(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?y(1,t.linkDistance):function(t){return 1+r.nodeSize(e.getNode(t.source))+r.nodeSize(e.getNode(t.target))},r.nodeStrength=y(1,t.nodeStrength),r.edgeStrength=y(1,t.edgeStrength),t},t.prototype.formatCentripetal=function(t,e){var r,n=t.centripetalOptions,o=t.center,i=t.clusterNodeStrength,s=t.leafCluster,a=t.clustering,u=t.nodeClusterBy,h=e.getAllNodes(),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&&u&&(r=Dt(e,u),c=Array.from(new Set(null==h?void 0:h.map((function(t){return t.data[u]}))))||[],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=_t(s))}else n=void 0;return{x:null==n?void 0:n.x,y:null==n?void 0:n.y}}})),a&&u){r||(r=Dt(e,u)),c||(c=Array.from(new Set(h.map((function(t){return t.data[u]}))))),c=c.filter((function(t){return void 0!==t}));var f={};c.forEach((function(t){var r=h.filter((function(e){return e.data[u]===t})).map((function(t){return e.getNode(t.id)}));f[t]=_t(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[u]];return{x:null==e?void 0:e.x,y:null==e?void 0:e.y}}})}var d=t.centripetalOptions,g=d.leaf,p=d.single,m=d.others;g&&"function"!=typeof g&&(t.centripetalOptions.leaf=function(){return g}),p&&"function"!=typeof p&&(t.centripetalOptions.single=function(){return p}),m&&"function"!=typeof m&&(t.centripetalOptions.others=function(){return m})},t.prototype.runOneStep=function(t,e,r,n,o){var i={},s=t.getAllNodes(),a=t.getAllEdges();if(null==s?void 0:s.length){var u=o.monitor;this.calRepulsive(t,i,o),a&&this.calAttractive(t,i),this.calGravity(t,e,i,o),this.updateVelocity(t,i,n,o),u&&u({energy:this.calTotalEnergy(i,s),nodes:e.getAllNodes(),edges:e.getAllEdges(),iterations:r})}},t.prototype.calTotalEnergy=function(t,e){if(!(null==e?void 0:e.length))return 0;var r=0;return e.forEach((function(e,n){var o=t[e.id].x,i=t[e.id].y,s=o*o+i*i,a=e.data.mass;r+=(void 0===a?1:a)*s*.5})),r},t.prototype.calRepulsive=function(t,e,r){var n=r.factor,o=r.coulombDisScale;!function(t,e,r,n){var o=e/r,i=t.getAllNodes(),s=i.map((function(t,e){var r=t.data,n=r.nodeStrength;return{x:r.x,y:r.y,size:r.size,index:e,vx:0,vy:0,weight:o*n}})),a=R(s,(function(t){return t.x}),(function(t){return t.y})).visitAfter(St);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,u=n-e,h=s*s+a*a,l=Math.sqrt(h)*h;if(u*u*.81<h){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 u=a.data.x-s.data.x,h=a.data.y-s.data.y;u||h||(u=.01*Math.random(),h=.01*Math.random());var l=Math.sqrt(u*u+h*h),c=u/l,f=h/l,d=edgeInfos[n]||{},g=d.linkDistance,p=void 0===g?200:g,m=d.edgeStrength,w=(p-l)*(void 0===m?200:m),y=1/(s.data.mass||1),v=1/(a.data.mass||1),x=c*w,M=f*w;e[o].x-=x*y,e[o].y-=M*y,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(),u=e.getAllEdges(),h=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,m=p.mass,w=p.x,y=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==i?void 0:i(v,S);if(k){var A=o(k,3);x=w-A[0],M=y-A[1],b=A[2]}else x=w-f[0],M=y-f[1];if(b&&(r[s].x-=b*x/m,r[s].y-=b*M/m),g){var D=g.leaf,I=g.single,R=g.others,_=g.center,z=(null==_?void 0:_(v,a,u,h,c))||{x:0,y:0,centerStrength:0},T=z.x,P=z.y,C=z.centerStrength;if(!l(T)||!l(P))return;var O=(w-T)/m,j=(y-P)/m;if(C&&(r[s].x-=C*O,r[s].y-=C*j),0===S){var q=I(v);if(!q)return;return r[s].x-=q*O,void(r[s].y-=q*j)}if(0===E||0===N){var V=D(v,a,u);if(!V)return;return r[s].x-=V*O,void(r[s].y-=V*j)}var L=R(v);if(!L)return;r[s].x-=L*O,r[s].y-=L*j}}))},t.prototype.updateVelocity=function(t,e,r,n){var o=n.damping,i=n.maxSpeed,s=n.interval,a=t.getAllNodes();(null==a?void 0:a.length)&&a.forEach((function(t){var n=t.id,a=(r[n].x+e[n].x*s)*o||.01,u=(r[n].y+e[n].y*s)*o||.01,h=Math.sqrt(a*a+u*u);if(h>i){var l=i/h;a*=l,u*=l}r[n]={x:a,y:u}}))},t.prototype.updatePosition=function(t,e,r,n){var o=this,i=n.distanceThresholdMode,s=n.interval,a=e.getAllNodes();if(null==a?void 0:a.length){var u=0;"max"===i?this.judgingDistance=-1/0:"min"===i&&(this.judgingDistance=1/0),a.forEach((function(n){var a=n.id,h=t.getNode(a);if(l(h.data.fx)&&l(h.data.fy))e.mergeNodeData(a,{x:h.data.fx,y:h.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:u+=d}}})),i&&"mean"!==i||(this.judgingDistance=u/a.length)}else this.judgingDistance=0},t.prototype.stop=function(){this.timeInterval&&"undefined"!=typeof window&&window.clearInterval(this.timeInterval)},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]=It(t,"leaf",r,e))})),n},It=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:Rt(t,e,n,r,a)}},Rt=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},_t=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}},zt=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={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},Pt=function(){function t(t){void 0===t&&(t={}),this.options=t,this.id="grid",this.options=r(r({},Tt),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,u=o.condense,c=o.preventOverlapPadding,f=o.preventOverlap,d=o.rows,g=o.cols,p=o.nodeSpacing,w=o.nodeSize,x=o.width,M=o.height,b=o.layoutInvisibles,E=o.onLayoutEnd,N=o.position,S=o.sortBy,k=e.getAllNodes(),A=e.getAllEdges();b||(k=k.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=k.length;if(0===D){var I={nodes:[],edges:A};return null==E||E(I),I}if(1===D){t&&e.mergeNodeData(k[0].id,{x:s[0],y:s[1]});var R={nodes:[r(r({},k[0]),{data:r(r({},k[0].data),{x:s[0],y:s[1]})})],edges:A};return null==E||E(R),R}var _=k.map((function(t){return m(t)}));"id"===S||a(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 l(e.id)&&l(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 z=x||"undefined"==typeof window?x:window.innerWidth,T=M||"undefined"==typeof window?M:window.innerHeight,P=D,C={rows:d,cols:g};if(null!=d&&null!=g)C.rows=d,C.cols=g;else if(null!=d&&null==g)C.rows=d,C.cols=Math.ceil(P/C.rows);else if(null==d&&null!=g)C.cols=g,C.rows=Math.ceil(P/C.cols);else{var O=Math.sqrt(P*T/z);C.rows=Math.round(O),C.cols=Math.round(z/T*O)}if(C.rows=Math.max(C.rows,1),C.cols=Math.max(C.cols,1),C.cols*C.rows>P)((q=Ct(C))-1)*(j=Ot(C))>=P?Ct(C,q-1):(j-1)*q>=P&&Ot(C,j-1);else for(;C.cols*C.rows<P;){var j,q=Ct(C);((j=Ot(C))+1)*q>=P?Ot(C,j+1):Ct(C,q+1)}var V=u?0:z/C.cols,L=u?0:T/C.rows;if(f||p){var F=y(10,p),$=v(30,w,!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=$(o)||30;h(i)?(r=i[0],n=i[1]):(r=i,n=i);var s=void 0!==F?F(t):c,a=r+s,u=n+s;V=Math.max(V,a),L=Math.max(L,u)}))}for(var U={},B={row:0,col:0},K={},G=0;G<_.length;G++){var W=_[G],J=void 0;if(N&&(J=N(e.getNode(W.id))),J&&(void 0!==J.row||void 0!==J.col)){var H={row:J.row,col:J.col};if(void 0===H.col)for(H.col=0;jt(U,H);)H.col++;else if(void 0===H.row)for(H.row=0;jt(U,H);)H.row++;K[W.id]=H,qt(U,H)}Lt(W,s,V,L,K,C,B,U)}var Y={nodes:_,edges:A};return null==E||E(Y),t&&_.forEach((function(t){e.mergeNodeData(t.id,{x:t.data.x,y:t.data.y})})),Y},t}(),Ct=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},Ot=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},jt=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},Vt=function(t,e){var r=t.cols||5;e.col++,e.col>=r&&(e.col=0,e.row++)},Lt=function(t,e,r,n,o,i,s,a){var u,h,l=o[t.id];if(l)u=l.col*r+r/2+e[0],h=l.row*n+n/2+e[1];else{for(;jt(a,s);)Vt(i,s);u=s.col*r+r/2+e[0],h=s.row*n+n/2+e[1],qt(a,s),Vt(i,s)}t.data.x=u,t.data.y=h};const Ft=Object.prototype.toString;function $t(t){return Ft.call(t).endsWith("Array]")}function Ut(t){var e=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};if(!$t(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 Bt(t){var e=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};if(!$t(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 Kt(t){var e,r=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};if(!$t(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(!$t(r.output))throw new TypeError("output option must be an array if specified");e=r.output}else e=new Array(t.length);var n=Bt(t),o=Ut(t);if(n===o)throw new RangeError("minimum and maximum input values are equal. Cannot rescale a constant array");var i=r.min,s=void 0===i?r.autoMinMax?n:0:i,a=r.max,u=void 0===a?r.autoMinMax?o:1:a;if(s>=u)throw new RangeError("min option must be smaller than max option");for(var h=(u-s)/(o-n),l=0;l<t.length;l++)e[l]=(t[l]-n)*h+s;return e}const Gt=" ".repeat(2),Wt=" ".repeat(4);function Jt(t,e={}){const{maxRows:r=15,maxColumns:n=10,maxNumSize:o=8,padMinus:i="auto"}=e;return`${t.constructor.name} {\\n${Gt}[\\n${Wt}${function(t,e,r,n,o){const{rows:i,columns:s}=t,a=Math.min(i,e),u=Math.min(s,r),h=[];if("auto"===o){o=!1;t:for(let e=0;e<a;e++)for(let r=0;r<u;r++)if(t.get(e,r)<0){o=!0;break t}}for(let e=0;e<a;e++){let r=[];for(let i=0;i<u;i++)r.push(Ht(t.get(e,i),n,o));h.push(`${r.join(" ")}`)}return u!==s&&(h[h.length-1]+=` ... ${s-r} more columns`),a!==i&&h.push(`... ${i-e} more rows`),h.join(`\\n${Wt}`)}(t,r,n,o,i)}\\n${Gt}]\\n${Gt}rows: ${t.rows}\\n${Gt}columns: ${t.columns}\\n}`}function Ht(t,e,r){return(t>=0&&r?` ${Yt(t,e-1)}`:Yt(t,e)).padEnd(e)}function Yt(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 Xt(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 Qt(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 Zt(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 te(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 ee(t,e,r,n,o){if(5!==arguments.length)throw new RangeError("expected 4 arguments");if(ne("startRow",e),ne("endRow",r),ne("startColumn",n),ne("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 re(t,e=0){let r=[];for(let n=0;n<t;n++)r.push(e);return r}function ne(t,e){if("number"!=typeof e)throw new TypeError(`${t} must be a number`)}function oe(t){if(t.isEmpty())throw new Error("Empty matrix has no elements to index")}class ie{static from1DArray(t,e,r){if(t*e!==r.length)throw new RangeError("data length does not match given dimensions");let n=new ae(t,e);for(let o=0;o<t;o++)for(let t=0;t<e;t++)n.set(o,t,r[o*e+t]);return n}static rowVector(t){let e=new ae(1,t.length);for(let r=0;r<t.length;r++)e.set(0,r,t[r]);return e}static columnVector(t){let e=new ae(t.length,1);for(let r=0;r<t.length;r++)e.set(r,0,t[r]);return e}static zeros(t,e){return new ae(t,e)}static ones(t,e){return new ae(t,e).fill(1)}static rand(t,e,r={}){if("object"!=typeof r)throw new TypeError("options must be an object");const{random:n=Math.random}=r;let o=new ae(t,e);for(let r=0;r<t;r++)for(let t=0;t<e;t++)o.set(r,t,n());return o}static randInt(t,e,r={}){if("object"!=typeof r)throw new TypeError("options must be an object");const{min:n=0,max:o=1e3,random:i=Math.random}=r;if(!Number.isInteger(n))throw new TypeError("min must be an integer");if(!Number.isInteger(o))throw new TypeError("max must be an integer");if(n>=o)throw new RangeError("min must be smaller than max");let s=o-n,a=new ae(t,e);for(let r=0;r<t;r++)for(let t=0;t<e;t++){let e=n+Math.round(i()*s);a.set(r,t,e)}return a}static eye(t,e,r){void 0===e&&(e=t),void 0===r&&(r=1);let n=Math.min(t,e),o=this.zeros(t,e);for(let t=0;t<n;t++)o.set(t,t,r);return o}static diag(t,e,r){let n=t.length;void 0===e&&(e=n),void 0===r&&(r=e);let o=Math.min(n,e,r),i=this.zeros(e,r);for(let e=0;e<o;e++)i.set(e,e,t[e]);return i}static min(t,e){t=this.checkMatrix(t),e=this.checkMatrix(e);let r=t.rows,n=t.columns,o=new ae(r,n);for(let i=0;i<r;i++)for(let r=0;r<n;r++)o.set(i,r,Math.min(t.get(i,r),e.get(i,r)));return o}static max(t,e){t=this.checkMatrix(t),e=this.checkMatrix(e);let r=t.rows,n=t.columns,o=new this(r,n);for(let i=0;i<r;i++)for(let r=0;r<n;r++)o.set(i,r,Math.max(t.get(i,r),e.get(i,r)));return o}static checkMatrix(t){return ie.isMatrix(t)?t:new ae(t)}static isMatrix(t){return null!=t&&"Matrix"===t.klass}get size(){return this.rows*this.columns}apply(t){if("function"!=typeof t)throw new TypeError("callback must be a function");for(let e=0;e<this.rows;e++)for(let r=0;r<this.columns;r++)t.call(this,e,r);return this}to1DArray(){let t=[];for(let e=0;e<this.rows;e++)for(let r=0;r<this.columns;r++)t.push(this.get(e,r));return t}to2DArray(){let t=[];for(let e=0;e<this.rows;e++){t.push([]);for(let r=0;r<this.columns;r++)t[e].push(this.get(e,r))}return t}toJSON(){return this.to2DArray()}isRowVector(){return 1===this.rows}isColumnVector(){return 1===this.columns}isVector(){return 1===this.rows||1===this.columns}isSquare(){return this.rows===this.columns}isEmpty(){return 0===this.rows||0===this.columns}isSymmetric(){if(this.isSquare()){for(let t=0;t<this.rows;t++)for(let e=0;e<=t;e++)if(this.get(t,e)!==this.get(e,t))return!1;return!0}return!1}isEchelonForm(){let t=0,e=0,r=-1,n=!0,o=!1;for(;t<this.rows&&n;){for(e=0,o=!1;e<this.columns&&!1===o;)0===this.get(t,e)?e++:1===this.get(t,e)&&e>r?(o=!0,r=e):(n=!1,o=!0);t++}return n}isReducedEchelonForm(){let t=0,e=0,r=-1,n=!0,o=!1;for(;t<this.rows&&n;){for(e=0,o=!1;e<this.columns&&!1===o;)0===this.get(t,e)?e++:1===this.get(t,e)&&e>r?(o=!0,r=e):(n=!1,o=!0);for(let r=e+1;r<this.rows;r++)0!==this.get(t,r)&&(n=!1);t++}return n}echelonForm(){let t=this.clone(),e=0,r=0;for(;e<t.rows&&r<t.columns;){let n=e;for(let o=e;o<t.rows;o++)t.get(o,r)>t.get(n,r)&&(n=o);if(0===t.get(n,r))r++;else{t.swapRows(e,n);let o=t.get(e,r);for(let n=r;n<t.columns;n++)t.set(e,n,t.get(e,n)/o);for(let n=e+1;n<t.rows;n++){let o=t.get(n,r)/t.get(e,r);t.set(n,r,0);for(let i=r+1;i<t.columns;i++)t.set(n,i,t.get(n,i)-t.get(e,i)*o)}e++,r++}}return t}reducedEchelonForm(){let t=this.echelonForm(),e=t.columns,r=t.rows,n=r-1;for(;n>=0;)if(0===t.maxRow(n))n--;else{let o=0,i=!1;for(;o<r&&!1===i;)1===t.get(n,o)?i=!0:o++;for(let r=0;r<n;r++){let i=t.get(r,o);for(let s=o;s<e;s++){let e=t.get(r,s)-i*t.get(n,s);t.set(r,s,e)}}n--}return t}set(){throw new Error("set method is unimplemented")}get(){throw new Error("get method is unimplemented")}repeat(t={}){if("object"!=typeof t)throw new TypeError("options must be an object");const{rows:e=1,columns:r=1}=t;if(!Number.isInteger(e)||e<=0)throw new TypeError("rows must be a positive integer");if(!Number.isInteger(r)||r<=0)throw new TypeError("columns must be a positive integer");let n=new ae(this.rows*e,this.columns*r);for(let t=0;t<e;t++)for(let e=0;e<r;e++)n.setSubMatrix(this,this.rows*t,this.columns*e);return n}fill(t){for(let e=0;e<this.rows;e++)for(let r=0;r<this.columns;r++)this.set(e,r,t);return this}neg(){return this.mulS(-1)}getRow(t){Xt(this,t);let e=[];for(let r=0;r<this.columns;r++)e.push(this.get(t,r));return e}getRowVector(t){return ae.rowVector(this.getRow(t))}setRow(t,e){Xt(this,t),e=Zt(this,e);for(let r=0;r<this.columns;r++)this.set(t,r,e[r]);return this}swapRows(t,e){Xt(this,t),Xt(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){Qt(this,t);let e=[];for(let r=0;r<this.rows;r++)e.push(this.get(r,t));return e}getColumnVector(t){return ae.columnVector(this.getColumn(t))}setColumn(t,e){Qt(this,t),e=te(this,e);for(let r=0;r<this.rows;r++)this.set(r,t,e[r]);return this}swapColumns(t,e){Qt(this,t),Qt(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=Zt(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=Zt(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=Zt(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=Zt(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=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[e]);return this}subColumnVector(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[e]);return this}mulColumnVector(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[e]);return this}divColumnVector(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[e]);return this}mulRow(t,e){Xt(this,t);for(let r=0;r<this.columns;r++)this.set(t,r,this.get(t,r)*e);return this}mulColumn(t,e){Qt(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(){oe(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(){oe(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(Xt(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){Xt(this,t),oe(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(Xt(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){Xt(this,t),oe(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(Qt(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){Qt(this,t),oe(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(Qt(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){Qt(this,t),oe(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){ie.isMatrix(t)&&(t=t.to1DArray());let e=this.to1DArray();if(e.length!==t.length)throw new RangeError("vectors do not have the same size");let r=0;for(let n=0;n<e.length;n++)r+=e[n]*t[n];return r}mmul(t){t=ae.checkMatrix(t);let e=this.rows,r=this.columns,n=t.columns,o=new ae(e,n),i=new Float64Array(r);for(let s=0;s<n;s++){for(let e=0;e<r;e++)i[e]=t.get(e,s);for(let t=0;t<e;t++){let e=0;for(let n=0;n<r;n++)e+=this.get(t,n)*i[n];o.set(t,s,e)}}return o}strassen2x2(t){t=ae.checkMatrix(t);let e=new ae(2,2);const r=this.get(0,0),n=t.get(0,0),o=this.get(0,1),i=t.get(0,1),s=this.get(1,0),a=t.get(1,0),u=this.get(1,1),h=t.get(1,1),l=(r+u)*(n+h),c=(s+u)*n,f=r*(i-h),d=u*(a-n),g=(r+o)*h,p=l+d-g+(o-u)*(a+h),m=f+g,w=c+d,y=l-c+f+(s-r)*(n+i);return e.set(0,0,p),e.set(0,1,m),e.set(1,0,w),e.set(1,1,y),e}strassen3x3(t){t=ae.checkMatrix(t);let e=new ae(3,3);const r=this.get(0,0),n=this.get(0,1),o=this.get(0,2),i=this.get(1,0),s=this.get(1,1),a=this.get(1,2),u=this.get(2,0),h=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),m=t.get(1,2),w=t.get(2,0),y=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+u+h)*(c-d+m),S=(-r+u)*(d-m),k=(u+h)*(-c+d),A=(-o+h+l)*(p+w-y),D=(o-l)*(p-y),I=o*w,R=(h+l)*(-w+y),_=(-o+s+a)*(m+w-v),z=(o-a)*(m-v),T=(s+a)*(-w+v),P=E+I+n*g,C=(r+n+o-i-s-h-l)*p+M+b+E+A+I+R,O=E+N+k+(r+n+o-s-a-u-h)*m+I+_+T,j=x+s*(-c+f+g-p-m-w+v)+M+E+I+_+z,q=x+M+b+E+a*y,V=I+_+z+T+i*d,L=E+N+S+h*(-c+d+g-p-m-w+y)+A+D+I,F=A+D+I+R+u*f,$=E+N+S+k+l*v;return e.set(0,0,P),e.set(0,1,C),e.set(0,2,O),e.set(1,0,j),e.set(1,1,q),e.set(1,2,V),e.set(2,0,L),e.set(2,1,F),e.set(2,2,$),e}mmulStrassen(t){t=ae.checkMatrix(t);let e=this.clone(),r=e.rows,n=e.columns,o=t.rows,i=t.columns;function s(t,e,r){let n=t.rows,o=t.columns;if(n===e&&o===r)return t;{let n=ie.zeros(e,r);return n=n.setSubMatrix(t,0,0),n}}n!==o&&console.warn(`Multiplying ${r} x ${n} and ${o} x ${i} matrix: dimensions do not match.`);let a=Math.max(r,o),u=Math.max(n,i);return e=s(e,a,u),function t(e,r,n,o){if(n<=512||o<=512)return e.mmul(r);n%2==1&&o%2==1?(e=s(e,n+1,o+1),r=s(r,n+1,o+1)):n%2==1?(e=s(e,n+1,o),r=s(r,n+1,o)):o%2==1&&(e=s(e,n,o+1),r=s(r,n,o+1));let i=parseInt(e.rows/2,10),a=parseInt(e.columns/2,10),u=e.subMatrix(0,i-1,0,a-1),h=r.subMatrix(0,i-1,0,a-1),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),m=t(ie.add(u,g),ie.add(h,p),i,a),w=t(ie.add(f,g),h,i,a),y=t(u,ie.sub(c,p),i,a),v=t(g,ie.sub(d,h),i,a),x=t(ie.add(u,l),p,i,a),M=t(ie.sub(f,u),ie.add(h,c),i,a),b=t(ie.sub(l,g),ie.add(d,p),i,a),E=ie.add(m,v);E.sub(x),E.add(b);let N=ie.add(y,x),S=ie.add(w,v),k=ie.sub(m,w);k.add(y),k.add(M);let A=ie.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,u),a,u)}scaleRows(t={}){if("object"!=typeof t)throw new TypeError("options must be an object");const{min:e=0,max:r=1}=t;if(!Number.isFinite(e))throw new TypeError("min must be a number");if(!Number.isFinite(r))throw new TypeError("max must be a number");if(e>=r)throw new RangeError("min must be smaller than max");let n=new ae(this.rows,this.columns);for(let t=0;t<this.rows;t++){const o=this.getRow(t);o.length>0&&Kt(o,{min:e,max:r,output:o}),n.setRow(t,o)}return n}scaleColumns(t={}){if("object"!=typeof t)throw new TypeError("options must be an object");const{min:e=0,max:r=1}=t;if(!Number.isFinite(e))throw new TypeError("min must be a number");if(!Number.isFinite(r))throw new TypeError("max must be a number");if(e>=r)throw new RangeError("min must be smaller than max");let n=new ae(this.rows,this.columns);for(let t=0;t<this.columns;t++){const o=this.getColumn(t);o.length&&Kt(o,{min:e,max:r,output:o}),n.setColumn(t,o)}return n}flipRows(){const t=Math.ceil(this.columns/2);for(let e=0;e<this.rows;e++)for(let r=0;r<t;r++){let t=this.get(e,r),n=this.get(e,this.columns-1-r);this.set(e,r,n),this.set(e,this.columns-1-r,t)}return this}flipColumns(){const t=Math.ceil(this.rows/2);for(let e=0;e<this.columns;e++)for(let r=0;r<t;r++){let t=this.get(r,e),n=this.get(this.rows-1-r,e);this.set(r,e,n),this.set(this.rows-1-r,e,t)}return this}kroneckerProduct(t){t=ae.checkMatrix(t);let e=this.rows,r=this.columns,n=t.rows,o=t.columns,i=new ae(e*n,r*o);for(let s=0;s<e;s++)for(let e=0;e<r;e++)for(let r=0;r<n;r++)for(let a=0;a<o;a++)i.set(n*s+r,o*e+a,this.get(s,e)*t.get(r,a));return i}kroneckerSum(t){if(t=ae.checkMatrix(t),!this.isSquare()||!t.isSquare())throw new Error("Kronecker Sum needs two Square Matrices");let e=this.rows,r=t.rows,n=this.kroneckerProduct(ae.eye(r,r)),o=ae.eye(e,e).kroneckerProduct(t);return n.add(o)}transpose(){let t=new ae(this.columns,this.rows);for(let e=0;e<this.rows;e++)for(let r=0;r<this.columns;r++)t.set(r,e,this.get(e,r));return t}sortRows(t=se){for(let e=0;e<this.rows;e++)this.setRow(e,this.getRow(e).sort(t));return this}sortColumns(t=se){for(let e=0;e<this.columns;e++)this.setColumn(e,this.getColumn(e).sort(t));return this}subMatrix(t,e,r,n){ee(this,t,e,r,n);let o=new ae(e-t+1,n-r+1);for(let i=t;i<=e;i++)for(let e=r;e<=n;e++)o.set(i-t,e-r,this.get(i,e));return o}subMatrixRow(t,e,r){if(void 0===e&&(e=0),void 0===r&&(r=this.columns-1),e>r||e<0||e>=this.columns||r<0||r>=this.columns)throw new RangeError("Argument out of range");let n=new ae(t.length,r-e+1);for(let o=0;o<t.length;o++)for(let i=e;i<=r;i++){if(t[o]<0||t[o]>=this.rows)throw new RangeError(`Row index out of range: ${t[o]}`);n.set(o,i-e,this.get(t[o],i))}return n}subMatrixColumn(t,e,r){if(void 0===e&&(e=0),void 0===r&&(r=this.rows-1),e>r||e<0||e>=this.rows||r<0||r>=this.rows)throw new RangeError("Argument out of range");let n=new ae(r-e+1,t.length);for(let o=0;o<t.length;o++)for(let i=e;i<=r;i++){if(t[o]<0||t[o]>=this.columns)throw new RangeError(`Column index out of range: ${t[o]}`);n.set(i-e,o,this.get(i,t[o]))}return n}setSubMatrix(t,e,r){if((t=ae.checkMatrix(t)).isEmpty())return this;ee(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(!$t(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(!$t(e))throw new TypeError("column indices must be an array");for(let r=0;r<e.length;r++)if(e[r]<0||e[r]>=t.columns)throw new RangeError("column indices are out of range")}(this,e);let r=new ae(t.length,e.length);for(let n=0;n<t.length;n++){let o=t[n];for(let t=0;t<e.length;t++){let i=e[t];r.set(n,t,this.get(o,i))}}return r}trace(){let t=Math.min(this.rows,this.columns),e=0;for(let r=0;r<t;r++)e+=this.get(r,r);return e}clone(){let t=new ae(this.rows,this.columns);for(let e=0;e<this.rows;e++)for(let r=0;r<this.columns;r++)t.set(e,r,this.get(e,r));return t}sum(t){switch(t){case"row":return function(t){let e=re(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=re(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=re(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=re(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(!$t(n))throw new TypeError("mean must be an array");return function(t,e,r){const n=t.rows,o=t.columns,i=[];for(let s=0;s<n;s++){let n=0,a=0,u=0;for(let e=0;e<o;e++)u=t.get(s,e)-r[s],n+=u,a+=u*u;e?i.push((a-n*n/o)/(o-1)):i.push((a-n*n/o)/o)}return i}(this,r,n);case"column":if(!$t(n))throw new TypeError("mean must be an array");return function(t,e,r){const n=t.rows,o=t.columns,i=[];for(let s=0;s<o;s++){let o=0,a=0,u=0;for(let e=0;e<n;e++)u=t.get(e,s)-r[s],o+=u,a+=u*u;e?i.push((a-o*o/n)/(n-1)):i.push((a-o*o/n)/n)}return i}(this,r,n);case void 0:if("number"!=typeof n)throw new TypeError("mean must be a number");return function(t,e,r){const n=t.rows,o=t.columns,i=n*o;let s=0,a=0,u=0;for(let e=0;e<n;e++)for(let n=0;n<o;n++)u=t.get(e,n)-r,s+=u,a+=u*u;return e?(a-s*s/i)/(i-1):(a-s*s/i)/i}(this,r,n);default:throw new Error(`invalid option: ${t}`)}}standardDeviation(t,e){"object"==typeof t&&(e=t,t=void 0);const r=this.variance(t,e);if(void 0===t)return Math.sqrt(r);for(let t=0;t<r.length;t++)r[t]=Math.sqrt(r[t]);return r}center(t,e={}){if("object"==typeof t&&(e=t,t=void 0),"object"!=typeof e)throw new TypeError("options must be an object");const{center:r=this.mean(t)}=e;switch(t){case"row":if(!$t(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(!$t(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(!$t(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(!$t(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 Jt(this,t)}}function se(t,e){return t-e}ie.prototype.klass="Matrix","undefined"!=typeof Symbol&&(ie.prototype[Symbol.for("nodejs.util.inspect.custom")]=function(){return Jt(this)}),ie.random=ie.rand,ie.randomInt=ie.randInt,ie.diagonal=ie.diag,ie.prototype.diagonal=ie.prototype.diag,ie.identity=ie.eye,ie.prototype.negate=ie.prototype.neg,ie.prototype.tensorProduct=ie.prototype.kroneckerProduct;class ae extends ie{constructor(t,e){if(super(),ae.isMatrix(t))return t.clone();if(Number.isInteger(t)&&t>=0){if(this.data=[],!(Number.isInteger(e)&&e>=0))throw new TypeError("nColumns must be a positive integer");for(let r=0;r<t;r++)this.data.push(new Float64Array(e))}else{if(!$t(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 Xt(this,t),this.data.splice(t,1),this.rows-=1,this}addRow(t,e){return void 0===e&&(e=t,t=this.rows),Xt(this,t,!0),e=Float64Array.from(Zt(this,e)),this.data.splice(t,0,e),this.rows+=1,this}removeColumn(t){Qt(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),Qt(this,t,!0),e=te(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}}(ie,ae);class ue extends ie{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 he(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 le{constructor(t,e={}){if((t=ue.checkMatrix(t)).isEmpty())throw new Error("Matrix must be non-empty");let r=t.rows,n=t.columns;const{computeLeftSingularVectors:o=!0,computeRightSingularVectors:i=!0,autoTranspose:s=!1}=e;let a,u=Boolean(o),h=Boolean(i),l=!1;if(r<n)if(s){a=t.transpose(),r=a.rows,n=a.columns,l=!0;let e=u;u=h,h=e}else a=t.clone(),console.warn("Computing SVD on a matrix with more columns than rows. Consider enabling autoTranspose");else a=t.clone();let c=Math.min(r,n),f=Math.min(r+1,n),d=new Float64Array(f),g=new ae(r,c),p=new ae(n,n),m=new Float64Array(n),w=new Float64Array(r),y=new Float64Array(f);for(let t=0;t<f;t++)y[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]=he(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))}m[e]=a.get(t,e)}if(u&&t<v)for(let e=t;e<r;e++)g.set(e,t,a.get(e,t));if(t<x){m[t]=0;for(let e=t+1;e<n;e++)m[t]=he(m[t],m[e]);if(0!==m[t]){m[t+1]<0&&(m[t]=0-m[t]);for(let e=t+1;e<n;e++)m[e]/=m[t];m[t+1]+=1}if(m[t]=-m[t],t+1<r&&0!==m[t]){for(let e=t+1;e<r;e++)w[e]=0;for(let e=t+1;e<r;e++)for(let r=t+1;r<n;r++)w[e]+=m[r]*a.get(e,r);for(let e=t+1;e<n;e++){let n=-m[e]/m[t+1];for(let o=t+1;o<r;o++)a.set(o,e,a.get(o,e)+n*w[o])}}if(h)for(let e=t+1;e<n;e++)p.set(e,t,m[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&&(m[x]=a.get(x,b-1)),m[b-1]=0,u){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(h)for(let t=n-1;t>=0;t--){if(t<x&&0!==m[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(m[t])<=e||Number.isNaN(m[t])){m[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(m[r]):0)+(r!==t+1?Math.abs(m[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=m[b-2];m[b-2]=0;for(let r=b-2;r>=t;r--){let o=he(d[r],e),i=d[r]/o,s=e/o;if(d[r]=o,r!==t&&(e=-s*m[r-1],m[r-1]=i*m[r-1]),h)for(let t=0;t<n;t++)o=i*p.get(t,r)+s*p.get(t,b-1),p.set(t,b-1,-s*p.get(t,r)+i*p.get(t,b-1)),p.set(t,r,o)}break}case 2:{let e=m[t-1];m[t-1]=0;for(let n=t;n<b;n++){let o=he(d[n],e),i=d[n]/o,s=e/o;if(d[n]=o,e=-s*m[n],m[n]=i*m[n],u)for(let e=0;e<r;e++)o=i*g.get(e,n)+s*g.get(e,t-1),g.set(e,t-1,-s*g.get(e,n)+i*g.get(e,t-1)),g.set(e,n,o)}break}case 3:{const e=Math.max(Math.abs(d[b-1]),Math.abs(d[b-2]),Math.abs(m[b-2]),Math.abs(d[t]),Math.abs(m[t])),o=d[b-1]/e,i=d[b-2]/e,s=m[b-2]/e,a=d[t]/e,l=m[t]/e,c=((i+o)*(i-o)+s*s)/2,f=o*s*(o*s);let w=0;0===c&&0===f||(w=c<0?0-Math.sqrt(c*c+f):Math.sqrt(c*c+f),w=f/(c+w));let y=(a+o)*(a-o)+w,v=a*l;for(let e=t;e<b-1;e++){let o=he(y,v);0===o&&(o=Number.MIN_VALUE);let i=y/o,s=v/o;if(e!==t&&(m[e-1]=o),y=i*d[e]+s*m[e],m[e]=i*m[e]-s*d[e],v=s*d[e+1],d[e+1]=i*d[e+1],h)for(let t=0;t<n;t++)o=i*p.get(t,e)+s*p.get(t,e+1),p.set(t,e+1,-s*p.get(t,e)+i*p.get(t,e+1)),p.set(t,e,o);if(o=he(y,v),0===o&&(o=Number.MIN_VALUE),i=y/o,s=v/o,d[e]=o,y=i*m[e]+s*d[e+1],d[e+1]=-s*m[e]+i*d[e+1],v=s*m[e+1],m[e+1]=i*m[e+1],u&&e<r-1)for(let t=0;t<r;t++)o=i*g.get(t,e)+s*g.get(t,e+1),g.set(t,e+1,-s*g.get(t,e)+i*g.get(t,e+1)),g.set(t,e,o)}m[b-2]=y,N+=1;break}case 4:if(d[t]<=0&&(d[t]=d[t]<0?-d[t]:0,h))for(let e=0;e<=E;e++)p.set(e,t,-p.get(e,t));for(;t<E&&!(d[t]>=d[t+1]);){let e=d[t];if(d[t]=d[t+1],d[t+1]=e,h&&t<n-1)for(let r=0;r<n;r++)e=p.get(r,t+1),p.set(r,t+1,p.get(r,t)),p.set(r,t,e);if(u&&t<r-1)for(let n=0;n<r;n++)e=g.get(n,t+1),g.set(n,t+1,g.get(n,t)),g.set(n,t,e);t++}N=0,b--}}if(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=ae.zeros(n,n);for(let t=0;t<n;t++)Math.abs(this.s[t])<=r?o.set(t,t,0):o.set(t,t,1/this.s[t]);let i=this.U,s=this.rightSingularVectors,a=s.mmul(o),u=s.rows,h=i.rows,l=ae.zeros(u,h);for(let t=0;t<u;t++)for(let e=0;e<h;e++){let r=0;for(let o=0;o<n;o++)r+=a.get(t,o)*i.get(e,o);l.set(t,e,r)}return l.mmul(e)}solveForDiagonal(t){return this.solve(ae.diag(t))}inverse(){let t=this.V,e=this.threshold,r=t.rows,n=t.columns,o=new ae(r,this.s.length);for(let i=0;i<r;i++)for(let r=0;r<n;r++)Math.abs(this.s[r])>e&&o.set(i,r,t.get(i,r)/this.s[r]);let i=this.U,s=i.rows,a=i.columns,u=new ae(r,s);for(let t=0;t<r;t++)for(let e=0;e<s;e++){let r=0;for(let n=0;n<a;n++)r+=o.get(t,n)*i.get(e,n);u.set(t,e,r)}return u}get condition(){return this.s[0]/this.s[Math.min(this.m,this.n)-1]}get norm2(){return this.s[0]}get rank(){let t=Math.max(this.m,this.n)*this.s[0]*Number.EPSILON,e=0,r=this.s;for(let n=0,o=r.length;n<o;n++)r[n]>t&&e++;return e}get diagonal(){return Array.from(this.s)}get threshold(){return Number.EPSILON/2*Math.max(this.m,this.n)*this.s[0]}get leftSingularVectors(){return this.U}get rightSingularVectors(){return this.V}get diagonalMatrix(){return ae.diag(this.s)}}var ce={center:[0,0],linkDistance:50},fe=function(){function t(t){void 0===t&&(t={}),this.options=t,this.id="mds",this.options=r(r({},ce),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,u=void 0===a?50:a,h=o.layoutInvisibles,l=o.onLayoutEnd,d=e.getAllNodes(),g=e.getAllEdges();if(h||(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}))),!d||0===d.length){var p={nodes:[],edges:g};return null==l||l(p),p}if(1===d.length){t&&e.mergeNodeData(d[0].id,{x:s[0],y:s[1]});var w={nodes:[r(r({},d[0]),{data:r(r({},d[0].data),{x:s[0],y:s[1]})})],edges:g};return null==l||l(w),w}var y=f({nodes:d,edges:g},!1),v=c(y);de(v);var x=function(t,e){var r=[];return t.forEach((function(t){var n=[];t.forEach((function(t){n.push(t*e)})),r.push(n)})),r}(v,u),M=ge(x),b=[];M.forEach((function(t,e){var r=m(d[e]);r.data.x=t[0]+s[0],r.data.y=t[1]+s[1],b.push(r)})),t&&b.forEach((function(t){return e.mergeNodeData(t.id,{x:t.data.x,y:t.data.y})}));var E={nodes:b,edges:g};return null==l||l(E),E},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)}))}))},ge=function(t){var e=ae.mul(ae.pow(t,2),-.5),r=e.mean("row"),n=e.mean("column"),o=e.mean();e.add(o).subRowVector(r).subColumnVector(n);var i=new le(e),s=ae.sqrt(i.diagonalMatrix).diagonal();return i.leftSingularVectors.toJSON().map((function(t){return ae.mul([t],[s]).toJSON()[0].splice(0,2)}))},pe={iterations:10,height:10,width:10,speed:100,gravity:10,k:5},me=function(t,e,r,n,o,i){e.forEach((function(s,a){r[a]={x:0,y:0},e.forEach((function(e,u){if(a!==u&&o[a]===o[u]){var h=s.x-e.x,l=s.y-e.y,c=Math.sqrt(h*h+l*l);if(0===c){c=1;var f=a>u?1:-1;h=.01*f,l=.01*f}if(c<i(t[a])/2+i(t[u])/2){var d=n*n/c;r[a].x+=h/c*d,r[a].y+=l/c*d}}}))}))},we=function(t,e,r,n,o,i,s,a){var u=i||s/10;return n&&e.forEach((function(e,r){var n=t[r].x-t[o].x,i=t[r].y-t[o].y,s=Math.sqrt(n*n+i*i),a=i/s,u=-n/s,h=Math.sqrt(e.x*e.x+e.y*e.y),l=Math.acos((a*e.x+u*e.y)/h);l>Math.PI/2&&(l-=Math.PI/2,a*=-1,u*=-1);var c=Math.cos(l)*h;e.x=a*c,e.y=u*c})),t.forEach((function(i,s){if(s!==o){var h=Math.sqrt(e[s].x*e[s].x+e[s].y*e[s].y);if(h>0&&s!==o){var l=Math.min(u*(r/800),h);if(i.x+=e[s].x/h*l,i.y+=e[s].y/h*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},ye={maxIteration:1e3,focusNode:null,unitRadius:null,linkDistance:50,preventOverlap:!1,strictRadial:!0,maxPreventOverlapIteration:200,sortStrength:10},ve=function(){function t(t){void 0===t&&(t={}),this.options=t,this.id="radial",this.options=r(r({},ye),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),u=s.width,h=s.height,l=s.center,d=s.focusNode,g=s.unitRadius,p=s.nodeSize,w=s.nodeSpacing,y=s.strictRadial,v=s.preventOverlap,x=s.maxPreventOverlapIteration,M=s.sortBy,b=s.linkDistance,E=void 0===b?50:b,N=s.sortStrength,S=void 0===N?10:N,k=s.maxIteration,A=void 0===k?1e3:k,D=s.layoutInvisibles,I=s.onLayoutEnd,R=e.getAllNodes(),_=e.getAllEdges();if(D||(R=R.filter((function(t){var e=(t.data||{}).visible;return e||void 0===e})),_=_.filter((function(t){var e=(t.data||{}).visible;return e||void 0===e}))),!R||0===R.length){var z={nodes:[],edges:_};return null==I||I(z),z}var T=u||"undefined"==typeof window?u:window.innerWidth,P=h||"undefined"==typeof window?h:window.innerHeight,C=l||[T/2,P/2];if(1===R.length){t&&e.mergeNodeData(R[0].id,{x:C[0],y:C[1]});var O={nodes:[r(r({},R[0]),{data:r(r({},R[0].data),{x:C[0],y:C[1]})})],edges:_};return null==I||I(O),O}var j=R[0];if(a(d)){for(var q=0;q<R.length;q++)if(R[q].id===d){j=R[q];break}}else j=d||R[0];var V=be(R,j.id),L=f({nodes:R,edges:_},!1),F=c(L),$=Ne(F,V);Ee(F,V,$+1);var U=F[V],B=T-C[0]>C[0]?C[0]:T-C[0],K=P-C[1]>C[1]?C[1]:P-C[1];0===B&&(B=T/2),0===K&&(K=P/2);var G=Math.min(B,K),W=Math.max.apply(Math,i([],o(U),!1)),J=[],H=g||G/W;U.forEach((function(t,e){J[e]=t*H}));var Y,X=xe(R,F,E,J,H,M,S),Q=Me(X),Z=function(t,e,r){try{var n=ae.mul(ae.pow(e,2),-.5),o=n.mean("row"),i=n.mean("column"),s=n.mean();n.add(s).subRowVector(o).subColumnVector(i);var a=new le(n),u=ae.sqrt(a.diagonalMatrix).diagonal();return a.leftSingularVectors.toJSON().map((function(e){return ae.mul([e],[u]).toJSON()[0].splice(0,t)}))}catch(t){for(var h=[],l=0;l<e.length;l++){var c=Math.random()*r,f=Math.random()*r;h.push([c,f])}return h}}(E,X,E),tt=Z.map((function(t){var e=o(t,2),r=e[0],n=e[1];return{x:(isNaN(r)?Math.random()*E:r)-Z[V][0],y:(isNaN(n)?Math.random()*E:n)-Z[V][1]}}));if(this.run(A,tt,Q,X,J,V),v){Y=Se(p,w);var et={nodes:R,nodeSizeFunc:Y,positions:tt,radii:J,height:P,width:T,strictRadial:Boolean(y),focusIdx:V,iterations:x||200,k:tt.length/4.5};tt=function(t,e){for(var n=r(r({},pe),e),o=n.positions,i=n.iterations,s=n.width,a=n.k,u=n.speed,h=void 0===u?100:u,l=n.strictRadial,c=n.focusIdx,f=n.radii,d=void 0===f?[]:f,g=n.nodeSizeFunc,p=t.getAllNodes(),m=[],w=s/10,y=0;y<i;y++)o.forEach((function(t,e){m[e]={x:0,y:0}})),me(p,o,m,a,d,g),we(o,m,h,l,c,w,s,d);return o}(e,et)}var rt=[];tt.forEach((function(t,e){var r=m(R[e]);r.data.x=t.x+C[0],r.data.y=t.y+C[1],rt.push(r)})),t&&rt.forEach((function(t){return e.mergeNodeData(t.id,{x:t.data.x,y:t.data.y})}));var nt={nodes:rt,edges:_};return null==I||I(nt),nt},t.prototype.run=function(t,e,r,n,o,i){for(var s=0;s<=t;s++){var a=s/t;this.oneIteration(a,e,o,n,r,i)}},t.prototype.oneIteration=function(t,e,r,n,o,i){var s=1-t;e.forEach((function(a,u){var h=d(a,{x:0,y:0}),l=0===h?0:1/h;if(u!==i){var c=0,f=0,g=0;e.forEach((function(t,e){if(u!==e){var r=d(a,t),i=0===r?0:1/r,s=n[e][u];g+=o[u][e],c+=o[u][e]*(t.x+s*(a.x-t.x)*i),f+=o[u][e]*(t.y+s*(a.y-t.y)*i)}}));var p=0===r[u]?0:1/r[u];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}(),xe=function(t,e,r,n,o,i,s){if(!t)return[];var u=[];if(e){var h={};e.forEach((function(e,l){var c=[];e.forEach((function(e,u){var f,d;if(l===u)c.push(0);else if(n[l]===n[u])if("data"===i)c.push(e*(Math.abs(l-u)*s)/(n[l]/o));else if(i){var g=void 0,p=void 0;if(h[t[l].id])g=h[t[l].id];else{var m=("id"===i?t[l].id:null===(f=t[l].data)||void 0===f?void 0:f[i])||0;g=a(m)?m.charCodeAt(0):m,h[t[l].id]=g}h[t[u].id]?p=h[t[u].id]:(m=("id"===i?t[u].id:null===(d=t[u].data)||void 0===d?void 0:d[i])||0,p=a(m)?m.charCodeAt(0):m,h[t[u].id]=p),c.push(e*(Math.abs(g-p)*s)/(n[l]/o))}else c.push(e*r/(n[l]/o));else{var w=(r+o)/2;c.push(e*w)}})),u.push(c)}))}return u},Me=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},be=function(t,e){var r=-1;return t.forEach((function(t,n){t.id===e&&(r=n)})),Math.max(r,0)},Ee=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}},Ne=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},Se=function(t,e){var r;return r=l(e)?function(){return e}:w(e)?e:function(){return 0},t?h(t)?function(e){return(t[0]>t[1]?t[0]:t[1])+r(e)}:function(e){return t+r(e)}:function(t){return t.data.bboxSize?Math.max(t.data.bboxSize[0],t.data.bboxSize[1])+r(t):t.data.size?h(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)}},ke={center:[0,0],width:300,height:300},Ae={circular:M,concentric:S,mds:fe,random:function(){function t(t){void 0===t&&(t={}),this.options=t,this.id="random",this.options=r(r({},ke),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,u=o.layoutInvisibles,h=o.onLayoutEnd,l=e.getAllNodes();u||(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==h||h(p),p},t}(),grid:Pt,radial:ve,force:At,d3force:bt};function De(t,e){return r=this,n=void 0,i=function(){var r,n,o,i,a,u,h,l,c;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(u){return function(a){if(r)throw new TypeError("Generator is already executing.");for(;i&&(i=0,a[0]&&(s=0)),s;)try{if(r=1,n&&(o=2&a[0]?n.return:a[0]?n.throw||((o=n.return)&&o.call(n),0):n.next)&&!(o=o.call(n,a[1])).done)return o;switch(n=0,o&&(a=[2&a[0],o.value]),a[0]){case 0:case 1:o=a;break;case 4:return s.label++,{value:a[1],done:!1};case 5:s.label++,n=a[1],a=[0];continue;case 7:a=s.ops.pop(),s.trys.pop();continue;default:if(!((o=(o=s.trys).length>0&&o[o.length-1])||6!==a[0]&&2!==a[0])){s=0;continue}if(3===a[0]&&(!o||a[1]>o[0]&&a[1]<o[3])){s.label=a[1];break}if(6===a[0]&&s.label<o[1]){s.label=o[1],o=a;break}if(o&&s.label<o[2]){s.label=o[2],s.ops.push(a);break}o[2]&&s.ops.pop(),s.trys.pop();continue}a=e.call(t,s)}catch(t){a=[6,t],n=0}finally{r=o=0}if(5&a[0])throw a[1];return{value:a[0]?a[1]:void 0,done:!0}}([a,u])}}}(this,(function(f){if(r=t.layout,n=r.id,o=r.options,i=t.nodes,a=t.edges,u=new s({nodes:i,edges:a}),!(c=Ae[n]))throw new Error("Unknown layout id: ".concat(n));return h=new c(o),[2,new Promise((function(t){l=h.execute(u,{onLayoutEnd:function(){t([l,e])}})}))]}))},new((o=void 0)||(o=Promise))((function(t,e){function s(t){try{u(i.next(t))}catch(t){e(t)}}function a(t){try{u(i.throw(t))}catch(t){e(t)}}function u(e){var r;e.done?t(e.value):(r=e.value,r instanceof o?r:new o((function(t){t(r)}))).then(s,a)}u((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=8d3d71d9cadd55fe4e07.worker.js.map'])),{name:"[fullhash].worker.js"});return URL.revokeObjectURL(URL.createObjectURL(new Blob(['(()=>{"use strict";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:()=>De});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},u=/-(\\w)/g,h=(function(t){return t.replace(u,(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&&Object.keys(t).length){var n=r({},t);return Object.keys(n).forEach((function(t){n[t]=p(n[t])})),n}return t},m=function(t){var e=p(t);return e.data=e.data||{},e},w=function(t){return"function"==typeof t};function y(t,e){return w(e)?e:l(e)?function(){return e}:function(){return t}}function v(t,e,r){return void 0===r&&(r=!0),e||0===e?w(e)?e:l(e)?function(){return e}:h(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?h(r)?r[0]>r[1]?r[0]:r[1]:g(r)?r.width>r.height?r.width:r.height:r:t}}var x={radius:null,startRadius:null,endRadius:null,startAngle:0,endAngle:2*Math.PI,clockwise:!0,divisions:1,ordering:null,angleRatio:1},M=function(){function t(t){void 0===t&&(t={}),this.options=t,this.id="circular",this.options=r(r({},x),t)}return t.prototype.execute=function(t,e){return this.genericCircularLayout(!1,t,e)},t.prototype.assign=function(t,e){var r=this;t.batch((function(){r.genericCircularLayout(!0,t,e)}))},t.prototype.genericCircularLayout=function(t,e,n){var i=r(r({},this.options),n),s=i.width,a=i.height,u=i.center,h=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,w=i.clockwise,x=i.nodeSpacing,M=i.nodeSize,N=i.layoutInvisibles,S=i.onLayoutEnd,k=e.getAllNodes(),A=e.getAllEdges();N||(k=k.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=k.length;if(0===D)return null==S||S({nodes:[],edges:[]}),{nodes:[],edges:[]};var I=o(E(s,a,u),3),R=I[0],_=I[1],z=I[2];if(1===D){t&&e.mergeNodeData(k[0].id,{x:z[0],y:z[1]});var T={nodes:[r(r({},k[0]),{data:r(r({},k[0].data),{x:z[0],y:z[1]})})],edges:A};return null==S||S(T),T}var P=(d-c)/D,C=i.radius,O=i.startRadius,j=i.endRadius;if(x){var q=y(10,x),V=v(10,M),L=-1/0;k.forEach((function(t){var e=V(t);L<e&&(L=e)}));var F=0;k.forEach((function(t,e){F+=0===e?L||10:(q(t)||0)+(L||10)})),C=F/(2*Math.PI)}else C||O||j?!O&&j?O=j:O&&!j&&(j=O):C=Math.min(_,R)/2;var $=P*g,U=[];U="topology"===p?b(e,k):"topology-directed"===p?b(e,k,!0):"degree"===p?function(t,e){var r=[];return e.forEach((function(t,e){r.push(m(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 m(t)}));for(var B=Math.ceil(D/h),K=0;K<D;++K){var G=C;G||null===O||null===j||(G=O+K*(j-O)/(D-1)),G||(G=10+100*K/(D-1));var W=c+K%B*$+2*Math.PI/h*Math.floor(K/B);w||(W=d-K%B*$-2*Math.PI/h*Math.floor(K/B)),U[K].data.x=z[0]+Math.cos(W)*G,U[K].data.y=z[1]+Math.sin(W)*G}t&&U.forEach((function(t){e.mergeNodeData(t.id,{x:t.data.x,y:t.data.y})}));var J={nodes:U,edges:A};return null==S||S(J),J},t}(),b=function(t,e,r){void 0===r&&(r=!1);var n=[m(e[0])],o={},i=e.length;o[e[0].id]=!0;var s=0;return e.forEach((function(a,u){if(0!==u)if(u!==i-1&&t.getDegree(a.id,"both")===t.getDegree(e[u+1].id,"both")&&!t.areNeighbors(n[s].id,a.id)||o[a.id]){for(var h=r?t.getSuccessors(n[s].id):t.getNeighbors(n[s].id),l=!1,c=0;c<h.length;c++){var f=h[c];if(t.getDegree(f.id)===t.getDegree(a.id)&&!o[f.id]){n.push(m(f)),o[f.id]=!0,l=!0;break}}for(var d=0;!l&&(o[e[d].id]||(n.push(m(e[d])),o[e[d].id]=!0,l=!0),++d!==i););}else n.push(m(a)),o[a.id]=!0,s++})),n},E=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]},N={nodeSize:30,minNodeSpacing:10,nodeSpacing:10,preventOverlap:!1,sweep:void 0,equidistant:!1,startAngle:1.5*Math.PI,clockwise:!0,maxLevelDiff:void 0,sortBy:"degree"},S=function(){function t(t){void 0===t&&(t={}),this.options=t,this.id="concentric",this.options=r(r({},N),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,u=o.height,c=o.sortBy,f=o.maxLevelDiff,d=o.sweep,p=o.clockwise,y=o.equidistant,v=o.minNodeSpacing,x=void 0===v?10:v,M=o.preventOverlap,b=o.startAngle,E=void 0===b?1.5*Math.PI:b,N=o.nodeSize,S=o.nodeSpacing,k=o.layoutInvisibles,A=o.onLayoutEnd,D=e.getAllNodes(),I=e.getAllEdges();k||(D=D.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 R=D.length;if(0===R){var _={nodes:[],edges:I};return null==A||A(_),_}var z=s||"undefined"==typeof window?s:window.innerWidth,T=u||"undefined"==typeof window?u:window.innerHeight,P=i||[z/2,T/2];if(1===R){t&&e.mergeNodeData(D[0].id,{x:P[0],y:P[1]});var C={nodes:[r(r({},D[0]),{data:r(r({},D[0].data),{x:P[0],y:P[1]})})],edges:I};return null==A||A(C),C}var O,j=[],q=0;O=h(N)?Math.max(N[0],N[1]):N,h(S)?q=Math.max(S[0],S[1]):l(S)&&(q=S),D.forEach((function(t){var e=m(t);j.push(e);var r=O,n=e.data;h(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)),O=Math.max(O,r),w(S)&&(q=Math.max(S(t),q))}));var V={};j.forEach((function(t,e){V[t.id]=e}));var L=c;a(L)&&void 0!==j[0].data[L]||(L="degree"),"degree"===L?j.sort((function(t,r){return e.getDegree(r.id,"both")-e.getDegree(t.id,"both")})):j.sort((function(t,e){return e.data[L]-t.data[L]}));var F=j[0],$=(f||("degree"===L?e.getDegree(F.id,"both"):F.data[L]))/4,U=[{nodes:[]}],B=U[0];j.forEach((function(t){if(B.nodes.length>0){var r="degree"===L?Math.abs(e.getDegree(B.nodes[0].id,"both")-e.getDegree(t.id,"both")):Math.abs(B.nodes[0].data[L]-t.data[L]);$&&r>=$&&(B={nodes:[]},U.push(B))}B.nodes.push(t)}));var K=O+(q||x);if(!M){var G=U.length>0&&U[0].nodes.length>1,W=(Math.min(z,T)/2-K)/(U.length+(G?1:0));K=Math.min(K,W)}var J=0;if(U.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&&M){var r=Math.cos(t.dTheta)-Math.cos(0),n=Math.sin(t.dTheta)-Math.sin(0),o=Math.sqrt(K*K/(r*r+n*n));J=Math.max(o,J)}t.r=J,J+=K})),y){for(var H=0,Y=0,X=0;X<U.length;X++){var Q=(U[X].r||0)-Y;H=Math.max(H,Q)}Y=0,U.forEach((function(t,e){0===e&&(Y=t.r||0),t.r=Y,Y+=H}))}U.forEach((function(t){var e=t.dTheta||0,r=t.r||0;t.nodes.forEach((function(t,n){var o=E+(p?1:-1)*e*n;t.data.x=P[0]+r*Math.cos(o),t.data.y=P[1]+r*Math.sin(o)}))})),t&&j.forEach((function(t){return e.mergeNodeData(t.id,{x:t.data.x,y:t.data.y})}));var Z={nodes:j,edges:I};return null==A||A(Z),Z},t}();function k(t,e,r,n){if(isNaN(e)||isNaN(r))return t;var o,i,s,a,u,h,l,c,f,d=t._root,g={data:n},p=t._x0,m=t._y0,w=t._x1,y=t._y1;if(!d)return t._root=g,t;for(;d.length;)if((h=e>=(i=(p+w)/2))?p=i:w=i,(l=r>=(s=(m+y)/2))?m=s:y=s,o=d,!(d=d[c=l<<1|h]))return o[c]=g,t;if(a=+t._x.call(null,d.data),u=+t._y.call(null,d.data),e===a&&r===u)return g.next=d,o?o[c]=g:t._root=g,t;do{o=o?o[c]=new Array(4):t._root=new Array(4),(h=e>=(i=(p+w)/2))?p=i:w=i,(l=r>=(s=(m+y)/2))?m=s:y=s}while((c=l<<1|h)==(f=(u>=s)<<1|a>=i));return o[f]=d,o[c]=g,t}function A(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 I(t){return t[1]}function R(t,e,r){var n=new _(null==e?D:e,null==r?I:r,NaN,NaN,NaN,NaN);return null==t?n:n.addAll(t)}function _(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 z(t){for(var e={data:t.data},r=e;t=t.next;)r=r.next={data:t.data};return e}var T=R.prototype=_.prototype;function P(t){return function(){return t}}function C(t){return 1e-6*(t()-.5)}T.copy=function(){var t,e,r=new _(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=z(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]=z(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),u=1/0,h=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<u&&(u=n),n>l&&(l=n),o<h&&(h=o),o>c&&(c=o));if(u>l||h>c)return this;for(this.cover(u,h).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,u=o-r||1,h=this._root;r>t||t>=o||n>e||e>=i;)switch(a=(e<n)<<1|t<r,(s=new Array(4))[a]=h,h=s,u*=2,a){case 0:o=r+u,i=n+u;break;case 1:r=o-u,i=n+u;break;case 2:o=r+u,n=i-u;break;case 3:r=o-u,n=i-u}this._root&&this._root.length&&(this._root=h)}return this._x0=r,this._y0=n,this._x1=o,this._y1=i,this},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,u,h,l=this._x0,c=this._y0,f=this._x1,d=this._y1,g=[],p=this._root;for(p&&g.push(new A(p,l,c,f,d)),null==r?r=1/0:(l=t-r,c=e-r,f=t+r,d=e+r,r*=r);u=g.pop();)if(!(!(p=u.node)||(o=u.x0)>f||(i=u.y0)>d||(s=u.x1)<l||(a=u.y1)<c))if(p.length){var m=(o+s)/2,w=(i+a)/2;g.push(new A(p[3],m,w,s,a),new A(p[2],o,w,m,a),new A(p[1],m,i,s,w),new A(p[0],o,i,m,w)),(h=(e>=w)<<1|t>=m)&&(u=g[g.length-1],g[g.length-1]=g[g.length-1-h],g[g.length-1-h]=u)}else{var y=t-+this._x.call(null,p.data),v=e-+this._y.call(null,p.data),x=y*y+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,u,h,l,c,f,d=this._root,g=this._x0,p=this._y0,m=this._x1,w=this._y1;if(!d)return this;if(d.length)for(;;){if((h=i>=(a=(g+m)/2))?g=a:m=a,(l=s>=(u=(p+w)/2))?p=u:w=u,e=d,!(d=d[c=l<<1|h]))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=[],u=this._root;for(u&&a.push(new A(u,this._x0,this._y0,this._x1,this._y1));e=a.pop();)if(!t(u=e.node,n=e.x0,o=e.y0,i=e.x1,s=e.y1)&&u.length){var h=(n+i)/2,l=(o+s)/2;(r=u[3])&&a.push(new A(r,h,l,i,s)),(r=u[2])&&a.push(new A(r,n,l,h,s)),(r=u[1])&&a.push(new A(r,h,o,i,l)),(r=u[0])&&a.push(new A(r,n,o,h,l))}return this},T.visitAfter=function(t){var e,r=[],n=[];for(this._root&&r.push(new A(this._root,this._x0,this._y0,this._x1,this._y1));e=r.pop();){var o=e.node;if(o.length){var i,s=e.x0,a=e.y0,u=e.x1,h=e.y1,l=(s+u)/2,c=(a+h)/2;(i=o[0])&&r.push(new A(i,s,a,l,c)),(i=o[1])&&r.push(new A(i,l,a,u,c)),(i=o[2])&&r.push(new A(i,s,c,l,h)),(i=o[3])&&r.push(new A(i,l,c,u,h))}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 O={value:()=>{}};function j(){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 q(n)}function q(t){this._=t}function V(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 L(t,e){for(var r,n=0,o=t.length;n<o;++n)if((r=t[n]).name===e)return r.value}function F(t,e,r){for(var n=0,o=t.length;n<o;++n)if(t[n].name===e){t[n]=O,t=t.slice(0,n).concat(t.slice(n+1));break}return null!=r&&t.push({name:e,value:r}),t}q.prototype=j.prototype={constructor:q,on:function(t,e){var r,n=this._,o=V(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]=F(n[r],t.name,e);else if(null==e)for(r in n)n[r]=F(n[r],t.name,null);return this}for(;++i<s;)if((r=(t=o[i]).type)&&(r=L(n[r],t.name)))return r},copy:function(){var t={},e=this._;for(var r in e)t[r]=e[r].slice();return new q(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;var U,B,K=0,G=0,W=0,J=0,H=0,Y=0,X="object"==typeof performance&&performance.now?performance:Date,Q="object"==typeof window&&window.requestAnimationFrame?window.requestAnimationFrame.bind(window):function(t){setTimeout(t,17)};function Z(){return H||(Q(tt),H=X.now()+Y)}function tt(){H=0}function et(){this._call=this._time=this._next=null}function rt(t,e,r){var n=new et;return n.restart(t,e,r),n}function nt(){H=(J=X.now())+Y,K=G=0;try{!function(){Z(),++K;for(var t,e=U;e;)(t=H-e._time)>=0&&e._call.call(void 0,t),e=e._next;--K}()}finally{K=0,function(){for(var t,e,r=U,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:U=e);B=t,it(n)}(),H=0}}function ot(){var t=X.now(),e=t-J;e>1e3&&(Y-=e,J=t)}function it(t){K||(G&&(G=clearTimeout(G)),t-H>24?(t<1/0&&(G=setTimeout(nt,t-X.now()-Y)),W&&(W=clearInterval(W))):(W||(J=X.now(),W=setInterval(ot,1e3)),K=1,Q(nt)))}et.prototype=rt.prototype={constructor:et,restart:function(t,e,r){if("function"!=typeof t)throw new TypeError("callback is not a function");r=(null==r?Z():+r)+(null==e?0:+e),this._next||B===this||(B?B._next=this:U=this,B=this),this._call=t,this._time=r,it()},stop:function(){this._call&&(this._call=null,this._time=1/0,it())}};const st=4294967296;function at(t){return t.x}function ut(t){return t.y}var ht=Math.PI*(3-Math.sqrt(5));function lt(t){var e,r=1,n=.001,o=1-Math.pow(n,1/300),i=0,s=.6,a=new Map,u=rt(c),h=$("tick","end"),l=function(){let t=1;return()=>(t=(1664525*t+1013904223)%st)/st}();function c(){f(),h.call("tick",e),r<n&&(u.stop(),h.call("end",e))}function f(n){var u,h,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)})),u=0;u<l;++u)null==(h=t[u]).fx?h.x+=h.vx*=s:(h.x=h.fx,h.vx=0),null==h.fy?h.y+=h.vy*=s:(h.y=h.fy,h.vy=0);return e}function d(){for(var e,r=0,n=t.length;r<n;++r){if((e=t[r]).index=r,null!=e.fx&&(e.x=e.fx),null!=e.fy&&(e.y=e.fy),isNaN(e.x)||isNaN(e.y)){var o=10*Math.sqrt(.5+r),i=r*ht;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 u.restart(c),e},stop:function(){return u.stop(),e},nodes:function(r){return arguments.length?(t=r,d(),a.forEach(g),e):t},alpha:function(t){return arguments.length?(r=+t,e):r},alphaMin:function(t){return arguments.length?(n=+t,e):n},alphaDecay:function(t){return arguments.length?(o=+t,e):+o},alphaTarget:function(t){return arguments.length?(i=+t,e):i},velocityDecay:function(t){return arguments.length?(s=1-t,e):1-s},randomSource:function(t){return arguments.length?(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,u,h=0,l=t.length;for(null==n?n=1/0:n*=n,h=0;h<l;++h)(s=(o=e-(a=t[h]).x)*o+(i=r-a.y)*i)<n&&(u=a,n=s);return u},on:function(t,r){return arguments.length>1?(h.on(t,r),e):h.on(t)}}}function ct(){var t,e,r,n,o,i=P(-30),s=1,a=1/0,u=.81;function h(r){var o,i=t.length,s=R(t,at,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,u=0;if(t.length){for(n=i=s=0;s<4;++s)(e=t[s])&&(r=Math.abs(e.value))&&(a+=e.value,u+=r,n+=r*e.x,i+=r*e.y);t.x=n/u,t.y=i/u}else{(e=t).x=e.data.x,e.y=e.data.y;do{a+=o[e.data.index]}while(e=e.next)}t.value=a}function f(t,i,h,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/u<g)return g<a&&(0===c&&(g+=(c=C(r))*c),0===f&&(g+=(f=C(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=C(r))*c),0===f&&(g+=(f=C(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 h.initialize=function(e,n){t=e,r=n,l()},h.strength=function(t){return arguments.length?(i="function"==typeof t?t:P(+t),l(),h):i},h.distanceMin=function(t){return arguments.length?(s=t*t,h):Math.sqrt(s)},h.distanceMax=function(t){return arguments.length?(a=t*t,h):Math.sqrt(a)},h.theta=function(t){return arguments.length?(u=t*t,h):Math.sqrt(u)},h}function ft(t){return t.index}function dt(t,e){var r=t.get(e);if(!r)throw new Error("node not found: "+e);return r}function gt(t){var e,r,n,o,i,s,a=ft,u=function(t){return 1/Math.min(o[t.source.index],o[t.target.index])},h=P(30),l=1;function c(n){for(var o=0,a=t.length;o<l;++o)for(var u,h,c,f,d,g,p,m=0;m<a;++m)h=(u=t[m]).source,f=(c=u.target).x+c.vx-h.x-h.vx||C(s),d=c.y+c.vy-h.y-h.vy||C(s),f*=g=((g=Math.sqrt(f*f+d*d))-r[m])/g*n*e[m],d*=g,c.vx-=f*(p=i[m]),c.vy-=d*p,h.vx+=f*(p=1-p),h.vy+=d*p}function f(){if(n){var s,u,h=n.length,l=t.length,c=new Map(n.map(((t,e)=>[a(t,e,n),t])));for(s=0,o=new Array(h);s<l;++s)(u=t[s]).index=s,"object"!=typeof u.source&&(u.source=dt(c,u.source)),"object"!=typeof u.target&&(u.target=dt(c,u.target)),o[u.source.index]=(o[u.source.index]||0)+1,o[u.target.index]=(o[u.target.index]||0)+1;for(s=0,i=new Array(l);s<l;++s)u=t[s],i[s]=o[u.source.index]/(o[u.source.index]+o[u.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]=+u(t[r],r,t)}function g(){if(n)for(var e=0,o=t.length;e<o;++e)r[e]=+h(t[e],e,t)}return null==t&&(t=[]),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?(u="function"==typeof t?t:P(+t),d(),c):u},c.distance=function(t){return arguments.length?(h="function"==typeof t?t:P(+t),g(),c):h},c}function pt(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,u,h,l,c,f,d=e.length,g=0;g<i;++g)for(s=R(e,pt,mt).visitAfter(a),t=0;t<d;++t)u=e[t],c=r[u.index],f=c*c,h=u.x+u.vx,l=u.y+u.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>h+g||i<h-g||r>l+g||s<l-g;if(a.index>u.index){var p=h-a.x-a.vx,m=l-a.y-a.vy,w=p*p+m*m;w<g*g&&(0===p&&(w+=(p=C(n))*p),0===m&&(w+=(m=C(n))*m),w=(g-(w=Math.sqrt(w)))/w*o,u.vx+=(p*=w)*(g=(d*=d)/(f+d)),u.vy+=(m*=w)*g,a.vx-=p*(g=1-g),a.vy-=m*g)}}}function a(t){if(t.data)return t.r=r[t.data.index];for(var e=t.r=0;e<4;++e)t[e]&&t[e].r>t.r&&(t.r=t[e].r)}function u(){if(e){var n,o,i=e.length;for(r=new Array(i),n=0;n<i;++n)o=e[n],r[o.index]=+t(o,n,e)}}return"function"!=typeof t&&(t=P(null==t?1:+t)),s.initialize=function(t,r){e=t,n=r,u()},s.iterations=function(t){return arguments.length?(i=+t,s):i},s.strength=function(t){return arguments.length?(o=+t,s):o},s.radius=function(e){return arguments.length?(t="function"==typeof e?e:P(+e),u(),s):t},s}function yt(t){var e,r,n,o=P(.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=P(null==t?0:+t)),i.initialize=function(t){e=t,s()},i.strength=function(t){return arguments.length?(o="function"==typeof t?t:P(+t),s(),i):o},i.x=function(e){return arguments.length?(t="function"==typeof e?e:P(+e),s(),i):t},i}function vt(t){var e,r,n,o=P(.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=P(null==t?0:+t)),i.initialize=function(t){e=t,s()},i.strength=function(t){return arguments.length?(o="function"==typeof t?t:P(+t),s(),i):o},i.y=function(e){return arguments.length?(t="function"==typeof e?e:P(+e),s(),i):t},i}function xt(){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),u=[0,0],h=[],l={},c=[],f=100,d=100,g={none:{x:0,y:0}},p=[],m="force",w=!0,y=.1;function v(t){if(!w)return v;e.tick(),M();for(var n=0,o=h.length,i=void 0,s=t*y;n<o;++n)(i=h[n]).vx+=(g[r(i)].x-i.x)*s,i.vy+=(g[r(i)].y-i.y)*s}function x(){h&&function(){if(h&&h.length){if(void 0===r(h[0]))throw Error("Couldnt find the grouping attribute for the nodes. Make sure to set it up with forceInBox.groupBy(\'clusterAttr\') before calling .links()");var t,u,g,m,w,y=(t=[],u=[],g={},{},w=[],m=function(t){var e={};return t.forEach((function(t){var n=r(t);e[n]||(e[n]={count:0,sumforceNodeSize:0})})),t.forEach((function(t){var o=r(t),i=n(t),s=e[o];s.count=s.count+1,s.sumforceNodeSize=s.sumforceNodeSize+Math.PI*(i*i)*1.3,e[o]=s})),e}(h),w=function(t){var e={},n=[];return t.forEach((function(t){var n,o,i,s,a,u=(o=(n=t).source,i=n.target,(s=r(l[o]))<=(a=r(l[i]))?"".concat(s,"~").concat(a):"".concat(a,"~").concat(s)),h=0;void 0!==e[u]&&(h=e[u]),h+=1,e[u]=h})),Object.entries(e).forEach((function(t){var e=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(m).forEach((function(e,r){var n=m[e];t.push({id:e,size:n.count,r:Math.sqrt(n.sumforceNodeSize/Math.PI)}),g[e]=r})),w.forEach((function(t){var e=t.source,r=t.target,n=g[e],o=g[r];void 0!==n&&void 0!==o&&u.push({source:n,target:o,count:t.count})})),{nodes:t,links:u});e=lt(y.nodes).force("x",yt(f).strength(.1)).force("y",vt(d).strength(.1)).force("collide",wt((function(t){return t.r})).iterations(4)).force("charge",ct().strength(i)).force("links",gt(y.nodes.length?y.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-u[0],y:t.y-u[1]}})),g}function b(t){l={},t.forEach((function(t){l[t.id]=t}))}return v.initialize=function(t){h=t,x()},v.template=function(t){return arguments.length?(m=t,x(),v):m},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?(w=t,v):w},v.strength=function(t){return arguments.length?(y=t,v):y},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||[]),h=t||[],v):h},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?(u=t,v):u},v.getFocis=M,v}var Mt={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},bt=function(){function t(t){void 0===t&&(t={}),this.options=t,this.id="d3force",this.options=r(r({},Mt),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.genericForceLayout=function(t,e,n){var o=this,i=r(r({},this.options),n),s=i.layoutInvisibles,a=e.getAllNodes(),u=e.getAllEdges();s||(a=a.filter((function(t){var e=(t.data||{}).visible;return e||void 0===e})),u=u.filter((function(t){var e=(t.data||{}).visible;return e||void 0===e})));var h=a.map((function(t){var e,n;return r(r({},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})}));if(!this.running){var l=i.alphaMin,c=i.alphaDecay,f=i.alpha,d=i.nodeStrength,g=i.edgeStrength,p=i.linkDistance,m=i.clustering,w=i.clusterFociStrength,y=i.clusterEdgeDistance,v=i.clusterEdgeStrength,x=i.clusterNodeStrength,M=i.clusterNodeSize,b=i.collideStrength,E=void 0===b?1:b,N=i.center,S=void 0===N?[0,0]:N,k=i.preventOverlap,A=i.nodeSize,D=i.nodeSpacing,I=i.onTick,R=i.onLayoutEnd,_=i.forceSimulation;if(_)m&&((z=xt()).nodes(h),z.links(u)),_.nodes(h),u&&(P=gt().id((function(t){return t.id})).links(u),g&&P.strength(g),p&&P.distance(p),_.force("link",P)),k&&this.overlapProcess(_,{nodeSize:A,nodeSpacing:D,collideStrength:E}),_.alpha(f).restart(),this.running=!0;else try{var z,T=ct();if(d&&T.strength(d),_=lt().nodes(h),m&&((z=xt()).centerX(S[0]).centerY(S[1]).template("force").strength(w),u&&z.links(u),h&&z.nodes(h),z.forceLinkDistance(y).forceLinkStrength(v).forceCharge(x).forceNodeSize(M),_.force("group",z)),_.force("center",function(t,e){var r,n=1;function o(){var o,i,s=r.length,a=0,u=0;for(o=0;o<s;++o)a+=(i=r[o]).x,u+=i.y;for(a=(a/s-t)*n,u=(u/s-e)*n,o=0;o<s;++o)(i=r[o]).x-=a,i.y-=u}return null==t&&(t=0),null==e&&(e=0),o.initialize=function(t){r=t},o.x=function(e){return arguments.length?(t=+e,o):t},o.y=function(t){return arguments.length?(e=+t,o):e},o.strength=function(t){return arguments.length?(n=+t,o):n},o}(S[0],S[1])).force("charge",T).alpha(f).alphaDecay(c).alphaMin(l),k&&this.overlapProcess(_,{nodeSize:A,nodeSpacing:D,collideStrength:E}),u){var P=gt().id((function(t){return t.id})).links(u);g&&P.strength(g),p&&P.distance(p),_.force("link",P)}_.on("tick",(function(){null==I||I({nodes:Et(h),edges:Nt(u)})})).on("end",(function(){o.running=!1,null==R||R({nodes:Et(h),edges:Nt(u)})})),this.running=!0}catch(t){this.running=!1,console.warn(t)}var C=Et(h);return t&&C.forEach((function(t){return e.mergeNodeData(t.id,{x:t.data.x,y:t.data.y})})),{nodes:C,edges:u}}},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}:w(i)?i:function(){return 0},o)if(w(o))r=function(t){return o(t)+n(t)};else if(h(o)){var a=(o[0]>o[1]?o[0]:o[1])/2;r=function(t){return a+n(t)}}else if(l(o)){var u=o/2;r=function(t){return u+n(t)}}else r=function(){return 10};else r=function(t){return t.size?h(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}(),Et=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})})}))},Nt=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 St(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,animate:!0,factor:1,edgeStrength:200,nodeStrength:1e3,coulombDisScale:.005,damping:.9,maxSpeed:500,minMovement:.4,interval:.02,linkDistance:200,clusterNodeStrength:20,preventOverlap:!0,distanceThresholdMode:"mean"},At=function(){function t(t){void 0===t&&(t={}),this.options=t,this.id="force",this.timeInterval=0,this.judgingDistance=0,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.genericForceLayout=function(t,e,n){var o=this,i=r(r({},this.options),n),a=e.getAllNodes(),u=e.getAllEdges();i.layoutInvisibles||(a=a.filter((function(t){return t.data.visible||void 0===t.data.visible})),u=u.filter((function(t){return t.data.visible||void 0===t.data.visible})));var h=this.formatOptions(i,e),c=h.width,f=h.height,d=h.nodeSize,g=h.getMass,p=h.nodeStrength,m=h.edgeStrength,w=h.linkDistance,y=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=u.map((function(t){return r(r({},t),{data:r(r({},t.data),{edgeStrength:m(t),linkDistance:w(t,e.getNode(t.source),e.getNode(t.target))})})}));if(!(null==a?void 0:a.length))return{nodes:[],edges:u};var x={};a.forEach((function(t,e){x[t.id]={x:0,y:0}}));var M=new s({nodes:y,edges:v});this.formatCentripetal(h,M);var b=h.maxIteration,E=h.animate,N=h.minMovement,S=h.onLayoutEnd,k=h.onTick;if(!E){for(var A=0;(this.judgingDistance>N||A<1)&&A<b;A++)this.runOneStep(M,e,A,x,h),this.updatePosition(e,M,x,h),t&&y.forEach((function(t){return e.mergeNodeData(t.id,{x:t.data.x,y:t.data.y})})),null==k||k({nodes:zt(e,y),edges:u});t&&y.forEach((function(t){return e.mergeNodeData(t.id,{x:t.data.x,y:t.data.y})}));var D={nodes:zt(e,y),edges:u};return null==S||S(D),D}if("undefined"!=typeof window){var I=0;return this.timeInterval=window.setInterval((function(){a&&(o.runOneStep(M,e,I,x,h),o.updatePosition(e,M,x,h),t&&y.forEach((function(t){return e.mergeNodeData(t.id,{x:t.data.x,y:t.data.y})})),null==k||k({nodes:zt(e,y),edges:u}),(++I>=b||o.judgingDistance<N)&&(null==S||S({nodes:zt(e,y),edges:u}),window.clearInterval(o.timeInterval)))}),0),{nodes:zt(e,y),edges:u}}},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=y(0,t.nodeSpacing);t.nodeSize?h(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?h(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?y(1,t.linkDistance):function(t){return 1+r.nodeSize(e.getNode(t.source))+r.nodeSize(e.getNode(t.target))},r.nodeStrength=y(1,t.nodeStrength),r.edgeStrength=y(1,t.edgeStrength),t},t.prototype.formatCentripetal=function(t,e){var r,n=t.centripetalOptions,o=t.center,i=t.clusterNodeStrength,s=t.leafCluster,a=t.clustering,u=t.nodeClusterBy,h=e.getAllNodes(),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&&u&&(r=Dt(e,u),c=Array.from(new Set(null==h?void 0:h.map((function(t){return t.data[u]}))))||[],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=_t(s))}else n=void 0;return{x:null==n?void 0:n.x,y:null==n?void 0:n.y}}})),a&&u){r||(r=Dt(e,u)),c||(c=Array.from(new Set(h.map((function(t){return t.data[u]}))))),c=c.filter((function(t){return void 0!==t}));var f={};c.forEach((function(t){var r=h.filter((function(e){return e.data[u]===t})).map((function(t){return e.getNode(t.id)}));f[t]=_t(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[u]];return{x:null==e?void 0:e.x,y:null==e?void 0:e.y}}})}var d=t.centripetalOptions,g=d.leaf,p=d.single,m=d.others;g&&"function"!=typeof g&&(t.centripetalOptions.leaf=function(){return g}),p&&"function"!=typeof p&&(t.centripetalOptions.single=function(){return p}),m&&"function"!=typeof m&&(t.centripetalOptions.others=function(){return m})},t.prototype.runOneStep=function(t,e,r,n,o){var i={},s=t.getAllNodes(),a=t.getAllEdges();if(null==s?void 0:s.length){var u=o.monitor;this.calRepulsive(t,i,o),a&&this.calAttractive(t,i),this.calGravity(t,e,i,o),this.updateVelocity(t,i,n,o),u&&u({energy:this.calTotalEnergy(i,s),nodes:e.getAllNodes(),edges:e.getAllEdges(),iterations:r})}},t.prototype.calTotalEnergy=function(t,e){if(!(null==e?void 0:e.length))return 0;var r=0;return e.forEach((function(e,n){var o=t[e.id].x,i=t[e.id].y,s=o*o+i*i,a=e.data.mass;r+=(void 0===a?1:a)*s*.5})),r},t.prototype.calRepulsive=function(t,e,r){var n=r.factor,o=r.coulombDisScale;!function(t,e,r,n){var o=e/r,i=t.getAllNodes(),s=i.map((function(t,e){var r=t.data,n=r.nodeStrength;return{x:r.x,y:r.y,size:r.size,index:e,vx:0,vy:0,weight:o*n}})),a=R(s,(function(t){return t.x}),(function(t){return t.y})).visitAfter(St);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,u=n-e,h=s*s+a*a,l=Math.sqrt(h)*h;if(u*u*.81<h){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 u=a.data.x-s.data.x,h=a.data.y-s.data.y;u||h||(u=.01*Math.random(),h=.01*Math.random());var l=Math.sqrt(u*u+h*h),c=u/l,f=h/l,d=edgeInfos[n]||{},g=d.linkDistance,p=void 0===g?200:g,m=d.edgeStrength,w=(p-l)*(void 0===m?200:m),y=1/(s.data.mass||1),v=1/(a.data.mass||1),x=c*w,M=f*w;e[o].x-=x*y,e[o].y-=M*y,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(),u=e.getAllEdges(),h=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,m=p.mass,w=p.x,y=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==i?void 0:i(v,S);if(k){var A=o(k,3);x=w-A[0],M=y-A[1],b=A[2]}else x=w-f[0],M=y-f[1];if(b&&(r[s].x-=b*x/m,r[s].y-=b*M/m),g){var D=g.leaf,I=g.single,R=g.others,_=g.center,z=(null==_?void 0:_(v,a,u,h,c))||{x:0,y:0,centerStrength:0},T=z.x,P=z.y,C=z.centerStrength;if(!l(T)||!l(P))return;var O=(w-T)/m,j=(y-P)/m;if(C&&(r[s].x-=C*O,r[s].y-=C*j),0===S){var q=I(v);if(!q)return;return r[s].x-=q*O,void(r[s].y-=q*j)}if(0===E||0===N){var V=D(v,a,u);if(!V)return;return r[s].x-=V*O,void(r[s].y-=V*j)}var L=R(v);if(!L)return;r[s].x-=L*O,r[s].y-=L*j}}))},t.prototype.updateVelocity=function(t,e,r,n){var o=n.damping,i=n.maxSpeed,s=n.interval,a=t.getAllNodes();(null==a?void 0:a.length)&&a.forEach((function(t){var n=t.id,a=(r[n].x+e[n].x*s)*o||.01,u=(r[n].y+e[n].y*s)*o||.01,h=Math.sqrt(a*a+u*u);if(h>i){var l=i/h;a*=l,u*=l}r[n]={x:a,y:u}}))},t.prototype.updatePosition=function(t,e,r,n){var o=this,i=n.distanceThresholdMode,s=n.interval,a=e.getAllNodes();if(null==a?void 0:a.length){var u=0;"max"===i?this.judgingDistance=-1/0:"min"===i&&(this.judgingDistance=1/0),a.forEach((function(n){var a=n.id,h=t.getNode(a);if(l(h.data.fx)&&l(h.data.fy))e.mergeNodeData(a,{x:h.data.fx,y:h.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:u+=d}}})),i&&"mean"!==i||(this.judgingDistance=u/a.length)}else this.judgingDistance=0},t.prototype.stop=function(){this.timeInterval&&"undefined"!=typeof window&&window.clearInterval(this.timeInterval)},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]=It(t,"leaf",r,e))})),n},It=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:Rt(t,e,n,r,a)}},Rt=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},_t=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}},zt=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={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},Pt=function(){function t(t){void 0===t&&(t={}),this.options=t,this.id="grid",this.options=r(r({},Tt),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,u=o.condense,c=o.preventOverlapPadding,f=o.preventOverlap,d=o.rows,g=o.cols,p=o.nodeSpacing,w=o.nodeSize,x=o.width,M=o.height,b=o.layoutInvisibles,E=o.onLayoutEnd,N=o.position,S=o.sortBy,k=e.getAllNodes(),A=e.getAllEdges();b||(k=k.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=k.length;if(0===D){var I={nodes:[],edges:A};return null==E||E(I),I}if(1===D){t&&e.mergeNodeData(k[0].id,{x:s[0],y:s[1]});var R={nodes:[r(r({},k[0]),{data:r(r({},k[0].data),{x:s[0],y:s[1]})})],edges:A};return null==E||E(R),R}var _=k.map((function(t){return m(t)}));"id"===S||a(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 l(e.id)&&l(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 z=x||"undefined"==typeof window?x:window.innerWidth,T=M||"undefined"==typeof window?M:window.innerHeight,P=D,C={rows:d,cols:g};if(null!=d&&null!=g)C.rows=d,C.cols=g;else if(null!=d&&null==g)C.rows=d,C.cols=Math.ceil(P/C.rows);else if(null==d&&null!=g)C.cols=g,C.rows=Math.ceil(P/C.cols);else{var O=Math.sqrt(P*T/z);C.rows=Math.round(O),C.cols=Math.round(z/T*O)}if(C.rows=Math.max(C.rows,1),C.cols=Math.max(C.cols,1),C.cols*C.rows>P)((q=Ct(C))-1)*(j=Ot(C))>=P?Ct(C,q-1):(j-1)*q>=P&&Ot(C,j-1);else for(;C.cols*C.rows<P;){var j,q=Ct(C);((j=Ot(C))+1)*q>=P?Ot(C,j+1):Ct(C,q+1)}var V=u?0:z/C.cols,L=u?0:T/C.rows;if(f||p){var F=y(10,p),$=v(30,w,!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=$(o)||30;h(i)?(r=i[0],n=i[1]):(r=i,n=i);var s=void 0!==F?F(t):c,a=r+s,u=n+s;V=Math.max(V,a),L=Math.max(L,u)}))}for(var U={},B={row:0,col:0},K={},G=0;G<_.length;G++){var W=_[G],J=void 0;if(N&&(J=N(e.getNode(W.id))),J&&(void 0!==J.row||void 0!==J.col)){var H={row:J.row,col:J.col};if(void 0===H.col)for(H.col=0;jt(U,H);)H.col++;else if(void 0===H.row)for(H.row=0;jt(U,H);)H.row++;K[W.id]=H,qt(U,H)}Lt(W,s,V,L,K,C,B,U)}var Y={nodes:_,edges:A};return null==E||E(Y),t&&_.forEach((function(t){e.mergeNodeData(t.id,{x:t.data.x,y:t.data.y})})),Y},t}(),Ct=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},Ot=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},jt=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},Vt=function(t,e){var r=t.cols||5;e.col++,e.col>=r&&(e.col=0,e.row++)},Lt=function(t,e,r,n,o,i,s,a){var u,h,l=o[t.id];if(l)u=l.col*r+r/2+e[0],h=l.row*n+n/2+e[1];else{for(;jt(a,s);)Vt(i,s);u=s.col*r+r/2+e[0],h=s.row*n+n/2+e[1],qt(a,s),Vt(i,s)}t.data.x=u,t.data.y=h};const Ft=Object.prototype.toString;function $t(t){return Ft.call(t).endsWith("Array]")}function Ut(t){var e=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};if(!$t(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 Bt(t){var e=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};if(!$t(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 Kt(t){var e,r=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};if(!$t(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(!$t(r.output))throw new TypeError("output option must be an array if specified");e=r.output}else e=new Array(t.length);var n=Bt(t),o=Ut(t);if(n===o)throw new RangeError("minimum and maximum input values are equal. Cannot rescale a constant array");var i=r.min,s=void 0===i?r.autoMinMax?n:0:i,a=r.max,u=void 0===a?r.autoMinMax?o:1:a;if(s>=u)throw new RangeError("min option must be smaller than max option");for(var h=(u-s)/(o-n),l=0;l<t.length;l++)e[l]=(t[l]-n)*h+s;return e}const Gt=" ".repeat(2),Wt=" ".repeat(4);function Jt(t,e={}){const{maxRows:r=15,maxColumns:n=10,maxNumSize:o=8,padMinus:i="auto"}=e;return`${t.constructor.name} {\\n${Gt}[\\n${Wt}${function(t,e,r,n,o){const{rows:i,columns:s}=t,a=Math.min(i,e),u=Math.min(s,r),h=[];if("auto"===o){o=!1;t:for(let e=0;e<a;e++)for(let r=0;r<u;r++)if(t.get(e,r)<0){o=!0;break t}}for(let e=0;e<a;e++){let r=[];for(let i=0;i<u;i++)r.push(Ht(t.get(e,i),n,o));h.push(`${r.join(" ")}`)}return u!==s&&(h[h.length-1]+=` ... ${s-r} more columns`),a!==i&&h.push(`... ${i-e} more rows`),h.join(`\\n${Wt}`)}(t,r,n,o,i)}\\n${Gt}]\\n${Gt}rows: ${t.rows}\\n${Gt}columns: ${t.columns}\\n}`}function Ht(t,e,r){return(t>=0&&r?` ${Yt(t,e-1)}`:Yt(t,e)).padEnd(e)}function Yt(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 Xt(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 Qt(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 Zt(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 te(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 ee(t,e,r,n,o){if(5!==arguments.length)throw new RangeError("expected 4 arguments");if(ne("startRow",e),ne("endRow",r),ne("startColumn",n),ne("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 re(t,e=0){let r=[];for(let n=0;n<t;n++)r.push(e);return r}function ne(t,e){if("number"!=typeof e)throw new TypeError(`${t} must be a number`)}function oe(t){if(t.isEmpty())throw new Error("Empty matrix has no elements to index")}class ie{static from1DArray(t,e,r){if(t*e!==r.length)throw new RangeError("data length does not match given dimensions");let n=new ae(t,e);for(let o=0;o<t;o++)for(let t=0;t<e;t++)n.set(o,t,r[o*e+t]);return n}static rowVector(t){let e=new ae(1,t.length);for(let r=0;r<t.length;r++)e.set(0,r,t[r]);return e}static columnVector(t){let e=new ae(t.length,1);for(let r=0;r<t.length;r++)e.set(r,0,t[r]);return e}static zeros(t,e){return new ae(t,e)}static ones(t,e){return new ae(t,e).fill(1)}static rand(t,e,r={}){if("object"!=typeof r)throw new TypeError("options must be an object");const{random:n=Math.random}=r;let o=new ae(t,e);for(let r=0;r<t;r++)for(let t=0;t<e;t++)o.set(r,t,n());return o}static randInt(t,e,r={}){if("object"!=typeof r)throw new TypeError("options must be an object");const{min:n=0,max:o=1e3,random:i=Math.random}=r;if(!Number.isInteger(n))throw new TypeError("min must be an integer");if(!Number.isInteger(o))throw new TypeError("max must be an integer");if(n>=o)throw new RangeError("min must be smaller than max");let s=o-n,a=new ae(t,e);for(let r=0;r<t;r++)for(let t=0;t<e;t++){let e=n+Math.round(i()*s);a.set(r,t,e)}return a}static eye(t,e,r){void 0===e&&(e=t),void 0===r&&(r=1);let n=Math.min(t,e),o=this.zeros(t,e);for(let t=0;t<n;t++)o.set(t,t,r);return o}static diag(t,e,r){let n=t.length;void 0===e&&(e=n),void 0===r&&(r=e);let o=Math.min(n,e,r),i=this.zeros(e,r);for(let e=0;e<o;e++)i.set(e,e,t[e]);return i}static min(t,e){t=this.checkMatrix(t),e=this.checkMatrix(e);let r=t.rows,n=t.columns,o=new ae(r,n);for(let i=0;i<r;i++)for(let r=0;r<n;r++)o.set(i,r,Math.min(t.get(i,r),e.get(i,r)));return o}static max(t,e){t=this.checkMatrix(t),e=this.checkMatrix(e);let r=t.rows,n=t.columns,o=new this(r,n);for(let i=0;i<r;i++)for(let r=0;r<n;r++)o.set(i,r,Math.max(t.get(i,r),e.get(i,r)));return o}static checkMatrix(t){return ie.isMatrix(t)?t:new ae(t)}static isMatrix(t){return null!=t&&"Matrix"===t.klass}get size(){return this.rows*this.columns}apply(t){if("function"!=typeof t)throw new TypeError("callback must be a function");for(let e=0;e<this.rows;e++)for(let r=0;r<this.columns;r++)t.call(this,e,r);return this}to1DArray(){let t=[];for(let e=0;e<this.rows;e++)for(let r=0;r<this.columns;r++)t.push(this.get(e,r));return t}to2DArray(){let t=[];for(let e=0;e<this.rows;e++){t.push([]);for(let r=0;r<this.columns;r++)t[e].push(this.get(e,r))}return t}toJSON(){return this.to2DArray()}isRowVector(){return 1===this.rows}isColumnVector(){return 1===this.columns}isVector(){return 1===this.rows||1===this.columns}isSquare(){return this.rows===this.columns}isEmpty(){return 0===this.rows||0===this.columns}isSymmetric(){if(this.isSquare()){for(let t=0;t<this.rows;t++)for(let e=0;e<=t;e++)if(this.get(t,e)!==this.get(e,t))return!1;return!0}return!1}isEchelonForm(){let t=0,e=0,r=-1,n=!0,o=!1;for(;t<this.rows&&n;){for(e=0,o=!1;e<this.columns&&!1===o;)0===this.get(t,e)?e++:1===this.get(t,e)&&e>r?(o=!0,r=e):(n=!1,o=!0);t++}return n}isReducedEchelonForm(){let t=0,e=0,r=-1,n=!0,o=!1;for(;t<this.rows&&n;){for(e=0,o=!1;e<this.columns&&!1===o;)0===this.get(t,e)?e++:1===this.get(t,e)&&e>r?(o=!0,r=e):(n=!1,o=!0);for(let r=e+1;r<this.rows;r++)0!==this.get(t,r)&&(n=!1);t++}return n}echelonForm(){let t=this.clone(),e=0,r=0;for(;e<t.rows&&r<t.columns;){let n=e;for(let o=e;o<t.rows;o++)t.get(o,r)>t.get(n,r)&&(n=o);if(0===t.get(n,r))r++;else{t.swapRows(e,n);let o=t.get(e,r);for(let n=r;n<t.columns;n++)t.set(e,n,t.get(e,n)/o);for(let n=e+1;n<t.rows;n++){let o=t.get(n,r)/t.get(e,r);t.set(n,r,0);for(let i=r+1;i<t.columns;i++)t.set(n,i,t.get(n,i)-t.get(e,i)*o)}e++,r++}}return t}reducedEchelonForm(){let t=this.echelonForm(),e=t.columns,r=t.rows,n=r-1;for(;n>=0;)if(0===t.maxRow(n))n--;else{let o=0,i=!1;for(;o<r&&!1===i;)1===t.get(n,o)?i=!0:o++;for(let r=0;r<n;r++){let i=t.get(r,o);for(let s=o;s<e;s++){let e=t.get(r,s)-i*t.get(n,s);t.set(r,s,e)}}n--}return t}set(){throw new Error("set method is unimplemented")}get(){throw new Error("get method is unimplemented")}repeat(t={}){if("object"!=typeof t)throw new TypeError("options must be an object");const{rows:e=1,columns:r=1}=t;if(!Number.isInteger(e)||e<=0)throw new TypeError("rows must be a positive integer");if(!Number.isInteger(r)||r<=0)throw new TypeError("columns must be a positive integer");let n=new ae(this.rows*e,this.columns*r);for(let t=0;t<e;t++)for(let e=0;e<r;e++)n.setSubMatrix(this,this.rows*t,this.columns*e);return n}fill(t){for(let e=0;e<this.rows;e++)for(let r=0;r<this.columns;r++)this.set(e,r,t);return this}neg(){return this.mulS(-1)}getRow(t){Xt(this,t);let e=[];for(let r=0;r<this.columns;r++)e.push(this.get(t,r));return e}getRowVector(t){return ae.rowVector(this.getRow(t))}setRow(t,e){Xt(this,t),e=Zt(this,e);for(let r=0;r<this.columns;r++)this.set(t,r,e[r]);return this}swapRows(t,e){Xt(this,t),Xt(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){Qt(this,t);let e=[];for(let r=0;r<this.rows;r++)e.push(this.get(r,t));return e}getColumnVector(t){return ae.columnVector(this.getColumn(t))}setColumn(t,e){Qt(this,t),e=te(this,e);for(let r=0;r<this.rows;r++)this.set(r,t,e[r]);return this}swapColumns(t,e){Qt(this,t),Qt(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=Zt(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=Zt(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=Zt(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=Zt(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=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[e]);return this}subColumnVector(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[e]);return this}mulColumnVector(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[e]);return this}divColumnVector(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[e]);return this}mulRow(t,e){Xt(this,t);for(let r=0;r<this.columns;r++)this.set(t,r,this.get(t,r)*e);return this}mulColumn(t,e){Qt(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(){oe(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(){oe(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(Xt(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){Xt(this,t),oe(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(Xt(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){Xt(this,t),oe(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(Qt(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){Qt(this,t),oe(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(Qt(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){Qt(this,t),oe(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){ie.isMatrix(t)&&(t=t.to1DArray());let e=this.to1DArray();if(e.length!==t.length)throw new RangeError("vectors do not have the same size");let r=0;for(let n=0;n<e.length;n++)r+=e[n]*t[n];return r}mmul(t){t=ae.checkMatrix(t);let e=this.rows,r=this.columns,n=t.columns,o=new ae(e,n),i=new Float64Array(r);for(let s=0;s<n;s++){for(let e=0;e<r;e++)i[e]=t.get(e,s);for(let t=0;t<e;t++){let e=0;for(let n=0;n<r;n++)e+=this.get(t,n)*i[n];o.set(t,s,e)}}return o}strassen2x2(t){t=ae.checkMatrix(t);let e=new ae(2,2);const r=this.get(0,0),n=t.get(0,0),o=this.get(0,1),i=t.get(0,1),s=this.get(1,0),a=t.get(1,0),u=this.get(1,1),h=t.get(1,1),l=(r+u)*(n+h),c=(s+u)*n,f=r*(i-h),d=u*(a-n),g=(r+o)*h,p=l+d-g+(o-u)*(a+h),m=f+g,w=c+d,y=l-c+f+(s-r)*(n+i);return e.set(0,0,p),e.set(0,1,m),e.set(1,0,w),e.set(1,1,y),e}strassen3x3(t){t=ae.checkMatrix(t);let e=new ae(3,3);const r=this.get(0,0),n=this.get(0,1),o=this.get(0,2),i=this.get(1,0),s=this.get(1,1),a=this.get(1,2),u=this.get(2,0),h=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),m=t.get(1,2),w=t.get(2,0),y=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+u+h)*(c-d+m),S=(-r+u)*(d-m),k=(u+h)*(-c+d),A=(-o+h+l)*(p+w-y),D=(o-l)*(p-y),I=o*w,R=(h+l)*(-w+y),_=(-o+s+a)*(m+w-v),z=(o-a)*(m-v),T=(s+a)*(-w+v),P=E+I+n*g,C=(r+n+o-i-s-h-l)*p+M+b+E+A+I+R,O=E+N+k+(r+n+o-s-a-u-h)*m+I+_+T,j=x+s*(-c+f+g-p-m-w+v)+M+E+I+_+z,q=x+M+b+E+a*y,V=I+_+z+T+i*d,L=E+N+S+h*(-c+d+g-p-m-w+y)+A+D+I,F=A+D+I+R+u*f,$=E+N+S+k+l*v;return e.set(0,0,P),e.set(0,1,C),e.set(0,2,O),e.set(1,0,j),e.set(1,1,q),e.set(1,2,V),e.set(2,0,L),e.set(2,1,F),e.set(2,2,$),e}mmulStrassen(t){t=ae.checkMatrix(t);let e=this.clone(),r=e.rows,n=e.columns,o=t.rows,i=t.columns;function s(t,e,r){let n=t.rows,o=t.columns;if(n===e&&o===r)return t;{let n=ie.zeros(e,r);return n=n.setSubMatrix(t,0,0),n}}n!==o&&console.warn(`Multiplying ${r} x ${n} and ${o} x ${i} matrix: dimensions do not match.`);let a=Math.max(r,o),u=Math.max(n,i);return e=s(e,a,u),function t(e,r,n,o){if(n<=512||o<=512)return e.mmul(r);n%2==1&&o%2==1?(e=s(e,n+1,o+1),r=s(r,n+1,o+1)):n%2==1?(e=s(e,n+1,o),r=s(r,n+1,o)):o%2==1&&(e=s(e,n,o+1),r=s(r,n,o+1));let i=parseInt(e.rows/2,10),a=parseInt(e.columns/2,10),u=e.subMatrix(0,i-1,0,a-1),h=r.subMatrix(0,i-1,0,a-1),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),m=t(ie.add(u,g),ie.add(h,p),i,a),w=t(ie.add(f,g),h,i,a),y=t(u,ie.sub(c,p),i,a),v=t(g,ie.sub(d,h),i,a),x=t(ie.add(u,l),p,i,a),M=t(ie.sub(f,u),ie.add(h,c),i,a),b=t(ie.sub(l,g),ie.add(d,p),i,a),E=ie.add(m,v);E.sub(x),E.add(b);let N=ie.add(y,x),S=ie.add(w,v),k=ie.sub(m,w);k.add(y),k.add(M);let A=ie.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,u),a,u)}scaleRows(t={}){if("object"!=typeof t)throw new TypeError("options must be an object");const{min:e=0,max:r=1}=t;if(!Number.isFinite(e))throw new TypeError("min must be a number");if(!Number.isFinite(r))throw new TypeError("max must be a number");if(e>=r)throw new RangeError("min must be smaller than max");let n=new ae(this.rows,this.columns);for(let t=0;t<this.rows;t++){const o=this.getRow(t);o.length>0&&Kt(o,{min:e,max:r,output:o}),n.setRow(t,o)}return n}scaleColumns(t={}){if("object"!=typeof t)throw new TypeError("options must be an object");const{min:e=0,max:r=1}=t;if(!Number.isFinite(e))throw new TypeError("min must be a number");if(!Number.isFinite(r))throw new TypeError("max must be a number");if(e>=r)throw new RangeError("min must be smaller than max");let n=new ae(this.rows,this.columns);for(let t=0;t<this.columns;t++){const o=this.getColumn(t);o.length&&Kt(o,{min:e,max:r,output:o}),n.setColumn(t,o)}return n}flipRows(){const t=Math.ceil(this.columns/2);for(let e=0;e<this.rows;e++)for(let r=0;r<t;r++){let t=this.get(e,r),n=this.get(e,this.columns-1-r);this.set(e,r,n),this.set(e,this.columns-1-r,t)}return this}flipColumns(){const t=Math.ceil(this.rows/2);for(let e=0;e<this.columns;e++)for(let r=0;r<t;r++){let t=this.get(r,e),n=this.get(this.rows-1-r,e);this.set(r,e,n),this.set(this.rows-1-r,e,t)}return this}kroneckerProduct(t){t=ae.checkMatrix(t);let e=this.rows,r=this.columns,n=t.rows,o=t.columns,i=new ae(e*n,r*o);for(let s=0;s<e;s++)for(let e=0;e<r;e++)for(let r=0;r<n;r++)for(let a=0;a<o;a++)i.set(n*s+r,o*e+a,this.get(s,e)*t.get(r,a));return i}kroneckerSum(t){if(t=ae.checkMatrix(t),!this.isSquare()||!t.isSquare())throw new Error("Kronecker Sum needs two Square Matrices");let e=this.rows,r=t.rows,n=this.kroneckerProduct(ae.eye(r,r)),o=ae.eye(e,e).kroneckerProduct(t);return n.add(o)}transpose(){let t=new ae(this.columns,this.rows);for(let e=0;e<this.rows;e++)for(let r=0;r<this.columns;r++)t.set(r,e,this.get(e,r));return t}sortRows(t=se){for(let e=0;e<this.rows;e++)this.setRow(e,this.getRow(e).sort(t));return this}sortColumns(t=se){for(let e=0;e<this.columns;e++)this.setColumn(e,this.getColumn(e).sort(t));return this}subMatrix(t,e,r,n){ee(this,t,e,r,n);let o=new ae(e-t+1,n-r+1);for(let i=t;i<=e;i++)for(let e=r;e<=n;e++)o.set(i-t,e-r,this.get(i,e));return o}subMatrixRow(t,e,r){if(void 0===e&&(e=0),void 0===r&&(r=this.columns-1),e>r||e<0||e>=this.columns||r<0||r>=this.columns)throw new RangeError("Argument out of range");let n=new ae(t.length,r-e+1);for(let o=0;o<t.length;o++)for(let i=e;i<=r;i++){if(t[o]<0||t[o]>=this.rows)throw new RangeError(`Row index out of range: ${t[o]}`);n.set(o,i-e,this.get(t[o],i))}return n}subMatrixColumn(t,e,r){if(void 0===e&&(e=0),void 0===r&&(r=this.rows-1),e>r||e<0||e>=this.rows||r<0||r>=this.rows)throw new RangeError("Argument out of range");let n=new ae(r-e+1,t.length);for(let o=0;o<t.length;o++)for(let i=e;i<=r;i++){if(t[o]<0||t[o]>=this.columns)throw new RangeError(`Column index out of range: ${t[o]}`);n.set(i-e,o,this.get(i,t[o]))}return n}setSubMatrix(t,e,r){if((t=ae.checkMatrix(t)).isEmpty())return this;ee(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(!$t(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(!$t(e))throw new TypeError("column indices must be an array");for(let r=0;r<e.length;r++)if(e[r]<0||e[r]>=t.columns)throw new RangeError("column indices are out of range")}(this,e);let r=new ae(t.length,e.length);for(let n=0;n<t.length;n++){let o=t[n];for(let t=0;t<e.length;t++){let i=e[t];r.set(n,t,this.get(o,i))}}return r}trace(){let t=Math.min(this.rows,this.columns),e=0;for(let r=0;r<t;r++)e+=this.get(r,r);return e}clone(){let t=new ae(this.rows,this.columns);for(let e=0;e<this.rows;e++)for(let r=0;r<this.columns;r++)t.set(e,r,this.get(e,r));return t}sum(t){switch(t){case"row":return function(t){let e=re(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=re(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=re(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=re(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(!$t(n))throw new TypeError("mean must be an array");return function(t,e,r){const n=t.rows,o=t.columns,i=[];for(let s=0;s<n;s++){let n=0,a=0,u=0;for(let e=0;e<o;e++)u=t.get(s,e)-r[s],n+=u,a+=u*u;e?i.push((a-n*n/o)/(o-1)):i.push((a-n*n/o)/o)}return i}(this,r,n);case"column":if(!$t(n))throw new TypeError("mean must be an array");return function(t,e,r){const n=t.rows,o=t.columns,i=[];for(let s=0;s<o;s++){let o=0,a=0,u=0;for(let e=0;e<n;e++)u=t.get(e,s)-r[s],o+=u,a+=u*u;e?i.push((a-o*o/n)/(n-1)):i.push((a-o*o/n)/n)}return i}(this,r,n);case void 0:if("number"!=typeof n)throw new TypeError("mean must be a number");return function(t,e,r){const n=t.rows,o=t.columns,i=n*o;let s=0,a=0,u=0;for(let e=0;e<n;e++)for(let n=0;n<o;n++)u=t.get(e,n)-r,s+=u,a+=u*u;return e?(a-s*s/i)/(i-1):(a-s*s/i)/i}(this,r,n);default:throw new Error(`invalid option: ${t}`)}}standardDeviation(t,e){"object"==typeof t&&(e=t,t=void 0);const r=this.variance(t,e);if(void 0===t)return Math.sqrt(r);for(let t=0;t<r.length;t++)r[t]=Math.sqrt(r[t]);return r}center(t,e={}){if("object"==typeof t&&(e=t,t=void 0),"object"!=typeof e)throw new TypeError("options must be an object");const{center:r=this.mean(t)}=e;switch(t){case"row":if(!$t(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(!$t(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(!$t(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(!$t(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 Jt(this,t)}}function se(t,e){return t-e}ie.prototype.klass="Matrix","undefined"!=typeof Symbol&&(ie.prototype[Symbol.for("nodejs.util.inspect.custom")]=function(){return Jt(this)}),ie.random=ie.rand,ie.randomInt=ie.randInt,ie.diagonal=ie.diag,ie.prototype.diagonal=ie.prototype.diag,ie.identity=ie.eye,ie.prototype.negate=ie.prototype.neg,ie.prototype.tensorProduct=ie.prototype.kroneckerProduct;class ae extends ie{constructor(t,e){if(super(),ae.isMatrix(t))return t.clone();if(Number.isInteger(t)&&t>=0){if(this.data=[],!(Number.isInteger(e)&&e>=0))throw new TypeError("nColumns must be a positive integer");for(let r=0;r<t;r++)this.data.push(new Float64Array(e))}else{if(!$t(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 Xt(this,t),this.data.splice(t,1),this.rows-=1,this}addRow(t,e){return void 0===e&&(e=t,t=this.rows),Xt(this,t,!0),e=Float64Array.from(Zt(this,e)),this.data.splice(t,0,e),this.rows+=1,this}removeColumn(t){Qt(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),Qt(this,t,!0),e=te(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}}(ie,ae);class ue extends ie{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 he(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 le{constructor(t,e={}){if((t=ue.checkMatrix(t)).isEmpty())throw new Error("Matrix must be non-empty");let r=t.rows,n=t.columns;const{computeLeftSingularVectors:o=!0,computeRightSingularVectors:i=!0,autoTranspose:s=!1}=e;let a,u=Boolean(o),h=Boolean(i),l=!1;if(r<n)if(s){a=t.transpose(),r=a.rows,n=a.columns,l=!0;let e=u;u=h,h=e}else a=t.clone(),console.warn("Computing SVD on a matrix with more columns than rows. Consider enabling autoTranspose");else a=t.clone();let c=Math.min(r,n),f=Math.min(r+1,n),d=new Float64Array(f),g=new ae(r,c),p=new ae(n,n),m=new Float64Array(n),w=new Float64Array(r),y=new Float64Array(f);for(let t=0;t<f;t++)y[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]=he(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))}m[e]=a.get(t,e)}if(u&&t<v)for(let e=t;e<r;e++)g.set(e,t,a.get(e,t));if(t<x){m[t]=0;for(let e=t+1;e<n;e++)m[t]=he(m[t],m[e]);if(0!==m[t]){m[t+1]<0&&(m[t]=0-m[t]);for(let e=t+1;e<n;e++)m[e]/=m[t];m[t+1]+=1}if(m[t]=-m[t],t+1<r&&0!==m[t]){for(let e=t+1;e<r;e++)w[e]=0;for(let e=t+1;e<r;e++)for(let r=t+1;r<n;r++)w[e]+=m[r]*a.get(e,r);for(let e=t+1;e<n;e++){let n=-m[e]/m[t+1];for(let o=t+1;o<r;o++)a.set(o,e,a.get(o,e)+n*w[o])}}if(h)for(let e=t+1;e<n;e++)p.set(e,t,m[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&&(m[x]=a.get(x,b-1)),m[b-1]=0,u){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(h)for(let t=n-1;t>=0;t--){if(t<x&&0!==m[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(m[t])<=e||Number.isNaN(m[t])){m[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(m[r]):0)+(r!==t+1?Math.abs(m[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=m[b-2];m[b-2]=0;for(let r=b-2;r>=t;r--){let o=he(d[r],e),i=d[r]/o,s=e/o;if(d[r]=o,r!==t&&(e=-s*m[r-1],m[r-1]=i*m[r-1]),h)for(let t=0;t<n;t++)o=i*p.get(t,r)+s*p.get(t,b-1),p.set(t,b-1,-s*p.get(t,r)+i*p.get(t,b-1)),p.set(t,r,o)}break}case 2:{let e=m[t-1];m[t-1]=0;for(let n=t;n<b;n++){let o=he(d[n],e),i=d[n]/o,s=e/o;if(d[n]=o,e=-s*m[n],m[n]=i*m[n],u)for(let e=0;e<r;e++)o=i*g.get(e,n)+s*g.get(e,t-1),g.set(e,t-1,-s*g.get(e,n)+i*g.get(e,t-1)),g.set(e,n,o)}break}case 3:{const e=Math.max(Math.abs(d[b-1]),Math.abs(d[b-2]),Math.abs(m[b-2]),Math.abs(d[t]),Math.abs(m[t])),o=d[b-1]/e,i=d[b-2]/e,s=m[b-2]/e,a=d[t]/e,l=m[t]/e,c=((i+o)*(i-o)+s*s)/2,f=o*s*(o*s);let w=0;0===c&&0===f||(w=c<0?0-Math.sqrt(c*c+f):Math.sqrt(c*c+f),w=f/(c+w));let y=(a+o)*(a-o)+w,v=a*l;for(let e=t;e<b-1;e++){let o=he(y,v);0===o&&(o=Number.MIN_VALUE);let i=y/o,s=v/o;if(e!==t&&(m[e-1]=o),y=i*d[e]+s*m[e],m[e]=i*m[e]-s*d[e],v=s*d[e+1],d[e+1]=i*d[e+1],h)for(let t=0;t<n;t++)o=i*p.get(t,e)+s*p.get(t,e+1),p.set(t,e+1,-s*p.get(t,e)+i*p.get(t,e+1)),p.set(t,e,o);if(o=he(y,v),0===o&&(o=Number.MIN_VALUE),i=y/o,s=v/o,d[e]=o,y=i*m[e]+s*d[e+1],d[e+1]=-s*m[e]+i*d[e+1],v=s*m[e+1],m[e+1]=i*m[e+1],u&&e<r-1)for(let t=0;t<r;t++)o=i*g.get(t,e)+s*g.get(t,e+1),g.set(t,e+1,-s*g.get(t,e)+i*g.get(t,e+1)),g.set(t,e,o)}m[b-2]=y,N+=1;break}case 4:if(d[t]<=0&&(d[t]=d[t]<0?-d[t]:0,h))for(let e=0;e<=E;e++)p.set(e,t,-p.get(e,t));for(;t<E&&!(d[t]>=d[t+1]);){let e=d[t];if(d[t]=d[t+1],d[t+1]=e,h&&t<n-1)for(let r=0;r<n;r++)e=p.get(r,t+1),p.set(r,t+1,p.get(r,t)),p.set(r,t,e);if(u&&t<r-1)for(let n=0;n<r;n++)e=g.get(n,t+1),g.set(n,t+1,g.get(n,t)),g.set(n,t,e);t++}N=0,b--}}if(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=ae.zeros(n,n);for(let t=0;t<n;t++)Math.abs(this.s[t])<=r?o.set(t,t,0):o.set(t,t,1/this.s[t]);let i=this.U,s=this.rightSingularVectors,a=s.mmul(o),u=s.rows,h=i.rows,l=ae.zeros(u,h);for(let t=0;t<u;t++)for(let e=0;e<h;e++){let r=0;for(let o=0;o<n;o++)r+=a.get(t,o)*i.get(e,o);l.set(t,e,r)}return l.mmul(e)}solveForDiagonal(t){return this.solve(ae.diag(t))}inverse(){let t=this.V,e=this.threshold,r=t.rows,n=t.columns,o=new ae(r,this.s.length);for(let i=0;i<r;i++)for(let r=0;r<n;r++)Math.abs(this.s[r])>e&&o.set(i,r,t.get(i,r)/this.s[r]);let i=this.U,s=i.rows,a=i.columns,u=new ae(r,s);for(let t=0;t<r;t++)for(let e=0;e<s;e++){let r=0;for(let n=0;n<a;n++)r+=o.get(t,n)*i.get(e,n);u.set(t,e,r)}return u}get condition(){return this.s[0]/this.s[Math.min(this.m,this.n)-1]}get norm2(){return this.s[0]}get rank(){let t=Math.max(this.m,this.n)*this.s[0]*Number.EPSILON,e=0,r=this.s;for(let n=0,o=r.length;n<o;n++)r[n]>t&&e++;return e}get diagonal(){return Array.from(this.s)}get threshold(){return Number.EPSILON/2*Math.max(this.m,this.n)*this.s[0]}get leftSingularVectors(){return this.U}get rightSingularVectors(){return this.V}get diagonalMatrix(){return ae.diag(this.s)}}var ce={center:[0,0],linkDistance:50},fe=function(){function t(t){void 0===t&&(t={}),this.options=t,this.id="mds",this.options=r(r({},ce),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,u=void 0===a?50:a,h=o.layoutInvisibles,l=o.onLayoutEnd,d=e.getAllNodes(),g=e.getAllEdges();if(h||(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}))),!d||0===d.length){var p={nodes:[],edges:g};return null==l||l(p),p}if(1===d.length){t&&e.mergeNodeData(d[0].id,{x:s[0],y:s[1]});var w={nodes:[r(r({},d[0]),{data:r(r({},d[0].data),{x:s[0],y:s[1]})})],edges:g};return null==l||l(w),w}var y=f({nodes:d,edges:g},!1),v=c(y);de(v);var x=function(t,e){var r=[];return t.forEach((function(t){var n=[];t.forEach((function(t){n.push(t*e)})),r.push(n)})),r}(v,u),M=ge(x),b=[];M.forEach((function(t,e){var r=m(d[e]);r.data.x=t[0]+s[0],r.data.y=t[1]+s[1],b.push(r)})),t&&b.forEach((function(t){return e.mergeNodeData(t.id,{x:t.data.x,y:t.data.y})}));var E={nodes:b,edges:g};return null==l||l(E),E},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)}))}))},ge=function(t){var e=ae.mul(ae.pow(t,2),-.5),r=e.mean("row"),n=e.mean("column"),o=e.mean();e.add(o).subRowVector(r).subColumnVector(n);var i=new le(e),s=ae.sqrt(i.diagonalMatrix).diagonal();return i.leftSingularVectors.toJSON().map((function(t){return ae.mul([t],[s]).toJSON()[0].splice(0,2)}))},pe={iterations:10,height:10,width:10,speed:100,gravity:10,k:5},me=function(t,e,r,n,o,i){e.forEach((function(s,a){r[a]={x:0,y:0},e.forEach((function(e,u){if(a!==u&&o[a]===o[u]){var h=s.x-e.x,l=s.y-e.y,c=Math.sqrt(h*h+l*l);if(0===c){c=1;var f=a>u?1:-1;h=.01*f,l=.01*f}if(c<i(t[a])/2+i(t[u])/2){var d=n*n/c;r[a].x+=h/c*d,r[a].y+=l/c*d}}}))}))},we=function(t,e,r,n,o,i,s,a){var u=i||s/10;return n&&e.forEach((function(e,r){var n=t[r].x-t[o].x,i=t[r].y-t[o].y,s=Math.sqrt(n*n+i*i),a=i/s,u=-n/s,h=Math.sqrt(e.x*e.x+e.y*e.y),l=Math.acos((a*e.x+u*e.y)/h);l>Math.PI/2&&(l-=Math.PI/2,a*=-1,u*=-1);var c=Math.cos(l)*h;e.x=a*c,e.y=u*c})),t.forEach((function(i,s){if(s!==o){var h=Math.sqrt(e[s].x*e[s].x+e[s].y*e[s].y);if(h>0&&s!==o){var l=Math.min(u*(r/800),h);if(i.x+=e[s].x/h*l,i.y+=e[s].y/h*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},ye={maxIteration:1e3,focusNode:null,unitRadius:null,linkDistance:50,preventOverlap:!1,strictRadial:!0,maxPreventOverlapIteration:200,sortStrength:10},ve=function(){function t(t){void 0===t&&(t={}),this.options=t,this.id="radial",this.options=r(r({},ye),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),u=s.width,h=s.height,l=s.center,d=s.focusNode,g=s.unitRadius,p=s.nodeSize,w=s.nodeSpacing,y=s.strictRadial,v=s.preventOverlap,x=s.maxPreventOverlapIteration,M=s.sortBy,b=s.linkDistance,E=void 0===b?50:b,N=s.sortStrength,S=void 0===N?10:N,k=s.maxIteration,A=void 0===k?1e3:k,D=s.layoutInvisibles,I=s.onLayoutEnd,R=e.getAllNodes(),_=e.getAllEdges();if(D||(R=R.filter((function(t){var e=(t.data||{}).visible;return e||void 0===e})),_=_.filter((function(t){var e=(t.data||{}).visible;return e||void 0===e}))),!R||0===R.length){var z={nodes:[],edges:_};return null==I||I(z),z}var T=u||"undefined"==typeof window?u:window.innerWidth,P=h||"undefined"==typeof window?h:window.innerHeight,C=l||[T/2,P/2];if(1===R.length){t&&e.mergeNodeData(R[0].id,{x:C[0],y:C[1]});var O={nodes:[r(r({},R[0]),{data:r(r({},R[0].data),{x:C[0],y:C[1]})})],edges:_};return null==I||I(O),O}var j=R[0];if(a(d)){for(var q=0;q<R.length;q++)if(R[q].id===d){j=R[q];break}}else j=d||R[0];var V=be(R,j.id),L=f({nodes:R,edges:_},!1),F=c(L),$=Ne(F,V);Ee(F,V,$+1);var U=F[V],B=T-C[0]>C[0]?C[0]:T-C[0],K=P-C[1]>C[1]?C[1]:P-C[1];0===B&&(B=T/2),0===K&&(K=P/2);var G=Math.min(B,K),W=Math.max.apply(Math,i([],o(U),!1)),J=[],H=g||G/W;U.forEach((function(t,e){J[e]=t*H}));var Y,X=xe(R,F,E,J,H,M,S),Q=Me(X),Z=function(t,e,r){try{var n=ae.mul(ae.pow(e,2),-.5),o=n.mean("row"),i=n.mean("column"),s=n.mean();n.add(s).subRowVector(o).subColumnVector(i);var a=new le(n),u=ae.sqrt(a.diagonalMatrix).diagonal();return a.leftSingularVectors.toJSON().map((function(e){return ae.mul([e],[u]).toJSON()[0].splice(0,t)}))}catch(t){for(var h=[],l=0;l<e.length;l++){var c=Math.random()*r,f=Math.random()*r;h.push([c,f])}return h}}(E,X,E),tt=Z.map((function(t){var e=o(t,2),r=e[0],n=e[1];return{x:(isNaN(r)?Math.random()*E:r)-Z[V][0],y:(isNaN(n)?Math.random()*E:n)-Z[V][1]}}));if(this.run(A,tt,Q,X,J,V),v){Y=Se(p,w);var et={nodes:R,nodeSizeFunc:Y,positions:tt,radii:J,height:P,width:T,strictRadial:Boolean(y),focusIdx:V,iterations:x||200,k:tt.length/4.5};tt=function(t,e){for(var n=r(r({},pe),e),o=n.positions,i=n.iterations,s=n.width,a=n.k,u=n.speed,h=void 0===u?100:u,l=n.strictRadial,c=n.focusIdx,f=n.radii,d=void 0===f?[]:f,g=n.nodeSizeFunc,p=t.getAllNodes(),m=[],w=s/10,y=0;y<i;y++)o.forEach((function(t,e){m[e]={x:0,y:0}})),me(p,o,m,a,d,g),we(o,m,h,l,c,w,s,d);return o}(e,et)}var rt=[];tt.forEach((function(t,e){var r=m(R[e]);r.data.x=t.x+C[0],r.data.y=t.y+C[1],rt.push(r)})),t&&rt.forEach((function(t){return e.mergeNodeData(t.id,{x:t.data.x,y:t.data.y})}));var nt={nodes:rt,edges:_};return null==I||I(nt),nt},t.prototype.run=function(t,e,r,n,o,i){for(var s=0;s<=t;s++){var a=s/t;this.oneIteration(a,e,o,n,r,i)}},t.prototype.oneIteration=function(t,e,r,n,o,i){var s=1-t;e.forEach((function(a,u){var h=d(a,{x:0,y:0}),l=0===h?0:1/h;if(u!==i){var c=0,f=0,g=0;e.forEach((function(t,e){if(u!==e){var r=d(a,t),i=0===r?0:1/r,s=n[e][u];g+=o[u][e],c+=o[u][e]*(t.x+s*(a.x-t.x)*i),f+=o[u][e]*(t.y+s*(a.y-t.y)*i)}}));var p=0===r[u]?0:1/r[u];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}(),xe=function(t,e,r,n,o,i,s){if(!t)return[];var u=[];if(e){var h={};e.forEach((function(e,l){var c=[];e.forEach((function(e,u){var f,d;if(l===u)c.push(0);else if(n[l]===n[u])if("data"===i)c.push(e*(Math.abs(l-u)*s)/(n[l]/o));else if(i){var g=void 0,p=void 0;if(h[t[l].id])g=h[t[l].id];else{var m=("id"===i?t[l].id:null===(f=t[l].data)||void 0===f?void 0:f[i])||0;g=a(m)?m.charCodeAt(0):m,h[t[l].id]=g}h[t[u].id]?p=h[t[u].id]:(m=("id"===i?t[u].id:null===(d=t[u].data)||void 0===d?void 0:d[i])||0,p=a(m)?m.charCodeAt(0):m,h[t[u].id]=p),c.push(e*(Math.abs(g-p)*s)/(n[l]/o))}else c.push(e*r/(n[l]/o));else{var w=(r+o)/2;c.push(e*w)}})),u.push(c)}))}return u},Me=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},be=function(t,e){var r=-1;return t.forEach((function(t,n){t.id===e&&(r=n)})),Math.max(r,0)},Ee=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}},Ne=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},Se=function(t,e){var r;return r=l(e)?function(){return e}:w(e)?e:function(){return 0},t?h(t)?function(e){return(t[0]>t[1]?t[0]:t[1])+r(e)}:function(e){return t+r(e)}:function(t){return t.data.bboxSize?Math.max(t.data.bboxSize[0],t.data.bboxSize[1])+r(t):t.data.size?h(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)}},ke={center:[0,0],width:300,height:300},Ae={circular:M,concentric:S,mds:fe,random:function(){function t(t){void 0===t&&(t={}),this.options=t,this.id="random",this.options=r(r({},ke),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,u=o.layoutInvisibles,h=o.onLayoutEnd,l=e.getAllNodes();u||(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==h||h(p),p},t}(),grid:Pt,radial:ve,force:At,d3force:bt};function De(t,e){return r=this,n=void 0,i=function(){var r,n,o,i,a,u,h,l,c;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(u){return function(a){if(r)throw new TypeError("Generator is already executing.");for(;i&&(i=0,a[0]&&(s=0)),s;)try{if(r=1,n&&(o=2&a[0]?n.return:a[0]?n.throw||((o=n.return)&&o.call(n),0):n.next)&&!(o=o.call(n,a[1])).done)return o;switch(n=0,o&&(a=[2&a[0],o.value]),a[0]){case 0:case 1:o=a;break;case 4:return s.label++,{value:a[1],done:!1};case 5:s.label++,n=a[1],a=[0];continue;case 7:a=s.ops.pop(),s.trys.pop();continue;default:if(!((o=(o=s.trys).length>0&&o[o.length-1])||6!==a[0]&&2!==a[0])){s=0;continue}if(3===a[0]&&(!o||a[1]>o[0]&&a[1]<o[3])){s.label=a[1];break}if(6===a[0]&&s.label<o[1]){s.label=o[1],o=a;break}if(o&&s.label<o[2]){s.label=o[2],s.ops.push(a);break}o[2]&&s.ops.pop(),s.trys.pop();continue}a=e.call(t,s)}catch(t){a=[6,t],n=0}finally{r=o=0}if(5&a[0])throw a[1];return{value:a[0]?a[1]:void 0,done:!0}}([a,u])}}}(this,(function(f){if(r=t.layout,n=r.id,o=r.options,i=t.nodes,a=t.edges,u=new s({nodes:i,edges:a}),!(c=Ae[n]))throw new Error("Unknown layout id: ".concat(n));return h=new c(o),[2,new Promise((function(t){l=h.execute(u,{onLayoutEnd:function(){t([l,e])}})}))]}))},new((o=void 0)||(o=Promise))((function(t,e){function s(t){try{u(i.next(t))}catch(t){e(t)}}function a(t){try{u(i.throw(t))}catch(t){e(t)}}function u(e){var r;e.done?t(e.value):(r=e.value,r instanceof o?r:new o((function(t){t(r)}))).then(s,a)}u((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=8d3d71d9cadd55fe4e07.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),r.r=t=>{"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(t,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(t,"__esModule",{value:!0})};var n={};return(()=>{"use strict";r.r(n),r.d(n,{CircularLayout:()=>b,ConcentricLayout:()=>I,D3ForceLayout:()=>_t,ForceLayout:()=>Tt,GridLayout:()=>Ft,MDSLayout:()=>ve,RadialLayout:()=>Ae,RandomLayout:()=>Te,Supervisor:()=>D,SupervisorEvent:()=>_,registerLayout:()=>Oe,registry:()=>Pe});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},u=/-(\w)/g,h=(function(t){return t.replace(u,(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 r=[];return t.forEach((function(t){r.push(t)})),r.map((function(t){return p(t)}))}if("object"==typeof t&&Object.keys(t).length){var n=e({},t);return Object.keys(n).forEach((function(t){n[t]=p(n[t])})),n}return t},m=function(t){var e=p(t);return e.data=e.data||{},e},w=function(t){return"function"==typeof t};function y(t,e){return w(e)?e:l(e)?function(){return e}:function(){return t}}function v(t,e,r){return void 0===r&&(r=!0),e||0===e?w(e)?e:l(e)?function(){return e}:h(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?h(r)?r[0]>r[1]?r[0]:r[1]:g(r)?r.width>r.height?r.width:r.height:r:t}}var x={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({},x),t)}return t.prototype.execute=function(t,e){return this.genericCircularLayout(!1,t,e)},t.prototype.assign=function(t,e){var r=this;t.batch((function(){r.genericCircularLayout(!0,t,e)}))},t.prototype.genericCircularLayout=function(t,r,n){var o=e(e({},this.options),n),s=o.width,a=o.height,u=o.center,h=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,w=o.clockwise,x=o.nodeSpacing,b=o.nodeSize,S=o.layoutInvisibles,N=o.onLayoutEnd,A=r.getAllNodes(),k=r.getAllEdges();S||(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 _=A.length;if(0===_)return null==N||N({nodes:[],edges:[]}),{nodes:[],edges:[]};var D=i(E(s,a,u),3),R=D[0],I=D[1],z=D[2];if(1===_){t&&r.mergeNodeData(A[0].id,{x:z[0],y:z[1]});var C={nodes:[e(e({},A[0]),{data:e(e({},A[0].data),{x:z[0],y:z[1]})})],edges:k};return null==N||N(C),C}var T=(d-c)/_,P=o.radius,O=o.startRadius,j=o.endRadius;if(x){var L=y(10,x),q=v(10,b),V=-1/0;A.forEach((function(t){var e=q(t);V<e&&(V=e)}));var F=0;A.forEach((function(t,e){F+=0===e?V||10:(L(t)||0)+(V||10)})),P=F/(2*Math.PI)}else P||O||j?!O&&j?O=j:O&&!j&&(j=O):P=Math.min(I,R)/2;var $=T*g,U=[];U="topology"===p?M(r,A):"topology-directed"===p?M(r,A,!0):"degree"===p?function(t,e){var r=[];return e.forEach((function(t,e){r.push(m(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 m(t)}));for(var K=Math.ceil(_/h),B=0;B<_;++B){var G=P;G||null===O||null===j||(G=O+B*(j-O)/(_-1)),G||(G=10+100*B/(_-1));var J=c+B%K*$+2*Math.PI/h*Math.floor(B/K);w||(J=d-B%K*$-2*Math.PI/h*Math.floor(B/K)),U[B].data.x=z[0]+Math.cos(J)*G,U[B].data.y=z[1]+Math.sin(J)*G}t&&U.forEach((function(t){r.mergeNodeData(t.id,{x:t.data.x,y:t.data.y})}));var H={nodes:U,edges:k};return null==N||N(H),H},t}(),M=function(t,e,r){void 0===r&&(r=!1);var n=[m(e[0])],o={},i=e.length;o[e[0].id]=!0;var s=0;return e.forEach((function(a,u){if(0!==u)if(u!==i-1&&t.getDegree(a.id,"both")===t.getDegree(e[u+1].id,"both")&&!t.areNeighbors(n[s].id,a.id)||o[a.id]){for(var h=r?t.getSuccessors(n[s].id):t.getNeighbors(n[s].id),l=!1,c=0;c<h.length;c++){var f=h[c];if(t.getDegree(f.id)===t.getDegree(a.id)&&!o[f.id]){n.push(m(f)),o[f.id]=!0,l=!0;break}}for(var d=0;!l&&(o[e[d].id]||(n.push(m(e[d])),o[e[d].id]=!0,l=!0),++d!==i););}else n.push(m(a)),o[a.id]=!0,s++})),n},E=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),N=r.n(S),A=r(825),k=r.n(A),_={LAYOUT_ITERATION:"tick",LAYOUT_END:"layoutend"},D=function(e){function r(t,r,n){var o=e.call(this)||this;return o.graph=t,o.layout=r,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=k()(),this.running&&(this.running=!1,this.start())},r.prototype.start=function(){var t=this;if(this.running)return this;this.running=!0;var e=this.layout.options,r=(e.onLayoutEnd,e.onTick,o(e,["onLayoutEnd","onTick"])),n={layout:{id:this.layout.id,options:r},nodes:this.graph.getAllNodes(),edges:this.graph.getAllEdges()},s=new Float32Array([0]);return this.worker.calculateLayout(n,[s]).then((function(e){var r=i(e,2),n=r[0];r[1],t.emit(_.LAYOUT_END,n),t.layout.options.onLayoutEnd&&t.layout.options.onLayoutEnd(n)})),this},r.prototype.stop=function(){return this.running=!1,this},r.prototype.kill=function(){this.worker&&this.worker.terminate()},r.prototype.isRunning=function(){return this.running},r}(N()),R={nodeSize:30,minNodeSpacing:10,nodeSpacing:10,preventOverlap:!1,sweep:void 0,equidistant:!1,startAngle:1.5*Math.PI,clockwise:!0,maxLevelDiff:void 0,sortBy:"degree"},I=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,u=o.height,c=o.sortBy,f=o.maxLevelDiff,d=o.sweep,p=o.clockwise,y=o.equidistant,v=o.minNodeSpacing,x=void 0===v?10:v,b=o.preventOverlap,M=o.startAngle,E=void 0===M?1.5*Math.PI:M,S=o.nodeSize,N=o.nodeSpacing,A=o.layoutInvisibles,k=o.onLayoutEnd,_=r.getAllNodes(),D=r.getAllEdges();A||(_=_.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=_.length;if(0===R){var I={nodes:[],edges:D};return null==k||k(I),I}var z=s||"undefined"==typeof window?s:window.innerWidth,C=u||"undefined"==typeof window?u:window.innerHeight,T=i||[z/2,C/2];if(1===R){t&&r.mergeNodeData(_[0].id,{x:T[0],y:T[1]});var P={nodes:[e(e({},_[0]),{data:e(e({},_[0].data),{x:T[0],y:T[1]})})],edges:D};return null==k||k(P),P}var O,j=[],L=0;O=h(S)?Math.max(S[0],S[1]):S,h(N)?L=Math.max(N[0],N[1]):l(N)&&(L=N),_.forEach((function(t){var e=m(t);j.push(e);var r=O,n=e.data;h(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)),O=Math.max(O,r),w(N)&&(L=Math.max(N(t),L))}));var q={};j.forEach((function(t,e){q[t.id]=e}));var V=c;a(V)&&void 0!==j[0].data[V]||(V="degree"),"degree"===V?j.sort((function(t,e){return r.getDegree(e.id,"both")-r.getDegree(t.id,"both")})):j.sort((function(t,e){return e.data[V]-t.data[V]}));var F=j[0],$=(f||("degree"===V?r.getDegree(F.id,"both"):F.data[V]))/4,U=[{nodes:[]}],K=U[0];j.forEach((function(t){if(K.nodes.length>0){var e="degree"===V?Math.abs(r.getDegree(K.nodes[0].id,"both")-r.getDegree(t.id,"both")):Math.abs(K.nodes[0].data[V]-t.data[V]);$&&e>=$&&(K={nodes:[]},U.push(K))}K.nodes.push(t)}));var B=O+(L||x);if(!b){var G=U.length>0&&U[0].nodes.length>1,J=(Math.min(z,C)/2-B)/(U.length+(G?1:0));B=Math.min(B,J)}var H=0;if(U.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&&b){var r=Math.cos(t.dTheta)-Math.cos(0),n=Math.sin(t.dTheta)-Math.sin(0),o=Math.sqrt(B*B/(r*r+n*n));H=Math.max(o,H)}t.r=H,H+=B})),y){for(var W=0,Y=0,X=0;X<U.length;X++){var Q=(U[X].r||0)-Y;W=Math.max(W,Q)}Y=0,U.forEach((function(t,e){0===e&&(Y=t.r||0),t.r=Y,Y+=W}))}U.forEach((function(t){var e=t.dTheta||0,r=t.r||0;t.nodes.forEach((function(t,n){var o=E+(p?1:-1)*e*n;t.data.x=T[0]+r*Math.cos(o),t.data.y=T[1]+r*Math.sin(o)}))})),t&&j.forEach((function(t){return r.mergeNodeData(t.id,{x:t.data.x,y:t.data.y})}));var Z={nodes:j,edges:D};return null==k||k(Z),Z},t}();function z(t,e,r,n){if(isNaN(e)||isNaN(r))return t;var o,i,s,a,u,h,l,c,f,d=t._root,g={data:n},p=t._x0,m=t._y0,w=t._x1,y=t._y1;if(!d)return t._root=g,t;for(;d.length;)if((h=e>=(i=(p+w)/2))?p=i:w=i,(l=r>=(s=(m+y)/2))?m=s:y=s,o=d,!(d=d[c=l<<1|h]))return o[c]=g,t;if(a=+t._x.call(null,d.data),u=+t._y.call(null,d.data),e===a&&r===u)return g.next=d,o?o[c]=g:t._root=g,t;do{o=o?o[c]=new Array(4):t._root=new Array(4),(h=e>=(i=(p+w)/2))?p=i:w=i,(l=r>=(s=(m+y)/2))?m=s:y=s}while((c=l<<1|h)==(f=(u>=s)<<1|a>=i));return o[f]=d,o[c]=g,t}function C(t,e,r,n,o){this.node=t,this.x0=e,this.y0=r,this.x1=n,this.y1=o}function T(t){return t[0]}function P(t){return t[1]}function O(t,e,r){var n=new j(null==e?T:e,null==r?P:r,NaN,NaN,NaN,NaN);return null==t?n:n.addAll(t)}function j(t,e,r,n,o,i){this._x=t,this._y=e,this._x0=r,this._y0=n,this._x1=o,this._y1=i,this._root=void 0}function L(t){for(var e={data:t.data},r=e;t=t.next;)r=r.next={data:t.data};return e}var q=O.prototype=j.prototype;function V(t){return function(){return t}}function F(t){return 1e-6*(t()-.5)}q.copy=function(){var t,e,r=new j(this._x,this._y,this._x0,this._y0,this._x1,this._y1),n=this._root;if(!n)return r;if(!n.length)return r._root=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},q.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)},q.addAll=function(t){var e,r,n,o,i=t.length,s=new Array(i),a=new Array(i),u=1/0,h=1/0,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<u&&(u=n),n>l&&(l=n),o<h&&(h=o),o>c&&(c=o));if(u>l||h>c)return this;for(this.cover(u,h).cover(l,c),r=0;r<i;++r)z(this,s[r],a[r],t[r]);return this},q.cover=function(t,e){if(isNaN(t=+t)||isNaN(e=+e))return this;var r=this._x0,n=this._y0,o=this._x1,i=this._y1;if(isNaN(r))o=(r=Math.floor(t))+1,i=(n=Math.floor(e))+1;else{for(var s,a,u=o-r||1,h=this._root;r>t||t>=o||n>e||e>=i;)switch(a=(e<n)<<1|t<r,(s=new Array(4))[a]=h,h=s,u*=2,a){case 0:o=r+u,i=n+u;break;case 1:r=o-u,i=n+u;break;case 2:o=r+u,n=i-u;break;case 3:r=o-u,n=i-u}this._root&&this._root.length&&(this._root=h)}return this._x0=r,this._y0=n,this._x1=o,this._y1=i,this},q.data=function(){var t=[];return this.visit((function(e){if(!e.length)do{t.push(e.data)}while(e=e.next)})),t},q.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]]},q.find=function(t,e,r){var n,o,i,s,a,u,h,l=this._x0,c=this._y0,f=this._x1,d=this._y1,g=[],p=this._root;for(p&&g.push(new C(p,l,c,f,d)),null==r?r=1/0:(l=t-r,c=e-r,f=t+r,d=e+r,r*=r);u=g.pop();)if(!(!(p=u.node)||(o=u.x0)>f||(i=u.y0)>d||(s=u.x1)<l||(a=u.y1)<c))if(p.length){var m=(o+s)/2,w=(i+a)/2;g.push(new C(p[3],m,w,s,a),new C(p[2],o,w,m,a),new C(p[1],m,i,s,w),new C(p[0],o,i,m,w)),(h=(e>=w)<<1|t>=m)&&(u=g[g.length-1],g[g.length-1]=g[g.length-1-h],g[g.length-1-h]=u)}else{var y=t-+this._x.call(null,p.data),v=e-+this._y.call(null,p.data),x=y*y+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},q.remove=function(t){if(isNaN(i=+this._x.call(null,t))||isNaN(s=+this._y.call(null,t)))return this;var e,r,n,o,i,s,a,u,h,l,c,f,d=this._root,g=this._x0,p=this._y0,m=this._x1,w=this._y1;if(!d)return this;if(d.length)for(;;){if((h=i>=(a=(g+m)/2))?g=a:m=a,(l=s>=(u=(p+w)/2))?p=u:w=u,e=d,!(d=d[c=l<<1|h]))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)},q.removeAll=function(t){for(var e=0,r=t.length;e<r;++e)this.remove(t[e]);return this},q.root=function(){return this._root},q.size=function(){var t=0;return this.visit((function(e){if(!e.length)do{++t}while(e=e.next)})),t},q.visit=function(t){var e,r,n,o,i,s,a=[],u=this._root;for(u&&a.push(new C(u,this._x0,this._y0,this._x1,this._y1));e=a.pop();)if(!t(u=e.node,n=e.x0,o=e.y0,i=e.x1,s=e.y1)&&u.length){var h=(n+i)/2,l=(o+s)/2;(r=u[3])&&a.push(new C(r,h,l,i,s)),(r=u[2])&&a.push(new C(r,n,l,h,s)),(r=u[1])&&a.push(new C(r,h,o,i,l)),(r=u[0])&&a.push(new C(r,n,o,h,l))}return this},q.visitAfter=function(t){var e,r=[],n=[];for(this._root&&r.push(new C(this._root,this._x0,this._y0,this._x1,this._y1));e=r.pop();){var o=e.node;if(o.length){var i,s=e.x0,a=e.y0,u=e.x1,h=e.y1,l=(s+u)/2,c=(a+h)/2;(i=o[0])&&r.push(new C(i,s,a,l,c)),(i=o[1])&&r.push(new C(i,l,a,u,c)),(i=o[2])&&r.push(new C(i,s,c,l,h)),(i=o[3])&&r.push(new C(i,l,c,u,h))}n.push(e)}for(;e=n.pop();)t(e.node,e.x0,e.y0,e.x1,e.y1);return this},q.x=function(t){return arguments.length?(this._x=t,this):this._x},q.y=function(t){return arguments.length?(this._y=t,this):this._y};var $={value:()=>{}};function U(){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 K(n)}function K(t){this._=t}function B(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 G(t,e){for(var r,n=0,o=t.length;n<o;++n)if((r=t[n]).name===e)return r.value}function J(t,e,r){for(var n=0,o=t.length;n<o;++n)if(t[n].name===e){t[n]=$,t=t.slice(0,n).concat(t.slice(n+1));break}return null!=r&&t.push({name:e,value:r}),t}K.prototype=U.prototype={constructor:K,on:function(t,e){var r,n=this._,o=B(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]=J(n[r],t.name,e);else if(null==e)for(r in n)n[r]=J(n[r],t.name,null);return this}for(;++i<s;)if((r=(t=o[i]).type)&&(r=G(n[r],t.name)))return r},copy:function(){var t={},e=this._;for(var r in e)t[r]=e[r].slice();return new K(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 H=U;var W,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 ut(t,e,r){var n=new at;return n.restart(t,e,r),n}function ht(){et=(tt=nt.now())+rt,X=Q=0;try{!function(){it(),++X;for(var t,e=W;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=W,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:W=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(ht,t-nt.now()-rt)),Z&&(Z=clearInterval(Z))):(Z||(tt=nt.now(),Z=setInterval(lt,1e3)),X=1,ot(ht)))}at.prototype=ut.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:W=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 mt(t){var e,r=1,n=.001,o=1-Math.pow(n,1/300),i=0,s=.6,a=new Map,u=ut(c),h=H("tick","end"),l=function(){let t=1;return()=>(t=(1664525*t+1013904223)%ft)/ft}();function c(){f(),h.call("tick",e),r<n&&(u.stop(),h.call("end",e))}function f(n){var u,h,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)})),u=0;u<l;++u)null==(h=t[u]).fx?h.x+=h.vx*=s:(h.x=h.fx,h.vx=0),null==h.fy?h.y+=h.vy*=s:(h.y=h.fy,h.vy=0);return e}function d(){for(var e,r=0,n=t.length;r<n;++r){if((e=t[r]).index=r,null!=e.fx&&(e.x=e.fx),null!=e.fy&&(e.y=e.fy),isNaN(e.x)||isNaN(e.y)){var o=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 u.restart(c),e},stop:function(){return u.stop(),e},nodes:function(r){return arguments.length?(t=r,d(),a.forEach(g),e):t},alpha:function(t){return arguments.length?(r=+t,e):r},alphaMin:function(t){return arguments.length?(n=+t,e):n},alphaDecay:function(t){return arguments.length?(o=+t,e):+o},alphaTarget:function(t){return arguments.length?(i=+t,e):i},velocityDecay:function(t){return arguments.length?(s=1-t,e):1-s},randomSource:function(t){return arguments.length?(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,u,h=0,l=t.length;for(null==n?n=1/0:n*=n,h=0;h<l;++h)(s=(o=e-(a=t[h]).x)*o+(i=r-a.y)*i)<n&&(u=a,n=s);return u},on:function(t,r){return arguments.length>1?(h.on(t,r),e):h.on(t)}}}function wt(){var t,e,r,n,o,i=V(-30),s=1,a=1/0,u=.81;function h(r){var o,i=t.length,s=O(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,u=0;if(t.length){for(n=i=s=0;s<4;++s)(e=t[s])&&(r=Math.abs(e.value))&&(a+=e.value,u+=r,n+=r*e.x,i+=r*e.y);t.x=n/u,t.y=i/u}else{(e=t).x=e.data.x,e.y=e.data.y;do{a+=o[e.data.index]}while(e=e.next)}t.value=a}function f(t,i,h,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/u<g)return g<a&&(0===c&&(g+=(c=F(r))*c),0===f&&(g+=(f=F(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=F(r))*c),0===f&&(g+=(f=F(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 h.initialize=function(e,n){t=e,r=n,l()},h.strength=function(t){return arguments.length?(i="function"==typeof t?t:V(+t),l(),h):i},h.distanceMin=function(t){return arguments.length?(s=t*t,h):Math.sqrt(s)},h.distanceMax=function(t){return arguments.length?(a=t*t,h):Math.sqrt(a)},h.theta=function(t){return arguments.length?(u=t*t,h):Math.sqrt(u)},h}function yt(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=yt,u=function(t){return 1/Math.min(o[t.source.index],o[t.target.index])},h=V(30),l=1;function c(n){for(var o=0,a=t.length;o<l;++o)for(var u,h,c,f,d,g,p,m=0;m<a;++m)h=(u=t[m]).source,f=(c=u.target).x+c.vx-h.x-h.vx||F(s),d=c.y+c.vy-h.y-h.vy||F(s),f*=g=((g=Math.sqrt(f*f+d*d))-r[m])/g*n*e[m],d*=g,c.vx-=f*(p=i[m]),c.vy-=d*p,h.vx+=f*(p=1-p),h.vy+=d*p}function f(){if(n){var s,u,h=n.length,l=t.length,c=new Map(n.map(((t,e)=>[a(t,e,n),t])));for(s=0,o=new Array(h);s<l;++s)(u=t[s]).index=s,"object"!=typeof u.source&&(u.source=vt(c,u.source)),"object"!=typeof u.target&&(u.target=vt(c,u.target)),o[u.source.index]=(o[u.source.index]||0)+1,o[u.target.index]=(o[u.target.index]||0)+1;for(s=0,i=new Array(l);s<l;++s)u=t[s],i[s]=o[u.source.index]/(o[u.source.index]+o[u.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]=+u(t[r],r,t)}function g(){if(n)for(var e=0,o=t.length;e<o;++e)r[e]=+h(t[e],e,t)}return null==t&&(t=[]),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?(u="function"==typeof t?t:V(+t),d(),c):u},c.distance=function(t){return arguments.length?(h="function"==typeof t?t:V(+t),g(),c):h},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,u,h,l,c,f,d=e.length,g=0;g<i;++g)for(s=O(e,bt,Mt).visitAfter(a),t=0;t<d;++t)u=e[t],c=r[u.index],f=c*c,h=u.x+u.vx,l=u.y+u.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>h+g||i<h-g||r>l+g||s<l-g;if(a.index>u.index){var p=h-a.x-a.vx,m=l-a.y-a.vy,w=p*p+m*m;w<g*g&&(0===p&&(w+=(p=F(n))*p),0===m&&(w+=(m=F(n))*m),w=(g-(w=Math.sqrt(w)))/w*o,u.vx+=(p*=w)*(g=(d*=d)/(f+d)),u.vy+=(m*=w)*g,a.vx-=p*(g=1-g),a.vy-=m*g)}}}function a(t){if(t.data)return t.r=r[t.data.index];for(var e=t.r=0;e<4;++e)t[e]&&t[e].r>t.r&&(t.r=t[e].r)}function u(){if(e){var n,o,i=e.length;for(r=new Array(i),n=0;n<i;++n)o=e[n],r[o.index]=+t(o,n,e)}}return"function"!=typeof t&&(t=V(null==t?1:+t)),s.initialize=function(t,r){e=t,n=r,u()},s.iterations=function(t){return arguments.length?(i=+t,s):i},s.strength=function(t){return arguments.length?(o=+t,s):o},s.radius=function(e){return arguments.length?(t="function"==typeof e?e:V(+e),u(),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 Nt(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),u=[0,0],h=[],l={},c=[],f=100,d=100,g={none:{x:0,y:0}},p=[],m="force",w=!0,y=.1;function v(t){if(!w)return v;e.tick(),b();for(var n=0,o=h.length,i=void 0,s=t*y;n<o;++n)(i=h[n]).vx+=(g[r(i)].x-i.x)*s,i.vy+=(g[r(i)].y-i.y)*s}function x(){h&&function(){if(h&&h.length){if(void 0===r(h[0]))throw Error("Couldnt find the grouping attribute for the nodes. Make sure to set it up with forceInBox.groupBy('clusterAttr') before calling .links()");var t,u,g,m,w,y=(t=[],u=[],g={},{},w=[],m=function(t){var e={};return t.forEach((function(t){var n=r(t);e[n]||(e[n]={count:0,sumforceNodeSize:0})})),t.forEach((function(t){var o=r(t),i=n(t),s=e[o];s.count=s.count+1,s.sumforceNodeSize=s.sumforceNodeSize+Math.PI*(i*i)*1.3,e[o]=s})),e}(h),w=function(t){var e={},n=[];return t.forEach((function(t){var n,o,i,s,a,u=(o=(n=t).source,i=n.target,(s=r(l[o]))<=(a=r(l[i]))?"".concat(s,"~").concat(a):"".concat(a,"~").concat(s)),h=0;void 0!==e[u]&&(h=e[u]),h+=1,e[u]=h})),Object.entries(e).forEach((function(t){var e=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(m).forEach((function(e,r){var n=m[e];t.push({id:e,size:n.count,r:Math.sqrt(n.sumforceNodeSize/Math.PI)}),g[e]=r})),w.forEach((function(t){var e=t.source,r=t.target,n=g[e],o=g[r];void 0!==n&&void 0!==o&&u.push({source:n,target:o,count:t.count})})),{nodes:t,links:u});e=mt(y.nodes).force("x",St(f).strength(.1)).force("y",Nt(d).strength(.1)).force("collide",Et((function(t){return t.r})).iterations(4)).force("charge",wt().strength(o)).force("links",xt(y.nodes.length?y.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-u[0],y:t.y-u[1]}})),g}function M(t){l={},t.forEach((function(t){l[t.id]=t}))}return v.initialize=function(t){h=t,x()},v.template=function(t){return arguments.length?(m=t,x(),v):m},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?(w=t,v):w},v.strength=function(t){return arguments.length?(y=t,v):y},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||[]),h=t||[],v):h},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?(u=t,v):u},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},_t=function(){function t(t){void 0===t&&(t={}),this.options=t,this.id="d3force",this.options=e(e({},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.genericForceLayout=function(t,r,n){var o=this,i=e(e({},this.options),n),s=i.layoutInvisibles,a=r.getAllNodes(),u=r.getAllEdges();s||(a=a.filter((function(t){var e=(t.data||{}).visible;return e||void 0===e})),u=u.filter((function(t){var e=(t.data||{}).visible;return e||void 0===e})));var h=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})}));if(!this.running){var l=i.alphaMin,c=i.alphaDecay,f=i.alpha,d=i.nodeStrength,g=i.edgeStrength,p=i.linkDistance,m=i.clustering,w=i.clusterFociStrength,y=i.clusterEdgeDistance,v=i.clusterEdgeStrength,x=i.clusterNodeStrength,b=i.clusterNodeSize,M=i.collideStrength,E=void 0===M?1:M,S=i.center,N=void 0===S?[0,0]:S,A=i.preventOverlap,k=i.nodeSize,_=i.nodeSpacing,D=i.onTick,R=i.onLayoutEnd,I=i.forceSimulation;if(I)m&&((z=At()).nodes(h),z.links(u)),I.nodes(h),u&&(T=xt().id((function(t){return t.id})).links(u),g&&T.strength(g),p&&T.distance(p),I.force("link",T)),A&&this.overlapProcess(I,{nodeSize:k,nodeSpacing:_,collideStrength:E}),I.alpha(f).restart(),this.running=!0;else try{var z,C=wt();if(d&&C.strength(d),I=mt().nodes(h),m&&((z=At()).centerX(N[0]).centerY(N[1]).template("force").strength(w),u&&z.links(u),h&&z.nodes(h),z.forceLinkDistance(y).forceLinkStrength(v).forceCharge(x).forceNodeSize(b),I.force("group",z)),I.force("center",function(t,e){var r,n=1;function o(){var o,i,s=r.length,a=0,u=0;for(o=0;o<s;++o)a+=(i=r[o]).x,u+=i.y;for(a=(a/s-t)*n,u=(u/s-e)*n,o=0;o<s;++o)(i=r[o]).x-=a,i.y-=u}return null==t&&(t=0),null==e&&(e=0),o.initialize=function(t){r=t},o.x=function(e){return arguments.length?(t=+e,o):t},o.y=function(t){return arguments.length?(e=+t,o):e},o.strength=function(t){return arguments.length?(n=+t,o):n},o}(N[0],N[1])).force("charge",C).alpha(f).alphaDecay(c).alphaMin(l),A&&this.overlapProcess(I,{nodeSize:k,nodeSpacing:_,collideStrength:E}),u){var T=xt().id((function(t){return t.id})).links(u);g&&T.strength(g),p&&T.distance(p),I.force("link",T)}I.on("tick",(function(){null==D||D({nodes:Dt(h),edges:Rt(u)})})).on("end",(function(){o.running=!1,null==R||R({nodes:Dt(h),edges:Rt(u)})})),this.running=!0}catch(t){this.running=!1,console.warn(t)}var P=Dt(h);return t&&P.forEach((function(t){return r.mergeNodeData(t.id,{x:t.data.x,y:t.data.y})})),{nodes:P,edges:u}}},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}:w(i)?i:function(){return 0},o)if(w(o))r=function(t){return o(t)+n(t)};else if(h(o)){var a=(o[0]>o[1]?o[0]:o[1])/2;r=function(t){return a+n(t)}}else if(l(o)){var u=o/2;r=function(t){return u+n(t)}}else r=function(){return 10};else r=function(t){return t.size?h(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",Et(r).strength(s))},t}(),Dt=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 It{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 It({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 zt(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 Ct={maxIteration:500,gravity:10,animate:!0,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.options=e(e({},Ct),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.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 u=this.formatOptions(i,r),h=u.width,c=u.height,f=u.nodeSize,d=u.getMass,g=u.nodeStrength,p=u.edgeStrength,m=u.linkDistance,w=s.map((function(t){return e(e({},t),{data:e(e({},t.data),{x:l(t.data.x)?t.data.x:Math.random()*h,y:l(t.data.y)?t.data.y:Math.random()*c,size:f(t)||30,mass:d(t),nodeStrength:g(t)})})})),y=a.map((function(t){return e(e({},t),{data:e(e({},t.data),{edgeStrength:p(t),linkDistance:m(t,r.getNode(t.source),r.getNode(t.target))})})}));if(!(null==s?void 0:s.length))return{nodes:[],edges:a};var v={};s.forEach((function(t,e){v[t.id]={x:0,y:0}}));var x=new It({nodes:w,edges:y});this.formatCentripetal(u,x);var b=u.maxIteration,M=u.animate,E=u.minMovement,S=u.onLayoutEnd,N=u.onTick;if(!M){for(var A=0;(this.judgingDistance>E||A<1)&&A<b;A++)this.runOneStep(x,r,A,v,u),this.updatePosition(r,x,v,u),t&&w.forEach((function(t){return r.mergeNodeData(t.id,{x:t.data.x,y:t.data.y})})),null==N||N({nodes:qt(r,w),edges:a});t&&w.forEach((function(t){return r.mergeNodeData(t.id,{x:t.data.x,y:t.data.y})}));var k={nodes:qt(r,w),edges:a};return null==S||S(k),k}if("undefined"!=typeof window){var _=0;return this.timeInterval=window.setInterval((function(){s&&(o.runOneStep(x,r,_,v,u),o.updatePosition(r,x,v,u),t&&w.forEach((function(t){return r.mergeNodeData(t.id,{x:t.data.x,y:t.data.y})})),null==N||N({nodes:qt(r,w),edges:a}),(++_>=b||o.judgingDistance<E)&&(null==S||S({nodes:qt(r,w),edges:a}),window.clearInterval(o.timeInterval)))}),0),{nodes:qt(r,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;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=y(0,t.nodeSpacing);t.nodeSize?h(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?h(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?y(1,t.linkDistance):function(t){return 1+r.nodeSize(e.getNode(t.source))+r.nodeSize(e.getNode(t.target))},r.nodeStrength=y(1,t.nodeStrength),r.edgeStrength=y(1,t.edgeStrength),t},t.prototype.formatCentripetal=function(t,e){var r,n=t.centripetalOptions,o=t.center,i=t.clusterNodeStrength,s=t.leafCluster,a=t.clustering,u=t.nodeClusterBy,h=e.getAllNodes(),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&&u&&(r=Pt(e,u),c=Array.from(new Set(null==h?void 0:h.map((function(t){return t.data[u]}))))||[],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=Lt(s))}else n=void 0;return{x:null==n?void 0:n.x,y:null==n?void 0:n.y}}})),a&&u){r||(r=Pt(e,u)),c||(c=Array.from(new Set(h.map((function(t){return t.data[u]}))))),c=c.filter((function(t){return void 0!==t}));var f={};c.forEach((function(t){var r=h.filter((function(e){return e.data[u]===t})).map((function(t){return e.getNode(t.id)}));f[t]=Lt(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[u]];return{x:null==e?void 0:e.x,y:null==e?void 0:e.y}}})}var d=t.centripetalOptions,g=d.leaf,p=d.single,m=d.others;g&&"function"!=typeof g&&(t.centripetalOptions.leaf=function(){return g}),p&&"function"!=typeof p&&(t.centripetalOptions.single=function(){return p}),m&&"function"!=typeof m&&(t.centripetalOptions.others=function(){return m})},t.prototype.runOneStep=function(t,e,r,n,o){var i={},s=t.getAllNodes(),a=t.getAllEdges();if(null==s?void 0:s.length){var u=o.monitor;this.calRepulsive(t,i,o),a&&this.calAttractive(t,i),this.calGravity(t,e,i,o),this.updateVelocity(t,i,n,o),u&&u({energy:this.calTotalEnergy(i,s),nodes:e.getAllNodes(),edges:e.getAllEdges(),iterations:r})}},t.prototype.calTotalEnergy=function(t,e){if(!(null==e?void 0:e.length))return 0;var r=0;return e.forEach((function(e,n){var o=t[e.id].x,i=t[e.id].y,s=o*o+i*i,a=e.data.mass;r+=(void 0===a?1:a)*s*.5})),r},t.prototype.calRepulsive=function(t,e,r){var n=r.factor,o=r.coulombDisScale;!function(t,e,r,n){var o=e/r,i=t.getAllNodes(),s=i.map((function(t,e){var r=t.data,n=r.nodeStrength;return{x:r.x,y:r.y,size:r.size,index:e,vx:0,vy:0,weight:o*n}})),a=O(s,(function(t){return t.x}),(function(t){return t.y})).visitAfter(zt);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,u=n-e,h=s*s+a*a,l=Math.sqrt(h)*h;if(u*u*.81<h){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 u=a.data.x-s.data.x,h=a.data.y-s.data.y;u||h||(u=.01*Math.random(),h=.01*Math.random());var l=Math.sqrt(u*u+h*h),c=u/l,f=h/l,d=edgeInfos[n]||{},g=d.linkDistance,p=void 0===g?200:g,m=d.edgeStrength,w=(p-l)*(void 0===m?200:m),y=1/(s.data.mass||1),v=1/(a.data.mass||1),x=c*w,b=f*w;e[o].x-=x*y,e[o].y-=b*y,e[i].x+=x*v,e[i].y+=b*v}}))},t.prototype.calGravity=function(t,e,r,n){var o=n.getCenter,s=t.getAllNodes(),a=e.getAllNodes(),u=e.getAllEdges(),h=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,m=p.mass,w=p.x,y=p.y,v=e.getNode(s),x=0,b=0,M=d,E=t.getDegree(s,"in"),S=t.getDegree(s,"out"),N=t.getDegree(s,"both"),A=null==o?void 0:o(v,N);if(A){var k=i(A,3);x=w-k[0],b=y-k[1],M=k[2]}else x=w-f[0],b=y-f[1];if(M&&(r[s].x-=M*x/m,r[s].y-=M*b/m),g){var _=g.leaf,D=g.single,R=g.others,I=g.center,z=(null==I?void 0:I(v,a,u,h,c))||{x:0,y:0,centerStrength:0},C=z.x,T=z.y,P=z.centerStrength;if(!l(C)||!l(T))return;var O=(w-C)/m,j=(y-T)/m;if(P&&(r[s].x-=P*O,r[s].y-=P*j),0===N){var L=D(v);if(!L)return;return r[s].x-=L*O,void(r[s].y-=L*j)}if(0===E||0===S){var q=_(v,a,u);if(!q)return;return r[s].x-=q*O,void(r[s].y-=q*j)}var V=R(v);if(!V)return;r[s].x-=V*O,r[s].y-=V*j}}))},t.prototype.updateVelocity=function(t,e,r,n){var o=n.damping,i=n.maxSpeed,s=n.interval,a=t.getAllNodes();(null==a?void 0:a.length)&&a.forEach((function(t){var n=t.id,a=(r[n].x+e[n].x*s)*o||.01,u=(r[n].y+e[n].y*s)*o||.01,h=Math.sqrt(a*a+u*u);if(h>i){var l=i/h;a*=l,u*=l}r[n]={x:a,y:u}}))},t.prototype.updatePosition=function(t,e,r,n){var o=this,i=n.distanceThresholdMode,s=n.interval,a=e.getAllNodes();if(null==a?void 0:a.length){var u=0;"max"===i?this.judgingDistance=-1/0:"min"===i&&(this.judgingDistance=1/0),a.forEach((function(n){var a=n.id,h=t.getNode(a);if(l(h.data.fx)&&l(h.data.fy))e.mergeNodeData(a,{x:h.data.fx,y:h.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:u+=d}}})),i&&"mean"!==i||(this.judgingDistance=u/a.length)}else this.judgingDistance=0},t.prototype.stop=function(){this.timeInterval&&"undefined"!=typeof window&&window.clearInterval(this.timeInterval)},t}(),Pt=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]=Ot(t,"leaf",r,e))})),n},Ot=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:jt(t,e,n,r,a)}},jt=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},Lt=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}},qt=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={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},Ft=function(){function t(t){void 0===t&&(t={}),this.options=t,this.id="grid",this.options=e(e({},Vt),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,u=o.condense,c=o.preventOverlapPadding,f=o.preventOverlap,d=o.rows,g=o.cols,p=o.nodeSpacing,w=o.nodeSize,x=o.width,b=o.height,M=o.layoutInvisibles,E=o.onLayoutEnd,S=o.position,N=o.sortBy,A=r.getAllNodes(),k=r.getAllEdges();M||(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 _=A.length;if(0===_){var D={nodes:[],edges:k};return null==E||E(D),D}if(1===_){t&&r.mergeNodeData(A[0].id,{x:s[0],y:s[1]});var R={nodes:[e(e({},A[0]),{data:e(e({},A[0].data),{x:s[0],y:s[1]})})],edges:k};return null==E||E(R),R}var I=A.map((function(t){return m(t)}));"id"===N||a(N)&&void 0!==I[0].data[N]||(N="degree"),"degree"===N?I.sort((function(t,e){return r.getDegree(e.id,"both")-r.getDegree(t.id,"both")})):"id"===N?I.sort((function(t,e){return l(e.id)&&l(t.id)?e.id-t.id:"".concat(t.id).localeCompare("".concat(e.id))})):I.sort((function(t,e){return e.data[N]-t.data[N]}));var z=x||"undefined"==typeof window?x:window.innerWidth,C=b||"undefined"==typeof window?b:window.innerHeight,T=_,P={rows:d,cols:g};if(null!=d&&null!=g)P.rows=d,P.cols=g;else if(null!=d&&null==g)P.rows=d,P.cols=Math.ceil(T/P.rows);else if(null==d&&null!=g)P.cols=g,P.rows=Math.ceil(T/P.cols);else{var O=Math.sqrt(T*C/z);P.rows=Math.round(O),P.cols=Math.round(z/C*O)}if(P.rows=Math.max(P.rows,1),P.cols=Math.max(P.cols,1),P.cols*P.rows>T)((L=$t(P))-1)*(j=Ut(P))>=T?$t(P,L-1):(j-1)*L>=T&&Ut(P,j-1);else for(;P.cols*P.rows<T;){var j,L=$t(P);((j=Ut(P))+1)*L>=T?Ut(P,j+1):$t(P,L+1)}var q=u?0:z/P.cols,V=u?0:C/P.rows;if(f||p){var F=y(10,p),$=v(30,w,!1);I.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=$(o)||30;h(i)?(e=i[0],n=i[1]):(e=i,n=i);var s=void 0!==F?F(t):c,a=e+s,u=n+s;q=Math.max(q,a),V=Math.max(V,u)}))}for(var U={},K={row:0,col:0},B={},G=0;G<I.length;G++){var J=I[G],H=void 0;if(S&&(H=S(r.getNode(J.id))),H&&(void 0!==H.row||void 0!==H.col)){var W={row:H.row,col:H.col};if(void 0===W.col)for(W.col=0;Kt(U,W);)W.col++;else if(void 0===W.row)for(W.row=0;Kt(U,W);)W.row++;B[J.id]=W,Bt(U,W)}Jt(J,s,q,V,B,P,K,U)}var Y={nodes:I,edges:k};return null==E||E(Y),t&&I.forEach((function(t){r.mergeNodeData(t.id,{x:t.data.x,y:t.data.y})})),Y},t}(),$t=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},Ut=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},Kt=function(t,e){return t["c-".concat(e.row,"-").concat(e.col)]||!1},Bt=function(t,e){return t["c-".concat(e.row,"-").concat(e.col)]=!0},Gt=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 u,h,l=o[t.id];if(l)u=l.col*r+r/2+e[0],h=l.row*n+n/2+e[1];else{for(;Kt(a,s);)Gt(i,s);u=s.col*r+r/2+e[0],h=s.row*n+n/2+e[1],Bt(a,s),Gt(i,s)}t.data.x=u,t.data.y=h};const Ht=Object.prototype.toString;function Wt(t){return Ht.call(t).endsWith("Array]")}function Yt(t){var e=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};if(!Wt(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 Xt(t){var e=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};if(!Wt(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 Qt(t){var e,r=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};if(!Wt(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(!Wt(r.output))throw new TypeError("output option must be an array if specified");e=r.output}else e=new Array(t.length);var n=Xt(t),o=Yt(t);if(n===o)throw new RangeError("minimum and maximum input values are equal. Cannot rescale a constant array");var i=r.min,s=void 0===i?r.autoMinMax?n:0:i,a=r.max,u=void 0===a?r.autoMinMax?o:1:a;if(s>=u)throw new RangeError("min option must be smaller than max option");for(var h=(u-s)/(o-n),l=0;l<t.length;l++)e[l]=(t[l]-n)*h+s;return e}const Zt=" ".repeat(2),te=" ".repeat(4);function ee(t,e={}){const{maxRows:r=15,maxColumns:n=10,maxNumSize:o=8,padMinus:i="auto"}=e;return`${t.constructor.name} {\n${Zt}[\n${te}${function(t,e,r,n,o){const{rows:i,columns:s}=t,a=Math.min(i,e),u=Math.min(s,r),h=[];if("auto"===o){o=!1;t:for(let e=0;e<a;e++)for(let r=0;r<u;r++)if(t.get(e,r)<0){o=!0;break t}}for(let e=0;e<a;e++){let r=[];for(let i=0;i<u;i++)r.push(re(t.get(e,i),n,o));h.push(`${r.join(" ")}`)}return u!==s&&(h[h.length-1]+=` ... ${s-r} more columns`),a!==i&&h.push(`... ${i-e} more rows`),h.join(`\n${te}`)}(t,r,n,o,i)}\n${Zt}]\n${Zt}rows: ${t.rows}\n${Zt}columns: ${t.columns}\n}`}function re(t,e,r){return(t>=0&&r?` ${ne(t,e-1)}`:ne(t,e)).padEnd(e)}function ne(t,e){let r=t.toString();if(r.length<=e)return r;let n=t.toFixed(e);if(n.length>e&&(n=t.toFixed(Math.max(0,e-(n.length-e)))),n.length<=e&&!n.startsWith("0.000")&&!n.startsWith("-0.000"))return n;let o=t.toExponential(e);return o.length>e&&(o=t.toExponential(Math.max(0,e-(o.length-e)))),o.slice(0)}function oe(t,e,r){let n=r?t.rows:t.rows-1;if(e<0||e>n)throw new RangeError("Row index out of range")}function ie(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 se(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 ae(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 ue(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 he(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 fe{static from1DArray(t,e,r){if(t*e!==r.length)throw new RangeError("data length does not match given dimensions");let n=new ge(t,e);for(let o=0;o<t;o++)for(let t=0;t<e;t++)n.set(o,t,r[o*e+t]);return n}static rowVector(t){let e=new ge(1,t.length);for(let r=0;r<t.length;r++)e.set(0,r,t[r]);return e}static columnVector(t){let e=new ge(t.length,1);for(let r=0;r<t.length;r++)e.set(r,0,t[r]);return e}static zeros(t,e){return new ge(t,e)}static ones(t,e){return new ge(t,e).fill(1)}static rand(t,e,r={}){if("object"!=typeof r)throw new TypeError("options must be an object");const{random:n=Math.random}=r;let o=new ge(t,e);for(let r=0;r<t;r++)for(let t=0;t<e;t++)o.set(r,t,n());return o}static randInt(t,e,r={}){if("object"!=typeof r)throw new TypeError("options must be an object");const{min:n=0,max:o=1e3,random:i=Math.random}=r;if(!Number.isInteger(n))throw new TypeError("min must be an integer");if(!Number.isInteger(o))throw new TypeError("max must be an integer");if(n>=o)throw new RangeError("min must be smaller than max");let s=o-n,a=new ge(t,e);for(let r=0;r<t;r++)for(let t=0;t<e;t++){let e=n+Math.round(i()*s);a.set(r,t,e)}return a}static eye(t,e,r){void 0===e&&(e=t),void 0===r&&(r=1);let n=Math.min(t,e),o=this.zeros(t,e);for(let t=0;t<n;t++)o.set(t,t,r);return o}static diag(t,e,r){let n=t.length;void 0===e&&(e=n),void 0===r&&(r=e);let o=Math.min(n,e,r),i=this.zeros(e,r);for(let e=0;e<o;e++)i.set(e,e,t[e]);return i}static min(t,e){t=this.checkMatrix(t),e=this.checkMatrix(e);let r=t.rows,n=t.columns,o=new ge(r,n);for(let i=0;i<r;i++)for(let r=0;r<n;r++)o.set(i,r,Math.min(t.get(i,r),e.get(i,r)));return o}static max(t,e){t=this.checkMatrix(t),e=this.checkMatrix(e);let r=t.rows,n=t.columns,o=new this(r,n);for(let i=0;i<r;i++)for(let r=0;r<n;r++)o.set(i,r,Math.max(t.get(i,r),e.get(i,r)));return o}static checkMatrix(t){return fe.isMatrix(t)?t:new ge(t)}static isMatrix(t){return null!=t&&"Matrix"===t.klass}get size(){return this.rows*this.columns}apply(t){if("function"!=typeof t)throw new TypeError("callback must be a function");for(let e=0;e<this.rows;e++)for(let r=0;r<this.columns;r++)t.call(this,e,r);return this}to1DArray(){let t=[];for(let e=0;e<this.rows;e++)for(let r=0;r<this.columns;r++)t.push(this.get(e,r));return t}to2DArray(){let t=[];for(let e=0;e<this.rows;e++){t.push([]);for(let r=0;r<this.columns;r++)t[e].push(this.get(e,r))}return t}toJSON(){return this.to2DArray()}isRowVector(){return 1===this.rows}isColumnVector(){return 1===this.columns}isVector(){return 1===this.rows||1===this.columns}isSquare(){return this.rows===this.columns}isEmpty(){return 0===this.rows||0===this.columns}isSymmetric(){if(this.isSquare()){for(let t=0;t<this.rows;t++)for(let e=0;e<=t;e++)if(this.get(t,e)!==this.get(e,t))return!1;return!0}return!1}isEchelonForm(){let t=0,e=0,r=-1,n=!0,o=!1;for(;t<this.rows&&n;){for(e=0,o=!1;e<this.columns&&!1===o;)0===this.get(t,e)?e++:1===this.get(t,e)&&e>r?(o=!0,r=e):(n=!1,o=!0);t++}return n}isReducedEchelonForm(){let t=0,e=0,r=-1,n=!0,o=!1;for(;t<this.rows&&n;){for(e=0,o=!1;e<this.columns&&!1===o;)0===this.get(t,e)?e++:1===this.get(t,e)&&e>r?(o=!0,r=e):(n=!1,o=!0);for(let r=e+1;r<this.rows;r++)0!==this.get(t,r)&&(n=!1);t++}return n}echelonForm(){let t=this.clone(),e=0,r=0;for(;e<t.rows&&r<t.columns;){let n=e;for(let o=e;o<t.rows;o++)t.get(o,r)>t.get(n,r)&&(n=o);if(0===t.get(n,r))r++;else{t.swapRows(e,n);let o=t.get(e,r);for(let n=r;n<t.columns;n++)t.set(e,n,t.get(e,n)/o);for(let n=e+1;n<t.rows;n++){let o=t.get(n,r)/t.get(e,r);t.set(n,r,0);for(let i=r+1;i<t.columns;i++)t.set(n,i,t.get(n,i)-t.get(e,i)*o)}e++,r++}}return t}reducedEchelonForm(){let t=this.echelonForm(),e=t.columns,r=t.rows,n=r-1;for(;n>=0;)if(0===t.maxRow(n))n--;else{let o=0,i=!1;for(;o<r&&!1===i;)1===t.get(n,o)?i=!0:o++;for(let r=0;r<n;r++){let i=t.get(r,o);for(let s=o;s<e;s++){let e=t.get(r,s)-i*t.get(n,s);t.set(r,s,e)}}n--}return t}set(){throw new Error("set method is unimplemented")}get(){throw new Error("get method is unimplemented")}repeat(t={}){if("object"!=typeof t)throw new TypeError("options must be an object");const{rows:e=1,columns:r=1}=t;if(!Number.isInteger(e)||e<=0)throw new TypeError("rows must be a positive integer");if(!Number.isInteger(r)||r<=0)throw new TypeError("columns must be a positive integer");let n=new ge(this.rows*e,this.columns*r);for(let t=0;t<e;t++)for(let e=0;e<r;e++)n.setSubMatrix(this,this.rows*t,this.columns*e);return n}fill(t){for(let e=0;e<this.rows;e++)for(let r=0;r<this.columns;r++)this.set(e,r,t);return this}neg(){return this.mulS(-1)}getRow(t){oe(this,t);let e=[];for(let r=0;r<this.columns;r++)e.push(this.get(t,r));return e}getRowVector(t){return ge.rowVector(this.getRow(t))}setRow(t,e){oe(this,t),e=se(this,e);for(let r=0;r<this.columns;r++)this.set(t,r,e[r]);return this}swapRows(t,e){oe(this,t),oe(this,e);for(let r=0;r<this.columns;r++){let n=this.get(t,r);this.set(t,r,this.get(e,r)),this.set(e,r,n)}return this}getColumn(t){ie(this,t);let e=[];for(let r=0;r<this.rows;r++)e.push(this.get(r,t));return e}getColumnVector(t){return ge.columnVector(this.getColumn(t))}setColumn(t,e){ie(this,t),e=ae(this,e);for(let r=0;r<this.rows;r++)this.set(r,t,e[r]);return this}swapColumns(t,e){ie(this,t),ie(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=se(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=se(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=se(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=se(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=ae(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=ae(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=ae(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=ae(this,t);for(let e=0;e<this.rows;e++)for(let r=0;r<this.columns;r++)this.set(e,r,this.get(e,r)/t[e]);return this}mulRow(t,e){oe(this,t);for(let r=0;r<this.columns;r++)this.set(t,r,this.get(t,r)*e);return this}mulColumn(t,e){ie(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(oe(this,t),this.isEmpty())return NaN;let e=this.get(t,0);for(let r=1;r<this.columns;r++)this.get(t,r)>e&&(e=this.get(t,r));return e}maxRowIndex(t){oe(this,t),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(oe(this,t),this.isEmpty())return NaN;let e=this.get(t,0);for(let r=1;r<this.columns;r++)this.get(t,r)<e&&(e=this.get(t,r));return e}minRowIndex(t){oe(this,t),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(ie(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){ie(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(ie(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){ie(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){fe.isMatrix(t)&&(t=t.to1DArray());let e=this.to1DArray();if(e.length!==t.length)throw new RangeError("vectors do not have the same size");let r=0;for(let n=0;n<e.length;n++)r+=e[n]*t[n];return r}mmul(t){t=ge.checkMatrix(t);let e=this.rows,r=this.columns,n=t.columns,o=new ge(e,n),i=new Float64Array(r);for(let s=0;s<n;s++){for(let e=0;e<r;e++)i[e]=t.get(e,s);for(let t=0;t<e;t++){let e=0;for(let n=0;n<r;n++)e+=this.get(t,n)*i[n];o.set(t,s,e)}}return o}strassen2x2(t){t=ge.checkMatrix(t);let e=new ge(2,2);const r=this.get(0,0),n=t.get(0,0),o=this.get(0,1),i=t.get(0,1),s=this.get(1,0),a=t.get(1,0),u=this.get(1,1),h=t.get(1,1),l=(r+u)*(n+h),c=(s+u)*n,f=r*(i-h),d=u*(a-n),g=(r+o)*h,p=l+d-g+(o-u)*(a+h),m=f+g,w=c+d,y=l-c+f+(s-r)*(n+i);return e.set(0,0,p),e.set(0,1,m),e.set(1,0,w),e.set(1,1,y),e}strassen3x3(t){t=ge.checkMatrix(t);let e=new ge(3,3);const r=this.get(0,0),n=this.get(0,1),o=this.get(0,2),i=this.get(1,0),s=this.get(1,1),a=this.get(1,2),u=this.get(2,0),h=this.get(2,1),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),m=t.get(1,2),w=t.get(2,0),y=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,S=(-r+u+h)*(c-d+m),N=(-r+u)*(d-m),A=(u+h)*(-c+d),k=(-o+h+l)*(p+w-y),_=(o-l)*(p-y),D=o*w,R=(h+l)*(-w+y),I=(-o+s+a)*(m+w-v),z=(o-a)*(m-v),C=(s+a)*(-w+v),T=E+D+n*g,P=(r+n+o-i-s-h-l)*p+b+M+E+k+D+R,O=E+S+A+(r+n+o-s-a-u-h)*m+D+I+C,j=x+s*(-c+f+g-p-m-w+v)+b+E+D+I+z,L=x+b+M+E+a*y,q=D+I+z+C+i*d,V=E+S+N+h*(-c+d+g-p-m-w+y)+k+_+D,F=k+_+D+R+u*f,$=E+S+N+A+l*v;return e.set(0,0,T),e.set(0,1,P),e.set(0,2,O),e.set(1,0,j),e.set(1,1,L),e.set(1,2,q),e.set(2,0,V),e.set(2,1,F),e.set(2,2,$),e}mmulStrassen(t){t=ge.checkMatrix(t);let e=this.clone(),r=e.rows,n=e.columns,o=t.rows,i=t.columns;function s(t,e,r){let n=t.rows,o=t.columns;if(n===e&&o===r)return t;{let n=fe.zeros(e,r);return n=n.setSubMatrix(t,0,0),n}}n!==o&&console.warn(`Multiplying ${r} x ${n} and ${o} x ${i} matrix: dimensions do not match.`);let a=Math.max(r,o),u=Math.max(n,i);return e=s(e,a,u),function t(e,r,n,o){if(n<=512||o<=512)return e.mmul(r);n%2==1&&o%2==1?(e=s(e,n+1,o+1),r=s(r,n+1,o+1)):n%2==1?(e=s(e,n+1,o),r=s(r,n+1,o)):o%2==1&&(e=s(e,n,o+1),r=s(r,n,o+1));let i=parseInt(e.rows/2,10),a=parseInt(e.columns/2,10),u=e.subMatrix(0,i-1,0,a-1),h=r.subMatrix(0,i-1,0,a-1),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),m=t(fe.add(u,g),fe.add(h,p),i,a),w=t(fe.add(f,g),h,i,a),y=t(u,fe.sub(c,p),i,a),v=t(g,fe.sub(d,h),i,a),x=t(fe.add(u,l),p,i,a),b=t(fe.sub(f,u),fe.add(h,c),i,a),M=t(fe.sub(l,g),fe.add(d,p),i,a),E=fe.add(m,v);E.sub(x),E.add(M);let S=fe.add(y,x),N=fe.add(w,v),A=fe.sub(m,w);A.add(y),A.add(b);let k=fe.zeros(2*E.rows,2*E.columns);return k=k.setSubMatrix(E,0,0),k=k.setSubMatrix(S,E.rows,0),k=k.setSubMatrix(N,0,E.columns),k=k.setSubMatrix(A,E.rows,E.columns),k.subMatrix(0,n-1,0,o-1)}(e,t=s(t,a,u),a,u)}scaleRows(t={}){if("object"!=typeof t)throw new TypeError("options must be an object");const{min:e=0,max:r=1}=t;if(!Number.isFinite(e))throw new TypeError("min must be a number");if(!Number.isFinite(r))throw new TypeError("max must be a number");if(e>=r)throw new RangeError("min must be smaller than max");let n=new ge(this.rows,this.columns);for(let t=0;t<this.rows;t++){const o=this.getRow(t);o.length>0&&Qt(o,{min:e,max:r,output:o}),n.setRow(t,o)}return n}scaleColumns(t={}){if("object"!=typeof t)throw new TypeError("options must be an object");const{min:e=0,max:r=1}=t;if(!Number.isFinite(e))throw new TypeError("min must be a number");if(!Number.isFinite(r))throw new TypeError("max must be a number");if(e>=r)throw new RangeError("min must be smaller than max");let n=new ge(this.rows,this.columns);for(let t=0;t<this.columns;t++){const o=this.getColumn(t);o.length&&Qt(o,{min:e,max:r,output:o}),n.setColumn(t,o)}return n}flipRows(){const t=Math.ceil(this.columns/2);for(let e=0;e<this.rows;e++)for(let r=0;r<t;r++){let t=this.get(e,r),n=this.get(e,this.columns-1-r);this.set(e,r,n),this.set(e,this.columns-1-r,t)}return this}flipColumns(){const t=Math.ceil(this.rows/2);for(let e=0;e<this.columns;e++)for(let r=0;r<t;r++){let t=this.get(r,e),n=this.get(this.rows-1-r,e);this.set(r,e,n),this.set(this.rows-1-r,e,t)}return this}kroneckerProduct(t){t=ge.checkMatrix(t);let e=this.rows,r=this.columns,n=t.rows,o=t.columns,i=new ge(e*n,r*o);for(let s=0;s<e;s++)for(let e=0;e<r;e++)for(let r=0;r<n;r++)for(let a=0;a<o;a++)i.set(n*s+r,o*e+a,this.get(s,e)*t.get(r,a));return i}kroneckerSum(t){if(t=ge.checkMatrix(t),!this.isSquare()||!t.isSquare())throw new Error("Kronecker Sum needs two Square Matrices");let e=this.rows,r=t.rows,n=this.kroneckerProduct(ge.eye(r,r)),o=ge.eye(e,e).kroneckerProduct(t);return n.add(o)}transpose(){let t=new ge(this.columns,this.rows);for(let e=0;e<this.rows;e++)for(let r=0;r<this.columns;r++)t.set(r,e,this.get(e,r));return t}sortRows(t=de){for(let e=0;e<this.rows;e++)this.setRow(e,this.getRow(e).sort(t));return this}sortColumns(t=de){for(let e=0;e<this.columns;e++)this.setColumn(e,this.getColumn(e).sort(t));return this}subMatrix(t,e,r,n){ue(this,t,e,r,n);let o=new ge(e-t+1,n-r+1);for(let i=t;i<=e;i++)for(let e=r;e<=n;e++)o.set(i-t,e-r,this.get(i,e));return o}subMatrixRow(t,e,r){if(void 0===e&&(e=0),void 0===r&&(r=this.columns-1),e>r||e<0||e>=this.columns||r<0||r>=this.columns)throw new RangeError("Argument out of range");let n=new ge(t.length,r-e+1);for(let o=0;o<t.length;o++)for(let i=e;i<=r;i++){if(t[o]<0||t[o]>=this.rows)throw new RangeError(`Row index out of range: ${t[o]}`);n.set(o,i-e,this.get(t[o],i))}return n}subMatrixColumn(t,e,r){if(void 0===e&&(e=0),void 0===r&&(r=this.rows-1),e>r||e<0||e>=this.rows||r<0||r>=this.rows)throw new RangeError("Argument out of range");let n=new ge(r-e+1,t.length);for(let o=0;o<t.length;o++)for(let i=e;i<=r;i++){if(t[o]<0||t[o]>=this.columns)throw new RangeError(`Column index out of range: ${t[o]}`);n.set(i-e,o,this.get(i,t[o]))}return n}setSubMatrix(t,e,r){if((t=ge.checkMatrix(t)).isEmpty())return this;ue(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(!Wt(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(!Wt(e))throw new TypeError("column indices must be an array");for(let r=0;r<e.length;r++)if(e[r]<0||e[r]>=t.columns)throw new RangeError("column indices are out of range")}(this,e);let r=new ge(t.length,e.length);for(let n=0;n<t.length;n++){let o=t[n];for(let t=0;t<e.length;t++){let i=e[t];r.set(n,t,this.get(o,i))}}return r}trace(){let t=Math.min(this.rows,this.columns),e=0;for(let r=0;r<t;r++)e+=this.get(r,r);return e}clone(){let t=new ge(this.rows,this.columns);for(let e=0;e<this.rows;e++)for(let r=0;r<this.columns;r++)t.set(e,r,this.get(e,r));return t}sum(t){switch(t){case"row":return function(t){let e=he(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=he(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=he(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=he(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(!Wt(n))throw new TypeError("mean must be an array");return function(t,e,r){const n=t.rows,o=t.columns,i=[];for(let s=0;s<n;s++){let n=0,a=0,u=0;for(let e=0;e<o;e++)u=t.get(s,e)-r[s],n+=u,a+=u*u;e?i.push((a-n*n/o)/(o-1)):i.push((a-n*n/o)/o)}return i}(this,r,n);case"column":if(!Wt(n))throw new TypeError("mean must be an array");return function(t,e,r){const n=t.rows,o=t.columns,i=[];for(let s=0;s<o;s++){let o=0,a=0,u=0;for(let e=0;e<n;e++)u=t.get(e,s)-r[s],o+=u,a+=u*u;e?i.push((a-o*o/n)/(n-1)):i.push((a-o*o/n)/n)}return i}(this,r,n);case void 0:if("number"!=typeof n)throw new TypeError("mean must be a number");return function(t,e,r){const n=t.rows,o=t.columns,i=n*o;let s=0,a=0,u=0;for(let e=0;e<n;e++)for(let n=0;n<o;n++)u=t.get(e,n)-r,s+=u,a+=u*u;return e?(a-s*s/i)/(i-1):(a-s*s/i)/i}(this,r,n);default:throw new Error(`invalid option: ${t}`)}}standardDeviation(t,e){"object"==typeof t&&(e=t,t=void 0);const r=this.variance(t,e);if(void 0===t)return Math.sqrt(r);for(let t=0;t<r.length;t++)r[t]=Math.sqrt(r[t]);return r}center(t,e={}){if("object"==typeof t&&(e=t,t=void 0),"object"!=typeof e)throw new TypeError("options must be an object");const{center:r=this.mean(t)}=e;switch(t){case"row":if(!Wt(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(!Wt(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(!Wt(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(!Wt(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 ee(this,t)}}function de(t,e){return t-e}fe.prototype.klass="Matrix","undefined"!=typeof Symbol&&(fe.prototype[Symbol.for("nodejs.util.inspect.custom")]=function(){return ee(this)}),fe.random=fe.rand,fe.randomInt=fe.randInt,fe.diagonal=fe.diag,fe.prototype.diagonal=fe.prototype.diag,fe.identity=fe.eye,fe.prototype.negate=fe.prototype.neg,fe.prototype.tensorProduct=fe.prototype.kroneckerProduct;class ge extends fe{constructor(t,e){if(super(),ge.isMatrix(t))return t.clone();if(Number.isInteger(t)&&t>=0){if(this.data=[],!(Number.isInteger(e)&&e>=0))throw new TypeError("nColumns must be a positive integer");for(let r=0;r<t;r++)this.data.push(new Float64Array(e))}else{if(!Wt(t))throw new TypeError("First argument must be a positive number or an array");{const r=t;if("number"!=typeof(e=(t=r.length)?r[0].length:0))throw new TypeError("Data must be a 2D array with at least one element");this.data=[];for(let n=0;n<t;n++){if(r[n].length!==e)throw new RangeError("Inconsistent array dimensions");if(!r[n].every((t=>"number"==typeof t)))throw new TypeError("Input data contains non-numeric values");this.data.push(Float64Array.from(r[n]))}}}this.rows=t,this.columns=e}set(t,e,r){return this.data[t][e]=r,this}get(t,e){return this.data[t][e]}removeRow(t){return oe(this,t),this.data.splice(t,1),this.rows-=1,this}addRow(t,e){return void 0===e&&(e=t,t=this.rows),oe(this,t,!0),e=Float64Array.from(se(this,e)),this.data.splice(t,0,e),this.rows+=1,this}removeColumn(t){ie(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),ie(this,t,!0),e=ae(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}}(fe,ge);class pe extends fe{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 me(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 we{constructor(t,e={}){if((t=pe.checkMatrix(t)).isEmpty())throw new Error("Matrix must be non-empty");let r=t.rows,n=t.columns;const{computeLeftSingularVectors:o=!0,computeRightSingularVectors:i=!0,autoTranspose:s=!1}=e;let a,u=Boolean(o),h=Boolean(i),l=!1;if(r<n)if(s){a=t.transpose(),r=a.rows,n=a.columns,l=!0;let e=u;u=h,h=e}else a=t.clone(),console.warn("Computing SVD on a matrix with more columns than rows. Consider enabling autoTranspose");else a=t.clone();let c=Math.min(r,n),f=Math.min(r+1,n),d=new Float64Array(f),g=new ge(r,c),p=new ge(n,n),m=new Float64Array(n),w=new Float64Array(r),y=new Float64Array(f);for(let t=0;t<f;t++)y[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]=me(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))}m[e]=a.get(t,e)}if(u&&t<v)for(let e=t;e<r;e++)g.set(e,t,a.get(e,t));if(t<x){m[t]=0;for(let e=t+1;e<n;e++)m[t]=me(m[t],m[e]);if(0!==m[t]){m[t+1]<0&&(m[t]=0-m[t]);for(let e=t+1;e<n;e++)m[e]/=m[t];m[t+1]+=1}if(m[t]=-m[t],t+1<r&&0!==m[t]){for(let e=t+1;e<r;e++)w[e]=0;for(let e=t+1;e<r;e++)for(let r=t+1;r<n;r++)w[e]+=m[r]*a.get(e,r);for(let e=t+1;e<n;e++){let n=-m[e]/m[t+1];for(let o=t+1;o<r;o++)a.set(o,e,a.get(o,e)+n*w[o])}}if(h)for(let e=t+1;e<n;e++)p.set(e,t,m[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&&(m[x]=a.get(x,M-1)),m[M-1]=0,u){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(h)for(let t=n-1;t>=0;t--){if(t<x&&0!==m[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,S=0,N=Number.EPSILON;for(;M>0;){let t,e;for(t=M-2;t>=-1&&-1!==t;t--){const e=Number.MIN_VALUE+N*Math.abs(d[t]+Math.abs(d[t+1]));if(Math.abs(m[t])<=e||Number.isNaN(m[t])){m[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(m[r]):0)+(r!==t+1?Math.abs(m[r-1]):0);if(Math.abs(d[r])<=N*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=m[M-2];m[M-2]=0;for(let r=M-2;r>=t;r--){let o=me(d[r],e),i=d[r]/o,s=e/o;if(d[r]=o,r!==t&&(e=-s*m[r-1],m[r-1]=i*m[r-1]),h)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=m[t-1];m[t-1]=0;for(let n=t;n<M;n++){let o=me(d[n],e),i=d[n]/o,s=e/o;if(d[n]=o,e=-s*m[n],m[n]=i*m[n],u)for(let e=0;e<r;e++)o=i*g.get(e,n)+s*g.get(e,t-1),g.set(e,t-1,-s*g.get(e,n)+i*g.get(e,t-1)),g.set(e,n,o)}break}case 3:{const e=Math.max(Math.abs(d[M-1]),Math.abs(d[M-2]),Math.abs(m[M-2]),Math.abs(d[t]),Math.abs(m[t])),o=d[M-1]/e,i=d[M-2]/e,s=m[M-2]/e,a=d[t]/e,l=m[t]/e,c=((i+o)*(i-o)+s*s)/2,f=o*s*(o*s);let w=0;0===c&&0===f||(w=c<0?0-Math.sqrt(c*c+f):Math.sqrt(c*c+f),w=f/(c+w));let y=(a+o)*(a-o)+w,v=a*l;for(let e=t;e<M-1;e++){let o=me(y,v);0===o&&(o=Number.MIN_VALUE);let i=y/o,s=v/o;if(e!==t&&(m[e-1]=o),y=i*d[e]+s*m[e],m[e]=i*m[e]-s*d[e],v=s*d[e+1],d[e+1]=i*d[e+1],h)for(let t=0;t<n;t++)o=i*p.get(t,e)+s*p.get(t,e+1),p.set(t,e+1,-s*p.get(t,e)+i*p.get(t,e+1)),p.set(t,e,o);if(o=me(y,v),0===o&&(o=Number.MIN_VALUE),i=y/o,s=v/o,d[e]=o,y=i*m[e]+s*d[e+1],d[e+1]=-s*m[e]+i*d[e+1],v=s*m[e+1],m[e+1]=i*m[e+1],u&&e<r-1)for(let t=0;t<r;t++)o=i*g.get(t,e)+s*g.get(t,e+1),g.set(t,e+1,-s*g.get(t,e)+i*g.get(t,e+1)),g.set(t,e,o)}m[M-2]=y,S+=1;break}case 4:if(d[t]<=0&&(d[t]=d[t]<0?-d[t]:0,h))for(let e=0;e<=E;e++)p.set(e,t,-p.get(e,t));for(;t<E&&!(d[t]>=d[t+1]);){let e=d[t];if(d[t]=d[t+1],d[t+1]=e,h&&t<n-1)for(let r=0;r<n;r++)e=p.get(r,t+1),p.set(r,t+1,p.get(r,t)),p.set(r,t,e);if(u&&t<r-1)for(let n=0;n<r;n++)e=g.get(n,t+1),g.set(n,t+1,g.get(n,t)),g.set(n,t,e);t++}S=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=ge.zeros(n,n);for(let t=0;t<n;t++)Math.abs(this.s[t])<=r?o.set(t,t,0):o.set(t,t,1/this.s[t]);let i=this.U,s=this.rightSingularVectors,a=s.mmul(o),u=s.rows,h=i.rows,l=ge.zeros(u,h);for(let t=0;t<u;t++)for(let e=0;e<h;e++){let r=0;for(let o=0;o<n;o++)r+=a.get(t,o)*i.get(e,o);l.set(t,e,r)}return l.mmul(e)}solveForDiagonal(t){return this.solve(ge.diag(t))}inverse(){let t=this.V,e=this.threshold,r=t.rows,n=t.columns,o=new ge(r,this.s.length);for(let i=0;i<r;i++)for(let r=0;r<n;r++)Math.abs(this.s[r])>e&&o.set(i,r,t.get(i,r)/this.s[r]);let i=this.U,s=i.rows,a=i.columns,u=new ge(r,s);for(let t=0;t<r;t++)for(let e=0;e<s;e++){let r=0;for(let n=0;n<a;n++)r+=o.get(t,n)*i.get(e,n);u.set(t,e,r)}return u}get condition(){return this.s[0]/this.s[Math.min(this.m,this.n)-1]}get norm2(){return this.s[0]}get rank(){let t=Math.max(this.m,this.n)*this.s[0]*Number.EPSILON,e=0,r=this.s;for(let n=0,o=r.length;n<o;n++)r[n]>t&&e++;return e}get diagonal(){return Array.from(this.s)}get threshold(){return Number.EPSILON/2*Math.max(this.m,this.n)*this.s[0]}get leftSingularVectors(){return this.U}get rightSingularVectors(){return this.V}get diagonalMatrix(){return ge.diag(this.s)}}var ye={center:[0,0],linkDistance:50},ve=function(){function t(t){void 0===t&&(t={}),this.options=t,this.id="mds",this.options=e(e({},ye),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,u=void 0===a?50:a,h=o.layoutInvisibles,l=o.onLayoutEnd,d=r.getAllNodes(),g=r.getAllEdges();if(h||(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}))),!d||0===d.length){var p={nodes:[],edges:g};return null==l||l(p),p}if(1===d.length){t&&r.mergeNodeData(d[0].id,{x:s[0],y:s[1]});var w={nodes:[e(e({},d[0]),{data:e(e({},d[0].data),{x:s[0],y:s[1]})})],edges:g};return null==l||l(w),w}var y=f({nodes:d,edges:g},!1),v=c(y);xe(v);var x=function(t,e){var r=[];return t.forEach((function(t){var n=[];t.forEach((function(t){n.push(t*e)})),r.push(n)})),r}(v,u),b=be(x),M=[];b.forEach((function(t,e){var r=m(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 E={nodes:M,edges:g};return null==l||l(E),E},t}(),xe=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)}))}))},be=function(t){var e=ge.mul(ge.pow(t,2),-.5),r=e.mean("row"),n=e.mean("column"),o=e.mean();e.add(o).subRowVector(r).subColumnVector(n);var i=new we(e),s=ge.sqrt(i.diagonalMatrix).diagonal();return i.leftSingularVectors.toJSON().map((function(t){return ge.mul([t],[s]).toJSON()[0].splice(0,2)}))},Me={iterations:10,height:10,width:10,speed:100,gravity:10,k:5},Ee=function(t,e,r,n,o,i){e.forEach((function(s,a){r[a]={x:0,y:0},e.forEach((function(e,u){if(a!==u&&o[a]===o[u]){var h=s.x-e.x,l=s.y-e.y,c=Math.sqrt(h*h+l*l);if(0===c){c=1;var f=a>u?1:-1;h=.01*f,l=.01*f}if(c<i(t[a])/2+i(t[u])/2){var d=n*n/c;r[a].x+=h/c*d,r[a].y+=l/c*d}}}))}))},Se=function(t,e,r,n,o,i,s,a){var u=i||s/10;return n&&e.forEach((function(e,r){var n=t[r].x-t[o].x,i=t[r].y-t[o].y,s=Math.sqrt(n*n+i*i),a=i/s,u=-n/s,h=Math.sqrt(e.x*e.x+e.y*e.y),l=Math.acos((a*e.x+u*e.y)/h);l>Math.PI/2&&(l-=Math.PI/2,a*=-1,u*=-1);var c=Math.cos(l)*h;e.x=a*c,e.y=u*c})),t.forEach((function(i,s){if(s!==o){var h=Math.sqrt(e[s].x*e[s].x+e[s].y*e[s].y);if(h>0&&s!==o){var l=Math.min(u*(r/800),h);if(i.x+=e[s].x/h*l,i.y+=e[s].y/h*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},Ne={maxIteration:1e3,focusNode:null,unitRadius:null,linkDistance:50,preventOverlap:!1,strictRadial:!0,maxPreventOverlapIteration:200,sortStrength:10},Ae=function(){function t(t){void 0===t&&(t={}),this.options=t,this.id="radial",this.options=e(e({},Ne),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),u=o.width,h=o.height,l=o.center,d=o.focusNode,g=o.unitRadius,p=o.nodeSize,w=o.nodeSpacing,y=o.strictRadial,v=o.preventOverlap,x=o.maxPreventOverlapIteration,b=o.sortBy,M=o.linkDistance,E=void 0===M?50:M,S=o.sortStrength,N=void 0===S?10:S,A=o.maxIteration,k=void 0===A?1e3:A,_=o.layoutInvisibles,D=o.onLayoutEnd,R=r.getAllNodes(),I=r.getAllEdges();if(_||(R=R.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}))),!R||0===R.length){var z={nodes:[],edges:I};return null==D||D(z),z}var C=u||"undefined"==typeof window?u:window.innerWidth,T=h||"undefined"==typeof window?h:window.innerHeight,P=l||[C/2,T/2];if(1===R.length){t&&r.mergeNodeData(R[0].id,{x:P[0],y:P[1]});var O={nodes:[e(e({},R[0]),{data:e(e({},R[0].data),{x:P[0],y:P[1]})})],edges:I};return null==D||D(O),O}var j=R[0];if(a(d)){for(var L=0;L<R.length;L++)if(R[L].id===d){j=R[L];break}}else j=d||R[0];var q=De(R,j.id),V=f({nodes:R,edges:I},!1),F=c(V),$=Ie(F,q);Re(F,q,$+1);var U=F[q],K=C-P[0]>P[0]?P[0]:C-P[0],B=T-P[1]>P[1]?P[1]:T-P[1];0===K&&(K=C/2),0===B&&(B=T/2);var G=Math.min(K,B),J=Math.max.apply(Math,s([],i(U),!1)),H=[],W=g||G/J;U.forEach((function(t,e){H[e]=t*W}));var Y,X=ke(R,F,E,H,W,b,N),Q=_e(X),Z=function(t,e,r){try{var n=ge.mul(ge.pow(e,2),-.5),o=n.mean("row"),i=n.mean("column"),s=n.mean();n.add(s).subRowVector(o).subColumnVector(i);var a=new we(n),u=ge.sqrt(a.diagonalMatrix).diagonal();return a.leftSingularVectors.toJSON().map((function(e){return ge.mul([e],[u]).toJSON()[0].splice(0,t)}))}catch(t){for(var h=[],l=0;l<e.length;l++){var c=Math.random()*r,f=Math.random()*r;h.push([c,f])}return h}}(E,X,E),tt=Z.map((function(t){var e=i(t,2),r=e[0],n=e[1];return{x:(isNaN(r)?Math.random()*E:r)-Z[q][0],y:(isNaN(n)?Math.random()*E:n)-Z[q][1]}}));if(this.run(k,tt,Q,X,H,q),v){Y=ze(p,w);var et={nodes:R,nodeSizeFunc:Y,positions:tt,radii:H,height:T,width:C,strictRadial:Boolean(y),focusIdx:q,iterations:x||200,k:tt.length/4.5};tt=function(t,r){for(var n=e(e({},Me),r),o=n.positions,i=n.iterations,s=n.width,a=n.k,u=n.speed,h=void 0===u?100:u,l=n.strictRadial,c=n.focusIdx,f=n.radii,d=void 0===f?[]:f,g=n.nodeSizeFunc,p=t.getAllNodes(),m=[],w=s/10,y=0;y<i;y++)o.forEach((function(t,e){m[e]={x:0,y:0}})),Ee(p,o,m,a,d,g),Se(o,m,h,l,c,w,s,d);return o}(r,et)}var rt=[];tt.forEach((function(t,e){var r=m(R[e]);r.data.x=t.x+P[0],r.data.y=t.y+P[1],rt.push(r)})),t&&rt.forEach((function(t){return r.mergeNodeData(t.id,{x:t.data.x,y:t.data.y})}));var nt={nodes:rt,edges:I};return null==D||D(nt),nt},t.prototype.run=function(t,e,r,n,o,i){for(var s=0;s<=t;s++){var a=s/t;this.oneIteration(a,e,o,n,r,i)}},t.prototype.oneIteration=function(t,e,r,n,o,i){var s=1-t;e.forEach((function(a,u){var h=d(a,{x:0,y:0}),l=0===h?0:1/h;if(u!==i){var c=0,f=0,g=0;e.forEach((function(t,e){if(u!==e){var r=d(a,t),i=0===r?0:1/r,s=n[e][u];g+=o[u][e],c+=o[u][e]*(t.x+s*(a.x-t.x)*i),f+=o[u][e]*(t.y+s*(a.y-t.y)*i)}}));var p=0===r[u]?0:1/r[u];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}(),ke=function(t,e,r,n,o,i,s){if(!t)return[];var u=[];if(e){var h={};e.forEach((function(e,l){var c=[];e.forEach((function(e,u){var f,d;if(l===u)c.push(0);else if(n[l]===n[u])if("data"===i)c.push(e*(Math.abs(l-u)*s)/(n[l]/o));else if(i){var g=void 0,p=void 0;if(h[t[l].id])g=h[t[l].id];else{var m=("id"===i?t[l].id:null===(f=t[l].data)||void 0===f?void 0:f[i])||0;g=a(m)?m.charCodeAt(0):m,h[t[l].id]=g}h[t[u].id]?p=h[t[u].id]:(m=("id"===i?t[u].id:null===(d=t[u].data)||void 0===d?void 0:d[i])||0,p=a(m)?m.charCodeAt(0):m,h[t[u].id]=p),c.push(e*(Math.abs(g-p)*s)/(n[l]/o))}else c.push(e*r/(n[l]/o));else{var w=(r+o)/2;c.push(e*w)}})),u.push(c)}))}return u},_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},De=function(t,e){var r=-1;return t.forEach((function(t,n){t.id===e&&(r=n)})),Math.max(r,0)},Re=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}},Ie=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},ze=function(t,e){var r;return r=l(e)?function(){return e}:w(e)?e:function(){return 0},t?h(t)?function(e){return(t[0]>t[1]?t[0]:t[1])+r(e)}:function(e){return t+r(e)}:function(t){return t.data.bboxSize?Math.max(t.data.bboxSize[0],t.data.bboxSize[1])+r(t):t.data.size?h(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)}},Ce={center:[0,0],width:300,height:300},Te=function(){function t(t){void 0===t&&(t={}),this.options=t,this.id="random",this.options=e(e({},Ce),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,u=o.layoutInvisibles,h=o.onLayoutEnd,l=r.getAllNodes();u||(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==h||h(p),p},t}(),Pe={circular:b,concentric:I,mds:ve,random:Te,grid:Ft,radial:Ae,force:Tt,d3force:_t};function Oe(t,e){Pe[t]=e}})(),n})()));
1
+ !function(t,e){"object"==typeof exports&&"object"==typeof module?module.exports=e():"function"==typeof define&&define.amd?define([],e):"object"==typeof exports?exports.Layout=e():t.Layout=e()}(self,(()=>(()=>{var t={161:t=>{"use strict";var e=Object.prototype.hasOwnProperty,r="~";function n(){}function o(t,e,r){this.fn=t,this.context=e,this.once=r||!1}function i(t,e,n,i,s){if("function"!=typeof n)throw new TypeError("The listener must be a function");var a=new o(n,i||t,s),u=r?r+e:e;return t._events[u]?t._events[u].fn?t._events[u]=[t._events[u],a]:t._events[u].push(a):(t._events[u]=a,t._eventsCount++),t}function s(t,e){0==--t._eventsCount?t._events=new n:delete t._events[e]}function a(){this._events=new n,this._eventsCount=0}Object.create&&(n.prototype=Object.create(null),(new n).__proto__||(r=!1)),a.prototype.eventNames=function(){var t,n,o=[];if(0===this._eventsCount)return o;for(n in t=this._events)e.call(t,n)&&o.push(r?n.slice(1):n);return Object.getOwnPropertySymbols?o.concat(Object.getOwnPropertySymbols(t)):o},a.prototype.listeners=function(t){var e=r?r+t:t,n=this._events[e];if(!n)return[];if(n.fn)return[n.fn];for(var o=0,i=n.length,s=new Array(i);o<i;o++)s[o]=n[o].fn;return s},a.prototype.listenerCount=function(t){var e=r?r+t:t,n=this._events[e];return n?n.fn?1:n.length:0},a.prototype.emit=function(t,e,n,o,i,s){var a=r?r+t:t;if(!this._events[a])return!1;var u,h,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(h=1,u=new Array(c-1);h<c;h++)u[h-1]=arguments[h];l.fn.apply(l.context,u)}else{var f,d=l.length;for(h=0;h<d;h++)switch(l[h].once&&this.removeListener(t,l[h].fn,void 0,!0),c){case 1:l[h].fn.call(l[h].context);break;case 2:l[h].fn.call(l[h].context,e);break;case 3:l[h].fn.call(l[h].context,e,n);break;case 4:l[h].fn.call(l[h].context,e,n,o);break;default:if(!u)for(f=1,u=new Array(c-1);f<c;f++)u[f-1]=arguments[f];l[h].fn.apply(l[h].context,u)}}return!0},a.prototype.on=function(t,e,r){return i(this,t,e,r,!1)},a.prototype.once=function(t,e,r){return i(this,t,e,r,!0)},a.prototype.removeListener=function(t,e,n,o){var i=r?r+t:t;if(!this._events[i])return this;if(!e)return s(this,i),this;var a=this._events[i];if(a.fn)a.fn!==e||o&&!a.once||n&&a.context!==n||s(this,i);else{for(var u=0,h=[],l=a.length;u<l;u++)(a[u].fn!==e||o&&!a[u].once||n&&a[u].context!==n)&&h.push(a[u]);h.length?this._events[i]=1===h.length?h[0]:h:s(this,i)}return this},a.prototype.removeAllListeners=function(t){var e;return t?(e=r?r+t:t,this._events[e]&&s(this,e)):(this._events=new n,this._eventsCount=0),this},a.prototype.off=a.prototype.removeListener,a.prototype.addListener=a.prototype.on,a.prefixed=r,a.EventEmitter=a,t.exports=a},825:(t,e,r)=>{var n=r(475),o=["calculateLayout"];t.exports=function(){var t=new Worker(URL.createObjectURL(new Blob(['(()=>{"use strict";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:()=>De});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},u=/-(\\w)/g,h=(function(t){return t.replace(u,(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&&Object.keys(t).length){var n=r({},t);return Object.keys(n).forEach((function(t){n[t]=p(n[t])})),n}return t},m=function(t){var e=p(t);return e.data=e.data||{},e},w=function(t){return"function"==typeof t};function y(t,e){return w(e)?e:l(e)?function(){return e}:function(){return t}}function v(t,e,r){return void 0===r&&(r=!0),e||0===e?w(e)?e:l(e)?function(){return e}:h(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?h(r)?r[0]>r[1]?r[0]:r[1]:g(r)?r.width>r.height?r.width:r.height:r:t}}var x={radius:null,startRadius:null,endRadius:null,startAngle:0,endAngle:2*Math.PI,clockwise:!0,divisions:1,ordering:null,angleRatio:1},M=function(){function t(t){void 0===t&&(t={}),this.options=t,this.id="circular",this.options=r(r({},x),t)}return t.prototype.execute=function(t,e){return this.genericCircularLayout(!1,t,e)},t.prototype.assign=function(t,e){var r=this;t.batch((function(){r.genericCircularLayout(!0,t,e)}))},t.prototype.genericCircularLayout=function(t,e,n){var i=r(r({},this.options),n),s=i.width,a=i.height,u=i.center,h=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,w=i.clockwise,x=i.nodeSpacing,M=i.nodeSize,N=i.layoutInvisibles,S=i.onLayoutEnd,k=e.getAllNodes(),A=e.getAllEdges();N||(k=k.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=k.length;if(0===D)return null==S||S({nodes:[],edges:[]}),{nodes:[],edges:[]};var I=o(E(s,a,u),3),R=I[0],_=I[1],z=I[2];if(1===D){t&&e.mergeNodeData(k[0].id,{x:z[0],y:z[1]});var T={nodes:[r(r({},k[0]),{data:r(r({},k[0].data),{x:z[0],y:z[1]})})],edges:A};return null==S||S(T),T}var P=(d-c)/D,C=i.radius,O=i.startRadius,j=i.endRadius;if(x){var q=y(10,x),V=v(10,M),L=-1/0;k.forEach((function(t){var e=V(t);L<e&&(L=e)}));var F=0;k.forEach((function(t,e){F+=0===e?L||10:(q(t)||0)+(L||10)})),C=F/(2*Math.PI)}else C||O||j?!O&&j?O=j:O&&!j&&(j=O):C=Math.min(_,R)/2;var $=P*g,U=[];U="topology"===p?b(e,k):"topology-directed"===p?b(e,k,!0):"degree"===p?function(t,e){var r=[];return e.forEach((function(t,e){r.push(m(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 m(t)}));for(var B=Math.ceil(D/h),K=0;K<D;++K){var G=C;G||null===O||null===j||(G=O+K*(j-O)/(D-1)),G||(G=10+100*K/(D-1));var W=c+K%B*$+2*Math.PI/h*Math.floor(K/B);w||(W=d-K%B*$-2*Math.PI/h*Math.floor(K/B)),U[K].data.x=z[0]+Math.cos(W)*G,U[K].data.y=z[1]+Math.sin(W)*G}t&&U.forEach((function(t){e.mergeNodeData(t.id,{x:t.data.x,y:t.data.y})}));var J={nodes:U,edges:A};return null==S||S(J),J},t}(),b=function(t,e,r){void 0===r&&(r=!1);var n=[m(e[0])],o={},i=e.length;o[e[0].id]=!0;var s=0;return e.forEach((function(a,u){if(0!==u)if(u!==i-1&&t.getDegree(a.id,"both")===t.getDegree(e[u+1].id,"both")&&!t.areNeighbors(n[s].id,a.id)||o[a.id]){for(var h=r?t.getSuccessors(n[s].id):t.getNeighbors(n[s].id),l=!1,c=0;c<h.length;c++){var f=h[c];if(t.getDegree(f.id)===t.getDegree(a.id)&&!o[f.id]){n.push(m(f)),o[f.id]=!0,l=!0;break}}for(var d=0;!l&&(o[e[d].id]||(n.push(m(e[d])),o[e[d].id]=!0,l=!0),++d!==i););}else n.push(m(a)),o[a.id]=!0,s++})),n},E=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]},N={nodeSize:30,minNodeSpacing:10,nodeSpacing:10,preventOverlap:!1,sweep:void 0,equidistant:!1,startAngle:1.5*Math.PI,clockwise:!0,maxLevelDiff:void 0,sortBy:"degree"},S=function(){function t(t){void 0===t&&(t={}),this.options=t,this.id="concentric",this.options=r(r({},N),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,u=o.height,c=o.sortBy,f=o.maxLevelDiff,d=o.sweep,p=o.clockwise,y=o.equidistant,v=o.minNodeSpacing,x=void 0===v?10:v,M=o.preventOverlap,b=o.startAngle,E=void 0===b?1.5*Math.PI:b,N=o.nodeSize,S=o.nodeSpacing,k=o.layoutInvisibles,A=o.onLayoutEnd,D=e.getAllNodes(),I=e.getAllEdges();k||(D=D.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 R=D.length;if(0===R){var _={nodes:[],edges:I};return null==A||A(_),_}var z=s||"undefined"==typeof window?s:window.innerWidth,T=u||"undefined"==typeof window?u:window.innerHeight,P=i||[z/2,T/2];if(1===R){t&&e.mergeNodeData(D[0].id,{x:P[0],y:P[1]});var C={nodes:[r(r({},D[0]),{data:r(r({},D[0].data),{x:P[0],y:P[1]})})],edges:I};return null==A||A(C),C}var O,j=[],q=0;O=h(N)?Math.max(N[0],N[1]):N,h(S)?q=Math.max(S[0],S[1]):l(S)&&(q=S),D.forEach((function(t){var e=m(t);j.push(e);var r=O,n=e.data;h(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)),O=Math.max(O,r),w(S)&&(q=Math.max(S(t),q))}));var V={};j.forEach((function(t,e){V[t.id]=e}));var L=c;a(L)&&void 0!==j[0].data[L]||(L="degree"),"degree"===L?j.sort((function(t,r){return e.getDegree(r.id,"both")-e.getDegree(t.id,"both")})):j.sort((function(t,e){return e.data[L]-t.data[L]}));var F=j[0],$=(f||("degree"===L?e.getDegree(F.id,"both"):F.data[L]))/4,U=[{nodes:[]}],B=U[0];j.forEach((function(t){if(B.nodes.length>0){var r="degree"===L?Math.abs(e.getDegree(B.nodes[0].id,"both")-e.getDegree(t.id,"both")):Math.abs(B.nodes[0].data[L]-t.data[L]);$&&r>=$&&(B={nodes:[]},U.push(B))}B.nodes.push(t)}));var K=O+(q||x);if(!M){var G=U.length>0&&U[0].nodes.length>1,W=(Math.min(z,T)/2-K)/(U.length+(G?1:0));K=Math.min(K,W)}var J=0;if(U.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&&M){var r=Math.cos(t.dTheta)-Math.cos(0),n=Math.sin(t.dTheta)-Math.sin(0),o=Math.sqrt(K*K/(r*r+n*n));J=Math.max(o,J)}t.r=J,J+=K})),y){for(var H=0,Y=0,X=0;X<U.length;X++){var Q=(U[X].r||0)-Y;H=Math.max(H,Q)}Y=0,U.forEach((function(t,e){0===e&&(Y=t.r||0),t.r=Y,Y+=H}))}U.forEach((function(t){var e=t.dTheta||0,r=t.r||0;t.nodes.forEach((function(t,n){var o=E+(p?1:-1)*e*n;t.data.x=P[0]+r*Math.cos(o),t.data.y=P[1]+r*Math.sin(o)}))})),t&&j.forEach((function(t){return e.mergeNodeData(t.id,{x:t.data.x,y:t.data.y})}));var Z={nodes:j,edges:I};return null==A||A(Z),Z},t}();function k(t,e,r,n){if(isNaN(e)||isNaN(r))return t;var o,i,s,a,u,h,l,c,f,d=t._root,g={data:n},p=t._x0,m=t._y0,w=t._x1,y=t._y1;if(!d)return t._root=g,t;for(;d.length;)if((h=e>=(i=(p+w)/2))?p=i:w=i,(l=r>=(s=(m+y)/2))?m=s:y=s,o=d,!(d=d[c=l<<1|h]))return o[c]=g,t;if(a=+t._x.call(null,d.data),u=+t._y.call(null,d.data),e===a&&r===u)return g.next=d,o?o[c]=g:t._root=g,t;do{o=o?o[c]=new Array(4):t._root=new Array(4),(h=e>=(i=(p+w)/2))?p=i:w=i,(l=r>=(s=(m+y)/2))?m=s:y=s}while((c=l<<1|h)==(f=(u>=s)<<1|a>=i));return o[f]=d,o[c]=g,t}function A(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 I(t){return t[1]}function R(t,e,r){var n=new _(null==e?D:e,null==r?I:r,NaN,NaN,NaN,NaN);return null==t?n:n.addAll(t)}function _(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 z(t){for(var e={data:t.data},r=e;t=t.next;)r=r.next={data:t.data};return e}var T=R.prototype=_.prototype;function P(t){return function(){return t}}function C(t){return 1e-6*(t()-.5)}T.copy=function(){var t,e,r=new _(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=z(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]=z(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),u=1/0,h=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<u&&(u=n),n>l&&(l=n),o<h&&(h=o),o>c&&(c=o));if(u>l||h>c)return this;for(this.cover(u,h).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,u=o-r||1,h=this._root;r>t||t>=o||n>e||e>=i;)switch(a=(e<n)<<1|t<r,(s=new Array(4))[a]=h,h=s,u*=2,a){case 0:o=r+u,i=n+u;break;case 1:r=o-u,i=n+u;break;case 2:o=r+u,n=i-u;break;case 3:r=o-u,n=i-u}this._root&&this._root.length&&(this._root=h)}return this._x0=r,this._y0=n,this._x1=o,this._y1=i,this},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,u,h,l=this._x0,c=this._y0,f=this._x1,d=this._y1,g=[],p=this._root;for(p&&g.push(new A(p,l,c,f,d)),null==r?r=1/0:(l=t-r,c=e-r,f=t+r,d=e+r,r*=r);u=g.pop();)if(!(!(p=u.node)||(o=u.x0)>f||(i=u.y0)>d||(s=u.x1)<l||(a=u.y1)<c))if(p.length){var m=(o+s)/2,w=(i+a)/2;g.push(new A(p[3],m,w,s,a),new A(p[2],o,w,m,a),new A(p[1],m,i,s,w),new A(p[0],o,i,m,w)),(h=(e>=w)<<1|t>=m)&&(u=g[g.length-1],g[g.length-1]=g[g.length-1-h],g[g.length-1-h]=u)}else{var y=t-+this._x.call(null,p.data),v=e-+this._y.call(null,p.data),x=y*y+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,u,h,l,c,f,d=this._root,g=this._x0,p=this._y0,m=this._x1,w=this._y1;if(!d)return this;if(d.length)for(;;){if((h=i>=(a=(g+m)/2))?g=a:m=a,(l=s>=(u=(p+w)/2))?p=u:w=u,e=d,!(d=d[c=l<<1|h]))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=[],u=this._root;for(u&&a.push(new A(u,this._x0,this._y0,this._x1,this._y1));e=a.pop();)if(!t(u=e.node,n=e.x0,o=e.y0,i=e.x1,s=e.y1)&&u.length){var h=(n+i)/2,l=(o+s)/2;(r=u[3])&&a.push(new A(r,h,l,i,s)),(r=u[2])&&a.push(new A(r,n,l,h,s)),(r=u[1])&&a.push(new A(r,h,o,i,l)),(r=u[0])&&a.push(new A(r,n,o,h,l))}return this},T.visitAfter=function(t){var e,r=[],n=[];for(this._root&&r.push(new A(this._root,this._x0,this._y0,this._x1,this._y1));e=r.pop();){var o=e.node;if(o.length){var i,s=e.x0,a=e.y0,u=e.x1,h=e.y1,l=(s+u)/2,c=(a+h)/2;(i=o[0])&&r.push(new A(i,s,a,l,c)),(i=o[1])&&r.push(new A(i,l,a,u,c)),(i=o[2])&&r.push(new A(i,s,c,l,h)),(i=o[3])&&r.push(new A(i,l,c,u,h))}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 O={value:()=>{}};function j(){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 q(n)}function q(t){this._=t}function V(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 L(t,e){for(var r,n=0,o=t.length;n<o;++n)if((r=t[n]).name===e)return r.value}function F(t,e,r){for(var n=0,o=t.length;n<o;++n)if(t[n].name===e){t[n]=O,t=t.slice(0,n).concat(t.slice(n+1));break}return null!=r&&t.push({name:e,value:r}),t}q.prototype=j.prototype={constructor:q,on:function(t,e){var r,n=this._,o=V(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]=F(n[r],t.name,e);else if(null==e)for(r in n)n[r]=F(n[r],t.name,null);return this}for(;++i<s;)if((r=(t=o[i]).type)&&(r=L(n[r],t.name)))return r},copy:function(){var t={},e=this._;for(var r in e)t[r]=e[r].slice();return new q(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;var U,B,K=0,G=0,W=0,J=0,H=0,Y=0,X="object"==typeof performance&&performance.now?performance:Date,Q="object"==typeof window&&window.requestAnimationFrame?window.requestAnimationFrame.bind(window):function(t){setTimeout(t,17)};function Z(){return H||(Q(tt),H=X.now()+Y)}function tt(){H=0}function et(){this._call=this._time=this._next=null}function rt(t,e,r){var n=new et;return n.restart(t,e,r),n}function nt(){H=(J=X.now())+Y,K=G=0;try{!function(){Z(),++K;for(var t,e=U;e;)(t=H-e._time)>=0&&e._call.call(void 0,t),e=e._next;--K}()}finally{K=0,function(){for(var t,e,r=U,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:U=e);B=t,it(n)}(),H=0}}function ot(){var t=X.now(),e=t-J;e>1e3&&(Y-=e,J=t)}function it(t){K||(G&&(G=clearTimeout(G)),t-H>24?(t<1/0&&(G=setTimeout(nt,t-X.now()-Y)),W&&(W=clearInterval(W))):(W||(J=X.now(),W=setInterval(ot,1e3)),K=1,Q(nt)))}et.prototype=rt.prototype={constructor:et,restart:function(t,e,r){if("function"!=typeof t)throw new TypeError("callback is not a function");r=(null==r?Z():+r)+(null==e?0:+e),this._next||B===this||(B?B._next=this:U=this,B=this),this._call=t,this._time=r,it()},stop:function(){this._call&&(this._call=null,this._time=1/0,it())}};const st=4294967296;function at(t){return t.x}function ut(t){return t.y}var ht=Math.PI*(3-Math.sqrt(5));function lt(t){var e,r=1,n=.001,o=1-Math.pow(n,1/300),i=0,s=.6,a=new Map,u=rt(c),h=$("tick","end"),l=function(){let t=1;return()=>(t=(1664525*t+1013904223)%st)/st}();function c(){f(),h.call("tick",e),r<n&&(u.stop(),h.call("end",e))}function f(n){var u,h,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)})),u=0;u<l;++u)null==(h=t[u]).fx?h.x+=h.vx*=s:(h.x=h.fx,h.vx=0),null==h.fy?h.y+=h.vy*=s:(h.y=h.fy,h.vy=0);return e}function d(){for(var e,r=0,n=t.length;r<n;++r){if((e=t[r]).index=r,null!=e.fx&&(e.x=e.fx),null!=e.fy&&(e.y=e.fy),isNaN(e.x)||isNaN(e.y)){var o=10*Math.sqrt(.5+r),i=r*ht;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 u.restart(c),e},stop:function(){return u.stop(),e},nodes:function(r){return arguments.length?(t=r,d(),a.forEach(g),e):t},alpha:function(t){return arguments.length?(r=+t,e):r},alphaMin:function(t){return arguments.length?(n=+t,e):n},alphaDecay:function(t){return arguments.length?(o=+t,e):+o},alphaTarget:function(t){return arguments.length?(i=+t,e):i},velocityDecay:function(t){return arguments.length?(s=1-t,e):1-s},randomSource:function(t){return arguments.length?(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,u,h=0,l=t.length;for(null==n?n=1/0:n*=n,h=0;h<l;++h)(s=(o=e-(a=t[h]).x)*o+(i=r-a.y)*i)<n&&(u=a,n=s);return u},on:function(t,r){return arguments.length>1?(h.on(t,r),e):h.on(t)}}}function ct(){var t,e,r,n,o,i=P(-30),s=1,a=1/0,u=.81;function h(r){var o,i=t.length,s=R(t,at,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,u=0;if(t.length){for(n=i=s=0;s<4;++s)(e=t[s])&&(r=Math.abs(e.value))&&(a+=e.value,u+=r,n+=r*e.x,i+=r*e.y);t.x=n/u,t.y=i/u}else{(e=t).x=e.data.x,e.y=e.data.y;do{a+=o[e.data.index]}while(e=e.next)}t.value=a}function f(t,i,h,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/u<g)return g<a&&(0===c&&(g+=(c=C(r))*c),0===f&&(g+=(f=C(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=C(r))*c),0===f&&(g+=(f=C(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 h.initialize=function(e,n){t=e,r=n,l()},h.strength=function(t){return arguments.length?(i="function"==typeof t?t:P(+t),l(),h):i},h.distanceMin=function(t){return arguments.length?(s=t*t,h):Math.sqrt(s)},h.distanceMax=function(t){return arguments.length?(a=t*t,h):Math.sqrt(a)},h.theta=function(t){return arguments.length?(u=t*t,h):Math.sqrt(u)},h}function ft(t){return t.index}function dt(t,e){var r=t.get(e);if(!r)throw new Error("node not found: "+e);return r}function gt(t){var e,r,n,o,i,s,a=ft,u=function(t){return 1/Math.min(o[t.source.index],o[t.target.index])},h=P(30),l=1;function c(n){for(var o=0,a=t.length;o<l;++o)for(var u,h,c,f,d,g,p,m=0;m<a;++m)h=(u=t[m]).source,f=(c=u.target).x+c.vx-h.x-h.vx||C(s),d=c.y+c.vy-h.y-h.vy||C(s),f*=g=((g=Math.sqrt(f*f+d*d))-r[m])/g*n*e[m],d*=g,c.vx-=f*(p=i[m]),c.vy-=d*p,h.vx+=f*(p=1-p),h.vy+=d*p}function f(){if(n){var s,u,h=n.length,l=t.length,c=new Map(n.map(((t,e)=>[a(t,e,n),t])));for(s=0,o=new Array(h);s<l;++s)(u=t[s]).index=s,"object"!=typeof u.source&&(u.source=dt(c,u.source)),"object"!=typeof u.target&&(u.target=dt(c,u.target)),o[u.source.index]=(o[u.source.index]||0)+1,o[u.target.index]=(o[u.target.index]||0)+1;for(s=0,i=new Array(l);s<l;++s)u=t[s],i[s]=o[u.source.index]/(o[u.source.index]+o[u.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]=+u(t[r],r,t)}function g(){if(n)for(var e=0,o=t.length;e<o;++e)r[e]=+h(t[e],e,t)}return null==t&&(t=[]),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?(u="function"==typeof t?t:P(+t),d(),c):u},c.distance=function(t){return arguments.length?(h="function"==typeof t?t:P(+t),g(),c):h},c}function pt(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,u,h,l,c,f,d=e.length,g=0;g<i;++g)for(s=R(e,pt,mt).visitAfter(a),t=0;t<d;++t)u=e[t],c=r[u.index],f=c*c,h=u.x+u.vx,l=u.y+u.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>h+g||i<h-g||r>l+g||s<l-g;if(a.index>u.index){var p=h-a.x-a.vx,m=l-a.y-a.vy,w=p*p+m*m;w<g*g&&(0===p&&(w+=(p=C(n))*p),0===m&&(w+=(m=C(n))*m),w=(g-(w=Math.sqrt(w)))/w*o,u.vx+=(p*=w)*(g=(d*=d)/(f+d)),u.vy+=(m*=w)*g,a.vx-=p*(g=1-g),a.vy-=m*g)}}}function a(t){if(t.data)return t.r=r[t.data.index];for(var e=t.r=0;e<4;++e)t[e]&&t[e].r>t.r&&(t.r=t[e].r)}function u(){if(e){var n,o,i=e.length;for(r=new Array(i),n=0;n<i;++n)o=e[n],r[o.index]=+t(o,n,e)}}return"function"!=typeof t&&(t=P(null==t?1:+t)),s.initialize=function(t,r){e=t,n=r,u()},s.iterations=function(t){return arguments.length?(i=+t,s):i},s.strength=function(t){return arguments.length?(o=+t,s):o},s.radius=function(e){return arguments.length?(t="function"==typeof e?e:P(+e),u(),s):t},s}function yt(t){var e,r,n,o=P(.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=P(null==t?0:+t)),i.initialize=function(t){e=t,s()},i.strength=function(t){return arguments.length?(o="function"==typeof t?t:P(+t),s(),i):o},i.x=function(e){return arguments.length?(t="function"==typeof e?e:P(+e),s(),i):t},i}function vt(t){var e,r,n,o=P(.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=P(null==t?0:+t)),i.initialize=function(t){e=t,s()},i.strength=function(t){return arguments.length?(o="function"==typeof t?t:P(+t),s(),i):o},i.y=function(e){return arguments.length?(t="function"==typeof e?e:P(+e),s(),i):t},i}function xt(){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),u=[0,0],h=[],l={},c=[],f=100,d=100,g={none:{x:0,y:0}},p=[],m="force",w=!0,y=.1;function v(t){if(!w)return v;e.tick(),M();for(var n=0,o=h.length,i=void 0,s=t*y;n<o;++n)(i=h[n]).vx+=(g[r(i)].x-i.x)*s,i.vy+=(g[r(i)].y-i.y)*s}function x(){h&&function(){if(h&&h.length){if(void 0===r(h[0]))throw Error("Couldnt find the grouping attribute for the nodes. Make sure to set it up with forceInBox.groupBy(\'clusterAttr\') before calling .links()");var t,u,g,m,w,y=(t=[],u=[],g={},{},w=[],m=function(t){var e={};return t.forEach((function(t){var n=r(t);e[n]||(e[n]={count:0,sumforceNodeSize:0})})),t.forEach((function(t){var o=r(t),i=n(t),s=e[o];s.count=s.count+1,s.sumforceNodeSize=s.sumforceNodeSize+Math.PI*(i*i)*1.3,e[o]=s})),e}(h),w=function(t){var e={},n=[];return t.forEach((function(t){var n,o,i,s,a,u=(o=(n=t).source,i=n.target,(s=r(l[o]))<=(a=r(l[i]))?"".concat(s,"~").concat(a):"".concat(a,"~").concat(s)),h=0;void 0!==e[u]&&(h=e[u]),h+=1,e[u]=h})),Object.entries(e).forEach((function(t){var e=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(m).forEach((function(e,r){var n=m[e];t.push({id:e,size:n.count,r:Math.sqrt(n.sumforceNodeSize/Math.PI)}),g[e]=r})),w.forEach((function(t){var e=t.source,r=t.target,n=g[e],o=g[r];void 0!==n&&void 0!==o&&u.push({source:n,target:o,count:t.count})})),{nodes:t,links:u});e=lt(y.nodes).force("x",yt(f).strength(.1)).force("y",vt(d).strength(.1)).force("collide",wt((function(t){return t.r})).iterations(4)).force("charge",ct().strength(i)).force("links",gt(y.nodes.length?y.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-u[0],y:t.y-u[1]}})),g}function b(t){l={},t.forEach((function(t){l[t.id]=t}))}return v.initialize=function(t){h=t,x()},v.template=function(t){return arguments.length?(m=t,x(),v):m},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?(w=t,v):w},v.strength=function(t){return arguments.length?(y=t,v):y},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||[]),h=t||[],v):h},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?(u=t,v):u},v.getFocis=M,v}var Mt={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},bt=function(){function t(t){void 0===t&&(t={}),this.options=t,this.id="d3force",this.options=r(r({},Mt),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.genericForceLayout=function(t,e,n){var o=this,i=r(r({},this.options),n),s=i.layoutInvisibles,a=e.getAllNodes(),u=e.getAllEdges();s||(a=a.filter((function(t){var e=(t.data||{}).visible;return e||void 0===e})),u=u.filter((function(t){var e=(t.data||{}).visible;return e||void 0===e})));var h=a.map((function(t){var e,n;return r(r({},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})}));if(!this.running){var l=i.alphaMin,c=i.alphaDecay,f=i.alpha,d=i.nodeStrength,g=i.edgeStrength,p=i.linkDistance,m=i.clustering,w=i.clusterFociStrength,y=i.clusterEdgeDistance,v=i.clusterEdgeStrength,x=i.clusterNodeStrength,M=i.clusterNodeSize,b=i.collideStrength,E=void 0===b?1:b,N=i.center,S=void 0===N?[0,0]:N,k=i.preventOverlap,A=i.nodeSize,D=i.nodeSpacing,I=i.onTick,R=i.onLayoutEnd,_=i.forceSimulation;if(_)m&&((z=xt()).nodes(h),z.links(u)),_.nodes(h),u&&(P=gt().id((function(t){return t.id})).links(u),g&&P.strength(g),p&&P.distance(p),_.force("link",P)),k&&this.overlapProcess(_,{nodeSize:A,nodeSpacing:D,collideStrength:E}),_.alpha(f).restart(),this.running=!0;else try{var z,T=ct();if(d&&T.strength(d),_=lt().nodes(h),m&&((z=xt()).centerX(S[0]).centerY(S[1]).template("force").strength(w),u&&z.links(u),h&&z.nodes(h),z.forceLinkDistance(y).forceLinkStrength(v).forceCharge(x).forceNodeSize(M),_.force("group",z)),_.force("center",function(t,e){var r,n=1;function o(){var o,i,s=r.length,a=0,u=0;for(o=0;o<s;++o)a+=(i=r[o]).x,u+=i.y;for(a=(a/s-t)*n,u=(u/s-e)*n,o=0;o<s;++o)(i=r[o]).x-=a,i.y-=u}return null==t&&(t=0),null==e&&(e=0),o.initialize=function(t){r=t},o.x=function(e){return arguments.length?(t=+e,o):t},o.y=function(t){return arguments.length?(e=+t,o):e},o.strength=function(t){return arguments.length?(n=+t,o):n},o}(S[0],S[1])).force("charge",T).alpha(f).alphaDecay(c).alphaMin(l),k&&this.overlapProcess(_,{nodeSize:A,nodeSpacing:D,collideStrength:E}),u){var P=gt().id((function(t){return t.id})).links(u);g&&P.strength(g),p&&P.distance(p),_.force("link",P)}_.on("tick",(function(){null==I||I({nodes:Et(h),edges:Nt(u)})})).on("end",(function(){o.running=!1,null==R||R({nodes:Et(h),edges:Nt(u)})})),this.running=!0}catch(t){this.running=!1,console.warn(t)}var C=Et(h);return t&&C.forEach((function(t){return e.mergeNodeData(t.id,{x:t.data.x,y:t.data.y})})),{nodes:C,edges:u}}},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}:w(i)?i:function(){return 0},o)if(w(o))r=function(t){return o(t)+n(t)};else if(h(o)){var a=(o[0]>o[1]?o[0]:o[1])/2;r=function(t){return a+n(t)}}else if(l(o)){var u=o/2;r=function(t){return u+n(t)}}else r=function(){return 10};else r=function(t){return t.size?h(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}(),Et=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})})}))},Nt=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 St(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,animate:!0,factor:1,edgeStrength:200,nodeStrength:1e3,coulombDisScale:.005,damping:.9,maxSpeed:500,minMovement:.4,interval:.02,linkDistance:200,clusterNodeStrength:20,preventOverlap:!0,distanceThresholdMode:"mean"},At=function(){function t(t){void 0===t&&(t={}),this.options=t,this.id="force",this.timeInterval=0,this.judgingDistance=0,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.genericForceLayout=function(t,e,n){var o=this,i=r(r({},this.options),n),a=e.getAllNodes(),u=e.getAllEdges();i.layoutInvisibles||(a=a.filter((function(t){return t.data.visible||void 0===t.data.visible})),u=u.filter((function(t){return t.data.visible||void 0===t.data.visible})));var h=this.formatOptions(i,e),c=h.width,f=h.height,d=h.nodeSize,g=h.getMass,p=h.nodeStrength,m=h.edgeStrength,w=h.linkDistance,y=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=u.map((function(t){return r(r({},t),{data:r(r({},t.data),{edgeStrength:m(t),linkDistance:w(t,e.getNode(t.source),e.getNode(t.target))})})}));if(!(null==a?void 0:a.length))return{nodes:[],edges:u};var x={};a.forEach((function(t,e){x[t.id]={x:0,y:0}}));var M=new s({nodes:y,edges:v});this.formatCentripetal(h,M);var b=h.maxIteration,E=h.animate,N=h.minMovement,S=h.onLayoutEnd,k=h.onTick;if(!E){for(var A=0;(this.judgingDistance>N||A<1)&&A<b;A++)this.runOneStep(M,e,A,x,h),this.updatePosition(e,M,x,h),t&&y.forEach((function(t){return e.mergeNodeData(t.id,{x:t.data.x,y:t.data.y})})),null==k||k({nodes:zt(e,y),edges:u});t&&y.forEach((function(t){return e.mergeNodeData(t.id,{x:t.data.x,y:t.data.y})}));var D={nodes:zt(e,y),edges:u};return null==S||S(D),D}if("undefined"!=typeof window){var I=0;return this.timeInterval=window.setInterval((function(){a&&(o.runOneStep(M,e,I,x,h),o.updatePosition(e,M,x,h),t&&y.forEach((function(t){return e.mergeNodeData(t.id,{x:t.data.x,y:t.data.y})})),null==k||k({nodes:zt(e,y),edges:u}),(++I>=b||o.judgingDistance<N)&&(null==S||S({nodes:zt(e,y),edges:u}),window.clearInterval(o.timeInterval)))}),0),{nodes:zt(e,y),edges:u}}},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=y(0,t.nodeSpacing);t.nodeSize?h(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?h(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?y(1,t.linkDistance):function(t){return 1+r.nodeSize(e.getNode(t.source))+r.nodeSize(e.getNode(t.target))},r.nodeStrength=y(1,t.nodeStrength),r.edgeStrength=y(1,t.edgeStrength),t},t.prototype.formatCentripetal=function(t,e){var r,n=t.centripetalOptions,o=t.center,i=t.clusterNodeStrength,s=t.leafCluster,a=t.clustering,u=t.nodeClusterBy,h=e.getAllNodes(),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&&u&&(r=Dt(e,u),c=Array.from(new Set(null==h?void 0:h.map((function(t){return t.data[u]}))))||[],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=_t(s))}else n=void 0;return{x:null==n?void 0:n.x,y:null==n?void 0:n.y}}})),a&&u){r||(r=Dt(e,u)),c||(c=Array.from(new Set(h.map((function(t){return t.data[u]}))))),c=c.filter((function(t){return void 0!==t}));var f={};c.forEach((function(t){var r=h.filter((function(e){return e.data[u]===t})).map((function(t){return e.getNode(t.id)}));f[t]=_t(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[u]];return{x:null==e?void 0:e.x,y:null==e?void 0:e.y}}})}var d=t.centripetalOptions,g=d.leaf,p=d.single,m=d.others;g&&"function"!=typeof g&&(t.centripetalOptions.leaf=function(){return g}),p&&"function"!=typeof p&&(t.centripetalOptions.single=function(){return p}),m&&"function"!=typeof m&&(t.centripetalOptions.others=function(){return m})},t.prototype.runOneStep=function(t,e,r,n,o){var i={},s=t.getAllNodes(),a=t.getAllEdges();if(null==s?void 0:s.length){var u=o.monitor;this.calRepulsive(t,i,o),a&&this.calAttractive(t,i),this.calGravity(t,e,i,o),this.updateVelocity(t,i,n,o),u&&u({energy:this.calTotalEnergy(i,s),nodes:e.getAllNodes(),edges:e.getAllEdges(),iterations:r})}},t.prototype.calTotalEnergy=function(t,e){if(!(null==e?void 0:e.length))return 0;var r=0;return e.forEach((function(e,n){var o=t[e.id].x,i=t[e.id].y,s=o*o+i*i,a=e.data.mass;r+=(void 0===a?1:a)*s*.5})),r},t.prototype.calRepulsive=function(t,e,r){var n=r.factor,o=r.coulombDisScale;!function(t,e,r,n){var o=e/r,i=t.getAllNodes(),s=i.map((function(t,e){var r=t.data,n=r.nodeStrength;return{x:r.x,y:r.y,size:r.size,index:e,vx:0,vy:0,weight:o*n}})),a=R(s,(function(t){return t.x}),(function(t){return t.y})).visitAfter(St);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,u=n-e,h=s*s+a*a,l=Math.sqrt(h)*h;if(u*u*.81<h){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 u=a.data.x-s.data.x,h=a.data.y-s.data.y;u||h||(u=.01*Math.random(),h=.01*Math.random());var l=Math.sqrt(u*u+h*h),c=u/l,f=h/l,d=edgeInfos[n]||{},g=d.linkDistance,p=void 0===g?200:g,m=d.edgeStrength,w=(p-l)*(void 0===m?200:m),y=1/(s.data.mass||1),v=1/(a.data.mass||1),x=c*w,M=f*w;e[o].x-=x*y,e[o].y-=M*y,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(),u=e.getAllEdges(),h=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,m=p.mass,w=p.x,y=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==i?void 0:i(v,S);if(k){var A=o(k,3);x=w-A[0],M=y-A[1],b=A[2]}else x=w-f[0],M=y-f[1];if(b&&(r[s].x-=b*x/m,r[s].y-=b*M/m),g){var D=g.leaf,I=g.single,R=g.others,_=g.center,z=(null==_?void 0:_(v,a,u,h,c))||{x:0,y:0,centerStrength:0},T=z.x,P=z.y,C=z.centerStrength;if(!l(T)||!l(P))return;var O=(w-T)/m,j=(y-P)/m;if(C&&(r[s].x-=C*O,r[s].y-=C*j),0===S){var q=I(v);if(!q)return;return r[s].x-=q*O,void(r[s].y-=q*j)}if(0===E||0===N){var V=D(v,a,u);if(!V)return;return r[s].x-=V*O,void(r[s].y-=V*j)}var L=R(v);if(!L)return;r[s].x-=L*O,r[s].y-=L*j}}))},t.prototype.updateVelocity=function(t,e,r,n){var o=n.damping,i=n.maxSpeed,s=n.interval,a=t.getAllNodes();(null==a?void 0:a.length)&&a.forEach((function(t){var n=t.id,a=(r[n].x+e[n].x*s)*o||.01,u=(r[n].y+e[n].y*s)*o||.01,h=Math.sqrt(a*a+u*u);if(h>i){var l=i/h;a*=l,u*=l}r[n]={x:a,y:u}}))},t.prototype.updatePosition=function(t,e,r,n){var o=this,i=n.distanceThresholdMode,s=n.interval,a=e.getAllNodes();if(null==a?void 0:a.length){var u=0;"max"===i?this.judgingDistance=-1/0:"min"===i&&(this.judgingDistance=1/0),a.forEach((function(n){var a=n.id,h=t.getNode(a);if(l(h.data.fx)&&l(h.data.fy))e.mergeNodeData(a,{x:h.data.fx,y:h.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:u+=d}}})),i&&"mean"!==i||(this.judgingDistance=u/a.length)}else this.judgingDistance=0},t.prototype.stop=function(){this.timeInterval&&"undefined"!=typeof window&&window.clearInterval(this.timeInterval)},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]=It(t,"leaf",r,e))})),n},It=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:Rt(t,e,n,r,a)}},Rt=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},_t=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}},zt=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={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},Pt=function(){function t(t){void 0===t&&(t={}),this.options=t,this.id="grid",this.options=r(r({},Tt),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,u=o.condense,c=o.preventOverlapPadding,f=o.preventOverlap,d=o.rows,g=o.cols,p=o.nodeSpacing,w=o.nodeSize,x=o.width,M=o.height,b=o.layoutInvisibles,E=o.onLayoutEnd,N=o.position,S=o.sortBy,k=e.getAllNodes(),A=e.getAllEdges();b||(k=k.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=k.length;if(0===D){var I={nodes:[],edges:A};return null==E||E(I),I}if(1===D){t&&e.mergeNodeData(k[0].id,{x:s[0],y:s[1]});var R={nodes:[r(r({},k[0]),{data:r(r({},k[0].data),{x:s[0],y:s[1]})})],edges:A};return null==E||E(R),R}var _=k.map((function(t){return m(t)}));"id"===S||a(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 l(e.id)&&l(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 z=x||"undefined"==typeof window?x:window.innerWidth,T=M||"undefined"==typeof window?M:window.innerHeight,P=D,C={rows:d,cols:g};if(null!=d&&null!=g)C.rows=d,C.cols=g;else if(null!=d&&null==g)C.rows=d,C.cols=Math.ceil(P/C.rows);else if(null==d&&null!=g)C.cols=g,C.rows=Math.ceil(P/C.cols);else{var O=Math.sqrt(P*T/z);C.rows=Math.round(O),C.cols=Math.round(z/T*O)}if(C.rows=Math.max(C.rows,1),C.cols=Math.max(C.cols,1),C.cols*C.rows>P)((q=Ct(C))-1)*(j=Ot(C))>=P?Ct(C,q-1):(j-1)*q>=P&&Ot(C,j-1);else for(;C.cols*C.rows<P;){var j,q=Ct(C);((j=Ot(C))+1)*q>=P?Ot(C,j+1):Ct(C,q+1)}var V=u?0:z/C.cols,L=u?0:T/C.rows;if(f||p){var F=y(10,p),$=v(30,w,!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=$(o)||30;h(i)?(r=i[0],n=i[1]):(r=i,n=i);var s=void 0!==F?F(t):c,a=r+s,u=n+s;V=Math.max(V,a),L=Math.max(L,u)}))}for(var U={},B={row:0,col:0},K={},G=0;G<_.length;G++){var W=_[G],J=void 0;if(N&&(J=N(e.getNode(W.id))),J&&(void 0!==J.row||void 0!==J.col)){var H={row:J.row,col:J.col};if(void 0===H.col)for(H.col=0;jt(U,H);)H.col++;else if(void 0===H.row)for(H.row=0;jt(U,H);)H.row++;K[W.id]=H,qt(U,H)}Lt(W,s,V,L,K,C,B,U)}var Y={nodes:_,edges:A};return null==E||E(Y),t&&_.forEach((function(t){e.mergeNodeData(t.id,{x:t.data.x,y:t.data.y})})),Y},t}(),Ct=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},Ot=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},jt=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},Vt=function(t,e){var r=t.cols||5;e.col++,e.col>=r&&(e.col=0,e.row++)},Lt=function(t,e,r,n,o,i,s,a){var u,h,l=o[t.id];if(l)u=l.col*r+r/2+e[0],h=l.row*n+n/2+e[1];else{for(;jt(a,s);)Vt(i,s);u=s.col*r+r/2+e[0],h=s.row*n+n/2+e[1],qt(a,s),Vt(i,s)}t.data.x=u,t.data.y=h};const Ft=Object.prototype.toString;function $t(t){return Ft.call(t).endsWith("Array]")}function Ut(t){var e=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};if(!$t(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 Bt(t){var e=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};if(!$t(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 Kt(t){var e,r=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};if(!$t(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(!$t(r.output))throw new TypeError("output option must be an array if specified");e=r.output}else e=new Array(t.length);var n=Bt(t),o=Ut(t);if(n===o)throw new RangeError("minimum and maximum input values are equal. Cannot rescale a constant array");var i=r.min,s=void 0===i?r.autoMinMax?n:0:i,a=r.max,u=void 0===a?r.autoMinMax?o:1:a;if(s>=u)throw new RangeError("min option must be smaller than max option");for(var h=(u-s)/(o-n),l=0;l<t.length;l++)e[l]=(t[l]-n)*h+s;return e}const Gt=" ".repeat(2),Wt=" ".repeat(4);function Jt(t,e={}){const{maxRows:r=15,maxColumns:n=10,maxNumSize:o=8,padMinus:i="auto"}=e;return`${t.constructor.name} {\\n${Gt}[\\n${Wt}${function(t,e,r,n,o){const{rows:i,columns:s}=t,a=Math.min(i,e),u=Math.min(s,r),h=[];if("auto"===o){o=!1;t:for(let e=0;e<a;e++)for(let r=0;r<u;r++)if(t.get(e,r)<0){o=!0;break t}}for(let e=0;e<a;e++){let r=[];for(let i=0;i<u;i++)r.push(Ht(t.get(e,i),n,o));h.push(`${r.join(" ")}`)}return u!==s&&(h[h.length-1]+=` ... ${s-r} more columns`),a!==i&&h.push(`... ${i-e} more rows`),h.join(`\\n${Wt}`)}(t,r,n,o,i)}\\n${Gt}]\\n${Gt}rows: ${t.rows}\\n${Gt}columns: ${t.columns}\\n}`}function Ht(t,e,r){return(t>=0&&r?` ${Yt(t,e-1)}`:Yt(t,e)).padEnd(e)}function Yt(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 Xt(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 Qt(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 Zt(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 te(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 ee(t,e,r,n,o){if(5!==arguments.length)throw new RangeError("expected 4 arguments");if(ne("startRow",e),ne("endRow",r),ne("startColumn",n),ne("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 re(t,e=0){let r=[];for(let n=0;n<t;n++)r.push(e);return r}function ne(t,e){if("number"!=typeof e)throw new TypeError(`${t} must be a number`)}function oe(t){if(t.isEmpty())throw new Error("Empty matrix has no elements to index")}class ie{static from1DArray(t,e,r){if(t*e!==r.length)throw new RangeError("data length does not match given dimensions");let n=new ae(t,e);for(let o=0;o<t;o++)for(let t=0;t<e;t++)n.set(o,t,r[o*e+t]);return n}static rowVector(t){let e=new ae(1,t.length);for(let r=0;r<t.length;r++)e.set(0,r,t[r]);return e}static columnVector(t){let e=new ae(t.length,1);for(let r=0;r<t.length;r++)e.set(r,0,t[r]);return e}static zeros(t,e){return new ae(t,e)}static ones(t,e){return new ae(t,e).fill(1)}static rand(t,e,r={}){if("object"!=typeof r)throw new TypeError("options must be an object");const{random:n=Math.random}=r;let o=new ae(t,e);for(let r=0;r<t;r++)for(let t=0;t<e;t++)o.set(r,t,n());return o}static randInt(t,e,r={}){if("object"!=typeof r)throw new TypeError("options must be an object");const{min:n=0,max:o=1e3,random:i=Math.random}=r;if(!Number.isInteger(n))throw new TypeError("min must be an integer");if(!Number.isInteger(o))throw new TypeError("max must be an integer");if(n>=o)throw new RangeError("min must be smaller than max");let s=o-n,a=new ae(t,e);for(let r=0;r<t;r++)for(let t=0;t<e;t++){let e=n+Math.round(i()*s);a.set(r,t,e)}return a}static eye(t,e,r){void 0===e&&(e=t),void 0===r&&(r=1);let n=Math.min(t,e),o=this.zeros(t,e);for(let t=0;t<n;t++)o.set(t,t,r);return o}static diag(t,e,r){let n=t.length;void 0===e&&(e=n),void 0===r&&(r=e);let o=Math.min(n,e,r),i=this.zeros(e,r);for(let e=0;e<o;e++)i.set(e,e,t[e]);return i}static min(t,e){t=this.checkMatrix(t),e=this.checkMatrix(e);let r=t.rows,n=t.columns,o=new ae(r,n);for(let i=0;i<r;i++)for(let r=0;r<n;r++)o.set(i,r,Math.min(t.get(i,r),e.get(i,r)));return o}static max(t,e){t=this.checkMatrix(t),e=this.checkMatrix(e);let r=t.rows,n=t.columns,o=new this(r,n);for(let i=0;i<r;i++)for(let r=0;r<n;r++)o.set(i,r,Math.max(t.get(i,r),e.get(i,r)));return o}static checkMatrix(t){return ie.isMatrix(t)?t:new ae(t)}static isMatrix(t){return null!=t&&"Matrix"===t.klass}get size(){return this.rows*this.columns}apply(t){if("function"!=typeof t)throw new TypeError("callback must be a function");for(let e=0;e<this.rows;e++)for(let r=0;r<this.columns;r++)t.call(this,e,r);return this}to1DArray(){let t=[];for(let e=0;e<this.rows;e++)for(let r=0;r<this.columns;r++)t.push(this.get(e,r));return t}to2DArray(){let t=[];for(let e=0;e<this.rows;e++){t.push([]);for(let r=0;r<this.columns;r++)t[e].push(this.get(e,r))}return t}toJSON(){return this.to2DArray()}isRowVector(){return 1===this.rows}isColumnVector(){return 1===this.columns}isVector(){return 1===this.rows||1===this.columns}isSquare(){return this.rows===this.columns}isEmpty(){return 0===this.rows||0===this.columns}isSymmetric(){if(this.isSquare()){for(let t=0;t<this.rows;t++)for(let e=0;e<=t;e++)if(this.get(t,e)!==this.get(e,t))return!1;return!0}return!1}isEchelonForm(){let t=0,e=0,r=-1,n=!0,o=!1;for(;t<this.rows&&n;){for(e=0,o=!1;e<this.columns&&!1===o;)0===this.get(t,e)?e++:1===this.get(t,e)&&e>r?(o=!0,r=e):(n=!1,o=!0);t++}return n}isReducedEchelonForm(){let t=0,e=0,r=-1,n=!0,o=!1;for(;t<this.rows&&n;){for(e=0,o=!1;e<this.columns&&!1===o;)0===this.get(t,e)?e++:1===this.get(t,e)&&e>r?(o=!0,r=e):(n=!1,o=!0);for(let r=e+1;r<this.rows;r++)0!==this.get(t,r)&&(n=!1);t++}return n}echelonForm(){let t=this.clone(),e=0,r=0;for(;e<t.rows&&r<t.columns;){let n=e;for(let o=e;o<t.rows;o++)t.get(o,r)>t.get(n,r)&&(n=o);if(0===t.get(n,r))r++;else{t.swapRows(e,n);let o=t.get(e,r);for(let n=r;n<t.columns;n++)t.set(e,n,t.get(e,n)/o);for(let n=e+1;n<t.rows;n++){let o=t.get(n,r)/t.get(e,r);t.set(n,r,0);for(let i=r+1;i<t.columns;i++)t.set(n,i,t.get(n,i)-t.get(e,i)*o)}e++,r++}}return t}reducedEchelonForm(){let t=this.echelonForm(),e=t.columns,r=t.rows,n=r-1;for(;n>=0;)if(0===t.maxRow(n))n--;else{let o=0,i=!1;for(;o<r&&!1===i;)1===t.get(n,o)?i=!0:o++;for(let r=0;r<n;r++){let i=t.get(r,o);for(let s=o;s<e;s++){let e=t.get(r,s)-i*t.get(n,s);t.set(r,s,e)}}n--}return t}set(){throw new Error("set method is unimplemented")}get(){throw new Error("get method is unimplemented")}repeat(t={}){if("object"!=typeof t)throw new TypeError("options must be an object");const{rows:e=1,columns:r=1}=t;if(!Number.isInteger(e)||e<=0)throw new TypeError("rows must be a positive integer");if(!Number.isInteger(r)||r<=0)throw new TypeError("columns must be a positive integer");let n=new ae(this.rows*e,this.columns*r);for(let t=0;t<e;t++)for(let e=0;e<r;e++)n.setSubMatrix(this,this.rows*t,this.columns*e);return n}fill(t){for(let e=0;e<this.rows;e++)for(let r=0;r<this.columns;r++)this.set(e,r,t);return this}neg(){return this.mulS(-1)}getRow(t){Xt(this,t);let e=[];for(let r=0;r<this.columns;r++)e.push(this.get(t,r));return e}getRowVector(t){return ae.rowVector(this.getRow(t))}setRow(t,e){Xt(this,t),e=Zt(this,e);for(let r=0;r<this.columns;r++)this.set(t,r,e[r]);return this}swapRows(t,e){Xt(this,t),Xt(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){Qt(this,t);let e=[];for(let r=0;r<this.rows;r++)e.push(this.get(r,t));return e}getColumnVector(t){return ae.columnVector(this.getColumn(t))}setColumn(t,e){Qt(this,t),e=te(this,e);for(let r=0;r<this.rows;r++)this.set(r,t,e[r]);return this}swapColumns(t,e){Qt(this,t),Qt(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=Zt(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=Zt(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=Zt(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=Zt(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=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[e]);return this}subColumnVector(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[e]);return this}mulColumnVector(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[e]);return this}divColumnVector(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[e]);return this}mulRow(t,e){Xt(this,t);for(let r=0;r<this.columns;r++)this.set(t,r,this.get(t,r)*e);return this}mulColumn(t,e){Qt(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(){oe(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(){oe(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(Xt(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){Xt(this,t),oe(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(Xt(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){Xt(this,t),oe(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(Qt(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){Qt(this,t),oe(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(Qt(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){Qt(this,t),oe(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){ie.isMatrix(t)&&(t=t.to1DArray());let e=this.to1DArray();if(e.length!==t.length)throw new RangeError("vectors do not have the same size");let r=0;for(let n=0;n<e.length;n++)r+=e[n]*t[n];return r}mmul(t){t=ae.checkMatrix(t);let e=this.rows,r=this.columns,n=t.columns,o=new ae(e,n),i=new Float64Array(r);for(let s=0;s<n;s++){for(let e=0;e<r;e++)i[e]=t.get(e,s);for(let t=0;t<e;t++){let e=0;for(let n=0;n<r;n++)e+=this.get(t,n)*i[n];o.set(t,s,e)}}return o}strassen2x2(t){t=ae.checkMatrix(t);let e=new ae(2,2);const r=this.get(0,0),n=t.get(0,0),o=this.get(0,1),i=t.get(0,1),s=this.get(1,0),a=t.get(1,0),u=this.get(1,1),h=t.get(1,1),l=(r+u)*(n+h),c=(s+u)*n,f=r*(i-h),d=u*(a-n),g=(r+o)*h,p=l+d-g+(o-u)*(a+h),m=f+g,w=c+d,y=l-c+f+(s-r)*(n+i);return e.set(0,0,p),e.set(0,1,m),e.set(1,0,w),e.set(1,1,y),e}strassen3x3(t){t=ae.checkMatrix(t);let e=new ae(3,3);const r=this.get(0,0),n=this.get(0,1),o=this.get(0,2),i=this.get(1,0),s=this.get(1,1),a=this.get(1,2),u=this.get(2,0),h=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),m=t.get(1,2),w=t.get(2,0),y=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+u+h)*(c-d+m),S=(-r+u)*(d-m),k=(u+h)*(-c+d),A=(-o+h+l)*(p+w-y),D=(o-l)*(p-y),I=o*w,R=(h+l)*(-w+y),_=(-o+s+a)*(m+w-v),z=(o-a)*(m-v),T=(s+a)*(-w+v),P=E+I+n*g,C=(r+n+o-i-s-h-l)*p+M+b+E+A+I+R,O=E+N+k+(r+n+o-s-a-u-h)*m+I+_+T,j=x+s*(-c+f+g-p-m-w+v)+M+E+I+_+z,q=x+M+b+E+a*y,V=I+_+z+T+i*d,L=E+N+S+h*(-c+d+g-p-m-w+y)+A+D+I,F=A+D+I+R+u*f,$=E+N+S+k+l*v;return e.set(0,0,P),e.set(0,1,C),e.set(0,2,O),e.set(1,0,j),e.set(1,1,q),e.set(1,2,V),e.set(2,0,L),e.set(2,1,F),e.set(2,2,$),e}mmulStrassen(t){t=ae.checkMatrix(t);let e=this.clone(),r=e.rows,n=e.columns,o=t.rows,i=t.columns;function s(t,e,r){let n=t.rows,o=t.columns;if(n===e&&o===r)return t;{let n=ie.zeros(e,r);return n=n.setSubMatrix(t,0,0),n}}n!==o&&console.warn(`Multiplying ${r} x ${n} and ${o} x ${i} matrix: dimensions do not match.`);let a=Math.max(r,o),u=Math.max(n,i);return e=s(e,a,u),function t(e,r,n,o){if(n<=512||o<=512)return e.mmul(r);n%2==1&&o%2==1?(e=s(e,n+1,o+1),r=s(r,n+1,o+1)):n%2==1?(e=s(e,n+1,o),r=s(r,n+1,o)):o%2==1&&(e=s(e,n,o+1),r=s(r,n,o+1));let i=parseInt(e.rows/2,10),a=parseInt(e.columns/2,10),u=e.subMatrix(0,i-1,0,a-1),h=r.subMatrix(0,i-1,0,a-1),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),m=t(ie.add(u,g),ie.add(h,p),i,a),w=t(ie.add(f,g),h,i,a),y=t(u,ie.sub(c,p),i,a),v=t(g,ie.sub(d,h),i,a),x=t(ie.add(u,l),p,i,a),M=t(ie.sub(f,u),ie.add(h,c),i,a),b=t(ie.sub(l,g),ie.add(d,p),i,a),E=ie.add(m,v);E.sub(x),E.add(b);let N=ie.add(y,x),S=ie.add(w,v),k=ie.sub(m,w);k.add(y),k.add(M);let A=ie.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,u),a,u)}scaleRows(t={}){if("object"!=typeof t)throw new TypeError("options must be an object");const{min:e=0,max:r=1}=t;if(!Number.isFinite(e))throw new TypeError("min must be a number");if(!Number.isFinite(r))throw new TypeError("max must be a number");if(e>=r)throw new RangeError("min must be smaller than max");let n=new ae(this.rows,this.columns);for(let t=0;t<this.rows;t++){const o=this.getRow(t);o.length>0&&Kt(o,{min:e,max:r,output:o}),n.setRow(t,o)}return n}scaleColumns(t={}){if("object"!=typeof t)throw new TypeError("options must be an object");const{min:e=0,max:r=1}=t;if(!Number.isFinite(e))throw new TypeError("min must be a number");if(!Number.isFinite(r))throw new TypeError("max must be a number");if(e>=r)throw new RangeError("min must be smaller than max");let n=new ae(this.rows,this.columns);for(let t=0;t<this.columns;t++){const o=this.getColumn(t);o.length&&Kt(o,{min:e,max:r,output:o}),n.setColumn(t,o)}return n}flipRows(){const t=Math.ceil(this.columns/2);for(let e=0;e<this.rows;e++)for(let r=0;r<t;r++){let t=this.get(e,r),n=this.get(e,this.columns-1-r);this.set(e,r,n),this.set(e,this.columns-1-r,t)}return this}flipColumns(){const t=Math.ceil(this.rows/2);for(let e=0;e<this.columns;e++)for(let r=0;r<t;r++){let t=this.get(r,e),n=this.get(this.rows-1-r,e);this.set(r,e,n),this.set(this.rows-1-r,e,t)}return this}kroneckerProduct(t){t=ae.checkMatrix(t);let e=this.rows,r=this.columns,n=t.rows,o=t.columns,i=new ae(e*n,r*o);for(let s=0;s<e;s++)for(let e=0;e<r;e++)for(let r=0;r<n;r++)for(let a=0;a<o;a++)i.set(n*s+r,o*e+a,this.get(s,e)*t.get(r,a));return i}kroneckerSum(t){if(t=ae.checkMatrix(t),!this.isSquare()||!t.isSquare())throw new Error("Kronecker Sum needs two Square Matrices");let e=this.rows,r=t.rows,n=this.kroneckerProduct(ae.eye(r,r)),o=ae.eye(e,e).kroneckerProduct(t);return n.add(o)}transpose(){let t=new ae(this.columns,this.rows);for(let e=0;e<this.rows;e++)for(let r=0;r<this.columns;r++)t.set(r,e,this.get(e,r));return t}sortRows(t=se){for(let e=0;e<this.rows;e++)this.setRow(e,this.getRow(e).sort(t));return this}sortColumns(t=se){for(let e=0;e<this.columns;e++)this.setColumn(e,this.getColumn(e).sort(t));return this}subMatrix(t,e,r,n){ee(this,t,e,r,n);let o=new ae(e-t+1,n-r+1);for(let i=t;i<=e;i++)for(let e=r;e<=n;e++)o.set(i-t,e-r,this.get(i,e));return o}subMatrixRow(t,e,r){if(void 0===e&&(e=0),void 0===r&&(r=this.columns-1),e>r||e<0||e>=this.columns||r<0||r>=this.columns)throw new RangeError("Argument out of range");let n=new ae(t.length,r-e+1);for(let o=0;o<t.length;o++)for(let i=e;i<=r;i++){if(t[o]<0||t[o]>=this.rows)throw new RangeError(`Row index out of range: ${t[o]}`);n.set(o,i-e,this.get(t[o],i))}return n}subMatrixColumn(t,e,r){if(void 0===e&&(e=0),void 0===r&&(r=this.rows-1),e>r||e<0||e>=this.rows||r<0||r>=this.rows)throw new RangeError("Argument out of range");let n=new ae(r-e+1,t.length);for(let o=0;o<t.length;o++)for(let i=e;i<=r;i++){if(t[o]<0||t[o]>=this.columns)throw new RangeError(`Column index out of range: ${t[o]}`);n.set(i-e,o,this.get(i,t[o]))}return n}setSubMatrix(t,e,r){if((t=ae.checkMatrix(t)).isEmpty())return this;ee(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(!$t(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(!$t(e))throw new TypeError("column indices must be an array");for(let r=0;r<e.length;r++)if(e[r]<0||e[r]>=t.columns)throw new RangeError("column indices are out of range")}(this,e);let r=new ae(t.length,e.length);for(let n=0;n<t.length;n++){let o=t[n];for(let t=0;t<e.length;t++){let i=e[t];r.set(n,t,this.get(o,i))}}return r}trace(){let t=Math.min(this.rows,this.columns),e=0;for(let r=0;r<t;r++)e+=this.get(r,r);return e}clone(){let t=new ae(this.rows,this.columns);for(let e=0;e<this.rows;e++)for(let r=0;r<this.columns;r++)t.set(e,r,this.get(e,r));return t}sum(t){switch(t){case"row":return function(t){let e=re(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=re(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=re(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=re(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(!$t(n))throw new TypeError("mean must be an array");return function(t,e,r){const n=t.rows,o=t.columns,i=[];for(let s=0;s<n;s++){let n=0,a=0,u=0;for(let e=0;e<o;e++)u=t.get(s,e)-r[s],n+=u,a+=u*u;e?i.push((a-n*n/o)/(o-1)):i.push((a-n*n/o)/o)}return i}(this,r,n);case"column":if(!$t(n))throw new TypeError("mean must be an array");return function(t,e,r){const n=t.rows,o=t.columns,i=[];for(let s=0;s<o;s++){let o=0,a=0,u=0;for(let e=0;e<n;e++)u=t.get(e,s)-r[s],o+=u,a+=u*u;e?i.push((a-o*o/n)/(n-1)):i.push((a-o*o/n)/n)}return i}(this,r,n);case void 0:if("number"!=typeof n)throw new TypeError("mean must be a number");return function(t,e,r){const n=t.rows,o=t.columns,i=n*o;let s=0,a=0,u=0;for(let e=0;e<n;e++)for(let n=0;n<o;n++)u=t.get(e,n)-r,s+=u,a+=u*u;return e?(a-s*s/i)/(i-1):(a-s*s/i)/i}(this,r,n);default:throw new Error(`invalid option: ${t}`)}}standardDeviation(t,e){"object"==typeof t&&(e=t,t=void 0);const r=this.variance(t,e);if(void 0===t)return Math.sqrt(r);for(let t=0;t<r.length;t++)r[t]=Math.sqrt(r[t]);return r}center(t,e={}){if("object"==typeof t&&(e=t,t=void 0),"object"!=typeof e)throw new TypeError("options must be an object");const{center:r=this.mean(t)}=e;switch(t){case"row":if(!$t(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(!$t(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(!$t(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(!$t(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 Jt(this,t)}}function se(t,e){return t-e}ie.prototype.klass="Matrix","undefined"!=typeof Symbol&&(ie.prototype[Symbol.for("nodejs.util.inspect.custom")]=function(){return Jt(this)}),ie.random=ie.rand,ie.randomInt=ie.randInt,ie.diagonal=ie.diag,ie.prototype.diagonal=ie.prototype.diag,ie.identity=ie.eye,ie.prototype.negate=ie.prototype.neg,ie.prototype.tensorProduct=ie.prototype.kroneckerProduct;class ae extends ie{constructor(t,e){if(super(),ae.isMatrix(t))return t.clone();if(Number.isInteger(t)&&t>=0){if(this.data=[],!(Number.isInteger(e)&&e>=0))throw new TypeError("nColumns must be a positive integer");for(let r=0;r<t;r++)this.data.push(new Float64Array(e))}else{if(!$t(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 Xt(this,t),this.data.splice(t,1),this.rows-=1,this}addRow(t,e){return void 0===e&&(e=t,t=this.rows),Xt(this,t,!0),e=Float64Array.from(Zt(this,e)),this.data.splice(t,0,e),this.rows+=1,this}removeColumn(t){Qt(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),Qt(this,t,!0),e=te(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}}(ie,ae);class ue extends ie{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 he(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 le{constructor(t,e={}){if((t=ue.checkMatrix(t)).isEmpty())throw new Error("Matrix must be non-empty");let r=t.rows,n=t.columns;const{computeLeftSingularVectors:o=!0,computeRightSingularVectors:i=!0,autoTranspose:s=!1}=e;let a,u=Boolean(o),h=Boolean(i),l=!1;if(r<n)if(s){a=t.transpose(),r=a.rows,n=a.columns,l=!0;let e=u;u=h,h=e}else a=t.clone(),console.warn("Computing SVD on a matrix with more columns than rows. Consider enabling autoTranspose");else a=t.clone();let c=Math.min(r,n),f=Math.min(r+1,n),d=new Float64Array(f),g=new ae(r,c),p=new ae(n,n),m=new Float64Array(n),w=new Float64Array(r),y=new Float64Array(f);for(let t=0;t<f;t++)y[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]=he(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))}m[e]=a.get(t,e)}if(u&&t<v)for(let e=t;e<r;e++)g.set(e,t,a.get(e,t));if(t<x){m[t]=0;for(let e=t+1;e<n;e++)m[t]=he(m[t],m[e]);if(0!==m[t]){m[t+1]<0&&(m[t]=0-m[t]);for(let e=t+1;e<n;e++)m[e]/=m[t];m[t+1]+=1}if(m[t]=-m[t],t+1<r&&0!==m[t]){for(let e=t+1;e<r;e++)w[e]=0;for(let e=t+1;e<r;e++)for(let r=t+1;r<n;r++)w[e]+=m[r]*a.get(e,r);for(let e=t+1;e<n;e++){let n=-m[e]/m[t+1];for(let o=t+1;o<r;o++)a.set(o,e,a.get(o,e)+n*w[o])}}if(h)for(let e=t+1;e<n;e++)p.set(e,t,m[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&&(m[x]=a.get(x,b-1)),m[b-1]=0,u){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(h)for(let t=n-1;t>=0;t--){if(t<x&&0!==m[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(m[t])<=e||Number.isNaN(m[t])){m[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(m[r]):0)+(r!==t+1?Math.abs(m[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=m[b-2];m[b-2]=0;for(let r=b-2;r>=t;r--){let o=he(d[r],e),i=d[r]/o,s=e/o;if(d[r]=o,r!==t&&(e=-s*m[r-1],m[r-1]=i*m[r-1]),h)for(let t=0;t<n;t++)o=i*p.get(t,r)+s*p.get(t,b-1),p.set(t,b-1,-s*p.get(t,r)+i*p.get(t,b-1)),p.set(t,r,o)}break}case 2:{let e=m[t-1];m[t-1]=0;for(let n=t;n<b;n++){let o=he(d[n],e),i=d[n]/o,s=e/o;if(d[n]=o,e=-s*m[n],m[n]=i*m[n],u)for(let e=0;e<r;e++)o=i*g.get(e,n)+s*g.get(e,t-1),g.set(e,t-1,-s*g.get(e,n)+i*g.get(e,t-1)),g.set(e,n,o)}break}case 3:{const e=Math.max(Math.abs(d[b-1]),Math.abs(d[b-2]),Math.abs(m[b-2]),Math.abs(d[t]),Math.abs(m[t])),o=d[b-1]/e,i=d[b-2]/e,s=m[b-2]/e,a=d[t]/e,l=m[t]/e,c=((i+o)*(i-o)+s*s)/2,f=o*s*(o*s);let w=0;0===c&&0===f||(w=c<0?0-Math.sqrt(c*c+f):Math.sqrt(c*c+f),w=f/(c+w));let y=(a+o)*(a-o)+w,v=a*l;for(let e=t;e<b-1;e++){let o=he(y,v);0===o&&(o=Number.MIN_VALUE);let i=y/o,s=v/o;if(e!==t&&(m[e-1]=o),y=i*d[e]+s*m[e],m[e]=i*m[e]-s*d[e],v=s*d[e+1],d[e+1]=i*d[e+1],h)for(let t=0;t<n;t++)o=i*p.get(t,e)+s*p.get(t,e+1),p.set(t,e+1,-s*p.get(t,e)+i*p.get(t,e+1)),p.set(t,e,o);if(o=he(y,v),0===o&&(o=Number.MIN_VALUE),i=y/o,s=v/o,d[e]=o,y=i*m[e]+s*d[e+1],d[e+1]=-s*m[e]+i*d[e+1],v=s*m[e+1],m[e+1]=i*m[e+1],u&&e<r-1)for(let t=0;t<r;t++)o=i*g.get(t,e)+s*g.get(t,e+1),g.set(t,e+1,-s*g.get(t,e)+i*g.get(t,e+1)),g.set(t,e,o)}m[b-2]=y,N+=1;break}case 4:if(d[t]<=0&&(d[t]=d[t]<0?-d[t]:0,h))for(let e=0;e<=E;e++)p.set(e,t,-p.get(e,t));for(;t<E&&!(d[t]>=d[t+1]);){let e=d[t];if(d[t]=d[t+1],d[t+1]=e,h&&t<n-1)for(let r=0;r<n;r++)e=p.get(r,t+1),p.set(r,t+1,p.get(r,t)),p.set(r,t,e);if(u&&t<r-1)for(let n=0;n<r;n++)e=g.get(n,t+1),g.set(n,t+1,g.get(n,t)),g.set(n,t,e);t++}N=0,b--}}if(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=ae.zeros(n,n);for(let t=0;t<n;t++)Math.abs(this.s[t])<=r?o.set(t,t,0):o.set(t,t,1/this.s[t]);let i=this.U,s=this.rightSingularVectors,a=s.mmul(o),u=s.rows,h=i.rows,l=ae.zeros(u,h);for(let t=0;t<u;t++)for(let e=0;e<h;e++){let r=0;for(let o=0;o<n;o++)r+=a.get(t,o)*i.get(e,o);l.set(t,e,r)}return l.mmul(e)}solveForDiagonal(t){return this.solve(ae.diag(t))}inverse(){let t=this.V,e=this.threshold,r=t.rows,n=t.columns,o=new ae(r,this.s.length);for(let i=0;i<r;i++)for(let r=0;r<n;r++)Math.abs(this.s[r])>e&&o.set(i,r,t.get(i,r)/this.s[r]);let i=this.U,s=i.rows,a=i.columns,u=new ae(r,s);for(let t=0;t<r;t++)for(let e=0;e<s;e++){let r=0;for(let n=0;n<a;n++)r+=o.get(t,n)*i.get(e,n);u.set(t,e,r)}return u}get condition(){return this.s[0]/this.s[Math.min(this.m,this.n)-1]}get norm2(){return this.s[0]}get rank(){let t=Math.max(this.m,this.n)*this.s[0]*Number.EPSILON,e=0,r=this.s;for(let n=0,o=r.length;n<o;n++)r[n]>t&&e++;return e}get diagonal(){return Array.from(this.s)}get threshold(){return Number.EPSILON/2*Math.max(this.m,this.n)*this.s[0]}get leftSingularVectors(){return this.U}get rightSingularVectors(){return this.V}get diagonalMatrix(){return ae.diag(this.s)}}var ce={center:[0,0],linkDistance:50},fe=function(){function t(t){void 0===t&&(t={}),this.options=t,this.id="mds",this.options=r(r({},ce),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,u=void 0===a?50:a,h=o.layoutInvisibles,l=o.onLayoutEnd,d=e.getAllNodes(),g=e.getAllEdges();if(h||(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}))),!d||0===d.length){var p={nodes:[],edges:g};return null==l||l(p),p}if(1===d.length){t&&e.mergeNodeData(d[0].id,{x:s[0],y:s[1]});var w={nodes:[r(r({},d[0]),{data:r(r({},d[0].data),{x:s[0],y:s[1]})})],edges:g};return null==l||l(w),w}var y=f({nodes:d,edges:g},!1),v=c(y);de(v);var x=function(t,e){var r=[];return t.forEach((function(t){var n=[];t.forEach((function(t){n.push(t*e)})),r.push(n)})),r}(v,u),M=ge(x),b=[];M.forEach((function(t,e){var r=m(d[e]);r.data.x=t[0]+s[0],r.data.y=t[1]+s[1],b.push(r)})),t&&b.forEach((function(t){return e.mergeNodeData(t.id,{x:t.data.x,y:t.data.y})}));var E={nodes:b,edges:g};return null==l||l(E),E},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)}))}))},ge=function(t){var e=ae.mul(ae.pow(t,2),-.5),r=e.mean("row"),n=e.mean("column"),o=e.mean();e.add(o).subRowVector(r).subColumnVector(n);var i=new le(e),s=ae.sqrt(i.diagonalMatrix).diagonal();return i.leftSingularVectors.toJSON().map((function(t){return ae.mul([t],[s]).toJSON()[0].splice(0,2)}))},pe={iterations:10,height:10,width:10,speed:100,gravity:10,k:5},me=function(t,e,r,n,o,i){e.forEach((function(s,a){r[a]={x:0,y:0},e.forEach((function(e,u){if(a!==u&&o[a]===o[u]){var h=s.x-e.x,l=s.y-e.y,c=Math.sqrt(h*h+l*l);if(0===c){c=1;var f=a>u?1:-1;h=.01*f,l=.01*f}if(c<i(t[a])/2+i(t[u])/2){var d=n*n/c;r[a].x+=h/c*d,r[a].y+=l/c*d}}}))}))},we=function(t,e,r,n,o,i,s,a){var u=i||s/10;return n&&e.forEach((function(e,r){var n=t[r].x-t[o].x,i=t[r].y-t[o].y,s=Math.sqrt(n*n+i*i),a=i/s,u=-n/s,h=Math.sqrt(e.x*e.x+e.y*e.y),l=Math.acos((a*e.x+u*e.y)/h);l>Math.PI/2&&(l-=Math.PI/2,a*=-1,u*=-1);var c=Math.cos(l)*h;e.x=a*c,e.y=u*c})),t.forEach((function(i,s){if(s!==o){var h=Math.sqrt(e[s].x*e[s].x+e[s].y*e[s].y);if(h>0&&s!==o){var l=Math.min(u*(r/800),h);if(i.x+=e[s].x/h*l,i.y+=e[s].y/h*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},ye={maxIteration:1e3,focusNode:null,unitRadius:null,linkDistance:50,preventOverlap:!1,strictRadial:!0,maxPreventOverlapIteration:200,sortStrength:10},ve=function(){function t(t){void 0===t&&(t={}),this.options=t,this.id="radial",this.options=r(r({},ye),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),u=s.width,h=s.height,l=s.center,d=s.focusNode,g=s.unitRadius,p=s.nodeSize,w=s.nodeSpacing,y=s.strictRadial,v=s.preventOverlap,x=s.maxPreventOverlapIteration,M=s.sortBy,b=s.linkDistance,E=void 0===b?50:b,N=s.sortStrength,S=void 0===N?10:N,k=s.maxIteration,A=void 0===k?1e3:k,D=s.layoutInvisibles,I=s.onLayoutEnd,R=e.getAllNodes(),_=e.getAllEdges();if(D||(R=R.filter((function(t){var e=(t.data||{}).visible;return e||void 0===e})),_=_.filter((function(t){var e=(t.data||{}).visible;return e||void 0===e}))),!R||0===R.length){var z={nodes:[],edges:_};return null==I||I(z),z}var T=u||"undefined"==typeof window?u:window.innerWidth,P=h||"undefined"==typeof window?h:window.innerHeight,C=l||[T/2,P/2];if(1===R.length){t&&e.mergeNodeData(R[0].id,{x:C[0],y:C[1]});var O={nodes:[r(r({},R[0]),{data:r(r({},R[0].data),{x:C[0],y:C[1]})})],edges:_};return null==I||I(O),O}var j=R[0];if(a(d)){for(var q=0;q<R.length;q++)if(R[q].id===d){j=R[q];break}}else j=d||R[0];var V=be(R,j.id),L=f({nodes:R,edges:_},!1),F=c(L),$=Ne(F,V);Ee(F,V,$+1);var U=F[V],B=T-C[0]>C[0]?C[0]:T-C[0],K=P-C[1]>C[1]?C[1]:P-C[1];0===B&&(B=T/2),0===K&&(K=P/2);var G=Math.min(B,K),W=Math.max.apply(Math,i([],o(U),!1)),J=[],H=g||G/W;U.forEach((function(t,e){J[e]=t*H}));var Y,X=xe(R,F,E,J,H,M,S),Q=Me(X),Z=function(t,e,r){try{var n=ae.mul(ae.pow(e,2),-.5),o=n.mean("row"),i=n.mean("column"),s=n.mean();n.add(s).subRowVector(o).subColumnVector(i);var a=new le(n),u=ae.sqrt(a.diagonalMatrix).diagonal();return a.leftSingularVectors.toJSON().map((function(e){return ae.mul([e],[u]).toJSON()[0].splice(0,t)}))}catch(t){for(var h=[],l=0;l<e.length;l++){var c=Math.random()*r,f=Math.random()*r;h.push([c,f])}return h}}(E,X,E),tt=Z.map((function(t){var e=o(t,2),r=e[0],n=e[1];return{x:(isNaN(r)?Math.random()*E:r)-Z[V][0],y:(isNaN(n)?Math.random()*E:n)-Z[V][1]}}));if(this.run(A,tt,Q,X,J,V),v){Y=Se(p,w);var et={nodes:R,nodeSizeFunc:Y,positions:tt,radii:J,height:P,width:T,strictRadial:Boolean(y),focusIdx:V,iterations:x||200,k:tt.length/4.5};tt=function(t,e){for(var n=r(r({},pe),e),o=n.positions,i=n.iterations,s=n.width,a=n.k,u=n.speed,h=void 0===u?100:u,l=n.strictRadial,c=n.focusIdx,f=n.radii,d=void 0===f?[]:f,g=n.nodeSizeFunc,p=t.getAllNodes(),m=[],w=s/10,y=0;y<i;y++)o.forEach((function(t,e){m[e]={x:0,y:0}})),me(p,o,m,a,d,g),we(o,m,h,l,c,w,s,d);return o}(e,et)}var rt=[];tt.forEach((function(t,e){var r=m(R[e]);r.data.x=t.x+C[0],r.data.y=t.y+C[1],rt.push(r)})),t&&rt.forEach((function(t){return e.mergeNodeData(t.id,{x:t.data.x,y:t.data.y})}));var nt={nodes:rt,edges:_};return null==I||I(nt),nt},t.prototype.run=function(t,e,r,n,o,i){for(var s=0;s<=t;s++){var a=s/t;this.oneIteration(a,e,o,n,r,i)}},t.prototype.oneIteration=function(t,e,r,n,o,i){var s=1-t;e.forEach((function(a,u){var h=d(a,{x:0,y:0}),l=0===h?0:1/h;if(u!==i){var c=0,f=0,g=0;e.forEach((function(t,e){if(u!==e){var r=d(a,t),i=0===r?0:1/r,s=n[e][u];g+=o[u][e],c+=o[u][e]*(t.x+s*(a.x-t.x)*i),f+=o[u][e]*(t.y+s*(a.y-t.y)*i)}}));var p=0===r[u]?0:1/r[u];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}(),xe=function(t,e,r,n,o,i,s){if(!t)return[];var u=[];if(e){var h={};e.forEach((function(e,l){var c=[];e.forEach((function(e,u){var f,d;if(l===u)c.push(0);else if(n[l]===n[u])if("data"===i)c.push(e*(Math.abs(l-u)*s)/(n[l]/o));else if(i){var g=void 0,p=void 0;if(h[t[l].id])g=h[t[l].id];else{var m=("id"===i?t[l].id:null===(f=t[l].data)||void 0===f?void 0:f[i])||0;g=a(m)?m.charCodeAt(0):m,h[t[l].id]=g}h[t[u].id]?p=h[t[u].id]:(m=("id"===i?t[u].id:null===(d=t[u].data)||void 0===d?void 0:d[i])||0,p=a(m)?m.charCodeAt(0):m,h[t[u].id]=p),c.push(e*(Math.abs(g-p)*s)/(n[l]/o))}else c.push(e*r/(n[l]/o));else{var w=(r+o)/2;c.push(e*w)}})),u.push(c)}))}return u},Me=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},be=function(t,e){var r=-1;return t.forEach((function(t,n){t.id===e&&(r=n)})),Math.max(r,0)},Ee=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}},Ne=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},Se=function(t,e){var r;return r=l(e)?function(){return e}:w(e)?e:function(){return 0},t?h(t)?function(e){return(t[0]>t[1]?t[0]:t[1])+r(e)}:function(e){return t+r(e)}:function(t){return t.data.bboxSize?Math.max(t.data.bboxSize[0],t.data.bboxSize[1])+r(t):t.data.size?h(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)}},ke={center:[0,0],width:300,height:300},Ae={circular:M,concentric:S,mds:fe,random:function(){function t(t){void 0===t&&(t={}),this.options=t,this.id="random",this.options=r(r({},ke),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,u=o.layoutInvisibles,h=o.onLayoutEnd,l=e.getAllNodes();u||(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==h||h(p),p},t}(),grid:Pt,radial:ve,force:At,d3force:bt};function De(t,e){return r=this,n=void 0,i=function(){var r,n,o,i,a,u,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(u){return function(a){if(r)throw new TypeError("Generator is already executing.");for(;i&&(i=0,a[0]&&(s=0)),s;)try{if(r=1,n&&(o=2&a[0]?n.return:a[0]?n.throw||((o=n.return)&&o.call(n),0):n.next)&&!(o=o.call(n,a[1])).done)return o;switch(n=0,o&&(a=[2&a[0],o.value]),a[0]){case 0:case 1:o=a;break;case 4:return s.label++,{value:a[1],done:!1};case 5:s.label++,n=a[1],a=[0];continue;case 7:a=s.ops.pop(),s.trys.pop();continue;default:if(!((o=(o=s.trys).length>0&&o[o.length-1])||6!==a[0]&&2!==a[0])){s=0;continue}if(3===a[0]&&(!o||a[1]>o[0]&&a[1]<o[3])){s.label=a[1];break}if(6===a[0]&&s.label<o[1]){s.label=o[1],o=a;break}if(o&&s.label<o[2]){s.label=o[2],s.ops.push(a);break}o[2]&&s.ops.pop(),s.trys.pop();continue}a=e.call(t,s)}catch(t){a=[6,t],n=0}finally{r=o=0}if(5&a[0])throw a[1];return{value:a[0]?a[1]:void 0,done:!0}}([a,u])}}}(this,(function(c){if(r=t.layout,n=r.id,o=r.options,i=t.nodes,a=t.edges,u=new s({nodes:i,edges:a}),!(l=Ae[n]))throw new Error("Unknown layout id: ".concat(n));return h=new l(o),[2,new Promise((function(t){h.execute(u,{onLayoutEnd:function(r){t([r,e])}})}))]}))},new((o=void 0)||(o=Promise))((function(t,e){function s(t){try{u(i.next(t))}catch(t){e(t)}}function a(t){try{u(i.throw(t))}catch(t){e(t)}}function u(e){var r;e.done?t(e.value):(r=e.value,r instanceof o?r:new o((function(t){t(r)}))).then(s,a)}u((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=a3736fcd924e7b5b918c.worker.js.map'])),{name:"[fullhash].worker.js"});return URL.revokeObjectURL(URL.createObjectURL(new Blob(['(()=>{"use strict";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:()=>De});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},u=/-(\\w)/g,h=(function(t){return t.replace(u,(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&&Object.keys(t).length){var n=r({},t);return Object.keys(n).forEach((function(t){n[t]=p(n[t])})),n}return t},m=function(t){var e=p(t);return e.data=e.data||{},e},w=function(t){return"function"==typeof t};function y(t,e){return w(e)?e:l(e)?function(){return e}:function(){return t}}function v(t,e,r){return void 0===r&&(r=!0),e||0===e?w(e)?e:l(e)?function(){return e}:h(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?h(r)?r[0]>r[1]?r[0]:r[1]:g(r)?r.width>r.height?r.width:r.height:r:t}}var x={radius:null,startRadius:null,endRadius:null,startAngle:0,endAngle:2*Math.PI,clockwise:!0,divisions:1,ordering:null,angleRatio:1},M=function(){function t(t){void 0===t&&(t={}),this.options=t,this.id="circular",this.options=r(r({},x),t)}return t.prototype.execute=function(t,e){return this.genericCircularLayout(!1,t,e)},t.prototype.assign=function(t,e){var r=this;t.batch((function(){r.genericCircularLayout(!0,t,e)}))},t.prototype.genericCircularLayout=function(t,e,n){var i=r(r({},this.options),n),s=i.width,a=i.height,u=i.center,h=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,w=i.clockwise,x=i.nodeSpacing,M=i.nodeSize,N=i.layoutInvisibles,S=i.onLayoutEnd,k=e.getAllNodes(),A=e.getAllEdges();N||(k=k.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=k.length;if(0===D)return null==S||S({nodes:[],edges:[]}),{nodes:[],edges:[]};var I=o(E(s,a,u),3),R=I[0],_=I[1],z=I[2];if(1===D){t&&e.mergeNodeData(k[0].id,{x:z[0],y:z[1]});var T={nodes:[r(r({},k[0]),{data:r(r({},k[0].data),{x:z[0],y:z[1]})})],edges:A};return null==S||S(T),T}var P=(d-c)/D,C=i.radius,O=i.startRadius,j=i.endRadius;if(x){var q=y(10,x),V=v(10,M),L=-1/0;k.forEach((function(t){var e=V(t);L<e&&(L=e)}));var F=0;k.forEach((function(t,e){F+=0===e?L||10:(q(t)||0)+(L||10)})),C=F/(2*Math.PI)}else C||O||j?!O&&j?O=j:O&&!j&&(j=O):C=Math.min(_,R)/2;var $=P*g,U=[];U="topology"===p?b(e,k):"topology-directed"===p?b(e,k,!0):"degree"===p?function(t,e){var r=[];return e.forEach((function(t,e){r.push(m(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 m(t)}));for(var B=Math.ceil(D/h),K=0;K<D;++K){var G=C;G||null===O||null===j||(G=O+K*(j-O)/(D-1)),G||(G=10+100*K/(D-1));var W=c+K%B*$+2*Math.PI/h*Math.floor(K/B);w||(W=d-K%B*$-2*Math.PI/h*Math.floor(K/B)),U[K].data.x=z[0]+Math.cos(W)*G,U[K].data.y=z[1]+Math.sin(W)*G}t&&U.forEach((function(t){e.mergeNodeData(t.id,{x:t.data.x,y:t.data.y})}));var J={nodes:U,edges:A};return null==S||S(J),J},t}(),b=function(t,e,r){void 0===r&&(r=!1);var n=[m(e[0])],o={},i=e.length;o[e[0].id]=!0;var s=0;return e.forEach((function(a,u){if(0!==u)if(u!==i-1&&t.getDegree(a.id,"both")===t.getDegree(e[u+1].id,"both")&&!t.areNeighbors(n[s].id,a.id)||o[a.id]){for(var h=r?t.getSuccessors(n[s].id):t.getNeighbors(n[s].id),l=!1,c=0;c<h.length;c++){var f=h[c];if(t.getDegree(f.id)===t.getDegree(a.id)&&!o[f.id]){n.push(m(f)),o[f.id]=!0,l=!0;break}}for(var d=0;!l&&(o[e[d].id]||(n.push(m(e[d])),o[e[d].id]=!0,l=!0),++d!==i););}else n.push(m(a)),o[a.id]=!0,s++})),n},E=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]},N={nodeSize:30,minNodeSpacing:10,nodeSpacing:10,preventOverlap:!1,sweep:void 0,equidistant:!1,startAngle:1.5*Math.PI,clockwise:!0,maxLevelDiff:void 0,sortBy:"degree"},S=function(){function t(t){void 0===t&&(t={}),this.options=t,this.id="concentric",this.options=r(r({},N),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,u=o.height,c=o.sortBy,f=o.maxLevelDiff,d=o.sweep,p=o.clockwise,y=o.equidistant,v=o.minNodeSpacing,x=void 0===v?10:v,M=o.preventOverlap,b=o.startAngle,E=void 0===b?1.5*Math.PI:b,N=o.nodeSize,S=o.nodeSpacing,k=o.layoutInvisibles,A=o.onLayoutEnd,D=e.getAllNodes(),I=e.getAllEdges();k||(D=D.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 R=D.length;if(0===R){var _={nodes:[],edges:I};return null==A||A(_),_}var z=s||"undefined"==typeof window?s:window.innerWidth,T=u||"undefined"==typeof window?u:window.innerHeight,P=i||[z/2,T/2];if(1===R){t&&e.mergeNodeData(D[0].id,{x:P[0],y:P[1]});var C={nodes:[r(r({},D[0]),{data:r(r({},D[0].data),{x:P[0],y:P[1]})})],edges:I};return null==A||A(C),C}var O,j=[],q=0;O=h(N)?Math.max(N[0],N[1]):N,h(S)?q=Math.max(S[0],S[1]):l(S)&&(q=S),D.forEach((function(t){var e=m(t);j.push(e);var r=O,n=e.data;h(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)),O=Math.max(O,r),w(S)&&(q=Math.max(S(t),q))}));var V={};j.forEach((function(t,e){V[t.id]=e}));var L=c;a(L)&&void 0!==j[0].data[L]||(L="degree"),"degree"===L?j.sort((function(t,r){return e.getDegree(r.id,"both")-e.getDegree(t.id,"both")})):j.sort((function(t,e){return e.data[L]-t.data[L]}));var F=j[0],$=(f||("degree"===L?e.getDegree(F.id,"both"):F.data[L]))/4,U=[{nodes:[]}],B=U[0];j.forEach((function(t){if(B.nodes.length>0){var r="degree"===L?Math.abs(e.getDegree(B.nodes[0].id,"both")-e.getDegree(t.id,"both")):Math.abs(B.nodes[0].data[L]-t.data[L]);$&&r>=$&&(B={nodes:[]},U.push(B))}B.nodes.push(t)}));var K=O+(q||x);if(!M){var G=U.length>0&&U[0].nodes.length>1,W=(Math.min(z,T)/2-K)/(U.length+(G?1:0));K=Math.min(K,W)}var J=0;if(U.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&&M){var r=Math.cos(t.dTheta)-Math.cos(0),n=Math.sin(t.dTheta)-Math.sin(0),o=Math.sqrt(K*K/(r*r+n*n));J=Math.max(o,J)}t.r=J,J+=K})),y){for(var H=0,Y=0,X=0;X<U.length;X++){var Q=(U[X].r||0)-Y;H=Math.max(H,Q)}Y=0,U.forEach((function(t,e){0===e&&(Y=t.r||0),t.r=Y,Y+=H}))}U.forEach((function(t){var e=t.dTheta||0,r=t.r||0;t.nodes.forEach((function(t,n){var o=E+(p?1:-1)*e*n;t.data.x=P[0]+r*Math.cos(o),t.data.y=P[1]+r*Math.sin(o)}))})),t&&j.forEach((function(t){return e.mergeNodeData(t.id,{x:t.data.x,y:t.data.y})}));var Z={nodes:j,edges:I};return null==A||A(Z),Z},t}();function k(t,e,r,n){if(isNaN(e)||isNaN(r))return t;var o,i,s,a,u,h,l,c,f,d=t._root,g={data:n},p=t._x0,m=t._y0,w=t._x1,y=t._y1;if(!d)return t._root=g,t;for(;d.length;)if((h=e>=(i=(p+w)/2))?p=i:w=i,(l=r>=(s=(m+y)/2))?m=s:y=s,o=d,!(d=d[c=l<<1|h]))return o[c]=g,t;if(a=+t._x.call(null,d.data),u=+t._y.call(null,d.data),e===a&&r===u)return g.next=d,o?o[c]=g:t._root=g,t;do{o=o?o[c]=new Array(4):t._root=new Array(4),(h=e>=(i=(p+w)/2))?p=i:w=i,(l=r>=(s=(m+y)/2))?m=s:y=s}while((c=l<<1|h)==(f=(u>=s)<<1|a>=i));return o[f]=d,o[c]=g,t}function A(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 I(t){return t[1]}function R(t,e,r){var n=new _(null==e?D:e,null==r?I:r,NaN,NaN,NaN,NaN);return null==t?n:n.addAll(t)}function _(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 z(t){for(var e={data:t.data},r=e;t=t.next;)r=r.next={data:t.data};return e}var T=R.prototype=_.prototype;function P(t){return function(){return t}}function C(t){return 1e-6*(t()-.5)}T.copy=function(){var t,e,r=new _(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=z(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]=z(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),u=1/0,h=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<u&&(u=n),n>l&&(l=n),o<h&&(h=o),o>c&&(c=o));if(u>l||h>c)return this;for(this.cover(u,h).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,u=o-r||1,h=this._root;r>t||t>=o||n>e||e>=i;)switch(a=(e<n)<<1|t<r,(s=new Array(4))[a]=h,h=s,u*=2,a){case 0:o=r+u,i=n+u;break;case 1:r=o-u,i=n+u;break;case 2:o=r+u,n=i-u;break;case 3:r=o-u,n=i-u}this._root&&this._root.length&&(this._root=h)}return this._x0=r,this._y0=n,this._x1=o,this._y1=i,this},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,u,h,l=this._x0,c=this._y0,f=this._x1,d=this._y1,g=[],p=this._root;for(p&&g.push(new A(p,l,c,f,d)),null==r?r=1/0:(l=t-r,c=e-r,f=t+r,d=e+r,r*=r);u=g.pop();)if(!(!(p=u.node)||(o=u.x0)>f||(i=u.y0)>d||(s=u.x1)<l||(a=u.y1)<c))if(p.length){var m=(o+s)/2,w=(i+a)/2;g.push(new A(p[3],m,w,s,a),new A(p[2],o,w,m,a),new A(p[1],m,i,s,w),new A(p[0],o,i,m,w)),(h=(e>=w)<<1|t>=m)&&(u=g[g.length-1],g[g.length-1]=g[g.length-1-h],g[g.length-1-h]=u)}else{var y=t-+this._x.call(null,p.data),v=e-+this._y.call(null,p.data),x=y*y+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,u,h,l,c,f,d=this._root,g=this._x0,p=this._y0,m=this._x1,w=this._y1;if(!d)return this;if(d.length)for(;;){if((h=i>=(a=(g+m)/2))?g=a:m=a,(l=s>=(u=(p+w)/2))?p=u:w=u,e=d,!(d=d[c=l<<1|h]))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=[],u=this._root;for(u&&a.push(new A(u,this._x0,this._y0,this._x1,this._y1));e=a.pop();)if(!t(u=e.node,n=e.x0,o=e.y0,i=e.x1,s=e.y1)&&u.length){var h=(n+i)/2,l=(o+s)/2;(r=u[3])&&a.push(new A(r,h,l,i,s)),(r=u[2])&&a.push(new A(r,n,l,h,s)),(r=u[1])&&a.push(new A(r,h,o,i,l)),(r=u[0])&&a.push(new A(r,n,o,h,l))}return this},T.visitAfter=function(t){var e,r=[],n=[];for(this._root&&r.push(new A(this._root,this._x0,this._y0,this._x1,this._y1));e=r.pop();){var o=e.node;if(o.length){var i,s=e.x0,a=e.y0,u=e.x1,h=e.y1,l=(s+u)/2,c=(a+h)/2;(i=o[0])&&r.push(new A(i,s,a,l,c)),(i=o[1])&&r.push(new A(i,l,a,u,c)),(i=o[2])&&r.push(new A(i,s,c,l,h)),(i=o[3])&&r.push(new A(i,l,c,u,h))}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 O={value:()=>{}};function j(){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 q(n)}function q(t){this._=t}function V(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 L(t,e){for(var r,n=0,o=t.length;n<o;++n)if((r=t[n]).name===e)return r.value}function F(t,e,r){for(var n=0,o=t.length;n<o;++n)if(t[n].name===e){t[n]=O,t=t.slice(0,n).concat(t.slice(n+1));break}return null!=r&&t.push({name:e,value:r}),t}q.prototype=j.prototype={constructor:q,on:function(t,e){var r,n=this._,o=V(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]=F(n[r],t.name,e);else if(null==e)for(r in n)n[r]=F(n[r],t.name,null);return this}for(;++i<s;)if((r=(t=o[i]).type)&&(r=L(n[r],t.name)))return r},copy:function(){var t={},e=this._;for(var r in e)t[r]=e[r].slice();return new q(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;var U,B,K=0,G=0,W=0,J=0,H=0,Y=0,X="object"==typeof performance&&performance.now?performance:Date,Q="object"==typeof window&&window.requestAnimationFrame?window.requestAnimationFrame.bind(window):function(t){setTimeout(t,17)};function Z(){return H||(Q(tt),H=X.now()+Y)}function tt(){H=0}function et(){this._call=this._time=this._next=null}function rt(t,e,r){var n=new et;return n.restart(t,e,r),n}function nt(){H=(J=X.now())+Y,K=G=0;try{!function(){Z(),++K;for(var t,e=U;e;)(t=H-e._time)>=0&&e._call.call(void 0,t),e=e._next;--K}()}finally{K=0,function(){for(var t,e,r=U,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:U=e);B=t,it(n)}(),H=0}}function ot(){var t=X.now(),e=t-J;e>1e3&&(Y-=e,J=t)}function it(t){K||(G&&(G=clearTimeout(G)),t-H>24?(t<1/0&&(G=setTimeout(nt,t-X.now()-Y)),W&&(W=clearInterval(W))):(W||(J=X.now(),W=setInterval(ot,1e3)),K=1,Q(nt)))}et.prototype=rt.prototype={constructor:et,restart:function(t,e,r){if("function"!=typeof t)throw new TypeError("callback is not a function");r=(null==r?Z():+r)+(null==e?0:+e),this._next||B===this||(B?B._next=this:U=this,B=this),this._call=t,this._time=r,it()},stop:function(){this._call&&(this._call=null,this._time=1/0,it())}};const st=4294967296;function at(t){return t.x}function ut(t){return t.y}var ht=Math.PI*(3-Math.sqrt(5));function lt(t){var e,r=1,n=.001,o=1-Math.pow(n,1/300),i=0,s=.6,a=new Map,u=rt(c),h=$("tick","end"),l=function(){let t=1;return()=>(t=(1664525*t+1013904223)%st)/st}();function c(){f(),h.call("tick",e),r<n&&(u.stop(),h.call("end",e))}function f(n){var u,h,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)})),u=0;u<l;++u)null==(h=t[u]).fx?h.x+=h.vx*=s:(h.x=h.fx,h.vx=0),null==h.fy?h.y+=h.vy*=s:(h.y=h.fy,h.vy=0);return e}function d(){for(var e,r=0,n=t.length;r<n;++r){if((e=t[r]).index=r,null!=e.fx&&(e.x=e.fx),null!=e.fy&&(e.y=e.fy),isNaN(e.x)||isNaN(e.y)){var o=10*Math.sqrt(.5+r),i=r*ht;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 u.restart(c),e},stop:function(){return u.stop(),e},nodes:function(r){return arguments.length?(t=r,d(),a.forEach(g),e):t},alpha:function(t){return arguments.length?(r=+t,e):r},alphaMin:function(t){return arguments.length?(n=+t,e):n},alphaDecay:function(t){return arguments.length?(o=+t,e):+o},alphaTarget:function(t){return arguments.length?(i=+t,e):i},velocityDecay:function(t){return arguments.length?(s=1-t,e):1-s},randomSource:function(t){return arguments.length?(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,u,h=0,l=t.length;for(null==n?n=1/0:n*=n,h=0;h<l;++h)(s=(o=e-(a=t[h]).x)*o+(i=r-a.y)*i)<n&&(u=a,n=s);return u},on:function(t,r){return arguments.length>1?(h.on(t,r),e):h.on(t)}}}function ct(){var t,e,r,n,o,i=P(-30),s=1,a=1/0,u=.81;function h(r){var o,i=t.length,s=R(t,at,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,u=0;if(t.length){for(n=i=s=0;s<4;++s)(e=t[s])&&(r=Math.abs(e.value))&&(a+=e.value,u+=r,n+=r*e.x,i+=r*e.y);t.x=n/u,t.y=i/u}else{(e=t).x=e.data.x,e.y=e.data.y;do{a+=o[e.data.index]}while(e=e.next)}t.value=a}function f(t,i,h,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/u<g)return g<a&&(0===c&&(g+=(c=C(r))*c),0===f&&(g+=(f=C(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=C(r))*c),0===f&&(g+=(f=C(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 h.initialize=function(e,n){t=e,r=n,l()},h.strength=function(t){return arguments.length?(i="function"==typeof t?t:P(+t),l(),h):i},h.distanceMin=function(t){return arguments.length?(s=t*t,h):Math.sqrt(s)},h.distanceMax=function(t){return arguments.length?(a=t*t,h):Math.sqrt(a)},h.theta=function(t){return arguments.length?(u=t*t,h):Math.sqrt(u)},h}function ft(t){return t.index}function dt(t,e){var r=t.get(e);if(!r)throw new Error("node not found: "+e);return r}function gt(t){var e,r,n,o,i,s,a=ft,u=function(t){return 1/Math.min(o[t.source.index],o[t.target.index])},h=P(30),l=1;function c(n){for(var o=0,a=t.length;o<l;++o)for(var u,h,c,f,d,g,p,m=0;m<a;++m)h=(u=t[m]).source,f=(c=u.target).x+c.vx-h.x-h.vx||C(s),d=c.y+c.vy-h.y-h.vy||C(s),f*=g=((g=Math.sqrt(f*f+d*d))-r[m])/g*n*e[m],d*=g,c.vx-=f*(p=i[m]),c.vy-=d*p,h.vx+=f*(p=1-p),h.vy+=d*p}function f(){if(n){var s,u,h=n.length,l=t.length,c=new Map(n.map(((t,e)=>[a(t,e,n),t])));for(s=0,o=new Array(h);s<l;++s)(u=t[s]).index=s,"object"!=typeof u.source&&(u.source=dt(c,u.source)),"object"!=typeof u.target&&(u.target=dt(c,u.target)),o[u.source.index]=(o[u.source.index]||0)+1,o[u.target.index]=(o[u.target.index]||0)+1;for(s=0,i=new Array(l);s<l;++s)u=t[s],i[s]=o[u.source.index]/(o[u.source.index]+o[u.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]=+u(t[r],r,t)}function g(){if(n)for(var e=0,o=t.length;e<o;++e)r[e]=+h(t[e],e,t)}return null==t&&(t=[]),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?(u="function"==typeof t?t:P(+t),d(),c):u},c.distance=function(t){return arguments.length?(h="function"==typeof t?t:P(+t),g(),c):h},c}function pt(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,u,h,l,c,f,d=e.length,g=0;g<i;++g)for(s=R(e,pt,mt).visitAfter(a),t=0;t<d;++t)u=e[t],c=r[u.index],f=c*c,h=u.x+u.vx,l=u.y+u.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>h+g||i<h-g||r>l+g||s<l-g;if(a.index>u.index){var p=h-a.x-a.vx,m=l-a.y-a.vy,w=p*p+m*m;w<g*g&&(0===p&&(w+=(p=C(n))*p),0===m&&(w+=(m=C(n))*m),w=(g-(w=Math.sqrt(w)))/w*o,u.vx+=(p*=w)*(g=(d*=d)/(f+d)),u.vy+=(m*=w)*g,a.vx-=p*(g=1-g),a.vy-=m*g)}}}function a(t){if(t.data)return t.r=r[t.data.index];for(var e=t.r=0;e<4;++e)t[e]&&t[e].r>t.r&&(t.r=t[e].r)}function u(){if(e){var n,o,i=e.length;for(r=new Array(i),n=0;n<i;++n)o=e[n],r[o.index]=+t(o,n,e)}}return"function"!=typeof t&&(t=P(null==t?1:+t)),s.initialize=function(t,r){e=t,n=r,u()},s.iterations=function(t){return arguments.length?(i=+t,s):i},s.strength=function(t){return arguments.length?(o=+t,s):o},s.radius=function(e){return arguments.length?(t="function"==typeof e?e:P(+e),u(),s):t},s}function yt(t){var e,r,n,o=P(.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=P(null==t?0:+t)),i.initialize=function(t){e=t,s()},i.strength=function(t){return arguments.length?(o="function"==typeof t?t:P(+t),s(),i):o},i.x=function(e){return arguments.length?(t="function"==typeof e?e:P(+e),s(),i):t},i}function vt(t){var e,r,n,o=P(.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=P(null==t?0:+t)),i.initialize=function(t){e=t,s()},i.strength=function(t){return arguments.length?(o="function"==typeof t?t:P(+t),s(),i):o},i.y=function(e){return arguments.length?(t="function"==typeof e?e:P(+e),s(),i):t},i}function xt(){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),u=[0,0],h=[],l={},c=[],f=100,d=100,g={none:{x:0,y:0}},p=[],m="force",w=!0,y=.1;function v(t){if(!w)return v;e.tick(),M();for(var n=0,o=h.length,i=void 0,s=t*y;n<o;++n)(i=h[n]).vx+=(g[r(i)].x-i.x)*s,i.vy+=(g[r(i)].y-i.y)*s}function x(){h&&function(){if(h&&h.length){if(void 0===r(h[0]))throw Error("Couldnt find the grouping attribute for the nodes. Make sure to set it up with forceInBox.groupBy(\'clusterAttr\') before calling .links()");var t,u,g,m,w,y=(t=[],u=[],g={},{},w=[],m=function(t){var e={};return t.forEach((function(t){var n=r(t);e[n]||(e[n]={count:0,sumforceNodeSize:0})})),t.forEach((function(t){var o=r(t),i=n(t),s=e[o];s.count=s.count+1,s.sumforceNodeSize=s.sumforceNodeSize+Math.PI*(i*i)*1.3,e[o]=s})),e}(h),w=function(t){var e={},n=[];return t.forEach((function(t){var n,o,i,s,a,u=(o=(n=t).source,i=n.target,(s=r(l[o]))<=(a=r(l[i]))?"".concat(s,"~").concat(a):"".concat(a,"~").concat(s)),h=0;void 0!==e[u]&&(h=e[u]),h+=1,e[u]=h})),Object.entries(e).forEach((function(t){var e=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(m).forEach((function(e,r){var n=m[e];t.push({id:e,size:n.count,r:Math.sqrt(n.sumforceNodeSize/Math.PI)}),g[e]=r})),w.forEach((function(t){var e=t.source,r=t.target,n=g[e],o=g[r];void 0!==n&&void 0!==o&&u.push({source:n,target:o,count:t.count})})),{nodes:t,links:u});e=lt(y.nodes).force("x",yt(f).strength(.1)).force("y",vt(d).strength(.1)).force("collide",wt((function(t){return t.r})).iterations(4)).force("charge",ct().strength(i)).force("links",gt(y.nodes.length?y.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-u[0],y:t.y-u[1]}})),g}function b(t){l={},t.forEach((function(t){l[t.id]=t}))}return v.initialize=function(t){h=t,x()},v.template=function(t){return arguments.length?(m=t,x(),v):m},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?(w=t,v):w},v.strength=function(t){return arguments.length?(y=t,v):y},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||[]),h=t||[],v):h},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?(u=t,v):u},v.getFocis=M,v}var Mt={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},bt=function(){function t(t){void 0===t&&(t={}),this.options=t,this.id="d3force",this.options=r(r({},Mt),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.genericForceLayout=function(t,e,n){var o=this,i=r(r({},this.options),n),s=i.layoutInvisibles,a=e.getAllNodes(),u=e.getAllEdges();s||(a=a.filter((function(t){var e=(t.data||{}).visible;return e||void 0===e})),u=u.filter((function(t){var e=(t.data||{}).visible;return e||void 0===e})));var h=a.map((function(t){var e,n;return r(r({},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})}));if(!this.running){var l=i.alphaMin,c=i.alphaDecay,f=i.alpha,d=i.nodeStrength,g=i.edgeStrength,p=i.linkDistance,m=i.clustering,w=i.clusterFociStrength,y=i.clusterEdgeDistance,v=i.clusterEdgeStrength,x=i.clusterNodeStrength,M=i.clusterNodeSize,b=i.collideStrength,E=void 0===b?1:b,N=i.center,S=void 0===N?[0,0]:N,k=i.preventOverlap,A=i.nodeSize,D=i.nodeSpacing,I=i.onTick,R=i.onLayoutEnd,_=i.forceSimulation;if(_)m&&((z=xt()).nodes(h),z.links(u)),_.nodes(h),u&&(P=gt().id((function(t){return t.id})).links(u),g&&P.strength(g),p&&P.distance(p),_.force("link",P)),k&&this.overlapProcess(_,{nodeSize:A,nodeSpacing:D,collideStrength:E}),_.alpha(f).restart(),this.running=!0;else try{var z,T=ct();if(d&&T.strength(d),_=lt().nodes(h),m&&((z=xt()).centerX(S[0]).centerY(S[1]).template("force").strength(w),u&&z.links(u),h&&z.nodes(h),z.forceLinkDistance(y).forceLinkStrength(v).forceCharge(x).forceNodeSize(M),_.force("group",z)),_.force("center",function(t,e){var r,n=1;function o(){var o,i,s=r.length,a=0,u=0;for(o=0;o<s;++o)a+=(i=r[o]).x,u+=i.y;for(a=(a/s-t)*n,u=(u/s-e)*n,o=0;o<s;++o)(i=r[o]).x-=a,i.y-=u}return null==t&&(t=0),null==e&&(e=0),o.initialize=function(t){r=t},o.x=function(e){return arguments.length?(t=+e,o):t},o.y=function(t){return arguments.length?(e=+t,o):e},o.strength=function(t){return arguments.length?(n=+t,o):n},o}(S[0],S[1])).force("charge",T).alpha(f).alphaDecay(c).alphaMin(l),k&&this.overlapProcess(_,{nodeSize:A,nodeSpacing:D,collideStrength:E}),u){var P=gt().id((function(t){return t.id})).links(u);g&&P.strength(g),p&&P.distance(p),_.force("link",P)}_.on("tick",(function(){null==I||I({nodes:Et(h),edges:Nt(u)})})).on("end",(function(){o.running=!1,null==R||R({nodes:Et(h),edges:Nt(u)})})),this.running=!0}catch(t){this.running=!1,console.warn(t)}var C=Et(h);return t&&C.forEach((function(t){return e.mergeNodeData(t.id,{x:t.data.x,y:t.data.y})})),{nodes:C,edges:u}}},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}:w(i)?i:function(){return 0},o)if(w(o))r=function(t){return o(t)+n(t)};else if(h(o)){var a=(o[0]>o[1]?o[0]:o[1])/2;r=function(t){return a+n(t)}}else if(l(o)){var u=o/2;r=function(t){return u+n(t)}}else r=function(){return 10};else r=function(t){return t.size?h(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}(),Et=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})})}))},Nt=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 St(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,animate:!0,factor:1,edgeStrength:200,nodeStrength:1e3,coulombDisScale:.005,damping:.9,maxSpeed:500,minMovement:.4,interval:.02,linkDistance:200,clusterNodeStrength:20,preventOverlap:!0,distanceThresholdMode:"mean"},At=function(){function t(t){void 0===t&&(t={}),this.options=t,this.id="force",this.timeInterval=0,this.judgingDistance=0,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.genericForceLayout=function(t,e,n){var o=this,i=r(r({},this.options),n),a=e.getAllNodes(),u=e.getAllEdges();i.layoutInvisibles||(a=a.filter((function(t){return t.data.visible||void 0===t.data.visible})),u=u.filter((function(t){return t.data.visible||void 0===t.data.visible})));var h=this.formatOptions(i,e),c=h.width,f=h.height,d=h.nodeSize,g=h.getMass,p=h.nodeStrength,m=h.edgeStrength,w=h.linkDistance,y=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=u.map((function(t){return r(r({},t),{data:r(r({},t.data),{edgeStrength:m(t),linkDistance:w(t,e.getNode(t.source),e.getNode(t.target))})})}));if(!(null==a?void 0:a.length))return{nodes:[],edges:u};var x={};a.forEach((function(t,e){x[t.id]={x:0,y:0}}));var M=new s({nodes:y,edges:v});this.formatCentripetal(h,M);var b=h.maxIteration,E=h.animate,N=h.minMovement,S=h.onLayoutEnd,k=h.onTick;if(!E){for(var A=0;(this.judgingDistance>N||A<1)&&A<b;A++)this.runOneStep(M,e,A,x,h),this.updatePosition(e,M,x,h),t&&y.forEach((function(t){return e.mergeNodeData(t.id,{x:t.data.x,y:t.data.y})})),null==k||k({nodes:zt(e,y),edges:u});t&&y.forEach((function(t){return e.mergeNodeData(t.id,{x:t.data.x,y:t.data.y})}));var D={nodes:zt(e,y),edges:u};return null==S||S(D),D}if("undefined"!=typeof window){var I=0;return this.timeInterval=window.setInterval((function(){a&&(o.runOneStep(M,e,I,x,h),o.updatePosition(e,M,x,h),t&&y.forEach((function(t){return e.mergeNodeData(t.id,{x:t.data.x,y:t.data.y})})),null==k||k({nodes:zt(e,y),edges:u}),(++I>=b||o.judgingDistance<N)&&(null==S||S({nodes:zt(e,y),edges:u}),window.clearInterval(o.timeInterval)))}),0),{nodes:zt(e,y),edges:u}}},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=y(0,t.nodeSpacing);t.nodeSize?h(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?h(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?y(1,t.linkDistance):function(t){return 1+r.nodeSize(e.getNode(t.source))+r.nodeSize(e.getNode(t.target))},r.nodeStrength=y(1,t.nodeStrength),r.edgeStrength=y(1,t.edgeStrength),t},t.prototype.formatCentripetal=function(t,e){var r,n=t.centripetalOptions,o=t.center,i=t.clusterNodeStrength,s=t.leafCluster,a=t.clustering,u=t.nodeClusterBy,h=e.getAllNodes(),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&&u&&(r=Dt(e,u),c=Array.from(new Set(null==h?void 0:h.map((function(t){return t.data[u]}))))||[],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=_t(s))}else n=void 0;return{x:null==n?void 0:n.x,y:null==n?void 0:n.y}}})),a&&u){r||(r=Dt(e,u)),c||(c=Array.from(new Set(h.map((function(t){return t.data[u]}))))),c=c.filter((function(t){return void 0!==t}));var f={};c.forEach((function(t){var r=h.filter((function(e){return e.data[u]===t})).map((function(t){return e.getNode(t.id)}));f[t]=_t(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[u]];return{x:null==e?void 0:e.x,y:null==e?void 0:e.y}}})}var d=t.centripetalOptions,g=d.leaf,p=d.single,m=d.others;g&&"function"!=typeof g&&(t.centripetalOptions.leaf=function(){return g}),p&&"function"!=typeof p&&(t.centripetalOptions.single=function(){return p}),m&&"function"!=typeof m&&(t.centripetalOptions.others=function(){return m})},t.prototype.runOneStep=function(t,e,r,n,o){var i={},s=t.getAllNodes(),a=t.getAllEdges();if(null==s?void 0:s.length){var u=o.monitor;this.calRepulsive(t,i,o),a&&this.calAttractive(t,i),this.calGravity(t,e,i,o),this.updateVelocity(t,i,n,o),u&&u({energy:this.calTotalEnergy(i,s),nodes:e.getAllNodes(),edges:e.getAllEdges(),iterations:r})}},t.prototype.calTotalEnergy=function(t,e){if(!(null==e?void 0:e.length))return 0;var r=0;return e.forEach((function(e,n){var o=t[e.id].x,i=t[e.id].y,s=o*o+i*i,a=e.data.mass;r+=(void 0===a?1:a)*s*.5})),r},t.prototype.calRepulsive=function(t,e,r){var n=r.factor,o=r.coulombDisScale;!function(t,e,r,n){var o=e/r,i=t.getAllNodes(),s=i.map((function(t,e){var r=t.data,n=r.nodeStrength;return{x:r.x,y:r.y,size:r.size,index:e,vx:0,vy:0,weight:o*n}})),a=R(s,(function(t){return t.x}),(function(t){return t.y})).visitAfter(St);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,u=n-e,h=s*s+a*a,l=Math.sqrt(h)*h;if(u*u*.81<h){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 u=a.data.x-s.data.x,h=a.data.y-s.data.y;u||h||(u=.01*Math.random(),h=.01*Math.random());var l=Math.sqrt(u*u+h*h),c=u/l,f=h/l,d=edgeInfos[n]||{},g=d.linkDistance,p=void 0===g?200:g,m=d.edgeStrength,w=(p-l)*(void 0===m?200:m),y=1/(s.data.mass||1),v=1/(a.data.mass||1),x=c*w,M=f*w;e[o].x-=x*y,e[o].y-=M*y,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(),u=e.getAllEdges(),h=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,m=p.mass,w=p.x,y=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==i?void 0:i(v,S);if(k){var A=o(k,3);x=w-A[0],M=y-A[1],b=A[2]}else x=w-f[0],M=y-f[1];if(b&&(r[s].x-=b*x/m,r[s].y-=b*M/m),g){var D=g.leaf,I=g.single,R=g.others,_=g.center,z=(null==_?void 0:_(v,a,u,h,c))||{x:0,y:0,centerStrength:0},T=z.x,P=z.y,C=z.centerStrength;if(!l(T)||!l(P))return;var O=(w-T)/m,j=(y-P)/m;if(C&&(r[s].x-=C*O,r[s].y-=C*j),0===S){var q=I(v);if(!q)return;return r[s].x-=q*O,void(r[s].y-=q*j)}if(0===E||0===N){var V=D(v,a,u);if(!V)return;return r[s].x-=V*O,void(r[s].y-=V*j)}var L=R(v);if(!L)return;r[s].x-=L*O,r[s].y-=L*j}}))},t.prototype.updateVelocity=function(t,e,r,n){var o=n.damping,i=n.maxSpeed,s=n.interval,a=t.getAllNodes();(null==a?void 0:a.length)&&a.forEach((function(t){var n=t.id,a=(r[n].x+e[n].x*s)*o||.01,u=(r[n].y+e[n].y*s)*o||.01,h=Math.sqrt(a*a+u*u);if(h>i){var l=i/h;a*=l,u*=l}r[n]={x:a,y:u}}))},t.prototype.updatePosition=function(t,e,r,n){var o=this,i=n.distanceThresholdMode,s=n.interval,a=e.getAllNodes();if(null==a?void 0:a.length){var u=0;"max"===i?this.judgingDistance=-1/0:"min"===i&&(this.judgingDistance=1/0),a.forEach((function(n){var a=n.id,h=t.getNode(a);if(l(h.data.fx)&&l(h.data.fy))e.mergeNodeData(a,{x:h.data.fx,y:h.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:u+=d}}})),i&&"mean"!==i||(this.judgingDistance=u/a.length)}else this.judgingDistance=0},t.prototype.stop=function(){this.timeInterval&&"undefined"!=typeof window&&window.clearInterval(this.timeInterval)},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]=It(t,"leaf",r,e))})),n},It=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:Rt(t,e,n,r,a)}},Rt=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},_t=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}},zt=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={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},Pt=function(){function t(t){void 0===t&&(t={}),this.options=t,this.id="grid",this.options=r(r({},Tt),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,u=o.condense,c=o.preventOverlapPadding,f=o.preventOverlap,d=o.rows,g=o.cols,p=o.nodeSpacing,w=o.nodeSize,x=o.width,M=o.height,b=o.layoutInvisibles,E=o.onLayoutEnd,N=o.position,S=o.sortBy,k=e.getAllNodes(),A=e.getAllEdges();b||(k=k.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=k.length;if(0===D){var I={nodes:[],edges:A};return null==E||E(I),I}if(1===D){t&&e.mergeNodeData(k[0].id,{x:s[0],y:s[1]});var R={nodes:[r(r({},k[0]),{data:r(r({},k[0].data),{x:s[0],y:s[1]})})],edges:A};return null==E||E(R),R}var _=k.map((function(t){return m(t)}));"id"===S||a(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 l(e.id)&&l(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 z=x||"undefined"==typeof window?x:window.innerWidth,T=M||"undefined"==typeof window?M:window.innerHeight,P=D,C={rows:d,cols:g};if(null!=d&&null!=g)C.rows=d,C.cols=g;else if(null!=d&&null==g)C.rows=d,C.cols=Math.ceil(P/C.rows);else if(null==d&&null!=g)C.cols=g,C.rows=Math.ceil(P/C.cols);else{var O=Math.sqrt(P*T/z);C.rows=Math.round(O),C.cols=Math.round(z/T*O)}if(C.rows=Math.max(C.rows,1),C.cols=Math.max(C.cols,1),C.cols*C.rows>P)((q=Ct(C))-1)*(j=Ot(C))>=P?Ct(C,q-1):(j-1)*q>=P&&Ot(C,j-1);else for(;C.cols*C.rows<P;){var j,q=Ct(C);((j=Ot(C))+1)*q>=P?Ot(C,j+1):Ct(C,q+1)}var V=u?0:z/C.cols,L=u?0:T/C.rows;if(f||p){var F=y(10,p),$=v(30,w,!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=$(o)||30;h(i)?(r=i[0],n=i[1]):(r=i,n=i);var s=void 0!==F?F(t):c,a=r+s,u=n+s;V=Math.max(V,a),L=Math.max(L,u)}))}for(var U={},B={row:0,col:0},K={},G=0;G<_.length;G++){var W=_[G],J=void 0;if(N&&(J=N(e.getNode(W.id))),J&&(void 0!==J.row||void 0!==J.col)){var H={row:J.row,col:J.col};if(void 0===H.col)for(H.col=0;jt(U,H);)H.col++;else if(void 0===H.row)for(H.row=0;jt(U,H);)H.row++;K[W.id]=H,qt(U,H)}Lt(W,s,V,L,K,C,B,U)}var Y={nodes:_,edges:A};return null==E||E(Y),t&&_.forEach((function(t){e.mergeNodeData(t.id,{x:t.data.x,y:t.data.y})})),Y},t}(),Ct=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},Ot=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},jt=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},Vt=function(t,e){var r=t.cols||5;e.col++,e.col>=r&&(e.col=0,e.row++)},Lt=function(t,e,r,n,o,i,s,a){var u,h,l=o[t.id];if(l)u=l.col*r+r/2+e[0],h=l.row*n+n/2+e[1];else{for(;jt(a,s);)Vt(i,s);u=s.col*r+r/2+e[0],h=s.row*n+n/2+e[1],qt(a,s),Vt(i,s)}t.data.x=u,t.data.y=h};const Ft=Object.prototype.toString;function $t(t){return Ft.call(t).endsWith("Array]")}function Ut(t){var e=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};if(!$t(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 Bt(t){var e=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};if(!$t(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 Kt(t){var e,r=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};if(!$t(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(!$t(r.output))throw new TypeError("output option must be an array if specified");e=r.output}else e=new Array(t.length);var n=Bt(t),o=Ut(t);if(n===o)throw new RangeError("minimum and maximum input values are equal. Cannot rescale a constant array");var i=r.min,s=void 0===i?r.autoMinMax?n:0:i,a=r.max,u=void 0===a?r.autoMinMax?o:1:a;if(s>=u)throw new RangeError("min option must be smaller than max option");for(var h=(u-s)/(o-n),l=0;l<t.length;l++)e[l]=(t[l]-n)*h+s;return e}const Gt=" ".repeat(2),Wt=" ".repeat(4);function Jt(t,e={}){const{maxRows:r=15,maxColumns:n=10,maxNumSize:o=8,padMinus:i="auto"}=e;return`${t.constructor.name} {\\n${Gt}[\\n${Wt}${function(t,e,r,n,o){const{rows:i,columns:s}=t,a=Math.min(i,e),u=Math.min(s,r),h=[];if("auto"===o){o=!1;t:for(let e=0;e<a;e++)for(let r=0;r<u;r++)if(t.get(e,r)<0){o=!0;break t}}for(let e=0;e<a;e++){let r=[];for(let i=0;i<u;i++)r.push(Ht(t.get(e,i),n,o));h.push(`${r.join(" ")}`)}return u!==s&&(h[h.length-1]+=` ... ${s-r} more columns`),a!==i&&h.push(`... ${i-e} more rows`),h.join(`\\n${Wt}`)}(t,r,n,o,i)}\\n${Gt}]\\n${Gt}rows: ${t.rows}\\n${Gt}columns: ${t.columns}\\n}`}function Ht(t,e,r){return(t>=0&&r?` ${Yt(t,e-1)}`:Yt(t,e)).padEnd(e)}function Yt(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 Xt(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 Qt(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 Zt(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 te(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 ee(t,e,r,n,o){if(5!==arguments.length)throw new RangeError("expected 4 arguments");if(ne("startRow",e),ne("endRow",r),ne("startColumn",n),ne("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 re(t,e=0){let r=[];for(let n=0;n<t;n++)r.push(e);return r}function ne(t,e){if("number"!=typeof e)throw new TypeError(`${t} must be a number`)}function oe(t){if(t.isEmpty())throw new Error("Empty matrix has no elements to index")}class ie{static from1DArray(t,e,r){if(t*e!==r.length)throw new RangeError("data length does not match given dimensions");let n=new ae(t,e);for(let o=0;o<t;o++)for(let t=0;t<e;t++)n.set(o,t,r[o*e+t]);return n}static rowVector(t){let e=new ae(1,t.length);for(let r=0;r<t.length;r++)e.set(0,r,t[r]);return e}static columnVector(t){let e=new ae(t.length,1);for(let r=0;r<t.length;r++)e.set(r,0,t[r]);return e}static zeros(t,e){return new ae(t,e)}static ones(t,e){return new ae(t,e).fill(1)}static rand(t,e,r={}){if("object"!=typeof r)throw new TypeError("options must be an object");const{random:n=Math.random}=r;let o=new ae(t,e);for(let r=0;r<t;r++)for(let t=0;t<e;t++)o.set(r,t,n());return o}static randInt(t,e,r={}){if("object"!=typeof r)throw new TypeError("options must be an object");const{min:n=0,max:o=1e3,random:i=Math.random}=r;if(!Number.isInteger(n))throw new TypeError("min must be an integer");if(!Number.isInteger(o))throw new TypeError("max must be an integer");if(n>=o)throw new RangeError("min must be smaller than max");let s=o-n,a=new ae(t,e);for(let r=0;r<t;r++)for(let t=0;t<e;t++){let e=n+Math.round(i()*s);a.set(r,t,e)}return a}static eye(t,e,r){void 0===e&&(e=t),void 0===r&&(r=1);let n=Math.min(t,e),o=this.zeros(t,e);for(let t=0;t<n;t++)o.set(t,t,r);return o}static diag(t,e,r){let n=t.length;void 0===e&&(e=n),void 0===r&&(r=e);let o=Math.min(n,e,r),i=this.zeros(e,r);for(let e=0;e<o;e++)i.set(e,e,t[e]);return i}static min(t,e){t=this.checkMatrix(t),e=this.checkMatrix(e);let r=t.rows,n=t.columns,o=new ae(r,n);for(let i=0;i<r;i++)for(let r=0;r<n;r++)o.set(i,r,Math.min(t.get(i,r),e.get(i,r)));return o}static max(t,e){t=this.checkMatrix(t),e=this.checkMatrix(e);let r=t.rows,n=t.columns,o=new this(r,n);for(let i=0;i<r;i++)for(let r=0;r<n;r++)o.set(i,r,Math.max(t.get(i,r),e.get(i,r)));return o}static checkMatrix(t){return ie.isMatrix(t)?t:new ae(t)}static isMatrix(t){return null!=t&&"Matrix"===t.klass}get size(){return this.rows*this.columns}apply(t){if("function"!=typeof t)throw new TypeError("callback must be a function");for(let e=0;e<this.rows;e++)for(let r=0;r<this.columns;r++)t.call(this,e,r);return this}to1DArray(){let t=[];for(let e=0;e<this.rows;e++)for(let r=0;r<this.columns;r++)t.push(this.get(e,r));return t}to2DArray(){let t=[];for(let e=0;e<this.rows;e++){t.push([]);for(let r=0;r<this.columns;r++)t[e].push(this.get(e,r))}return t}toJSON(){return this.to2DArray()}isRowVector(){return 1===this.rows}isColumnVector(){return 1===this.columns}isVector(){return 1===this.rows||1===this.columns}isSquare(){return this.rows===this.columns}isEmpty(){return 0===this.rows||0===this.columns}isSymmetric(){if(this.isSquare()){for(let t=0;t<this.rows;t++)for(let e=0;e<=t;e++)if(this.get(t,e)!==this.get(e,t))return!1;return!0}return!1}isEchelonForm(){let t=0,e=0,r=-1,n=!0,o=!1;for(;t<this.rows&&n;){for(e=0,o=!1;e<this.columns&&!1===o;)0===this.get(t,e)?e++:1===this.get(t,e)&&e>r?(o=!0,r=e):(n=!1,o=!0);t++}return n}isReducedEchelonForm(){let t=0,e=0,r=-1,n=!0,o=!1;for(;t<this.rows&&n;){for(e=0,o=!1;e<this.columns&&!1===o;)0===this.get(t,e)?e++:1===this.get(t,e)&&e>r?(o=!0,r=e):(n=!1,o=!0);for(let r=e+1;r<this.rows;r++)0!==this.get(t,r)&&(n=!1);t++}return n}echelonForm(){let t=this.clone(),e=0,r=0;for(;e<t.rows&&r<t.columns;){let n=e;for(let o=e;o<t.rows;o++)t.get(o,r)>t.get(n,r)&&(n=o);if(0===t.get(n,r))r++;else{t.swapRows(e,n);let o=t.get(e,r);for(let n=r;n<t.columns;n++)t.set(e,n,t.get(e,n)/o);for(let n=e+1;n<t.rows;n++){let o=t.get(n,r)/t.get(e,r);t.set(n,r,0);for(let i=r+1;i<t.columns;i++)t.set(n,i,t.get(n,i)-t.get(e,i)*o)}e++,r++}}return t}reducedEchelonForm(){let t=this.echelonForm(),e=t.columns,r=t.rows,n=r-1;for(;n>=0;)if(0===t.maxRow(n))n--;else{let o=0,i=!1;for(;o<r&&!1===i;)1===t.get(n,o)?i=!0:o++;for(let r=0;r<n;r++){let i=t.get(r,o);for(let s=o;s<e;s++){let e=t.get(r,s)-i*t.get(n,s);t.set(r,s,e)}}n--}return t}set(){throw new Error("set method is unimplemented")}get(){throw new Error("get method is unimplemented")}repeat(t={}){if("object"!=typeof t)throw new TypeError("options must be an object");const{rows:e=1,columns:r=1}=t;if(!Number.isInteger(e)||e<=0)throw new TypeError("rows must be a positive integer");if(!Number.isInteger(r)||r<=0)throw new TypeError("columns must be a positive integer");let n=new ae(this.rows*e,this.columns*r);for(let t=0;t<e;t++)for(let e=0;e<r;e++)n.setSubMatrix(this,this.rows*t,this.columns*e);return n}fill(t){for(let e=0;e<this.rows;e++)for(let r=0;r<this.columns;r++)this.set(e,r,t);return this}neg(){return this.mulS(-1)}getRow(t){Xt(this,t);let e=[];for(let r=0;r<this.columns;r++)e.push(this.get(t,r));return e}getRowVector(t){return ae.rowVector(this.getRow(t))}setRow(t,e){Xt(this,t),e=Zt(this,e);for(let r=0;r<this.columns;r++)this.set(t,r,e[r]);return this}swapRows(t,e){Xt(this,t),Xt(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){Qt(this,t);let e=[];for(let r=0;r<this.rows;r++)e.push(this.get(r,t));return e}getColumnVector(t){return ae.columnVector(this.getColumn(t))}setColumn(t,e){Qt(this,t),e=te(this,e);for(let r=0;r<this.rows;r++)this.set(r,t,e[r]);return this}swapColumns(t,e){Qt(this,t),Qt(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=Zt(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=Zt(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=Zt(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=Zt(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=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[e]);return this}subColumnVector(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[e]);return this}mulColumnVector(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[e]);return this}divColumnVector(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[e]);return this}mulRow(t,e){Xt(this,t);for(let r=0;r<this.columns;r++)this.set(t,r,this.get(t,r)*e);return this}mulColumn(t,e){Qt(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(){oe(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(){oe(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(Xt(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){Xt(this,t),oe(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(Xt(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){Xt(this,t),oe(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(Qt(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){Qt(this,t),oe(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(Qt(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){Qt(this,t),oe(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){ie.isMatrix(t)&&(t=t.to1DArray());let e=this.to1DArray();if(e.length!==t.length)throw new RangeError("vectors do not have the same size");let r=0;for(let n=0;n<e.length;n++)r+=e[n]*t[n];return r}mmul(t){t=ae.checkMatrix(t);let e=this.rows,r=this.columns,n=t.columns,o=new ae(e,n),i=new Float64Array(r);for(let s=0;s<n;s++){for(let e=0;e<r;e++)i[e]=t.get(e,s);for(let t=0;t<e;t++){let e=0;for(let n=0;n<r;n++)e+=this.get(t,n)*i[n];o.set(t,s,e)}}return o}strassen2x2(t){t=ae.checkMatrix(t);let e=new ae(2,2);const r=this.get(0,0),n=t.get(0,0),o=this.get(0,1),i=t.get(0,1),s=this.get(1,0),a=t.get(1,0),u=this.get(1,1),h=t.get(1,1),l=(r+u)*(n+h),c=(s+u)*n,f=r*(i-h),d=u*(a-n),g=(r+o)*h,p=l+d-g+(o-u)*(a+h),m=f+g,w=c+d,y=l-c+f+(s-r)*(n+i);return e.set(0,0,p),e.set(0,1,m),e.set(1,0,w),e.set(1,1,y),e}strassen3x3(t){t=ae.checkMatrix(t);let e=new ae(3,3);const r=this.get(0,0),n=this.get(0,1),o=this.get(0,2),i=this.get(1,0),s=this.get(1,1),a=this.get(1,2),u=this.get(2,0),h=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),m=t.get(1,2),w=t.get(2,0),y=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+u+h)*(c-d+m),S=(-r+u)*(d-m),k=(u+h)*(-c+d),A=(-o+h+l)*(p+w-y),D=(o-l)*(p-y),I=o*w,R=(h+l)*(-w+y),_=(-o+s+a)*(m+w-v),z=(o-a)*(m-v),T=(s+a)*(-w+v),P=E+I+n*g,C=(r+n+o-i-s-h-l)*p+M+b+E+A+I+R,O=E+N+k+(r+n+o-s-a-u-h)*m+I+_+T,j=x+s*(-c+f+g-p-m-w+v)+M+E+I+_+z,q=x+M+b+E+a*y,V=I+_+z+T+i*d,L=E+N+S+h*(-c+d+g-p-m-w+y)+A+D+I,F=A+D+I+R+u*f,$=E+N+S+k+l*v;return e.set(0,0,P),e.set(0,1,C),e.set(0,2,O),e.set(1,0,j),e.set(1,1,q),e.set(1,2,V),e.set(2,0,L),e.set(2,1,F),e.set(2,2,$),e}mmulStrassen(t){t=ae.checkMatrix(t);let e=this.clone(),r=e.rows,n=e.columns,o=t.rows,i=t.columns;function s(t,e,r){let n=t.rows,o=t.columns;if(n===e&&o===r)return t;{let n=ie.zeros(e,r);return n=n.setSubMatrix(t,0,0),n}}n!==o&&console.warn(`Multiplying ${r} x ${n} and ${o} x ${i} matrix: dimensions do not match.`);let a=Math.max(r,o),u=Math.max(n,i);return e=s(e,a,u),function t(e,r,n,o){if(n<=512||o<=512)return e.mmul(r);n%2==1&&o%2==1?(e=s(e,n+1,o+1),r=s(r,n+1,o+1)):n%2==1?(e=s(e,n+1,o),r=s(r,n+1,o)):o%2==1&&(e=s(e,n,o+1),r=s(r,n,o+1));let i=parseInt(e.rows/2,10),a=parseInt(e.columns/2,10),u=e.subMatrix(0,i-1,0,a-1),h=r.subMatrix(0,i-1,0,a-1),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),m=t(ie.add(u,g),ie.add(h,p),i,a),w=t(ie.add(f,g),h,i,a),y=t(u,ie.sub(c,p),i,a),v=t(g,ie.sub(d,h),i,a),x=t(ie.add(u,l),p,i,a),M=t(ie.sub(f,u),ie.add(h,c),i,a),b=t(ie.sub(l,g),ie.add(d,p),i,a),E=ie.add(m,v);E.sub(x),E.add(b);let N=ie.add(y,x),S=ie.add(w,v),k=ie.sub(m,w);k.add(y),k.add(M);let A=ie.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,u),a,u)}scaleRows(t={}){if("object"!=typeof t)throw new TypeError("options must be an object");const{min:e=0,max:r=1}=t;if(!Number.isFinite(e))throw new TypeError("min must be a number");if(!Number.isFinite(r))throw new TypeError("max must be a number");if(e>=r)throw new RangeError("min must be smaller than max");let n=new ae(this.rows,this.columns);for(let t=0;t<this.rows;t++){const o=this.getRow(t);o.length>0&&Kt(o,{min:e,max:r,output:o}),n.setRow(t,o)}return n}scaleColumns(t={}){if("object"!=typeof t)throw new TypeError("options must be an object");const{min:e=0,max:r=1}=t;if(!Number.isFinite(e))throw new TypeError("min must be a number");if(!Number.isFinite(r))throw new TypeError("max must be a number");if(e>=r)throw new RangeError("min must be smaller than max");let n=new ae(this.rows,this.columns);for(let t=0;t<this.columns;t++){const o=this.getColumn(t);o.length&&Kt(o,{min:e,max:r,output:o}),n.setColumn(t,o)}return n}flipRows(){const t=Math.ceil(this.columns/2);for(let e=0;e<this.rows;e++)for(let r=0;r<t;r++){let t=this.get(e,r),n=this.get(e,this.columns-1-r);this.set(e,r,n),this.set(e,this.columns-1-r,t)}return this}flipColumns(){const t=Math.ceil(this.rows/2);for(let e=0;e<this.columns;e++)for(let r=0;r<t;r++){let t=this.get(r,e),n=this.get(this.rows-1-r,e);this.set(r,e,n),this.set(this.rows-1-r,e,t)}return this}kroneckerProduct(t){t=ae.checkMatrix(t);let e=this.rows,r=this.columns,n=t.rows,o=t.columns,i=new ae(e*n,r*o);for(let s=0;s<e;s++)for(let e=0;e<r;e++)for(let r=0;r<n;r++)for(let a=0;a<o;a++)i.set(n*s+r,o*e+a,this.get(s,e)*t.get(r,a));return i}kroneckerSum(t){if(t=ae.checkMatrix(t),!this.isSquare()||!t.isSquare())throw new Error("Kronecker Sum needs two Square Matrices");let e=this.rows,r=t.rows,n=this.kroneckerProduct(ae.eye(r,r)),o=ae.eye(e,e).kroneckerProduct(t);return n.add(o)}transpose(){let t=new ae(this.columns,this.rows);for(let e=0;e<this.rows;e++)for(let r=0;r<this.columns;r++)t.set(r,e,this.get(e,r));return t}sortRows(t=se){for(let e=0;e<this.rows;e++)this.setRow(e,this.getRow(e).sort(t));return this}sortColumns(t=se){for(let e=0;e<this.columns;e++)this.setColumn(e,this.getColumn(e).sort(t));return this}subMatrix(t,e,r,n){ee(this,t,e,r,n);let o=new ae(e-t+1,n-r+1);for(let i=t;i<=e;i++)for(let e=r;e<=n;e++)o.set(i-t,e-r,this.get(i,e));return o}subMatrixRow(t,e,r){if(void 0===e&&(e=0),void 0===r&&(r=this.columns-1),e>r||e<0||e>=this.columns||r<0||r>=this.columns)throw new RangeError("Argument out of range");let n=new ae(t.length,r-e+1);for(let o=0;o<t.length;o++)for(let i=e;i<=r;i++){if(t[o]<0||t[o]>=this.rows)throw new RangeError(`Row index out of range: ${t[o]}`);n.set(o,i-e,this.get(t[o],i))}return n}subMatrixColumn(t,e,r){if(void 0===e&&(e=0),void 0===r&&(r=this.rows-1),e>r||e<0||e>=this.rows||r<0||r>=this.rows)throw new RangeError("Argument out of range");let n=new ae(r-e+1,t.length);for(let o=0;o<t.length;o++)for(let i=e;i<=r;i++){if(t[o]<0||t[o]>=this.columns)throw new RangeError(`Column index out of range: ${t[o]}`);n.set(i-e,o,this.get(i,t[o]))}return n}setSubMatrix(t,e,r){if((t=ae.checkMatrix(t)).isEmpty())return this;ee(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(!$t(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(!$t(e))throw new TypeError("column indices must be an array");for(let r=0;r<e.length;r++)if(e[r]<0||e[r]>=t.columns)throw new RangeError("column indices are out of range")}(this,e);let r=new ae(t.length,e.length);for(let n=0;n<t.length;n++){let o=t[n];for(let t=0;t<e.length;t++){let i=e[t];r.set(n,t,this.get(o,i))}}return r}trace(){let t=Math.min(this.rows,this.columns),e=0;for(let r=0;r<t;r++)e+=this.get(r,r);return e}clone(){let t=new ae(this.rows,this.columns);for(let e=0;e<this.rows;e++)for(let r=0;r<this.columns;r++)t.set(e,r,this.get(e,r));return t}sum(t){switch(t){case"row":return function(t){let e=re(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=re(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=re(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=re(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(!$t(n))throw new TypeError("mean must be an array");return function(t,e,r){const n=t.rows,o=t.columns,i=[];for(let s=0;s<n;s++){let n=0,a=0,u=0;for(let e=0;e<o;e++)u=t.get(s,e)-r[s],n+=u,a+=u*u;e?i.push((a-n*n/o)/(o-1)):i.push((a-n*n/o)/o)}return i}(this,r,n);case"column":if(!$t(n))throw new TypeError("mean must be an array");return function(t,e,r){const n=t.rows,o=t.columns,i=[];for(let s=0;s<o;s++){let o=0,a=0,u=0;for(let e=0;e<n;e++)u=t.get(e,s)-r[s],o+=u,a+=u*u;e?i.push((a-o*o/n)/(n-1)):i.push((a-o*o/n)/n)}return i}(this,r,n);case void 0:if("number"!=typeof n)throw new TypeError("mean must be a number");return function(t,e,r){const n=t.rows,o=t.columns,i=n*o;let s=0,a=0,u=0;for(let e=0;e<n;e++)for(let n=0;n<o;n++)u=t.get(e,n)-r,s+=u,a+=u*u;return e?(a-s*s/i)/(i-1):(a-s*s/i)/i}(this,r,n);default:throw new Error(`invalid option: ${t}`)}}standardDeviation(t,e){"object"==typeof t&&(e=t,t=void 0);const r=this.variance(t,e);if(void 0===t)return Math.sqrt(r);for(let t=0;t<r.length;t++)r[t]=Math.sqrt(r[t]);return r}center(t,e={}){if("object"==typeof t&&(e=t,t=void 0),"object"!=typeof e)throw new TypeError("options must be an object");const{center:r=this.mean(t)}=e;switch(t){case"row":if(!$t(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(!$t(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(!$t(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(!$t(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 Jt(this,t)}}function se(t,e){return t-e}ie.prototype.klass="Matrix","undefined"!=typeof Symbol&&(ie.prototype[Symbol.for("nodejs.util.inspect.custom")]=function(){return Jt(this)}),ie.random=ie.rand,ie.randomInt=ie.randInt,ie.diagonal=ie.diag,ie.prototype.diagonal=ie.prototype.diag,ie.identity=ie.eye,ie.prototype.negate=ie.prototype.neg,ie.prototype.tensorProduct=ie.prototype.kroneckerProduct;class ae extends ie{constructor(t,e){if(super(),ae.isMatrix(t))return t.clone();if(Number.isInteger(t)&&t>=0){if(this.data=[],!(Number.isInteger(e)&&e>=0))throw new TypeError("nColumns must be a positive integer");for(let r=0;r<t;r++)this.data.push(new Float64Array(e))}else{if(!$t(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 Xt(this,t),this.data.splice(t,1),this.rows-=1,this}addRow(t,e){return void 0===e&&(e=t,t=this.rows),Xt(this,t,!0),e=Float64Array.from(Zt(this,e)),this.data.splice(t,0,e),this.rows+=1,this}removeColumn(t){Qt(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),Qt(this,t,!0),e=te(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}}(ie,ae);class ue extends ie{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 he(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 le{constructor(t,e={}){if((t=ue.checkMatrix(t)).isEmpty())throw new Error("Matrix must be non-empty");let r=t.rows,n=t.columns;const{computeLeftSingularVectors:o=!0,computeRightSingularVectors:i=!0,autoTranspose:s=!1}=e;let a,u=Boolean(o),h=Boolean(i),l=!1;if(r<n)if(s){a=t.transpose(),r=a.rows,n=a.columns,l=!0;let e=u;u=h,h=e}else a=t.clone(),console.warn("Computing SVD on a matrix with more columns than rows. Consider enabling autoTranspose");else a=t.clone();let c=Math.min(r,n),f=Math.min(r+1,n),d=new Float64Array(f),g=new ae(r,c),p=new ae(n,n),m=new Float64Array(n),w=new Float64Array(r),y=new Float64Array(f);for(let t=0;t<f;t++)y[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]=he(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))}m[e]=a.get(t,e)}if(u&&t<v)for(let e=t;e<r;e++)g.set(e,t,a.get(e,t));if(t<x){m[t]=0;for(let e=t+1;e<n;e++)m[t]=he(m[t],m[e]);if(0!==m[t]){m[t+1]<0&&(m[t]=0-m[t]);for(let e=t+1;e<n;e++)m[e]/=m[t];m[t+1]+=1}if(m[t]=-m[t],t+1<r&&0!==m[t]){for(let e=t+1;e<r;e++)w[e]=0;for(let e=t+1;e<r;e++)for(let r=t+1;r<n;r++)w[e]+=m[r]*a.get(e,r);for(let e=t+1;e<n;e++){let n=-m[e]/m[t+1];for(let o=t+1;o<r;o++)a.set(o,e,a.get(o,e)+n*w[o])}}if(h)for(let e=t+1;e<n;e++)p.set(e,t,m[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&&(m[x]=a.get(x,b-1)),m[b-1]=0,u){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(h)for(let t=n-1;t>=0;t--){if(t<x&&0!==m[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(m[t])<=e||Number.isNaN(m[t])){m[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(m[r]):0)+(r!==t+1?Math.abs(m[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=m[b-2];m[b-2]=0;for(let r=b-2;r>=t;r--){let o=he(d[r],e),i=d[r]/o,s=e/o;if(d[r]=o,r!==t&&(e=-s*m[r-1],m[r-1]=i*m[r-1]),h)for(let t=0;t<n;t++)o=i*p.get(t,r)+s*p.get(t,b-1),p.set(t,b-1,-s*p.get(t,r)+i*p.get(t,b-1)),p.set(t,r,o)}break}case 2:{let e=m[t-1];m[t-1]=0;for(let n=t;n<b;n++){let o=he(d[n],e),i=d[n]/o,s=e/o;if(d[n]=o,e=-s*m[n],m[n]=i*m[n],u)for(let e=0;e<r;e++)o=i*g.get(e,n)+s*g.get(e,t-1),g.set(e,t-1,-s*g.get(e,n)+i*g.get(e,t-1)),g.set(e,n,o)}break}case 3:{const e=Math.max(Math.abs(d[b-1]),Math.abs(d[b-2]),Math.abs(m[b-2]),Math.abs(d[t]),Math.abs(m[t])),o=d[b-1]/e,i=d[b-2]/e,s=m[b-2]/e,a=d[t]/e,l=m[t]/e,c=((i+o)*(i-o)+s*s)/2,f=o*s*(o*s);let w=0;0===c&&0===f||(w=c<0?0-Math.sqrt(c*c+f):Math.sqrt(c*c+f),w=f/(c+w));let y=(a+o)*(a-o)+w,v=a*l;for(let e=t;e<b-1;e++){let o=he(y,v);0===o&&(o=Number.MIN_VALUE);let i=y/o,s=v/o;if(e!==t&&(m[e-1]=o),y=i*d[e]+s*m[e],m[e]=i*m[e]-s*d[e],v=s*d[e+1],d[e+1]=i*d[e+1],h)for(let t=0;t<n;t++)o=i*p.get(t,e)+s*p.get(t,e+1),p.set(t,e+1,-s*p.get(t,e)+i*p.get(t,e+1)),p.set(t,e,o);if(o=he(y,v),0===o&&(o=Number.MIN_VALUE),i=y/o,s=v/o,d[e]=o,y=i*m[e]+s*d[e+1],d[e+1]=-s*m[e]+i*d[e+1],v=s*m[e+1],m[e+1]=i*m[e+1],u&&e<r-1)for(let t=0;t<r;t++)o=i*g.get(t,e)+s*g.get(t,e+1),g.set(t,e+1,-s*g.get(t,e)+i*g.get(t,e+1)),g.set(t,e,o)}m[b-2]=y,N+=1;break}case 4:if(d[t]<=0&&(d[t]=d[t]<0?-d[t]:0,h))for(let e=0;e<=E;e++)p.set(e,t,-p.get(e,t));for(;t<E&&!(d[t]>=d[t+1]);){let e=d[t];if(d[t]=d[t+1],d[t+1]=e,h&&t<n-1)for(let r=0;r<n;r++)e=p.get(r,t+1),p.set(r,t+1,p.get(r,t)),p.set(r,t,e);if(u&&t<r-1)for(let n=0;n<r;n++)e=g.get(n,t+1),g.set(n,t+1,g.get(n,t)),g.set(n,t,e);t++}N=0,b--}}if(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=ae.zeros(n,n);for(let t=0;t<n;t++)Math.abs(this.s[t])<=r?o.set(t,t,0):o.set(t,t,1/this.s[t]);let i=this.U,s=this.rightSingularVectors,a=s.mmul(o),u=s.rows,h=i.rows,l=ae.zeros(u,h);for(let t=0;t<u;t++)for(let e=0;e<h;e++){let r=0;for(let o=0;o<n;o++)r+=a.get(t,o)*i.get(e,o);l.set(t,e,r)}return l.mmul(e)}solveForDiagonal(t){return this.solve(ae.diag(t))}inverse(){let t=this.V,e=this.threshold,r=t.rows,n=t.columns,o=new ae(r,this.s.length);for(let i=0;i<r;i++)for(let r=0;r<n;r++)Math.abs(this.s[r])>e&&o.set(i,r,t.get(i,r)/this.s[r]);let i=this.U,s=i.rows,a=i.columns,u=new ae(r,s);for(let t=0;t<r;t++)for(let e=0;e<s;e++){let r=0;for(let n=0;n<a;n++)r+=o.get(t,n)*i.get(e,n);u.set(t,e,r)}return u}get condition(){return this.s[0]/this.s[Math.min(this.m,this.n)-1]}get norm2(){return this.s[0]}get rank(){let t=Math.max(this.m,this.n)*this.s[0]*Number.EPSILON,e=0,r=this.s;for(let n=0,o=r.length;n<o;n++)r[n]>t&&e++;return e}get diagonal(){return Array.from(this.s)}get threshold(){return Number.EPSILON/2*Math.max(this.m,this.n)*this.s[0]}get leftSingularVectors(){return this.U}get rightSingularVectors(){return this.V}get diagonalMatrix(){return ae.diag(this.s)}}var ce={center:[0,0],linkDistance:50},fe=function(){function t(t){void 0===t&&(t={}),this.options=t,this.id="mds",this.options=r(r({},ce),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,u=void 0===a?50:a,h=o.layoutInvisibles,l=o.onLayoutEnd,d=e.getAllNodes(),g=e.getAllEdges();if(h||(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}))),!d||0===d.length){var p={nodes:[],edges:g};return null==l||l(p),p}if(1===d.length){t&&e.mergeNodeData(d[0].id,{x:s[0],y:s[1]});var w={nodes:[r(r({},d[0]),{data:r(r({},d[0].data),{x:s[0],y:s[1]})})],edges:g};return null==l||l(w),w}var y=f({nodes:d,edges:g},!1),v=c(y);de(v);var x=function(t,e){var r=[];return t.forEach((function(t){var n=[];t.forEach((function(t){n.push(t*e)})),r.push(n)})),r}(v,u),M=ge(x),b=[];M.forEach((function(t,e){var r=m(d[e]);r.data.x=t[0]+s[0],r.data.y=t[1]+s[1],b.push(r)})),t&&b.forEach((function(t){return e.mergeNodeData(t.id,{x:t.data.x,y:t.data.y})}));var E={nodes:b,edges:g};return null==l||l(E),E},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)}))}))},ge=function(t){var e=ae.mul(ae.pow(t,2),-.5),r=e.mean("row"),n=e.mean("column"),o=e.mean();e.add(o).subRowVector(r).subColumnVector(n);var i=new le(e),s=ae.sqrt(i.diagonalMatrix).diagonal();return i.leftSingularVectors.toJSON().map((function(t){return ae.mul([t],[s]).toJSON()[0].splice(0,2)}))},pe={iterations:10,height:10,width:10,speed:100,gravity:10,k:5},me=function(t,e,r,n,o,i){e.forEach((function(s,a){r[a]={x:0,y:0},e.forEach((function(e,u){if(a!==u&&o[a]===o[u]){var h=s.x-e.x,l=s.y-e.y,c=Math.sqrt(h*h+l*l);if(0===c){c=1;var f=a>u?1:-1;h=.01*f,l=.01*f}if(c<i(t[a])/2+i(t[u])/2){var d=n*n/c;r[a].x+=h/c*d,r[a].y+=l/c*d}}}))}))},we=function(t,e,r,n,o,i,s,a){var u=i||s/10;return n&&e.forEach((function(e,r){var n=t[r].x-t[o].x,i=t[r].y-t[o].y,s=Math.sqrt(n*n+i*i),a=i/s,u=-n/s,h=Math.sqrt(e.x*e.x+e.y*e.y),l=Math.acos((a*e.x+u*e.y)/h);l>Math.PI/2&&(l-=Math.PI/2,a*=-1,u*=-1);var c=Math.cos(l)*h;e.x=a*c,e.y=u*c})),t.forEach((function(i,s){if(s!==o){var h=Math.sqrt(e[s].x*e[s].x+e[s].y*e[s].y);if(h>0&&s!==o){var l=Math.min(u*(r/800),h);if(i.x+=e[s].x/h*l,i.y+=e[s].y/h*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},ye={maxIteration:1e3,focusNode:null,unitRadius:null,linkDistance:50,preventOverlap:!1,strictRadial:!0,maxPreventOverlapIteration:200,sortStrength:10},ve=function(){function t(t){void 0===t&&(t={}),this.options=t,this.id="radial",this.options=r(r({},ye),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),u=s.width,h=s.height,l=s.center,d=s.focusNode,g=s.unitRadius,p=s.nodeSize,w=s.nodeSpacing,y=s.strictRadial,v=s.preventOverlap,x=s.maxPreventOverlapIteration,M=s.sortBy,b=s.linkDistance,E=void 0===b?50:b,N=s.sortStrength,S=void 0===N?10:N,k=s.maxIteration,A=void 0===k?1e3:k,D=s.layoutInvisibles,I=s.onLayoutEnd,R=e.getAllNodes(),_=e.getAllEdges();if(D||(R=R.filter((function(t){var e=(t.data||{}).visible;return e||void 0===e})),_=_.filter((function(t){var e=(t.data||{}).visible;return e||void 0===e}))),!R||0===R.length){var z={nodes:[],edges:_};return null==I||I(z),z}var T=u||"undefined"==typeof window?u:window.innerWidth,P=h||"undefined"==typeof window?h:window.innerHeight,C=l||[T/2,P/2];if(1===R.length){t&&e.mergeNodeData(R[0].id,{x:C[0],y:C[1]});var O={nodes:[r(r({},R[0]),{data:r(r({},R[0].data),{x:C[0],y:C[1]})})],edges:_};return null==I||I(O),O}var j=R[0];if(a(d)){for(var q=0;q<R.length;q++)if(R[q].id===d){j=R[q];break}}else j=d||R[0];var V=be(R,j.id),L=f({nodes:R,edges:_},!1),F=c(L),$=Ne(F,V);Ee(F,V,$+1);var U=F[V],B=T-C[0]>C[0]?C[0]:T-C[0],K=P-C[1]>C[1]?C[1]:P-C[1];0===B&&(B=T/2),0===K&&(K=P/2);var G=Math.min(B,K),W=Math.max.apply(Math,i([],o(U),!1)),J=[],H=g||G/W;U.forEach((function(t,e){J[e]=t*H}));var Y,X=xe(R,F,E,J,H,M,S),Q=Me(X),Z=function(t,e,r){try{var n=ae.mul(ae.pow(e,2),-.5),o=n.mean("row"),i=n.mean("column"),s=n.mean();n.add(s).subRowVector(o).subColumnVector(i);var a=new le(n),u=ae.sqrt(a.diagonalMatrix).diagonal();return a.leftSingularVectors.toJSON().map((function(e){return ae.mul([e],[u]).toJSON()[0].splice(0,t)}))}catch(t){for(var h=[],l=0;l<e.length;l++){var c=Math.random()*r,f=Math.random()*r;h.push([c,f])}return h}}(E,X,E),tt=Z.map((function(t){var e=o(t,2),r=e[0],n=e[1];return{x:(isNaN(r)?Math.random()*E:r)-Z[V][0],y:(isNaN(n)?Math.random()*E:n)-Z[V][1]}}));if(this.run(A,tt,Q,X,J,V),v){Y=Se(p,w);var et={nodes:R,nodeSizeFunc:Y,positions:tt,radii:J,height:P,width:T,strictRadial:Boolean(y),focusIdx:V,iterations:x||200,k:tt.length/4.5};tt=function(t,e){for(var n=r(r({},pe),e),o=n.positions,i=n.iterations,s=n.width,a=n.k,u=n.speed,h=void 0===u?100:u,l=n.strictRadial,c=n.focusIdx,f=n.radii,d=void 0===f?[]:f,g=n.nodeSizeFunc,p=t.getAllNodes(),m=[],w=s/10,y=0;y<i;y++)o.forEach((function(t,e){m[e]={x:0,y:0}})),me(p,o,m,a,d,g),we(o,m,h,l,c,w,s,d);return o}(e,et)}var rt=[];tt.forEach((function(t,e){var r=m(R[e]);r.data.x=t.x+C[0],r.data.y=t.y+C[1],rt.push(r)})),t&&rt.forEach((function(t){return e.mergeNodeData(t.id,{x:t.data.x,y:t.data.y})}));var nt={nodes:rt,edges:_};return null==I||I(nt),nt},t.prototype.run=function(t,e,r,n,o,i){for(var s=0;s<=t;s++){var a=s/t;this.oneIteration(a,e,o,n,r,i)}},t.prototype.oneIteration=function(t,e,r,n,o,i){var s=1-t;e.forEach((function(a,u){var h=d(a,{x:0,y:0}),l=0===h?0:1/h;if(u!==i){var c=0,f=0,g=0;e.forEach((function(t,e){if(u!==e){var r=d(a,t),i=0===r?0:1/r,s=n[e][u];g+=o[u][e],c+=o[u][e]*(t.x+s*(a.x-t.x)*i),f+=o[u][e]*(t.y+s*(a.y-t.y)*i)}}));var p=0===r[u]?0:1/r[u];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}(),xe=function(t,e,r,n,o,i,s){if(!t)return[];var u=[];if(e){var h={};e.forEach((function(e,l){var c=[];e.forEach((function(e,u){var f,d;if(l===u)c.push(0);else if(n[l]===n[u])if("data"===i)c.push(e*(Math.abs(l-u)*s)/(n[l]/o));else if(i){var g=void 0,p=void 0;if(h[t[l].id])g=h[t[l].id];else{var m=("id"===i?t[l].id:null===(f=t[l].data)||void 0===f?void 0:f[i])||0;g=a(m)?m.charCodeAt(0):m,h[t[l].id]=g}h[t[u].id]?p=h[t[u].id]:(m=("id"===i?t[u].id:null===(d=t[u].data)||void 0===d?void 0:d[i])||0,p=a(m)?m.charCodeAt(0):m,h[t[u].id]=p),c.push(e*(Math.abs(g-p)*s)/(n[l]/o))}else c.push(e*r/(n[l]/o));else{var w=(r+o)/2;c.push(e*w)}})),u.push(c)}))}return u},Me=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},be=function(t,e){var r=-1;return t.forEach((function(t,n){t.id===e&&(r=n)})),Math.max(r,0)},Ee=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}},Ne=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},Se=function(t,e){var r;return r=l(e)?function(){return e}:w(e)?e:function(){return 0},t?h(t)?function(e){return(t[0]>t[1]?t[0]:t[1])+r(e)}:function(e){return t+r(e)}:function(t){return t.data.bboxSize?Math.max(t.data.bboxSize[0],t.data.bboxSize[1])+r(t):t.data.size?h(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)}},ke={center:[0,0],width:300,height:300},Ae={circular:M,concentric:S,mds:fe,random:function(){function t(t){void 0===t&&(t={}),this.options=t,this.id="random",this.options=r(r({},ke),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,u=o.layoutInvisibles,h=o.onLayoutEnd,l=e.getAllNodes();u||(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==h||h(p),p},t}(),grid:Pt,radial:ve,force:At,d3force:bt};function De(t,e){return r=this,n=void 0,i=function(){var r,n,o,i,a,u,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(u){return function(a){if(r)throw new TypeError("Generator is already executing.");for(;i&&(i=0,a[0]&&(s=0)),s;)try{if(r=1,n&&(o=2&a[0]?n.return:a[0]?n.throw||((o=n.return)&&o.call(n),0):n.next)&&!(o=o.call(n,a[1])).done)return o;switch(n=0,o&&(a=[2&a[0],o.value]),a[0]){case 0:case 1:o=a;break;case 4:return s.label++,{value:a[1],done:!1};case 5:s.label++,n=a[1],a=[0];continue;case 7:a=s.ops.pop(),s.trys.pop();continue;default:if(!((o=(o=s.trys).length>0&&o[o.length-1])||6!==a[0]&&2!==a[0])){s=0;continue}if(3===a[0]&&(!o||a[1]>o[0]&&a[1]<o[3])){s.label=a[1];break}if(6===a[0]&&s.label<o[1]){s.label=o[1],o=a;break}if(o&&s.label<o[2]){s.label=o[2],s.ops.push(a);break}o[2]&&s.ops.pop(),s.trys.pop();continue}a=e.call(t,s)}catch(t){a=[6,t],n=0}finally{r=o=0}if(5&a[0])throw a[1];return{value:a[0]?a[1]:void 0,done:!0}}([a,u])}}}(this,(function(c){if(r=t.layout,n=r.id,o=r.options,i=t.nodes,a=t.edges,u=new s({nodes:i,edges:a}),!(l=Ae[n]))throw new Error("Unknown layout id: ".concat(n));return h=new l(o),[2,new Promise((function(t){h.execute(u,{onLayoutEnd:function(r){t([r,e])}})}))]}))},new((o=void 0)||(o=Promise))((function(t,e){function s(t){try{u(i.next(t))}catch(t){e(t)}}function a(t){try{u(i.throw(t))}catch(t){e(t)}}function u(e){var r;e.done?t(e.value):(r=e.value,r instanceof o?r:new o((function(t){t(r)}))).then(s,a)}u((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=a3736fcd924e7b5b918c.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),r.r=t=>{"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(t,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(t,"__esModule",{value:!0})};var n={};return(()=>{"use strict";r.r(n),r.d(n,{CircularLayout:()=>b,ConcentricLayout:()=>I,D3ForceLayout:()=>_t,ForceLayout:()=>Tt,GridLayout:()=>Ft,MDSLayout:()=>ve,RadialLayout:()=>Ae,RandomLayout:()=>Te,Supervisor:()=>D,SupervisorEvent:()=>_,registerLayout:()=>Oe,registry:()=>Pe});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},u=/-(\w)/g,h=(function(t){return t.replace(u,(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 r=[];return t.forEach((function(t){r.push(t)})),r.map((function(t){return p(t)}))}if("object"==typeof t&&Object.keys(t).length){var n=e({},t);return Object.keys(n).forEach((function(t){n[t]=p(n[t])})),n}return t},m=function(t){var e=p(t);return e.data=e.data||{},e},w=function(t){return"function"==typeof t};function y(t,e){return w(e)?e:l(e)?function(){return e}:function(){return t}}function v(t,e,r){return void 0===r&&(r=!0),e||0===e?w(e)?e:l(e)?function(){return e}:h(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?h(r)?r[0]>r[1]?r[0]:r[1]:g(r)?r.width>r.height?r.width:r.height:r:t}}var x={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({},x),t)}return t.prototype.execute=function(t,e){return this.genericCircularLayout(!1,t,e)},t.prototype.assign=function(t,e){var r=this;t.batch((function(){r.genericCircularLayout(!0,t,e)}))},t.prototype.genericCircularLayout=function(t,r,n){var o=e(e({},this.options),n),s=o.width,a=o.height,u=o.center,h=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,w=o.clockwise,x=o.nodeSpacing,b=o.nodeSize,S=o.layoutInvisibles,N=o.onLayoutEnd,A=r.getAllNodes(),k=r.getAllEdges();S||(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 _=A.length;if(0===_)return null==N||N({nodes:[],edges:[]}),{nodes:[],edges:[]};var D=i(E(s,a,u),3),R=D[0],I=D[1],z=D[2];if(1===_){t&&r.mergeNodeData(A[0].id,{x:z[0],y:z[1]});var C={nodes:[e(e({},A[0]),{data:e(e({},A[0].data),{x:z[0],y:z[1]})})],edges:k};return null==N||N(C),C}var T=(d-c)/_,P=o.radius,O=o.startRadius,j=o.endRadius;if(x){var L=y(10,x),q=v(10,b),V=-1/0;A.forEach((function(t){var e=q(t);V<e&&(V=e)}));var F=0;A.forEach((function(t,e){F+=0===e?V||10:(L(t)||0)+(V||10)})),P=F/(2*Math.PI)}else P||O||j?!O&&j?O=j:O&&!j&&(j=O):P=Math.min(I,R)/2;var $=T*g,U=[];U="topology"===p?M(r,A):"topology-directed"===p?M(r,A,!0):"degree"===p?function(t,e){var r=[];return e.forEach((function(t,e){r.push(m(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 m(t)}));for(var K=Math.ceil(_/h),B=0;B<_;++B){var G=P;G||null===O||null===j||(G=O+B*(j-O)/(_-1)),G||(G=10+100*B/(_-1));var J=c+B%K*$+2*Math.PI/h*Math.floor(B/K);w||(J=d-B%K*$-2*Math.PI/h*Math.floor(B/K)),U[B].data.x=z[0]+Math.cos(J)*G,U[B].data.y=z[1]+Math.sin(J)*G}t&&U.forEach((function(t){r.mergeNodeData(t.id,{x:t.data.x,y:t.data.y})}));var H={nodes:U,edges:k};return null==N||N(H),H},t}(),M=function(t,e,r){void 0===r&&(r=!1);var n=[m(e[0])],o={},i=e.length;o[e[0].id]=!0;var s=0;return e.forEach((function(a,u){if(0!==u)if(u!==i-1&&t.getDegree(a.id,"both")===t.getDegree(e[u+1].id,"both")&&!t.areNeighbors(n[s].id,a.id)||o[a.id]){for(var h=r?t.getSuccessors(n[s].id):t.getNeighbors(n[s].id),l=!1,c=0;c<h.length;c++){var f=h[c];if(t.getDegree(f.id)===t.getDegree(a.id)&&!o[f.id]){n.push(m(f)),o[f.id]=!0,l=!0;break}}for(var d=0;!l&&(o[e[d].id]||(n.push(m(e[d])),o[e[d].id]=!0,l=!0),++d!==i););}else n.push(m(a)),o[a.id]=!0,s++})),n},E=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),N=r.n(S),A=r(825),k=r.n(A),_={LAYOUT_ITERATION:"tick",LAYOUT_END:"layoutend"},D=function(e){function r(t,r,n){var o=e.call(this)||this;return o.graph=t,o.layout=r,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=k()(),this.running&&(this.running=!1,this.start())},r.prototype.start=function(){var t=this;if(this.running)return this;this.running=!0;var e=this.layout.options,r=(e.onLayoutEnd,e.onTick,o(e,["onLayoutEnd","onTick"])),n={layout:{id:this.layout.id,options:r},nodes:this.graph.getAllNodes(),edges:this.graph.getAllEdges()},s=new Float32Array([0]);return this.worker.calculateLayout(n,[s]).then((function(e){var r=i(e,2),n=r[0];r[1],t.emit(_.LAYOUT_END,n),t.layout.options.onLayoutEnd&&t.layout.options.onLayoutEnd(n)})),this},r.prototype.stop=function(){return this.running=!1,this},r.prototype.kill=function(){this.worker&&this.worker.terminate()},r.prototype.isRunning=function(){return this.running},r}(N()),R={nodeSize:30,minNodeSpacing:10,nodeSpacing:10,preventOverlap:!1,sweep:void 0,equidistant:!1,startAngle:1.5*Math.PI,clockwise:!0,maxLevelDiff:void 0,sortBy:"degree"},I=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,u=o.height,c=o.sortBy,f=o.maxLevelDiff,d=o.sweep,p=o.clockwise,y=o.equidistant,v=o.minNodeSpacing,x=void 0===v?10:v,b=o.preventOverlap,M=o.startAngle,E=void 0===M?1.5*Math.PI:M,S=o.nodeSize,N=o.nodeSpacing,A=o.layoutInvisibles,k=o.onLayoutEnd,_=r.getAllNodes(),D=r.getAllEdges();A||(_=_.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=_.length;if(0===R){var I={nodes:[],edges:D};return null==k||k(I),I}var z=s||"undefined"==typeof window?s:window.innerWidth,C=u||"undefined"==typeof window?u:window.innerHeight,T=i||[z/2,C/2];if(1===R){t&&r.mergeNodeData(_[0].id,{x:T[0],y:T[1]});var P={nodes:[e(e({},_[0]),{data:e(e({},_[0].data),{x:T[0],y:T[1]})})],edges:D};return null==k||k(P),P}var O,j=[],L=0;O=h(S)?Math.max(S[0],S[1]):S,h(N)?L=Math.max(N[0],N[1]):l(N)&&(L=N),_.forEach((function(t){var e=m(t);j.push(e);var r=O,n=e.data;h(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)),O=Math.max(O,r),w(N)&&(L=Math.max(N(t),L))}));var q={};j.forEach((function(t,e){q[t.id]=e}));var V=c;a(V)&&void 0!==j[0].data[V]||(V="degree"),"degree"===V?j.sort((function(t,e){return r.getDegree(e.id,"both")-r.getDegree(t.id,"both")})):j.sort((function(t,e){return e.data[V]-t.data[V]}));var F=j[0],$=(f||("degree"===V?r.getDegree(F.id,"both"):F.data[V]))/4,U=[{nodes:[]}],K=U[0];j.forEach((function(t){if(K.nodes.length>0){var e="degree"===V?Math.abs(r.getDegree(K.nodes[0].id,"both")-r.getDegree(t.id,"both")):Math.abs(K.nodes[0].data[V]-t.data[V]);$&&e>=$&&(K={nodes:[]},U.push(K))}K.nodes.push(t)}));var B=O+(L||x);if(!b){var G=U.length>0&&U[0].nodes.length>1,J=(Math.min(z,C)/2-B)/(U.length+(G?1:0));B=Math.min(B,J)}var H=0;if(U.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&&b){var r=Math.cos(t.dTheta)-Math.cos(0),n=Math.sin(t.dTheta)-Math.sin(0),o=Math.sqrt(B*B/(r*r+n*n));H=Math.max(o,H)}t.r=H,H+=B})),y){for(var W=0,Y=0,X=0;X<U.length;X++){var Q=(U[X].r||0)-Y;W=Math.max(W,Q)}Y=0,U.forEach((function(t,e){0===e&&(Y=t.r||0),t.r=Y,Y+=W}))}U.forEach((function(t){var e=t.dTheta||0,r=t.r||0;t.nodes.forEach((function(t,n){var o=E+(p?1:-1)*e*n;t.data.x=T[0]+r*Math.cos(o),t.data.y=T[1]+r*Math.sin(o)}))})),t&&j.forEach((function(t){return r.mergeNodeData(t.id,{x:t.data.x,y:t.data.y})}));var Z={nodes:j,edges:D};return null==k||k(Z),Z},t}();function z(t,e,r,n){if(isNaN(e)||isNaN(r))return t;var o,i,s,a,u,h,l,c,f,d=t._root,g={data:n},p=t._x0,m=t._y0,w=t._x1,y=t._y1;if(!d)return t._root=g,t;for(;d.length;)if((h=e>=(i=(p+w)/2))?p=i:w=i,(l=r>=(s=(m+y)/2))?m=s:y=s,o=d,!(d=d[c=l<<1|h]))return o[c]=g,t;if(a=+t._x.call(null,d.data),u=+t._y.call(null,d.data),e===a&&r===u)return g.next=d,o?o[c]=g:t._root=g,t;do{o=o?o[c]=new Array(4):t._root=new Array(4),(h=e>=(i=(p+w)/2))?p=i:w=i,(l=r>=(s=(m+y)/2))?m=s:y=s}while((c=l<<1|h)==(f=(u>=s)<<1|a>=i));return o[f]=d,o[c]=g,t}function C(t,e,r,n,o){this.node=t,this.x0=e,this.y0=r,this.x1=n,this.y1=o}function T(t){return t[0]}function P(t){return t[1]}function O(t,e,r){var n=new j(null==e?T:e,null==r?P:r,NaN,NaN,NaN,NaN);return null==t?n:n.addAll(t)}function j(t,e,r,n,o,i){this._x=t,this._y=e,this._x0=r,this._y0=n,this._x1=o,this._y1=i,this._root=void 0}function L(t){for(var e={data:t.data},r=e;t=t.next;)r=r.next={data:t.data};return e}var q=O.prototype=j.prototype;function V(t){return function(){return t}}function F(t){return 1e-6*(t()-.5)}q.copy=function(){var t,e,r=new j(this._x,this._y,this._x0,this._y0,this._x1,this._y1),n=this._root;if(!n)return r;if(!n.length)return r._root=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},q.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)},q.addAll=function(t){var e,r,n,o,i=t.length,s=new Array(i),a=new Array(i),u=1/0,h=1/0,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<u&&(u=n),n>l&&(l=n),o<h&&(h=o),o>c&&(c=o));if(u>l||h>c)return this;for(this.cover(u,h).cover(l,c),r=0;r<i;++r)z(this,s[r],a[r],t[r]);return this},q.cover=function(t,e){if(isNaN(t=+t)||isNaN(e=+e))return this;var r=this._x0,n=this._y0,o=this._x1,i=this._y1;if(isNaN(r))o=(r=Math.floor(t))+1,i=(n=Math.floor(e))+1;else{for(var s,a,u=o-r||1,h=this._root;r>t||t>=o||n>e||e>=i;)switch(a=(e<n)<<1|t<r,(s=new Array(4))[a]=h,h=s,u*=2,a){case 0:o=r+u,i=n+u;break;case 1:r=o-u,i=n+u;break;case 2:o=r+u,n=i-u;break;case 3:r=o-u,n=i-u}this._root&&this._root.length&&(this._root=h)}return this._x0=r,this._y0=n,this._x1=o,this._y1=i,this},q.data=function(){var t=[];return this.visit((function(e){if(!e.length)do{t.push(e.data)}while(e=e.next)})),t},q.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]]},q.find=function(t,e,r){var n,o,i,s,a,u,h,l=this._x0,c=this._y0,f=this._x1,d=this._y1,g=[],p=this._root;for(p&&g.push(new C(p,l,c,f,d)),null==r?r=1/0:(l=t-r,c=e-r,f=t+r,d=e+r,r*=r);u=g.pop();)if(!(!(p=u.node)||(o=u.x0)>f||(i=u.y0)>d||(s=u.x1)<l||(a=u.y1)<c))if(p.length){var m=(o+s)/2,w=(i+a)/2;g.push(new C(p[3],m,w,s,a),new C(p[2],o,w,m,a),new C(p[1],m,i,s,w),new C(p[0],o,i,m,w)),(h=(e>=w)<<1|t>=m)&&(u=g[g.length-1],g[g.length-1]=g[g.length-1-h],g[g.length-1-h]=u)}else{var y=t-+this._x.call(null,p.data),v=e-+this._y.call(null,p.data),x=y*y+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},q.remove=function(t){if(isNaN(i=+this._x.call(null,t))||isNaN(s=+this._y.call(null,t)))return this;var e,r,n,o,i,s,a,u,h,l,c,f,d=this._root,g=this._x0,p=this._y0,m=this._x1,w=this._y1;if(!d)return this;if(d.length)for(;;){if((h=i>=(a=(g+m)/2))?g=a:m=a,(l=s>=(u=(p+w)/2))?p=u:w=u,e=d,!(d=d[c=l<<1|h]))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)},q.removeAll=function(t){for(var e=0,r=t.length;e<r;++e)this.remove(t[e]);return this},q.root=function(){return this._root},q.size=function(){var t=0;return this.visit((function(e){if(!e.length)do{++t}while(e=e.next)})),t},q.visit=function(t){var e,r,n,o,i,s,a=[],u=this._root;for(u&&a.push(new C(u,this._x0,this._y0,this._x1,this._y1));e=a.pop();)if(!t(u=e.node,n=e.x0,o=e.y0,i=e.x1,s=e.y1)&&u.length){var h=(n+i)/2,l=(o+s)/2;(r=u[3])&&a.push(new C(r,h,l,i,s)),(r=u[2])&&a.push(new C(r,n,l,h,s)),(r=u[1])&&a.push(new C(r,h,o,i,l)),(r=u[0])&&a.push(new C(r,n,o,h,l))}return this},q.visitAfter=function(t){var e,r=[],n=[];for(this._root&&r.push(new C(this._root,this._x0,this._y0,this._x1,this._y1));e=r.pop();){var o=e.node;if(o.length){var i,s=e.x0,a=e.y0,u=e.x1,h=e.y1,l=(s+u)/2,c=(a+h)/2;(i=o[0])&&r.push(new C(i,s,a,l,c)),(i=o[1])&&r.push(new C(i,l,a,u,c)),(i=o[2])&&r.push(new C(i,s,c,l,h)),(i=o[3])&&r.push(new C(i,l,c,u,h))}n.push(e)}for(;e=n.pop();)t(e.node,e.x0,e.y0,e.x1,e.y1);return this},q.x=function(t){return arguments.length?(this._x=t,this):this._x},q.y=function(t){return arguments.length?(this._y=t,this):this._y};var $={value:()=>{}};function U(){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 K(n)}function K(t){this._=t}function B(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 G(t,e){for(var r,n=0,o=t.length;n<o;++n)if((r=t[n]).name===e)return r.value}function J(t,e,r){for(var n=0,o=t.length;n<o;++n)if(t[n].name===e){t[n]=$,t=t.slice(0,n).concat(t.slice(n+1));break}return null!=r&&t.push({name:e,value:r}),t}K.prototype=U.prototype={constructor:K,on:function(t,e){var r,n=this._,o=B(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]=J(n[r],t.name,e);else if(null==e)for(r in n)n[r]=J(n[r],t.name,null);return this}for(;++i<s;)if((r=(t=o[i]).type)&&(r=G(n[r],t.name)))return r},copy:function(){var t={},e=this._;for(var r in e)t[r]=e[r].slice();return new K(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 H=U;var W,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 ut(t,e,r){var n=new at;return n.restart(t,e,r),n}function ht(){et=(tt=nt.now())+rt,X=Q=0;try{!function(){it(),++X;for(var t,e=W;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=W,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:W=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(ht,t-nt.now()-rt)),Z&&(Z=clearInterval(Z))):(Z||(tt=nt.now(),Z=setInterval(lt,1e3)),X=1,ot(ht)))}at.prototype=ut.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:W=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 mt(t){var e,r=1,n=.001,o=1-Math.pow(n,1/300),i=0,s=.6,a=new Map,u=ut(c),h=H("tick","end"),l=function(){let t=1;return()=>(t=(1664525*t+1013904223)%ft)/ft}();function c(){f(),h.call("tick",e),r<n&&(u.stop(),h.call("end",e))}function f(n){var u,h,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)})),u=0;u<l;++u)null==(h=t[u]).fx?h.x+=h.vx*=s:(h.x=h.fx,h.vx=0),null==h.fy?h.y+=h.vy*=s:(h.y=h.fy,h.vy=0);return e}function d(){for(var e,r=0,n=t.length;r<n;++r){if((e=t[r]).index=r,null!=e.fx&&(e.x=e.fx),null!=e.fy&&(e.y=e.fy),isNaN(e.x)||isNaN(e.y)){var o=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 u.restart(c),e},stop:function(){return u.stop(),e},nodes:function(r){return arguments.length?(t=r,d(),a.forEach(g),e):t},alpha:function(t){return arguments.length?(r=+t,e):r},alphaMin:function(t){return arguments.length?(n=+t,e):n},alphaDecay:function(t){return arguments.length?(o=+t,e):+o},alphaTarget:function(t){return arguments.length?(i=+t,e):i},velocityDecay:function(t){return arguments.length?(s=1-t,e):1-s},randomSource:function(t){return arguments.length?(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,u,h=0,l=t.length;for(null==n?n=1/0:n*=n,h=0;h<l;++h)(s=(o=e-(a=t[h]).x)*o+(i=r-a.y)*i)<n&&(u=a,n=s);return u},on:function(t,r){return arguments.length>1?(h.on(t,r),e):h.on(t)}}}function wt(){var t,e,r,n,o,i=V(-30),s=1,a=1/0,u=.81;function h(r){var o,i=t.length,s=O(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,u=0;if(t.length){for(n=i=s=0;s<4;++s)(e=t[s])&&(r=Math.abs(e.value))&&(a+=e.value,u+=r,n+=r*e.x,i+=r*e.y);t.x=n/u,t.y=i/u}else{(e=t).x=e.data.x,e.y=e.data.y;do{a+=o[e.data.index]}while(e=e.next)}t.value=a}function f(t,i,h,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/u<g)return g<a&&(0===c&&(g+=(c=F(r))*c),0===f&&(g+=(f=F(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=F(r))*c),0===f&&(g+=(f=F(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 h.initialize=function(e,n){t=e,r=n,l()},h.strength=function(t){return arguments.length?(i="function"==typeof t?t:V(+t),l(),h):i},h.distanceMin=function(t){return arguments.length?(s=t*t,h):Math.sqrt(s)},h.distanceMax=function(t){return arguments.length?(a=t*t,h):Math.sqrt(a)},h.theta=function(t){return arguments.length?(u=t*t,h):Math.sqrt(u)},h}function yt(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=yt,u=function(t){return 1/Math.min(o[t.source.index],o[t.target.index])},h=V(30),l=1;function c(n){for(var o=0,a=t.length;o<l;++o)for(var u,h,c,f,d,g,p,m=0;m<a;++m)h=(u=t[m]).source,f=(c=u.target).x+c.vx-h.x-h.vx||F(s),d=c.y+c.vy-h.y-h.vy||F(s),f*=g=((g=Math.sqrt(f*f+d*d))-r[m])/g*n*e[m],d*=g,c.vx-=f*(p=i[m]),c.vy-=d*p,h.vx+=f*(p=1-p),h.vy+=d*p}function f(){if(n){var s,u,h=n.length,l=t.length,c=new Map(n.map(((t,e)=>[a(t,e,n),t])));for(s=0,o=new Array(h);s<l;++s)(u=t[s]).index=s,"object"!=typeof u.source&&(u.source=vt(c,u.source)),"object"!=typeof u.target&&(u.target=vt(c,u.target)),o[u.source.index]=(o[u.source.index]||0)+1,o[u.target.index]=(o[u.target.index]||0)+1;for(s=0,i=new Array(l);s<l;++s)u=t[s],i[s]=o[u.source.index]/(o[u.source.index]+o[u.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]=+u(t[r],r,t)}function g(){if(n)for(var e=0,o=t.length;e<o;++e)r[e]=+h(t[e],e,t)}return null==t&&(t=[]),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?(u="function"==typeof t?t:V(+t),d(),c):u},c.distance=function(t){return arguments.length?(h="function"==typeof t?t:V(+t),g(),c):h},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,u,h,l,c,f,d=e.length,g=0;g<i;++g)for(s=O(e,bt,Mt).visitAfter(a),t=0;t<d;++t)u=e[t],c=r[u.index],f=c*c,h=u.x+u.vx,l=u.y+u.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>h+g||i<h-g||r>l+g||s<l-g;if(a.index>u.index){var p=h-a.x-a.vx,m=l-a.y-a.vy,w=p*p+m*m;w<g*g&&(0===p&&(w+=(p=F(n))*p),0===m&&(w+=(m=F(n))*m),w=(g-(w=Math.sqrt(w)))/w*o,u.vx+=(p*=w)*(g=(d*=d)/(f+d)),u.vy+=(m*=w)*g,a.vx-=p*(g=1-g),a.vy-=m*g)}}}function a(t){if(t.data)return t.r=r[t.data.index];for(var e=t.r=0;e<4;++e)t[e]&&t[e].r>t.r&&(t.r=t[e].r)}function u(){if(e){var n,o,i=e.length;for(r=new Array(i),n=0;n<i;++n)o=e[n],r[o.index]=+t(o,n,e)}}return"function"!=typeof t&&(t=V(null==t?1:+t)),s.initialize=function(t,r){e=t,n=r,u()},s.iterations=function(t){return arguments.length?(i=+t,s):i},s.strength=function(t){return arguments.length?(o=+t,s):o},s.radius=function(e){return arguments.length?(t="function"==typeof e?e:V(+e),u(),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 Nt(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),u=[0,0],h=[],l={},c=[],f=100,d=100,g={none:{x:0,y:0}},p=[],m="force",w=!0,y=.1;function v(t){if(!w)return v;e.tick(),b();for(var n=0,o=h.length,i=void 0,s=t*y;n<o;++n)(i=h[n]).vx+=(g[r(i)].x-i.x)*s,i.vy+=(g[r(i)].y-i.y)*s}function x(){h&&function(){if(h&&h.length){if(void 0===r(h[0]))throw Error("Couldnt find the grouping attribute for the nodes. Make sure to set it up with forceInBox.groupBy('clusterAttr') before calling .links()");var t,u,g,m,w,y=(t=[],u=[],g={},{},w=[],m=function(t){var e={};return t.forEach((function(t){var n=r(t);e[n]||(e[n]={count:0,sumforceNodeSize:0})})),t.forEach((function(t){var o=r(t),i=n(t),s=e[o];s.count=s.count+1,s.sumforceNodeSize=s.sumforceNodeSize+Math.PI*(i*i)*1.3,e[o]=s})),e}(h),w=function(t){var e={},n=[];return t.forEach((function(t){var n,o,i,s,a,u=(o=(n=t).source,i=n.target,(s=r(l[o]))<=(a=r(l[i]))?"".concat(s,"~").concat(a):"".concat(a,"~").concat(s)),h=0;void 0!==e[u]&&(h=e[u]),h+=1,e[u]=h})),Object.entries(e).forEach((function(t){var e=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(m).forEach((function(e,r){var n=m[e];t.push({id:e,size:n.count,r:Math.sqrt(n.sumforceNodeSize/Math.PI)}),g[e]=r})),w.forEach((function(t){var e=t.source,r=t.target,n=g[e],o=g[r];void 0!==n&&void 0!==o&&u.push({source:n,target:o,count:t.count})})),{nodes:t,links:u});e=mt(y.nodes).force("x",St(f).strength(.1)).force("y",Nt(d).strength(.1)).force("collide",Et((function(t){return t.r})).iterations(4)).force("charge",wt().strength(o)).force("links",xt(y.nodes.length?y.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-u[0],y:t.y-u[1]}})),g}function M(t){l={},t.forEach((function(t){l[t.id]=t}))}return v.initialize=function(t){h=t,x()},v.template=function(t){return arguments.length?(m=t,x(),v):m},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?(w=t,v):w},v.strength=function(t){return arguments.length?(y=t,v):y},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||[]),h=t||[],v):h},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?(u=t,v):u},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},_t=function(){function t(t){void 0===t&&(t={}),this.options=t,this.id="d3force",this.options=e(e({},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.genericForceLayout=function(t,r,n){var o=this,i=e(e({},this.options),n),s=i.layoutInvisibles,a=r.getAllNodes(),u=r.getAllEdges();s||(a=a.filter((function(t){var e=(t.data||{}).visible;return e||void 0===e})),u=u.filter((function(t){var e=(t.data||{}).visible;return e||void 0===e})));var h=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})}));if(!this.running){var l=i.alphaMin,c=i.alphaDecay,f=i.alpha,d=i.nodeStrength,g=i.edgeStrength,p=i.linkDistance,m=i.clustering,w=i.clusterFociStrength,y=i.clusterEdgeDistance,v=i.clusterEdgeStrength,x=i.clusterNodeStrength,b=i.clusterNodeSize,M=i.collideStrength,E=void 0===M?1:M,S=i.center,N=void 0===S?[0,0]:S,A=i.preventOverlap,k=i.nodeSize,_=i.nodeSpacing,D=i.onTick,R=i.onLayoutEnd,I=i.forceSimulation;if(I)m&&((z=At()).nodes(h),z.links(u)),I.nodes(h),u&&(T=xt().id((function(t){return t.id})).links(u),g&&T.strength(g),p&&T.distance(p),I.force("link",T)),A&&this.overlapProcess(I,{nodeSize:k,nodeSpacing:_,collideStrength:E}),I.alpha(f).restart(),this.running=!0;else try{var z,C=wt();if(d&&C.strength(d),I=mt().nodes(h),m&&((z=At()).centerX(N[0]).centerY(N[1]).template("force").strength(w),u&&z.links(u),h&&z.nodes(h),z.forceLinkDistance(y).forceLinkStrength(v).forceCharge(x).forceNodeSize(b),I.force("group",z)),I.force("center",function(t,e){var r,n=1;function o(){var o,i,s=r.length,a=0,u=0;for(o=0;o<s;++o)a+=(i=r[o]).x,u+=i.y;for(a=(a/s-t)*n,u=(u/s-e)*n,o=0;o<s;++o)(i=r[o]).x-=a,i.y-=u}return null==t&&(t=0),null==e&&(e=0),o.initialize=function(t){r=t},o.x=function(e){return arguments.length?(t=+e,o):t},o.y=function(t){return arguments.length?(e=+t,o):e},o.strength=function(t){return arguments.length?(n=+t,o):n},o}(N[0],N[1])).force("charge",C).alpha(f).alphaDecay(c).alphaMin(l),A&&this.overlapProcess(I,{nodeSize:k,nodeSpacing:_,collideStrength:E}),u){var T=xt().id((function(t){return t.id})).links(u);g&&T.strength(g),p&&T.distance(p),I.force("link",T)}I.on("tick",(function(){null==D||D({nodes:Dt(h),edges:Rt(u)})})).on("end",(function(){o.running=!1,null==R||R({nodes:Dt(h),edges:Rt(u)})})),this.running=!0}catch(t){this.running=!1,console.warn(t)}var P=Dt(h);return t&&P.forEach((function(t){return r.mergeNodeData(t.id,{x:t.data.x,y:t.data.y})})),{nodes:P,edges:u}}},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}:w(i)?i:function(){return 0},o)if(w(o))r=function(t){return o(t)+n(t)};else if(h(o)){var a=(o[0]>o[1]?o[0]:o[1])/2;r=function(t){return a+n(t)}}else if(l(o)){var u=o/2;r=function(t){return u+n(t)}}else r=function(){return 10};else r=function(t){return t.size?h(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",Et(r).strength(s))},t}(),Dt=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 It{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 It({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 zt(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 Ct={maxIteration:500,gravity:10,animate:!0,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.options=e(e({},Ct),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.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 u=this.formatOptions(i,r),h=u.width,c=u.height,f=u.nodeSize,d=u.getMass,g=u.nodeStrength,p=u.edgeStrength,m=u.linkDistance,w=s.map((function(t){return e(e({},t),{data:e(e({},t.data),{x:l(t.data.x)?t.data.x:Math.random()*h,y:l(t.data.y)?t.data.y:Math.random()*c,size:f(t)||30,mass:d(t),nodeStrength:g(t)})})})),y=a.map((function(t){return e(e({},t),{data:e(e({},t.data),{edgeStrength:p(t),linkDistance:m(t,r.getNode(t.source),r.getNode(t.target))})})}));if(!(null==s?void 0:s.length))return{nodes:[],edges:a};var v={};s.forEach((function(t,e){v[t.id]={x:0,y:0}}));var x=new It({nodes:w,edges:y});this.formatCentripetal(u,x);var b=u.maxIteration,M=u.animate,E=u.minMovement,S=u.onLayoutEnd,N=u.onTick;if(!M){for(var A=0;(this.judgingDistance>E||A<1)&&A<b;A++)this.runOneStep(x,r,A,v,u),this.updatePosition(r,x,v,u),t&&w.forEach((function(t){return r.mergeNodeData(t.id,{x:t.data.x,y:t.data.y})})),null==N||N({nodes:qt(r,w),edges:a});t&&w.forEach((function(t){return r.mergeNodeData(t.id,{x:t.data.x,y:t.data.y})}));var k={nodes:qt(r,w),edges:a};return null==S||S(k),k}if("undefined"!=typeof window){var _=0;return this.timeInterval=window.setInterval((function(){s&&(o.runOneStep(x,r,_,v,u),o.updatePosition(r,x,v,u),t&&w.forEach((function(t){return r.mergeNodeData(t.id,{x:t.data.x,y:t.data.y})})),null==N||N({nodes:qt(r,w),edges:a}),(++_>=b||o.judgingDistance<E)&&(null==S||S({nodes:qt(r,w),edges:a}),window.clearInterval(o.timeInterval)))}),0),{nodes:qt(r,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;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=y(0,t.nodeSpacing);t.nodeSize?h(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?h(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?y(1,t.linkDistance):function(t){return 1+r.nodeSize(e.getNode(t.source))+r.nodeSize(e.getNode(t.target))},r.nodeStrength=y(1,t.nodeStrength),r.edgeStrength=y(1,t.edgeStrength),t},t.prototype.formatCentripetal=function(t,e){var r,n=t.centripetalOptions,o=t.center,i=t.clusterNodeStrength,s=t.leafCluster,a=t.clustering,u=t.nodeClusterBy,h=e.getAllNodes(),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&&u&&(r=Pt(e,u),c=Array.from(new Set(null==h?void 0:h.map((function(t){return t.data[u]}))))||[],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=Lt(s))}else n=void 0;return{x:null==n?void 0:n.x,y:null==n?void 0:n.y}}})),a&&u){r||(r=Pt(e,u)),c||(c=Array.from(new Set(h.map((function(t){return t.data[u]}))))),c=c.filter((function(t){return void 0!==t}));var f={};c.forEach((function(t){var r=h.filter((function(e){return e.data[u]===t})).map((function(t){return e.getNode(t.id)}));f[t]=Lt(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[u]];return{x:null==e?void 0:e.x,y:null==e?void 0:e.y}}})}var d=t.centripetalOptions,g=d.leaf,p=d.single,m=d.others;g&&"function"!=typeof g&&(t.centripetalOptions.leaf=function(){return g}),p&&"function"!=typeof p&&(t.centripetalOptions.single=function(){return p}),m&&"function"!=typeof m&&(t.centripetalOptions.others=function(){return m})},t.prototype.runOneStep=function(t,e,r,n,o){var i={},s=t.getAllNodes(),a=t.getAllEdges();if(null==s?void 0:s.length){var u=o.monitor;this.calRepulsive(t,i,o),a&&this.calAttractive(t,i),this.calGravity(t,e,i,o),this.updateVelocity(t,i,n,o),u&&u({energy:this.calTotalEnergy(i,s),nodes:e.getAllNodes(),edges:e.getAllEdges(),iterations:r})}},t.prototype.calTotalEnergy=function(t,e){if(!(null==e?void 0:e.length))return 0;var r=0;return e.forEach((function(e,n){var o=t[e.id].x,i=t[e.id].y,s=o*o+i*i,a=e.data.mass;r+=(void 0===a?1:a)*s*.5})),r},t.prototype.calRepulsive=function(t,e,r){var n=r.factor,o=r.coulombDisScale;!function(t,e,r,n){var o=e/r,i=t.getAllNodes(),s=i.map((function(t,e){var r=t.data,n=r.nodeStrength;return{x:r.x,y:r.y,size:r.size,index:e,vx:0,vy:0,weight:o*n}})),a=O(s,(function(t){return t.x}),(function(t){return t.y})).visitAfter(zt);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,u=n-e,h=s*s+a*a,l=Math.sqrt(h)*h;if(u*u*.81<h){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 u=a.data.x-s.data.x,h=a.data.y-s.data.y;u||h||(u=.01*Math.random(),h=.01*Math.random());var l=Math.sqrt(u*u+h*h),c=u/l,f=h/l,d=edgeInfos[n]||{},g=d.linkDistance,p=void 0===g?200:g,m=d.edgeStrength,w=(p-l)*(void 0===m?200:m),y=1/(s.data.mass||1),v=1/(a.data.mass||1),x=c*w,b=f*w;e[o].x-=x*y,e[o].y-=b*y,e[i].x+=x*v,e[i].y+=b*v}}))},t.prototype.calGravity=function(t,e,r,n){var o=n.getCenter,s=t.getAllNodes(),a=e.getAllNodes(),u=e.getAllEdges(),h=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,m=p.mass,w=p.x,y=p.y,v=e.getNode(s),x=0,b=0,M=d,E=t.getDegree(s,"in"),S=t.getDegree(s,"out"),N=t.getDegree(s,"both"),A=null==o?void 0:o(v,N);if(A){var k=i(A,3);x=w-k[0],b=y-k[1],M=k[2]}else x=w-f[0],b=y-f[1];if(M&&(r[s].x-=M*x/m,r[s].y-=M*b/m),g){var _=g.leaf,D=g.single,R=g.others,I=g.center,z=(null==I?void 0:I(v,a,u,h,c))||{x:0,y:0,centerStrength:0},C=z.x,T=z.y,P=z.centerStrength;if(!l(C)||!l(T))return;var O=(w-C)/m,j=(y-T)/m;if(P&&(r[s].x-=P*O,r[s].y-=P*j),0===N){var L=D(v);if(!L)return;return r[s].x-=L*O,void(r[s].y-=L*j)}if(0===E||0===S){var q=_(v,a,u);if(!q)return;return r[s].x-=q*O,void(r[s].y-=q*j)}var V=R(v);if(!V)return;r[s].x-=V*O,r[s].y-=V*j}}))},t.prototype.updateVelocity=function(t,e,r,n){var o=n.damping,i=n.maxSpeed,s=n.interval,a=t.getAllNodes();(null==a?void 0:a.length)&&a.forEach((function(t){var n=t.id,a=(r[n].x+e[n].x*s)*o||.01,u=(r[n].y+e[n].y*s)*o||.01,h=Math.sqrt(a*a+u*u);if(h>i){var l=i/h;a*=l,u*=l}r[n]={x:a,y:u}}))},t.prototype.updatePosition=function(t,e,r,n){var o=this,i=n.distanceThresholdMode,s=n.interval,a=e.getAllNodes();if(null==a?void 0:a.length){var u=0;"max"===i?this.judgingDistance=-1/0:"min"===i&&(this.judgingDistance=1/0),a.forEach((function(n){var a=n.id,h=t.getNode(a);if(l(h.data.fx)&&l(h.data.fy))e.mergeNodeData(a,{x:h.data.fx,y:h.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:u+=d}}})),i&&"mean"!==i||(this.judgingDistance=u/a.length)}else this.judgingDistance=0},t.prototype.stop=function(){this.timeInterval&&"undefined"!=typeof window&&window.clearInterval(this.timeInterval)},t}(),Pt=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]=Ot(t,"leaf",r,e))})),n},Ot=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:jt(t,e,n,r,a)}},jt=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},Lt=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}},qt=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={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},Ft=function(){function t(t){void 0===t&&(t={}),this.options=t,this.id="grid",this.options=e(e({},Vt),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,u=o.condense,c=o.preventOverlapPadding,f=o.preventOverlap,d=o.rows,g=o.cols,p=o.nodeSpacing,w=o.nodeSize,x=o.width,b=o.height,M=o.layoutInvisibles,E=o.onLayoutEnd,S=o.position,N=o.sortBy,A=r.getAllNodes(),k=r.getAllEdges();M||(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 _=A.length;if(0===_){var D={nodes:[],edges:k};return null==E||E(D),D}if(1===_){t&&r.mergeNodeData(A[0].id,{x:s[0],y:s[1]});var R={nodes:[e(e({},A[0]),{data:e(e({},A[0].data),{x:s[0],y:s[1]})})],edges:k};return null==E||E(R),R}var I=A.map((function(t){return m(t)}));"id"===N||a(N)&&void 0!==I[0].data[N]||(N="degree"),"degree"===N?I.sort((function(t,e){return r.getDegree(e.id,"both")-r.getDegree(t.id,"both")})):"id"===N?I.sort((function(t,e){return l(e.id)&&l(t.id)?e.id-t.id:"".concat(t.id).localeCompare("".concat(e.id))})):I.sort((function(t,e){return e.data[N]-t.data[N]}));var z=x||"undefined"==typeof window?x:window.innerWidth,C=b||"undefined"==typeof window?b:window.innerHeight,T=_,P={rows:d,cols:g};if(null!=d&&null!=g)P.rows=d,P.cols=g;else if(null!=d&&null==g)P.rows=d,P.cols=Math.ceil(T/P.rows);else if(null==d&&null!=g)P.cols=g,P.rows=Math.ceil(T/P.cols);else{var O=Math.sqrt(T*C/z);P.rows=Math.round(O),P.cols=Math.round(z/C*O)}if(P.rows=Math.max(P.rows,1),P.cols=Math.max(P.cols,1),P.cols*P.rows>T)((L=$t(P))-1)*(j=Ut(P))>=T?$t(P,L-1):(j-1)*L>=T&&Ut(P,j-1);else for(;P.cols*P.rows<T;){var j,L=$t(P);((j=Ut(P))+1)*L>=T?Ut(P,j+1):$t(P,L+1)}var q=u?0:z/P.cols,V=u?0:C/P.rows;if(f||p){var F=y(10,p),$=v(30,w,!1);I.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=$(o)||30;h(i)?(e=i[0],n=i[1]):(e=i,n=i);var s=void 0!==F?F(t):c,a=e+s,u=n+s;q=Math.max(q,a),V=Math.max(V,u)}))}for(var U={},K={row:0,col:0},B={},G=0;G<I.length;G++){var J=I[G],H=void 0;if(S&&(H=S(r.getNode(J.id))),H&&(void 0!==H.row||void 0!==H.col)){var W={row:H.row,col:H.col};if(void 0===W.col)for(W.col=0;Kt(U,W);)W.col++;else if(void 0===W.row)for(W.row=0;Kt(U,W);)W.row++;B[J.id]=W,Bt(U,W)}Jt(J,s,q,V,B,P,K,U)}var Y={nodes:I,edges:k};return null==E||E(Y),t&&I.forEach((function(t){r.mergeNodeData(t.id,{x:t.data.x,y:t.data.y})})),Y},t}(),$t=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},Ut=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},Kt=function(t,e){return t["c-".concat(e.row,"-").concat(e.col)]||!1},Bt=function(t,e){return t["c-".concat(e.row,"-").concat(e.col)]=!0},Gt=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 u,h,l=o[t.id];if(l)u=l.col*r+r/2+e[0],h=l.row*n+n/2+e[1];else{for(;Kt(a,s);)Gt(i,s);u=s.col*r+r/2+e[0],h=s.row*n+n/2+e[1],Bt(a,s),Gt(i,s)}t.data.x=u,t.data.y=h};const Ht=Object.prototype.toString;function Wt(t){return Ht.call(t).endsWith("Array]")}function Yt(t){var e=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};if(!Wt(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 Xt(t){var e=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};if(!Wt(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 Qt(t){var e,r=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};if(!Wt(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(!Wt(r.output))throw new TypeError("output option must be an array if specified");e=r.output}else e=new Array(t.length);var n=Xt(t),o=Yt(t);if(n===o)throw new RangeError("minimum and maximum input values are equal. Cannot rescale a constant array");var i=r.min,s=void 0===i?r.autoMinMax?n:0:i,a=r.max,u=void 0===a?r.autoMinMax?o:1:a;if(s>=u)throw new RangeError("min option must be smaller than max option");for(var h=(u-s)/(o-n),l=0;l<t.length;l++)e[l]=(t[l]-n)*h+s;return e}const Zt=" ".repeat(2),te=" ".repeat(4);function ee(t,e={}){const{maxRows:r=15,maxColumns:n=10,maxNumSize:o=8,padMinus:i="auto"}=e;return`${t.constructor.name} {\n${Zt}[\n${te}${function(t,e,r,n,o){const{rows:i,columns:s}=t,a=Math.min(i,e),u=Math.min(s,r),h=[];if("auto"===o){o=!1;t:for(let e=0;e<a;e++)for(let r=0;r<u;r++)if(t.get(e,r)<0){o=!0;break t}}for(let e=0;e<a;e++){let r=[];for(let i=0;i<u;i++)r.push(re(t.get(e,i),n,o));h.push(`${r.join(" ")}`)}return u!==s&&(h[h.length-1]+=` ... ${s-r} more columns`),a!==i&&h.push(`... ${i-e} more rows`),h.join(`\n${te}`)}(t,r,n,o,i)}\n${Zt}]\n${Zt}rows: ${t.rows}\n${Zt}columns: ${t.columns}\n}`}function re(t,e,r){return(t>=0&&r?` ${ne(t,e-1)}`:ne(t,e)).padEnd(e)}function ne(t,e){let r=t.toString();if(r.length<=e)return r;let n=t.toFixed(e);if(n.length>e&&(n=t.toFixed(Math.max(0,e-(n.length-e)))),n.length<=e&&!n.startsWith("0.000")&&!n.startsWith("-0.000"))return n;let o=t.toExponential(e);return o.length>e&&(o=t.toExponential(Math.max(0,e-(o.length-e)))),o.slice(0)}function oe(t,e,r){let n=r?t.rows:t.rows-1;if(e<0||e>n)throw new RangeError("Row index out of range")}function ie(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 se(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 ae(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 ue(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 he(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 fe{static from1DArray(t,e,r){if(t*e!==r.length)throw new RangeError("data length does not match given dimensions");let n=new ge(t,e);for(let o=0;o<t;o++)for(let t=0;t<e;t++)n.set(o,t,r[o*e+t]);return n}static rowVector(t){let e=new ge(1,t.length);for(let r=0;r<t.length;r++)e.set(0,r,t[r]);return e}static columnVector(t){let e=new ge(t.length,1);for(let r=0;r<t.length;r++)e.set(r,0,t[r]);return e}static zeros(t,e){return new ge(t,e)}static ones(t,e){return new ge(t,e).fill(1)}static rand(t,e,r={}){if("object"!=typeof r)throw new TypeError("options must be an object");const{random:n=Math.random}=r;let o=new ge(t,e);for(let r=0;r<t;r++)for(let t=0;t<e;t++)o.set(r,t,n());return o}static randInt(t,e,r={}){if("object"!=typeof r)throw new TypeError("options must be an object");const{min:n=0,max:o=1e3,random:i=Math.random}=r;if(!Number.isInteger(n))throw new TypeError("min must be an integer");if(!Number.isInteger(o))throw new TypeError("max must be an integer");if(n>=o)throw new RangeError("min must be smaller than max");let s=o-n,a=new ge(t,e);for(let r=0;r<t;r++)for(let t=0;t<e;t++){let e=n+Math.round(i()*s);a.set(r,t,e)}return a}static eye(t,e,r){void 0===e&&(e=t),void 0===r&&(r=1);let n=Math.min(t,e),o=this.zeros(t,e);for(let t=0;t<n;t++)o.set(t,t,r);return o}static diag(t,e,r){let n=t.length;void 0===e&&(e=n),void 0===r&&(r=e);let o=Math.min(n,e,r),i=this.zeros(e,r);for(let e=0;e<o;e++)i.set(e,e,t[e]);return i}static min(t,e){t=this.checkMatrix(t),e=this.checkMatrix(e);let r=t.rows,n=t.columns,o=new ge(r,n);for(let i=0;i<r;i++)for(let r=0;r<n;r++)o.set(i,r,Math.min(t.get(i,r),e.get(i,r)));return o}static max(t,e){t=this.checkMatrix(t),e=this.checkMatrix(e);let r=t.rows,n=t.columns,o=new this(r,n);for(let i=0;i<r;i++)for(let r=0;r<n;r++)o.set(i,r,Math.max(t.get(i,r),e.get(i,r)));return o}static checkMatrix(t){return fe.isMatrix(t)?t:new ge(t)}static isMatrix(t){return null!=t&&"Matrix"===t.klass}get size(){return this.rows*this.columns}apply(t){if("function"!=typeof t)throw new TypeError("callback must be a function");for(let e=0;e<this.rows;e++)for(let r=0;r<this.columns;r++)t.call(this,e,r);return this}to1DArray(){let t=[];for(let e=0;e<this.rows;e++)for(let r=0;r<this.columns;r++)t.push(this.get(e,r));return t}to2DArray(){let t=[];for(let e=0;e<this.rows;e++){t.push([]);for(let r=0;r<this.columns;r++)t[e].push(this.get(e,r))}return t}toJSON(){return this.to2DArray()}isRowVector(){return 1===this.rows}isColumnVector(){return 1===this.columns}isVector(){return 1===this.rows||1===this.columns}isSquare(){return this.rows===this.columns}isEmpty(){return 0===this.rows||0===this.columns}isSymmetric(){if(this.isSquare()){for(let t=0;t<this.rows;t++)for(let e=0;e<=t;e++)if(this.get(t,e)!==this.get(e,t))return!1;return!0}return!1}isEchelonForm(){let t=0,e=0,r=-1,n=!0,o=!1;for(;t<this.rows&&n;){for(e=0,o=!1;e<this.columns&&!1===o;)0===this.get(t,e)?e++:1===this.get(t,e)&&e>r?(o=!0,r=e):(n=!1,o=!0);t++}return n}isReducedEchelonForm(){let t=0,e=0,r=-1,n=!0,o=!1;for(;t<this.rows&&n;){for(e=0,o=!1;e<this.columns&&!1===o;)0===this.get(t,e)?e++:1===this.get(t,e)&&e>r?(o=!0,r=e):(n=!1,o=!0);for(let r=e+1;r<this.rows;r++)0!==this.get(t,r)&&(n=!1);t++}return n}echelonForm(){let t=this.clone(),e=0,r=0;for(;e<t.rows&&r<t.columns;){let n=e;for(let o=e;o<t.rows;o++)t.get(o,r)>t.get(n,r)&&(n=o);if(0===t.get(n,r))r++;else{t.swapRows(e,n);let o=t.get(e,r);for(let n=r;n<t.columns;n++)t.set(e,n,t.get(e,n)/o);for(let n=e+1;n<t.rows;n++){let o=t.get(n,r)/t.get(e,r);t.set(n,r,0);for(let i=r+1;i<t.columns;i++)t.set(n,i,t.get(n,i)-t.get(e,i)*o)}e++,r++}}return t}reducedEchelonForm(){let t=this.echelonForm(),e=t.columns,r=t.rows,n=r-1;for(;n>=0;)if(0===t.maxRow(n))n--;else{let o=0,i=!1;for(;o<r&&!1===i;)1===t.get(n,o)?i=!0:o++;for(let r=0;r<n;r++){let i=t.get(r,o);for(let s=o;s<e;s++){let e=t.get(r,s)-i*t.get(n,s);t.set(r,s,e)}}n--}return t}set(){throw new Error("set method is unimplemented")}get(){throw new Error("get method is unimplemented")}repeat(t={}){if("object"!=typeof t)throw new TypeError("options must be an object");const{rows:e=1,columns:r=1}=t;if(!Number.isInteger(e)||e<=0)throw new TypeError("rows must be a positive integer");if(!Number.isInteger(r)||r<=0)throw new TypeError("columns must be a positive integer");let n=new ge(this.rows*e,this.columns*r);for(let t=0;t<e;t++)for(let e=0;e<r;e++)n.setSubMatrix(this,this.rows*t,this.columns*e);return n}fill(t){for(let e=0;e<this.rows;e++)for(let r=0;r<this.columns;r++)this.set(e,r,t);return this}neg(){return this.mulS(-1)}getRow(t){oe(this,t);let e=[];for(let r=0;r<this.columns;r++)e.push(this.get(t,r));return e}getRowVector(t){return ge.rowVector(this.getRow(t))}setRow(t,e){oe(this,t),e=se(this,e);for(let r=0;r<this.columns;r++)this.set(t,r,e[r]);return this}swapRows(t,e){oe(this,t),oe(this,e);for(let r=0;r<this.columns;r++){let n=this.get(t,r);this.set(t,r,this.get(e,r)),this.set(e,r,n)}return this}getColumn(t){ie(this,t);let e=[];for(let r=0;r<this.rows;r++)e.push(this.get(r,t));return e}getColumnVector(t){return ge.columnVector(this.getColumn(t))}setColumn(t,e){ie(this,t),e=ae(this,e);for(let r=0;r<this.rows;r++)this.set(r,t,e[r]);return this}swapColumns(t,e){ie(this,t),ie(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=se(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=se(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=se(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=se(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=ae(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=ae(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=ae(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=ae(this,t);for(let e=0;e<this.rows;e++)for(let r=0;r<this.columns;r++)this.set(e,r,this.get(e,r)/t[e]);return this}mulRow(t,e){oe(this,t);for(let r=0;r<this.columns;r++)this.set(t,r,this.get(t,r)*e);return this}mulColumn(t,e){ie(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(oe(this,t),this.isEmpty())return NaN;let e=this.get(t,0);for(let r=1;r<this.columns;r++)this.get(t,r)>e&&(e=this.get(t,r));return e}maxRowIndex(t){oe(this,t),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(oe(this,t),this.isEmpty())return NaN;let e=this.get(t,0);for(let r=1;r<this.columns;r++)this.get(t,r)<e&&(e=this.get(t,r));return e}minRowIndex(t){oe(this,t),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(ie(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){ie(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(ie(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){ie(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){fe.isMatrix(t)&&(t=t.to1DArray());let e=this.to1DArray();if(e.length!==t.length)throw new RangeError("vectors do not have the same size");let r=0;for(let n=0;n<e.length;n++)r+=e[n]*t[n];return r}mmul(t){t=ge.checkMatrix(t);let e=this.rows,r=this.columns,n=t.columns,o=new ge(e,n),i=new Float64Array(r);for(let s=0;s<n;s++){for(let e=0;e<r;e++)i[e]=t.get(e,s);for(let t=0;t<e;t++){let e=0;for(let n=0;n<r;n++)e+=this.get(t,n)*i[n];o.set(t,s,e)}}return o}strassen2x2(t){t=ge.checkMatrix(t);let e=new ge(2,2);const r=this.get(0,0),n=t.get(0,0),o=this.get(0,1),i=t.get(0,1),s=this.get(1,0),a=t.get(1,0),u=this.get(1,1),h=t.get(1,1),l=(r+u)*(n+h),c=(s+u)*n,f=r*(i-h),d=u*(a-n),g=(r+o)*h,p=l+d-g+(o-u)*(a+h),m=f+g,w=c+d,y=l-c+f+(s-r)*(n+i);return e.set(0,0,p),e.set(0,1,m),e.set(1,0,w),e.set(1,1,y),e}strassen3x3(t){t=ge.checkMatrix(t);let e=new ge(3,3);const r=this.get(0,0),n=this.get(0,1),o=this.get(0,2),i=this.get(1,0),s=this.get(1,1),a=this.get(1,2),u=this.get(2,0),h=this.get(2,1),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),m=t.get(1,2),w=t.get(2,0),y=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,S=(-r+u+h)*(c-d+m),N=(-r+u)*(d-m),A=(u+h)*(-c+d),k=(-o+h+l)*(p+w-y),_=(o-l)*(p-y),D=o*w,R=(h+l)*(-w+y),I=(-o+s+a)*(m+w-v),z=(o-a)*(m-v),C=(s+a)*(-w+v),T=E+D+n*g,P=(r+n+o-i-s-h-l)*p+b+M+E+k+D+R,O=E+S+A+(r+n+o-s-a-u-h)*m+D+I+C,j=x+s*(-c+f+g-p-m-w+v)+b+E+D+I+z,L=x+b+M+E+a*y,q=D+I+z+C+i*d,V=E+S+N+h*(-c+d+g-p-m-w+y)+k+_+D,F=k+_+D+R+u*f,$=E+S+N+A+l*v;return e.set(0,0,T),e.set(0,1,P),e.set(0,2,O),e.set(1,0,j),e.set(1,1,L),e.set(1,2,q),e.set(2,0,V),e.set(2,1,F),e.set(2,2,$),e}mmulStrassen(t){t=ge.checkMatrix(t);let e=this.clone(),r=e.rows,n=e.columns,o=t.rows,i=t.columns;function s(t,e,r){let n=t.rows,o=t.columns;if(n===e&&o===r)return t;{let n=fe.zeros(e,r);return n=n.setSubMatrix(t,0,0),n}}n!==o&&console.warn(`Multiplying ${r} x ${n} and ${o} x ${i} matrix: dimensions do not match.`);let a=Math.max(r,o),u=Math.max(n,i);return e=s(e,a,u),function t(e,r,n,o){if(n<=512||o<=512)return e.mmul(r);n%2==1&&o%2==1?(e=s(e,n+1,o+1),r=s(r,n+1,o+1)):n%2==1?(e=s(e,n+1,o),r=s(r,n+1,o)):o%2==1&&(e=s(e,n,o+1),r=s(r,n,o+1));let i=parseInt(e.rows/2,10),a=parseInt(e.columns/2,10),u=e.subMatrix(0,i-1,0,a-1),h=r.subMatrix(0,i-1,0,a-1),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),m=t(fe.add(u,g),fe.add(h,p),i,a),w=t(fe.add(f,g),h,i,a),y=t(u,fe.sub(c,p),i,a),v=t(g,fe.sub(d,h),i,a),x=t(fe.add(u,l),p,i,a),b=t(fe.sub(f,u),fe.add(h,c),i,a),M=t(fe.sub(l,g),fe.add(d,p),i,a),E=fe.add(m,v);E.sub(x),E.add(M);let S=fe.add(y,x),N=fe.add(w,v),A=fe.sub(m,w);A.add(y),A.add(b);let k=fe.zeros(2*E.rows,2*E.columns);return k=k.setSubMatrix(E,0,0),k=k.setSubMatrix(S,E.rows,0),k=k.setSubMatrix(N,0,E.columns),k=k.setSubMatrix(A,E.rows,E.columns),k.subMatrix(0,n-1,0,o-1)}(e,t=s(t,a,u),a,u)}scaleRows(t={}){if("object"!=typeof t)throw new TypeError("options must be an object");const{min:e=0,max:r=1}=t;if(!Number.isFinite(e))throw new TypeError("min must be a number");if(!Number.isFinite(r))throw new TypeError("max must be a number");if(e>=r)throw new RangeError("min must be smaller than max");let n=new ge(this.rows,this.columns);for(let t=0;t<this.rows;t++){const o=this.getRow(t);o.length>0&&Qt(o,{min:e,max:r,output:o}),n.setRow(t,o)}return n}scaleColumns(t={}){if("object"!=typeof t)throw new TypeError("options must be an object");const{min:e=0,max:r=1}=t;if(!Number.isFinite(e))throw new TypeError("min must be a number");if(!Number.isFinite(r))throw new TypeError("max must be a number");if(e>=r)throw new RangeError("min must be smaller than max");let n=new ge(this.rows,this.columns);for(let t=0;t<this.columns;t++){const o=this.getColumn(t);o.length&&Qt(o,{min:e,max:r,output:o}),n.setColumn(t,o)}return n}flipRows(){const t=Math.ceil(this.columns/2);for(let e=0;e<this.rows;e++)for(let r=0;r<t;r++){let t=this.get(e,r),n=this.get(e,this.columns-1-r);this.set(e,r,n),this.set(e,this.columns-1-r,t)}return this}flipColumns(){const t=Math.ceil(this.rows/2);for(let e=0;e<this.columns;e++)for(let r=0;r<t;r++){let t=this.get(r,e),n=this.get(this.rows-1-r,e);this.set(r,e,n),this.set(this.rows-1-r,e,t)}return this}kroneckerProduct(t){t=ge.checkMatrix(t);let e=this.rows,r=this.columns,n=t.rows,o=t.columns,i=new ge(e*n,r*o);for(let s=0;s<e;s++)for(let e=0;e<r;e++)for(let r=0;r<n;r++)for(let a=0;a<o;a++)i.set(n*s+r,o*e+a,this.get(s,e)*t.get(r,a));return i}kroneckerSum(t){if(t=ge.checkMatrix(t),!this.isSquare()||!t.isSquare())throw new Error("Kronecker Sum needs two Square Matrices");let e=this.rows,r=t.rows,n=this.kroneckerProduct(ge.eye(r,r)),o=ge.eye(e,e).kroneckerProduct(t);return n.add(o)}transpose(){let t=new ge(this.columns,this.rows);for(let e=0;e<this.rows;e++)for(let r=0;r<this.columns;r++)t.set(r,e,this.get(e,r));return t}sortRows(t=de){for(let e=0;e<this.rows;e++)this.setRow(e,this.getRow(e).sort(t));return this}sortColumns(t=de){for(let e=0;e<this.columns;e++)this.setColumn(e,this.getColumn(e).sort(t));return this}subMatrix(t,e,r,n){ue(this,t,e,r,n);let o=new ge(e-t+1,n-r+1);for(let i=t;i<=e;i++)for(let e=r;e<=n;e++)o.set(i-t,e-r,this.get(i,e));return o}subMatrixRow(t,e,r){if(void 0===e&&(e=0),void 0===r&&(r=this.columns-1),e>r||e<0||e>=this.columns||r<0||r>=this.columns)throw new RangeError("Argument out of range");let n=new ge(t.length,r-e+1);for(let o=0;o<t.length;o++)for(let i=e;i<=r;i++){if(t[o]<0||t[o]>=this.rows)throw new RangeError(`Row index out of range: ${t[o]}`);n.set(o,i-e,this.get(t[o],i))}return n}subMatrixColumn(t,e,r){if(void 0===e&&(e=0),void 0===r&&(r=this.rows-1),e>r||e<0||e>=this.rows||r<0||r>=this.rows)throw new RangeError("Argument out of range");let n=new ge(r-e+1,t.length);for(let o=0;o<t.length;o++)for(let i=e;i<=r;i++){if(t[o]<0||t[o]>=this.columns)throw new RangeError(`Column index out of range: ${t[o]}`);n.set(i-e,o,this.get(i,t[o]))}return n}setSubMatrix(t,e,r){if((t=ge.checkMatrix(t)).isEmpty())return this;ue(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(!Wt(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(!Wt(e))throw new TypeError("column indices must be an array");for(let r=0;r<e.length;r++)if(e[r]<0||e[r]>=t.columns)throw new RangeError("column indices are out of range")}(this,e);let r=new ge(t.length,e.length);for(let n=0;n<t.length;n++){let o=t[n];for(let t=0;t<e.length;t++){let i=e[t];r.set(n,t,this.get(o,i))}}return r}trace(){let t=Math.min(this.rows,this.columns),e=0;for(let r=0;r<t;r++)e+=this.get(r,r);return e}clone(){let t=new ge(this.rows,this.columns);for(let e=0;e<this.rows;e++)for(let r=0;r<this.columns;r++)t.set(e,r,this.get(e,r));return t}sum(t){switch(t){case"row":return function(t){let e=he(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=he(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=he(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=he(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(!Wt(n))throw new TypeError("mean must be an array");return function(t,e,r){const n=t.rows,o=t.columns,i=[];for(let s=0;s<n;s++){let n=0,a=0,u=0;for(let e=0;e<o;e++)u=t.get(s,e)-r[s],n+=u,a+=u*u;e?i.push((a-n*n/o)/(o-1)):i.push((a-n*n/o)/o)}return i}(this,r,n);case"column":if(!Wt(n))throw new TypeError("mean must be an array");return function(t,e,r){const n=t.rows,o=t.columns,i=[];for(let s=0;s<o;s++){let o=0,a=0,u=0;for(let e=0;e<n;e++)u=t.get(e,s)-r[s],o+=u,a+=u*u;e?i.push((a-o*o/n)/(n-1)):i.push((a-o*o/n)/n)}return i}(this,r,n);case void 0:if("number"!=typeof n)throw new TypeError("mean must be a number");return function(t,e,r){const n=t.rows,o=t.columns,i=n*o;let s=0,a=0,u=0;for(let e=0;e<n;e++)for(let n=0;n<o;n++)u=t.get(e,n)-r,s+=u,a+=u*u;return e?(a-s*s/i)/(i-1):(a-s*s/i)/i}(this,r,n);default:throw new Error(`invalid option: ${t}`)}}standardDeviation(t,e){"object"==typeof t&&(e=t,t=void 0);const r=this.variance(t,e);if(void 0===t)return Math.sqrt(r);for(let t=0;t<r.length;t++)r[t]=Math.sqrt(r[t]);return r}center(t,e={}){if("object"==typeof t&&(e=t,t=void 0),"object"!=typeof e)throw new TypeError("options must be an object");const{center:r=this.mean(t)}=e;switch(t){case"row":if(!Wt(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(!Wt(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(!Wt(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(!Wt(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 ee(this,t)}}function de(t,e){return t-e}fe.prototype.klass="Matrix","undefined"!=typeof Symbol&&(fe.prototype[Symbol.for("nodejs.util.inspect.custom")]=function(){return ee(this)}),fe.random=fe.rand,fe.randomInt=fe.randInt,fe.diagonal=fe.diag,fe.prototype.diagonal=fe.prototype.diag,fe.identity=fe.eye,fe.prototype.negate=fe.prototype.neg,fe.prototype.tensorProduct=fe.prototype.kroneckerProduct;class ge extends fe{constructor(t,e){if(super(),ge.isMatrix(t))return t.clone();if(Number.isInteger(t)&&t>=0){if(this.data=[],!(Number.isInteger(e)&&e>=0))throw new TypeError("nColumns must be a positive integer");for(let r=0;r<t;r++)this.data.push(new Float64Array(e))}else{if(!Wt(t))throw new TypeError("First argument must be a positive number or an array");{const r=t;if("number"!=typeof(e=(t=r.length)?r[0].length:0))throw new TypeError("Data must be a 2D array with at least one element");this.data=[];for(let n=0;n<t;n++){if(r[n].length!==e)throw new RangeError("Inconsistent array dimensions");if(!r[n].every((t=>"number"==typeof t)))throw new TypeError("Input data contains non-numeric values");this.data.push(Float64Array.from(r[n]))}}}this.rows=t,this.columns=e}set(t,e,r){return this.data[t][e]=r,this}get(t,e){return this.data[t][e]}removeRow(t){return oe(this,t),this.data.splice(t,1),this.rows-=1,this}addRow(t,e){return void 0===e&&(e=t,t=this.rows),oe(this,t,!0),e=Float64Array.from(se(this,e)),this.data.splice(t,0,e),this.rows+=1,this}removeColumn(t){ie(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),ie(this,t,!0),e=ae(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}}(fe,ge);class pe extends fe{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 me(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 we{constructor(t,e={}){if((t=pe.checkMatrix(t)).isEmpty())throw new Error("Matrix must be non-empty");let r=t.rows,n=t.columns;const{computeLeftSingularVectors:o=!0,computeRightSingularVectors:i=!0,autoTranspose:s=!1}=e;let a,u=Boolean(o),h=Boolean(i),l=!1;if(r<n)if(s){a=t.transpose(),r=a.rows,n=a.columns,l=!0;let e=u;u=h,h=e}else a=t.clone(),console.warn("Computing SVD on a matrix with more columns than rows. Consider enabling autoTranspose");else a=t.clone();let c=Math.min(r,n),f=Math.min(r+1,n),d=new Float64Array(f),g=new ge(r,c),p=new ge(n,n),m=new Float64Array(n),w=new Float64Array(r),y=new Float64Array(f);for(let t=0;t<f;t++)y[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]=me(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))}m[e]=a.get(t,e)}if(u&&t<v)for(let e=t;e<r;e++)g.set(e,t,a.get(e,t));if(t<x){m[t]=0;for(let e=t+1;e<n;e++)m[t]=me(m[t],m[e]);if(0!==m[t]){m[t+1]<0&&(m[t]=0-m[t]);for(let e=t+1;e<n;e++)m[e]/=m[t];m[t+1]+=1}if(m[t]=-m[t],t+1<r&&0!==m[t]){for(let e=t+1;e<r;e++)w[e]=0;for(let e=t+1;e<r;e++)for(let r=t+1;r<n;r++)w[e]+=m[r]*a.get(e,r);for(let e=t+1;e<n;e++){let n=-m[e]/m[t+1];for(let o=t+1;o<r;o++)a.set(o,e,a.get(o,e)+n*w[o])}}if(h)for(let e=t+1;e<n;e++)p.set(e,t,m[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&&(m[x]=a.get(x,M-1)),m[M-1]=0,u){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(h)for(let t=n-1;t>=0;t--){if(t<x&&0!==m[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,S=0,N=Number.EPSILON;for(;M>0;){let t,e;for(t=M-2;t>=-1&&-1!==t;t--){const e=Number.MIN_VALUE+N*Math.abs(d[t]+Math.abs(d[t+1]));if(Math.abs(m[t])<=e||Number.isNaN(m[t])){m[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(m[r]):0)+(r!==t+1?Math.abs(m[r-1]):0);if(Math.abs(d[r])<=N*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=m[M-2];m[M-2]=0;for(let r=M-2;r>=t;r--){let o=me(d[r],e),i=d[r]/o,s=e/o;if(d[r]=o,r!==t&&(e=-s*m[r-1],m[r-1]=i*m[r-1]),h)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=m[t-1];m[t-1]=0;for(let n=t;n<M;n++){let o=me(d[n],e),i=d[n]/o,s=e/o;if(d[n]=o,e=-s*m[n],m[n]=i*m[n],u)for(let e=0;e<r;e++)o=i*g.get(e,n)+s*g.get(e,t-1),g.set(e,t-1,-s*g.get(e,n)+i*g.get(e,t-1)),g.set(e,n,o)}break}case 3:{const e=Math.max(Math.abs(d[M-1]),Math.abs(d[M-2]),Math.abs(m[M-2]),Math.abs(d[t]),Math.abs(m[t])),o=d[M-1]/e,i=d[M-2]/e,s=m[M-2]/e,a=d[t]/e,l=m[t]/e,c=((i+o)*(i-o)+s*s)/2,f=o*s*(o*s);let w=0;0===c&&0===f||(w=c<0?0-Math.sqrt(c*c+f):Math.sqrt(c*c+f),w=f/(c+w));let y=(a+o)*(a-o)+w,v=a*l;for(let e=t;e<M-1;e++){let o=me(y,v);0===o&&(o=Number.MIN_VALUE);let i=y/o,s=v/o;if(e!==t&&(m[e-1]=o),y=i*d[e]+s*m[e],m[e]=i*m[e]-s*d[e],v=s*d[e+1],d[e+1]=i*d[e+1],h)for(let t=0;t<n;t++)o=i*p.get(t,e)+s*p.get(t,e+1),p.set(t,e+1,-s*p.get(t,e)+i*p.get(t,e+1)),p.set(t,e,o);if(o=me(y,v),0===o&&(o=Number.MIN_VALUE),i=y/o,s=v/o,d[e]=o,y=i*m[e]+s*d[e+1],d[e+1]=-s*m[e]+i*d[e+1],v=s*m[e+1],m[e+1]=i*m[e+1],u&&e<r-1)for(let t=0;t<r;t++)o=i*g.get(t,e)+s*g.get(t,e+1),g.set(t,e+1,-s*g.get(t,e)+i*g.get(t,e+1)),g.set(t,e,o)}m[M-2]=y,S+=1;break}case 4:if(d[t]<=0&&(d[t]=d[t]<0?-d[t]:0,h))for(let e=0;e<=E;e++)p.set(e,t,-p.get(e,t));for(;t<E&&!(d[t]>=d[t+1]);){let e=d[t];if(d[t]=d[t+1],d[t+1]=e,h&&t<n-1)for(let r=0;r<n;r++)e=p.get(r,t+1),p.set(r,t+1,p.get(r,t)),p.set(r,t,e);if(u&&t<r-1)for(let n=0;n<r;n++)e=g.get(n,t+1),g.set(n,t+1,g.get(n,t)),g.set(n,t,e);t++}S=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=ge.zeros(n,n);for(let t=0;t<n;t++)Math.abs(this.s[t])<=r?o.set(t,t,0):o.set(t,t,1/this.s[t]);let i=this.U,s=this.rightSingularVectors,a=s.mmul(o),u=s.rows,h=i.rows,l=ge.zeros(u,h);for(let t=0;t<u;t++)for(let e=0;e<h;e++){let r=0;for(let o=0;o<n;o++)r+=a.get(t,o)*i.get(e,o);l.set(t,e,r)}return l.mmul(e)}solveForDiagonal(t){return this.solve(ge.diag(t))}inverse(){let t=this.V,e=this.threshold,r=t.rows,n=t.columns,o=new ge(r,this.s.length);for(let i=0;i<r;i++)for(let r=0;r<n;r++)Math.abs(this.s[r])>e&&o.set(i,r,t.get(i,r)/this.s[r]);let i=this.U,s=i.rows,a=i.columns,u=new ge(r,s);for(let t=0;t<r;t++)for(let e=0;e<s;e++){let r=0;for(let n=0;n<a;n++)r+=o.get(t,n)*i.get(e,n);u.set(t,e,r)}return u}get condition(){return this.s[0]/this.s[Math.min(this.m,this.n)-1]}get norm2(){return this.s[0]}get rank(){let t=Math.max(this.m,this.n)*this.s[0]*Number.EPSILON,e=0,r=this.s;for(let n=0,o=r.length;n<o;n++)r[n]>t&&e++;return e}get diagonal(){return Array.from(this.s)}get threshold(){return Number.EPSILON/2*Math.max(this.m,this.n)*this.s[0]}get leftSingularVectors(){return this.U}get rightSingularVectors(){return this.V}get diagonalMatrix(){return ge.diag(this.s)}}var ye={center:[0,0],linkDistance:50},ve=function(){function t(t){void 0===t&&(t={}),this.options=t,this.id="mds",this.options=e(e({},ye),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,u=void 0===a?50:a,h=o.layoutInvisibles,l=o.onLayoutEnd,d=r.getAllNodes(),g=r.getAllEdges();if(h||(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}))),!d||0===d.length){var p={nodes:[],edges:g};return null==l||l(p),p}if(1===d.length){t&&r.mergeNodeData(d[0].id,{x:s[0],y:s[1]});var w={nodes:[e(e({},d[0]),{data:e(e({},d[0].data),{x:s[0],y:s[1]})})],edges:g};return null==l||l(w),w}var y=f({nodes:d,edges:g},!1),v=c(y);xe(v);var x=function(t,e){var r=[];return t.forEach((function(t){var n=[];t.forEach((function(t){n.push(t*e)})),r.push(n)})),r}(v,u),b=be(x),M=[];b.forEach((function(t,e){var r=m(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 E={nodes:M,edges:g};return null==l||l(E),E},t}(),xe=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)}))}))},be=function(t){var e=ge.mul(ge.pow(t,2),-.5),r=e.mean("row"),n=e.mean("column"),o=e.mean();e.add(o).subRowVector(r).subColumnVector(n);var i=new we(e),s=ge.sqrt(i.diagonalMatrix).diagonal();return i.leftSingularVectors.toJSON().map((function(t){return ge.mul([t],[s]).toJSON()[0].splice(0,2)}))},Me={iterations:10,height:10,width:10,speed:100,gravity:10,k:5},Ee=function(t,e,r,n,o,i){e.forEach((function(s,a){r[a]={x:0,y:0},e.forEach((function(e,u){if(a!==u&&o[a]===o[u]){var h=s.x-e.x,l=s.y-e.y,c=Math.sqrt(h*h+l*l);if(0===c){c=1;var f=a>u?1:-1;h=.01*f,l=.01*f}if(c<i(t[a])/2+i(t[u])/2){var d=n*n/c;r[a].x+=h/c*d,r[a].y+=l/c*d}}}))}))},Se=function(t,e,r,n,o,i,s,a){var u=i||s/10;return n&&e.forEach((function(e,r){var n=t[r].x-t[o].x,i=t[r].y-t[o].y,s=Math.sqrt(n*n+i*i),a=i/s,u=-n/s,h=Math.sqrt(e.x*e.x+e.y*e.y),l=Math.acos((a*e.x+u*e.y)/h);l>Math.PI/2&&(l-=Math.PI/2,a*=-1,u*=-1);var c=Math.cos(l)*h;e.x=a*c,e.y=u*c})),t.forEach((function(i,s){if(s!==o){var h=Math.sqrt(e[s].x*e[s].x+e[s].y*e[s].y);if(h>0&&s!==o){var l=Math.min(u*(r/800),h);if(i.x+=e[s].x/h*l,i.y+=e[s].y/h*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},Ne={maxIteration:1e3,focusNode:null,unitRadius:null,linkDistance:50,preventOverlap:!1,strictRadial:!0,maxPreventOverlapIteration:200,sortStrength:10},Ae=function(){function t(t){void 0===t&&(t={}),this.options=t,this.id="radial",this.options=e(e({},Ne),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),u=o.width,h=o.height,l=o.center,d=o.focusNode,g=o.unitRadius,p=o.nodeSize,w=o.nodeSpacing,y=o.strictRadial,v=o.preventOverlap,x=o.maxPreventOverlapIteration,b=o.sortBy,M=o.linkDistance,E=void 0===M?50:M,S=o.sortStrength,N=void 0===S?10:S,A=o.maxIteration,k=void 0===A?1e3:A,_=o.layoutInvisibles,D=o.onLayoutEnd,R=r.getAllNodes(),I=r.getAllEdges();if(_||(R=R.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}))),!R||0===R.length){var z={nodes:[],edges:I};return null==D||D(z),z}var C=u||"undefined"==typeof window?u:window.innerWidth,T=h||"undefined"==typeof window?h:window.innerHeight,P=l||[C/2,T/2];if(1===R.length){t&&r.mergeNodeData(R[0].id,{x:P[0],y:P[1]});var O={nodes:[e(e({},R[0]),{data:e(e({},R[0].data),{x:P[0],y:P[1]})})],edges:I};return null==D||D(O),O}var j=R[0];if(a(d)){for(var L=0;L<R.length;L++)if(R[L].id===d){j=R[L];break}}else j=d||R[0];var q=De(R,j.id),V=f({nodes:R,edges:I},!1),F=c(V),$=Ie(F,q);Re(F,q,$+1);var U=F[q],K=C-P[0]>P[0]?P[0]:C-P[0],B=T-P[1]>P[1]?P[1]:T-P[1];0===K&&(K=C/2),0===B&&(B=T/2);var G=Math.min(K,B),J=Math.max.apply(Math,s([],i(U),!1)),H=[],W=g||G/J;U.forEach((function(t,e){H[e]=t*W}));var Y,X=ke(R,F,E,H,W,b,N),Q=_e(X),Z=function(t,e,r){try{var n=ge.mul(ge.pow(e,2),-.5),o=n.mean("row"),i=n.mean("column"),s=n.mean();n.add(s).subRowVector(o).subColumnVector(i);var a=new we(n),u=ge.sqrt(a.diagonalMatrix).diagonal();return a.leftSingularVectors.toJSON().map((function(e){return ge.mul([e],[u]).toJSON()[0].splice(0,t)}))}catch(t){for(var h=[],l=0;l<e.length;l++){var c=Math.random()*r,f=Math.random()*r;h.push([c,f])}return h}}(E,X,E),tt=Z.map((function(t){var e=i(t,2),r=e[0],n=e[1];return{x:(isNaN(r)?Math.random()*E:r)-Z[q][0],y:(isNaN(n)?Math.random()*E:n)-Z[q][1]}}));if(this.run(k,tt,Q,X,H,q),v){Y=ze(p,w);var et={nodes:R,nodeSizeFunc:Y,positions:tt,radii:H,height:T,width:C,strictRadial:Boolean(y),focusIdx:q,iterations:x||200,k:tt.length/4.5};tt=function(t,r){for(var n=e(e({},Me),r),o=n.positions,i=n.iterations,s=n.width,a=n.k,u=n.speed,h=void 0===u?100:u,l=n.strictRadial,c=n.focusIdx,f=n.radii,d=void 0===f?[]:f,g=n.nodeSizeFunc,p=t.getAllNodes(),m=[],w=s/10,y=0;y<i;y++)o.forEach((function(t,e){m[e]={x:0,y:0}})),Ee(p,o,m,a,d,g),Se(o,m,h,l,c,w,s,d);return o}(r,et)}var rt=[];tt.forEach((function(t,e){var r=m(R[e]);r.data.x=t.x+P[0],r.data.y=t.y+P[1],rt.push(r)})),t&&rt.forEach((function(t){return r.mergeNodeData(t.id,{x:t.data.x,y:t.data.y})}));var nt={nodes:rt,edges:I};return null==D||D(nt),nt},t.prototype.run=function(t,e,r,n,o,i){for(var s=0;s<=t;s++){var a=s/t;this.oneIteration(a,e,o,n,r,i)}},t.prototype.oneIteration=function(t,e,r,n,o,i){var s=1-t;e.forEach((function(a,u){var h=d(a,{x:0,y:0}),l=0===h?0:1/h;if(u!==i){var c=0,f=0,g=0;e.forEach((function(t,e){if(u!==e){var r=d(a,t),i=0===r?0:1/r,s=n[e][u];g+=o[u][e],c+=o[u][e]*(t.x+s*(a.x-t.x)*i),f+=o[u][e]*(t.y+s*(a.y-t.y)*i)}}));var p=0===r[u]?0:1/r[u];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}(),ke=function(t,e,r,n,o,i,s){if(!t)return[];var u=[];if(e){var h={};e.forEach((function(e,l){var c=[];e.forEach((function(e,u){var f,d;if(l===u)c.push(0);else if(n[l]===n[u])if("data"===i)c.push(e*(Math.abs(l-u)*s)/(n[l]/o));else if(i){var g=void 0,p=void 0;if(h[t[l].id])g=h[t[l].id];else{var m=("id"===i?t[l].id:null===(f=t[l].data)||void 0===f?void 0:f[i])||0;g=a(m)?m.charCodeAt(0):m,h[t[l].id]=g}h[t[u].id]?p=h[t[u].id]:(m=("id"===i?t[u].id:null===(d=t[u].data)||void 0===d?void 0:d[i])||0,p=a(m)?m.charCodeAt(0):m,h[t[u].id]=p),c.push(e*(Math.abs(g-p)*s)/(n[l]/o))}else c.push(e*r/(n[l]/o));else{var w=(r+o)/2;c.push(e*w)}})),u.push(c)}))}return u},_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},De=function(t,e){var r=-1;return t.forEach((function(t,n){t.id===e&&(r=n)})),Math.max(r,0)},Re=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}},Ie=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},ze=function(t,e){var r;return r=l(e)?function(){return e}:w(e)?e:function(){return 0},t?h(t)?function(e){return(t[0]>t[1]?t[0]:t[1])+r(e)}:function(e){return t+r(e)}:function(t){return t.data.bboxSize?Math.max(t.data.bboxSize[0],t.data.bboxSize[1])+r(t):t.data.size?h(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)}},Ce={center:[0,0],width:300,height:300},Te=function(){function t(t){void 0===t&&(t={}),this.options=t,this.id="random",this.options=e(e({},Ce),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,u=o.layoutInvisibles,h=o.onLayoutEnd,l=r.getAllNodes();u||(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==h||h(p),p},t}(),Pe={circular:b,concentric:I,mds:ve,random:Te,grid:Ft,radial:Ae,force:Tt,d3force:_t};function Oe(t,e){Pe[t]=e}})(),n})()));
2
2
  //# sourceMappingURL=index.min.js.map