@antv/layout 2.0.0-beta.1 → 2.0.0
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.js +26 -13
- package/dist/index.js.map +1 -1
- package/dist/index.min.js +2 -2
- package/dist/index.min.js.map +1 -1
- package/dist/worker.js +2 -2
- package/dist/worker.js.map +1 -1
- package/lib/algorithm/antv-dagre/rank/index.js +1 -1
- package/lib/algorithm/concentric/index.js +1 -1
- package/lib/index.d.ts +2 -2
- package/lib/runtime/supervisor.js +26 -12
- package/lib/runtime/supervisor.js.map +1 -1
- package/lib/util/format.js +1 -1
- package/lib/worker.js +26 -12
- package/lib/worker.js.map +1 -1
- package/package.json +4 -2
- package/src/runtime/supervisor.ts +26 -11
package/dist/worker.js
CHANGED
|
@@ -1,8 +1,8 @@
|
|
|
1
|
-
!function(){"use strict";
|
|
1
|
+
!function(){"use strict";function t(t,e,r,n){return new(r||(r=Promise))(function(o,i){function s(t){try{u(n.next(t))}catch(t){i(t)}}function a(t){try{u(n.throw(t))}catch(t){i(t)}}function u(t){var e;t.done?o(t.value):(e=t.value,e instanceof r?e:new r(function(t){t(e)})).then(s,a)}u((n=n.apply(t,e||[])).next())})}"function"==typeof SuppressedError&&SuppressedError;
|
|
2
2
|
/**
|
|
3
3
|
* @license
|
|
4
4
|
* Copyright 2019 Google LLC
|
|
5
5
|
* SPDX-License-Identifier: Apache-2.0
|
|
6
6
|
*/
|
|
7
|
-
const r=Symbol("Comlink.proxy"),n=Symbol("Comlink.endpoint"),o=Symbol("Comlink.releaseProxy"),i=Symbol("Comlink.finalizer"),s=Symbol("Comlink.thrown"),a=t=>"object"==typeof t&&null!==t||"function"==typeof t,u=new Map([["proxy",{canHandle:t=>a(t)&&t[r],serialize(t){const{port1:e,port2:r}=new MessageChannel;return c(t,e),[r,[r]]},deserialize:t=>(t.start(),l(t))}],["throw",{canHandle:t=>a(t)&&s in t,serialize({value:t}){let e;return e=t instanceof Error?{isError:!0,value:{message:t.message,name:t.name,stack:t.stack}}:{isError:!1,value:t},[e,[]]},deserialize(t){if(t.isError)throw Object.assign(new Error(t.value.message),t.value);throw t.value}}]]);function c(t,e=globalThis,n=["*"]){e.addEventListener("message",function o(a){if(!a||!a.data)return;if(!function(t,e){for(const r of t){if(e===r||"*"===r)return!0;if(r instanceof RegExp&&r.test(e))return!0}return!1}(n,a.origin))return void console.warn(`Invalid origin '${a.origin}' for comlink proxy`);const{id:u,type:l,path:d}=Object.assign({path:[]},a.data),f=(a.data.argumentList||[]).map(x);let g;try{const e=d.slice(0,-1).reduce((t,e)=>t[e],t),n=d.reduce((t,e)=>t[e],t);switch(l){case"GET":g=n;break;case"SET":e[d.slice(-1)[0]]=x(a.data.value),g=!0;break;case"APPLY":g=n.apply(e,f);break;case"CONSTRUCT":g=function(t){return Object.assign(t,{[r]:!0})}(new n(...f));break;case"ENDPOINT":{const{port1:e,port2:r}=new MessageChannel;c(t,r),g=function(t,e){return y.set(t,e),t}(e,[e])}break;case"RELEASE":g=void 0;break;default:return}}catch(t){g={value:t,[s]:0}}Promise.resolve(g).catch(t=>({value:t,[s]:0})).then(r=>{const[n,s]=w(r);e.postMessage(Object.assign(Object.assign({},n),{id:u}),s),"RELEASE"===l&&(e.removeEventListener("message",o),h(e),i in t&&"function"==typeof t[i]&&t[i]())}).catch(t=>{const[r,n]=w({value:new TypeError("Unserializable return value"),[s]:0});e.postMessage(Object.assign(Object.assign({},r),{id:u}),n)})}),e.start&&e.start()}function h(t){(function(t){return"MessagePort"===t.constructor.name})(t)&&t.close()}function l(t,e){const r=new Map;return t.addEventListener("message",function(t){const{data:e}=t;if(!e||!e.id)return;const n=r.get(e.id);if(n)try{n(e)}finally{r.delete(e.id)}}),v(t,r,[],e)}function d(t){if(t)throw new Error("Proxy has been released and is not useable")}function f(t){return b(t,new Map,{type:"RELEASE"}).then(()=>{h(t)})}const g=new WeakMap,p="FinalizationRegistry"in globalThis&&new FinalizationRegistry(t=>{const e=(g.get(t)||0)-1;g.set(t,e),0===e&&f(t)});function v(t,e,r=[],i=function(){}){let s=!1;const a=new Proxy(i,{get(n,i){if(d(s),i===o)return()=>{!function(t){p&&p.unregister(t)}(a),f(t),e.clear(),s=!0};if("then"===i){if(0===r.length)return{then:()=>a};const n=b(t,e,{type:"GET",path:r.map(t=>t.toString())}).then(x);return n.then.bind(n)}return v(t,e,[...r,i])},set(n,o,i){d(s);const[a,u]=w(i);return b(t,e,{type:"SET",path:[...r,o].map(t=>t.toString()),value:a},u).then(x)},apply(o,i,a){d(s);const u=r[r.length-1];if(u===n)return b(t,e,{type:"ENDPOINT"}).then(x);if("bind"===u)return v(t,e,r.slice(0,-1));const[c,h]=m(a);return b(t,e,{type:"APPLY",path:r.map(t=>t.toString()),argumentList:c},h).then(x)},construct(n,o){d(s);const[i,a]=m(o);return b(t,e,{type:"CONSTRUCT",path:r.map(t=>t.toString()),argumentList:i},a).then(x)}});return function(t,e){const r=(g.get(e)||0)+1;g.set(e,r),p&&p.register(t,e,t)}(a,t),a}function m(t){const e=t.map(w);return[e.map(t=>t[0]),(r=e.map(t=>t[1]),Array.prototype.concat.apply([],r))];var r}const y=new WeakMap;function w(t){for(const[e,r]of u)if(r.canHandle(t)){const[n,o]=r.serialize(t);return[{type:"HANDLER",name:e,value:n},o]}return[{type:"RAW",value:t},y.get(t)||[]]}function x(t){switch(t.type){case"HANDLER":return u.get(t.name).deserialize(t.value);case"RAW":return t.value}}function b(t,e,r,n){return new Promise(o=>{const i=new Array(4).fill(0).map(()=>Math.floor(Math.random()*Number.MAX_SAFE_INTEGER).toString(16)).join("-");e.set(i,o),t.start&&t.start(),t.postMessage(Object.assign({id:i},r),n)})}function E(t){return"function"==typeof t}function M(t){return null==t}function N(t){return Array.isArray(t)}var _={}.toString,k=function(t,e){return _.call(t)==="[object "+e+"]"},S=function(t){if(!function(t){return"object"==typeof t&&null!==t}(t)||!k(t,"Object"))return!1;if(null===Object.getPrototypeOf(t))return!0;for(var e=t;null!==Object.getPrototypeOf(e);)e=Object.getPrototypeOf(e);return Object.getPrototypeOf(t)===e};function A(t){return"string"==typeof t}function O(t){return"number"==typeof t}var z={}.toString,j=Object.prototype,C=function(t){if("object"!=typeof t||null===t)return t;var e;if(N(t)){e=[];for(var r=0,n=t.length;r<n;r++)"object"==typeof t[r]&&null!=t[r]?e[r]=C(t[r]):e[r]=t[r]}else for(var o in e={},t)"object"==typeof t[o]&&null!=t[o]?e[o]=C(t[o]):e[o]=t[o];return e};function I(t,e){if(Object.hasOwn)return Object.hasOwn(t,e);if(null==t)throw new TypeError("Cannot convert undefined or null to object");return Object.prototype.hasOwnProperty.call(Object(t),e)}function R(t,e,r,n){for(var o in r=r||0,n=n||5,e)if(I(e,o)){var i=e[o];null!==i&&S(i)?(S(t[o])||(t[o]={}),r<n?R(t[o],i,r+1,n):t[o]=e[o]):N(i)?(t[o]=[],t[o]=t[o].concat(i)):void 0!==i&&(t[o]=i)}}var T=Object.prototype.hasOwnProperty;function P(t){if(M(t))return!0;if(function(t){return null!==t&&"function"!=typeof t&&isFinite(t.length)}(t))return!t.length;var e=function(t){return z.call(t).replace(/^\[object /,"").replace(/]$/,"")}(t);if("Map"===e||"Set"===e)return!t.size;if(function(t){var e=t&&t.constructor;return t===("function"==typeof e&&e.prototype||j)}(t))return!Object.keys(t).length;for(var r in t)if(T.call(t,r))return!1;return!0}var F=Object.prototype.hasOwnProperty,L=function(t,e){if(null===t||!S(t))return{};var r={};return function(t,e){var r,n;if(t)if(N(t))for(var o=0,i=t.length;o<i&&!1!==e(t[o],o);o++);else if(n=typeof(r=t),null!==r&&"object"===n||"function"===n)for(var s in t)if(t.hasOwnProperty(s)&&!1===e(t[s],s))break}(e,function(e){F.call(t,e)&&(r[e]=t[e])}),r};function D(t,e,r=2){if(1===t.nodeCount()){const n=t.firstNode();n.x=e[0],n.y=e[1],3===r&&(n.z=e[2]||0)}}const q={abs:Math.abs,ceil:Math.ceil,floor:Math.floor,max:Math.max,min:Math.min,round:Math.round,sqrt:Math.sqrt,pow:Math.pow};class B extends Error{constructor(t,e,r){super(t),this.position=e,this.token=r,this.name="ExpressionError"}}var V;!function(t){t[t.STRING=0]="STRING",t[t.NUMBER=1]="NUMBER",t[t.BOOLEAN=2]="BOOLEAN",t[t.NULL=3]="NULL",t[t.IDENTIFIER=4]="IDENTIFIER",t[t.OPERATOR=5]="OPERATOR",t[t.FUNCTION=6]="FUNCTION",t[t.DOT=7]="DOT",t[t.BRACKET_LEFT=8]="BRACKET_LEFT",t[t.BRACKET_RIGHT=9]="BRACKET_RIGHT",t[t.PAREN_LEFT=10]="PAREN_LEFT",t[t.PAREN_RIGHT=11]="PAREN_RIGHT",t[t.COMMA=12]="COMMA",t[t.QUESTION=13]="QUESTION",t[t.COLON=14]="COLON",t[t.DOLLAR=15]="DOLLAR"}(V||(V={}));const U=new Set([32,9,10,13]),$=new Set([43,45,42,47,37,33,38,124,61,60,62]),G=new Map([["true",V.BOOLEAN],["false",V.BOOLEAN],["null",V.NULL]]),W=new Map([["===",!0],["!==",!0],["<=",!0],[">=",!0],["&&",!0],["||",!0],["+",!0],["-",!0],["*",!0],["/",!0],["%",!0],["!",!0],["<",!0],[">",!0]]),Y=new Map([[46,V.DOT],[91,V.BRACKET_LEFT],[93,V.BRACKET_RIGHT],[40,V.PAREN_LEFT],[41,V.PAREN_RIGHT],[44,V.COMMA],[63,V.QUESTION],[58,V.COLON],[36,V.DOLLAR]]),H=new Map;for(const[t,e]of Y.entries())H.set(t,{type:e,value:String.fromCharCode(t)});function X(t){return t>=48&&t<=57}function Q(t){return t>=97&&t<=122||t>=65&&t<=90||95===t}function K(t){return Q(t)||X(t)}function J(t){return $.has(t)}var Z;!function(t){t[t.Program=0]="Program",t[t.Literal=1]="Literal",t[t.Identifier=2]="Identifier",t[t.MemberExpression=3]="MemberExpression",t[t.CallExpression=4]="CallExpression",t[t.BinaryExpression=5]="BinaryExpression",t[t.UnaryExpression=6]="UnaryExpression",t[t.ConditionalExpression=7]="ConditionalExpression"}(Z||(Z={}));const tt=new Map([["||",2],["&&",3],["===",4],["!==",4],[">",5],[">=",5],["<",5],["<=",5],["+",6],["-",6],["*",7],["/",7],["%",7],["!",8]]),et={type:Z.Literal,value:null},rt={type:Z.Literal,value:!0},nt={type:Z.Literal,value:!1},ot=t=>{let e=0;const r=t.length,n=()=>e>=r?null:t[e],o=()=>t[e++],i=t=>{const e=n();return null!==e&&e.type===t},s=t=>t.type===V.OPERATOR?tt.get(t.value)||-1:t.type===V.DOT||t.type===V.BRACKET_LEFT?9:t.type===V.QUESTION?1:-1,a=t=>{let r,s;if(o().type===V.DOT){if(!i(V.IDENTIFIER)){const t=n();throw new B("Expected property name",e,t?t.value:"<end of input>")}const t=o();r={type:Z.Identifier,name:t.value},s=!1}else{if(r=c(0),!i(V.BRACKET_RIGHT)){const t=n();throw new B("Expected closing bracket",e,t?t.value:"<end of input>")}o(),s=!0}return{type:Z.MemberExpression,object:t,property:r,computed:s}},u=()=>{const t=n();if(!t)throw new B("Unexpected end of input",e,"<end of input>");if(t.type===V.OPERATOR&&("!"===t.value||"-"===t.value)){o();const e=u();return{type:Z.UnaryExpression,operator:t.value,argument:e,prefix:!0}}switch(t.type){case V.NUMBER:return o(),{type:Z.Literal,value:Number(t.value)};case V.STRING:return o(),{type:Z.Literal,value:t.value};case V.BOOLEAN:return o(),"true"===t.value?rt:nt;case V.NULL:return o(),et;case V.IDENTIFIER:return o(),{type:Z.Identifier,name:t.value};case V.FUNCTION:return(()=>{const t=o(),r=[];if(!i(V.PAREN_LEFT)){const t=n();throw new B("Expected opening parenthesis after function name",e,t?t.value:"<end of input>")}for(o();;){if(i(V.PAREN_RIGHT)){o();break}if(!n()){const t=n();throw new B("Expected closing parenthesis",e,t?t.value:"<end of input>")}if(r.length>0){if(!i(V.COMMA)){const t=n();throw new B("Expected comma between function arguments",e,t?t.value:"<end of input>")}o()}const t=c(0);r.push(t)}return{type:Z.CallExpression,callee:{type:Z.Identifier,name:t.value},arguments:r}})();case V.PAREN_LEFT:{o();const t=c(0);if(!i(V.PAREN_RIGHT)){const t=n();throw new B("Expected closing parenthesis",e,t?t.value:"<end of input>")}return o(),t}default:throw new B(`Unexpected token: ${t.type}`,e,t.value)}},c=(h=0)=>{let l=u();for(;e<r;){const r=t[e],u=s(r);if(u<=h)break;if(r.type!==V.QUESTION)if(r.type!==V.OPERATOR){if(r.type!==V.DOT&&r.type!==V.BRACKET_LEFT)break;l=a(l)}else{o();const t=c(u);l={type:Z.BinaryExpression,operator:r.value,left:l,right:t}}else{o();const t=c(0);if(!i(V.COLON)){const t=n();throw new B("Expected : in conditional expression",e,t?t.value:"<end of input>")}o();const r=c(0);l={type:Z.ConditionalExpression,test:l,consequent:t,alternate:r}}}return l},h=c();return{type:Z.Program,body:h}},it=(t,e,r)=>{let n=e;r&&(n={...e,context:{...e.context,...r}});const o=t=>{switch(t.type){case Z.Literal:return(t=>t.value)(t);case Z.Identifier:return(t=>{if(!(t.name in n.context))throw new B(`Undefined variable: ${t.name}`);return n.context[t.name]})(t);case Z.MemberExpression:return(t=>{const e=o(t.object);if(null==e)throw new B("Cannot access property of null or undefined");return e[t.computed?o(t.property):t.property.name]})(t);case Z.CallExpression:return(t=>{const e=n.functions[t.callee.name];if(!e)throw new B(`Undefined function: ${t.callee.name}`);return e(...t.arguments.map(t=>o(t)))})(t);case Z.BinaryExpression:return(t=>{if("&&"===t.operator){const e=o(t.left);return e?o(t.right):e}if("||"===t.operator)return o(t.left)||o(t.right);const e=o(t.left),r=o(t.right);switch(t.operator){case"+":return e+r;case"-":return e-r;case"*":return e*r;case"/":return e/r;case"%":return e%r;case"===":return e===r;case"!==":return e!==r;case">":return e>r;case">=":return e>=r;case"<":return e<r;case"<=":return e<=r;default:throw new B(`Unknown operator: ${t.operator}`)}})(t);case Z.UnaryExpression:return(t=>{const e=o(t.argument);if(t.prefix)switch(t.operator){case"!":return!e;case"-":if("number"!=typeof e)throw new B(`Cannot apply unary - to non-number: ${e}`);return-e;default:throw new B(`Unknown operator: ${t.operator}`)}throw new B(`Postfix operators are not supported: ${t.operator}`)})(t);case Z.ConditionalExpression:return(t=>{const e=o(t.test);return o(e?t.consequent:t.alternate)})(t);default:throw new B(`Evaluation error: Unsupported node type: ${t.type}`)}};return o(t.body)};function st(t){const e=(t=>{const e=t,r=e.length,n=new Array(Math.ceil(r/3));let o=0,i=0;function s(t){const n=i+1;i++;let o="",s=!1;for(;i<r;){const r=e.charCodeAt(i);if(r===t)return s||(o=e.substring(n,i)),i++,{type:V.STRING,value:o};92===r?(s||(o=e.substring(n,i),s=!0),i++,o+=e[i]):s&&(o+=e[i]),i++}throw new B(`Unterminated string starting with ${String.fromCharCode(t)}`,i,e.substring(Math.max(0,i-10),i))}function a(){const t=i;for(45===e.charCodeAt(i)&&i++;i<r&&X(e.charCodeAt(i));)i++;if(i<r&&46===e.charCodeAt(i))for(i++;i<r&&X(e.charCodeAt(i));)i++;const n=e.slice(t,i);return{type:V.NUMBER,value:n}}function u(){i++;const t=i;if(i<r&&Q(e.charCodeAt(i)))for(i++;i<r&&K(e.charCodeAt(i));)i++;const n=e.slice(t,i);return{type:V.FUNCTION,value:n}}function c(){const t=i++;for(;i<r&&K(e.charCodeAt(i));)i++;const n=e.slice(t,i),o=G.get(n);return o?{type:o,value:n}:{type:V.IDENTIFIER,value:n}}function h(){if(i+2<r){const t=e.substring(i,i+3);if(W.has(t))return i+=3,{type:V.OPERATOR,value:t}}if(i+1<r){const t=e.substring(i,i+2);if(W.has(t))return i+=2,{type:V.OPERATOR,value:t}}const t=e[i];if(W.has(t))return i++,{type:V.OPERATOR,value:t};throw new B(`Unknown operator at position ${i}: ${e.substring(i,i+1)}`,i,e.substring(Math.max(0,i-10),i))}for(;i<r;){const t=e.charCodeAt(i);if(l=t,U.has(l)){i++;continue}const d=H.get(t);if(d)n[o++]=d,i++;else if(34!==t&&39!==t)if(X(t)||45===t&&i+1<r&&X(e.charCodeAt(i+1)))n[o++]=a();else if(64!==t)if(Q(t))n[o++]=c();else{if(!J(t))throw new B(`Unexpected character: ${e[i]}`,i,e.substring(Math.max(0,i-10),i));n[o++]=h()}else n[o++]=u();else n[o++]=s(t)}var l;return o===n.length?n:n.slice(0,o)})(t),r=ot(e),n=((t={},e={})=>({context:t,functions:e}))({},q);return(t={})=>it(r,n,t)}function at(t,e){if("string"!=typeof t)return;const r=t.trim();if(r)try{return st(r),function(t,e={}){return st(t)(e)}(r,e)}catch(t){return}}function ut(t){if(!t)return[0,0,0];if(O(t))return[t,t,t];if(Array.isArray(t)&&0===t.length)return[0,0,0];const[e,r=e,n=e]=t;return[e,r,n]}function ct(t,e){if("function"==typeof t)return t;if("string"==typeof t){const r=t;return(...t)=>{const n={};for(let r=0;r<e.length;r++)n[e[r]]=t[r];return at(r,n)}}return()=>t}function ht(t,e,r="node"){if(M(t))return()=>e;if(A(t)){const n=ct(t,[r]);return t=>{const r=n(t);return O(r)?r:e}}return E(t)?t:O(t)?()=>t:()=>e}function lt(t,e=10,r="node"){if(M(t))return()=>e;if(A(t)){const n=ct(t,[r]);return t=>{const r=n(t);return function(t){return!!O(t)||!!Array.isArray(t)&&t.every(t=>O(t))}(r)?r:e}}return E(t)?t:O(t)||Array.isArray(t)?()=>t:()=>e}const dt=(t,e,r=10,n=0)=>{const o=lt(e,n),i=lt(t,r);return t=>{const[e,r,n]=ut(i(t)),[s,a,u]=ut(o(t));return[e+s,r+a,n+u]}},ft=(t,e)=>{const r=t.nodeCount(),n=Array.from({length:r},()=>[]),o={};let i=0;return t.forEachNode(t=>{o[t.id]=i++}),t.forEachEdge(t=>{const e=o[t.source],r=o[t.target];null!=e&&null!=r&&(n[e].push(r),n[r].push(e))}),n};function gt(t){const e=t.length;new Array(e).fill(0);const r=Array.from({length:e},()=>new Array(e).fill(1/0));for(let n=0;n<e;n++)r[n]=pt(t,n);return r}function pt(t,e){const r=t.length,n=new Array(r).fill(1/0);n[e]=0;const o=new vt;for(o.push([0,e]);!o.empty();){const[e,r]=o.pop();if(e!==n[r])continue;const i=t[r];for(let t=0;t<i.length;t++){const r=i[t],s=e+1;s<n[r]&&(n[r]=s,o.push([s,r]))}}return n}class vt{constructor(){this.data=[]}push(t){this.data.push(t),this.bubbleUp(this.data.length-1)}pop(){const t=this.data[0],e=this.data.pop();return this.data.length>0&&(this.data[0]=e,this.bubbleDown(0)),t}empty(){return 0===this.data.length}bubbleUp(t){const e=this.data;for(;t>0;){const r=t-1>>1;if(e[r][0]<=e[t][0])break;[e[r],e[t]]=[e[t],e[r]],t=r}}bubbleDown(t){const e=this.data,r=e.length;for(;;){const n=2*t+1,o=2*t+2;let i=t;if(n<r&&e[n][0]<e[i][0]&&(i=n),o<r&&e[o][0]<e[i][0]&&(i=o),i===t)break;[e[t],e[i]]=[e[i],e[t]],t=i}}}function mt(t,...e){return e.forEach(e=>{e&&Object.keys(e).forEach(r=>{const n=e[r];void 0!==n&&(t[r]=n)})}),t}function yt(t,e){const r=t.nodes();return r.sort(e),t.setNodeOrder(r),t}function wt(t,e="desc"){return yt(t,(r,n)=>{const o=t.degree(r.id),i=t.degree(n.id);return"asc"===e?o-i:i-o})}function xt(t,e){return yt(t,(r,n)=>{const o=t.originalNode(r.id),i=t.originalNode(n.id);return e(o,i)})}function bt(t,e=!1){const r=t.nodeCount();if(0===r)return t;const n=t.nodes(),o=[n[0]],i={};i[n[0].id]=!0;let s=0,a=0;return t.forEachNode(u=>{if(0!==a){const c=t.degree(u.id,"both"),h=a<r-1?t.degree(n[a+1].id,"both"):0,l=o[s].id,d=t.neighbors(l,"both").includes(u.id);if(a!==r-1&&c===h&&!d||i[u.id]){const s=e?t.successors(l):t.neighbors(l);let a=!1;for(let e=0;e<s.length;e++){const r=s[e],n=t.node(r);if(n&&t.degree(r)===t.degree(u.id)&&!i[r]){o.push(n),i[r]=!0,a=!0;break}}let c=0;for(;!a&&(i[n[c].id]||(o.push(n[c]),i[n[c].id]=!0,a=!0),c++,c!==r););}else o.push(u),i[u.id]=!0,s++}a++}),t.setNodeOrder(o),t}function Et(t){var e;return[t.x,t.y,null!==(e=t.z)&&void 0!==e?e:0]}const Mt=t=>{const{width:e,height:r,center:n}=t,o=null!=e?e:"undefined"!=typeof window?window.innerWidth:0,i=null!=r?r:"undefined"!=typeof window?window.innerHeight:0;return{width:o,height:i,center:null!=n?n:[o/2,i/2]}};class Nt{constructor(t,e={}){this.edgeIdCounter=new Map,this.nodeMap=function(t,e){if(!t)throw new Error("Data.nodes is required");const r=new Map;for(const n of t){const t={_original:n};for(const e of _t){const r=n[e];M(r)||(t[e]=r)}if(e){const r=e(n);for(const e in r){const n=r[e];M(n)||(t[e]=n)}}if(M(t.id))throw new Error("Node is missing id field");r.set(t.id,t)}return r}(t.nodes,e.node),this.edgeMap=function(t,e,r){const n=new Map;for(const o of t){const t={_original:o};for(const e of kt){const r=o[e];M(r)||(t[e]=r)}if(e){const r=e(o);for(const e in r){const n=r[e];M(n)||(t[e]=n)}}if(M(t.source)||M(t.target))throw new Error("Edge is missing source or target field");M(t.id)&&(t.id=null==r?void 0:r(o)),n.set(t.id,t)}return n}(t.edges||[],e.edge,this.getEdgeId.bind(this))}data(){return{nodes:this.nodeMap,edges:this.edgeMap}}replace(t){this.nodeMap=t.nodes,this.edgeMap=t.edges,this.clearCache()}nodes(){return Array.from(this.nodeMap.values())}node(t){return this.nodeMap.get(t)}nodeAt(t){this.indexNodeCache||this.buildNodeIndexCache();const e=this.indexNodeCache.get(t);return e?this.nodeMap.get(e):void 0}nodeIndexOf(t){var e;return this.nodeIndexCache||this.buildNodeIndexCache(),null!==(e=this.nodeIndexCache.get(t))&&void 0!==e?e:-1}firstNode(){return this.nodeMap.values().next().value}forEachNode(t){let e=0;this.nodeMap.forEach(r=>t(r,e++))}originalNode(t){const e=this.nodeMap.get(t);return null==e?void 0:e._original}nodeCount(){return this.nodeMap.size}edges(){return Array.from(this.edgeMap.values())}edge(t){return this.edgeMap.get(t)}firstEdge(){return this.edgeMap.values().next().value}forEachEdge(t){let e=0;this.edgeMap.forEach(r=>t(r,e++))}originalEdge(t){const e=this.edgeMap.get(t);return null==e?void 0:e._original}edgeCount(){return this.edgeMap.size}getEdgeId(t){if(t.id)return t.id;const e=`${t.source}-${t.target}`,r=this.edgeIdCounter.get(e)||0,n=0===r?e:`${e}-${r}`;return this.edgeIdCounter.set(e,r+1),n}degree(t,e="both"){this.degreeCache||this.buildDegreeCache();const r=this.degreeCache.get(t);return r?r[e]:0}neighbors(t,e="both"){if(this.outAdjacencyCache&&this.inAdjacencyCache||this.buildAdjacencyCache(),"out"===e)return Array.from(this.outAdjacencyCache.get(t)||[]);if("in"===e)return Array.from(this.inAdjacencyCache.get(t)||[]);if(this.bothAdjacencyCache)return Array.from(this.bothAdjacencyCache.get(t)||[]);const r=this.inAdjacencyCache.get(t),n=this.outAdjacencyCache.get(t);if(!r&&!n)return[];if(!r)return Array.from(n);if(!n)return Array.from(r);const o=new Set;return r.forEach(t=>o.add(t)),n.forEach(t=>o.add(t)),Array.from(o)}successors(t){return this.neighbors(t,"out")}predecessors(t){return this.neighbors(t,"in")}setNodeOrder(t){const e=new Map;for(const r of t)e.set(r.id,r);this.nodeMap=e,this.nodeIndexCache=void 0,this.indexNodeCache=void 0}clearCache(){this.degreeCache=void 0,this.inAdjacencyCache=void 0,this.outAdjacencyCache=void 0,this.bothAdjacencyCache=void 0,this.nodeIndexCache=void 0,this.indexNodeCache=void 0}buildDegreeCache(){this.degreeCache=new Map;for(const t of this.edges()){const{source:e,target:r}=t;if(t.source===t.target)continue;this.degreeCache.has(e)||this.degreeCache.set(e,{in:0,out:0,both:0});const n=this.degreeCache.get(t.source);n&&(n.out++,n.both++),this.degreeCache.has(r)||this.degreeCache.set(r,{in:0,out:0,both:0});const o=this.degreeCache.get(t.target);o&&(o.in++,o.both++)}}buildAdjacencyCache(){this.inAdjacencyCache=new Map,this.outAdjacencyCache=new Map;for(const t of this.edges())this.nodeMap.has(t.source)&&this.nodeMap.has(t.target)&&(this.outAdjacencyCache.has(t.source)||this.outAdjacencyCache.set(t.source,new Set),this.outAdjacencyCache.get(t.source).add(t.target),this.inAdjacencyCache.has(t.target)||this.inAdjacencyCache.set(t.target,new Set),this.inAdjacencyCache.get(t.target).add(t.source))}buildNodeIndexCache(){this.nodeIndexCache=new Map,this.indexNodeCache=new Map;let t=0;this.nodeMap.forEach((e,r)=>{this.nodeIndexCache.set(r,t),this.indexNodeCache.set(t,r),t++})}destroy(){this.clearCache(),this.nodeMap.clear(),this.edgeMap.clear(),this.edgeIdCounter.clear()}}const _t=["id","x","y","z","vx","vy","vz","fx","fy","fz","parentId"],kt=["id","source","target","points"];function St(t,e,r,n=2){t.forEachNode(t=>{M(t.x)&&(t.x=Math.random()*e),M(t.y)&&(t.y=Math.random()*r),3===n&&M(t.z)&&(t.z=Math.random()*Math.min(e,r))})}class At{constructor(t,e={}){this.graph=new Nt(t,e)}export(){return this.graph.data()}replace(t){this.graph.replace(t)}forEachNode(t){this.graph.forEachNode(t)}forEachEdge(t){this.graph.forEachEdge((e,r)=>{e.sourceNode=this.graph.node(e.source),e.targetNode=this.graph.node(e.target),t(e,r)})}destroy(){this.graph.destroy()}}class Ot{constructor(){this.worker=null,this.workerApi=null}execute(t,r,n){return e(this,void 0,void 0,function*(){if(this.worker||(yield this.initWorker()),!this.workerApi)throw new Error("Worker API not initialized");return yield this.workerApi.execute(t,r,n)})}destroy(){this.workerApi&&this.workerApi.destroy(),this.worker&&(this.worker.terminate(),this.worker=null,this.workerApi=null)}initWorker(){return e(this,void 0,void 0,function*(){const t=this.resolveWorkerPath(),e=t.includes("/lib/")||t.endsWith(".mjs")?"module":"classic";this.worker=new Worker(t,{type:e}),this.workerApi=l(this.worker)})}resolveWorkerPath(){if(void 0!=={url:t&&"SCRIPT"===t.tagName.toUpperCase()&&t.src||new URL("worker.js",document.baseURI).href}&&(t&&"SCRIPT"===t.tagName.toUpperCase()&&t.src||new URL("worker.js",document.baseURI).href)){const e=new URL(t&&"SCRIPT"===t.tagName.toUpperCase()&&t.src||new URL("worker.js",document.baseURI).href),r=e.href.replace(/\/runtime\/[^/]+\.js$/,"/worker.js");return r!==e.href?r:e.href.replace(/\/[^/]+\.js$/,"/worker.js")}if("undefined"!=typeof document){const t=document.getElementsByTagName("script");for(let e=t.length-1;e>=0;e--){const r=t[e].src;if(r&&(r.includes("index.js")||r.includes("index.min.js")))return r.replace(/index(\.min)?\.js/,"worker.js")}}return"./worker.js"}}class zt{constructor(t){this.supervisor=null,this.initialOptions=this.mergeOptions(this.getDefaultOptions(),t)}get options(){return this.runtimeOptions||this.initialOptions}mergeOptions(t,e){return Object.assign({},t,e||{})}execute(t,r){return e(this,void 0,void 0,function*(){this.runtimeOptions=this.mergeOptions(this.initialOptions,r);const{node:e,edge:n,enableWorker:o}=this.runtimeOptions;this.context=new At(t,{node:e,edge:n}),this.model=this.context.graph;o&&"undefined"!=typeof Worker?yield this.layoutInWorker(t,this.runtimeOptions):yield this.layout(this.runtimeOptions)})}layoutInWorker(t,r){var n;return e(this,void 0,void 0,function*(){try{this.supervisor||(this.supervisor=new Ot);const e=yield this.supervisor.execute(this.id,t,r);null===(n=this.context)||void 0===n||n.replace(e)}catch(t){console.error("Layout in worker failed, fallback to main thread layout.",t),yield this.layout(r)}})}forEachNode(t){this.context.forEachNode(t)}forEachEdge(t){this.context.forEachEdge(t)}destroy(){var t;null===(t=this.context)||void 0===t||t.destroy(),this.model=null,this.context=null,this.supervisor&&(this.supervisor.destroy(),this.supervisor=null)}}class jt extends zt{}class Ct{constructor(t={}){this.options=t,this.nodes=new Map,this.edges=new Map,this.inEdges=new Map,this.outEdges=new Map,this.parentMap=new Map,this.childrenMap=new Map,t.tree&&Array.isArray(t.tree)&&t.tree.length>0&&("string"==typeof t.tree[0]?t.tree.forEach(t=>{this.parentMap.set(t,new Map),this.childrenMap.set(t,new Map)}):(this.attachTreeStructure("default"),this.addTree(t.tree))),t.nodes&&t.nodes.forEach(t=>this.addNode(t)),t.edges&&t.edges.forEach(t=>this.addEdge(t))}addNode(t){this.nodes.has(t.id)||(this.nodes.set(t.id,t),this.inEdges.set(t.id,new Set),this.outEdges.set(t.id,new Set))}addNodes(t){t.forEach(t=>this.addNode(t))}getNode(t){return this.nodes.get(t)}hasNode(t){return this.nodes.has(t)}removeNode(t){if(!this.nodes.has(t))return;const e=Array.from(this.inEdges.get(t)||[]),r=Array.from(this.outEdges.get(t)||[]);e.forEach(t=>this.removeEdge(t)),r.forEach(t=>this.removeEdge(t)),this.nodes.delete(t),this.inEdges.delete(t),this.outEdges.delete(t),this.parentMap.forEach(e=>{e.delete(t)}),this.childrenMap.forEach(e=>{e.delete(t)})}getAllNodes(){return Array.from(this.nodes.values())}addEdge(t){if(!this.nodes.has(t.source)||!this.nodes.has(t.target))throw new Error(`Cannot add edge ${t.id}: source ${t.source} or target ${t.target} does not exist`);this.edges.set(t.id,t),this.outEdges.get(t.source).add(t.id),this.inEdges.get(t.target).add(t.id)}addEdges(t){t.forEach(t=>this.addEdge(t))}getEdge(t){return this.edges.get(t)}hasEdge(t){return this.edges.has(t)}removeEdge(t){var e,r;const n=this.edges.get(t);n&&(this.edges.delete(t),null===(e=this.outEdges.get(n.source))||void 0===e||e.delete(t),null===(r=this.inEdges.get(n.target))||void 0===r||r.delete(t))}getAllEdges(){return Array.from(this.edges.values())}updateEdgeData(t,e){const r=this.edges.get(t);r&&Object.assign(r.data,e)}updateNodeData(t,e){const r=this.nodes.get(t);r&&Object.assign(r.data,e)}getRelatedEdges(t,e="both"){const r=[];if("in"===e||"both"===e){const e=this.inEdges.get(t);e&&e.forEach(t=>{const e=this.edges.get(t);e&&r.push(e)})}if("out"===e||"both"===e){const e=this.outEdges.get(t);e&&e.forEach(t=>{const e=this.edges.get(t);e&&r.push(e)})}return r}getSuccessors(t){const e=this.outEdges.get(t);if(!e||0===e.size)return[];const r=[];return e.forEach(t=>{const e=this.edges.get(t);if(e){const t=this.nodes.get(e.target);t&&r.push(t)}}),r.length>0?r:[]}getPredecessors(t){const e=this.inEdges.get(t);if(!e||0===e.size)return[];const r=[];return e.forEach(t=>{const e=this.edges.get(t);if(e){const t=this.nodes.get(e.source);t&&r.push(t)}}),r.length>0?r:[]}getNeighbors(t){const e=[...this.getSuccessors(t)||[],...this.getPredecessors(t)||[]],r=Array.from(new Map(e.map(t=>[t.id,t])).values());return r.length>0?r:[]}attachTreeStructure(t){this.parentMap.has(t)||(this.parentMap.set(t,new Map),this.childrenMap.set(t,new Map))}addTree(t,e){var r,n;const o=e||(null!==(n=null===(r=this.options.tree)||void 0===r?void 0:r[0])&&void 0!==n?n:"default");this.hasTreeStructure(o)||this.attachTreeStructure(o);const i=Array.isArray(t)?t:[t],s=(t,e)=>{this.addNode({id:t.id,data:t.data}),void 0!==e&&this.setParent(t.id,e,o),t.children&&t.children.length>0&&t.children.forEach(e=>{s(e,t.id)})};i.forEach(t=>s(t))}hasTreeStructure(t){return this.parentMap.has(t)}setParent(t,e,r){var n,o,i;const s=r||(null!==(o=null===(n=this.options.tree)||void 0===n?void 0:n[0])&&void 0!==o?o:"default");this.parentMap.has(s)||this.attachTreeStructure(s);const a=this.parentMap.get(s),u=this.childrenMap.get(s),c=a.get(t);void 0!==c&&(null===(i=u.get(c))||void 0===i||i.delete(t)),a.set(t,e),u.has(e)||u.set(e,new Set),u.get(e).add(t)}getParent(t,e){var r,n;const o=e||(null!==(n=null===(r=this.options.tree)||void 0===r?void 0:r[0])&&void 0!==n?n:"default");this.parentMap.has(o)||this.attachTreeStructure(o);const i=this.parentMap.get(o);if(!i)return;const s=i.get(t);return void 0===s?null:this.nodes.get(s)}getChildren(t,e){var r,n;const o=e||(null!==(n=null===(r=this.options.tree)||void 0===r?void 0:r[0])&&void 0!==n?n:"default"),i=this.childrenMap.get(o);if(!i)return[];const s=i.get(t);return s?Array.from(s).map(t=>this.nodes.get(t)).filter(t=>void 0!==t):[]}getRoots(t){var e,r;const n=t||(null!==(r=null===(e=this.options.tree)||void 0===e?void 0:e[0])&&void 0!==r?r:"default"),o=this.parentMap.get(n),i=[];return this.nodes.forEach(t=>{o&&void 0!==o.get(t.id)||i.push(t)}),i}dfsTree(t,e){const r=[t],n=new Set;for(;r.length>0;){const t=r.pop();if(n.has(t))continue;const o=this.getNode(t);if(o){n.add(t);if(!0===e(o))continue;const i=this.getChildren(t);for(let t=i.length-1;t>=0;t--)n.has(i[t].id)||r.push(i[t].id)}}}}const It=(t,e)=>{if("next"!==t&&"prev"!==t)return e},Rt=t=>{t.prev.next=t.next,t.next.prev=t.prev,delete t.next,delete t.prev};let Tt=class{constructor(){const t={};t.prev=t,t.next=t.prev,this.shortcut=t}dequeue(){const t=this.shortcut,e=t.prev;if(e&&e!==t)return Rt(e),e}enqueue(t){const e=this.shortcut;t.prev&&t.next&&Rt(t),t.next=e.next,e.next.prev=t,e.next=t,t.prev=e}toString(){const t=[],e=this.shortcut;let r=e.prev;for(;r!==e;)t.push(JSON.stringify(r,It)),r=null==r?void 0:r.prev;return`[${t.join(", ")}]`}};class Pt extends Tt{}const Ft=()=>1,Lt=(t,e,r)=>{let n=[];const o=e[e.length-1],i=e[0];let s;for(;t.getAllNodes().length;){for(;s=i.dequeue();)Dt(t,e,r,s);for(;s=o.dequeue();)Dt(t,e,r,s);if(t.getAllNodes().length)for(let o=e.length-2;o>0;--o)if(s=e[o].dequeue(),s){n=n.concat(Dt(t,e,r,s,!0));break}}return n},Dt=(t,e,r,n,o)=>{var i,s;const a=[];return t.hasNode(n.v)&&(null===(i=t.getRelatedEdges(n.v,"in"))||void 0===i||i.forEach(n=>{const i=n.data.weight,s=t.getNode(n.source);o&&a.push({v:n.source,w:n.target,in:0,out:0}),void 0===s.data.out&&(s.data.out=0),s.data.out-=i,Bt(e,r,Object.assign({v:s.id},s.data))}),null===(s=t.getRelatedEdges(n.v,"out"))||void 0===s||s.forEach(n=>{const o=n.data.weight,i=n.target,s=t.getNode(i);void 0===s.data.in&&(s.data.in=0),s.data.in-=o,Bt(e,r,Object.assign({v:s.id},s.data))}),t.removeNode(n.v)),o?a:void 0},qt=(t,e)=>{const r=new Ct;let n=0,o=0;t.getAllNodes().forEach(t=>{r.addNode({id:t.id,data:{v:t.id,in:0,out:0}})}),t.getAllEdges().forEach(t=>{const i=r.getRelatedEdges(t.source,"out").find(e=>e.target===t.target),s=(null==e?void 0:e(t))||1;i?r.updateEdgeData(null==i?void 0:i.id,Object.assign(Object.assign({},i.data),{weight:i.data.weight+s})):r.addEdge({id:t.id,source:t.source,target:t.target,data:{weight:s}}),o=Math.max(o,r.getNode(t.source).data.out+=s),n=Math.max(n,r.getNode(t.target).data.in+=s)});const i=[],s=o+n+3;for(let t=0;t<s;t++)i.push(new Pt);const a=n+1;return r.getAllNodes().forEach(t=>{Bt(i,a,Object.assign({v:t.id},r.getNode(t.id).data))}),{buckets:i,zeroIdx:a,graph:r}},Bt=(t,e,r)=>{r.out?r.in?t[r.out-r.in+e].enqueue(r):t[t.length-1].enqueue(r):t[0].enqueue(r)},Vt=(t,e)=>{const r=((t,e)=>{var r;if(t.getAllNodes().length<=1)return[];const n=qt(t,e||Ft);return null===(r=Lt(n.graph,n.buckets,n.zeroIdx).map(e=>t.getRelatedEdges(e.v,"out").filter(({target:t})=>t===e.w)))||void 0===r?void 0:r.flat()})(t,t=>t.data.weight||1);null==r||r.forEach(e=>{const r=e.data;t.removeEdge(e.id),r.forwardName=e.data.name,r.reversed=!0,t.addEdge({id:e.id,source:e.target,target:e.source,data:Object.assign({},r)})})},Ut=(t,e,r,n)=>{let o;do{o=`${n}${Math.random()}`}while(t.hasNode(o));return r.dummy=e,t.addNode({id:o,data:r}),o},$t=t=>{const e=new Ct;return t.getAllNodes().forEach(r=>{t.getChildren(r.id).length||e.addNode(Object.assign({},r))}),t.getAllEdges().forEach(t=>{e.addEdge(t)}),e},Gt=(t,e)=>{const r=Number(t.x),n=Number(t.y),o=Number(e.x)-r,i=Number(e.y)-n;let s,a,u=Number(t.width)/2,c=Number(t.height)/2;return o||i?(Math.abs(i)*u>Math.abs(o)*c?(i<0&&(c=-c),s=c*o/i,a=c):(o<0&&(u=-u),s=u,a=u*i/o),{x:r+s,y:n+a}):{x:0,y:0}},Wt=t=>{const e=[],r=Ht(t)+1;for(let t=0;t<r;t++)e.push([]);t.getAllNodes().forEach(t=>{const r=t.data.rank;void 0!==r&&e[r]&&e[r].push(t.id)});for(let n=0;n<r;n++)e[n]=e[n].sort((e,r)=>{return n=t.getNode(e).data.order,o=t.getNode(r).data.order,Number(n)-Number(o);var n,o});return e},Yt=(t,e,r,n)=>{const o={width:0,height:0};return O(r)&&O(n)&&(o.rank=r,o.order=n),Ut(t,"border",o,e)},Ht=t=>{let e;return t.getAllNodes().forEach(t=>{const r=t.data.rank;void 0!==r&&(void 0===e||r>e)&&(e=r)}),e||(e=0),e},Xt=(t,e)=>t.reduce((t,r)=>e(t)>e(r)?r:t),Qt=(t,e,r,n,o,i)=>{if(!n.includes(e.id)){n.push(e.id),r||i.push(e.id);const s=o(e.id);s&&s.forEach(e=>Qt(t,e,r,n,o,i)),r&&i.push(e.id)}},Kt=(t,e,r,n)=>{const o=Array.isArray(e)?e:[e],i=e=>t.getNeighbors(e),s=[],a=[];return o.forEach(e=>{if(!t.hasNode(e.id))throw new Error(`Graph does not have node: ${e}`);Qt(t,e,"post"===r,a,i,s)}),s},Jt=(t,e,r,n,o,i)=>{const s={rank:i,borderType:e,width:0,height:0},a=i-o.data.minRank,u=o.data[e][a-1],c=Ut(t,"border",s,r);o.data[e][a]=c,t.setParent(c,n),u&&t.addEdge({id:`e${Math.random()}`,source:u,target:c,data:{weight:1}})},Zt=t=>{t.getAllNodes().forEach(t=>{te(t)}),t.getAllEdges().forEach(t=>{te(t)})},te=t=>{const e=t.data.width;t.data.width=t.data.height,t.data.height=e},ee=t=>{t.getAllNodes().forEach(t=>{re(t.data)}),t.getAllEdges().forEach(t=>{var e;null===(e=t.data.points)||void 0===e||e.forEach(t=>re(t)),t.data.hasOwnProperty("y")&&re(t.data)})},re=t=>{(null==t?void 0:t.y)&&(t.y=-t.y)},ne=t=>{t.getAllNodes().forEach(t=>{oe(t.data)}),t.getAllEdges().forEach(t=>{var e;null===(e=t.data.points)||void 0===e||e.forEach(t=>oe(t)),t.data.hasOwnProperty("x")&&oe(t.data)})},oe=t=>{const e=t.x;t.x=t.y,t.y=e},ie=(t,e,r,n,o,i,s)=>{const a=t.getChildren(s);if(!(null==a?void 0:a.length))return void(s!==e&&t.addEdge({id:`e${Math.random()}`,source:e,target:s,data:{weight:0,minlen:r}}));const u=Yt(t,"_bt"),c=Yt(t,"_bb"),h=t.getNode(s);t.setParent(u,s),h.data.borderTop=u,t.setParent(c,s),h.data.borderBottom=c,null==a||a.forEach(a=>{ie(t,e,r,n,o,i,a.id);const h=a.data.borderTop?a.data.borderTop:a.id,l=a.data.borderBottom?a.data.borderBottom:a.id,d=a.data.borderTop?n:2*n,f=h!==l?1:o-i[s]+1;t.addEdge({id:`e${Math.random()}`,source:u,target:h,data:{minlen:f,weight:d,nestingEdge:!0}}),t.addEdge({id:`e${Math.random()}`,source:l,target:c,data:{minlen:f,weight:d,nestingEdge:!0}})}),t.getParent(s)||t.addEdge({id:`e${Math.random()}`,source:e,target:u,data:{weight:0,minlen:o+i[s]}})},se=t=>{const e={},r=(n,o)=>{const i=t.getChildren(n);null==i||i.forEach(t=>r(t.id,o+1)),e[n]=o};return t.getRoots().forEach(t=>r(t.id,1)),e},ae=t=>{let e=0;return t.getAllEdges().forEach(t=>{e+=t.data.weight}),e},ue="edge-label",ce=(t,e,r)=>{let n=e.source,o=t.getNode(n).data.rank;const i=e.target,s=t.getNode(i).data.rank,a=e.data.labelRank;if(s===o+1)return;let u,c,h;for(t.removeEdge(e.id),h=0,++o;o<s;++h,++o)e.data.points=[],c={originalEdge:e,width:0,height:0,rank:o},u=Ut(t,"edge",c,"_d"),o===a&&(c.width=e.data.width,c.height=e.data.height,c.dummy=ue,c.labelpos=e.data.labelpos),t.addEdge({id:`e${Math.random()}`,source:n,target:u,data:{weight:e.data.weight}}),0===h&&r.push(u),n=u;t.addEdge({id:`e${Math.random()}`,source:n,target:i,data:{weight:e.data.weight}})},he=t=>{let e;for(;t.hasNode(e=`_root${Math.random()}`););return e},le=(t,e,r)=>{const n=(o=r,i=r.map((t,e)=>e),null==o?void 0:o.reduce((t,e,r)=>(t[e]=i[r],t),{}));var o,i;const s=e.map(e=>{const r=t.getRelatedEdges(e,"out").map(t=>({pos:n[t.target]||0,weight:t.data.weight}));return null==r?void 0:r.sort((t,e)=>t.pos-e.pos)}),a=s.flat().filter(t=>void 0!==t);let u=1;for(;u<r.length;)u<<=1;const c=2*u-1;u-=1;const h=Array(c).fill(0,0,c);let l=0;return null==a||a.forEach(t=>{if(t){let e=t.pos+u;h[e]+=t.weight;let r=0;for(;e>0;)e%2&&(r+=h[e+1]),e=e-1>>1,h[e]+=t.weight;l+=t.weight*r}}),l},de=(t,e)=>{let r=0;for(let n=1;n<(null==e?void 0:e.length);n+=1)r+=le(t,e[n-1],e[n]);return r},fe=t=>{const e={},r=t.getAllNodes(),n=r.map(t=>{var e;return null!==(e=t.data.rank)&&void 0!==e?e:-1/0}),o=Math.max(...n),i=[];for(let t=0;t<o+1;t++)i.push([]);const s=r.sort((e,r)=>t.getNode(e.id).data.rank-t.getNode(r.id).data.rank),a=s.filter(e=>void 0!==t.getNode(e.id).data.fixorder),u=a.sort((e,r)=>t.getNode(e.id).data.fixorder-t.getNode(r.id).data.fixorder);return null==u||u.forEach(r=>{isNaN(t.getNode(r.id).data.rank)||i[t.getNode(r.id).data.rank].push(r.id),e[r.id]=!0}),null==s||s.forEach(r=>t.dfsTree(r.id,t=>{if(e.hasOwnProperty(t.id))return!0;e[t.id]=!0,isNaN(t.data.rank)||i[t.data.rank].push(t.id)})),i},ge=t=>{var e,r;const n=[];for(;null==t?void 0:t.length;){const o=t.pop();n.push(o),null===(e=o.in.reverse())||void 0===e||e.forEach(t=>{return(e=o,t=>{t.merged||(void 0===t.barycenter||void 0===e.barycenter||t.barycenter>=e.barycenter)&&pe(e,t)})(t);var e}),null===(r=o.out)||void 0===r||r.forEach(e=>{return(r=o,e=>{e.in.push(r),0===--e.indegree&&t.push(e)})(e);var r})}const o=n.filter(t=>!t.merged),i=["vs","i","barycenter","weight"];return o.map(t=>{const e={};return null==i||i.forEach(r=>{void 0!==t[r]&&(e[r]=t[r])}),e})},pe=(t,e)=>{var r;let n=0,o=0;t.weight&&(n+=t.barycenter*t.weight,o+=t.weight),e.weight&&(n+=e.barycenter*e.weight,o+=e.weight),t.vs=null===(r=e.vs)||void 0===r?void 0:r.concat(t.vs),t.barycenter=n/o,t.weight=o,t.i=Math.min(e.i,t.i),e.merged=!0},ve=(t,e,r)=>{let n,o=r;for(;e.length&&(n=e[e.length-1]).i<=o;)e.pop(),null==t||t.push(n.vs),o++;return o},me=(t,e)=>(r,n)=>{if(void 0!==r.fixorder&&void 0!==n.fixorder)return r.fixorder-n.fixorder;if(r.barycenter<n.barycenter)return-1;if(r.barycenter>n.barycenter)return 1;if(e&&void 0!==r.order&&void 0!==n.order){if(r.order<n.order)return-1;if(r.order>n.order)return 1}return t?n.i-r.i:r.i-n.i},ye=(t,e,r,n,o,i)=>{var s,a,u,c;let h=t.getChildren(e).map(t=>t.id);const l=t.getNode(e),d=l?l.data.borderLeft:void 0,f=l?l.data.borderRight:void 0,g={};d&&(h=null==h?void 0:h.filter(t=>t!==d&&t!==f));const p=((t,e)=>e.map(e=>{const r=t.getRelatedEdges(e,"in");if(!(null==r?void 0:r.length))return{v:e};const n={sum:0,weight:0};return null==r||r.forEach(e=>{const r=t.getNode(e.source);n.sum+=e.data.weight*r.data.order,n.weight+=e.data.weight}),{v:e,barycenter:n.sum/n.weight,weight:n.weight}}))(t,h||[]);null==p||p.forEach(e=>{var o;if(null===(o=t.getChildren(e.v))||void 0===o?void 0:o.length){const o=ye(t,e.v,r,n,i);g[e.v]=o,o.hasOwnProperty("barycenter")&&xe(e,o)}});const v=((t,e)=>{var r,n,o;const i={};null==t||t.forEach((t,e)=>{i[t.v]={i:e,indegree:0,in:[],out:[],vs:[t.v]};const r=i[t.v];void 0!==t.barycenter&&(r.barycenter=t.barycenter,r.weight=t.weight)}),null===(r=e.getAllEdges())||void 0===r||r.forEach(t=>{const e=i[t.source],r=i[t.target];void 0!==e&&void 0!==r&&(r.indegree++,e.out.push(i[t.target]))});const s=null===(o=(n=Object.values(i)).filter)||void 0===o?void 0:o.call(n,t=>!t.indegree);return ge(s)})(p,r);we(v,g),null===(s=v.filter(t=>t.vs.length>0))||void 0===s||s.forEach(e=>{const r=t.getNode(e.vs[0]);r&&(e.fixorder=r.data.fixorder,e.order=r.data.order)});const m=((t,e,r,n)=>{const o=((t,e)=>{const r={lhs:[],rhs:[]};return null==t||t.forEach(t=>{e(t)?r.lhs.push(t):r.rhs.push(t)}),r})(t,t=>{const e=t.hasOwnProperty("fixorder")&&!isNaN(t.fixorder);return n?!e&&t.hasOwnProperty("barycenter"):e||t.hasOwnProperty("barycenter")}),i=o.lhs,s=o.rhs.sort((t,e)=>-t.i- -e.i),a=[];let u=0,c=0,h=0;null==i||i.sort(me(!!e,!!r)),h=ve(a,s,h),null==i||i.forEach(t=>{var e;h+=null===(e=t.vs)||void 0===e?void 0:e.length,a.push(t.vs),u+=t.barycenter*t.weight,c+=t.weight,h=ve(a,s,h)});const l={vs:a.flat()};return c&&(l.barycenter=u/c,l.weight=c),l})(v,n,o,i);if(d&&(m.vs=[d,m.vs,f].flat(),null===(a=t.getPredecessors(d))||void 0===a?void 0:a.length)){const e=t.getNode((null===(u=t.getPredecessors(d))||void 0===u?void 0:u[0].id)||""),r=t.getNode((null===(c=t.getPredecessors(f))||void 0===c?void 0:c[0].id)||"");m.hasOwnProperty("barycenter")||(m.barycenter=0,m.weight=0),m.barycenter=(m.barycenter*m.weight+e.data.order+r.data.order)/(m.weight+2),m.weight+=2}return m},we=(t,e)=>{null==t||t.forEach(t=>{var r;const n=null===(r=t.vs)||void 0===r?void 0:r.map(t=>e[t]?e[t].vs:t);t.vs=n.flat()})},xe=(t,e)=>{void 0!==t.barycenter?(t.barycenter=(t.barycenter*t.weight+e.barycenter*e.weight)/(t.weight+e.weight),t.weight+=e.weight):(t.barycenter=e.barycenter,t.weight=e.weight)},be=(t,e,r)=>e.map(e=>((t,e,r)=>{const n=he(t),o=new Ct;return o.addNode({id:n,data:{}}),t.getAllNodes().forEach(i=>{var s,a;const u=t.getParent(i.id);(i.data.rank===e||i.data.minRank<=e&&e<=i.data.maxRank)&&(o.hasNode(i.id)||o.addNode(Object.assign({},i)),(null==u?void 0:u.id)&&!o.hasNode(null==u?void 0:u.id)&&o.addNode(Object.assign({},u)),o.setParent(i.id,(null==u?void 0:u.id)||n),t.getRelatedEdges(i.id,r).forEach(e=>{const r=e.source===i.id?e.target:e.source;o.hasNode(r)||o.addNode(Object.assign({},t.getNode(r)));const n=o.getRelatedEdges(r,"out").find(({target:t})=>t===i.id),s=void 0!==n?n.data.weight:0;n?o.updateEdgeData(n.id,Object.assign(Object.assign({},n.data),{weight:e.data.weight+s})):o.addEdge({id:e.id,source:r,target:i.id,data:{weight:e.data.weight+s}})}),i.data.hasOwnProperty("minRank")&&o.updateNodeData(i.id,Object.assign(Object.assign({},i.data),{borderLeft:[null===(s=i.data.borderLeft)||void 0===s?void 0:s[e-i.data.minRank]],borderRight:[null===(a=i.data.borderRight)||void 0===a?void 0:a[e-i.data.minRank]]})))}),o})(t,e,r)),Ee=(t,e,r,n)=>{const o=new Ct;null==t||t.forEach(t=>{var i;const s=t.getRoots()[0].id,a=ye(t,s,o,e,r,n);for(let e=0;e<(null===(i=a.vs)||void 0===i?void 0:i.length);e++){const r=t.getNode(a.vs[e]);r&&(r.data.order=e)}((t,e,r)=>{const n={};let o;null==r||r.forEach(r=>{let i,s,a=t.getParent(r);for(;a;){if(i=t.getParent(a.id),i?(s=n[i.id],n[i.id]=a.id):(s=o,o=a.id),s&&s!==a.id)return e.hasNode(s)||e.addNode({id:s,data:{}}),e.hasNode(a.id)||e.addNode({id:a.id,data:{}}),void(e.hasEdge(`e${s}-${a.id}`)||e.addEdge({id:`e${s}-${a.id}`,source:s,target:a.id,data:{}}));a=i}})})(t,o,a.vs)})},Me=(t,e)=>{null==e||e.forEach(e=>{null==e||e.forEach((e,r)=>{t.getNode(e).data.order=r})})},Ne=(t,e)=>{const r=(t=>{const e={};let r=0;const n=o=>{const i=r;t.getChildren(o).forEach(t=>n(t.id)),e[o]={low:i,lim:r++}};return t.getRoots().forEach(t=>n(t.id)),e})(t);e.forEach(e=>{var n,o;let i=e,s=t.getNode(i);const a=s.data.originalEdge;if(!a)return;const u=((t,e,r,n)=>{var o,i;const s=[],a=[],u=Math.min(e[r].low,e[n].low),c=Math.max(e[r].lim,e[n].lim);let h,l;h=r;do{h=null===(o=t.getParent(h))||void 0===o?void 0:o.id,s.push(h)}while(h&&(e[h].low>u||c>e[h].lim));for(l=h,h=n;h&&h!==l;)a.push(h),h=null===(i=t.getParent(h))||void 0===i?void 0:i.id;return{lca:l,path:s.concat(a.reverse())}})(t,r,a.source,a.target),c=u.path,h=u.lca;let l=0,d=c[l],f=!0;for(;i!==a.target;){if(s=t.getNode(i),f){for(;d!==h&&(null===(n=t.getNode(d))||void 0===n?void 0:n.data.maxRank)<s.data.rank;)l++,d=c[l];d===h&&(f=!1)}if(!f){for(;l<c.length-1&&(null===(o=t.getNode(c[l+1]))||void 0===o?void 0:o.data.minRank)<=s.data.rank;)l++;d=c[l]}t.hasNode(d)&&t.setParent(i,d),i=t.getSuccessors(i)[0].id}})},_e=(t,e)=>{const r={};function n(e,n){const o=function(t){return JSON.stringify(t.slice(1))}(e);n.get(o)||(!function(e,n,o,i,s){var a,u;let c;for(let h=n;h<o;h++)c=e[h],(null===(a=t.getNode(c))||void 0===a?void 0:a.data.dummy)&&(null===(u=t.getPredecessors(c))||void 0===u||u.forEach(e=>{const n=t.getNode(e.id);n.data.dummy&&(n.data.order<i||n.data.order>s)&&Se(r,e.id,c)}))}(...e),n.set(o,!0))}const o=(e,r)=>{let o,i=-1,s=0;const a=new Map;return null==r||r.forEach((u,c)=>{var h;if("border"===(null===(h=t.getNode(u))||void 0===h?void 0:h.data.dummy)){const e=t.getPredecessors(u)||[];e.length&&(o=t.getNode(e[0].id).data.order,n([r,s,c,i,o],a),s=c,i=o)}n([r,s,r.length,o,e.length],a)}),r};return(null==e?void 0:e.length)&&e.reduce(o),r},ke=(t,e)=>{var r,n;if(null===(r=t.getNode(e))||void 0===r?void 0:r.data.dummy)return null===(n=t.getPredecessors(e))||void 0===n?void 0:n.find(e=>t.getNode(e.id).data.dummy)},Se=(t,e,r)=>{let n=e,o=r;if(n>o){const t=n;n=o,o=t}let i=t[n];i||(t[n]=i={}),i[o]=!0},Ae=(t,e,r)=>{let n=e,o=r;if(n>r){n=r,o=e}return!!t[n]},Oe=(t,e,r,n,o,i)=>{const s=new Ct,a=ze(n,o,i);return null==e||e.forEach(e=>{let n;null==e||e.forEach(e=>{const o=r[e];if(s.hasNode(o)||s.addNode({id:o,data:{}}),n){const i=r[n],u=s.getRelatedEdges(i,"out").find(t=>t.target===o);u?s.updateEdgeData(u.id,Object.assign(Object.assign({},u.data),{weight:Math.max(a(t,e,n),u.data.weight||0)})):s.addEdge({id:`e${Math.random()}`,source:i,target:o,data:{weight:Math.max(a(t,e,n),0)}})}n=e})}),s};const ze=(t,e,r)=>(n,o,i)=>{const s=n.getNode(o),a=n.getNode(i);let u=0,c=0;if(u+=s.data.width/2,s.data.hasOwnProperty("labelpos"))switch((s.data.labelpos||"").toLowerCase()){case"l":c=-s.data.width/2;break;case"r":c=s.data.width/2}if(c&&(u+=r?c:-c),c=0,u+=(s.data.dummy?e:t)/2,u+=(a.data.dummy?e:t)/2,u+=a.data.width/2,a.data.labelpos)switch((a.data.labelpos||"").toLowerCase()){case"l":c=a.data.width/2;break;case"r":c=-a.data.width/2}return c&&(u+=r?c:-c),c=0,u},je=(t,e)=>t.getNode(e).data.width||0,Ce=(t,e)=>{const{align:r,nodesep:n=0,edgesep:o=0}=e||{},i=Wt(t),s=Object.assign(((t,e)=>{const r={},n=(e,n)=>{let o=0,i=0;const s=e.length,a=null==n?void 0:n[(null==n?void 0:n.length)-1];return null==n||n.forEach((e,u)=>{var c;const h=ke(t,e),l=h?t.getNode(h.id).data.order:s;(h||e===a)&&(null===(c=n.slice(i,u+1))||void 0===c||c.forEach(e=>{var n;null===(n=t.getPredecessors(e))||void 0===n||n.forEach(n=>{var i;const s=t.getNode(n.id),a=s.data.order;!(a<o||l<a)||s.data.dummy&&(null===(i=t.getNode(e))||void 0===i?void 0:i.data.dummy)||Se(r,n.id,e)})}),i=u+1,o=l)}),n};return(null==e?void 0:e.length)&&e.reduce(n),r})(t,i),_e(t,i)),a={};let u=[];["u","d"].forEach(e=>{u="u"===e?i:Object.values(i).reverse(),["l","r"].forEach(r=>{"r"===r&&(u=u.map(t=>Object.values(t).reverse()));const i=("u"===e?t.getPredecessors:t.getSuccessors).bind(t),c=((t,e,r,n)=>{const o={},i={},s={};return null==e||e.forEach(t=>{null==t||t.forEach((t,e)=>{o[t]=t,i[t]=t,s[t]=e})}),null==e||e.forEach(t=>{let e=-1;null==t||t.forEach(t=>{let a=n(t).map(t=>t.id);if(a.length){a=a.sort((t,e)=>s[t]-s[e]);const n=(a.length-1)/2;for(let u=Math.floor(n),c=Math.ceil(n);u<=c;++u){const n=a[u];i[t]===t&&e<s[n]&&!Ae(r,t,n)&&(i[n]=t,i[t]=o[t]=o[n],e=s[n])}}})}),{root:o,align:i}})(0,u,s,i),h=((t,e,r,n,o,i,s)=>{var a;const u={},c=Oe(t,e,r,o,i,s),h=s?"borderLeft":"borderRight",l=(t,e)=>{let r=c.getAllNodes(),n=r.pop();const o={};for(;n;)o[n.id]?t(n.id):(o[n.id]=!0,r.push(n),r=r.concat(e(n.id))),n=r.pop()};return l(t=>{u[t]=(c.getRelatedEdges(t,"in")||[]).reduce((t,e)=>Math.max(t,(u[e.source]||0)+e.data.weight),0)},c.getPredecessors.bind(c)),l(e=>{const r=(c.getRelatedEdges(e,"out")||[]).reduce((t,e)=>Math.min(t,(u[e.target]||0)-e.data.weight),Number.POSITIVE_INFINITY),n=t.getNode(e);r!==Number.POSITIVE_INFINITY&&n.data.borderType!==h&&(u[e]=Math.max(u[e],r))},c.getSuccessors.bind(c)),null===(a=Object.values(n))||void 0===a||a.forEach(t=>{u[t]=u[r[t]]}),u})(t,u,c.root,c.align,n,o,"r"===r);"r"===r&&Object.keys(h).forEach(t=>h[t]=-h[t]),a[e+r]=h})});const c=((t,e)=>Xt(Object.values(e),e=>{var r;let n=Number.NEGATIVE_INFINITY,o=Number.POSITIVE_INFINITY;return null===(r=Object.keys(e))||void 0===r||r.forEach(r=>{const i=e[r],s=je(t,r)/2;n=Math.max(i+s,n),o=Math.min(i-s,o)}),n-o}))(t,a);return c&&function(t,e){const r=Object.values(e),n=Math.min(...r),o=Math.max(...r);["u","d"].forEach(r=>{["l","r"].forEach(i=>{const s=r+i,a=t[s];let u;if(a===e)return;const c=Object.values(a);u="l"===i?n-Math.min(...c):o-Math.max(...c),u&&(t[s]={},Object.keys(a).forEach(e=>{t[s][e]=a[e]+u}))})})}(a,c),((t,e)=>{const r={};return Object.keys(t.ul).forEach(n=>{if(e)r[n]=t[e.toLowerCase()][n];else{const e=Object.values(t).map(t=>t[n]);r[n]=(e[0]+e[1])/2}}),r})(a,r)},Ie=(t,e)=>{var r;const n=$t(t);((t,e)=>{const{ranksep:r=0}=e||{},n=Wt(t);let o=0;null==n||n.forEach(e=>{const n=e.map(e=>t.getNode(e).data.height),i=Math.max(...n,0);null==e||e.forEach(e=>{t.getNode(e).data.y=o+i/2}),o+=i+r})})(n,e);const o=Ce(n,e);null===(r=Object.keys(o))||void 0===r||r.forEach(t=>{n.getNode(t).data.x=o[t]})},Re=t=>{const e={},r=n=>{var o;const i=t.getNode(n);if(!i)return 0;if(e[n])return i.data.rank;let s;return e[n]=!0,null===(o=t.getRelatedEdges(n,"out"))||void 0===o||o.forEach(t=>{const e=r(t.target)-t.data.minlen;e&&(void 0===s||e<s)&&(s=e)}),s||(s=0),i.data.rank=s,s};t.getAllNodes().filter(e=>0===t.getRelatedEdges(e.id,"in").length).forEach(t=>r(t.id))},Te=(t,e)=>t.getNode(e.target).data.rank-t.getNode(e.source).data.rank-e.data.minlen,Pe=(t,e)=>{const r=n=>{e.getRelatedEdges(n,"both").forEach(o=>{const i=o.source,s=n===i?o.target:i;t.hasNode(s)||Te(e,o)||(t.addNode({id:s,data:{}}),t.addEdge({id:o.id,source:n,target:s,data:{}}),r(s))})};return t.getAllNodes().forEach(t=>r(t.id)),t.getAllNodes().length},Fe=(t,e)=>{const r=n=>{var o;null===(o=e.getRelatedEdges(n,"both"))||void 0===o||o.forEach(o=>{const i=o.source,s=n===i?o.target:i;t.hasNode(s)||void 0===e.getNode(s).data.layer&&Te(e,o)||(t.addNode({id:s,data:{}}),t.addEdge({id:o.id,source:n,target:s,data:{}}),r(s))})};return t.getAllNodes().forEach(t=>r(t.id)),t.getAllNodes().length},Le=(t,e)=>Xt(e.getAllEdges(),r=>t.hasNode(r.source)!==t.hasNode(r.target)?Te(e,r):1/0),De=(t,e,r)=>{t.getAllNodes().forEach(t=>{const n=e.getNode(t.id);n.data.rank||(n.data.rank=0),n.data.rank+=r})},qe=t=>{const e=(t=>{const e=new Ct;return t.getAllNodes().forEach(t=>{e.addNode(Object.assign({},t))}),t.getAllEdges().forEach(t=>{const r=e.getRelatedEdges(t.source,"out").find(e=>e.target===t.target);r?e.updateEdgeData(null==r?void 0:r.id,Object.assign(Object.assign({},r.data),{weight:r.data.weight+t.data.weight||0,minlen:Math.max(r.data.minlen,t.data.minlen||1)})):e.addEdge({id:t.id,source:t.source,target:t.target,data:{weight:t.data.weight||0,minlen:t.data.minlen||1}})}),e})(t);Re(e);const r=(t=>{const e=new Ct({tree:[]}),r=t.getAllNodes()[0],n=t.getAllNodes().length;let o,i;for(e.addNode(r);Pe(e,t)<n;)o=Le(e,t),i=e.hasNode(o.source)?Te(t,o):-Te(t,o),De(e,t,i);return e})(e);let n,o;for($e(r),Be(r,e);n=We(r);)o=Ye(r,e,n),He(r,e,n,o)},Be=(t,e)=>{let r=Kt(t,t.getAllNodes(),"post");r=r.slice(0,(null==r?void 0:r.length)-1),r.forEach(r=>{Ve(t,e,r)})},Ve=(t,e,r)=>{const n=t.getNode(r).data.parent,o=t.getRelatedEdges(r,"both").find(t=>t.target===n||t.source===n);o.data.cutvalue=Ue(t,e,r)},Ue=(t,e,r)=>{const n=t.getNode(r).data.parent;let o=!0,i=e.getRelatedEdges(r,"out").find(t=>t.target===n),s=0;return i||(o=!1,i=e.getRelatedEdges(n,"out").find(t=>t.target===r)),s=i.data.weight,e.getRelatedEdges(r,"both").forEach(e=>{const i=e.source===r,a=i?e.target:e.source;if(a!==n){const n=i===o,u=e.data.weight;if(s+=n?u:-u,Qe(t,r,a)){const e=t.getRelatedEdges(r,"both").find(t=>t.source===a||t.target===a).data.cutvalue;s+=n?-e:e}}}),s},$e=(t,e=t.getAllNodes()[0].id)=>{Ge(t,{},1,e)},Ge=(t,e,r,n,o)=>{var i;const s=r;let a=r;const u=t.getNode(n);return e[n]=!0,null===(i=t.getNeighbors(n))||void 0===i||i.forEach(r=>{e[r.id]||(a=Ge(t,e,a,r.id,n))}),u.data.low=s,u.data.lim=a++,o?u.data.parent=o:delete u.data.parent,a},We=t=>t.getAllEdges().find(t=>t.data.cutvalue<0),Ye=(t,e,r)=>{let n=r.source,o=r.target;e.getRelatedEdges(n,"out").find(t=>t.target===o)||(n=r.target,o=r.source);const i=t.getNode(n),s=t.getNode(o);let a=i,u=!1;i.data.lim>s.data.lim&&(a=s,u=!0);const c=e.getAllEdges().filter(e=>u===Ke(t.getNode(e.source),a)&&u!==Ke(t.getNode(e.target),a));return Xt(c,t=>Te(e,t))},He=(t,e,r,n)=>{const o=t.getRelatedEdges(r.source,"both").find(t=>t.source===r.target||t.target===r.target);o&&t.removeEdge(o.id),t.addEdge({id:`e${Math.random()}`,source:n.source,target:n.target,data:{}}),$e(t),Be(t,e),Xe(t,e)},Xe=(t,e)=>{const r=t.getAllNodes().find(t=>!t.data.parent);let n=Kt(t,r,"pre");n=n.slice(1),n.forEach(r=>{const n=t.getNode(r).data.parent;let o=e.getRelatedEdges(r,"out").find(t=>t.target===n),i=!1;!o&&e.hasNode(n)&&(o=e.getRelatedEdges(n,"out").find(t=>t.target===r),i=!0),e.getNode(r).data.rank=(e.hasNode(n)&&e.getNode(n).data.rank||0)+(i?null==o?void 0:o.data.minlen:-(null==o?void 0:o.data.minlen))})},Qe=(t,e,r)=>t.getRelatedEdges(e,"both").find(t=>t.source===r||t.target===r),Ke=(t,e)=>e.data.low<=t.data.lim&&t.data.lim<=e.data.lim,Je=Re,Ze=t=>{(t=>{const e={};let r;const n=o=>{var i;const s=t.getNode(o);if(!s)return 0;if(e[o])return s.data.rank;let a;return e[o]=!0,null===(i=t.getRelatedEdges(o,"out"))||void 0===i||i.forEach(t=>{const e=n(t.target)-t.data.minlen;e&&(void 0===a||e<a)&&(a=e)}),a||(a=0),(void 0===r||a<r)&&(r=a),s.data.rank=a,a};t.getAllNodes().filter(e=>0===t.getRelatedEdges(e.id,"in").length).forEach(t=>{t&&n(t.id)}),void 0===r&&(r=0);const o={},i=(e,r)=>{var n;const s=t.getNode(e),a=isNaN(s.data.layer)?r:s.data.layer;(void 0===s.data.rank||s.data.rank<a)&&(s.data.rank=a),o[e]||(o[e]=!0,null===(n=t.getRelatedEdges(e,"out"))||void 0===n||n.forEach(t=>{i(t.target,a+t.data.minlen)}))};t.getAllNodes().forEach(t=>{const e=t.data;e&&(isNaN(e.layer)?e.rank-=r:i(t.id,e.layer))})})(t),(t=>{const e=new Ct({tree:[]}),r=t.getAllNodes()[0],n=t.getAllNodes().length;let o,i;for(e.addNode(r);Fe(e,t)<n;)o=Le(e,t),i=e.hasNode(o.source)?Te(t,o):-Te(t,o),De(e,t,i)})(t)},tr=t=>{qe(t)},er=(t,e)=>{const{ranker:r,rankdir:n="tb",nodeOrder:o,keepNodeOrder:i,align:s,nodesep:a=50,edgesep:u=20,ranksep:c=50}=e;wr(t),Vt(t);const{nestingRoot:h,nodeRankFactor:l}=(t=>{const e=Ut(t,"root",{},"_root"),r=se(t);let n=Math.max(...Object.values(r));Math.abs(n)===1/0&&(n=1);const o=n-1,i=2*o+1;t.getAllEdges().forEach(t=>{t.data.minlen*=i});const s=ae(t)+1;return t.getRoots().forEach(n=>{ie(t,e,i,s,o,r,n.id)}),{nestingRoot:e,nodeRankFactor:i}})(t);((t,e)=>{switch(e){case"network-simplex":tr(t);break;case"tight-tree":default:Ze(t);break;case"longest-path":Je(t)}})($t(t),r),lr(t),((t,e=0)=>{const r=t.getAllNodes(),n=r.filter(t=>void 0!==t.data.rank).map(t=>t.data.rank),o=Math.min(...n),i=[];r.forEach(t=>{const e=(t.data.rank||0)-o;i[e]||(i[e]=[]),i[e].push(t.id)});let s=0;for(let r=0;r<i.length;r++){const n=i[r];void 0===n?r%e!==0&&(s-=1):s&&(null==n||n.forEach(e=>{const r=t.getNode(e);r&&(r.data.rank=r.data.rank||0,r.data.rank+=s)}))}})(t,l),((t,e)=>{e&&t.removeNode(e),t.getAllEdges().forEach(e=>{e.data.nestingEdge&&t.removeEdge(e.id)})})(t,h),(t=>{const e=t.getAllNodes().filter(t=>void 0!==t.data.rank).map(t=>t.data.rank),r=Math.min(...e);t.getAllNodes().forEach(t=>{t.data.hasOwnProperty("rank")&&r!==1/0&&(t.data.rank-=r)})})(t),dr(t),fr(t);const d=[];((t,e)=>{t.getAllEdges().forEach(r=>ce(t,r,e))})(t,d),Ne(t,d),(t=>{const e=r=>{const n=t.getChildren(r),o=t.getNode(r);if((null==n?void 0:n.length)&&n.forEach(t=>e(t.id)),o.data.hasOwnProperty("minRank")){o.data.borderLeft=[],o.data.borderRight=[];for(let e=o.data.minRank,n=o.data.maxRank+1;e<n;e+=1)Jt(t,"borderLeft","_bl",r,o,e),Jt(t,"borderRight","_br",r,o,e)}};t.getRoots().forEach(t=>e(t.id))})(t),i&&((t,e)=>{const r=t.getAllNodes().filter(e=>{var r;return!(null===(r=t.getChildren(e.id))||void 0===r?void 0:r.length)}).map(t=>t.data.rank),n=Math.max(...r),o=[];for(let t=0;t<n+1;t++)o[t]=[];null==e||e.forEach(e=>{const r=t.getNode(e);r&&!r.data.dummy&&(isNaN(r.data.rank)||(r.data.fixorder=o[r.data.rank].length,o[r.data.rank].push(e)))})})(t,o),((t,e)=>{const r=Ht(t),n=[],o=[];for(let t=1;t<r+1;t++)n.push(t);for(let t=r-1;t>-1;t--)o.push(t);const i=be(t,n,"in"),s=be(t,o,"out");let a=fe(t);Me(t,a);let u,c=Number.POSITIVE_INFINITY;for(let r=0,n=0;n<4;++r,++n){Ee(r%2?i:s,r%4>=2,!1,e),a=Wt(t);const o=de(t,a);o<c&&(n=0,u=C(a),c=o)}a=fe(t),Me(t,a);for(let r=0,n=0;n<4;++r,++n){Ee(r%2?i:s,r%4>=2,!0,e),a=Wt(t);const o=de(t,a);o<c&&(n=0,u=C(a),c=o)}Me(t,u)})(t,i),xr(t),((t,e)=>{const r=e.toLowerCase();"lr"!==r&&"rl"!==r||Zt(t)})(t,n),Ie(t,{align:s,nodesep:a,edgesep:u,ranksep:c}),br(t),yr(t),((t,e)=>{e.forEach(e=>{let r=t.getNode(e);const{data:n}=r,o=n.originalEdge;let i;o&&t.addEdge(o);let s=e;for(;r.data.dummy;)i=t.getSuccessors(s)[0],t.removeNode(s),o.data.points.push({x:r.data.x,y:r.data.y}),r.data.dummy===ue&&(o.data.x=r.data.x,o.data.y=r.data.y,o.data.width=r.data.width,o.data.height=r.data.height),s=i.id,r=t.getNode(s)})})(t,d),vr(t),((t,e)=>{const r=e.toLowerCase();"bt"!==r&&"rl"!==r||ee(t),"lr"!==r&&"rl"!==r||(ne(t),Zt(t))})(t,n);const{width:f,height:g}=gr(t);return pr(t),mr(t),(t=>{t.getAllEdges().forEach(e=>{const r=e.data;if(r.reversed){t.removeEdge(e.id);const n=r.forwardName;delete r.reversed,delete r.forwardName,t.addEdge({id:e.id,source:e.target,target:e.source,data:Object.assign(Object.assign({},r),{forwardName:n})})}})})(t),{width:f,height:g}},rr=(t,e)=>{t.getAllNodes().forEach(r=>{const n=t.getNode(r.id);if(e.hasNode(r.id)){const t=e.getNode(r.id);n.data.fixorder=t.data._order,delete t.data._order}else delete n.data.fixorder})},nr=(t,e)=>{t.getAllNodes().forEach(r=>{var n;const o=t.getNode(r.id);if(o){const t=e.getNode(r.id);o.data.x=t.data.x,o.data.y=t.data.y,o.data._order=t.data.order,o.data._rank=t.data.rank,(null===(n=e.getChildren(r.id))||void 0===n?void 0:n.length)&&(o.data.width=t.data.width,o.data.height=t.data.height)}}),t.getAllEdges().forEach(r=>{const n=t.getEdge(r.id),o=e.getEdge(r.id);n.data.points=o?o.data.points:[],o&&o.data.hasOwnProperty("x")&&(n.data.x=o.data.x,n.data.y=o.data.y)})},or=["width","height","layer","fixorder"],ir={width:0,height:0},sr=["minlen","weight","width","height","labeloffset"],ar={minlen:1,weight:1,width:0,height:0,labeloffset:10,labelpos:"r"},ur=["labelpos"],cr=t=>{const e=new Ct({tree:[]});return t.getAllNodes().forEach(r=>{const n=Mr(t.getNode(r.id).data),o=Object.assign(Object.assign({},ir),n),i=Er(o,or);e.hasNode(r.id)||e.addNode({id:r.id,data:Object.assign({},i)});const s=t.hasTreeStructure("combo")?t.getParent(r.id,"combo"):t.getParent(r.id);M(s)||(e.hasNode(s.id)||e.addNode(Object.assign({},s)),e.setParent(r.id,s.id))}),t.getAllEdges().forEach(r=>{const n=Mr(t.getEdge(r.id).data),o={};null==ur||ur.forEach(t=>{void 0!==n[t]&&(o[t]=n[t])}),e.addEdge({id:r.id,source:r.source,target:r.target,data:Object.assign({},ar,Er(n,sr),o)})}),e},hr=(t,e)=>{const{ranksep:r=0,rankdir:n}=e;return t.getAllNodes().forEach(t=>{isNaN(t.data.layer)||t.data.layer||(t.data.layer=0)}),t.getAllEdges().forEach(t=>{var e;t.data.minlen*=2,"c"!==(null===(e=t.data.labelpos)||void 0===e?void 0:e.toLowerCase())&&("TB"===n||"BT"===n?t.data.width+=t.data.labeloffset:t.data.height+=t.data.labeloffset)}),r/2},lr=t=>{t.getAllEdges().forEach(e=>{if(e.data.width&&e.data.height){const r=t.getNode(e.source),n={e:e,rank:(t.getNode(e.target).data.rank-r.data.rank)/2+r.data.rank};Ut(t,"edge-proxy",n,"_ep")}})},dr=t=>{let e=0;return t.getAllNodes().forEach(r=>{var n,o;r.data.borderTop&&(r.data.minRank=null===(n=t.getNode(r.data.borderTop))||void 0===n?void 0:n.data.rank,r.data.maxRank=null===(o=t.getNode(r.data.borderBottom))||void 0===o?void 0:o.data.rank,e=Math.max(e,r.data.maxRank||-1/0))}),e},fr=t=>{t.getAllNodes().forEach(e=>{"edge-proxy"===e.data.dummy&&(t.getEdge(e.data.e.id).data.labelRank=e.data.rank,t.removeNode(e.id))})},gr=(t,e)=>{let r,n,o=0,i=0;const{marginx:s=0,marginy:a=0}={},u=t=>{if(!t.data)return;const e=t.data.x,s=t.data.y,a=t.data.width,u=t.data.height;isNaN(e)||isNaN(a)||(void 0===r&&(r=e-a/2),r=Math.min(r,e-a/2),o=Math.max(o,e+a/2)),isNaN(s)||isNaN(u)||(void 0===n&&(n=s-u/2),n=Math.min(n,s-u/2),i=Math.max(i,s+u/2))};return t.getAllNodes().forEach(t=>{u(t)}),t.getAllEdges().forEach(t=>{(null==t?void 0:t.data.hasOwnProperty("x"))&&u(t)}),r-=s,n-=a,t.getAllNodes().forEach(t=>{t.data.x-=r,t.data.y-=n}),t.getAllEdges().forEach(t=>{var e;null===(e=t.data.points)||void 0===e||e.forEach(t=>{t.x-=r,t.y-=n}),t.data.hasOwnProperty("x")&&(t.data.x-=r),t.data.hasOwnProperty("y")&&(t.data.y-=n)}),{width:o-r+s,height:i-n+a}},pr=t=>{t.getAllEdges().forEach(e=>{const r=t.getNode(e.source),n=t.getNode(e.target);let o,i;e.data.points?(o=e.data.points[0],i=e.data.points[e.data.points.length-1]):(e.data.points=[],o={x:n.data.x,y:n.data.y},i={x:r.data.x,y:r.data.y}),e.data.points.unshift(Gt(r.data,o)),e.data.points.push(Gt(n.data,i))})},vr=t=>{t.getAllEdges().forEach(t=>{if(t.data.hasOwnProperty("x"))switch("l"!==t.data.labelpos&&"r"!==t.data.labelpos||(t.data.width-=t.data.labeloffset),t.data.labelpos){case"l":t.data.x-=t.data.width/2+t.data.labeloffset;break;case"r":t.data.x+=t.data.width/2+t.data.labeloffset}})},mr=t=>{t.getAllEdges().forEach(t=>{var e;t.data.reversed&&(null===(e=t.data.points)||void 0===e||e.reverse())})},yr=t=>{t.getAllNodes().forEach(e=>{var r,n,o;if(null===(r=t.getChildren(e.id))||void 0===r?void 0:r.length){const r=t.getNode(e.id),i=t.getNode(r.data.borderTop),s=t.getNode(r.data.borderBottom),a=t.getNode(r.data.borderLeft[(null===(n=r.data.borderLeft)||void 0===n?void 0:n.length)-1]),u=t.getNode(r.data.borderRight[(null===(o=r.data.borderRight)||void 0===o?void 0:o.length)-1]);r.data.width=Math.abs((null==u?void 0:u.data.x)-(null==a?void 0:a.data.x))||10,r.data.height=Math.abs((null==s?void 0:s.data.y)-(null==i?void 0:i.data.y))||10,r.data.x=((null==a?void 0:a.data.x)||0)+r.data.width/2,r.data.y=((null==i?void 0:i.data.y)||0)+r.data.height/2}}),t.getAllNodes().forEach(e=>{"border"===e.data.dummy&&t.removeNode(e.id)})},wr=t=>{t.getAllEdges().forEach(e=>{if(e.source===e.target){const r=t.getNode(e.source);r.data.selfEdges||(r.data.selfEdges=[]),r.data.selfEdges.push(e),t.removeEdge(e.id)}})},xr=t=>{const e=Wt(t);null==e||e.forEach(e=>{let r=0;null==e||e.forEach((e,n)=>{var o;const i=t.getNode(e);i.data.order=n+r,null===(o=i.data.selfEdges)||void 0===o||o.forEach(e=>{Ut(t,"selfedge",{width:e.data.width,height:e.data.height,rank:i.data.rank,order:n+ ++r,e:e},"_se")}),delete i.data.selfEdges})})},br=t=>{t.getAllNodes().forEach(e=>{const r=t.getNode(e.id);if("selfedge"===r.data.dummy){const n=t.getNode(r.data.e.source),o=n.data.x+n.data.width/2,i=n.data.y,s=r.data.x-o,a=n.data.height/2;t.hasEdge(r.data.e.id)?t.updateEdgeData(r.data.e.id,r.data.e.data):t.addEdge({id:r.data.e.id,source:r.data.e.source,target:r.data.e.target,data:r.data.e.data}),t.removeNode(e.id),r.data.e.data.points=[{x:o+2*s/3,y:i-a},{x:o+5*s/6,y:i-a},{y:i,x:o+s},{x:o+5*s/6,y:i+a},{x:o+2*s/3,y:i+a}],r.data.e.data.x=r.data.x,r.data.e.data.y=r.data.y}})},Er=(t,e)=>{const r={};return null==e||e.forEach(e=>{void 0!==t[e]&&(r[e]=+t[e])}),r},Mr=(t={})=>{const e={};return Object.keys(t).forEach(r=>{e[r.toLowerCase()]=t[r]}),e},Nr={nodeSize:10,nodeSpacing:0,rankdir:"TB",nodesep:50,ranksep:50,edgeLabelSpace:!0,ranker:"tight-tree",controlPoints:!1,radial:!1,focusNode:null};const _r=(t,e,r,n,o,i,s)=>{let a=(null==t?void 0:t.slice(1,t.length-1))||[];if(e&&r){let{x:t,y:u}=e.data,{x:c,y:h}=r.data;if(o&&(t=e.data.y,u=e.data.x,c=r.data.y,h=r.data.x),h!==u&&t!==c){const l=n.indexOf(u),d=n[l+1];if(d){const t=a[0],e=o?{x:(u+d)/2,y:(null==t?void 0:t.y)||c}:{x:(null==t?void 0:t.x)||c,y:(u+d)/2};t&&!i(t,e)||a.unshift(e)}const f=n.indexOf(h),g=Math.abs(f-l);if(1===g)a=s(a,e.data,r.data),a.length||a.push(o?{x:(u+h)/2,y:t}:{x:t,y:(u+h)/2});else if(g>1){const e=n[f-1];if(e){const r=a[a.length-1],n=o?{x:(h+e)/2,y:(null==r?void 0:r.y)||c}:{x:(null==r?void 0:r.x)||t,y:(h+e)/2};r&&!i(r,n)||a.push(n)}}}}return a},kr={radius:null,startRadius:null,endRadius:null,startAngle:0,endAngle:2*Math.PI,clockwise:!0,divisions:1,ordering:null,angleRatio:1,nodeSize:10,nodeSpacing:0};const Sr={nodeSize:30,nodeSpacing:10,preventOverlap:!1,sweep:void 0,equidistant:!1,startAngle:1.5*Math.PI,clockwise:!0,maxLevelDiff:void 0,sortBy:"degree"};function Ar(t,e,r,n){if(isNaN(e)||isNaN(r))return t;var o,i,s,a,u,c,h,l,d,f=t._root,g={data:n},p=t._x0,v=t._y0,m=t._x1,y=t._y1;if(!f)return t._root=g,t;for(;f.length;)if((c=e>=(i=(p+m)/2))?p=i:m=i,(h=r>=(s=(v+y)/2))?v=s:y=s,o=f,!(f=f[l=h<<1|c]))return o[l]=g,t;if(a=+t._x.call(null,f.data),u=+t._y.call(null,f.data),e===a&&r===u)return g.next=f,o?o[l]=g:t._root=g,t;do{o=o?o[l]=new Array(4):t._root=new Array(4),(c=e>=(i=(p+m)/2))?p=i:m=i,(h=r>=(s=(v+y)/2))?v=s:y=s}while((l=h<<1|c)==(d=(u>=s)<<1|a>=i));return o[d]=f,o[l]=g,t}function Or(t,e,r,n,o){this.node=t,this.x0=e,this.y0=r,this.x1=n,this.y1=o}function zr(t){return t[0]}function jr(t){return t[1]}function Cr(t,e,r){var n=new Ir(null==e?zr:e,null==r?jr:r,NaN,NaN,NaN,NaN);return null==t?n:n.addAll(t)}function Ir(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 Rr(t){for(var e={data:t.data},r=e;t=t.next;)r=r.next={data:t.data};return e}var Tr=Cr.prototype=Ir.prototype;function Pr(t){return function(){return t}}function Fr(t){return 1e-6*(t()-.5)}function Lr(t){return t.x+t.vx}function Dr(t){return t.y+t.vy}function qr(t){var e,r,n,o=1,i=1;function s(){for(var t,s,u,c,h,l,d,f=e.length,g=0;g<i;++g)for(s=Cr(e,Lr,Dr).visitAfter(a),t=0;t<f;++t)u=e[t],l=r[u.index],d=l*l,c=u.x+u.vx,h=u.y+u.vy,s.visit(p);function p(t,e,r,i,s){var a=t.data,f=t.r,g=l+f;if(!a)return e>c+g||i<c-g||r>h+g||s<h-g;if(a.index>u.index){var p=c-a.x-a.vx,v=h-a.y-a.vy,m=p*p+v*v;m<g*g&&(0===p&&(m+=(p=Fr(n))*p),0===v&&(m+=(v=Fr(n))*v),m=(g-(m=Math.sqrt(m)))/m*o,u.vx+=(p*=m)*(g=(f*=f)/(d+f)),u.vy+=(v*=m)*g,a.vx-=p*(g=1-g),a.vy-=v*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=Pr(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:Pr(+e),u(),s):t},s}function Br(t){return t.index}function Vr(t,e){var r=t.get(e);if(!r)throw new Error("node not found: "+e);return r}function Ur(t){var e,r,n,o,i,s,a=Br,u=function(t){return 1/Math.min(o[t.source.index],o[t.target.index])},c=Pr(30),h=1;function l(n){for(var o=0,a=t.length;o<h;++o)for(var u,c,l,d,f,g,p,v=0;v<a;++v)c=(u=t[v]).source,d=(l=u.target).x+l.vx-c.x-c.vx||Fr(s),f=l.y+l.vy-c.y-c.vy||Fr(s),d*=g=((g=Math.sqrt(d*d+f*f))-r[v])/g*n*e[v],f*=g,l.vx-=d*(p=i[v]),l.vy-=f*p,c.vx+=d*(p=1-p),c.vy+=f*p}function d(){if(n){var s,u,c=n.length,h=t.length,l=new Map(n.map((t,e)=>[a(t,e,n),t]));for(s=0,o=new Array(c);s<h;++s)(u=t[s]).index=s,"object"!=typeof u.source&&(u.source=Vr(l,u.source)),"object"!=typeof u.target&&(u.target=Vr(l,u.target)),o[u.source.index]=(o[u.source.index]||0)+1,o[u.target.index]=(o[u.target.index]||0)+1;for(s=0,i=new Array(h);s<h;++s)u=t[s],i[s]=o[u.source.index]/(o[u.source.index]+o[u.target.index]);e=new Array(h),f(),r=new Array(h),g()}}function f(){if(n)for(var r=0,o=t.length;r<o;++r)e[r]=+u(t[r],r,t)}function g(){if(n)for(var e=0,o=t.length;e<o;++e)r[e]=+c(t[e],e,t)}return null==t&&(t=[]),l.initialize=function(t,e){n=t,s=e,d()},l.links=function(e){return arguments.length?(t=e,d(),l):t},l.id=function(t){return arguments.length?(a=t,l):a},l.iterations=function(t){return arguments.length?(h=+t,l):h},l.strength=function(t){return arguments.length?(u="function"==typeof t?t:Pr(+t),f(),l):u},l.distance=function(t){return arguments.length?(c="function"==typeof t?t:Pr(+t),g(),l):c},l}Tr.copy=function(){var t,e,r=new Ir(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=Rr(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]=Rr(e));return r},Tr.add=function(t){const e=+this._x.call(null,t),r=+this._y.call(null,t);return Ar(this.cover(e,r),e,r,t)},Tr.addAll=function(t){var e,r,n,o,i=t.length,s=new Array(i),a=new Array(i),u=1/0,c=1/0,h=-1/0,l=-1/0;for(r=0;r<i;++r)isNaN(n=+this._x.call(null,e=t[r]))||isNaN(o=+this._y.call(null,e))||(s[r]=n,a[r]=o,n<u&&(u=n),n>h&&(h=n),o<c&&(c=o),o>l&&(l=o));if(u>h||c>l)return this;for(this.cover(u,c).cover(h,l),r=0;r<i;++r)Ar(this,s[r],a[r],t[r]);return this},Tr.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,c=this._root;r>t||t>=o||n>e||e>=i;)switch(a=(e<n)<<1|t<r,(s=new Array(4))[a]=c,c=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=c)}return this._x0=r,this._y0=n,this._x1=o,this._y1=i,this},Tr.data=function(){var t=[];return this.visit(function(e){if(!e.length)do{t.push(e.data)}while(e=e.next)}),t},Tr.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]]},Tr.find=function(t,e,r){var n,o,i,s,a,u,c,h=this._x0,l=this._y0,d=this._x1,f=this._y1,g=[],p=this._root;for(p&&g.push(new Or(p,h,l,d,f)),null==r?r=1/0:(h=t-r,l=e-r,d=t+r,f=e+r,r*=r);u=g.pop();)if(!(!(p=u.node)||(o=u.x0)>d||(i=u.y0)>f||(s=u.x1)<h||(a=u.y1)<l))if(p.length){var v=(o+s)/2,m=(i+a)/2;g.push(new Or(p[3],v,m,s,a),new Or(p[2],o,m,v,a),new Or(p[1],v,i,s,m),new Or(p[0],o,i,v,m)),(c=(e>=m)<<1|t>=v)&&(u=g[g.length-1],g[g.length-1]=g[g.length-1-c],g[g.length-1-c]=u)}else{var y=t-+this._x.call(null,p.data),w=e-+this._y.call(null,p.data),x=y*y+w*w;if(x<r){var b=Math.sqrt(r=x);h=t-b,l=e-b,d=t+b,f=e+b,n=p.data}}return n},Tr.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,c,h,l,d,f=this._root,g=this._x0,p=this._y0,v=this._x1,m=this._y1;if(!f)return this;if(f.length)for(;;){if((c=i>=(a=(g+v)/2))?g=a:v=a,(h=s>=(u=(p+m)/2))?p=u:m=u,e=f,!(f=f[l=h<<1|c]))return this;if(!f.length)break;(e[l+1&3]||e[l+2&3]||e[l+3&3])&&(r=e,d=l)}for(;f.data!==t;)if(n=f,!(f=f.next))return this;return(o=f.next)&&delete f.next,n?(o?n.next=o:delete n.next,this):e?(o?e[l]=o:delete e[l],(f=e[0]||e[1]||e[2]||e[3])&&f===(e[3]||e[2]||e[1]||e[0])&&!f.length&&(r?r[d]=f:this._root=f),this):(this._root=o,this)},Tr.removeAll=function(t){for(var e=0,r=t.length;e<r;++e)this.remove(t[e]);return this},Tr.root=function(){return this._root},Tr.size=function(){var t=0;return this.visit(function(e){if(!e.length)do{++t}while(e=e.next)}),t},Tr.visit=function(t){var e,r,n,o,i,s,a=[],u=this._root;for(u&&a.push(new Or(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 c=(n+i)/2,h=(o+s)/2;(r=u[3])&&a.push(new Or(r,c,h,i,s)),(r=u[2])&&a.push(new Or(r,n,h,c,s)),(r=u[1])&&a.push(new Or(r,c,o,i,h)),(r=u[0])&&a.push(new Or(r,n,o,c,h))}return this},Tr.visitAfter=function(t){var e,r=[],n=[];for(this._root&&r.push(new Or(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,c=e.y1,h=(s+u)/2,l=(a+c)/2;(i=o[0])&&r.push(new Or(i,s,a,h,l)),(i=o[1])&&r.push(new Or(i,h,a,u,l)),(i=o[2])&&r.push(new Or(i,s,l,h,c)),(i=o[3])&&r.push(new Or(i,h,l,u,c))}n.push(e)}for(;e=n.pop();)t(e.node,e.x0,e.y0,e.x1,e.y1);return this},Tr.x=function(t){return arguments.length?(this._x=t,this):this._x},Tr.y=function(t){return arguments.length?(this._y=t,this):this._y};var $r={value:()=>{}};function Gr(){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 Wr(n)}function Wr(t){this._=t}function Yr(t,e){for(var r,n=0,o=t.length;n<o;++n)if((r=t[n]).name===e)return r.value}function Hr(t,e,r){for(var n=0,o=t.length;n<o;++n)if(t[n].name===e){t[n]=$r,t=t.slice(0,n).concat(t.slice(n+1));break}return null!=r&&t.push({name:e,value:r}),t}Wr.prototype=Gr.prototype={constructor:Wr,on:function(t,e){var r,n,o=this._,i=(n=o,(t+"").trim().split(/^|\s+/).map(function(t){var e="",r=t.indexOf(".");if(r>=0&&(e=t.slice(r+1),t=t.slice(0,r)),t&&!n.hasOwnProperty(t))throw new Error("unknown type: "+t);return{type:t,name:e}})),s=-1,a=i.length;if(!(arguments.length<2)){if(null!=e&&"function"!=typeof e)throw new Error("invalid callback: "+e);for(;++s<a;)if(r=(t=i[s]).type)o[r]=Hr(o[r],t.name,e);else if(null==e)for(r in o)o[r]=Hr(o[r],t.name,null);return this}for(;++s<a;)if((r=(t=i[s]).type)&&(r=Yr(o[r],t.name)))return r},copy:function(){var t={},e=this._;for(var r in e)t[r]=e[r].slice();return new Wr(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)}};var Xr,Qr,Kr=0,Jr=0,Zr=0,tn=0,en=0,rn=0,nn="object"==typeof performance&&performance.now?performance:Date,on="object"==typeof window&&window.requestAnimationFrame?window.requestAnimationFrame.bind(window):function(t){setTimeout(t,17)};function sn(){return en||(on(an),en=nn.now()+rn)}function an(){en=0}function un(){this._call=this._time=this._next=null}function cn(t,e,r){var n=new un;return n.restart(t,e,r),n}function hn(){en=(tn=nn.now())+rn,Kr=Jr=0;try{!function(){sn(),++Kr;for(var t,e=Xr;e;)(t=en-e._time)>=0&&e._call.call(void 0,t),e=e._next;--Kr}()}finally{Kr=0,function(){var t,e,r=Xr,n=1/0;for(;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:Xr=e);Qr=t,dn(n)}(),en=0}}function ln(){var t=nn.now(),e=t-tn;e>1e3&&(rn-=e,tn=t)}function dn(t){Kr||(Jr&&(Jr=clearTimeout(Jr)),t-en>24?(t<1/0&&(Jr=setTimeout(hn,t-nn.now()-rn)),Zr&&(Zr=clearInterval(Zr))):(Zr||(tn=nn.now(),Zr=setInterval(ln,1e3)),Kr=1,on(hn)))}un.prototype=cn.prototype={constructor:un,restart:function(t,e,r){if("function"!=typeof t)throw new TypeError("callback is not a function");r=(null==r?sn():+r)+(null==e?0:+e),this._next||Qr===this||(Qr?Qr._next=this:Xr=this,Qr=this),this._call=t,this._time=r,dn()},stop:function(){this._call&&(this._call=null,this._time=1/0,dn())}};const fn=4294967296;function gn(t){return t.x}function pn(t){return t.y}var vn=Math.PI*(3-Math.sqrt(5));function mn(t){var e,r=1,n=.001,o=1-Math.pow(n,1/300),i=0,s=.6,a=new Map,u=cn(l),c=Gr("tick","end"),h=function(){let t=1;return()=>(t=(1664525*t+1013904223)%fn)/fn}();function l(){d(),c.call("tick",e),r<n&&(u.stop(),c.call("end",e))}function d(n){var u,c,h=t.length;void 0===n&&(n=1);for(var l=0;l<n;++l)for(r+=(i-r)*o,a.forEach(function(t){t(r)}),u=0;u<h;++u)null==(c=t[u]).fx?c.x+=c.vx*=s:(c.x=c.fx,c.vx=0),null==c.fy?c.y+=c.vy*=s:(c.y=c.fy,c.vy=0);return e}function f(){for(var e,r=0,n=t.length;r<n;++r){if((e=t[r]).index=r,null!=e.fx&&(e.x=e.fx),null!=e.fy&&(e.y=e.fy),isNaN(e.x)||isNaN(e.y)){var o=10*Math.sqrt(.5+r),i=r*vn;e.x=o*Math.cos(i),e.y=o*Math.sin(i)}(isNaN(e.vx)||isNaN(e.vy))&&(e.vx=e.vy=0)}}function g(e){return e.initialize&&e.initialize(t,h),e}return null==t&&(t=[]),f(),e={tick:d,restart:function(){return u.restart(l),e},stop:function(){return u.stop(),e},nodes:function(r){return arguments.length?(t=r,f(),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?(h=t,a.forEach(g),e):h},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,c=0,h=t.length;for(null==n?n=1/0:n*=n,c=0;c<h;++c)(s=(o=e-(a=t[c]).x)*o+(i=r-a.y)*i)<n&&(u=a,n=s);return u},on:function(t,r){return arguments.length>1?(c.on(t,r),e):c.on(t)}}}function yn(){var t,e,r,n,o,i=Pr(-30),s=1,a=1/0,u=.81;function c(r){var o,i=t.length,s=Cr(t,gn,pn).visitAfter(l);for(n=r,o=0;o<i;++o)e=t[o],s.visit(d)}function h(){if(t){var e,r,n=t.length;for(o=new Array(n),e=0;e<n;++e)r=t[e],o[r.index]=+i(r,e,t)}}function l(t){var e,r,n,i,s,a=0,u=0;if(t.length){for(n=i=s=0;s<4;++s)(e=t[s])&&(r=Math.abs(e.value))&&(a+=e.value,u+=r,n+=r*e.x,i+=r*e.y);t.x=n/u,t.y=i/u}else{(e=t).x=e.data.x,e.y=e.data.y;do{a+=o[e.data.index]}while(e=e.next)}t.value=a}function d(t,i,c,h){if(!t.value)return!0;var l=t.x-e.x,d=t.y-e.y,f=h-i,g=l*l+d*d;if(f*f/u<g)return g<a&&(0===l&&(g+=(l=Fr(r))*l),0===d&&(g+=(d=Fr(r))*d),g<s&&(g=Math.sqrt(s*g)),e.vx+=l*t.value*n/g,e.vy+=d*t.value*n/g),!0;if(!(t.length||g>=a)){(t.data!==e||t.next)&&(0===l&&(g+=(l=Fr(r))*l),0===d&&(g+=(d=Fr(r))*d),g<s&&(g=Math.sqrt(s*g)));do{t.data!==e&&(f=o[t.data.index]*n/g,e.vx+=l*f,e.vy+=d*f)}while(t=t.next)}}return c.initialize=function(e,n){t=e,r=n,h()},c.strength=function(t){return arguments.length?(i="function"==typeof t?t:Pr(+t),h(),c):i},c.distanceMin=function(t){return arguments.length?(s=t*t,c):Math.sqrt(s)},c.distanceMax=function(t){return arguments.length?(a=t*t,c):Math.sqrt(a)},c.theta=function(t){return arguments.length?(u=t*t,c):Math.sqrt(u)},c}function wn(t){var e,r,n,o=Pr(.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=Pr(null==t?0:+t)),i.initialize=function(t){e=t,s()},i.strength=function(t){return arguments.length?(o="function"==typeof t?t:Pr(+t),s(),i):o},i.x=function(e){return arguments.length?(t="function"==typeof e?e:Pr(+e),s(),i):t},i}function xn(t){var e,r,n,o=Pr(.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=Pr(null==t?0:+t)),i.initialize=function(t){e=t,s()},i.strength=function(t){return arguments.length?(o="function"==typeof t?t:Pr(+t),s(),i):o},i.y=function(e){return arguments.length?(t="function"==typeof e?e:Pr(+e),s(),i):t},i}const bn=(t,e)=>t[e];function En(){function t(t){return()=>t}let e,r=t=>t.cluster,n=t(1),o=t(-1),i=t(100),s=t(.1),a=[0,0],u=[],c={},h=[],l=100,d=100,f={none:{x:0,y:0}},g=[],p="force",v=!0,m=.1;function y(t){if(!v)return y;e.tick(),x();for(let e,n=0,o=u.length,i=t*m;n<o;++n)e=u[n],e.vx||(e.vx=0),e.vy||(e.vy=0),e.vx+=(f[r(e._original)].x-e.x)*i,e.vy+=(f[r(e._original)].y-e.y)*i}function w(){u&&function(){if(!u||!u.length)return;const t=u[0];if(void 0===r(t._original))throw Error("Couldnt find the grouping attribute for the nodes. Make sure to set it up with forceInABox.groupBy('clusterAttr') before calling .links()");const a=function(){const t=[],e=[],o={};let i=[],s={},a=[];return s=function(t){const e={};return t.forEach(t=>{const n=r(t._original);e[n]||(e[n]={count:0,sumforceNodeSize:0})}),t.forEach(t=>{const o=r(t._original),i=n(t._original),s=e[o];s.count=s.count+1,s.sumforceNodeSize=s.sumforceNodeSize+Math.PI*(i*i)*1.3,e[o]=s}),e}(u),a=function(t){const e={},n=[];t.forEach(t=>{const n=function(t){const e=bn(t,"source"),n=bn(t,"target"),o=r(c[e]._original),i=r(c[n]._original);return o<=i?`${o}~${i}`:`${i}~${o}`}(t);let o=0;void 0!==e[n]&&(o=e[n]),o+=1,e[n]=o});return Object.entries(e).forEach(([t,e])=>{const r=t.split("~")[0],o=t.split("~")[1];void 0!==r&&void 0!==o&&n.push({source:r,target:o,count:e})}),n}(h),i=Object.keys(s),i.forEach((e,r)=>{const n=s[e];t.push({id:e,size:n.count,r:Math.sqrt(n.sumforceNodeSize/Math.PI)}),o[e]=r}),a.forEach(t=>{const r=bn(t,"source"),n=bn(t,"target"),i=o[r],s=o[n];void 0!==i&&void 0!==s&&e.push({source:i,target:s,count:t.count})}),{nodes:t,links:e}}();e=mn(a.nodes).force("x",wn(l).strength(.1)).force("y",xn(d).strength(.1)).force("collide",qr(t=>t.r).iterations(4)).force("charge",yn().strength(o)).force("links",Ur(a.nodes.length?a.links:[]).distance(i).strength(s)),g=e.nodes(),x()}()}function x(){return f={none:{x:0,y:0}},g.forEach(t=>{f[t.id]={x:t.x-a[0],y:t.y-a[1]}}),f}return y.initialize=t=>{u=t,w()},y.template=function(t){return arguments.length?(p=t,w(),y):p},y.groupBy=function(t){return arguments.length?"string"==typeof t?(r=e=>e[t],y):(r=t,y):r},y.enableGrouping=function(t){return arguments.length?(v=t,y):v},y.strength=function(t){return arguments.length?(m=t,y):m},y.centerX=function(t){return arguments.length?(l=t,y):l},y.centerY=function(t){return arguments.length?(d=t,y):d},y.nodes=function(t){return arguments.length?(function(t){c={},t.forEach(t=>{c[t.id]=t})}(t||[]),u=t||[],y):u},y.links=function(t){return arguments.length?(h=t||[],w(),y):h},y.forceNodeSize=function(e){return arguments.length?(n="function"==typeof e?e:t(+e),w(),y):n},y.nodeSize=y.forceNodeSize,y.forceCharge=function(e){return arguments.length?(o="function"==typeof e?e:t(+e),w(),y):o},y.forceLinkDistance=function(e){return arguments.length?(i="function"==typeof e?e:t(+e),w(),y):i},y.forceLinkStrength=function(e){return arguments.length?(s="function"==typeof e?e:t(+e),w(),y):s},y.offset=function(t){return arguments.length?(a=t,y):a},y.getFocis=x,y}const Mn={edgeId:"edge.id",manyBody:{strength:-30},preventOverlap:!1,nodeSize:10,nodeSpacing:0,x:!1,y:!1,clustering:!1,clusterNodeStrength:-1,clusterEdgeStrength:.1,clusterEdgeDistance:100,clusterFociStrength:.8,clusterNodeSize:10};class Nn extends jt{getDefaultOptions(){return Mn}mergeOptions(t,e){return function(t){for(var e=[],r=1;r<arguments.length;r++)e[r-1]=arguments[r];for(var n=0;n<e.length;n+=1)R(t,e[n]);return t}({},t,e)}constructor(t){super(t),this.id="d3-force",this.d3Nodes=[],this.d3Edges=[],this.config={simulationAttrs:["alpha","alphaMin","alphaDecay","alphaTarget","velocityDecay","randomSource"]},this.options.forceSimulation&&(this.simulation=this.options.forceSimulation)}stop(){return this.simulation&&this.simulation.stop(),this}tick(t=1){var e,r;if(this.simulation){for(let e=0;e<t;e++)this.simulation.tick();this.syncPositionsFromD3(),null===(r=(e=this.options).onTick)||void 0===r||r.call(e,this)}return this}restart(t){return this.simulation&&(void 0!==t&&this.simulation.alpha(t),this.simulation.restart()),this}reheat(){return this.restart(1)}getAlpha(){var t,e;return null!==(e=null===(t=this.simulation)||void 0===t?void 0:t.alpha())&&void 0!==e?e:0}setAlpha(t){return this.simulation&&this.simulation.alpha(t),this}getForce(t){var e;return null===(e=this.simulation)||void 0===e?void 0:e.force(t)}force(t,e){return this.simulation&&this.simulation.force(t,e),this}nodes(){var t,e;return null!==(e=null===(t=this.simulation)||void 0===t?void 0:t.nodes())&&void 0!==e?e:[]}find(t,e,r){if(this.simulation)return this.simulation.find(t,e,r)}setFixedPosition(t,e){const r=this.d3Nodes.find(e=>e.id===t),n=this.model.node(t);if(!n||!r)return;const o=["fx","fy","fz"];null!==e?e.forEach((t,e)=>{e<o.length&&("number"==typeof t||null===t)&&(n[o[e]]=t,r[o[e]]=t)}):o.forEach(t=>{delete n[t],delete r[t]})}parseOptions(t){const e=t;return void 0===e.iterations&&(e.link&&void 0===e.link.iterations&&(e.iterations=e.link.iterations),e.collide&&void 0===e.collide.iterations&&(e.iterations=e.collide.iterations)),e}layout(){var t;return e(this,void 0,void 0,function*(){const e=this.parseOptions(this.options||{});this.createD3Copies();const r=this.setSimulation(e);return r.nodes(this.d3Nodes),null===(t=r.force("link"))||void 0===t||t.links(this.d3Edges),new Promise(t=>{r.on("end",()=>{this.syncPositionsFromD3(),t()})})})}createD3Copies(){this.d3Nodes=[],this.d3Edges=[],this.model.forEachNode(t=>{this.d3Nodes.push(Object.assign({},t))}),this.model.forEachEdge(t=>{this.d3Edges.push(Object.assign({},t))})}syncPositionsFromD3(){this.d3Nodes.forEach(t=>{const e=this.model.node(t.id);e&&(e.x=t.x,e.y=t.y,void 0!==t.z&&(e.z=t.z),void 0!==t.fx&&(e.fx=t.fx),void 0!==t.fy&&(e.fy=t.fy),void 0!==t.fz&&(e.fz=t.fz),void 0!==t.vx&&(e.vx=t.vx),void 0!==t.vy&&(e.vy=t.vy),void 0!==t.vz&&(e.vz=t.vz))})}initSimulation(){return mn()}setSimulation(t){const e=this.simulation||this.options.forceSimulation||this.initSimulation();return this.simulation||(this.simulation=e.on("tick",()=>{var e;this.syncPositionsFromD3(),null===(e=t.onTick)||void 0===e||e.call(t,this)})),_n(e,this.config.simulationAttrs.map(e=>[e,t[e]])),this.setupForces(e,t),e}setupForces(t,e){this.setupLinkForce(t,e),this.setupManyBodyForce(t,e),this.setupCenterForce(t,e),this.setupCollisionForce(t,e),this.setupXForce(t,e),this.setupYForce(t,e),this.setupRadialForce(t,e),this.setupClusterForce(t,e)}getCenterOptions(t){if(!1===t.center)return;const e=Mt({width:t.width,height:t.height});return mt({},t.center||{},{x:e.width/2,y:e.height/2,strength:t.centerStrength})}setupCenterForce(t,e){const r=this.getCenterOptions(e);if(r){let e=t.force("center");e||(e=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}(r.x,r.y),t.force("center",e));const n=[];void 0!==r.x&&n.push(["x",r.x]),void 0!==r.y&&n.push(["y",r.y]),void 0!==r.strength&&n.push(["strength",r.strength]),_n(e,n)}else t.force("center",null)}getManyBodyOptions(t){if(!1!==t.manyBody)return mt({},t.manyBody||{},{strength:t.nodeStrength?ct(t.nodeStrength,["node"]):void 0,distanceMin:t.distanceMin,distanceMax:t.distanceMax,theta:t.theta})}setupManyBodyForce(t,e){const r=this.getManyBodyOptions(e);if(r){let e=t.force("charge");e||(e=yn(),t.force("charge",e));const n=[];void 0!==r.strength&&n.push(["strength",r.strength]),void 0!==r.distanceMin&&n.push(["distanceMin",r.distanceMin]),void 0!==r.distanceMax&&n.push(["distanceMax",r.distanceMax]),void 0!==r.theta&&n.push(["theta",r.theta]),_n(e,n)}else t.force("charge",null)}getLinkOptions(t){if(!1!==t.link)return mt({},t.link||{},{id:t.edgeId?ct(t.edgeId,["edge"]):void 0,distance:t.linkDistance?ct(t.linkDistance,["edge"]):void 0,strength:t.edgeStrength?ct(t.edgeStrength,["edge"]):void 0,iterations:t.edgeIterations})}setupLinkForce(t,e){const r=this.model.edges(),n=this.getLinkOptions(e);if(r.length>0&&n){let e=t.force("link");e||(e=Ur(),t.force("link",e));const r=[];void 0!==n.id&&r.push(["id",n.id]),void 0!==n.distance&&r.push(["distance",n.distance]),void 0!==n.strength&&r.push(["strength",n.strength]),void 0!==n.iterations&&r.push(["iterations",n.iterations]),_n(e,r)}else t.force("link",null)}getCollisionOptions(t){if(!1===t.preventOverlap&&(!1===t.collide||void 0===t.collide))return;const e=dt(t.nodeSize,t.nodeSpacing,Mn.nodeSize,Mn.nodeSpacing);return mt({},t.collide||{},{radius:t.collide&&t.collide.radius||(t=>Math.max(...e(t._original))/2),strength:t.collideStrength,iterations:t.collideIterations})}setupCollisionForce(t,e){const r=this.getCollisionOptions(e);if(r){let e=t.force("collide");e||(e=qr(),t.force("collide",e));const n=[];void 0!==r.radius&&n.push(["radius",r.radius]),void 0!==r.strength&&n.push(["strength",r.strength]),void 0!==r.iterations&&n.push(["iterations",r.iterations]),_n(e,n)}else t.force("collide",null)}getXForceOptions(t){var e;if(!1===t.x)return;const r=this.getCenterOptions(t);return mt({},t.x||{},{x:null!==(e=t.forceXPosition)&&void 0!==e?e:r&&r.x,strength:t.forceXStrength})}setupXForce(t,e){const r=this.getXForceOptions(e);if(r){let e=t.force("x");e||(e=wn(),t.force("x",e));const n=[];void 0!==r.x&&n.push(["x",r.x]),void 0!==r.strength&&n.push(["strength",r.strength]),_n(e,n)}else t.force("x",null)}getYForceOptions(t){var e;if(!1===t.y)return;const r=this.getCenterOptions(t);return mt({},t.y||{},{y:null!==(e=t.forceYPosition)&&void 0!==e?e:r&&r.y,strength:t.forceYStrength})}setupYForce(t,e){const r=this.getYForceOptions(e);if(r){let e=t.force("y");e||(e=xn(),t.force("y",e));const n=[];void 0!==r.y&&n.push(["y",r.y]),void 0!==r.strength&&n.push(["strength",r.strength]),_n(e,n)}else t.force("y",null)}getRadialOptions(t){var e,r,n;if(void 0!==t.radial||void 0!==t.radialStrength||void 0!==t.radialRadius||void 0!==t.radialX||void 0!==t.radialY){const o=this.getCenterOptions(t);return mt({},t.radial||{},{strength:t.radialStrength,radius:null!==(e=t.radialRadius)&&void 0!==e?e:100,x:null!==(r=t.radialX)&&void 0!==r?r:o&&o.x,y:null!==(n=t.radialY)&&void 0!==n?n:o&&o.y})}}setupRadialForce(t,e){const r=this.getRadialOptions(e);if(r){let e=t.force("radial");e||(e=function(t,e,r){var n,o,i,s=Pr(.1);function a(t){for(var s=0,a=n.length;s<a;++s){var u=n[s],c=u.x-e||1e-6,h=u.y-r||1e-6,l=Math.sqrt(c*c+h*h),d=(i[s]-l)*o[s]*t/l;u.vx+=c*d,u.vy+=h*d}}function u(){if(n){var e,r=n.length;for(o=new Array(r),i=new Array(r),e=0;e<r;++e)i[e]=+t(n[e],e,n),o[e]=isNaN(i[e])?0:+s(n[e],e,n)}}return"function"!=typeof t&&(t=Pr(+t)),null==e&&(e=0),null==r&&(r=0),a.initialize=function(t){n=t,u()},a.strength=function(t){return arguments.length?(s="function"==typeof t?t:Pr(+t),u(),a):s},a.radius=function(e){return arguments.length?(t="function"==typeof e?e:Pr(+e),u(),a):t},a.x=function(t){return arguments.length?(e=+t,a):e},a.y=function(t){return arguments.length?(r=+t,a):r},a}(r.radius||100,r.x,r.y),t.force("radial",e));const n=[];void 0!==r.radius&&n.push(["radius",r.radius]),void 0!==r.strength&&n.push(["strength",r.strength]),void 0!==r.x&&n.push(["x",r.x]),void 0!==r.y&&n.push(["y",r.y]),_n(e,n)}else t.force("radial",null)}setupClusterForce(t,e){const{clustering:r}=e;if(r){const{clusterFociStrength:r,clusterEdgeDistance:n,clusterEdgeStrength:o,clusterNodeStrength:i,clusterNodeSize:s,clusterBy:a}=e,u=this.getCenterOptions(e);let c=t.force("group");c||(c=En(),t.force("group",c)),_n(c,[["centerX",u&&u.x],["centerY",u&&u.y],["template","force"],["strength",r],["groupBy",a?ct(a,["node"]):void 0],["nodes",this.model.nodes()],["links",this.model.edges()],["forceLinkDistance",n],["forceLinkStrength",o],["forceCharge",i],["forceNodeSize",s]])}else t.force("group",null)}}const _n=(t,e)=>e.reduce((e,[r,n])=>e[r]&&void 0!==n?e[r].call(t,n):e,t);function kn(t,e,r){var n,o=1;function i(){var i,s,a=n.length,u=0,c=0,h=0;for(i=0;i<a;++i)u+=(s=n[i]).x||0,c+=s.y||0,h+=s.z||0;for(u=(u/a-t)*o,c=(c/a-e)*o,h=(h/a-r)*o,i=0;i<a;++i)s=n[i],u&&(s.x-=u),c&&(s.y-=c),h&&(s.z-=h)}return null==t&&(t=0),null==e&&(e=0),null==r&&(r=0),i.initialize=function(t){n=t},i.x=function(e){return arguments.length?(t=+e,i):t},i.y=function(t){return arguments.length?(e=+t,i):e},i.z=function(t){return arguments.length?(r=+t,i):r},i.strength=function(t){return arguments.length?(o=+t,i):o},i}function Sn(t,e,r){if(isNaN(e))return t;var n,o,i,s,a,u,c=t._root,h={data:r},l=t._x0,d=t._x1;if(!c)return t._root=h,t;for(;c.length;)if((s=e>=(o=(l+d)/2))?l=o:d=o,n=c,!(c=c[a=+s]))return n[a]=h,t;if(e===(i=+t._x.call(null,c.data)))return h.next=c,n?n[a]=h:t._root=h,t;do{n=n?n[a]=new Array(2):t._root=new Array(2),(s=e>=(o=(l+d)/2))?l=o:d=o}while((a=+s)===(u=+(i>=o)));return n[u]=c,n[a]=h,t}function An(t,e,r){this.node=t,this.x0=e,this.x1=r}function On(t){return t[0]}function zn(t,e){var r=new jn(null==e?On:e,NaN,NaN);return null==t?r:r.addAll(t)}function jn(t,e,r){this._x=t,this._x0=e,this._x1=r,this._root=void 0}function Cn(t){for(var e={data:t.data},r=e;t=t.next;)r=r.next={data:t.data};return e}var In=zn.prototype=jn.prototype;function Rn(t,e,r,n,o){if(isNaN(e)||isNaN(r)||isNaN(n))return t;var i,s,a,u,c,h,l,d,f,g,p,v,m=t._root,y={data:o},w=t._x0,x=t._y0,b=t._z0,E=t._x1,M=t._y1,N=t._z1;if(!m)return t._root=y,t;for(;m.length;)if((d=e>=(s=(w+E)/2))?w=s:E=s,(f=r>=(a=(x+M)/2))?x=a:M=a,(g=n>=(u=(b+N)/2))?b=u:N=u,i=m,!(m=m[p=g<<2|f<<1|d]))return i[p]=y,t;if(c=+t._x.call(null,m.data),h=+t._y.call(null,m.data),l=+t._z.call(null,m.data),e===c&&r===h&&n===l)return y.next=m,i?i[p]=y:t._root=y,t;do{i=i?i[p]=new Array(8):t._root=new Array(8),(d=e>=(s=(w+E)/2))?w=s:E=s,(f=r>=(a=(x+M)/2))?x=a:M=a,(g=n>=(u=(b+N)/2))?b=u:N=u}while((p=g<<2|f<<1|d)==(v=(l>=u)<<2|(h>=a)<<1|c>=s));return i[v]=m,i[p]=y,t}function Tn(t,e,r,n,o,i,s){this.node=t,this.x0=e,this.y0=r,this.z0=n,this.x1=o,this.y1=i,this.z1=s}In.copy=function(){var t,e,r=new jn(this._x,this._x0,this._x1),n=this._root;if(!n)return r;if(!n.length)return r._root=Cn(n),r;for(t=[{source:n,target:r._root=new Array(2)}];n=t.pop();)for(var o=0;o<2;++o)(e=n.source[o])&&(e.length?t.push({source:e,target:n.target[o]=new Array(2)}):n.target[o]=Cn(e));return r},In.add=function(t){const e=+this._x.call(null,t);return Sn(this.cover(e),e,t)},In.addAll=function(t){Array.isArray(t)||(t=Array.from(t));const e=t.length,r=new Float64Array(e);let n=1/0,o=-1/0;for(let i,s=0;s<e;++s)isNaN(i=+this._x.call(null,t[s]))||(r[s]=i,i<n&&(n=i),i>o&&(o=i));if(n>o)return this;this.cover(n).cover(o);for(let n=0;n<e;++n)Sn(this,r[n],t[n]);return this},In.cover=function(t){if(isNaN(t=+t))return this;var e=this._x0,r=this._x1;if(isNaN(e))r=(e=Math.floor(t))+1;else{for(var n,o,i=r-e||1,s=this._root;e>t||t>=r;)switch(o=+(t<e),(n=new Array(2))[o]=s,s=n,i*=2,o){case 0:r=e+i;break;case 1:e=r-i}this._root&&this._root.length&&(this._root=s)}return this._x0=e,this._x1=r,this},In.data=function(){var t=[];return this.visit(function(e){if(!e.length)do{t.push(e.data)}while(e=e.next)}),t},In.extent=function(t){return arguments.length?this.cover(+t[0][0]).cover(+t[1][0]):isNaN(this._x0)?void 0:[[this._x0],[this._x1]]},In.find=function(t,e){var r,n,o,i,s,a=this._x0,u=this._x1,c=[],h=this._root;for(h&&c.push(new An(h,a,u)),null==e?e=1/0:(a=t-e,u=t+e);i=c.pop();)if(!(!(h=i.node)||(n=i.x0)>u||(o=i.x1)<a))if(h.length){var l=(n+o)/2;c.push(new An(h[1],l,o),new An(h[0],n,l)),(s=+(t>=l))&&(i=c[c.length-1],c[c.length-1]=c[c.length-1-s],c[c.length-1-s]=i)}else{var d=Math.abs(t-+this._x.call(null,h.data));d<e&&(e=d,a=t-d,u=t+d,r=h.data)}return r},In.remove=function(t){if(isNaN(i=+this._x.call(null,t)))return this;var e,r,n,o,i,s,a,u,c,h=this._root,l=this._x0,d=this._x1;if(!h)return this;if(h.length)for(;;){if((a=i>=(s=(l+d)/2))?l=s:d=s,e=h,!(h=h[u=+a]))return this;if(!h.length)break;e[u+1&1]&&(r=e,c=u)}for(;h.data!==t;)if(n=h,!(h=h.next))return this;return(o=h.next)&&delete h.next,n?(o?n.next=o:delete n.next,this):e?(o?e[u]=o:delete e[u],(h=e[0]||e[1])&&h===(e[1]||e[0])&&!h.length&&(r?r[c]=h:this._root=h),this):(this._root=o,this)},In.removeAll=function(t){for(var e=0,r=t.length;e<r;++e)this.remove(t[e]);return this},In.root=function(){return this._root},In.size=function(){var t=0;return this.visit(function(e){if(!e.length)do{++t}while(e=e.next)}),t},In.visit=function(t){var e,r,n,o,i=[],s=this._root;for(s&&i.push(new An(s,this._x0,this._x1));e=i.pop();)if(!t(s=e.node,n=e.x0,o=e.x1)&&s.length){var a=(n+o)/2;(r=s[1])&&i.push(new An(r,a,o)),(r=s[0])&&i.push(new An(r,n,a))}return this},In.visitAfter=function(t){var e,r=[],n=[];for(this._root&&r.push(new An(this._root,this._x0,this._x1));e=r.pop();){var o=e.node;if(o.length){var i,s=e.x0,a=e.x1,u=(s+a)/2;(i=o[0])&&r.push(new An(i,s,u)),(i=o[1])&&r.push(new An(i,u,a))}n.push(e)}for(;e=n.pop();)t(e.node,e.x0,e.x1);return this},In.x=function(t){return arguments.length?(this._x=t,this):this._x};const Pn=(t,e,r,n,o,i)=>Math.sqrt((t-n)**2+(e-o)**2+(r-i)**2);function Fn(t){return t[0]}function Ln(t){return t[1]}function Dn(t){return t[2]}function qn(t,e,r,n){var o=new Bn(null==e?Fn:e,null==r?Ln:r,null==n?Dn:n,NaN,NaN,NaN,NaN,NaN,NaN);return null==t?o:o.addAll(t)}function Bn(t,e,r,n,o,i,s,a,u){this._x=t,this._y=e,this._z=r,this._x0=n,this._y0=o,this._z0=i,this._x1=s,this._y1=a,this._z1=u,this._root=void 0}function Vn(t){for(var e={data:t.data},r=e;t=t.next;)r=r.next={data:t.data};return e}var Un=qn.prototype=Bn.prototype;function $n(t){return function(){return t}}function Gn(t){return 1e-6*(t()-.5)}function Wn(t){return t.x+t.vx}function Yn(t){return t.y+t.vy}function Hn(t){return t.z+t.vz}function Xn(t){var e,r,n,o,i=1,s=1;function a(){for(var t,a,c,h,l,d,f,g,p=e.length,v=0;v<s;++v)for(a=(1===r?zn(e,Wn):2===r?Cr(e,Wn,Yn):3===r?qn(e,Wn,Yn,Hn):null).visitAfter(u),t=0;t<p;++t)c=e[t],f=n[c.index],g=f*f,h=c.x+c.vx,r>1&&(l=c.y+c.vy),r>2&&(d=c.z+c.vz),a.visit(m);function m(t,e,n,s,a,u,p){var v=[e,n,s,a,u,p],m=v[0],y=v[1],w=v[2],x=v[r],b=v[r+1],E=v[r+2],M=t.data,N=t.r,_=f+N;if(!M)return m>h+_||x<h-_||r>1&&(y>l+_||b<l-_)||r>2&&(w>d+_||E<d-_);if(M.index>c.index){var k=h-M.x-M.vx,S=r>1?l-M.y-M.vy:0,A=r>2?d-M.z-M.vz:0,O=k*k+S*S+A*A;O<_*_&&(0===k&&(O+=(k=Gn(o))*k),r>1&&0===S&&(O+=(S=Gn(o))*S),r>2&&0===A&&(O+=(A=Gn(o))*A),O=(_-(O=Math.sqrt(O)))/O*i,c.vx+=(k*=O)*(_=(N*=N)/(g+N)),r>1&&(c.vy+=(S*=O)*_),r>2&&(c.vz+=(A*=O)*_),M.vx-=k*(_=1-_),r>1&&(M.vy-=S*_),r>2&&(M.vz-=A*_))}}}function u(t){if(t.data)return t.r=n[t.data.index];for(var e=t.r=0;e<Math.pow(2,r);++e)t[e]&&t[e].r>t.r&&(t.r=t[e].r)}function c(){if(e){var r,o,i=e.length;for(n=new Array(i),r=0;r<i;++r)o=e[r],n[o.index]=+t(o,r,e)}}return"function"!=typeof t&&(t=$n(null==t?1:+t)),a.initialize=function(t,...n){e=t,o=n.find(t=>"function"==typeof t)||Math.random,r=n.find(t=>[1,2,3].includes(t))||2,c()},a.iterations=function(t){return arguments.length?(s=+t,a):s},a.strength=function(t){return arguments.length?(i=+t,a):i},a.radius=function(e){return arguments.length?(t="function"==typeof e?e:$n(+e),c(),a):t},a}function Qn(t){return t.index}function Kn(t,e){var r=t.get(e);if(!r)throw new Error("node not found: "+e);return r}function Jn(t){var e,r,n,o,i,s,a,u=Qn,c=function(t){return 1/Math.min(i[t.source.index],i[t.target.index])},h=$n(30),l=1;function d(n){for(var i=0,u=t.length;i<l;++i)for(var c,h,d,f,g,p=0,v=0,m=0,y=0;p<u;++p)h=(c=t[p]).source,v=(d=c.target).x+d.vx-h.x-h.vx||Gn(a),o>1&&(m=d.y+d.vy-h.y-h.vy||Gn(a)),o>2&&(y=d.z+d.vz-h.z-h.vz||Gn(a)),v*=f=((f=Math.sqrt(v*v+m*m+y*y))-r[p])/f*n*e[p],m*=f,y*=f,d.vx-=v*(g=s[p]),o>1&&(d.vy-=m*g),o>2&&(d.vz-=y*g),h.vx+=v*(g=1-g),o>1&&(h.vy+=m*g),o>2&&(h.vz+=y*g)}function f(){if(n){var o,a,c=n.length,h=t.length,l=new Map(n.map((t,e)=>[u(t,e,n),t]));for(o=0,i=new Array(c);o<h;++o)(a=t[o]).index=o,"object"!=typeof a.source&&(a.source=Kn(l,a.source)),"object"!=typeof a.target&&(a.target=Kn(l,a.target)),i[a.source.index]=(i[a.source.index]||0)+1,i[a.target.index]=(i[a.target.index]||0)+1;for(o=0,s=new Array(h);o<h;++o)a=t[o],s[o]=i[a.source.index]/(i[a.source.index]+i[a.target.index]);e=new Array(h),g(),r=new Array(h),p()}}function g(){if(n)for(var r=0,o=t.length;r<o;++r)e[r]=+c(t[r],r,t)}function p(){if(n)for(var e=0,o=t.length;e<o;++e)r[e]=+h(t[e],e,t)}return null==t&&(t=[]),d.initialize=function(t,...e){n=t,a=e.find(t=>"function"==typeof t)||Math.random,o=e.find(t=>[1,2,3].includes(t))||2,f()},d.links=function(e){return arguments.length?(t=e,f(),d):t},d.id=function(t){return arguments.length?(u=t,d):u},d.iterations=function(t){return arguments.length?(l=+t,d):l},d.strength=function(t){return arguments.length?(c="function"==typeof t?t:$n(+t),g(),d):c},d.distance=function(t){return arguments.length?(h="function"==typeof t?t:$n(+t),p(),d):h},d}Un.copy=function(){var t,e,r=new Bn(this._x,this._y,this._z,this._x0,this._y0,this._z0,this._x1,this._y1,this._z1),n=this._root;if(!n)return r;if(!n.length)return r._root=Vn(n),r;for(t=[{source:n,target:r._root=new Array(8)}];n=t.pop();)for(var o=0;o<8;++o)(e=n.source[o])&&(e.length?t.push({source:e,target:n.target[o]=new Array(8)}):n.target[o]=Vn(e));return r},Un.add=function(t){const e=+this._x.call(null,t),r=+this._y.call(null,t),n=+this._z.call(null,t);return Rn(this.cover(e,r,n),e,r,n,t)},Un.addAll=function(t){Array.isArray(t)||(t=Array.from(t));const e=t.length,r=new Float64Array(e),n=new Float64Array(e),o=new Float64Array(e);let i=1/0,s=1/0,a=1/0,u=-1/0,c=-1/0,h=-1/0;for(let l,d,f,g,p=0;p<e;++p)isNaN(d=+this._x.call(null,l=t[p]))||isNaN(f=+this._y.call(null,l))||isNaN(g=+this._z.call(null,l))||(r[p]=d,n[p]=f,o[p]=g,d<i&&(i=d),d>u&&(u=d),f<s&&(s=f),f>c&&(c=f),g<a&&(a=g),g>h&&(h=g));if(i>u||s>c||a>h)return this;this.cover(i,s,a).cover(u,c,h);for(let i=0;i<e;++i)Rn(this,r[i],n[i],o[i],t[i]);return this},Un.cover=function(t,e,r){if(isNaN(t=+t)||isNaN(e=+e)||isNaN(r=+r))return this;var n=this._x0,o=this._y0,i=this._z0,s=this._x1,a=this._y1,u=this._z1;if(isNaN(n))s=(n=Math.floor(t))+1,a=(o=Math.floor(e))+1,u=(i=Math.floor(r))+1;else{for(var c,h,l=s-n||1,d=this._root;n>t||t>=s||o>e||e>=a||i>r||r>=u;)switch(h=(r<i)<<2|(e<o)<<1|t<n,(c=new Array(8))[h]=d,d=c,l*=2,h){case 0:s=n+l,a=o+l,u=i+l;break;case 1:n=s-l,a=o+l,u=i+l;break;case 2:s=n+l,o=a-l,u=i+l;break;case 3:n=s-l,o=a-l,u=i+l;break;case 4:s=n+l,a=o+l,i=u-l;break;case 5:n=s-l,a=o+l,i=u-l;break;case 6:s=n+l,o=a-l,i=u-l;break;case 7:n=s-l,o=a-l,i=u-l}this._root&&this._root.length&&(this._root=d)}return this._x0=n,this._y0=o,this._z0=i,this._x1=s,this._y1=a,this._z1=u,this},Un.data=function(){var t=[];return this.visit(function(e){if(!e.length)do{t.push(e.data)}while(e=e.next)}),t},Un.extent=function(t){return arguments.length?this.cover(+t[0][0],+t[0][1],+t[0][2]).cover(+t[1][0],+t[1][1],+t[1][2]):isNaN(this._x0)?void 0:[[this._x0,this._y0,this._z0],[this._x1,this._y1,this._z1]]},Un.find=function(t,e,r,n){var o,i,s,a,u,c,h,l,d,f=this._x0,g=this._y0,p=this._z0,v=this._x1,m=this._y1,y=this._z1,w=[],x=this._root;for(x&&w.push(new Tn(x,f,g,p,v,m,y)),null==n?n=1/0:(f=t-n,g=e-n,p=r-n,v=t+n,m=e+n,y=r+n,n*=n);l=w.pop();)if(!(!(x=l.node)||(i=l.x0)>v||(s=l.y0)>m||(a=l.z0)>y||(u=l.x1)<f||(c=l.y1)<g||(h=l.z1)<p))if(x.length){var b=(i+u)/2,E=(s+c)/2,M=(a+h)/2;w.push(new Tn(x[7],b,E,M,u,c,h),new Tn(x[6],i,E,M,b,c,h),new Tn(x[5],b,s,M,u,E,h),new Tn(x[4],i,s,M,b,E,h),new Tn(x[3],b,E,a,u,c,M),new Tn(x[2],i,E,a,b,c,M),new Tn(x[1],b,s,a,u,E,M),new Tn(x[0],i,s,a,b,E,M)),(d=(r>=M)<<2|(e>=E)<<1|t>=b)&&(l=w[w.length-1],w[w.length-1]=w[w.length-1-d],w[w.length-1-d]=l)}else{var N=t-+this._x.call(null,x.data),_=e-+this._y.call(null,x.data),k=r-+this._z.call(null,x.data),S=N*N+_*_+k*k;if(S<n){var A=Math.sqrt(n=S);f=t-A,g=e-A,p=r-A,v=t+A,m=e+A,y=r+A,o=x.data}}return o},Un.findAllWithinRadius=function(t,e,r,n){const o=[],i=t-n,s=e-n,a=r-n,u=t+n,c=e+n,h=r+n;return this.visit((l,d,f,g,p,v,m)=>{if(!l.length)do{const i=l.data;Pn(t,e,r,this._x(i),this._y(i),this._z(i))<=n&&o.push(i)}while(l=l.next);return d>u||f>c||g>h||p<i||v<s||m<a}),o},Un.remove=function(t){if(isNaN(i=+this._x.call(null,t))||isNaN(s=+this._y.call(null,t))||isNaN(a=+this._z.call(null,t)))return this;var e,r,n,o,i,s,a,u,c,h,l,d,f,g,p,v=this._root,m=this._x0,y=this._y0,w=this._z0,x=this._x1,b=this._y1,E=this._z1;if(!v)return this;if(v.length)for(;;){if((l=i>=(u=(m+x)/2))?m=u:x=u,(d=s>=(c=(y+b)/2))?y=c:b=c,(f=a>=(h=(w+E)/2))?w=h:E=h,e=v,!(v=v[g=f<<2|d<<1|l]))return this;if(!v.length)break;(e[g+1&7]||e[g+2&7]||e[g+3&7]||e[g+4&7]||e[g+5&7]||e[g+6&7]||e[g+7&7])&&(r=e,p=g)}for(;v.data!==t;)if(n=v,!(v=v.next))return this;return(o=v.next)&&delete v.next,n?(o?n.next=o:delete n.next,this):e?(o?e[g]=o:delete e[g],(v=e[0]||e[1]||e[2]||e[3]||e[4]||e[5]||e[6]||e[7])&&v===(e[7]||e[6]||e[5]||e[4]||e[3]||e[2]||e[1]||e[0])&&!v.length&&(r?r[p]=v:this._root=v),this):(this._root=o,this)},Un.removeAll=function(t){for(var e=0,r=t.length;e<r;++e)this.remove(t[e]);return this},Un.root=function(){return this._root},Un.size=function(){var t=0;return this.visit(function(e){if(!e.length)do{++t}while(e=e.next)}),t},Un.visit=function(t){var e,r,n,o,i,s,a,u,c=[],h=this._root;for(h&&c.push(new Tn(h,this._x0,this._y0,this._z0,this._x1,this._y1,this._z1));e=c.pop();)if(!t(h=e.node,n=e.x0,o=e.y0,i=e.z0,s=e.x1,a=e.y1,u=e.z1)&&h.length){var l=(n+s)/2,d=(o+a)/2,f=(i+u)/2;(r=h[7])&&c.push(new Tn(r,l,d,f,s,a,u)),(r=h[6])&&c.push(new Tn(r,n,d,f,l,a,u)),(r=h[5])&&c.push(new Tn(r,l,o,f,s,d,u)),(r=h[4])&&c.push(new Tn(r,n,o,f,l,d,u)),(r=h[3])&&c.push(new Tn(r,l,d,i,s,a,f)),(r=h[2])&&c.push(new Tn(r,n,d,i,l,a,f)),(r=h[1])&&c.push(new Tn(r,l,o,i,s,d,f)),(r=h[0])&&c.push(new Tn(r,n,o,i,l,d,f))}return this},Un.visitAfter=function(t){var e,r=[],n=[];for(this._root&&r.push(new Tn(this._root,this._x0,this._y0,this._z0,this._x1,this._y1,this._z1));e=r.pop();){var o=e.node;if(o.length){var i,s=e.x0,a=e.y0,u=e.z0,c=e.x1,h=e.y1,l=e.z1,d=(s+c)/2,f=(a+h)/2,g=(u+l)/2;(i=o[0])&&r.push(new Tn(i,s,a,u,d,f,g)),(i=o[1])&&r.push(new Tn(i,d,a,u,c,f,g)),(i=o[2])&&r.push(new Tn(i,s,f,u,d,h,g)),(i=o[3])&&r.push(new Tn(i,d,f,u,c,h,g)),(i=o[4])&&r.push(new Tn(i,s,a,g,d,f,l)),(i=o[5])&&r.push(new Tn(i,d,a,g,c,f,l)),(i=o[6])&&r.push(new Tn(i,s,f,g,d,h,l)),(i=o[7])&&r.push(new Tn(i,d,f,g,c,h,l))}n.push(e)}for(;e=n.pop();)t(e.node,e.x0,e.y0,e.z0,e.x1,e.y1,e.z1);return this},Un.x=function(t){return arguments.length?(this._x=t,this):this._x},Un.y=function(t){return arguments.length?(this._y=t,this):this._y},Un.z=function(t){return arguments.length?(this._z=t,this):this._z};const Zn=4294967296;function to(t){return t.x}function eo(t){return t.y}function ro(t){return t.z}var no=Math.PI*(3-Math.sqrt(5)),oo=20*Math.PI/(9+Math.sqrt(221));function io(t,e){e=e||2;var r,n=Math.min(3,Math.max(1,Math.round(e))),o=1,i=.001,s=1-Math.pow(i,1/300),a=0,u=.6,c=new Map,h=cn(f),l=Gr("tick","end"),d=function(){let t=1;return()=>(t=(1664525*t+1013904223)%Zn)/Zn}();function f(){g(),l.call("tick",r),o<i&&(h.stop(),l.call("end",r))}function g(e){var i,h,l=t.length;void 0===e&&(e=1);for(var d=0;d<e;++d)for(o+=(a-o)*s,c.forEach(function(t){t(o)}),i=0;i<l;++i)null==(h=t[i]).fx?h.x+=h.vx*=u:(h.x=h.fx,h.vx=0),n>1&&(null==h.fy?h.y+=h.vy*=u:(h.y=h.fy,h.vy=0)),n>2&&(null==h.fz?h.z+=h.vz*=u:(h.z=h.fz,h.vz=0));return r}function p(){for(var e,r=0,o=t.length;r<o;++r){if((e=t[r]).index=r,null!=e.fx&&(e.x=e.fx),null!=e.fy&&(e.y=e.fy),null!=e.fz&&(e.z=e.fz),isNaN(e.x)||n>1&&isNaN(e.y)||n>2&&isNaN(e.z)){var i=10*(n>2?Math.cbrt(.5+r):n>1?Math.sqrt(.5+r):r),s=r*no,a=r*oo;1===n?e.x=i:2===n?(e.x=i*Math.cos(s),e.y=i*Math.sin(s)):(e.x=i*Math.sin(s)*Math.cos(a),e.y=i*Math.cos(s),e.z=i*Math.sin(s)*Math.sin(a))}(isNaN(e.vx)||n>1&&isNaN(e.vy)||n>2&&isNaN(e.vz))&&(e.vx=0,n>1&&(e.vy=0),n>2&&(e.vz=0))}}function v(e){return e.initialize&&e.initialize(t,d,n),e}return null==t&&(t=[]),p(),r={tick:g,restart:function(){return h.restart(f),r},stop:function(){return h.stop(),r},numDimensions:function(t){return arguments.length?(n=Math.min(3,Math.max(1,Math.round(t))),c.forEach(v),r):n},nodes:function(e){return arguments.length?(t=e,p(),c.forEach(v),r):t},alpha:function(t){return arguments.length?(o=+t,r):o},alphaMin:function(t){return arguments.length?(i=+t,r):i},alphaDecay:function(t){return arguments.length?(s=+t,r):+s},alphaTarget:function(t){return arguments.length?(a=+t,r):a},velocityDecay:function(t){return arguments.length?(u=1-t,r):1-u},randomSource:function(t){return arguments.length?(d=t,c.forEach(v),r):d},force:function(t,e){return arguments.length>1?(null==e?c.delete(t):c.set(t,v(e)),r):c.get(t)},find:function(){var e,r,o,i,s,a,u=Array.prototype.slice.call(arguments),c=u.shift()||0,h=(n>1?u.shift():null)||0,l=(n>2?u.shift():null)||0,d=u.shift()||1/0,f=0,g=t.length;for(d*=d,f=0;f<g;++f)(i=(e=c-(s=t[f]).x)*e+(r=h-(s.y||0))*r+(o=l-(s.z||0))*o)<d&&(a=s,d=i);return a},on:function(t,e){return arguments.length>1?(l.on(t,e),r):l.on(t)}}}function so(){var t,e,r,n,o,i,s=$n(-30),a=1,u=1/0,c=.81;function h(n){var i,s=t.length,a=(1===e?zn(t,to):2===e?Cr(t,to,eo):3===e?qn(t,to,eo,ro):null).visitAfter(d);for(o=n,i=0;i<s;++i)r=t[i],a.visit(f)}function l(){if(t){var e,r,n=t.length;for(i=new Array(n),e=0;e<n;++e)r=t[e],i[r.index]=+s(r,e,t)}}function d(t){var r,n,o,s,a,u,c=0,h=0,l=t.length;if(l){for(o=s=a=u=0;u<l;++u)(r=t[u])&&(n=Math.abs(r.value))&&(c+=r.value,h+=n,o+=n*(r.x||0),s+=n*(r.y||0),a+=n*(r.z||0));c*=Math.sqrt(4/l),t.x=o/h,e>1&&(t.y=s/h),e>2&&(t.z=a/h)}else{(r=t).x=r.data.x,e>1&&(r.y=r.data.y),e>2&&(r.z=r.data.z);do{c+=i[r.data.index]}while(r=r.next)}t.value=c}function f(t,s,h,l,d){if(!t.value)return!0;var f=[h,l,d][e-1],g=t.x-r.x,p=e>1?t.y-r.y:0,v=e>2?t.z-r.z:0,m=f-s,y=g*g+p*p+v*v;if(m*m/c<y)return y<u&&(0===g&&(y+=(g=Gn(n))*g),e>1&&0===p&&(y+=(p=Gn(n))*p),e>2&&0===v&&(y+=(v=Gn(n))*v),y<a&&(y=Math.sqrt(a*y)),r.vx+=g*t.value*o/y,e>1&&(r.vy+=p*t.value*o/y),e>2&&(r.vz+=v*t.value*o/y)),!0;if(!(t.length||y>=u)){(t.data!==r||t.next)&&(0===g&&(y+=(g=Gn(n))*g),e>1&&0===p&&(y+=(p=Gn(n))*p),e>2&&0===v&&(y+=(v=Gn(n))*v),y<a&&(y=Math.sqrt(a*y)));do{t.data!==r&&(m=i[t.data.index]*o/y,r.vx+=g*m,e>1&&(r.vy+=p*m),e>2&&(r.vz+=v*m))}while(t=t.next)}}return h.initialize=function(r,...o){t=r,n=o.find(t=>"function"==typeof t)||Math.random,e=o.find(t=>[1,2,3].includes(t))||2,l()},h.strength=function(t){return arguments.length?(s="function"==typeof t?t:$n(+t),l(),h):s},h.distanceMin=function(t){return arguments.length?(a=t*t,h):Math.sqrt(a)},h.distanceMax=function(t){return arguments.length?(u=t*t,h):Math.sqrt(u)},h.theta=function(t){return arguments.length?(c=t*t,h):Math.sqrt(c)},h}function ao(t,e,r,n){var o,i,s,a,u=$n(.1);function c(t){for(var u=0,c=o.length;u<c;++u){var h=o[u],l=h.x-e||1e-6,d=(h.y||0)-r||1e-6,f=(h.z||0)-n||1e-6,g=Math.sqrt(l*l+d*d+f*f),p=(a[u]-g)*s[u]*t/g;h.vx+=l*p,i>1&&(h.vy+=d*p),i>2&&(h.vz+=f*p)}}function h(){if(o){var e,r=o.length;for(s=new Array(r),a=new Array(r),e=0;e<r;++e)a[e]=+t(o[e],e,o),s[e]=isNaN(a[e])?0:+u(o[e],e,o)}}return"function"!=typeof t&&(t=$n(+t)),null==e&&(e=0),null==r&&(r=0),null==n&&(n=0),c.initialize=function(t,...e){o=t,i=e.find(t=>[1,2,3].includes(t))||2,h()},c.strength=function(t){return arguments.length?(u="function"==typeof t?t:$n(+t),h(),c):u},c.radius=function(e){return arguments.length?(t="function"==typeof e?e:$n(+e),h(),c):t},c.x=function(t){return arguments.length?(e=+t,c):e},c.y=function(t){return arguments.length?(r=+t,c):r},c.z=function(t){return arguments.length?(n=+t,c):n},c}function uo(t){var e,r,n,o=$n(.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=$n(null==t?0:+t)),i.initialize=function(t){e=t,s()},i.strength=function(t){return arguments.length?(o="function"==typeof t?t:$n(+t),s(),i):o},i.x=function(e){return arguments.length?(t="function"==typeof e?e:$n(+e),s(),i):t},i}function co(t){var e,r,n,o=$n(.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=$n(null==t?0:+t)),i.initialize=function(t){e=t,s()},i.strength=function(t){return arguments.length?(o="function"==typeof t?t:$n(+t),s(),i):o},i.y=function(e){return arguments.length?(t="function"==typeof e?e:$n(+e),s(),i):t},i}function ho(t){var e,r,n,o=$n(.1);function i(t){for(var o,i=0,s=e.length;i<s;++i)(o=e[i]).vz+=(n[i]-o.z)*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=$n(null==t?0:+t)),i.initialize=function(t){e=t,s()},i.strength=function(t){return arguments.length?(o="function"==typeof t?t:$n(+t),s(),i):o},i.z=function(e){return arguments.length?(t="function"==typeof e?e:$n(+e),s(),i):t},i}var lo,fo,go,po,vo,mo,yo,wo,xo,bo,Eo,Mo,No,_o,ko,So,Ao,Oo,zo,jo,Co,Io,Ro,To,Po,Fo,Lo,Do,qo,Bo,Vo,Uo,$o,Go,Wo,Yo,Ho,Xo,Qo,Ko,Jo,Zo,ti,ei,ri,ni,oi,ii,si,ai,ui,ci,hi,li,di,fi,gi,pi,vi,mi,yi,wi,xi,bi,Ei,Mi,Ni,_i,ki,Si,Ai,Oi,zi,ji,Ci,Ii,Ri,Ti,Pi,Fi,Li,Di,qi,Bi,Vi,Ui,$i,Gi,Wi,Yi,Hi,Xi,Qi,Ki,Ji,Zi,ts,es,rs,ns,os,is,ss,as,us,cs,hs,ls,ds="undefined"!=typeof globalThis?globalThis:"undefined"!=typeof window?window:"undefined"!=typeof global?global:"undefined"!=typeof self?self:{};function fs(t){return t&&t.__esModule&&Object.prototype.hasOwnProperty.call(t,"default")?t.default:t}function gs(t){if(Object.prototype.hasOwnProperty.call(t,"__esModule"))return t;var e=t.default;if("function"==typeof e){var r=function t(){var r=!1;try{r=this instanceof t}catch{}return r?Reflect.construct(e,arguments,this.constructor):e.apply(this,arguments)};r.prototype=e.prototype}else r={};return Object.defineProperty(r,"__esModule",{value:!0}),Object.keys(t).forEach(function(e){var n=Object.getOwnPropertyDescriptor(t,e);Object.defineProperty(r,e,n.get?n:{enumerable:!0,get:function(){return t[e]}})}),r}function ps(){if(po)return go;return po=1,go=function(t,e){return t===e||t!=t&&e!=e}}function vs(){if(mo)return vo;mo=1;var t=ps();return vo=function(e,r){for(var n=e.length;n--;)if(t(e[n][0],r))return n;return-1}}function ms(){if(So)return ko;So=1;var t=fo?lo:(fo=1,lo=function(){this.__data__=[],this.size=0}),e=function(){if(wo)return yo;wo=1;var t=vs(),e=Array.prototype.splice;return yo=function(r){var n=this.__data__,o=t(n,r);return!(o<0||(o==n.length-1?n.pop():e.call(n,o,1),--this.size,0))},yo}(),r=function(){if(bo)return xo;bo=1;var t=vs();return xo=function(e){var r=this.__data__,n=t(r,e);return n<0?void 0:r[n][1]},xo}(),n=function(){if(Mo)return Eo;Mo=1;var t=vs();return Eo=function(e){return t(this.__data__,e)>-1}}(),o=function(){if(_o)return No;_o=1;var t=vs();return No=function(e,r){var n=this.__data__,o=t(n,e);return o<0?(++this.size,n.push([e,r])):n[o][1]=r,this},No}();function i(t){var e=-1,r=null==t?0:t.length;for(this.clear();++e<r;){var n=t[e];this.set(n[0],n[1])}}return i.prototype.clear=t,i.prototype.delete=e,i.prototype.get=r,i.prototype.has=n,i.prototype.set=o,ko=i}function ys(){if(Fo)return Po;Fo=1;var t="object"==typeof ds&&ds&&ds.Object===Object&&ds;return Po=t}function ws(){if(Do)return Lo;Do=1;var t=ys(),e="object"==typeof self&&self&&self.Object===Object&&self,r=t||e||Function("return this")();return Lo=r}function xs(){if(Bo)return qo;Bo=1;var t=ws().Symbol;return qo=t}function bs(){if(Yo)return Wo;Yo=1;var t=xs(),e=function(){if(Uo)return Vo;Uo=1;var t=xs(),e=Object.prototype,r=e.hasOwnProperty,n=e.toString,o=t?t.toStringTag:void 0;return Vo=function(t){var e=r.call(t,o),i=t[o];try{t[o]=void 0;var s=!0}catch(t){}var a=n.call(t);return s&&(e?t[o]=i:delete t[o]),a}}(),r=function(){if(Go)return $o;Go=1;var t=Object.prototype.toString;return $o=function(e){return t.call(e)}}(),n=t?t.toStringTag:void 0;return Wo=function(t){return null==t?void 0===t?"[object Undefined]":"[object Null]":n&&n in Object(t)?e(t):r(t)}}function Es(){if(Xo)return Ho;return Xo=1,Ho=function(t){var e=typeof t;return null!=t&&("object"==e||"function"==e)}}function Ms(){if(Ko)return Qo;Ko=1;var t=bs(),e=Es();return Qo=function(r){if(!e(r))return!1;var n=t(r);return"[object Function]"==n||"[object GeneratorFunction]"==n||"[object AsyncFunction]"==n||"[object Proxy]"==n}}function Ns(){if(ei)return ti;ei=1;var t,e=function(){if(Zo)return Jo;Zo=1;var t=ws()["__core-js_shared__"];return Jo=t}(),r=(t=/[^.]+$/.exec(e&&e.keys&&e.keys.IE_PROTO||""))?"Symbol(src)_1."+t:"";return ti=function(t){return!!r&&r in t}}function _s(){if(ni)return ri;ni=1;var t=Function.prototype.toString;return ri=function(e){if(null!=e){try{return t.call(e)}catch(t){}try{return e+""}catch(t){}}return""}}function ks(){if(ci)return ui;ci=1;var t=function(){if(ii)return oi;ii=1;var t=Ms(),e=Ns(),r=Es(),n=_s(),o=/^\[object .+?Constructor\]$/,i=Function.prototype,s=Object.prototype,a=i.toString,u=s.hasOwnProperty,c=RegExp("^"+a.call(u).replace(/[\\^$.*+?()[\]{}|]/g,"\\$&").replace(/hasOwnProperty|(function).*?(?=\\\()| for .+?(?=\\\])/g,"$1.*?")+"$");return oi=function(i){return!(!r(i)||e(i))&&(t(i)?c:o).test(n(i))}}(),e=ai?si:(ai=1,si=function(t,e){return null==t?void 0:t[e]});return ui=function(r,n){var o=e(r,n);return t(o)?o:void 0}}function Ss(){if(li)return hi;li=1;var t=ks()(ws(),"Map");return hi=t}function As(){if(fi)return di;fi=1;var t=ks()(Object,"create");return di=t}function Os(){if(_i)return Ni;_i=1;var t=function(){if(pi)return gi;pi=1;var t=As();return gi=function(){this.__data__=t?t(null):{},this.size=0}}(),e=mi?vi:(mi=1,vi=function(t){var e=this.has(t)&&delete this.__data__[t];return this.size-=e?1:0,e}),r=function(){if(wi)return yi;wi=1;var t=As(),e=Object.prototype.hasOwnProperty;return yi=function(r){var n=this.__data__;if(t){var o=n[r];return"__lodash_hash_undefined__"===o?void 0:o}return e.call(n,r)?n[r]:void 0}}(),n=function(){if(bi)return xi;bi=1;var t=As(),e=Object.prototype.hasOwnProperty;return xi=function(r){var n=this.__data__;return t?void 0!==n[r]:e.call(n,r)}}(),o=function(){if(Mi)return Ei;Mi=1;var t=As();return Ei=function(e,r){var n=this.__data__;return this.size+=this.has(e)?0:1,n[e]=t&&void 0===r?"__lodash_hash_undefined__":r,this}}();function i(t){var e=-1,r=null==t?0:t.length;for(this.clear();++e<r;){var n=t[e];this.set(n[0],n[1])}}return i.prototype.clear=t,i.prototype.delete=e,i.prototype.get=r,i.prototype.has=n,i.prototype.set=o,Ni=i}function zs(){if(ji)return zi;ji=1;var t=Oi?Ai:(Oi=1,Ai=function(t){var e=typeof t;return"string"==e||"number"==e||"symbol"==e||"boolean"==e?"__proto__"!==t:null===t});return zi=function(e,r){var n=e.__data__;return t(r)?n["string"==typeof r?"string":"hash"]:n.map}}function js(){if(Bi)return qi;Bi=1;var t=function(){if(Si)return ki;Si=1;var t=Os(),e=ms(),r=Ss();return ki=function(){this.size=0,this.__data__={hash:new t,map:new(r||e),string:new t}}}(),e=function(){if(Ii)return Ci;Ii=1;var t=zs();return Ci=function(e){var r=t(this,e).delete(e);return this.size-=r?1:0,r}}(),r=function(){if(Ti)return Ri;Ti=1;var t=zs();return Ri=function(e){return t(this,e).get(e)}}(),n=function(){if(Fi)return Pi;Fi=1;var t=zs();return Pi=function(e){return t(this,e).has(e)}}(),o=function(){if(Di)return Li;Di=1;var t=zs();return Li=function(e,r){var n=t(this,e),o=n.size;return n.set(e,r),this.size+=n.size==o?0:1,this}}();function i(t){var e=-1,r=null==t?0:t.length;for(this.clear();++e<r;){var n=t[e];this.set(n[0],n[1])}}return i.prototype.clear=t,i.prototype.delete=e,i.prototype.get=r,i.prototype.has=n,i.prototype.set=o,qi=i}function Cs(){if(Gi)return $i;Gi=1;var t=ms(),e=function(){if(Oo)return Ao;Oo=1;var t=ms();return Ao=function(){this.__data__=new t,this.size=0}}(),r=jo?zo:(jo=1,zo=function(t){var e=this.__data__,r=e.delete(t);return this.size=e.size,r}),n=Io?Co:(Io=1,Co=function(t){return this.__data__.get(t)}),o=To?Ro:(To=1,Ro=function(t){return this.__data__.has(t)}),i=function(){if(Ui)return Vi;Ui=1;var t=ms(),e=Ss(),r=js();return Vi=function(n,o){var i=this.__data__;if(i instanceof t){var s=i.__data__;if(!e||s.length<199)return s.push([n,o]),this.size=++i.size,this;i=this.__data__=new r(s)}return i.set(n,o),this.size=i.size,this}}();function s(e){var r=this.__data__=new t(e);this.size=r.size}return s.prototype.clear=e,s.prototype.delete=r,s.prototype.get=n,s.prototype.has=o,s.prototype.set=i,$i=s}function Is(){if(Yi)return Wi;return Yi=1,Wi=function(t,e){for(var r=-1,n=null==t?0:t.length;++r<n&&!1!==e(t[r],r,t););return t},Wi}function Rs(){if(Xi)return Hi;Xi=1;var t=ks(),e=function(){try{var e=t(Object,"defineProperty");return e({},"",{}),e}catch(t){}}();return Hi=e}function Ts(){if(Ki)return Qi;Ki=1;var t=Rs();return Qi=function(e,r,n){"__proto__"==r&&t?t(e,r,{configurable:!0,enumerable:!0,value:n,writable:!0}):e[r]=n}}function Ps(){if(Zi)return Ji;Zi=1;var t=Ts(),e=ps(),r=Object.prototype.hasOwnProperty;return Ji=function(n,o,i){var s=n[o];r.call(n,o)&&e(s,i)&&(void 0!==i||o in n)||t(n,o,i)}}function Fs(){if(es)return ts;es=1;var t=Ps(),e=Ts();return ts=function(r,n,o,i){var s=!o;o||(o={});for(var a=-1,u=n.length;++a<u;){var c=n[a],h=i?i(o[c],r[c],c,o,r):void 0;void 0===h&&(h=r[c]),s?e(o,c,h):t(o,c,h)}return o},ts}function Ls(){if(is)return os;return is=1,os=function(t){return null!=t&&"object"==typeof t}}function Ds(){if(cs)return us;cs=1;var t=function(){if(as)return ss;as=1;var t=bs(),e=Ls();return ss=function(r){return e(r)&&"[object Arguments]"==t(r)}}(),e=Ls(),r=Object.prototype,n=r.hasOwnProperty,o=r.propertyIsEnumerable,i=t(function(){return arguments}())?t:function(t){return e(t)&&n.call(t,"callee")&&!o.call(t,"callee")};return us=i}function qs(){if(ls)return hs;ls=1;var t=Array.isArray;return hs=t}var Bs,Vs,Us,$s,Gs,Ws,Ys,Hs,Xs,Qs,Ks,Js={exports:{}};function Zs(){return Us||(Us=1,function(t,e){var r=ws(),n=Vs?Bs:(Vs=1,Bs=function(){return!1}),o=e&&!e.nodeType&&e,i=o&&t&&!t.nodeType&&t,s=i&&i.exports===o?r.Buffer:void 0,a=(s?s.isBuffer:void 0)||n;t.exports=a}(Js,Js.exports)),Js.exports}function ta(){if(Gs)return $s;Gs=1;var t=/^(?:0|[1-9]\d*)$/;return $s=function(e,r){var n=typeof e;return!!(r=null==r?9007199254740991:r)&&("number"==n||"symbol"!=n&&t.test(e))&&e>-1&&e%1==0&&e<r}}function ea(){if(Ys)return Ws;Ys=1;return Ws=function(t){return"number"==typeof t&&t>-1&&t%1==0&&t<=9007199254740991}}function ra(){if(Ks)return Qs;return Ks=1,Qs=function(t){return function(e){return t(e)}}}var na,oa,ia,sa,aa,ua,ca,ha,la,da,fa,ga,pa,va,ma,ya,wa,xa,ba,Ea,Ma,Na,_a,ka,Sa,Aa,Oa,za={exports:{}};function ja(){return na||(na=1,t=za,e=za.exports,r=ys(),n=e&&!e.nodeType&&e,o=n&&t&&!t.nodeType&&t,i=o&&o.exports===n&&r.process,s=function(){try{var t=o&&o.require&&o.require("util").types;return t||i&&i.binding&&i.binding("util")}catch(t){}}(),t.exports=s),za.exports;var t,e,r,n,o,i,s}function Ca(){if(ia)return oa;ia=1;var t=function(){if(Xs)return Hs;Xs=1;var t=bs(),e=ea(),r=Ls(),n={};return n["[object Float32Array]"]=n["[object Float64Array]"]=n["[object Int8Array]"]=n["[object Int16Array]"]=n["[object Int32Array]"]=n["[object Uint8Array]"]=n["[object Uint8ClampedArray]"]=n["[object Uint16Array]"]=n["[object Uint32Array]"]=!0,n["[object Arguments]"]=n["[object Array]"]=n["[object ArrayBuffer]"]=n["[object Boolean]"]=n["[object DataView]"]=n["[object Date]"]=n["[object Error]"]=n["[object Function]"]=n["[object Map]"]=n["[object Number]"]=n["[object Object]"]=n["[object RegExp]"]=n["[object Set]"]=n["[object String]"]=n["[object WeakMap]"]=!1,Hs=function(o){return r(o)&&e(o.length)&&!!n[t(o)]}}(),e=ra(),r=ja(),n=r&&r.isTypedArray,o=n?e(n):t;return oa=o}function Ia(){if(aa)return sa;aa=1;var t=(ns||(ns=1,rs=function(t,e){for(var r=-1,n=Array(t);++r<t;)n[r]=e(r);return n}),rs),e=Ds(),r=qs(),n=Zs(),o=ta(),i=Ca(),s=Object.prototype.hasOwnProperty;return sa=function(a,u){var c=r(a),h=!c&&e(a),l=!c&&!h&&n(a),d=!c&&!h&&!l&&i(a),f=c||h||l||d,g=f?t(a.length,String):[],p=g.length;for(var v in a)!u&&!s.call(a,v)||f&&("length"==v||l&&("offset"==v||"parent"==v)||d&&("buffer"==v||"byteLength"==v||"byteOffset"==v)||o(v,p))||g.push(v);return g},sa}function Ra(){if(ca)return ua;ca=1;var t=Object.prototype;return ua=function(e){var r=e&&e.constructor;return e===("function"==typeof r&&r.prototype||t)}}function Ta(){if(la)return ha;return la=1,ha=function(t,e){return function(r){return t(e(r))}}}function Pa(){if(pa)return ga;pa=1;var t=Ra(),e=function(){if(fa)return da;fa=1;var t=Ta()(Object.keys,Object);return da=t}(),r=Object.prototype.hasOwnProperty;return ga=function(n){if(!t(n))return e(n);var o=[];for(var i in Object(n))r.call(n,i)&&"constructor"!=i&&o.push(i);return o}}function Fa(){if(ma)return va;ma=1;var t=Ms(),e=ea();return va=function(r){return null!=r&&e(r.length)&&!t(r)}}function La(){if(wa)return ya;wa=1;var t=Ia(),e=Pa(),r=Fa();return ya=function(n){return r(n)?t(n):e(n)}}function Da(){if(_a)return Na;_a=1;var t=Es(),e=Ra(),r=Ma?Ea:(Ma=1,Ea=function(t){var e=[];if(null!=t)for(var r in Object(t))e.push(r);return e}),n=Object.prototype.hasOwnProperty;return Na=function(o){if(!t(o))return r(o);var i=e(o),s=[];for(var a in o)("constructor"!=a||!i&&n.call(o,a))&&s.push(a);return s}}function qa(){if(Sa)return ka;Sa=1;var t=Ia(),e=Da(),r=Fa();return ka=function(n){return r(n)?t(n,!0):e(n)}}var Ba,Va,Ua,$a,Ga,Wa,Ya,Ha,Xa,Qa,Ka,Ja,Za,tu,eu,ru,nu,ou,iu,su,au,uu,cu,hu,lu,du,fu,gu,pu,vu,mu,yu,wu,xu,bu,Eu,Mu,Nu,_u,ku,Su,Au,Ou,zu,ju,Cu,Iu,Ru,Tu,Pu,Fu,Lu,Du,qu,Bu,Vu,Uu,$u,Gu,Wu,Yu,Hu,Xu,Qu,Ku,Ju,Zu,tc,ec,rc,nc,oc,ic,sc,ac,uc,cc,hc,lc,dc,fc,gc,pc,vc,mc,yc,wc,xc,bc,Ec,Mc,Nc,_c,kc,Sc,Ac,Oc,zc,jc,Cc,Ic,Rc,Tc,Pc,Fc,Lc,Dc,qc,Bc,Vc,Uc,$c,Gc,Wc,Yc,Hc,Xc,Qc,Kc,Jc,Zc,th,eh,rh,nh,oh,ih,sh,ah,uh,ch,hh,lh,dh,fh,gh,ph,vh,mh,yh,wh,xh,bh,Eh,Mh,Nh,_h,kh,Sh,Ah,Oh,zh,jh,Ch,Ih,Rh,Th,Ph,Fh,Lh,Dh,qh,Bh,Vh,Uh,$h,Gh,Wh,Yh,Hh,Xh,Qh,Kh,Jh,Zh,tl,el,rl,nl,ol,il,sl,al,ul,cl,hl,ll,dl,fl,gl,pl,vl,ml,yl,wl,xl,bl,El,Ml,Nl,_l,kl,Sl,Al,Ol,zl,jl,Cl,Il,Rl,Tl,Pl,Fl,Ll,Dl,ql,Bl,Vl,Ul,$l,Gl,Wl,Yl,Hl,Xl,Ql,Kl,Jl,Zl,td,ed,rd,nd,od,id,sd,ad,ud,cd,hd,ld,dd,fd,gd,pd,vd,md,yd,wd,xd,bd,Ed,Md,Nd,_d,kd,Sd,Ad,Od,zd,jd,Cd,Id,Rd,Td,Pd,Fd,Ld,Dd,qd,Bd,Vd,Ud,$d,Gd,Wd,Yd,Hd,Xd,Qd,Kd,Jd,Zd,tf,ef,rf,nf,of,sf,af,uf,cf,hf,lf,df,ff,gf,pf,vf,mf,yf,wf,xf,bf,Ef,Mf,Nf,_f,kf,Sf,Af,Of,zf,jf,Cf,If,Rf,Tf,Pf,Ff,Lf,Df,qf,Bf,Vf,Uf,$f,Gf,Wf,Yf,Hf,Xf,Qf,Kf,Jf,Zf,tg,eg,rg,ng,og,ig,sg,ag,ug,cg,hg,lg,dg,fg,gg,pg,vg,mg,yg,wg,xg,bg,Eg,Mg,Ng,_g,kg,Sg,Ag,Og,zg,jg,Cg,Ig,Rg,Tg,Pg,Fg,Lg,Dg,qg,Bg,Vg,Ug,$g,Gg,Wg,Yg,Hg,Xg,Qg,Kg,Jg,Zg,tp,ep,rp,np,op,ip,sp,ap,up,cp,hp,lp,dp,fp,gp,pp,vp,mp,yp,wp,xp,bp,Ep,Mp,Np,_p,kp,Sp,Ap,Op,zp,jp,Cp,Ip,Rp,Tp,Pp,Fp,Lp,Dp,qp,Bp={exports:{}};function Vp(){return Ba||(Ba=1,t=Bp,e=Bp.exports,r=ws(),n=e&&!e.nodeType&&e,o=n&&t&&!t.nodeType&&t,i=o&&o.exports===n?r.Buffer:void 0,s=i?i.allocUnsafe:void 0,t.exports=function(t,e){if(e)return t.slice();var r=t.length,n=s?s(r):new t.constructor(r);return t.copy(n),n}),Bp.exports;var t,e,r,n,o,i,s}function Up(){if(Ua)return Va;return Ua=1,Va=function(t,e){var r=-1,n=t.length;for(e||(e=Array(n));++r<n;)e[r]=t[r];return e},Va}function $p(){if(Ga)return $a;return Ga=1,$a=function(t,e){for(var r=-1,n=null==t?0:t.length,o=0,i=[];++r<n;){var s=t[r];e(s,r,t)&&(i[o++]=s)}return i},$a}function Gp(){if(Ya)return Wa;return Ya=1,Wa=function(){return[]}}function Wp(){if(Xa)return Ha;Xa=1;var t=$p(),e=Gp(),r=Object.prototype.propertyIsEnumerable,n=Object.getOwnPropertySymbols;return Ha=n?function(e){return null==e?[]:(e=Object(e),t(n(e),function(t){return r.call(e,t)}))}:e}function Yp(){if(Za)return Ja;return Za=1,Ja=function(t,e){for(var r=-1,n=e.length,o=t.length;++r<n;)t[o+r]=e[r];return t},Ja}function Hp(){if(eu)return tu;eu=1;var t=Ta()(Object.getPrototypeOf,Object);return tu=t}function Xp(){if(nu)return ru;nu=1;var t=Yp(),e=Hp(),r=Wp(),n=Gp(),o=Object.getOwnPropertySymbols;return ru=o?function(n){for(var o=[];n;)t(o,r(n)),n=e(n);return o}:n}function Qp(){if(au)return su;au=1;var t=Yp(),e=qs();return su=function(r,n,o){var i=n(r);return e(r)?i:t(i,o(r))}}function Kp(){if(cu)return uu;cu=1;var t=Qp(),e=Wp(),r=La();return uu=function(n){return t(n,r,e)}}function Jp(){if(mu)return vu;mu=1;var t=ks()(ws(),"Set");return vu=t}function Zp(){if(bu)return xu;bu=1;var t=function(){if(fu)return du;fu=1;var t=ks()(ws(),"DataView");return du=t}(),e=Ss(),r=function(){if(pu)return gu;pu=1;var t=ks()(ws(),"Promise");return gu=t}(),n=Jp(),o=function(){if(wu)return yu;wu=1;var t=ks()(ws(),"WeakMap");return yu=t}(),i=bs(),s=_s(),a="[object Map]",u="[object Promise]",c="[object Set]",h="[object WeakMap]",l="[object DataView]",d=s(t),f=s(e),g=s(r),p=s(n),v=s(o),m=i;return(t&&m(new t(new ArrayBuffer(1)))!=l||e&&m(new e)!=a||r&&m(r.resolve())!=u||n&&m(new n)!=c||o&&m(new o)!=h)&&(m=function(t){var e=i(t),r="[object Object]"==e?t.constructor:void 0,n=r?s(r):"";if(n)switch(n){case d:return l;case f:return a;case g:return u;case p:return c;case v:return h}return e}),xu=m}function tv(){if(_u)return Nu;_u=1;var t=ws().Uint8Array;return Nu=t}function ev(){if(Su)return ku;Su=1;var t=tv();return ku=function(e){var r=new e.constructor(e.byteLength);return new t(r).set(new t(e)),r}}function rv(){if(Tu)return Ru;Tu=1;var t=ev();return Ru=function(e,r){var n=r?t(e.buffer):e.buffer;return new e.constructor(n,e.byteOffset,e.length)}}function nv(){if(Fu)return Pu;Fu=1;var t=ev(),e=function(){if(Ou)return Au;Ou=1;var t=ev();return Au=function(e,r){var n=r?t(e.buffer):e.buffer;return new e.constructor(n,e.byteOffset,e.byteLength)}}(),r=function(){if(ju)return zu;ju=1;var t=/\w*$/;return zu=function(e){var r=new e.constructor(e.source,t.exec(e));return r.lastIndex=e.lastIndex,r}}(),n=function(){if(Iu)return Cu;Iu=1;var t=xs(),e=t?t.prototype:void 0,r=e?e.valueOf:void 0;return Cu=function(t){return r?Object(r.call(t)):{}}}(),o=rv();return Pu=function(i,s,a){var u=i.constructor;switch(s){case"[object ArrayBuffer]":return t(i);case"[object Boolean]":case"[object Date]":return new u(+i);case"[object DataView]":return e(i,a);case"[object Float32Array]":case"[object Float64Array]":case"[object Int8Array]":case"[object Int16Array]":case"[object Int32Array]":case"[object Uint8Array]":case"[object Uint8ClampedArray]":case"[object Uint16Array]":case"[object Uint32Array]":return o(i,a);case"[object Map]":case"[object Set]":return new u;case"[object Number]":case"[object String]":return new u(i);case"[object RegExp]":return r(i);case"[object Symbol]":return n(i)}}}function ov(){if(Du)return Lu;Du=1;var t=Es(),e=Object.create,r=function(){function r(){}return function(n){if(!t(n))return{};if(e)return e(n);r.prototype=n;var o=new r;return r.prototype=void 0,o}}();return Lu=r}function iv(){if(Bu)return qu;Bu=1;var t=ov(),e=Hp(),r=Ra();return qu=function(n){return"function"!=typeof n.constructor||r(n)?{}:t(e(n))}}function sv(){if(Gu)return $u;Gu=1;var t=function(){if(Uu)return Vu;Uu=1;var t=Zp(),e=Ls();return Vu=function(r){return e(r)&&"[object Map]"==t(r)}}(),e=ra(),r=ja(),n=r&&r.isMap,o=n?e(n):t;return $u=o}function av(){if(Xu)return Hu;Xu=1;var t=function(){if(Yu)return Wu;Yu=1;var t=Zp(),e=Ls();return Wu=function(r){return e(r)&&"[object Set]"==t(r)}}(),e=ra(),r=ja(),n=r&&r.isSet,o=n?e(n):t;return Hu=o}function uv(){if(Ku)return Qu;Ku=1;var t=Cs(),e=Is(),r=Ps(),n=function(){if(ba)return xa;ba=1;var t=Fs(),e=La();return xa=function(r,n){return r&&t(n,e(n),r)}}(),o=function(){if(Oa)return Aa;Oa=1;var t=Fs(),e=qa();return Aa=function(r,n){return r&&t(n,e(n),r)}}(),i=Vp(),s=Up(),a=function(){if(Ka)return Qa;Ka=1;var t=Fs(),e=Wp();return Qa=function(r,n){return t(r,e(r),n)}}(),u=function(){if(iu)return ou;iu=1;var t=Fs(),e=Xp();return ou=function(r,n){return t(r,e(r),n)}}(),c=Kp(),h=function(){if(lu)return hu;lu=1;var t=Qp(),e=Xp(),r=qa();return hu=function(n){return t(n,r,e)}}(),l=Zp(),d=function(){if(Mu)return Eu;Mu=1;var t=Object.prototype.hasOwnProperty;return Eu=function(e){var r=e.length,n=new e.constructor(r);return r&&"string"==typeof e[0]&&t.call(e,"index")&&(n.index=e.index,n.input=e.input),n}}(),f=nv(),g=iv(),p=qs(),v=Zs(),m=sv(),y=Es(),w=av(),x=La(),b=qa(),E="[object Arguments]",M="[object Function]",N="[object Object]",_={};return _[E]=_["[object Array]"]=_["[object ArrayBuffer]"]=_["[object DataView]"]=_["[object Boolean]"]=_["[object Date]"]=_["[object Float32Array]"]=_["[object Float64Array]"]=_["[object Int8Array]"]=_["[object Int16Array]"]=_["[object Int32Array]"]=_["[object Map]"]=_["[object Number]"]=_[N]=_["[object RegExp]"]=_["[object Set]"]=_["[object String]"]=_["[object Symbol]"]=_["[object Uint8Array]"]=_["[object Uint8ClampedArray]"]=_["[object Uint16Array]"]=_["[object Uint32Array]"]=!0,_["[object Error]"]=_[M]=_["[object WeakMap]"]=!1,Qu=function k(S,A,O,z,j,C){var I,R=1&A,T=2&A,P=4&A;if(O&&(I=j?O(S,z,j,C):O(S)),void 0!==I)return I;if(!y(S))return S;var F=p(S);if(F){if(I=d(S),!R)return s(S,I)}else{var L=l(S),D=L==M||"[object GeneratorFunction]"==L;if(v(S))return i(S,R);if(L==N||L==E||D&&!j){if(I=T||D?{}:g(S),!R)return T?u(S,o(I,S)):a(S,n(I,S))}else{if(!_[L])return j?S:{};I=f(S,L,R)}}C||(C=new t);var q=C.get(S);if(q)return q;C.set(S,I),w(S)?S.forEach(function(t){I.add(k(t,A,O,t,S,C))}):m(S)&&S.forEach(function(t,e){I.set(e,k(t,A,O,e,S,C))});var B=F?void 0:(P?T?h:c:T?b:x)(S);return e(B||S,function(t,e){B&&(t=S[e=t]),r(I,e,k(t,A,O,e,S,C))}),I},Qu}function cv(){if(Zu)return Ju;Zu=1;var t=uv();return Ju=function(e){return t(e,4)}}function hv(){if(ec)return tc;return ec=1,tc=function(t){return function(){return t}}}function lv(){if(ic)return oc;ic=1;var t=(nc||(nc=1,rc=function(t){return function(e,r,n){for(var o=-1,i=Object(e),s=n(e),a=s.length;a--;){var u=s[t?a:++o];if(!1===r(i[u],u,i))break}return e}}),rc),e=t();return oc=e}function dv(){if(ac)return sc;ac=1;var t=lv(),e=La();return sc=function(r,n){return r&&t(r,n,e)}}function fv(){if(lc)return hc;lc=1;var t=dv(),e=function(){if(cc)return uc;cc=1;var t=Fa();return uc=function(e,r){return function(n,o){if(null==n)return n;if(!t(n))return e(n,o);for(var i=n.length,s=r?i:-1,a=Object(n);(r?s--:++s<i)&&!1!==o(a[s],s,a););return n}},uc}(),r=e(t);return hc=r}function gv(){if(fc)return dc;return fc=1,dc=function(t){return t}}function pv(){if(pc)return gc;pc=1;var t=gv();return gc=function(e){return"function"==typeof e?e:t}}function vv(){if(mc)return vc;mc=1;var t=Is(),e=fv(),r=pv(),n=qs();return vc=function(o,i){return(n(o)?t:e)(o,r(i))}}function mv(){return wc?yc:(wc=1,yc=vv())}function yv(){if(Sc)return kc;Sc=1;var t=js(),e=Mc?Ec:(Mc=1,Ec=function(t){return this.__data__.set(t,"__lodash_hash_undefined__"),this}),r=_c?Nc:(_c=1,Nc=function(t){return this.__data__.has(t)});function n(e){var r=-1,n=null==e?0:e.length;for(this.__data__=new t;++r<n;)this.add(e[r])}return n.prototype.add=n.prototype.push=e,n.prototype.has=r,kc=n}function wv(){if(jc)return zc;return jc=1,zc=function(t,e){return t.has(e)}}function xv(){if(Ic)return Cc;Ic=1;var t=yv(),e=(Oc||(Oc=1,Ac=function(t,e){for(var r=-1,n=null==t?0:t.length;++r<n;)if(e(t[r],r,t))return!0;return!1}),Ac),r=wv();return Cc=function(n,o,i,s,a,u){var c=1&i,h=n.length,l=o.length;if(h!=l&&!(c&&l>h))return!1;var d=u.get(n),f=u.get(o);if(d&&f)return d==o&&f==n;var g=-1,p=!0,v=2&i?new t:void 0;for(u.set(n,o),u.set(o,n);++g<h;){var m=n[g],y=o[g];if(s)var w=c?s(y,m,g,o,n,u):s(m,y,g,n,o,u);if(void 0!==w){if(w)continue;p=!1;break}if(v){if(!e(o,function(t,e){if(!r(v,e)&&(m===t||a(m,t,i,s,u)))return v.push(e)})){p=!1;break}}else if(m!==y&&!a(m,y,i,s,u)){p=!1;break}}return u.delete(n),u.delete(o),p},Cc}function bv(){if(Fc)return Pc;return Fc=1,Pc=function(t){var e=-1,r=Array(t.size);return t.forEach(function(t){r[++e]=t}),r},Pc}function Ev(){if(Dc)return Lc;Dc=1;var t=xs(),e=tv(),r=ps(),n=xv(),o=(Tc||(Tc=1,Rc=function(t){var e=-1,r=Array(t.size);return t.forEach(function(t,n){r[++e]=[n,t]}),r}),Rc),i=bv(),s=t?t.prototype:void 0,a=s?s.valueOf:void 0;return Lc=function(t,s,u,c,h,l,d){switch(u){case"[object DataView]":if(t.byteLength!=s.byteLength||t.byteOffset!=s.byteOffset)return!1;t=t.buffer,s=s.buffer;case"[object ArrayBuffer]":return!(t.byteLength!=s.byteLength||!l(new e(t),new e(s)));case"[object Boolean]":case"[object Date]":case"[object Number]":return r(+t,+s);case"[object Error]":return t.name==s.name&&t.message==s.message;case"[object RegExp]":case"[object String]":return t==s+"";case"[object Map]":var f=o;case"[object Set]":var g=1&c;if(f||(f=i),t.size!=s.size&&!g)return!1;var p=d.get(t);if(p)return p==s;c|=2,d.set(t,s);var v=n(f(t),f(s),c,h,l,d);return d.delete(t),v;case"[object Symbol]":if(a)return a.call(t)==a.call(s)}return!1}}function Mv(){if(Uc)return Vc;Uc=1;var t=Cs(),e=xv(),r=Ev(),n=function(){if(Bc)return qc;Bc=1;var t=Kp(),e=Object.prototype.hasOwnProperty;return qc=function(r,n,o,i,s,a){var u=1&o,c=t(r),h=c.length;if(h!=t(n).length&&!u)return!1;for(var l=h;l--;){var d=c[l];if(!(u?d in n:e.call(n,d)))return!1}var f=a.get(r),g=a.get(n);if(f&&g)return f==n&&g==r;var p=!0;a.set(r,n),a.set(n,r);for(var v=u;++l<h;){var m=r[d=c[l]],y=n[d];if(i)var w=u?i(y,m,d,n,r,a):i(m,y,d,r,n,a);if(!(void 0===w?m===y||s(m,y,o,i,a):w)){p=!1;break}v||(v="constructor"==d)}if(p&&!v){var x=r.constructor,b=n.constructor;x==b||!("constructor"in r)||!("constructor"in n)||"function"==typeof x&&x instanceof x&&"function"==typeof b&&b instanceof b||(p=!1)}return a.delete(r),a.delete(n),p},qc}(),o=Zp(),i=qs(),s=Zs(),a=Ca(),u="[object Arguments]",c="[object Array]",h="[object Object]",l=Object.prototype.hasOwnProperty;return Vc=function(d,f,g,p,v,m){var y=i(d),w=i(f),x=y?c:o(d),b=w?c:o(f),E=(x=x==u?h:x)==h,M=(b=b==u?h:b)==h,N=x==b;if(N&&s(d)){if(!s(f))return!1;y=!0,E=!1}if(N&&!E)return m||(m=new t),y||a(d)?e(d,f,g,p,v,m):r(d,f,x,g,p,v,m);if(!(1&g)){var _=E&&l.call(d,"__wrapped__"),k=M&&l.call(f,"__wrapped__");if(_||k){var S=_?d.value():d,A=k?f.value():f;return m||(m=new t),v(S,A,g,p,m)}}return!!N&&(m||(m=new t),n(d,f,g,p,v,m))}}function Nv(){if(Gc)return $c;Gc=1;var t=Mv(),e=Ls();return $c=function r(n,o,i,s,a){return n===o||(null==n||null==o||!e(n)&&!e(o)?n!=n&&o!=o:t(n,o,i,s,r,a))},$c}function _v(){if(Xc)return Hc;Xc=1;var t=Es();return Hc=function(e){return e==e&&!t(e)}}function kv(){if(Zc)return Jc;return Zc=1,Jc=function(t,e){return function(r){return null!=r&&(r[t]===e&&(void 0!==e||t in Object(r)))}}}function Sv(){if(eh)return th;eh=1;var t=function(){if(Yc)return Wc;Yc=1;var t=Cs(),e=Nv();return Wc=function(r,n,o,i){var s=o.length,a=s,u=!i;if(null==r)return!a;for(r=Object(r);s--;){var c=o[s];if(u&&c[2]?c[1]!==r[c[0]]:!(c[0]in r))return!1}for(;++s<a;){var h=(c=o[s])[0],l=r[h],d=c[1];if(u&&c[2]){if(void 0===l&&!(h in r))return!1}else{var f=new t;if(i)var g=i(l,d,h,r,n,f);if(!(void 0===g?e(d,l,3,i,f):g))return!1}}return!0},Wc}(),e=function(){if(Kc)return Qc;Kc=1;var t=_v(),e=La();return Qc=function(r){for(var n=e(r),o=n.length;o--;){var i=n[o],s=r[i];n[o]=[i,s,t(s)]}return n}}(),r=kv();return th=function(n){var o=e(n);return 1==o.length&&o[0][2]?r(o[0][0],o[0][1]):function(e){return e===n||t(e,n,o)}}}function Av(){if(nh)return rh;nh=1;var t=bs(),e=Ls();return rh=function(r){return"symbol"==typeof r||e(r)&&"[object Symbol]"==t(r)}}function Ov(){if(ih)return oh;ih=1;var t=qs(),e=Av(),r=/\.|\[(?:[^[\]]*|(["'])(?:(?!\1)[^\\]|\\.)*?\1)\]/,n=/^\w*$/;return oh=function(o,i){if(t(o))return!1;var s=typeof o;return!("number"!=s&&"symbol"!=s&&"boolean"!=s&&null!=o&&!e(o))||(n.test(o)||!r.test(o)||null!=i&&o in Object(i))}}function zv(){if(ch)return uh;ch=1;var t=function(){if(ah)return sh;ah=1;var t=js();function e(r,n){if("function"!=typeof r||null!=n&&"function"!=typeof n)throw new TypeError("Expected a function");var o=function(){var t=arguments,e=n?n.apply(this,t):t[0],i=o.cache;if(i.has(e))return i.get(e);var s=r.apply(this,t);return o.cache=i.set(e,s)||i,s};return o.cache=new(e.Cache||t),o}return e.Cache=t,sh=e}();return uh=function(e){var r=t(e,function(t){return 500===n.size&&n.clear(),t}),n=r.cache;return r}}function jv(){if(fh)return dh;return fh=1,dh=function(t,e){for(var r=-1,n=null==t?0:t.length,o=Array(n);++r<n;)o[r]=e(t[r],r,t);return o},dh}function Cv(){if(mh)return vh;mh=1;var t=function(){if(ph)return gh;ph=1;var t=xs(),e=jv(),r=qs(),n=Av(),o=t?t.prototype:void 0,i=o?o.toString:void 0;return gh=function t(o){if("string"==typeof o)return o;if(r(o))return e(o,t)+"";if(n(o))return i?i.call(o):"";var s=o+"";return"0"==s&&1/o==-1/0?"-0":s},gh}();return vh=function(e){return null==e?"":t(e)}}function Iv(){if(wh)return yh;wh=1;var t=qs(),e=Ov(),r=function(){if(lh)return hh;lh=1;var t=zv(),e=/[^.[\]]+|\[(?:(-?\d+(?:\.\d+)?)|(["'])((?:(?!\2)[^\\]|\\.)*?)\2)\]|(?=(?:\.|\[\])(?:\.|\[\]|$))/g,r=/\\(\\)?/g,n=t(function(t){var n=[];return 46===t.charCodeAt(0)&&n.push(""),t.replace(e,function(t,e,o,i){n.push(o?i.replace(r,"$1"):e||t)}),n});return hh=n}(),n=Cv();return yh=function(o,i){return t(o)?o:e(o,i)?[o]:r(n(o))}}function Rv(){if(bh)return xh;bh=1;var t=Av();return xh=function(e){if("string"==typeof e||t(e))return e;var r=e+"";return"0"==r&&1/e==-1/0?"-0":r}}function Tv(){if(Mh)return Eh;Mh=1;var t=Iv(),e=Rv();return Eh=function(r,n){for(var o=0,i=(n=t(n,r)).length;null!=r&&o<i;)r=r[e(n[o++])];return o&&o==i?r:void 0},Eh}function Pv(){if(Oh)return Ah;Oh=1;var t=Iv(),e=Ds(),r=qs(),n=ta(),o=ea(),i=Rv();return Ah=function(s,a,u){for(var c=-1,h=(a=t(a,s)).length,l=!1;++c<h;){var d=i(a[c]);if(!(l=null!=s&&u(s,d)))break;s=s[d]}return l||++c!=h?l:!!(h=null==s?0:s.length)&&o(h)&&n(d,h)&&(r(s)||e(s))},Ah}function Fv(){if(jh)return zh;jh=1;var t=Sh?kh:(Sh=1,kh=function(t,e){return null!=t&&e in Object(t)}),e=Pv();return zh=function(r,n){return null!=r&&e(r,n,t)}}function Lv(){if(Ih)return Ch;Ih=1;var t=Nv(),e=function(){if(_h)return Nh;_h=1;var t=Tv();return Nh=function(e,r,n){var o=null==e?void 0:t(e,r);return void 0===o?n:o}}(),r=Fv(),n=Ov(),o=_v(),i=kv(),s=Rv();return Ch=function(a,u){return n(a)&&o(u)?i(s(a),u):function(n){var o=e(n,a);return void 0===o&&o===u?r(n,a):t(u,o,3)}}}function Dv(){if(Th)return Rh;return Th=1,Rh=function(t){return function(e){return null==e?void 0:e[t]}}}function qv(){if(Dh)return Lh;Dh=1;var t=Dv(),e=function(){if(Fh)return Ph;Fh=1;var t=Tv();return Ph=function(e){return function(r){return t(r,e)}}}(),r=Ov(),n=Rv();return Lh=function(o){return r(o)?t(n(o)):e(o)}}function Bv(){if(Bh)return qh;Bh=1;var t=Sv(),e=Lv(),r=gv(),n=qs(),o=qv();return qh=function(i){return"function"==typeof i?i:null==i?r:"object"==typeof i?n(i)?e(i[0],i[1]):t(i):o(i)}}function Vv(){if(Uh)return Vh;Uh=1;var t=$p(),e=function(){if(bc)return xc;bc=1;var t=fv();return xc=function(e,r){var n=[];return t(e,function(t,e,o){r(t,e,o)&&n.push(t)}),n},xc}(),r=Bv(),n=qs();return Vh=function(o,i){return(n(o)?t:e)(o,r(i,3))}}function Uv(){if(Yh)return Wh;Yh=1;var t=function(){if(Gh)return $h;Gh=1;var t=Object.prototype.hasOwnProperty;return $h=function(e,r){return null!=e&&t.call(e,r)}}(),e=Pv();return Wh=function(r,n){return null!=r&&e(r,n,t)}}function $v(){if(Xh)return Hh;Xh=1;var t=Pa(),e=Zp(),r=Ds(),n=qs(),o=Fa(),i=Zs(),s=Ra(),a=Ca(),u=Object.prototype.hasOwnProperty;return Hh=function(c){if(null==c)return!0;if(o(c)&&(n(c)||"string"==typeof c||"function"==typeof c.splice||i(c)||a(c)||r(c)))return!c.length;var h=e(c);if("[object Map]"==h||"[object Set]"==h)return!c.size;if(s(c))return!t(c).length;for(var l in c)if(u.call(c,l))return!1;return!0}}function Gv(){if(Kh)return Qh;return Kh=1,Qh=function(t){return void 0===t}}function Wv(){if(Zh)return Jh;Zh=1;var t=fv(),e=Fa();return Jh=function(r,n){var o=-1,i=e(r)?Array(r.length):[];return t(r,function(t,e,r){i[++o]=n(t,e,r)}),i},Jh}function Yv(){if(el)return tl;el=1;var t=jv(),e=Bv(),r=Wv(),n=qs();return tl=function(o,i){return(n(o)?t:r)(o,e(i,3))}}function Hv(){if(al)return sl;al=1;var t=(nl||(nl=1,rl=function(t,e,r,n){var o=-1,i=null==t?0:t.length;for(n&&i&&(r=t[++o]);++o<i;)r=e(r,t[o],o,t);return r}),rl),e=fv(),r=Bv(),n=(il||(il=1,ol=function(t,e,r,n,o){return o(t,function(t,o,i){r=n?(n=!1,t):e(r,t,o,i)}),r}),ol),o=qs();return sl=function(i,s,a){var u=o(i)?t:n,c=arguments.length<3;return u(i,r(s,4),a,c,e)},sl}function Xv(){if(ml)return vl;ml=1;var t=function(){if(ll)return hl;ll=1;var t=Dv()("length");return hl=t}(),e=function(){if(fl)return dl;fl=1;var t=RegExp("[\\u200d\\ud800-\\udfff\\u0300-\\u036f\\ufe20-\\ufe2f\\u20d0-\\u20ff\\ufe0e\\ufe0f]");return dl=function(e){return t.test(e)}}(),r=function(){if(pl)return gl;pl=1;var t="\\ud800-\\udfff",e="["+t+"]",r="[\\u0300-\\u036f\\ufe20-\\ufe2f\\u20d0-\\u20ff]",n="\\ud83c[\\udffb-\\udfff]",o="[^"+t+"]",i="(?:\\ud83c[\\udde6-\\uddff]){2}",s="[\\ud800-\\udbff][\\udc00-\\udfff]",a="(?:"+r+"|"+n+")?",u="[\\ufe0e\\ufe0f]?",c=u+a+"(?:\\u200d(?:"+[o,i,s].join("|")+")"+u+a+")*",h="(?:"+[o+r+"?",r,i,s,e].join("|")+")",l=RegExp(n+"(?="+n+")|"+h+c,"g");return gl=function(t){for(var e=l.lastIndex=0;l.test(t);)++e;return e}}();return vl=function(n){return e(n)?r(n):t(n)}}function Qv(){if(wl)return yl;wl=1;var t=Pa(),e=Zp(),r=Fa(),n=function(){if(cl)return ul;cl=1;var t=bs(),e=qs(),r=Ls();return ul=function(n){return"string"==typeof n||!e(n)&&r(n)&&"[object String]"==t(n)}}(),o=Xv();return yl=function(i){if(null==i)return 0;if(r(i))return n(i)?o(i):i.length;var s=e(i);return"[object Map]"==s||"[object Set]"==s?i.size:t(i).length}}function Kv(){if(bl)return xl;bl=1;var t=Is(),e=ov(),r=dv(),n=Bv(),o=Hp(),i=qs(),s=Zs(),a=Ms(),u=Es(),c=Ca();return xl=function(h,l,d){var f=i(h),g=f||s(h)||c(h);if(l=n(l,4),null==d){var p=h&&h.constructor;d=g?f?new p:[]:u(h)&&a(p)?e(o(h)):{}}return(g?t:r)(h,function(t,e,r){return l(d,t,e,r)}),d},xl}function Jv(){if(_l)return Nl;_l=1;var t=Yp(),e=function(){if(Ml)return El;Ml=1;var t=xs(),e=Ds(),r=qs(),n=t?t.isConcatSpreadable:void 0;return El=function(t){return r(t)||e(t)||!!(n&&t&&t[n])}}();return Nl=function r(n,o,i,s,a){var u=-1,c=n.length;for(i||(i=e),a||(a=[]);++u<c;){var h=n[u];o>0&&i(h)?o>1?r(h,o-1,i,s,a):t(a,h):s||(a[a.length]=h)}return a},Nl}function Zv(){if(Ol)return Al;Ol=1;var t=Sl?kl:(Sl=1,kl=function(t,e,r){switch(r.length){case 0:return t.call(e);case 1:return t.call(e,r[0]);case 2:return t.call(e,r[0],r[1]);case 3:return t.call(e,r[0],r[1],r[2])}return t.apply(e,r)}),e=Math.max;return Al=function(r,n,o){return n=e(void 0===n?r.length-1:n,0),function(){for(var i=arguments,s=-1,a=e(i.length-n,0),u=Array(a);++s<a;)u[s]=i[n+s];s=-1;for(var c=Array(n+1);++s<n;)c[s]=i[s];return c[n]=o(u),t(r,this,c)}},Al}function tm(){if(Tl)return Rl;Tl=1;var t=function(){if(jl)return zl;jl=1;var t=hv(),e=Rs(),r=gv();return zl=e?function(r,n){return e(r,"toString",{configurable:!0,enumerable:!1,value:t(n),writable:!0})}:r}(),e=function(){if(Il)return Cl;Il=1;var t=Date.now;return Cl=function(e){var r=0,n=0;return function(){var o=t(),i=16-(o-n);if(n=o,i>0){if(++r>=800)return arguments[0]}else r=0;return e.apply(void 0,arguments)}},Cl}(),r=e(t);return Rl=r}function em(){if(Fl)return Pl;Fl=1;var t=gv(),e=Zv(),r=tm();return Pl=function(n,o){return r(e(n,o,t),n+"")}}function rm(){if(Dl)return Ll;return Dl=1,Ll=function(t,e,r,n){for(var o=t.length,i=r+(n?1:-1);n?i--:++i<o;)if(e(t[i],i,t))return i;return-1},Ll}function nm(){if(Gl)return $l;Gl=1;var t=rm(),e=Bl?ql:(Bl=1,ql=function(t){return t!=t}),r=(Ul||(Ul=1,Vl=function(t,e,r){for(var n=r-1,o=t.length;++n<o;)if(t[n]===e)return n;return-1}),Vl);return $l=function(n,o,i){return o==o?r(n,o,i):t(n,e,i)}}function om(){if(Zl)return Jl;Zl=1;var t=Jp(),e=Kl?Ql:(Kl=1,Ql=function(){}),r=bv(),n=t&&1/r(new t([,-0]))[1]==1/0?function(e){return new t(e)}:e;return Jl=n}function im(){if(ed)return td;ed=1;var t=yv(),e=function(){if(Yl)return Wl;Yl=1;var t=nm();return Wl=function(e,r){return!(null==e||!e.length)&&t(e,r,0)>-1}}(),r=(Xl||(Xl=1,Hl=function(t,e,r){for(var n=-1,o=null==t?0:t.length;++n<o;)if(r(e,t[n]))return!0;return!1}),Hl),n=wv(),o=om(),i=bv();return td=function(s,a,u){var c=-1,h=e,l=s.length,d=!0,f=[],g=f;if(u)d=!1,h=r;else if(l>=200){var p=a?null:o(s);if(p)return i(p);d=!1,h=n,g=new t}else g=a?[]:f;t:for(;++c<l;){var v=s[c],m=a?a(v):v;if(v=u||0!==v?v:0,d&&m==m){for(var y=g.length;y--;)if(g[y]===m)continue t;a&&g.push(m),f.push(v)}else h(g,m,u)||(g!==f&&g.push(m),f.push(v))}return f},td}function sm(){if(nd)return rd;nd=1;var t=Fa(),e=Ls();return rd=function(r){return e(r)&&t(r)}}function am(){if(id)return od;id=1;var t=Jv(),e=em(),r=im(),n=sm(),o=e(function(e){return r(t(e,1,n,!0))});return od=o}function um(){if(cd)return ud;cd=1;var t=function(){if(ad)return sd;ad=1;var t=jv();return sd=function(e,r){return t(r,function(t){return e[t]})}}(),e=La();return ud=function(r){return null==r?[]:t(r,e(r))}}function cm(){if(ld)return hd;var t;ld=1;try{t={clone:cv(),constant:hv(),each:mv(),filter:Vv(),has:Uv(),isArray:qs(),isEmpty:$v(),isFunction:Ms(),isUndefined:Gv(),keys:La(),map:Yv(),reduce:Hv(),size:Qv(),transform:Kv(),union:am(),values:um()}}catch(t){}return t||(t=window._),hd=t}function hm(){if(fd)return dd;fd=1;var t=cm();dd=r;var e="\0";function r(r){this._isDirected=!t.has(r,"directed")||r.directed,this._isMultigraph=!!t.has(r,"multigraph")&&r.multigraph,this._isCompound=!!t.has(r,"compound")&&r.compound,this._label=void 0,this._defaultNodeLabelFn=t.constant(void 0),this._defaultEdgeLabelFn=t.constant(void 0),this._nodes={},this._isCompound&&(this._parent={},this._children={},this._children[e]={}),this._in={},this._preds={},this._out={},this._sucs={},this._edgeObjs={},this._edgeLabels={}}function n(t,e){t[e]?t[e]++:t[e]=1}function o(t,e){--t[e]||delete t[e]}function i(e,r,n,o){var i=""+r,s=""+n;if(!e&&i>s){var a=i;i=s,s=a}return i+""+s+""+(t.isUndefined(o)?"\0":o)}function s(t,e){return i(t,e.v,e.w,e.name)}return r.prototype._nodeCount=0,r.prototype._edgeCount=0,r.prototype.isDirected=function(){return this._isDirected},r.prototype.isMultigraph=function(){return this._isMultigraph},r.prototype.isCompound=function(){return this._isCompound},r.prototype.setGraph=function(t){return this._label=t,this},r.prototype.graph=function(){return this._label},r.prototype.setDefaultNodeLabel=function(e){return t.isFunction(e)||(e=t.constant(e)),this._defaultNodeLabelFn=e,this},r.prototype.nodeCount=function(){return this._nodeCount},r.prototype.nodes=function(){return t.keys(this._nodes)},r.prototype.sources=function(){var e=this;return t.filter(this.nodes(),function(r){return t.isEmpty(e._in[r])})},r.prototype.sinks=function(){var e=this;return t.filter(this.nodes(),function(r){return t.isEmpty(e._out[r])})},r.prototype.setNodes=function(e,r){var n=arguments,o=this;return t.each(e,function(t){n.length>1?o.setNode(t,r):o.setNode(t)}),this},r.prototype.setNode=function(r,n){return t.has(this._nodes,r)?(arguments.length>1&&(this._nodes[r]=n),this):(this._nodes[r]=arguments.length>1?n:this._defaultNodeLabelFn(r),this._isCompound&&(this._parent[r]=e,this._children[r]={},this._children[e][r]=!0),this._in[r]={},this._preds[r]={},this._out[r]={},this._sucs[r]={},++this._nodeCount,this)},r.prototype.node=function(t){return this._nodes[t]},r.prototype.hasNode=function(e){return t.has(this._nodes,e)},r.prototype.removeNode=function(e){var r=this;if(t.has(this._nodes,e)){var n=function(t){r.removeEdge(r._edgeObjs[t])};delete this._nodes[e],this._isCompound&&(this._removeFromParentsChildList(e),delete this._parent[e],t.each(this.children(e),function(t){r.setParent(t)}),delete this._children[e]),t.each(t.keys(this._in[e]),n),delete this._in[e],delete this._preds[e],t.each(t.keys(this._out[e]),n),delete this._out[e],delete this._sucs[e],--this._nodeCount}return this},r.prototype.setParent=function(r,n){if(!this._isCompound)throw new Error("Cannot set parent in a non-compound graph");if(t.isUndefined(n))n=e;else{for(var o=n+="";!t.isUndefined(o);o=this.parent(o))if(o===r)throw new Error("Setting "+n+" as parent of "+r+" would create a cycle");this.setNode(n)}return this.setNode(r),this._removeFromParentsChildList(r),this._parent[r]=n,this._children[n][r]=!0,this},r.prototype._removeFromParentsChildList=function(t){delete this._children[this._parent[t]][t]},r.prototype.parent=function(t){if(this._isCompound){var r=this._parent[t];if(r!==e)return r}},r.prototype.children=function(r){if(t.isUndefined(r)&&(r=e),this._isCompound){var n=this._children[r];if(n)return t.keys(n)}else{if(r===e)return this.nodes();if(this.hasNode(r))return[]}},r.prototype.predecessors=function(e){var r=this._preds[e];if(r)return t.keys(r)},r.prototype.successors=function(e){var r=this._sucs[e];if(r)return t.keys(r)},r.prototype.neighbors=function(e){var r=this.predecessors(e);if(r)return t.union(r,this.successors(e))},r.prototype.isLeaf=function(t){return 0===(this.isDirected()?this.successors(t):this.neighbors(t)).length},r.prototype.filterNodes=function(e){var r=new this.constructor({directed:this._isDirected,multigraph:this._isMultigraph,compound:this._isCompound});r.setGraph(this.graph());var n=this;t.each(this._nodes,function(t,n){e(n)&&r.setNode(n,t)}),t.each(this._edgeObjs,function(t){r.hasNode(t.v)&&r.hasNode(t.w)&&r.setEdge(t,n.edge(t))});var o={};function i(t){var e=n.parent(t);return void 0===e||r.hasNode(e)?(o[t]=e,e):e in o?o[e]:i(e)}return this._isCompound&&t.each(r.nodes(),function(t){r.setParent(t,i(t))}),r},r.prototype.setDefaultEdgeLabel=function(e){return t.isFunction(e)||(e=t.constant(e)),this._defaultEdgeLabelFn=e,this},r.prototype.edgeCount=function(){return this._edgeCount},r.prototype.edges=function(){return t.values(this._edgeObjs)},r.prototype.setPath=function(e,r){var n=this,o=arguments;return t.reduce(e,function(t,e){return o.length>1?n.setEdge(t,e,r):n.setEdge(t,e),e}),this},r.prototype.setEdge=function(){var e,r,o,s,a=!1,u=arguments[0];"object"==typeof u&&null!==u&&"v"in u?(e=u.v,r=u.w,o=u.name,2===arguments.length&&(s=arguments[1],a=!0)):(e=u,r=arguments[1],o=arguments[3],arguments.length>2&&(s=arguments[2],a=!0)),e=""+e,r=""+r,t.isUndefined(o)||(o=""+o);var c=i(this._isDirected,e,r,o);if(t.has(this._edgeLabels,c))return a&&(this._edgeLabels[c]=s),this;if(!t.isUndefined(o)&&!this._isMultigraph)throw new Error("Cannot set a named edge when isMultigraph = false");this.setNode(e),this.setNode(r),this._edgeLabels[c]=a?s:this._defaultEdgeLabelFn(e,r,o);var h=function(t,e,r,n){var o=""+e,i=""+r;if(!t&&o>i){var s=o;o=i,i=s}var a={v:o,w:i};n&&(a.name=n);return a}(this._isDirected,e,r,o);return e=h.v,r=h.w,Object.freeze(h),this._edgeObjs[c]=h,n(this._preds[r],e),n(this._sucs[e],r),this._in[r][c]=h,this._out[e][c]=h,this._edgeCount++,this},r.prototype.edge=function(t,e,r){var n=1===arguments.length?s(this._isDirected,arguments[0]):i(this._isDirected,t,e,r);return this._edgeLabels[n]},r.prototype.hasEdge=function(e,r,n){var o=1===arguments.length?s(this._isDirected,arguments[0]):i(this._isDirected,e,r,n);return t.has(this._edgeLabels,o)},r.prototype.removeEdge=function(t,e,r){var n=1===arguments.length?s(this._isDirected,arguments[0]):i(this._isDirected,t,e,r),a=this._edgeObjs[n];return a&&(t=a.v,e=a.w,delete this._edgeLabels[n],delete this._edgeObjs[n],o(this._preds[e],t),o(this._sucs[t],e),delete this._in[e][n],delete this._out[t][n],this._edgeCount--),this},r.prototype.inEdges=function(e,r){var n=this._in[e];if(n){var o=t.values(n);return r?t.filter(o,function(t){return t.v===r}):o}},r.prototype.outEdges=function(e,r){var n=this._out[e];if(n){var o=t.values(n);return r?t.filter(o,function(t){return t.w===r}):o}},r.prototype.nodeEdges=function(t,e){var r=this.inEdges(t,e);if(r)return r.concat(this.outEdges(t,e))},dd}function lm(){return md?vd:(md=1,vd={Graph:hm(),version:pd?gd:(pd=1,gd="2.1.8")})}function dm(){if(wd)return yd;wd=1;var t=cm(),e=hm();function r(e){return t.map(e.nodes(),function(r){var n=e.node(r),o=e.parent(r),i={v:r};return t.isUndefined(n)||(i.value=n),t.isUndefined(o)||(i.parent=o),i})}function n(e){return t.map(e.edges(),function(r){var n=e.edge(r),o={v:r.v,w:r.w};return t.isUndefined(r.name)||(o.name=r.name),t.isUndefined(n)||(o.value=n),o})}return yd={write:function(e){var o={options:{directed:e.isDirected(),multigraph:e.isMultigraph(),compound:e.isCompound()},nodes:r(e),edges:n(e)};t.isUndefined(e.graph())||(o.value=t.clone(e.graph()));return o},read:function(r){var n=new e(r.options).setGraph(r.value);return t.each(r.nodes,function(t){n.setNode(t.v,t.value),t.parent&&n.setParent(t.v,t.parent)}),t.each(r.edges,function(t){n.setEdge({v:t.v,w:t.w,name:t.name},t.value)}),n}}}function fm(){if(bd)return xd;bd=1;var t=cm();return xd=function(e){var r,n={},o=[];function i(o){t.has(n,o)||(n[o]=!0,r.push(o),t.each(e.successors(o),i),t.each(e.predecessors(o),i))}return t.each(e.nodes(),function(t){r=[],i(t),r.length&&o.push(r)}),o},xd}function gm(){if(Md)return Ed;Md=1;var t=cm();function e(){this._arr=[],this._keyIndices={}}return Ed=e,e.prototype.size=function(){return this._arr.length},e.prototype.keys=function(){return this._arr.map(function(t){return t.key})},e.prototype.has=function(e){return t.has(this._keyIndices,e)},e.prototype.priority=function(t){var e=this._keyIndices[t];if(void 0!==e)return this._arr[e].priority},e.prototype.min=function(){if(0===this.size())throw new Error("Queue underflow");return this._arr[0].key},e.prototype.add=function(e,r){var n=this._keyIndices;if(e=String(e),!t.has(n,e)){var o=this._arr,i=o.length;return n[e]=i,o.push({key:e,priority:r}),this._decrease(i),!0}return!1},e.prototype.removeMin=function(){this._swap(0,this._arr.length-1);var t=this._arr.pop();return delete this._keyIndices[t.key],this._heapify(0),t.key},e.prototype.decrease=function(t,e){var r=this._keyIndices[t];if(e>this._arr[r].priority)throw new Error("New priority is greater than current priority. Key: "+t+" Old: "+this._arr[r].priority+" New: "+e);this._arr[r].priority=e,this._decrease(r)},e.prototype._heapify=function(t){var e=this._arr,r=2*t,n=r+1,o=t;r<e.length&&(o=e[r].priority<e[o].priority?r:o,n<e.length&&(o=e[n].priority<e[o].priority?n:o),o!==t&&(this._swap(t,o),this._heapify(o)))},e.prototype._decrease=function(t){for(var e,r=this._arr,n=r[t].priority;0!==t&&!(r[e=t>>1].priority<n);)this._swap(t,e),t=e},e.prototype._swap=function(t,e){var r=this._arr,n=this._keyIndices,o=r[t],i=r[e];r[t]=i,r[e]=o,n[i.key]=t,n[o.key]=e},Ed}function pm(){if(_d)return Nd;_d=1;var t=cm(),e=gm();Nd=function(t,n,o,i){return function(t,r,n,o){var i,s,a={},u=new e,c=function(t){var e=t.v!==i?t.v:t.w,r=a[e],o=n(t),c=s.distance+o;if(o<0)throw new Error("dijkstra does not allow negative edge weights. Bad edge: "+t+" Weight: "+o);c<r.distance&&(r.distance=c,r.predecessor=i,u.decrease(e,c))};t.nodes().forEach(function(t){var e=t===r?0:Number.POSITIVE_INFINITY;a[t]={distance:e},u.add(t,e)});for(;u.size()>0&&(i=u.removeMin(),(s=a[i]).distance!==Number.POSITIVE_INFINITY);)o(i).forEach(c);return a}(t,String(n),o||r,i||function(e){return t.outEdges(e)})};var r=t.constant(1);return Nd}function vm(){if(Sd)return kd;Sd=1;var t=pm(),e=cm();return kd=function(r,n,o){return e.transform(r.nodes(),function(e,i){e[i]=t(r,i,n,o)},{})}}function mm(){if(Od)return Ad;Od=1;var t=cm();return Ad=function(e){var r=0,n=[],o={},i=[];function s(a){var u=o[a]={onStack:!0,lowlink:r,index:r++};if(n.push(a),e.successors(a).forEach(function(e){t.has(o,e)?o[e].onStack&&(u.lowlink=Math.min(u.lowlink,o[e].index)):(s(e),u.lowlink=Math.min(u.lowlink,o[e].lowlink))}),u.lowlink===u.index){var c,h=[];do{c=n.pop(),o[c].onStack=!1,h.push(c)}while(a!==c);i.push(h)}}return e.nodes().forEach(function(e){t.has(o,e)||s(e)}),i},Ad}function ym(){if(jd)return zd;jd=1;var t=cm(),e=mm();return zd=function(r){return t.filter(e(r),function(t){return t.length>1||1===t.length&&r.hasEdge(t[0],t[0])})}}function wm(){if(Id)return Cd;Id=1;var t=cm();Cd=function(t,r,n){return function(t,e,r){var n={},o=t.nodes();return o.forEach(function(t){n[t]={},n[t][t]={distance:0},o.forEach(function(e){t!==e&&(n[t][e]={distance:Number.POSITIVE_INFINITY})}),r(t).forEach(function(r){var o=r.v===t?r.w:r.v,i=e(r);n[t][o]={distance:i,predecessor:t}})}),o.forEach(function(t){var e=n[t];o.forEach(function(r){var i=n[r];o.forEach(function(r){var n=i[t],o=e[r],s=i[r],a=n.distance+o.distance;a<s.distance&&(s.distance=a,s.predecessor=o.predecessor)})})}),n}(t,r||e,n||function(e){return t.outEdges(e)})};var e=t.constant(1);return Cd}function xm(){if(Td)return Rd;Td=1;var t=cm();function e(e){var n={},o={},i=[];if(t.each(e.sinks(),function s(a){if(t.has(o,a))throw new r;t.has(n,a)||(o[a]=!0,n[a]=!0,t.each(e.predecessors(a),s),delete o[a],i.push(a))}),t.size(n)!==e.nodeCount())throw new r;return i}function r(){}return Rd=e,e.CycleException=r,r.prototype=new Error,Rd}function bm(){if(Fd)return Pd;Fd=1;var t=xm();return Pd=function(e){try{t(e)}catch(e){if(e instanceof t.CycleException)return!1;throw e}return!0},Pd}function Em(){if(Dd)return Ld;Dd=1;var t=cm();function e(r,n,o,i,s,a){t.has(i,n)||(i[n]=!0,o||a.push(n),t.each(s(n),function(t){e(r,t,o,i,s,a)}),o&&a.push(n))}return Ld=function(r,n,o){t.isArray(n)||(n=[n]);var i=(r.isDirected()?r.successors:r.neighbors).bind(r),s=[],a={};return t.each(n,function(t){if(!r.hasNode(t))throw new Error("Graph does not have node: "+t);e(r,t,"post"===o,a,i,s)}),s},Ld}function Mm(){if(Bd)return qd;Bd=1;var t=Em();return qd=function(e,r){return t(e,r,"post")}}function Nm(){if(Ud)return Vd;Ud=1;var t=Em();return Vd=function(e,r){return t(e,r,"pre")}}function _m(){if(Gd)return $d;Gd=1;var t=cm(),e=hm(),r=gm();return $d=function(n,o){var i,s=new e,a={},u=new r;function c(t){var e=t.v===i?t.w:t.v,r=u.priority(e);if(void 0!==r){var n=o(t);n<r&&(a[e]=i,u.decrease(e,n))}}if(0===n.nodeCount())return s;t.each(n.nodes(),function(t){u.add(t,Number.POSITIVE_INFINITY),s.setNode(t)}),u.decrease(n.nodes()[0],0);var h=!1;for(;u.size()>0;){if(i=u.removeMin(),t.has(a,i))s.setEdge(i,a[i]);else{if(h)throw new Error("Input graph is not connected: "+n);h=!0}n.nodeEdges(i).forEach(c)}return s},$d}function km(){if(Xd)return Hd;Xd=1;var t=lm();return Hd={Graph:t.Graph,json:dm(),alg:Yd?Wd:(Yd=1,Wd={components:fm(),dijkstra:pm(),dijkstraAll:vm(),findCycles:ym(),floydWarshall:wm(),isAcyclic:bm(),postorder:Mm(),preorder:Nm(),prim:_m(),tarjan:mm(),topsort:xm()}),version:t.version}}function Sm(){if(Kd)return Qd;var t;Kd=1;try{t=km()}catch(t){}return t||(t=window.graphlib),Qd=t}function Am(){if(Zd)return Jd;Zd=1;var t=uv();return Jd=function(e){return t(e,5)}}function Om(){if(ef)return tf;ef=1;var t=ps(),e=Fa(),r=ta(),n=Es();return tf=function(o,i,s){if(!n(s))return!1;var a=typeof i;return!!("number"==a?e(s)&&r(i,s.length):"string"==a&&i in s)&&t(s[i],o)},tf}function zm(){if(nf)return rf;nf=1;var t=em(),e=ps(),r=Om(),n=qa(),o=Object.prototype,i=o.hasOwnProperty,s=t(function(t,s){t=Object(t);var a=-1,u=s.length,c=u>2?s[2]:void 0;for(c&&r(s[0],s[1],c)&&(u=1);++a<u;)for(var h=s[a],l=n(h),d=-1,f=l.length;++d<f;){var g=l[d],p=t[g];(void 0===p||e(p,o[g])&&!i.call(t,g))&&(t[g]=h[g])}return t});return rf=s}function jm(){if(hf)return cf;hf=1;var t=function(){if(uf)return af;uf=1;var t=/\s/;return af=function(e){for(var r=e.length;r--&&t.test(e.charAt(r)););return r},af}(),e=/^\s+/;return cf=function(r){return r?r.slice(0,t(r)+1).replace(e,""):r}}function Cm(){if(gf)return ff;gf=1;var t=function(){if(df)return lf;df=1;var t=jm(),e=Es(),r=Av(),n=/^[-+]0x[0-9a-f]+$/i,o=/^0b[01]+$/i,i=/^0o[0-7]+$/i,s=parseInt;return lf=function(a){if("number"==typeof a)return a;if(r(a))return NaN;if(e(a)){var u="function"==typeof a.valueOf?a.valueOf():a;a=e(u)?u+"":u}if("string"!=typeof a)return 0===a?a:+a;a=t(a);var c=o.test(a);return c||i.test(a)?s(a.slice(2),c?2:8):n.test(a)?NaN:+a}}(),e=1/0;return ff=function(r){return r?(r=t(r))===e||r===-1/0?17976931348623157e292*(r<0?-1:1):r==r?r:0:0===r?r:0}}function Im(){if(yf)return mf;yf=1;var t=rm(),e=Bv(),r=function(){if(vf)return pf;vf=1;var t=Cm();return pf=function(e){var r=t(e),n=r%1;return r==r?n?r-n:r:0}}(),n=Math.max;return mf=function(o,i,s){var a=null==o?0:o.length;if(!a)return-1;var u=null==s?0:r(s);return u<0&&(u=n(a+u,0)),t(o,e(i,3),u)},mf}function Rm(){if(xf)return wf;xf=1;var t=function(){if(sf)return of;sf=1;var t=Bv(),e=Fa(),r=La();return of=function(n){return function(o,i,s){var a=Object(o);if(!e(o)){var u=t(i,3);o=r(o),i=function(t){return u(a[t],t,a)}}var c=n(o,i,s);return c>-1?a[u?o[c]:c]:void 0}},of}(),e=t(Im());return wf=e}function Tm(){if(Ef)return bf;Ef=1;var t=Jv();return bf=function(e){return(null==e?0:e.length)?t(e,1):[]}}function Pm(){if(Nf)return Mf;Nf=1;var t=lv(),e=pv(),r=qa();return Mf=function(n,o){return null==n?n:t(n,e(o),r)}}function Fm(){if(kf)return _f;return kf=1,_f=function(t){var e=null==t?0:t.length;return e?t[e-1]:void 0}}function Lm(){if(Af)return Sf;Af=1;var t=Ts(),e=dv(),r=Bv();return Sf=function(n,o){var i={};return o=r(o,3),e(n,function(e,r,n){t(i,r,o(e,r,n))}),i}}function Dm(){if(zf)return Of;zf=1;var t=Av();return Of=function(e,r,n){for(var o=-1,i=e.length;++o<i;){var s=e[o],a=r(s);if(null!=a&&(void 0===u?a==a&&!t(a):n(a,u)))var u=a,c=s}return c},Of}function qm(){if(Rf)return If;Rf=1;var t=Dm(),e=Cf?jf:(Cf=1,jf=function(t,e){return t>e}),r=gv();return If=function(n){return n&&n.length?t(n,r,e):void 0}}function Bm(){if(Pf)return Tf;Pf=1;var t=Ts(),e=ps();return Tf=function(r,n,o){(void 0!==o&&!e(r[n],o)||void 0===o&&!(n in r))&&t(r,n,o)}}function Vm(){if(qf)return Df;return qf=1,Df=function(t,e){if(("constructor"!==e||"function"!=typeof t[e])&&"__proto__"!=e)return t[e]}}function Um(){if($f)return Uf;$f=1;var t=Bm(),e=Vp(),r=rv(),n=Up(),o=iv(),i=Ds(),s=qs(),a=sm(),u=Zs(),c=Ms(),h=Es(),l=function(){if(Lf)return Ff;Lf=1;var t=bs(),e=Hp(),r=Ls(),n=Function.prototype,o=Object.prototype,i=n.toString,s=o.hasOwnProperty,a=i.call(Object);return Ff=function(n){if(!r(n)||"[object Object]"!=t(n))return!1;var o=e(n);if(null===o)return!0;var u=s.call(o,"constructor")&&o.constructor;return"function"==typeof u&&u instanceof u&&i.call(u)==a}}(),d=Ca(),f=Vm(),g=function(){if(Vf)return Bf;Vf=1;var t=Fs(),e=qa();return Bf=function(r){return t(r,e(r))}}();return Uf=function(p,v,m,y,w,x,b){var E=f(p,m),M=f(v,m),N=b.get(M);if(N)t(p,m,N);else{var _=x?x(E,M,m+"",p,v,b):void 0,k=void 0===_;if(k){var S=s(M),A=!S&&u(M),O=!S&&!A&&d(M);_=M,S||A||O?s(E)?_=E:a(E)?_=n(E):A?(k=!1,_=e(M,!0)):O?(k=!1,_=r(M,!0)):_=[]:l(M)||i(M)?(_=E,i(E)?_=g(E):h(E)&&!c(E)||(_=o(M))):k=!1}k&&(b.set(M,_),w(_,M,y,x,b),b.delete(M)),t(p,m,_)}}}function $m(){if(Qf)return Xf;Qf=1;var t=function(){if(Wf)return Gf;Wf=1;var t=Cs(),e=Bm(),r=lv(),n=Um(),o=Es(),i=qa(),s=Vm();return Gf=function a(u,c,h,l,d){u!==c&&r(c,function(r,i){if(d||(d=new t),o(r))n(u,c,i,h,a,l,d);else{var f=l?l(s(u,i),r,i+"",u,c,d):void 0;void 0===f&&(f=r),e(u,i,f)}},i)},Gf}(),e=function(){if(Hf)return Yf;Hf=1;var t=em(),e=Om();return Yf=function(r){return t(function(t,n){var o=-1,i=n.length,s=i>1?n[i-1]:void 0,a=i>2?n[2]:void 0;for(s=r.length>3&&"function"==typeof s?(i--,s):void 0,a&&e(n[0],n[1],a)&&(s=i<3?void 0:s,i=1),t=Object(t);++o<i;){var u=n[o];u&&r(t,u,o,s)}return t})},Yf}(),r=e(function(e,r,n){t(e,r,n)});return Xf=r}function Gm(){if(Jf)return Kf;return Jf=1,Kf=function(t,e){return t<e}}function Wm(){if(tg)return Zf;tg=1;var t=Dm(),e=Gm(),r=gv();return Zf=function(n){return n&&n.length?t(n,r,e):void 0}}function Ym(){if(rg)return eg;rg=1;var t=Dm(),e=Bv(),r=Gm();return eg=function(n,o){return n&&n.length?t(n,e(o,2),r):void 0}}function Hm(){if(og)return ng;og=1;var t=ws();return ng=function(){return t.Date.now()}}function Xm(){if(ug)return ag;ug=1;var t=Tv(),e=function(){if(sg)return ig;sg=1;var t=Ps(),e=Iv(),r=ta(),n=Es(),o=Rv();return ig=function(i,s,a,u){if(!n(i))return i;for(var c=-1,h=(s=e(s,i)).length,l=h-1,d=i;null!=d&&++c<h;){var f=o(s[c]),g=a;if("__proto__"===f||"constructor"===f||"prototype"===f)return i;if(c!=l){var p=d[f];void 0===(g=u?u(p,f,d):void 0)&&(g=n(p)?p:r(s[c+1])?[]:{})}t(d,f,g),d=d[f]}return i},ig}(),r=Iv();return ag=function(n,o,i){for(var s=-1,a=o.length,u={};++s<a;){var c=o[s],h=t(n,c);i(h,c)&&e(u,r(c,n),h)}return u},ag}function Qm(){if(gg)return fg;gg=1;var t=function(){if(hg)return cg;hg=1;var t=Xm(),e=Fv();return cg=function(r,n){return t(r,n,function(t,n){return e(r,n)})}}(),e=function(){if(dg)return lg;dg=1;var t=Tm(),e=Zv(),r=tm();return lg=function(n){return r(e(n,void 0,t),n+"")}}()(function(e,r){return null==e?{}:t(e,r)});return fg=e}function Km(){if(yg)return mg;yg=1;var t=function(){if(vg)return pg;vg=1;var t=Math.ceil,e=Math.max;return pg=function(r,n,o,i){for(var s=-1,a=e(t((n-r)/(o||1)),0),u=Array(a);a--;)u[i?a:++s]=r,r+=o;return u},pg}(),e=Om(),r=Cm();return mg=function(n){return function(o,i,s){return s&&"number"!=typeof s&&e(o,i,s)&&(i=s=void 0),o=r(o),void 0===i?(i=o,o=0):i=r(i),s=void 0===s?o<i?1:-1:r(s),t(o,i,s,n)}}}function Jm(){if(xg)return wg;xg=1;var t=Km()();return wg=t}function Zm(){if(kg)return _g;kg=1;var t=function(){if(Ng)return Mg;Ng=1;var t=Av();return Mg=function(e,r){if(e!==r){var n=void 0!==e,o=null===e,i=e==e,s=t(e),a=void 0!==r,u=null===r,c=r==r,h=t(r);if(!u&&!h&&!s&&e>r||s&&a&&c&&!u&&!h||o&&a&&c||!n&&c||!i)return 1;if(!o&&!s&&!h&&e<r||h&&n&&i&&!o&&!s||u&&n&&i||!a&&i||!c)return-1}return 0}}();return _g=function(e,r,n){for(var o=-1,i=e.criteria,s=r.criteria,a=i.length,u=n.length;++o<a;){var c=t(i[o],s[o]);if(c)return o>=u?c:c*("desc"==n[o]?-1:1)}return e.index-r.index},_g}function ty(){if(Ag)return Sg;Ag=1;var t=jv(),e=Tv(),r=Bv(),n=Wv(),o=Eg?bg:(Eg=1,bg=function(t,e){var r=t.length;for(t.sort(e);r--;)t[r]=t[r].value;return t}),i=ra(),s=Zm(),a=gv(),u=qs();return Sg=function(c,h,l){h=h.length?t(h,function(t){return u(t)?function(r){return e(r,1===t.length?t[0]:t)}:t}):[a];var d=-1;h=t(h,i(r));var f=n(c,function(e,r,n){return{criteria:t(h,function(t){return t(e)}),index:++d,value:e}});return o(f,function(t,e){return s(t,e,l)})},Sg}function ey(){if(zg)return Og;zg=1;var t=Jv(),e=ty(),r=em(),n=Om(),o=r(function(r,o){if(null==r)return[];var i=o.length;return i>1&&n(r,o[0],o[1])?o=[]:i>2&&n(o[0],o[1],o[2])&&(o=[o[0]]),e(r,t(o,1),[])});return Og=o}function ry(){if(Cg)return jg;Cg=1;var t=Cv(),e=0;return jg=function(r){var n=++e;return t(r)+n}}function ny(){if(Pg)return Tg;Pg=1;var t=Ps(),e=(Rg||(Rg=1,Ig=function(t,e,r){for(var n=-1,o=t.length,i=e.length,s={};++n<o;){var a=n<i?e[n]:void 0;r(s,t[n],a)}return s}),Ig);return Tg=function(r,n){return e(r||[],n||[],t)}}function oy(){if(Lg)return Fg;var t;Lg=1;try{t={cloneDeep:Am(),constant:hv(),defaults:zm(),each:mv(),filter:Vv(),find:Rm(),flatten:Tm(),forEach:vv(),forIn:Pm(),has:Uv(),isUndefined:Gv(),last:Fm(),map:Yv(),mapValues:Lm(),max:qm(),merge:$m(),min:Wm(),minBy:Ym(),now:Hm(),pick:Qm(),range:Jm(),reduce:Hv(),sortBy:ey(),uniqueId:ry(),values:um(),zipObject:ny()}}catch(t){}return t||(t=window._),Fg=t}function iy(){if(Vg)return Bg;Vg=1;var t=oy(),e=Sm().Graph,r=function(){if(qg)return Dg;function t(){var t={};t._next=t._prev=t,this._sentinel=t}function e(t){t._prev._next=t._next,t._next._prev=t._prev,delete t._next,delete t._prev}function r(t,e){if("_next"!==t&&"_prev"!==t)return e}return qg=1,Dg=t,t.prototype.dequeue=function(){var t=this._sentinel,r=t._prev;if(r!==t)return e(r),r},t.prototype.enqueue=function(t){var r=this._sentinel;t._prev&&t._next&&e(t),t._next=r._next,r._next._prev=t,r._next=t,t._prev=r},t.prototype.toString=function(){for(var t=[],e=this._sentinel,n=e._prev;n!==e;)t.push(JSON.stringify(n,r)),n=n._prev;return"["+t.join(", ")+"]"},Dg}();Bg=function(s,a){if(s.nodeCount()<=1)return[];var u=function(n,o){var s=new e,a=0,u=0;t.forEach(n.nodes(),function(t){s.setNode(t,{v:t,in:0,out:0})}),t.forEach(n.edges(),function(t){var e=s.edge(t.v,t.w)||0,r=o(t),n=e+r;s.setEdge(t.v,t.w,n),u=Math.max(u,s.node(t.v).out+=r),a=Math.max(a,s.node(t.w).in+=r)});var c=t.range(u+a+3).map(function(){return new r}),h=a+1;return t.forEach(s.nodes(),function(t){i(c,h,s.node(t))}),{graph:s,buckets:c,zeroIdx:h}}(s,a||n),c=function(t,e,r){var n,i=[],s=e[e.length-1],a=e[0];for(;t.nodeCount();){for(;n=a.dequeue();)o(t,e,r,n);for(;n=s.dequeue();)o(t,e,r,n);if(t.nodeCount())for(var u=e.length-2;u>0;--u)if(n=e[u].dequeue()){i=i.concat(o(t,e,r,n,!0));break}}return i}(u.graph,u.buckets,u.zeroIdx);return t.flatten(t.map(c,function(t){return s.outEdges(t.v,t.w)}),!0)};var n=t.constant(1);function o(e,r,n,o,s){var a=s?[]:void 0;return t.forEach(e.inEdges(o.v),function(t){var o=e.edge(t),u=e.node(t.v);s&&a.push({v:t.v,w:t.w}),u.out-=o,i(r,n,u)}),t.forEach(e.outEdges(o.v),function(t){var o=e.edge(t),s=t.w,a=e.node(s);a.in-=o,i(r,n,a)}),e.removeNode(o.v),a}function i(t,e,r){r.out?r.in?t[r.out-r.in+e].enqueue(r):t[t.length-1].enqueue(r):t[0].enqueue(r)}return Bg}function sy(){if($g)return Ug;$g=1;var t=oy(),e=iy();return Ug={run:function(r){var n="greedy"===r.graph().acyclicer?e(r,function(t){return function(e){return t.edge(e).weight}}(r)):function(e){var r=[],n={},o={};function i(s){t.has(o,s)||(o[s]=!0,n[s]=!0,t.forEach(e.outEdges(s),function(e){t.has(n,e.w)?r.push(e):i(e.w)}),delete n[s])}return t.forEach(e.nodes(),i),r}(r);t.forEach(n,function(e){var n=r.edge(e);r.removeEdge(e),n.forwardName=e.name,n.reversed=!0,r.setEdge(e.w,e.v,n,t.uniqueId("rev"))})},undo:function(e){t.forEach(e.edges(),function(t){var r=e.edge(t);if(r.reversed){e.removeEdge(t);var n=r.forwardName;delete r.reversed,delete r.forwardName,e.setEdge(t.w,t.v,r,n)}})}},Ug}function ay(){if(Wg)return Gg;Wg=1;var t=oy(),e=Sm().Graph;function r(e,r,n,o){var i;do{i=t.uniqueId(o)}while(e.hasNode(i));return n.dummy=r,e.setNode(i,n),i}function n(e){return t.max(t.map(e.nodes(),function(r){var n=e.node(r).rank;if(!t.isUndefined(n))return n}))}return Gg={addDummyNode:r,simplify:function(r){var n=(new e).setGraph(r.graph());return t.forEach(r.nodes(),function(t){n.setNode(t,r.node(t))}),t.forEach(r.edges(),function(t){var e=n.edge(t.v,t.w)||{weight:0,minlen:1},o=r.edge(t);n.setEdge(t.v,t.w,{weight:e.weight+o.weight,minlen:Math.max(e.minlen,o.minlen)})}),n},asNonCompoundGraph:function(r){var n=new e({multigraph:r.isMultigraph()}).setGraph(r.graph());return t.forEach(r.nodes(),function(t){r.children(t).length||n.setNode(t,r.node(t))}),t.forEach(r.edges(),function(t){n.setEdge(t,r.edge(t))}),n},successorWeights:function(e){var r=t.map(e.nodes(),function(r){var n={};return t.forEach(e.outEdges(r),function(t){n[t.w]=(n[t.w]||0)+e.edge(t).weight}),n});return t.zipObject(e.nodes(),r)},predecessorWeights:function(e){var r=t.map(e.nodes(),function(r){var n={};return t.forEach(e.inEdges(r),function(t){n[t.v]=(n[t.v]||0)+e.edge(t).weight}),n});return t.zipObject(e.nodes(),r)},intersectRect:function(t,e){var r,n,o=t.x,i=t.y,s=e.x-o,a=e.y-i,u=t.width/2,c=t.height/2;if(!s&&!a)throw new Error("Not possible to find intersection inside of the rectangle");Math.abs(a)*u>Math.abs(s)*c?(a<0&&(c=-c),r=c*s/a,n=c):(s<0&&(u=-u),r=u,n=u*a/s);return{x:o+r,y:i+n}},buildLayerMatrix:function(e){var r=t.map(t.range(n(e)+1),function(){return[]});return t.forEach(e.nodes(),function(n){var o=e.node(n),i=o.rank;t.isUndefined(i)||(r[i][o.order]=n)}),r},normalizeRanks:function(e){var r=t.min(t.map(e.nodes(),function(t){return e.node(t).rank}));t.forEach(e.nodes(),function(n){var o=e.node(n);t.has(o,"rank")&&(o.rank-=r)})},removeEmptyRanks:function(e){var r=t.min(t.map(e.nodes(),function(t){return e.node(t).rank})),n=[];t.forEach(e.nodes(),function(t){var o=e.node(t).rank-r;n[o]||(n[o]=[]),n[o].push(t)});var o=0,i=e.graph().nodeRankFactor;t.forEach(n,function(r,n){t.isUndefined(r)&&n%i!==0?--o:o&&t.forEach(r,function(t){e.node(t).rank+=o})})},addBorderNode:function(t,e,n,o){var i={width:0,height:0};arguments.length>=4&&(i.rank=n,i.order=o);return r(t,"border",i,e)},maxRank:n,partition:function(e,r){var n={lhs:[],rhs:[]};return t.forEach(e,function(t){r(t)?n.lhs.push(t):n.rhs.push(t)}),n},time:function(e,r){var n=t.now();try{return r()}finally{console.log(e+" time: "+(t.now()-n)+"ms")}},notime:function(t,e){return e()}},Gg}function uy(){if(Hg)return Yg;Hg=1;var t=oy(),e=ay();return Yg={run:function(r){r.graph().dummyChains=[],t.forEach(r.edges(),function(t){!function(t,r){var n,o,i,s=r.v,a=t.node(s).rank,u=r.w,c=t.node(u).rank,h=r.name,l=t.edge(r),d=l.labelRank;if(c===a+1)return;for(t.removeEdge(r),i=0,++a;a<c;++i,++a)l.points=[],o={width:0,height:0,edgeLabel:l,edgeObj:r,rank:a},n=e.addDummyNode(t,"edge",o,"_d"),a===d&&(o.width=l.width,o.height=l.height,o.dummy="edge-label",o.labelpos=l.labelpos),t.setEdge(s,n,{weight:l.weight},h),0===i&&t.graph().dummyChains.push(n),s=n;t.setEdge(s,u,{weight:l.weight},h)}(r,t)})},undo:function(e){t.forEach(e.graph().dummyChains,function(t){var r,n=e.node(t),o=n.edgeLabel;for(e.setEdge(n.edgeObj,o);n.dummy;)r=e.successors(t)[0],e.removeNode(t),o.points.push({x:n.x,y:n.y}),"edge-label"===n.dummy&&(o.x=n.x,o.y=n.y,o.width=n.width,o.height=n.height),t=r,n=e.node(t)})}},Yg}function cy(){if(Qg)return Xg;Qg=1;var t=oy();return Xg={longestPath:function(e){var r={};t.forEach(e.sources(),function n(o){var i=e.node(o);if(t.has(r,o))return i.rank;r[o]=!0;var s=t.min(t.map(e.outEdges(o),function(t){return n(t.w)-e.edge(t).minlen}));return s!==Number.POSITIVE_INFINITY&&null!=s||(s=0),i.rank=s})},slack:function(t,e){return t.node(e.w).rank-t.node(e.v).rank-t.edge(e).minlen}},Xg}function hy(){if(Jg)return Kg;Jg=1;var t=oy(),e=Sm().Graph,r=cy().slack;function n(e,n){return t.forEach(e.nodes(),function o(i){t.forEach(n.nodeEdges(i),function(t){var s=t.v,a=i===s?t.w:s;e.hasNode(a)||r(n,t)||(e.setNode(a,{}),e.setEdge(i,a,{}),o(a))})}),e.nodeCount()}function o(e,n){return t.minBy(n.edges(),function(t){if(e.hasNode(t.v)!==e.hasNode(t.w))return r(n,t)})}function i(e,r,n){t.forEach(e.nodes(),function(t){r.node(t).rank+=n})}return Kg=function(t){var s,a,u=new e({directed:!1}),c=t.nodes()[0],h=t.nodeCount();u.setNode(c,{});for(;n(u,t)<h;)s=o(u,t),a=u.hasNode(s.v)?r(t,s):-r(t,s),i(u,t,a);return u}}function ly(){if(tp)return Zg;tp=1;var t=oy(),e=hy(),r=cy().slack,n=cy().longestPath,o=Sm().alg.preorder,i=Sm().alg.postorder,s=ay().simplify;function a(t){t=s(t),n(t);var r,o=e(t);for(h(o),u(o,t);r=d(o);)g(o,t,r,f(o,t,r))}function u(e,r){var n=i(e,e.nodes());n=n.slice(0,n.length-1),t.forEach(n,function(t){!function(t,e,r){var n=t.node(r),o=n.parent;t.edge(r,o).cutvalue=c(t,e,r)}(e,r,t)})}function c(e,r,n){var o=e.node(n).parent,i=!0,s=r.edge(n,o),a=0;return s||(i=!1,s=r.edge(o,n)),a=s.weight,t.forEach(r.nodeEdges(n),function(t){var s=t.v===n,u=s?t.w:t.v;if(u!==o){var c=s===i,h=r.edge(t).weight;if(a+=c?h:-h,function(t,e,r){return t.hasEdge(e,r)}(e,n,u)){var l=e.edge(n,u).cutvalue;a+=c?-l:l}}}),a}function h(t,e){arguments.length<2&&(e=t.nodes()[0]),l(t,{},1,e)}function l(e,r,n,o,i){var s=n,a=e.node(o);return r[o]=!0,t.forEach(e.neighbors(o),function(i){t.has(r,i)||(n=l(e,r,n,i,o))}),a.low=s,a.lim=n++,i?a.parent=i:delete a.parent,n}function d(e){return t.find(e.edges(),function(t){return e.edge(t).cutvalue<0})}function f(e,n,o){var i=o.v,s=o.w;n.hasEdge(i,s)||(i=o.w,s=o.v);var a=e.node(i),u=e.node(s),c=a,h=!1;a.lim>u.lim&&(c=u,h=!0);var l=t.filter(n.edges(),function(t){return h===p(e,e.node(t.v),c)&&h!==p(e,e.node(t.w),c)});return t.minBy(l,function(t){return r(n,t)})}function g(e,r,n,i){var s=n.v,a=n.w;e.removeEdge(s,a),e.setEdge(i.v,i.w,{}),h(e),u(e,r),function(e,r){var n=t.find(e.nodes(),function(t){return!r.node(t).parent}),i=o(e,n);i=i.slice(1),t.forEach(i,function(t){var n=e.node(t).parent,o=r.edge(t,n),i=!1;o||(o=r.edge(n,t),i=!0),r.node(t).rank=r.node(n).rank+(i?o.minlen:-o.minlen)})}(e,r)}function p(t,e,r){return r.low<=e.lim&&e.lim<=r.lim}return Zg=a,a.initLowLimValues=h,a.initCutValues=u,a.calcCutValue=c,a.leaveEdge=d,a.enterEdge=f,a.exchangeEdges=g,Zg}function dy(){if(rp)return ep;rp=1;var t=cy().longestPath,e=hy(),r=ly();ep=function(r){switch(r.graph().ranker){case"network-simplex":default:o(r);break;case"tight-tree":!function(r){t(r),e(r)}(r);break;case"longest-path":n(r)}};var n=t;function o(t){r(t)}return ep}function fy(){if(op)return np;op=1;var t=oy();return np=function(e){var r=function(e){var r={},n=0;function o(i){var s=n;t.forEach(e.children(i),o),r[i]={low:s,lim:n++}}return t.forEach(e.children(),o),r}(e);t.forEach(e.graph().dummyChains,function(t){for(var n=e.node(t),o=n.edgeObj,i=function(t,e,r,n){var o,i,s=[],a=[],u=Math.min(e[r].low,e[n].low),c=Math.max(e[r].lim,e[n].lim);o=r;do{o=t.parent(o),s.push(o)}while(o&&(e[o].low>u||c>e[o].lim));i=o,o=n;for(;(o=t.parent(o))!==i;)a.push(o);return{path:s.concat(a.reverse()),lca:i}}(e,r,o.v,o.w),s=i.path,a=i.lca,u=0,c=s[u],h=!0;t!==o.w;){if(n=e.node(t),h){for(;(c=s[u])!==a&&e.node(c).maxRank<n.rank;)u++;c===a&&(h=!1)}if(!h){for(;u<s.length-1&&e.node(c=s[u+1]).minRank<=n.rank;)u++;c=s[u]}e.setParent(t,c),t=e.successors(t)[0]}})},np}function gy(){if(sp)return ip;sp=1;var t=oy(),e=ay();function r(n,o,i,s,a,u,c){var h=n.children(c);if(h.length){var l=e.addBorderNode(n,"_bt"),d=e.addBorderNode(n,"_bb"),f=n.node(c);n.setParent(l,c),f.borderTop=l,n.setParent(d,c),f.borderBottom=d,t.forEach(h,function(t){r(n,o,i,s,a,u,t);var e=n.node(t),h=e.borderTop?e.borderTop:t,f=e.borderBottom?e.borderBottom:t,g=e.borderTop?s:2*s,p=h!==f?1:a-u[c]+1;n.setEdge(l,h,{weight:g,minlen:p,nestingEdge:!0}),n.setEdge(f,d,{weight:g,minlen:p,nestingEdge:!0})}),n.parent(c)||n.setEdge(o,l,{weight:0,minlen:a+u[c]})}else c!==o&&n.setEdge(o,c,{weight:0,minlen:i})}return ip={run:function(n){var o=e.addDummyNode(n,"root",{},"_root"),i=function(e){var r={};function n(o,i){var s=e.children(o);s&&s.length&&t.forEach(s,function(t){n(t,i+1)}),r[o]=i}return t.forEach(e.children(),function(t){n(t,1)}),r}(n),s=t.max(t.values(i))-1,a=2*s+1;n.graph().nestingRoot=o,t.forEach(n.edges(),function(t){n.edge(t).minlen*=a});var u=function(e){return t.reduce(e.edges(),function(t,r){return t+e.edge(r).weight},0)}(n)+1;t.forEach(n.children(),function(t){r(n,o,a,u,s,i,t)}),n.graph().nodeRankFactor=a},cleanup:function(e){var r=e.graph();e.removeNode(r.nestingRoot),delete r.nestingRoot,t.forEach(e.edges(),function(t){e.edge(t).nestingEdge&&e.removeEdge(t)})}},ip}function py(){if(hp)return cp;hp=1;var t=oy();function e(e){t.forEach(e.nodes(),function(t){r(e.node(t))}),t.forEach(e.edges(),function(t){r(e.edge(t))})}function r(t){var e=t.width;t.width=t.height,t.height=e}function n(t){t.y=-t.y}function o(t){var e=t.x;t.x=t.y,t.y=e}return cp={adjust:function(t){var r=t.graph().rankdir.toLowerCase();"lr"!==r&&"rl"!==r||e(t)},undo:function(r){var i=r.graph().rankdir.toLowerCase();"bt"!==i&&"rl"!==i||function(e){t.forEach(e.nodes(),function(t){n(e.node(t))}),t.forEach(e.edges(),function(r){var o=e.edge(r);t.forEach(o.points,n),t.has(o,"y")&&n(o)})}(r);"lr"!==i&&"rl"!==i||(!function(e){t.forEach(e.nodes(),function(t){o(e.node(t))}),t.forEach(e.edges(),function(r){var n=e.edge(r);t.forEach(n.points,o),t.has(n,"x")&&o(n)})}(r),e(r))}},cp}function vy(){if(yp)return mp;yp=1;var t=oy();return mp=function(e,r){var n={};return t.forEach(e,function(e,r){var o=n[e.v]={indegree:0,in:[],out:[],vs:[e.v],i:r};t.isUndefined(e.barycenter)||(o.barycenter=e.barycenter,o.weight=e.weight)}),t.forEach(r.edges(),function(e){var r=n[e.v],o=n[e.w];t.isUndefined(r)||t.isUndefined(o)||(o.indegree++,r.out.push(n[e.w]))}),function(e){var r=[];function n(e){return function(r){r.merged||(t.isUndefined(r.barycenter)||t.isUndefined(e.barycenter)||r.barycenter>=e.barycenter)&&function(t,e){var r=0,n=0;t.weight&&(r+=t.barycenter*t.weight,n+=t.weight);e.weight&&(r+=e.barycenter*e.weight,n+=e.weight);t.vs=e.vs.concat(t.vs),t.barycenter=r/n,t.weight=n,t.i=Math.min(e.i,t.i),e.merged=!0}(e,r)}}function o(t){return function(r){r.in.push(t),0===--r.indegree&&e.push(r)}}for(;e.length;){var i=e.pop();r.push(i),t.forEach(i.in.reverse(),n(i)),t.forEach(i.out,o(i))}return t.map(t.filter(r,function(t){return!t.merged}),function(e){return t.pick(e,["vs","i","barycenter","weight"])})}(t.filter(n,function(t){return!t.indegree}))},mp}function my(){if(Ep)return bp;Ep=1;var t=oy(),e=function(){if(vp)return pp;vp=1;var t=oy();return pp=function(e,r){return t.map(r,function(r){var n=e.inEdges(r);if(n.length){var o=t.reduce(n,function(t,r){var n=e.edge(r),o=e.node(r.v);return{sum:t.sum+n.weight*o.order,weight:t.weight+n.weight}},{sum:0,weight:0});return{v:r,barycenter:o.sum/o.weight,weight:o.weight}}return{v:r}})},pp}(),r=vy(),n=function(){if(xp)return wp;xp=1;var t=oy(),e=ay();function r(e,r,n){for(var o;r.length&&(o=t.last(r)).i<=n;)r.pop(),e.push(o.vs),n++;return n}return wp=function(n,o){var i,s=e.partition(n,function(e){return t.has(e,"barycenter")}),a=s.lhs,u=t.sortBy(s.rhs,function(t){return-t.i}),c=[],h=0,l=0,d=0;a.sort((i=!!o,function(t,e){return t.barycenter<e.barycenter?-1:t.barycenter>e.barycenter?1:i?e.i-t.i:t.i-e.i})),d=r(c,u,d),t.forEach(a,function(t){d+=t.vs.length,c.push(t.vs),h+=t.barycenter*t.weight,l+=t.weight,d=r(c,u,d)});var f={vs:t.flatten(c,!0)};return l&&(f.barycenter=h/l,f.weight=l),f}}();return bp=function o(i,s,a,u){var c=i.children(s),h=i.node(s),l=h?h.borderLeft:void 0,d=h?h.borderRight:void 0,f={};l&&(c=t.filter(c,function(t){return t!==l&&t!==d}));var g=e(i,c);t.forEach(g,function(e){if(i.children(e.v).length){var r=o(i,e.v,a,u);f[e.v]=r,t.has(r,"barycenter")&&(n=e,s=r,t.isUndefined(n.barycenter)?(n.barycenter=s.barycenter,n.weight=s.weight):(n.barycenter=(n.barycenter*n.weight+s.barycenter*s.weight)/(n.weight+s.weight),n.weight+=s.weight))}var n,s});var p=r(g,a);!function(e,r){t.forEach(e,function(e){e.vs=t.flatten(e.vs.map(function(t){return r[t]?r[t].vs:t}),!0)})}(p,f);var v=n(p,u);if(l&&(v.vs=t.flatten([l,v.vs,d],!0),i.predecessors(l).length)){var m=i.node(i.predecessors(l)[0]),y=i.node(i.predecessors(d)[0]);t.has(v,"barycenter")||(v.barycenter=0,v.weight=0),v.barycenter=(v.barycenter*v.weight+m.order+y.order)/(v.weight+2),v.weight+=2}return v},bp}function yy(){if(Np)return Mp;Np=1;var t=oy(),e=Sm().Graph;return Mp=function(r,n,o){var i=function(e){var r;for(;e.hasNode(r=t.uniqueId("_root")););return r}(r),s=new e({compound:!0}).setGraph({root:i}).setDefaultNodeLabel(function(t){return r.node(t)});return t.forEach(r.nodes(),function(e){var a=r.node(e),u=r.parent(e);(a.rank===n||a.minRank<=n&&n<=a.maxRank)&&(s.setNode(e),s.setParent(e,u||i),t.forEach(r[o](e),function(n){var o=n.v===e?n.w:n.v,i=s.edge(o,e),a=t.isUndefined(i)?0:i.weight;s.setEdge(o,e,{weight:r.edge(n).weight+a})}),t.has(a,"minRank")&&s.setNode(e,{borderLeft:a.borderLeft[n],borderRight:a.borderRight[n]}))}),s},Mp}function wy(){if(Ap)return Sp;Ap=1;var t=oy(),e=function(){if(dp)return lp;dp=1;var t=oy();return lp=function(e){var r={},n=t.filter(e.nodes(),function(t){return!e.children(t).length}),o=t.max(t.map(n,function(t){return e.node(t).rank})),i=t.map(t.range(o+1),function(){return[]});function s(n){if(!t.has(r,n)){r[n]=!0;var o=e.node(n);i[o.rank].push(n),t.forEach(e.successors(n),s)}}var a=t.sortBy(n,function(t){return e.node(t).rank});return t.forEach(a,s),i},lp}(),r=function(){if(gp)return fp;gp=1;var t=oy();function e(e,r,n){for(var o=t.zipObject(n,t.map(n,function(t,e){return e})),i=t.flatten(t.map(r,function(r){return t.sortBy(t.map(e.outEdges(r),function(t){return{pos:o[t.w],weight:e.edge(t).weight}}),"pos")}),!0),s=1;s<n.length;)s<<=1;var a=2*s-1;s-=1;var u=t.map(new Array(a),function(){return 0}),c=0;return t.forEach(i.forEach(function(t){var e=t.pos+s;u[e]+=t.weight;for(var r=0;e>0;)e%2&&(r+=u[e+1]),u[e=e-1>>1]+=t.weight;c+=t.weight*r})),c}return fp=function(t,r){for(var n=0,o=1;o<r.length;++o)n+=e(t,r[o-1],r[o]);return n},fp}(),n=my(),o=yy(),i=function(){if(kp)return _p;kp=1;var t=oy();return _p=function(e,r,n){var o,i={};t.forEach(n,function(t){for(var n,s,a=e.parent(t);a;){if((n=e.parent(a))?(s=i[n],i[n]=a):(s=o,o=a),s&&s!==a)return void r.setEdge(s,a);a=n}})}}(),s=Sm().Graph,a=ay();function u(e,r,n){return t.map(r,function(t){return o(e,t,n)})}function c(e,r){var o=new s;t.forEach(e,function(e){var s=e.graph().root,a=n(e,s,o,r);t.forEach(a.vs,function(t,r){e.node(t).order=r}),i(e,o,a.vs)})}function h(e,r){t.forEach(r,function(r){t.forEach(r,function(t,r){e.node(t).order=r})})}return Sp=function(n){var o=a.maxRank(n),i=u(n,t.range(1,o+1),"inEdges"),s=u(n,t.range(o-1,-1,-1),"outEdges"),l=e(n);h(n,l);for(var d,f=Number.POSITIVE_INFINITY,g=0,p=0;p<4;++g,++p){c(g%2?i:s,g%4>=2),l=a.buildLayerMatrix(n);var v=r(n,l);v<f&&(p=0,d=t.cloneDeep(l),f=v)}h(n,d)},Sp}function xy(){if(zp)return Op;zp=1;var t=oy(),e=Sm().Graph,r=ay();function n(e,r){var n={};return t.reduce(r,function(r,o){var s=0,a=0,u=r.length,c=t.last(o);return t.forEach(o,function(r,h){var l=function(e,r){if(e.node(r).dummy)return t.find(e.predecessors(r),function(t){return e.node(t).dummy})}(e,r),d=l?e.node(l).order:u;(l||r===c)&&(t.forEach(o.slice(a,h+1),function(r){t.forEach(e.predecessors(r),function(t){var o=e.node(t),a=o.order;!(a<s||d<a)||o.dummy&&e.node(r).dummy||i(n,t,r)})}),a=h+1,s=d)}),o}),n}function o(e,r){var n={};function o(r,o,s,a,u){var c;t.forEach(t.range(o,s),function(o){c=r[o],e.node(c).dummy&&t.forEach(e.predecessors(c),function(t){var r=e.node(t);r.dummy&&(r.order<a||r.order>u)&&i(n,t,c)})})}return t.reduce(r,function(r,n){var i,s=-1,a=0;return t.forEach(n,function(t,u){if("border"===e.node(t).dummy){var c=e.predecessors(t);c.length&&(i=e.node(c[0]).order,o(n,a,u,s,i),a=u,s=i)}o(n,a,n.length,i,r.length)}),n}),n}function i(t,e,r){if(e>r){var n=e;e=r,r=n}var o=t[e];o||(t[e]=o={}),o[r]=!0}function s(e,r,n){if(r>n){var o=r;r=n,n=o}return t.has(e[r],n)}function a(e,r,n,o){var i={},a={},u={};return t.forEach(r,function(e){t.forEach(e,function(t,e){i[t]=t,a[t]=t,u[t]=e})}),t.forEach(r,function(e){var r=-1;t.forEach(e,function(e){var c=o(e);if(c.length){c=t.sortBy(c,function(t){return u[t]});for(var h=(c.length-1)/2,l=Math.floor(h),d=Math.ceil(h);l<=d;++l){var f=c[l];a[e]===e&&r<u[f]&&!s(n,e,f)&&(a[f]=e,a[e]=i[e]=i[f],r=u[f])}}})}),{root:i,align:a}}function u(r,n,o,i,s){var a={},u=function(r,n,o,i){var s=new e,a=r.graph(),u=function(e,r,n){return function(o,i,s){var a,u=o.node(i),c=o.node(s),h=0;if(h+=u.width/2,t.has(u,"labelpos"))switch(u.labelpos.toLowerCase()){case"l":a=-u.width/2;break;case"r":a=u.width/2}if(a&&(h+=n?a:-a),a=0,h+=(u.dummy?r:e)/2,h+=(c.dummy?r:e)/2,h+=c.width/2,t.has(c,"labelpos"))switch(c.labelpos.toLowerCase()){case"l":a=c.width/2;break;case"r":a=-c.width/2}return a&&(h+=n?a:-a),a=0,h}}(a.nodesep,a.edgesep,i);return t.forEach(n,function(e){var n;t.forEach(e,function(t){var e=o[t];if(s.setNode(e),n){var i=o[n],a=s.edge(i,e);s.setEdge(i,e,Math.max(u(r,t,n),a||0))}n=t})}),s}(r,n,o,s),c=s?"borderLeft":"borderRight";function h(t,e){for(var r=u.nodes(),n=r.pop(),o={};n;)o[n]?t(n):(o[n]=!0,r.push(n),r=r.concat(e(n))),n=r.pop()}return h(function(t){a[t]=u.inEdges(t).reduce(function(t,e){return Math.max(t,a[e.v]+u.edge(e))},0)},u.predecessors.bind(u)),h(function(t){var e=u.outEdges(t).reduce(function(t,e){return Math.min(t,a[e.w]-u.edge(e))},Number.POSITIVE_INFINITY),n=r.node(t);e!==Number.POSITIVE_INFINITY&&n.borderType!==c&&(a[t]=Math.max(a[t],e))},u.successors.bind(u)),t.forEach(i,function(t){a[t]=a[o[t]]}),a}function c(e,r){return t.minBy(t.values(r),function(r){var n=Number.NEGATIVE_INFINITY,o=Number.POSITIVE_INFINITY;return t.forIn(r,function(t,r){var i=function(t,e){return t.node(e).width}(e,r)/2;n=Math.max(t+i,n),o=Math.min(t-i,o)}),n-o})}function h(e,r){var n=t.values(r),o=t.min(n),i=t.max(n);t.forEach(["u","d"],function(n){t.forEach(["l","r"],function(s){var a,u=n+s,c=e[u];if(c!==r){var h=t.values(c);(a="l"===s?o-t.min(h):i-t.max(h))&&(e[u]=t.mapValues(c,function(t){return t+a}))}})})}function l(e,r){return t.mapValues(e.ul,function(n,o){if(r)return e[r.toLowerCase()][o];var i=t.sortBy(t.map(e,o));return(i[1]+i[2])/2})}return Op={positionX:function(e){var i,s=r.buildLayerMatrix(e),d=t.merge(n(e,s),o(e,s)),f={};t.forEach(["u","d"],function(r){i="u"===r?s:t.values(s).reverse(),t.forEach(["l","r"],function(n){"r"===n&&(i=t.map(i,function(e){return t.values(e).reverse()}));var o=("u"===r?e.predecessors:e.successors).bind(e),s=a(e,i,d,o),c=u(e,i,s.root,s.align,"r"===n);"r"===n&&(c=t.mapValues(c,function(t){return-t})),f[r+n]=c})});var g=c(e,f);return h(f,g),l(f,e.graph().align)},findType1Conflicts:n,findType2Conflicts:o,addConflict:i,hasConflict:s,verticalAlignment:a,horizontalCompaction:u,alignCoordinates:h,findSmallestWidthAlignment:c,balance:l},Op}function by(){if(Cp)return jp;Cp=1;var t=oy(),e=ay(),r=xy().positionX;return jp=function(n){(function(r){var n=e.buildLayerMatrix(r),o=r.graph().ranksep,i=0;t.forEach(n,function(e){var n=t.max(t.map(e,function(t){return r.node(t).height}));t.forEach(e,function(t){r.node(t).y=i+n/2}),i+=n+o})})(n=e.asNonCompoundGraph(n)),t.forEach(r(n),function(t,e){n.node(e).x=t})},jp}function Ey(){if(Rp)return Ip;Rp=1;var t=oy(),e=sy(),r=uy(),n=dy(),o=ay().normalizeRanks,i=fy(),s=ay().removeEmptyRanks,a=gy(),u=function(){if(up)return ap;up=1;var t=oy(),e=ay();function r(t,r,n,o,i,s){var a={width:0,height:0,rank:s,borderType:r},u=i[r][s-1],c=e.addDummyNode(t,"border",a,n);i[r][s]=c,t.setParent(c,o),u&&t.setEdge(u,c,{weight:1})}return ap=function(e){t.forEach(e.children(),function n(o){var i=e.children(o),s=e.node(o);if(i.length&&t.forEach(i,n),t.has(s,"minRank")){s.borderLeft=[],s.borderRight=[];for(var a=s.minRank,u=s.maxRank+1;a<u;++a)r(e,"borderLeft","_bl",o,s,a),r(e,"borderRight","_br",o,s,a)}})},ap}(),c=py(),h=wy(),l=by(),d=ay(),f=Sm().Graph;Ip=function(N,_){var k=_&&_.debugTiming?d.time:d.notime;k("layout",function(){var _=k(" buildLayoutGraph",function(){return function(e){var r=new f({multigraph:!0,compound:!0}),n=M(e.graph());return r.setGraph(t.merge({},p,E(n,g),t.pick(n,v))),t.forEach(e.nodes(),function(n){var o=M(e.node(n));r.setNode(n,t.defaults(E(o,m),y)),r.setParent(n,e.parent(n))}),t.forEach(e.edges(),function(n){var o=M(e.edge(n));r.setEdge(n,t.merge({},x,E(o,w),t.pick(o,b)))}),r}(N)});k(" runLayout",function(){!function(f,g){g(" makeSpaceForEdgeLabels",function(){!function(e){var r=e.graph();r.ranksep/=2,t.forEach(e.edges(),function(t){var n=e.edge(t);n.minlen*=2,"c"!==n.labelpos.toLowerCase()&&("TB"===r.rankdir||"BT"===r.rankdir?n.width+=n.labeloffset:n.height+=n.labeloffset)})}(f)}),g(" removeSelfEdges",function(){!function(e){t.forEach(e.edges(),function(t){if(t.v===t.w){var r=e.node(t.v);r.selfEdges||(r.selfEdges=[]),r.selfEdges.push({e:t,label:e.edge(t)}),e.removeEdge(t)}})}(f)}),g(" acyclic",function(){e.run(f)}),g(" nestingGraph.run",function(){a.run(f)}),g(" rank",function(){n(d.asNonCompoundGraph(f))}),g(" injectEdgeLabelProxies",function(){!function(e){t.forEach(e.edges(),function(t){var r=e.edge(t);if(r.width&&r.height){var n=e.node(t.v),o={rank:(e.node(t.w).rank-n.rank)/2+n.rank,e:t};d.addDummyNode(e,"edge-proxy",o,"_ep")}})}(f)}),g(" removeEmptyRanks",function(){s(f)}),g(" nestingGraph.cleanup",function(){a.cleanup(f)}),g(" normalizeRanks",function(){o(f)}),g(" assignRankMinMax",function(){!function(e){var r=0;t.forEach(e.nodes(),function(n){var o=e.node(n);o.borderTop&&(o.minRank=e.node(o.borderTop).rank,o.maxRank=e.node(o.borderBottom).rank,r=t.max(r,o.maxRank))}),e.graph().maxRank=r}(f)}),g(" removeEdgeLabelProxies",function(){!function(e){t.forEach(e.nodes(),function(t){var r=e.node(t);"edge-proxy"===r.dummy&&(e.edge(r.e).labelRank=r.rank,e.removeNode(t))})}(f)}),g(" normalize.run",function(){r.run(f)}),g(" parentDummyChains",function(){i(f)}),g(" addBorderSegments",function(){u(f)}),g(" order",function(){h(f)}),g(" insertSelfEdges",function(){!function(e){var r=d.buildLayerMatrix(e);t.forEach(r,function(r){var n=0;t.forEach(r,function(r,o){var i=e.node(r);i.order=o+n,t.forEach(i.selfEdges,function(t){d.addDummyNode(e,"selfedge",{width:t.label.width,height:t.label.height,rank:i.rank,order:o+ ++n,e:t.e,label:t.label},"_se")}),delete i.selfEdges})})}(f)}),g(" adjustCoordinateSystem",function(){c.adjust(f)}),g(" position",function(){l(f)}),g(" positionSelfEdges",function(){!function(e){t.forEach(e.nodes(),function(t){var r=e.node(t);if("selfedge"===r.dummy){var n=e.node(r.e.v),o=n.x+n.width/2,i=n.y,s=r.x-o,a=n.height/2;e.setEdge(r.e,r.label),e.removeNode(t),r.label.points=[{x:o+2*s/3,y:i-a},{x:o+5*s/6,y:i-a},{x:o+s,y:i},{x:o+5*s/6,y:i+a},{x:o+2*s/3,y:i+a}],r.label.x=r.x,r.label.y=r.y}})}(f)}),g(" removeBorderNodes",function(){!function(e){t.forEach(e.nodes(),function(r){if(e.children(r).length){var n=e.node(r),o=e.node(n.borderTop),i=e.node(n.borderBottom),s=e.node(t.last(n.borderLeft)),a=e.node(t.last(n.borderRight));n.width=Math.abs(a.x-s.x),n.height=Math.abs(i.y-o.y),n.x=s.x+n.width/2,n.y=o.y+n.height/2}}),t.forEach(e.nodes(),function(t){"border"===e.node(t).dummy&&e.removeNode(t)})}(f)}),g(" normalize.undo",function(){r.undo(f)}),g(" fixupEdgeLabelCoords",function(){!function(e){t.forEach(e.edges(),function(r){var n=e.edge(r);if(t.has(n,"x"))switch("l"!==n.labelpos&&"r"!==n.labelpos||(n.width-=n.labeloffset),n.labelpos){case"l":n.x-=n.width/2+n.labeloffset;break;case"r":n.x+=n.width/2+n.labeloffset}})}(f)}),g(" undoCoordinateSystem",function(){c.undo(f)}),g(" translateGraph",function(){!function(e){var r=Number.POSITIVE_INFINITY,n=0,o=Number.POSITIVE_INFINITY,i=0,s=e.graph(),a=s.marginx||0,u=s.marginy||0;function c(t){var e=t.x,s=t.y,a=t.width,u=t.height;r=Math.min(r,e-a/2),n=Math.max(n,e+a/2),o=Math.min(o,s-u/2),i=Math.max(i,s+u/2)}t.forEach(e.nodes(),function(t){c(e.node(t))}),t.forEach(e.edges(),function(r){var n=e.edge(r);t.has(n,"x")&&c(n)}),r-=a,o-=u,t.forEach(e.nodes(),function(t){var n=e.node(t);n.x-=r,n.y-=o}),t.forEach(e.edges(),function(n){var i=e.edge(n);t.forEach(i.points,function(t){t.x-=r,t.y-=o}),t.has(i,"x")&&(i.x-=r),t.has(i,"y")&&(i.y-=o)}),s.width=n-r+a,s.height=i-o+u}(f)}),g(" assignNodeIntersects",function(){!function(e){t.forEach(e.edges(),function(t){var r,n,o=e.edge(t),i=e.node(t.v),s=e.node(t.w);o.points?(r=o.points[0],n=o.points[o.points.length-1]):(o.points=[],r=s,n=i),o.points.unshift(d.intersectRect(i,r)),o.points.push(d.intersectRect(s,n))})}(f)}),g(" reversePoints",function(){!function(e){t.forEach(e.edges(),function(t){var r=e.edge(t);r.reversed&&r.points.reverse()})}(f)}),g(" acyclic.undo",function(){e.undo(f)})}(_,k)}),k(" updateInputGraph",function(){!function(e,r){t.forEach(e.nodes(),function(t){var n=e.node(t),o=r.node(t);n&&(n.x=o.x,n.y=o.y,r.children(t).length&&(n.width=o.width,n.height=o.height))}),t.forEach(e.edges(),function(n){var o=e.edge(n),i=r.edge(n);o.points=i.points,t.has(i,"x")&&(o.x=i.x,o.y=i.y)}),e.graph().width=r.graph().width,e.graph().height=r.graph().height}(N,_)})})};var g=["nodesep","edgesep","ranksep","marginx","marginy"],p={ranksep:50,edgesep:20,nodesep:50,rankdir:"tb"},v=["acyclicer","ranker","rankdir","align"],m=["width","height"],y={width:0,height:0},w=["minlen","weight","width","height","labeloffset"],x={minlen:1,weight:1,width:0,height:0,labeloffset:10,labelpos:"r"},b=["labelpos"];function E(e,r){return t.mapValues(t.pick(e,r),Number)}function M(e){var r={};return t.forEach(e,function(t,e){r[e.toLowerCase()]=t}),r}return Ip}function My(){if(Pp)return Tp;Pp=1;var t=oy(),e=ay(),r=Sm().Graph;return Tp={debugOrdering:function(n){var o=e.buildLayerMatrix(n),i=new r({compound:!0,multigraph:!0}).setGraph({});return t.forEach(n.nodes(),function(t){i.setNode(t,{label:t}),i.setParent(t,"layer"+n.node(t).rank)}),t.forEach(n.edges(),function(t){i.setEdge(t.v,t.w,{},t.name)}),t.forEach(o,function(e,r){var n="layer"+r;i.setNode(n,{rank:"same"}),t.reduce(e,function(t,e){return i.setEdge(t,e,{style:"invis"}),e})}),i}},Tp}var Ny=qp?Dp:(qp=1,Dp={graphlib:Sm(),layout:Ey(),debug:My(),util:{time:ay().time,notime:ay().notime},version:Lp?Fp:(Lp=1,Fp="0.8.5")}),_y=fs(Ny);const ky=1e-6;function Sy(t){var e;let r=0;if(t.length)for(let e=0;e<t.length;e++){const n=t[e];n&&n.r>r&&(r=n.r)}else if(t.data){r=t.data.r||0;let n=t.next;for(;n;)r=Math.max(r,(null===(e=n.data)||void 0===e?void 0:e.r)||0),n=n.next}t.r=r}function Ay(t=1,e=.005,r=2){function n(n,o){!function(t,e,r,n,o=2){const i=e/r,s=t.nodes(),a=s.map((t,e)=>{const{nodeStrength:r,x:n,y:o,z:s,size:a,mass:u}=t;return{x:n,y:o,z:s,size:a,index:e,id:t.id,vx:0,vy:0,vz:0,weight:i*r,mass:u||1}}),u=(2===o?Cr(a,t=>t.x,t=>t.y):qn(a,t=>t.x,t=>t.y,t=>t.z)).visitAfter(Oy),c=new Map;a.forEach(t=>{c.set(t.id,t),function(t,e,r){e.visit((e,n,o,i,s,a,u)=>zy(e,n,o,i,s,a,u,t,r))}(t,u,o)}),a.map(t=>{const e=t.id;n[e]={x:t.vx/t.mass,y:t.vy/t.mass,z:t.vz/t.mass}})}(n,t,e*e,o,r)}return n.factor=function(e){return arguments.length?(t=e,n):t},n.coulombDisScale=function(t){return arguments.length?(e=t,n):e},n.dimensions=function(t){return arguments.length?(r=t,n):r},n}function Oy(t){let e=0,r=0,n=0,o=0,i=0;const s=t.length;if(s){for(let a=0;a<s;a++){const s=t[a];s&&s.weight&&(e+=s.weight,r+=s.x*s.weight,n+=s.y*s.weight,o+=s.z*s.weight,i+=s.size*s.weight)}t.x=r/e,t.y=n/e,t.z=o/e,t.size=i/e,t.weight=e}else{const e=t;t.x=e.data.x,t.y=e.data.y,t.z=e.data.z,t.size=e.data.size,t.weight=e.data.weight}}const zy=(t,e,r,n,o,i,s,a,u)=>{var c;if((null===(c=t.data)||void 0===c?void 0:c.id)===a.id)return;const h=2===u?n:3===u?i:r,l=a.x-t.x||.1,d=a.y-t.y||.1,f=a.z-t.z||.1,g=[l,d,f],p=h-e;let v=0;for(let t=0;t<u;t++)v+=g[t]*g[t];const m=Math.sqrt(v)*v;if(p*p*.81<v){const e=t.weight/m;return a.vx+=l*e,a.vy+=d*e,a.vz+=f*e,!0}if(t.length)return!1;if(t.data!==a){const e=t.data.weight/m;a.vx+=l*e,a.vy+=d*e,a.vz+=f*e}};var jy=function(){function t(){this._events={}}return t.prototype.on=function(t,e,r){return this._events[t]||(this._events[t]=[]),this._events[t].push({callback:e,once:!!r}),this},t.prototype.once=function(t,e){return this.on(t,e,!0)},t.prototype.emit=function(t){for(var e=this,r=[],n=1;n<arguments.length;n++)r[n-1]=arguments[n];var o=this._events[t]||[],i=this._events["*"]||[],s=function(n){for(var o=n.length,i=0;i<o;i++)if(n[i]){var s=n[i],a=s.callback;s.once&&(n.splice(i,1),0===n.length&&delete e._events[t],o--,i--),a.apply(e,r)}};s(o),s(i)},t.prototype.off=function(t,e){if(t)if(e){for(var r=this._events[t]||[],n=r.length,o=0;o<n;o++)r[o].callback===e&&(r.splice(o,1),n--,o--);0===r.length&&delete this._events[t]}else delete this._events[t];else this._events={};return this},t.prototype.getEvents=function(){return this._events},t}();class Cy extends jy{constructor(){super(...arguments),this.iteration=0,this.judgingDistance=1/0,this.running=!1,this.tickCallback=null,this.endCallback=null,this.timer=0}initialize(t){this.options=t,this.iteration=0,this.judgingDistance=1/0}on(t,e){return"tick"===t&&(this.tickCallback=e),"end"===t&&(this.endCallback=e),this}tick(t=1){var e;for(let r=0;r<t;r++){const t=this.runOneStep();this.judgingDistance=t,this.iteration++,null===(e=this.tickCallback)||void 0===e||e.call(this)}return this}restart(){if(this.running)return this;const{maxIteration:t=500,minMovement:e=0,animate:r=!0}=this.options;if(!r||"undefined"==typeof window){for(;this.iteration<t&&(this.judgingDistance>e||this.iteration<1);)this.tick(1);return Promise.resolve().then(()=>{var t;null===(t=this.endCallback)||void 0===t||t.call(this)}),this}return this.running=!0,this.timer=window.setInterval(()=>{var r;this.tick(1),(this.iteration>=t||this.judgingDistance<e)&&(this.stop(),null===(r=this.endCallback)||void 0===r||r.call(this))},0),this}stop(){return this.running=!1,this.timer&&(clearInterval(this.timer),this.timer=0),this}}class Iy extends Cy{constructor(){super(...arguments),this.forces=new Map,this.velMap={}}data(t){return this.model=t,t.forEachNode(t=>{this.velMap[t.id]={x:0,y:0,z:0}}),this}force(t,e){return 1===arguments.length?this.forces.get(t)||null:(null===e?this.forces.delete(t):e&&this.forces.set(t,e),e||null)}runOneStep(){const t={},e=this.model.nodes();if(!e.length)return 0;e.forEach(e=>{t[e.id]={x:0,y:0,z:0}}),this.forces.forEach(e=>{e(this.model,t)}),this.updateVelocity(t);const r=this.updatePosition();return this.monitor(t,e),r}setFixedPosition(t,e){const r=this.model.node(t);if(!r)return;const n=["fx","fy","fz"];if(null===e)return void n.forEach(t=>delete r[t]);e.forEach((t,e)=>{e<n.length&&("number"==typeof t||null===t)&&(r[n[e]]=t)});const o=this.velMap[t];o&&(o.x=0,o.y=0,o.z=0)}updateVelocity(t){const{damping:e=.9,maxSpeed:r=100,interval:n=.02,dimensions:o=2}=this.options;this.model.nodes().forEach(i=>{const s=i.id;let a=(this.velMap[s].x+t[s].x*n)*e,u=(this.velMap[s].y+t[s].y*n)*e,c=3===o?(this.velMap[s].z+t[s].z*n)*e:0;const h=Math.sqrt(a*a+u*u+c*c);if(h>r){const t=r/h;a*=t,u*=t,c*=t}this.velMap[s]={x:a,y:u,z:c}})}updatePosition(){const{distanceThresholdMode:t="mean",interval:e=.02,dimensions:r=2}=this.options,n=this.model.nodes();let o=0,i="max"===t?-1/0:"min"===t?1/0:0;return n.forEach(n=>{const s=n.id;if(O(n.fx)&&O(n.fy))return n.x=n.fx,n.y=n.fy,void(3===r&&O(n.fz)&&(n.z=n.fz));const a=this.velMap[s].x*e,u=this.velMap[s].y*e,c=3===r?this.velMap[s].z*e:0;n.x+=a,n.y+=u,3===r&&(n.z=(n.z||0)+c);const h=Math.sqrt(a*a+u*u+c*c);"max"===t?i=Math.max(i,h):"min"===t?i=Math.min(i,h):o+=h}),"mean"===t?o/n.length:i}monitor(t,e){const{monitor:r,dimensions:n=2}=this.options;if(!r)return;let o=0;e.forEach(e=>{const r=t[e.id],i=r.x*r.x+r.y*r.y+(3===n?r.z*r.z:0);o+=(e.mass||1)*i*.5}),r({energy:o,nodes:e,edges:this.model.edges(),iterations:this.iteration})}}const Ry={nodeSize:30,dimensions:2,maxIteration:500,gravity:10,factor:1,edgeStrength:50,nodeStrength:1e3,coulombDisScale:.005,damping:.9,maxSpeed:200,minMovement:.4,interval:.02,linkDistance:200,clusterNodeStrength:20,collideStrength:1,preventOverlap:!0,distanceThresholdMode:"mean"};class Ty{constructor(t){this.id=t.id||0,this.rx=t.rx,this.ry=t.ry,this.fx=0,this.fy=0,this.mass=t.mass,this.degree=t.degree,this.g=t.g||0}distanceTo(t){const e=this.rx-t.rx,r=this.ry-t.ry;return Math.hypot(e,r)}setPos(t,e){this.rx=t,this.ry=e}resetForce(){this.fx=0,this.fy=0}addForce(t){const e=t.rx-this.rx,r=t.ry-this.ry;let n=Math.hypot(e,r);n=n<1e-4?1e-4:n;const o=this.g*(this.degree+1)*(t.degree+1)/n;this.fx+=o*e/n,this.fy+=o*r/n}in(t){return t.contains(this.rx,this.ry)}add(t){const e=this.mass+t.mass,r=(this.rx*this.mass+t.rx*t.mass)/e,n=(this.ry*this.mass+t.ry*t.mass)/e,o=this.degree+t.degree;return new Ty({rx:r,ry:n,mass:e,degree:o})}}class Py{constructor(t){this.xmid=t.xmid,this.ymid=t.ymid,this.length=t.length,this.massCenter=t.massCenter||[0,0],this.mass=t.mass||1}getLength(){return this.length}contains(t,e){const r=this.length/2;return t<=this.xmid+r&&t>=this.xmid-r&&e<=this.ymid+r&&e>=this.ymid-r}NW(){const t=this.xmid-this.length/4,e=this.ymid+this.length/4,r=this.length/2;return new Py({xmid:t,ymid:e,length:r})}NE(){const t=this.xmid+this.length/4,e=this.ymid+this.length/4,r=this.length/2;return new Py({xmid:t,ymid:e,length:r})}SW(){const t=this.xmid-this.length/4,e=this.ymid-this.length/4,r=this.length/2;return new Py({xmid:t,ymid:e,length:r})}SE(){const t=this.xmid+this.length/4,e=this.ymid-this.length/4,r=this.length/2;return new Py({xmid:t,ymid:e,length:r})}}class Fy{constructor(t){this.body=null,this.quad=null,this.NW=null,this.NE=null,this.SW=null,this.SE=null,this.theta=.5,null!=t&&(this.quad=t)}insert(t){null!=this.body?this._isExternal()?(this.quad&&(this.NW=new Fy(this.quad.NW()),this.NE=new Fy(this.quad.NE()),this.SW=new Fy(this.quad.SW()),this.SE=new Fy(this.quad.SE())),this._putBody(this.body),this._putBody(t),this.body=this.body.add(t)):(this.body=this.body.add(t),this._putBody(t)):this.body=t}_putBody(t){this.quad&&(t.in(this.quad.NW())&&this.NW?this.NW.insert(t):t.in(this.quad.NE())&&this.NE?this.NE.insert(t):t.in(this.quad.SW())&&this.SW?this.SW.insert(t):t.in(this.quad.SE())&&this.SE&&this.SE.insert(t))}_isExternal(){return null==this.NW&&null==this.NE&&null==this.SW&&null==this.SE}updateForce(t){if(null!=this.body&&t!==this.body)if(this._isExternal())t.addForce(this.body);else{(this.quad?this.quad.getLength():0)/this.body.distanceTo(t)<this.theta?t.addForce(this.body):(this.NW&&this.NW.updateForce(t),this.NE&&this.NE.updateForce(t),this.SW&&this.SW.updateForce(t),this.SE&&this.SE.updateForce(t))}}}let Ly=class extends Cy{constructor(){super(...arguments),this.sg=0,this.forces={},this.preForces={},this.bodies={},this.sizes={},this.maxIteration=0}data(t,e){return this.model=t,this.sizes=e,this}initialize(t){super.initialize(t),this.maxIteration=t.maxIteration,this.sg=0,this.initForces()}initForces(){const{model:t,options:e}=this,{kr:r,barnesHut:n}=e,o=t.nodes();this.forces={},this.preForces={},this.bodies={};for(let e=0;e<o.length;e+=1){const i=o[e];if(this.forces[i.id]=[0,0],this.preForces[i.id]=[0,0],n){const n={id:e,rx:i.x,ry:i.y,mass:1,g:r,degree:t.degree(i.id)};this.bodies[i.id]=new Ty(n)}}}setFixedPosition(t,e){const r=this.model.node(t);if(!r)return;const n=["fx","fy","fz"];null!==e?e.forEach((t,e)=>{e<n.length&&("number"==typeof t||null===t)&&(r[n[e]]=t)}):n.forEach(t=>{delete r[t]})}isNodeFixed(t){return O(t.fx)&&O(t.fy)}syncFixedPositions(){this.model.forEachNode(t=>{this.isNodeFixed(t)&&(t.x=t.fx,t.y=t.fy)})}runOneStep(){const{model:t,options:e}=this,{preventOverlap:r,barnesHut:n}=e,o=this.maxIteration-this.iteration,i=t.nodes();for(let t=0;t<i.length;t+=1){const{id:e}=i[t];this.preForces[e]=[...this.forces[e]||[0,0]],this.forces[e]=[0,0]}return this.syncFixedPositions(),this.calculateAttractive(o),n&&!r?this.calculateOptRepulsiveGravity():this.calculateRepulsiveGravity(o,100),this.updatePositions()}calculateAttractive(t){const{model:e,options:r}=this,{preventOverlap:n,dissuadeHubs:o,mode:i,prune:s}=r,a=e.edges();for(let t=0;t<a.length;t+=1){const{source:r,target:u}=a[t],c=e.node(r),h=e.node(u),l=e.degree(r),d=e.degree(u);if(s&&(l<=1||d<=1))continue;const f=h.x-c.x,g=h.y-c.y;let p=Math.hypot(f,g);p=p<1e-4?1e-4:p;const v=f/p,m=g/p;let y=p;n&&(y=Math.max(0,p-this.sizes[r]-this.sizes[u]));let w=y,x=y;"linlog"===i&&(w=Math.log(1+y),x=w),o&&(w=y/l,x=y/d),this.forces[r][0]+=w*v,this.forces[r][1]+=w*m,this.forces[u][0]-=x*v,this.forces[u][1]-=x*m}}calculateOptRepulsiveGravity(){const{model:t,options:e}=this,{kg:r,center:n,prune:o,kr:i}=e,s=t.nodes(),a=s.length;let u=Number.POSITIVE_INFINITY,c=Number.NEGATIVE_INFINITY,h=Number.POSITIVE_INFINITY,l=Number.NEGATIVE_INFINITY;for(let e=0;e<a;e+=1){const r=s[e],{id:n,x:i,y:a}=r;if(o&&t.degree(n)<=1)continue;const d=this.bodies[n];d&&(d.setPos(i,a),i<u&&(u=i),i>c&&(c=i),a<h&&(h=a),a>l&&(l=a))}let d=Math.max(c-u,l-h);(!isFinite(d)||d<=0)&&(d=1);const f=new Py({xmid:(c+u)/2,ymid:(l+h)/2,length:d,massCenter:n,mass:a}),g=new Fy(f);for(let e=0;e<a;e+=1){const{id:r}=s[e];if(o&&t.degree(r)<=1)continue;const n=this.bodies[r];n&&n.in(f)&&g.insert(n)}for(let e=0;e<a;e+=1){const i=s[e],{id:a,x:u,y:c}=i,h=t.degree(a);if(o&&h<=1)continue;const l=this.bodies[a];if(!l)continue;l.resetForce(),g.updateForce(l),this.forces[a][0]-=l.fx,this.forces[a][1]-=l.fy;const d=u-n[0],f=c-n[1];let p=Math.hypot(d,f);p=p<1e-4?1e-4:p;const v=d/p,m=f/p,y=r*(h+1);this.forces[a][0]-=y*v,this.forces[a][1]-=y*m}}calculateRepulsiveGravity(t,e){const{model:r,options:n}=this,{preventOverlap:o,kr:i,kg:s,center:a,prune:u}=n,c=r.nodes(),h=c.length;for(let t=0;t<h;t+=1){const n=c[t],l=r.degree(n.id);for(let s=t+1;s<h;s+=1){const t=c[s],a=r.degree(t.id);if(u&&(l<=1||a<=1))continue;const h=t.x-n.x,d=t.y-n.y;let f=Math.hypot(h,d);f=f<1e-4?1e-4:f;const g=h/f,p=d/f;let v,m=f;if(o){const r=f-this.sizes[n.id]-this.sizes[t.id];r<0?v=e*(l+1)*(a+1):0===r?v=0:(m=r,v=i*(l+1)*(a+1)/m)}else v=i*(l+1)*(a+1)/m;this.forces[n.id][0]-=v*g,this.forces[n.id][1]-=v*p,this.forces[t.id][0]+=v*g,this.forces[t.id][1]+=v*p}const d=n.x-a[0],f=n.y-a[1];let g=Math.hypot(d,f);g=g<1e-4?1e-4:g;const p=d/g,v=f/g,m=s*(l+1);this.forces[n.id][0]-=m*p,this.forces[n.id][1]-=m*v}}updatePositions(){const{model:t,options:e}=this,{ks:r,tao:n,prune:o,ksmax:i,distanceThresholdMode:s="max"}=e,a=t.nodes(),u=a.length,c={},h={};let l=0,d=0;for(let e=0;e<u;e+=1){const{id:r}=a[e],n=t.degree(r);if(o&&n<=1)continue;const i=this.preForces[r]||[0,0],s=this.forces[r]||[0,0],u=s[0]-i[0],f=s[1]-i[1],g=Math.hypot(u,f),p=s[0]+i[0],v=s[1]+i[1],m=Math.hypot(p,v);c[r]=g,h[r]=m/2,l+=(n+1)*c[r],d+=(n+1)*h[r]}let f=this.sg;const g=this.sg;l<=0?f=g>0?g:1:(f=n*d/l,0!==g&&(f=f>1.5*g?1.5*g:f)),this.sg=f;let p=0,v=1/0,m=0,y=0;for(let e=0;e<u;e+=1){const n=a[e],s=n.id,u=t.degree(s);if(o&&u<=1)continue;if(this.isNodeFixed(n))continue;const h=c[s]||0;let l=r*f/(1+f*Math.sqrt(h)),d=Math.hypot(this.forces[s][0],this.forces[s][1]);d=d<1e-4?1e-4:d;const g=i/d;l>g&&(l=g);const w=l*this.forces[s][0],x=l*this.forces[s][1];n.x+=w,n.y+=x;const b=Math.hypot(w,x);b>0&&(y++,m+=b,b>p&&(p=b),b<v&&(v=b))}switch(s){case"min":return v;case"mean":return y>0?m/y:0;default:return p}}destroy(){this.stop(),this.forces={},this.preForces={},this.bodies={},this.sizes={},this.off()}};const Dy={nodeSize:10,nodeSpacing:0,width:300,height:300,kr:5,kg:1,mode:"normal",preventOverlap:!1,dissuadeHubs:!1,maxIteration:0,ks:.1,ksmax:10,tao:.1};class qy extends Cy{constructor(){super(...arguments),this.displacements=null,this.clusterMap=null}data(t){return this.model=t,this}initialize(t){super.initialize(t),this.recomputeConstants(),this.displacements=null,this.clusterMap=null,this.initDisplacements()}recomputeConstants(){const{model:t,options:e}=this,{width:r,height:n}=Mt(e),o=r*n;this.k2=o/(t.nodeCount()+1),this.k=Math.sqrt(this.k2),this.maxDisplace=Math.sqrt(o)/10}runOneStep(){return this.syncFixedPositions(),this.initDisplacements(),this.calculateRepulsive(),this.calculateAttractive(),this.applyClusterGravity(),this.applyGlobalGravity(),this.updatePositions()}setFixedPosition(t,e){const r=this.model.node(t);if(!r)return;const n=["fx","fy","fz"];null!==e?e.forEach((t,e)=>{e<n.length&&("number"==typeof t||null===t)&&(r[n[e]]=t)}):n.forEach(t=>{delete r[t]})}isNodeFixed(t){return!M(t.fx)&&!M(t.fy)}syncFixedPositions(){const{model:t,options:e}=this,r=3===e.dimensions;t.forEachNode(t=>{this.isNodeFixed(t)&&(t.x=t.fx,t.y=t.fy,r&&void 0!==t.fz&&(t.z=t.fz))})}initDisplacements(){this.displacements||(this.displacements=new Map,this.model.forEachNode(t=>{this.displacements.set(t.id,{x:0,y:0,z:0})})),this.displacements.forEach(t=>{t.x=0,t.y=0,t.z=0})}calculateRepulsive(){const{model:t,options:e}=this,r=3===e.dimensions,n=t.nodes();for(let t=0;t<n.length;t++){const e=n[t],o=this.displacements.get(e.id),i=this.isNodeFixed(e);for(let s=t+1;s<n.length;s++){const t=n[s],a=this.displacements.get(t.id),u=this.isNodeFixed(t);let c=e.x-t.x,h=e.y-t.y,l=r?e.z-t.z:0,d=c*c+h*h+l*l;0===d&&(d=1,c=.01,h=.01,l=.01);const f=this.k2/d,g=c*f,p=h*f,v=l*f;i||u?i&&!u?(a.x-=2*g,a.y-=2*p,r&&(a.z-=2*v)):!i&&u&&(o.x+=2*g,o.y+=2*p,r&&(o.z+=2*v)):(o.x+=g,o.y+=p,a.x-=g,a.y-=p,r&&(o.z+=v,a.z-=v))}}}calculateAttractive(){const{model:t,options:e}=this,r=3===e.dimensions;t.forEachEdge(e=>{const{source:n,target:o}=e;if(!n||!o||n===o)return;const i=t.node(n),s=t.node(o),a=this.displacements.get(n),u=this.displacements.get(o),c=this.isNodeFixed(i),h=this.isNodeFixed(s),l=s.x-i.x,d=s.y-i.y,f=r?s.z-i.z:0,g=Math.sqrt(l*l+d*d+f*f);if(0===g)return;const p=g/this.k,v=l*p,m=d*p,y=f*p;c||h?c&&!h?(u.x-=2*v,u.y-=2*m,r&&(u.z-=2*y)):!c&&h&&(a.x+=2*v,a.y+=2*m,r&&(a.z+=2*y)):(a.x+=v,a.y+=m,u.x-=v,u.y-=m,r&&(a.z+=y,u.z-=y))})}applyClusterGravity(){const{model:t,options:e}=this,{nodeClusterBy:r,clusterGravity:n,dimensions:o,clustering:i}=e;if(!i)return;if(this.clusterMap||(this.clusterMap=new Map,t.forEachNode(e=>{const n=r(t.originalNode(e.id));this.clusterMap.has(n)||this.clusterMap.set(n,{name:n,cx:0,cy:0,cz:0,count:0})})),0===this.clusterMap.size)return;const s=3===o;this.clusterMap.forEach(t=>{t.cx=0,t.cy=0,t.cz=0,t.count=0}),t.forEachNode(e=>{const n=r(t.originalNode(e.id)),o=this.clusterMap.get(n);o&&(o.cx+=e.x,o.cy+=e.y,s&&(o.cz+=e.z),o.count++)}),this.clusterMap.forEach(t=>{t.count>0&&(t.cx/=t.count,t.cy/=t.count,t.cz/=t.count)}),t.forEachNode(e=>{const{id:o}=e;if(this.isNodeFixed(e))return;const i=r(t.originalNode(o)),a=this.clusterMap.get(i);if(!a)return;const u=this.displacements.get(o),c=e.x-a.cx,h=e.y-a.cy,l=s?e.z-a.cz:0,d=Math.sqrt(c*c+h*h+l*l);if(0===d)return;const f=this.k*n;u.x-=f*c/d,u.y-=f*h/d,s&&(u.z-=f*l/d)})}applyGlobalGravity(){const{model:t,options:e}=this,{gravity:r,center:n,dimensions:o}=e,i=3===o,s=.01*this.k*r;t.forEachNode(t=>{const{id:e}=t;if(this.isNodeFixed(t))return;const r=this.displacements.get(e);r.x-=s*(t.x-n[0]),r.y-=s*(t.y-n[1]),i&&(r.z-=s*(t.z-(n[2]||0)))})}updatePositions(){const{model:t,options:e}=this,{speed:r,dimensions:n,distanceThresholdMode:o="max"}=e,i=3===n;let s=0,a=1/0,u=0,c=0;if(t.forEachNode(t=>{const{id:e}=t;if(this.isNodeFixed(t))return;const n=this.displacements.get(e),o=Math.sqrt(n.x*n.x+n.y*n.y+(i?n.z*n.z:0));if(0===o)return;const h=Math.min(this.maxDisplace*(r/800),o),l=h/o;t.x+=n.x*l,t.y+=n.y*l,i&&(t.z=t.z+n.z*l),s=Math.max(s,h),a=Math.min(a,h),u+=h,c++}),0===c)return 0;switch(o){case"min":return a===1/0?0:a;case"mean":return u/c;default:return s}}destroy(){var t,e;this.stop(),null===(t=this.displacements)||void 0===t||t.clear(),null===(e=this.clusterMap)||void 0===e||e.clear()}}const By={maxIteration:1e3,gravity:10,speed:5,clustering:!1,clusterGravity:10,width:300,height:300,nodeClusterBy:"node.cluster",dimensions:2};const Vy={begin:[0,0],preventOverlap:!0,condense:!1,rows:void 0,cols:void 0,position:void 0,sortBy:"degree",nodeSize:30,nodeSpacing:10,width:300,height:300};const Uy=(t,e)=>{let r;const n=t.rows||5,o=t.cols||5;if(null==e)r=Math.min(n,o);else{Math.min(n,o)===t.rows?t.rows=e:t.cols=e}return r},$y=(t,e)=>{let r;const n=t.rows||5,o=t.cols||5;if(null==e)r=Math.max(n,o);else{Math.max(n,o)===t.rows?t.rows=e:t.cols=e}return r},Gy=(t,e)=>t[`c-${e.row}-${e.col}`]||!1,Wy=(t,e)=>t[`c-${e.row}-${e.col}`]=!0,Yy=(t,e)=>{const r=t.cols||5;e.col++,e.col>=r&&(e.col=0,e.row++)},Hy=(t,e,r,n,o,i,s,a)=>{let u,c;const h=o[t.id];if(h)u=h.col*r+r/2+e[0],c=h.row*n+n/2+e[1];else{for(;Gy(a,s);)Yy(i,s);u=s.col*r+r/2+e[0],c=s.row*n+n/2+e[1],Wy(a,s),Yy(i,s)}t.x=u,t.y=c};var Xy={};const Qy=Object.prototype.toString;function Ky(t){const e=Qy.call(t);return e.endsWith("Array]")&&!e.includes("Big")}var Jy=gs(Object.freeze({__proto__:null,isAnyArray:Ky}));var Zy,tw=Object.freeze({__proto__:null,default:function(t){var e,r=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};if(!Ky(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(!Ky(r.output))throw new TypeError("output option must be an array if specified");e=r.output}else e=new Array(t.length);var n=function(t){var e=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};if(!Ky(t))throw new TypeError("input must be an array");if(0===t.length)throw new TypeError("input must not be empty");var r=e.fromIndex,n=void 0===r?0:r,o=e.toIndex,i=void 0===o?t.length:o;if(n<0||n>=t.length||!Number.isInteger(n))throw new Error("fromIndex must be a positive integer smaller than length");if(i<=n||i>t.length||!Number.isInteger(i))throw new Error("toIndex must be an integer greater than fromIndex and at most equal to length");for(var s=t[n],a=n+1;a<i;a++)t[a]<s&&(s=t[a]);return s}(t),o=function(t){var e=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};if(!Ky(t))throw new TypeError("input must be an array");if(0===t.length)throw new TypeError("input must not be empty");var r=e.fromIndex,n=void 0===r?0:r,o=e.toIndex,i=void 0===o?t.length:o;if(n<0||n>=t.length||!Number.isInteger(n))throw new Error("fromIndex must be a positive integer smaller than length");if(i<=n||i>t.length||!Number.isInteger(i))throw new Error("toIndex must be an integer greater than fromIndex and at most equal to length");for(var s=t[n],a=n+1;a<i;a++)t[a]>s&&(s=t[a]);return s}(t);if(n===o)throw new RangeError("minimum and maximum input values are equal. Cannot rescale a constant array");var i=r.min,s=void 0===i?r.autoMinMax?n:0:i,a=r.max,u=void 0===a?r.autoMinMax?o:1:a;if(s>=u)throw new RangeError("min option must be smaller than max option");for(var c=(u-s)/(o-n),h=0;h<t.length;h++)e[h]=(t[h]-n)*c+s;return e}}),ew=gs(tw);function rw(){if(Zy)return Xy;Zy=1,Object.defineProperty(Xy,"__esModule",{value:!0});var t=Jy,e=ew;const r=" ".repeat(2),n=" ".repeat(4);function o(t,e={}){const{maxRows:o=15,maxColumns:s=10,maxNumSize:a=8,padMinus:u="auto"}=e;return`${t.constructor.name} {\n${r}[\n${n}${function(t,e,r,o,s){const{rows:a,columns:u}=t,c=Math.min(a,e),h=Math.min(u,r),l=[];if("auto"===s){s=!1;t:for(let e=0;e<c;e++)for(let r=0;r<h;r++)if(t.get(e,r)<0){s=!0;break t}}for(let e=0;e<c;e++){let r=[];for(let n=0;n<h;n++)r.push(i(t.get(e,n),o,s));l.push(`${r.join(" ")}`)}h!==u&&(l[l.length-1]+=` ... ${u-r} more columns`);c!==a&&l.push(`... ${a-e} more rows`);return l.join(`\n${n}`)}(t,o,s,a,u)}\n${r}]\n${r}rows: ${t.rows}\n${r}columns: ${t.columns}\n}`}function i(t,e,r){return(t>=0&&r?` ${s(t,e-1)}`:s(t,e)).padEnd(e)}function s(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 a(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 u(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 c(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 h(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 l(e,r){if(!t.isAnyArray(r))throw new TypeError("row indices must be an array");for(let t=0;t<r.length;t++)if(r[t]<0||r[t]>=e.rows)throw new RangeError("row indices are out of range")}function d(e,r){if(!t.isAnyArray(r))throw new TypeError("column indices must be an array");for(let t=0;t<r.length;t++)if(r[t]<0||r[t]>=e.columns)throw new RangeError("column indices are out of range")}function f(t,e,r,n,o){if(5!==arguments.length)throw new RangeError("expected 4 arguments");if(p("startRow",e),p("endRow",r),p("startColumn",n),p("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 g(t,e=0){let r=[];for(let n=0;n<t;n++)r.push(e);return r}function p(t,e){if("number"!=typeof e)throw new TypeError(`${t} must be a number`)}function v(t){if(t.isEmpty())throw new Error("Empty matrix has no elements to index")}class m{static from1DArray(t,e,r){if(t*e!==r.length)throw new RangeError("data length does not match given dimensions");let n=new x(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 x(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 x(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 x(t,e)}static ones(t,e){return new x(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 x(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 x(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 x(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 m.isMatrix(t)?t:new x(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}isDistance(){if(!this.isSymmetric())return!1;for(let t=0;t<this.rows;t++)if(0!==this.get(t,t))return!1;return!0}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 x(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){a(this,t);let e=[];for(let r=0;r<this.columns;r++)e.push(this.get(t,r));return e}getRowVector(t){return x.rowVector(this.getRow(t))}setRow(t,e){a(this,t),e=c(this,e);for(let r=0;r<this.columns;r++)this.set(t,r,e[r]);return this}swapRows(t,e){a(this,t),a(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){u(this,t);let e=[];for(let r=0;r<this.rows;r++)e.push(this.get(r,t));return e}getColumnVector(t){return x.columnVector(this.getColumn(t))}setColumn(t,e){u(this,t),e=h(this,e);for(let r=0;r<this.rows;r++)this.set(r,t,e[r]);return this}swapColumns(t,e){u(this,t),u(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=c(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=c(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=c(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=c(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=h(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=h(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=h(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=h(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){a(this,t);for(let r=0;r<this.columns;r++)this.set(t,r,this.get(t,r)*e);return this}mulColumn(t,e){u(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(){v(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(){v(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(a(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){a(this,t),v(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(a(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){a(this,t),v(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(u(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){u(this,t),v(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(u(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){u(this,t),v(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"){switch(t){case"max":return this.max();case"frobenius":return Math.sqrt(this.dot(this));default: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){m.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=x.checkMatrix(t);let e=this.rows,r=this.columns,n=t.columns,o=new x(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}mpow(t){if(!this.isSquare())throw new RangeError("Matrix must be square");if(!Number.isInteger(t)||t<0)throw new RangeError("Exponent must be a non-negative integer");let e=x.eye(this.rows),r=this;for(let n=t;n>=1;n/=2)1&n&&(e=e.mmul(r)),r=r.mmul(r);return e}strassen2x2(t){t=x.checkMatrix(t);let e=new x(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),c=t.get(1,1),h=(r+u)*(n+c),l=(s+u)*n,d=r*(i-c),f=u*(a-n),g=(r+o)*c,p=h+f-g+(o-u)*(a+c),v=d+g,m=l+f,y=h-l+d+(s-r)*(n+i);return e.set(0,0,p),e.set(0,1,v),e.set(1,0,m),e.set(1,1,y),e}strassen3x3(t){t=x.checkMatrix(t);let e=new x(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),c=this.get(2,1),h=this.get(2,2),l=t.get(0,0),d=t.get(0,1),f=t.get(0,2),g=t.get(1,0),p=t.get(1,1),v=t.get(1,2),m=t.get(2,0),y=t.get(2,1),w=t.get(2,2),b=(r-i)*(-d+p),E=(-r+i+s)*(l-d+p),M=(i+s)*(-l+d),N=r*l,_=(-r+u+c)*(l-f+v),k=(-r+u)*(f-v),S=(u+c)*(-l+f),A=(-o+c+h)*(p+m-y),O=(o-h)*(p-y),z=o*m,j=(c+h)*(-m+y),C=(-o+s+a)*(v+m-w),I=(o-a)*(v-w),R=(s+a)*(-m+w),T=N+z+n*g,P=(r+n+o-i-s-c-h)*p+E+M+N+A+z+j,F=N+_+S+(r+n+o-s-a-u-c)*v+z+C+R,L=b+s*(-l+d+g-p-v-m+w)+E+N+z+C+I,D=b+E+M+N+a*y,q=z+C+I+R+i*f,B=N+_+k+c*(-l+f+g-p-v-m+y)+A+O+z,V=A+O+z+j+u*d,U=N+_+k+S+h*w;return e.set(0,0,T),e.set(0,1,P),e.set(0,2,F),e.set(1,0,L),e.set(1,1,D),e.set(1,2,q),e.set(2,0,B),e.set(2,1,V),e.set(2,2,U),e}mmulStrassen(t){t=x.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=m.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),c=r.subMatrix(0,i-1,0,a-1),h=e.subMatrix(0,i-1,a,e.columns-1),l=r.subMatrix(0,i-1,a,r.columns-1),d=e.subMatrix(i,e.rows-1,0,a-1),f=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),v=t(m.add(u,g),m.add(c,p),i,a),y=t(m.add(d,g),c,i,a),w=t(u,m.sub(l,p),i,a),x=t(g,m.sub(f,c),i,a),b=t(m.add(u,h),p,i,a),E=t(m.sub(d,u),m.add(c,l),i,a),M=t(m.sub(h,g),m.add(f,p),i,a),N=m.add(v,x);N.sub(b),N.add(M);let _=m.add(w,b),k=m.add(y,x),S=m.sub(v,y);S.add(w),S.add(E);let A=m.zeros(2*N.rows,2*N.columns);return A=A.setSubMatrix(N,0,0),A=A.setSubMatrix(_,N.rows,0),A=A.setSubMatrix(k,0,N.columns),A=A.setSubMatrix(S,N.rows,N.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:r=0,max:n=1}=t;if(!Number.isFinite(r))throw new TypeError("min must be a number");if(!Number.isFinite(n))throw new TypeError("max must be a number");if(r>=n)throw new RangeError("min must be smaller than max");let o=new x(this.rows,this.columns);for(let t=0;t<this.rows;t++){const i=this.getRow(t);i.length>0&&e(i,{min:r,max:n,output:i}),o.setRow(t,i)}return o}scaleColumns(t={}){if("object"!=typeof t)throw new TypeError("options must be an object");const{min:r=0,max:n=1}=t;if(!Number.isFinite(r))throw new TypeError("min must be a number");if(!Number.isFinite(n))throw new TypeError("max must be a number");if(r>=n)throw new RangeError("min must be smaller than max");let o=new x(this.rows,this.columns);for(let t=0;t<this.columns;t++){const i=this.getColumn(t);i.length&&e(i,{min:r,max:n,output:i}),o.setColumn(t,i)}return o}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=x.checkMatrix(t);let e=this.rows,r=this.columns,n=t.rows,o=t.columns,i=new x(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=x.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(x.eye(r,r)),o=x.eye(e,e).kroneckerProduct(t);return n.add(o)}transpose(){let t=new x(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=y){for(let e=0;e<this.rows;e++)this.setRow(e,this.getRow(e).sort(t));return this}sortColumns(t=y){for(let e=0;e<this.columns;e++)this.setColumn(e,this.getColumn(e).sort(t));return this}subMatrix(t,e,r,n){f(this,t,e,r,n);let o=new x(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 x(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 x(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=x.checkMatrix(t)).isEmpty())return this;f(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){l(this,t),d(this,e);let r=new x(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(){return this.constructor.copy(this,new x(this.rows,this.columns))}static copy(t,e){for(const[r,n,o]of t.entries())e.set(r,n,o);return e}sum(t){switch(t){case"row":return function(t){let e=g(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=g(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=g(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=g(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(e,r={}){if("object"==typeof e&&(r=e,e=void 0),"object"!=typeof r)throw new TypeError("options must be an object");const{unbiased:n=!0,mean:o=this.mean(e)}=r;if("boolean"!=typeof n)throw new TypeError("unbiased must be a boolean");switch(e){case"row":if(!t.isAnyArray(o))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,n,o);case"column":if(!t.isAnyArray(o))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,n,o);case void 0:if("number"!=typeof o)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,n,o);default:throw new Error(`invalid option: ${e}`)}}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(e,r={}){if("object"==typeof e&&(r=e,e=void 0),"object"!=typeof r)throw new TypeError("options must be an object");const{center:n=this.mean(e)}=r;switch(e){case"row":if(!t.isAnyArray(n))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,n),this;case"column":if(!t.isAnyArray(n))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,n),this;case void 0:if("number"!=typeof n)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,n),this;default:throw new Error(`invalid option: ${e}`)}}scale(e,r={}){if("object"==typeof e&&(r=e,e=void 0),"object"!=typeof r)throw new TypeError("options must be an object");let n=r.scale;switch(e){case"row":if(void 0===n)n=function(t){const e=[];for(let r=0;r<t.rows;r++){let n=0;for(let e=0;e<t.columns;e++)n+=t.get(r,e)**2/(t.columns-1);e.push(Math.sqrt(n))}return e}(this);else if(!t.isAnyArray(n))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,n),this;case"column":if(void 0===n)n=function(t){const e=[];for(let r=0;r<t.columns;r++){let n=0;for(let e=0;e<t.rows;e++)n+=t.get(e,r)**2/(t.rows-1);e.push(Math.sqrt(n))}return e}(this);else if(!t.isAnyArray(n))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,n),this;case void 0:if(void 0===n)n=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+=t.get(o,n)**2/e;return Math.sqrt(r)}(this);else if("number"!=typeof n)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,n),this;default:throw new Error(`invalid option: ${e}`)}}toString(t){return o(this,t)}[Symbol.iterator](){return this.entries()}*entries(){for(let t=0;t<this.rows;t++)for(let e=0;e<this.columns;e++)yield[t,e,this.get(t,e)]}*values(){for(let t=0;t<this.rows;t++)for(let e=0;e<this.columns;e++)yield this.get(t,e)}}function y(t,e){return t-e}function w(t){return t.every(t=>"number"==typeof t)}m.prototype.klass="Matrix","undefined"!=typeof Symbol&&(m.prototype[Symbol.for("nodejs.util.inspect.custom")]=function(){return o(this)}),m.random=m.rand,m.randomInt=m.randInt,m.diagonal=m.diag,m.prototype.diagonal=m.prototype.diag,m.identity=m.eye,m.prototype.negate=m.prototype.neg,m.prototype.tensorProduct=m.prototype.kroneckerProduct;class x extends m{data;#t(t,e){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));this.rows=t,this.columns=e}constructor(e,r){if(super(),x.isMatrix(e))this.#t(e.rows,e.columns),x.copy(e,this);else if(Number.isInteger(e)&&e>=0)this.#t(e,r);else{if(!t.isAnyArray(e))throw new TypeError("First argument must be a positive number or an array");{const t=e;if("number"!=typeof(r=(e=t.length)?t[0].length:0))throw new TypeError("Data must be a 2D array with at least one element");this.data=[];for(let n=0;n<e;n++){if(t[n].length!==r)throw new RangeError("Inconsistent array dimensions");if(!w(t[n]))throw new TypeError("Input data contains non-numeric values");this.data.push(Float64Array.from(t[n]))}this.rows=e,this.columns=r}}}set(t,e,r){return this.data[t][e]=r,this}get(t,e){return this.data[t][e]}removeRow(t){return a(this,t),this.data.splice(t,1),this.rows-=1,this}addRow(t,e){return void 0===e&&(e=t,t=this.rows),a(this,t,!0),e=Float64Array.from(c(this,e)),this.data.splice(t,0,e),this.rows+=1,this}removeColumn(t){u(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),u(this,t,!0),e=h(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,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,this.get(e,r)**t.get(e,r));return this}}(m,x);class b extends m{#e;get size(){return this.#e.size}get rows(){return this.#e.rows}get columns(){return this.#e.columns}get diagonalSize(){return this.rows}static isSymmetricMatrix(t){return x.isMatrix(t)&&"SymmetricMatrix"===t.klassType}static zeros(t){return new this(t)}static ones(t){return new this(t).fill(1)}constructor(t){if(super(),x.isMatrix(t)){if(!t.isSymmetric())throw new TypeError("not symmetric data");this.#e=x.copy(t,new x(t.rows,t.rows))}else if(Number.isInteger(t)&&t>=0)this.#e=new x(t,t);else if(this.#e=new x(t),!this.isSymmetric())throw new TypeError("not symmetric data")}clone(){const t=new b(this.diagonalSize);for(const[e,r,n]of this.upperRightEntries())t.set(e,r,n);return t}toMatrix(){return new x(this)}get(t,e){return this.#e.get(t,e)}set(t,e,r){return this.#e.set(t,e,r),this.#e.set(e,t,r),this}removeCross(t){return this.#e.removeRow(t),this.#e.removeColumn(t),this}addCross(t,e){void 0===e&&(e=t,t=this.diagonalSize);const r=e.slice();return r.splice(t,1),this.#e.addRow(t,r),this.#e.addColumn(t,e),this}applyMask(t){if(t.length!==this.diagonalSize)throw new RangeError("Mask size do not match with matrix size");const e=[];for(const[r,n]of t.entries())n||e.push(r);e.reverse();for(const t of e)this.removeCross(t);return this}toCompact(){const{diagonalSize:t}=this,e=new Array(t*(t+1)/2);for(let r=0,n=0,o=0;o<e.length;o++)e[o]=this.get(n,r),++r>=t&&(r=++n);return e}static fromCompact(t){const e=t.length,r=(Math.sqrt(8*e+1)-1)/2;if(!Number.isInteger(r))throw new TypeError(`This array is not a compact representation of a Symmetric Matrix, ${JSON.stringify(t)}`);const n=new b(r);for(let o=0,i=0,s=0;s<e;s++)n.set(o,i,t[s]),++o>=r&&(o=++i);return n}*upperRightEntries(){for(let t=0,e=0;t<this.diagonalSize;void 0){const r=this.get(t,e);yield[t,e,r],++e>=this.diagonalSize&&(e=++t)}}*upperRightValues(){for(let t=0,e=0;t<this.diagonalSize;void 0){const r=this.get(t,e);yield r,++e>=this.diagonalSize&&(e=++t)}}}b.prototype.klassType="SymmetricMatrix";class E extends b{static isDistanceMatrix(t){return b.isSymmetricMatrix(t)&&"DistanceMatrix"===t.klassSubType}constructor(t){if(super(t),!this.isDistance())throw new TypeError("Provided arguments do no produce a distance matrix")}set(t,e,r){return t===e&&(r=0),super.set(t,e,r)}addCross(t,e){return void 0===e&&(e=t,t=this.diagonalSize),(e=e.slice())[t]=0,super.addCross(t,e)}toSymmetricMatrix(){return new b(this)}clone(){const t=new E(this.diagonalSize);for(const[e,r,n]of this.upperRightEntries())e!==r&&t.set(e,r,n);return t}toCompact(){const{diagonalSize:t}=this,e=new Array((t-1)*t/2);for(let r=1,n=0,o=0;o<e.length;o++)e[o]=this.get(n,r),++r>=t&&(r=1+ ++n);return e}static fromCompact(t){const e=t.length;if(0===e)return new this(0);const r=(Math.sqrt(8*e+1)+1)/2;if(!Number.isInteger(r))throw new TypeError(`This array is not a compact representation of a DistanceMatrix, ${JSON.stringify(t)}`);const n=new this(r);for(let o=1,i=0,s=0;s<e;s++)n.set(o,i,t[s]),++o>=r&&(o=1+ ++i);return n}}E.prototype.klassSubType="DistanceMatrix";class M extends m{constructor(t,e,r){super(),this.matrix=t,this.rows=e,this.columns=r}}class N extends M{constructor(t,e,r){l(t,e),d(t,r),super(t,e.length,r.length),this.rowIndices=e,this.columnIndices=r}set(t,e,r){return this.matrix.set(this.rowIndices[t],this.columnIndices[e],r),this}get(t,e){return this.matrix.get(this.rowIndices[t],this.columnIndices[e])}}class _ extends m{constructor(t,e={}){const{rows:r=1}=e;if(t.length%r!==0)throw new Error("the data length is not divisible by the number of rows");super(),this.rows=r,this.columns=t.length/r,this.data=t}set(t,e,r){let n=this._calculateIndex(t,e);return this.data[n]=r,this}get(t,e){let r=this._calculateIndex(t,e);return this.data[r]}_calculateIndex(t,e){return t*this.columns+e}}class k extends m{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]}}class S{constructor(t){let e,r,n,o,i,s,a,u,c,h=(t=k.checkMatrix(t)).clone(),l=h.rows,d=h.columns,f=new Float64Array(l),g=1;for(e=0;e<l;e++)f[e]=e;for(u=new Float64Array(l),r=0;r<d;r++){for(e=0;e<l;e++)u[e]=h.get(e,r);for(e=0;e<l;e++){for(c=Math.min(e,r),i=0,n=0;n<c;n++)i+=h.get(e,n)*u[n];u[e]-=i,h.set(e,r,u[e])}for(o=r,e=r+1;e<l;e++)Math.abs(u[e])>Math.abs(u[o])&&(o=e);if(o!==r){for(n=0;n<d;n++)s=h.get(o,n),h.set(o,n,h.get(r,n)),h.set(r,n,s);a=f[o],f[o]=f[r],f[r]=a,g=-g}if(r<l&&0!==h.get(r,r))for(e=r+1;e<l;e++)h.set(e,r,h.get(e,r)/h.get(r,r))}this.LU=h,this.pivotVector=f,this.pivotSign=g}isSingular(){let t=this.LU,e=t.columns;for(let r=0;r<e;r++)if(0===t.get(r,r))return!0;return!1}solve(t){t=x.checkMatrix(t);let e=this.LU;if(e.rows!==t.rows)throw new Error("Invalid matrix dimensions");if(this.isSingular())throw new Error("LU matrix is singular");let r,n,o,i=t.columns,s=t.subMatrixRow(this.pivotVector,0,i-1),a=e.columns;for(o=0;o<a;o++)for(r=o+1;r<a;r++)for(n=0;n<i;n++)s.set(r,n,s.get(r,n)-s.get(o,n)*e.get(r,o));for(o=a-1;o>=0;o--){for(n=0;n<i;n++)s.set(o,n,s.get(o,n)/e.get(o,o));for(r=0;r<o;r++)for(n=0;n<i;n++)s.set(r,n,s.get(r,n)-s.get(o,n)*e.get(r,o))}return s}get determinant(){let t=this.LU;if(!t.isSquare())throw new Error("Matrix must be square");let e=this.pivotSign,r=t.columns;for(let n=0;n<r;n++)e*=t.get(n,n);return e}get lowerTriangularMatrix(){let t=this.LU,e=t.rows,r=t.columns,n=new x(e,r);for(let o=0;o<e;o++)for(let e=0;e<r;e++)o>e?n.set(o,e,t.get(o,e)):o===e?n.set(o,e,1):n.set(o,e,0);return n}get upperTriangularMatrix(){let t=this.LU,e=t.rows,r=t.columns,n=new x(e,r);for(let o=0;o<e;o++)for(let e=0;e<r;e++)o<=e?n.set(o,e,t.get(o,e)):n.set(o,e,0);return n}get pivotPermutationVector(){return Array.from(this.pivotVector)}}function A(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 O{constructor(t){let e,r,n,o,i=(t=k.checkMatrix(t)).clone(),s=t.rows,a=t.columns,u=new Float64Array(a);for(n=0;n<a;n++){let t=0;for(e=n;e<s;e++)t=A(t,i.get(e,n));if(0!==t){for(i.get(n,n)<0&&(t=-t),e=n;e<s;e++)i.set(e,n,i.get(e,n)/t);for(i.set(n,n,i.get(n,n)+1),r=n+1;r<a;r++){for(o=0,e=n;e<s;e++)o+=i.get(e,n)*i.get(e,r);for(o=-o/i.get(n,n),e=n;e<s;e++)i.set(e,r,i.get(e,r)+o*i.get(e,n))}}u[n]=-t}this.QR=i,this.Rdiag=u}solve(t){t=x.checkMatrix(t);let e=this.QR,r=e.rows;if(t.rows!==r)throw new Error("Matrix row dimensions must agree");if(!this.isFullRank())throw new Error("Matrix is rank deficient");let n,o,i,s,a=t.columns,u=t.clone(),c=e.columns;for(i=0;i<c;i++)for(o=0;o<a;o++){for(s=0,n=i;n<r;n++)s+=e.get(n,i)*u.get(n,o);for(s=-s/e.get(i,i),n=i;n<r;n++)u.set(n,o,u.get(n,o)+s*e.get(n,i))}for(i=c-1;i>=0;i--){for(o=0;o<a;o++)u.set(i,o,u.get(i,o)/this.Rdiag[i]);for(n=0;n<i;n++)for(o=0;o<a;o++)u.set(n,o,u.get(n,o)-u.get(i,o)*e.get(n,i))}return u.subMatrix(0,c-1,0,a-1)}isFullRank(){let t=this.QR.columns;for(let e=0;e<t;e++)if(0===this.Rdiag[e])return!1;return!0}get upperTriangularMatrix(){let t,e,r=this.QR,n=r.columns,o=new x(n,n);for(t=0;t<n;t++)for(e=0;e<n;e++)t<e?o.set(t,e,r.get(t,e)):t===e?o.set(t,e,this.Rdiag[t]):o.set(t,e,0);return o}get orthogonalMatrix(){let t,e,r,n,o=this.QR,i=o.rows,s=o.columns,a=new x(i,s);for(r=s-1;r>=0;r--){for(t=0;t<i;t++)a.set(t,r,0);for(a.set(r,r,1),e=r;e<s;e++)if(0!==o.get(r,r)){for(n=0,t=r;t<i;t++)n+=o.get(t,r)*a.get(t,e);for(n=-n/o.get(r,r),t=r;t<i;t++)a.set(t,e,a.get(t,e)+n*o.get(t,r))}}return a}}class z{constructor(t,e={}){if((t=k.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),c=Boolean(i),h=!1;if(r<n)if(s){a=t.transpose(),r=a.rows,n=a.columns,h=!0;let e=u;u=c,c=e}else a=t.clone(),console.warn("Computing SVD on a matrix with more columns than rows. Consider enabling autoTranspose");else a=t.clone();let l=Math.min(r,n),d=Math.min(r+1,n),f=new Float64Array(d),g=new x(r,l),p=new x(n,n),v=new Float64Array(n),m=new Float64Array(r),y=new Float64Array(d);for(let t=0;t<d;t++)y[t]=t;let w=Math.min(r-1,n),b=Math.max(0,Math.min(n-2,r)),E=Math.max(w,b);for(let t=0;t<E;t++){if(t<w){f[t]=0;for(let e=t;e<r;e++)f[t]=A(f[t],a.get(e,t));if(0!==f[t]){a.get(t,t)<0&&(f[t]=-f[t]);for(let e=t;e<r;e++)a.set(e,t,a.get(e,t)/f[t]);a.set(t,t,a.get(t,t)+1)}f[t]=-f[t]}for(let e=t+1;e<n;e++){if(t<w&&0!==f[t]){let n=0;for(let o=t;o<r;o++)n+=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))}v[e]=a.get(t,e)}if(u&&t<w)for(let e=t;e<r;e++)g.set(e,t,a.get(e,t));if(t<b){v[t]=0;for(let e=t+1;e<n;e++)v[t]=A(v[t],v[e]);if(0!==v[t]){v[t+1]<0&&(v[t]=0-v[t]);for(let e=t+1;e<n;e++)v[e]/=v[t];v[t+1]+=1}if(v[t]=-v[t],t+1<r&&0!==v[t]){for(let e=t+1;e<r;e++)m[e]=0;for(let e=t+1;e<r;e++)for(let r=t+1;r<n;r++)m[e]+=v[r]*a.get(e,r);for(let e=t+1;e<n;e++){let n=-v[e]/v[t+1];for(let o=t+1;o<r;o++)a.set(o,e,a.get(o,e)+n*m[o])}}if(c)for(let e=t+1;e<n;e++)p.set(e,t,v[e])}}let M=Math.min(n,r+1);if(w<n&&(f[w]=a.get(w,w)),r<M&&(f[M-1]=0),b+1<M&&(v[b]=a.get(b,M-1)),v[M-1]=0,u){for(let t=w;t<l;t++){for(let e=0;e<r;e++)g.set(e,t,0);g.set(t,t,1)}for(let t=w-1;t>=0;t--)if(0!==f[t]){for(let e=t+1;e<l;e++){let n=0;for(let o=t;o<r;o++)n+=g.get(o,t)*g.get(o,e);n=-n/g.get(t,t);for(let o=t;o<r;o++)g.set(o,e,g.get(o,e)+n*g.get(o,t))}for(let e=t;e<r;e++)g.set(e,t,-g.get(e,t));g.set(t,t,1+g.get(t,t));for(let e=0;e<t-1;e++)g.set(e,t,0)}else{for(let e=0;e<r;e++)g.set(e,t,0);g.set(t,t,1)}}if(c)for(let t=n-1;t>=0;t--){if(t<b&&0!==v[t])for(let e=t+1;e<n;e++){let r=0;for(let o=t+1;o<n;o++)r+=p.get(o,t)*p.get(o,e);r=-r/p.get(t+1,t);for(let o=t+1;o<n;o++)p.set(o,e,p.get(o,e)+r*p.get(o,t))}for(let e=0;e<n;e++)p.set(e,t,0);p.set(t,t,1)}let N=M-1,_=Number.EPSILON;for(;M>0;){let t,e;for(t=M-2;t>=-1&&-1!==t;t--){const e=Number.MIN_VALUE+_*Math.abs(f[t]+Math.abs(f[t+1]));if(Math.abs(v[t])<=e||Number.isNaN(v[t])){v[t]=0;break}}if(t===M-2)e=4;else{let r;for(r=M-1;r>=t&&r!==t;r--){let e=(r!==M?Math.abs(v[r]):0)+(r!==t+1?Math.abs(v[r-1]):0);if(Math.abs(f[r])<=_*e){f[r]=0;break}}r===t?e=3:r===M-1?e=1:(e=2,t=r)}switch(t++,e){case 1:{let e=v[M-2];v[M-2]=0;for(let r=M-2;r>=t;r--){let o=A(f[r],e),i=f[r]/o,s=e/o;if(f[r]=o,r!==t&&(e=-s*v[r-1],v[r-1]=i*v[r-1]),c)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=v[t-1];v[t-1]=0;for(let n=t;n<M;n++){let o=A(f[n],e),i=f[n]/o,s=e/o;if(f[n]=o,e=-s*v[n],v[n]=i*v[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(f[M-1]),Math.abs(f[M-2]),Math.abs(v[M-2]),Math.abs(f[t]),Math.abs(v[t])),o=f[M-1]/e,i=f[M-2]/e,s=v[M-2]/e,a=f[t]/e,h=v[t]/e,l=((i+o)*(i-o)+s*s)/2,d=o*s*(o*s);let m=0;0===l&&0===d||(m=l<0?0-Math.sqrt(l*l+d):Math.sqrt(l*l+d),m=d/(l+m));let y=(a+o)*(a-o)+m,w=a*h;for(let e=t;e<M-1;e++){let o=A(y,w);0===o&&(o=Number.MIN_VALUE);let i=y/o,s=w/o;if(e!==t&&(v[e-1]=o),y=i*f[e]+s*v[e],v[e]=i*v[e]-s*f[e],w=s*f[e+1],f[e+1]=i*f[e+1],c)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=A(y,w),0===o&&(o=Number.MIN_VALUE),i=y/o,s=w/o,f[e]=o,y=i*v[e]+s*f[e+1],f[e+1]=-s*v[e]+i*f[e+1],w=s*v[e+1],v[e+1]=i*v[e+1],u&&e<r-1)for(let t=0;t<r;t++)o=i*g.get(t,e)+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)}v[M-2]=y;break}case 4:if(f[t]<=0&&(f[t]=f[t]<0?-f[t]:0,c))for(let e=0;e<=N;e++)p.set(e,t,-p.get(e,t));for(;t<N&&!(f[t]>=f[t+1]);){let e=f[t];if(f[t]=f[t+1],f[t+1]=e,c&&t<n-1)for(let r=0;r<n;r++)e=p.get(r,t+1),p.set(r,t+1,p.get(r,t)),p.set(r,t,e);if(u&&t<r-1)for(let n=0;n<r;n++)e=g.get(n,t+1),g.set(n,t+1,g.get(n,t)),g.set(n,t,e);t++}M--}}if(h){let t=p;p=g,g=t}this.m=r,this.n=n,this.s=f,this.U=g,this.V=p}solve(t){let e=t,r=this.threshold,n=this.s.length,o=x.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,c=i.rows,h=x.zeros(u,c);for(let t=0;t<u;t++)for(let e=0;e<c;e++){let r=0;for(let o=0;o<n;o++)r+=a.get(t,o)*i.get(e,o);h.set(t,e,r)}return h.mmul(e)}solveForDiagonal(t){return this.solve(x.diag(t))}inverse(){let t=this.V,e=this.threshold,r=t.rows,n=t.columns,o=new x(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 x(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 x.diag(this.s)}}function j(t,e,r=!1){return t=k.checkMatrix(t),e=k.checkMatrix(e),r?new z(t).solve(e):t.isSquare()?new S(t).solve(e):new O(t).solve(e)}function C(t,e){let r=[];for(let n=0;n<t;n++)n!==e&&r.push(n);return r}function I(t,e,r,n=1e-9,o=1e-9){if(t>o)return new Array(e.rows+1).fill(0);{let t=e.addRow(r,[0]);for(let e=0;e<t.rows;e++)Math.abs(t.get(e,0))<n&&t.set(e,0,0);return t.to1DArray()}}class R{constructor(t,e={}){const{assumeSymmetric:r=!1}=e;if(!(t=k.checkMatrix(t)).isSquare())throw new Error("Matrix is not a square matrix");if(t.isEmpty())throw new Error("Matrix must be non-empty");let n,o,i=t.columns,s=new x(i,i),a=new Float64Array(i),u=new Float64Array(i),c=t,h=!1;if(h=!!r||t.isSymmetric(),h){for(n=0;n<i;n++)for(o=0;o<i;o++)s.set(n,o,c.get(n,o));!function(t,e,r,n){let o,i,s,a,u,c,h,l;for(u=0;u<t;u++)r[u]=n.get(t-1,u);for(a=t-1;a>0;a--){for(l=0,s=0,c=0;c<a;c++)l+=Math.abs(r[c]);if(0===l)for(e[a]=r[a-1],u=0;u<a;u++)r[u]=n.get(a-1,u),n.set(a,u,0),n.set(u,a,0);else{for(c=0;c<a;c++)r[c]/=l,s+=r[c]*r[c];for(o=r[a-1],i=Math.sqrt(s),o>0&&(i=-i),e[a]=l*i,s-=o*i,r[a-1]=o-i,u=0;u<a;u++)e[u]=0;for(u=0;u<a;u++){for(o=r[u],n.set(u,a,o),i=e[u]+n.get(u,u)*o,c=u+1;c<=a-1;c++)i+=n.get(c,u)*r[c],e[c]+=n.get(c,u)*o;e[u]=i}for(o=0,u=0;u<a;u++)e[u]/=s,o+=e[u]*r[u];for(h=o/(s+s),u=0;u<a;u++)e[u]-=h*r[u];for(u=0;u<a;u++){for(o=r[u],i=e[u],c=u;c<=a-1;c++)n.set(c,u,n.get(c,u)-(o*e[c]+i*r[c]));r[u]=n.get(a-1,u),n.set(a,u,0)}}r[a]=s}for(a=0;a<t-1;a++){if(n.set(t-1,a,n.get(a,a)),n.set(a,a,1),s=r[a+1],0!==s){for(c=0;c<=a;c++)r[c]=n.get(c,a+1)/s;for(u=0;u<=a;u++){for(i=0,c=0;c<=a;c++)i+=n.get(c,a+1)*n.get(c,u);for(c=0;c<=a;c++)n.set(c,u,n.get(c,u)-i*r[c])}}for(c=0;c<=a;c++)n.set(c,a+1,0)}for(u=0;u<t;u++)r[u]=n.get(t-1,u),n.set(t-1,u,0);n.set(t-1,t-1,1),e[0]=0}(i,u,a,s),function(t,e,r,n){let o,i,s,a,u,c,h,l,d,f,g,p,v,m,y,w;for(s=1;s<t;s++)e[s-1]=e[s];e[t-1]=0;let x=0,b=0,E=Number.EPSILON;for(c=0;c<t;c++){for(b=Math.max(b,Math.abs(r[c])+Math.abs(e[c])),h=c;h<t&&!(Math.abs(e[h])<=E*b);)h++;if(h>c)do{for(o=r[c],l=(r[c+1]-o)/(2*e[c]),d=A(l,1),l<0&&(d=-d),r[c]=e[c]/(l+d),r[c+1]=e[c]*(l+d),f=r[c+1],i=o-r[c],s=c+2;s<t;s++)r[s]-=i;for(x+=i,l=r[h],g=1,p=g,v=g,m=e[c+1],y=0,w=0,s=h-1;s>=c;s--)for(v=p,p=g,w=y,o=g*e[s],i=g*l,d=A(l,e[s]),e[s+1]=y*d,y=e[s]/d,g=l/d,l=g*r[s]-y*o,r[s+1]=i+y*(g*o+y*r[s]),u=0;u<t;u++)i=n.get(u,s+1),n.set(u,s+1,y*n.get(u,s)+g*i),n.set(u,s,g*n.get(u,s)-y*i);l=-y*w*v*m*e[c]/f,e[c]=y*l,r[c]=g*l}while(Math.abs(e[c])>E*b);r[c]=r[c]+x,e[c]=0}for(s=0;s<t-1;s++){for(u=s,l=r[s],a=s+1;a<t;a++)r[a]<l&&(u=a,l=r[a]);if(u!==s)for(r[u]=r[s],r[s]=l,a=0;a<t;a++)l=n.get(a,s),n.set(a,s,n.get(a,u)),n.set(a,u,l)}}(i,u,a,s)}else{let t=new x(i,i),e=new Float64Array(i);for(o=0;o<i;o++)for(n=0;n<i;n++)t.set(n,o,c.get(n,o));!function(t,e,r,n){let o,i,s,a,u,c,h,l=0,d=t-1;for(c=l+1;c<=d-1;c++){for(h=0,a=c;a<=d;a++)h+=Math.abs(e.get(a,c-1));if(0!==h){for(s=0,a=d;a>=c;a--)r[a]=e.get(a,c-1)/h,s+=r[a]*r[a];for(i=Math.sqrt(s),r[c]>0&&(i=-i),s-=r[c]*i,r[c]=r[c]-i,u=c;u<t;u++){for(o=0,a=d;a>=c;a--)o+=r[a]*e.get(a,u);for(o/=s,a=c;a<=d;a++)e.set(a,u,e.get(a,u)-o*r[a])}for(a=0;a<=d;a++){for(o=0,u=d;u>=c;u--)o+=r[u]*e.get(a,u);for(o/=s,u=c;u<=d;u++)e.set(a,u,e.get(a,u)-o*r[u])}r[c]=h*r[c],e.set(c,c-1,h*i)}}for(a=0;a<t;a++)for(u=0;u<t;u++)n.set(a,u,a===u?1:0);for(c=d-1;c>=l+1;c--)if(0!==e.get(c,c-1)){for(a=c+1;a<=d;a++)r[a]=e.get(a,c-1);for(u=c;u<=d;u++){for(i=0,a=c;a<=d;a++)i+=r[a]*n.get(a,u);for(i=i/r[c]/e.get(c,c-1),a=c;a<=d;a++)n.set(a,u,n.get(a,u)+i*r[a])}}}(i,t,e,s),function(t,e,r,n,o){let i,s,a,u,c,h,l,d,f,g,p,v,m,y,w,x=t-1,b=0,E=t-1,M=Number.EPSILON,N=0,_=0,k=0,S=0,A=0,O=0,z=0,j=0;for(i=0;i<t;i++)for((i<b||i>E)&&(r[i]=o.get(i,i),e[i]=0),s=Math.max(i-1,0);s<t;s++)_+=Math.abs(o.get(i,s));for(;x>=b;){for(u=x;u>b&&(O=Math.abs(o.get(u-1,u-1))+Math.abs(o.get(u,u)),0===O&&(O=_),!(Math.abs(o.get(u,u-1))<M*O));)u--;if(u===x)o.set(x,x,o.get(x,x)+N),r[x]=o.get(x,x),e[x]=0,x--,j=0;else if(u===x-1){if(l=o.get(x,x-1)*o.get(x-1,x),k=(o.get(x-1,x-1)-o.get(x,x))/2,S=k*k+l,z=Math.sqrt(Math.abs(S)),o.set(x,x,o.get(x,x)+N),o.set(x-1,x-1,o.get(x-1,x-1)+N),d=o.get(x,x),S>=0){for(z=k>=0?k+z:k-z,r[x-1]=d+z,r[x]=r[x-1],0!==z&&(r[x]=d-l/z),e[x-1]=0,e[x]=0,d=o.get(x,x-1),O=Math.abs(d)+Math.abs(z),k=d/O,S=z/O,A=Math.sqrt(k*k+S*S),k/=A,S/=A,s=x-1;s<t;s++)z=o.get(x-1,s),o.set(x-1,s,S*z+k*o.get(x,s)),o.set(x,s,S*o.get(x,s)-k*z);for(i=0;i<=x;i++)z=o.get(i,x-1),o.set(i,x-1,S*z+k*o.get(i,x)),o.set(i,x,S*o.get(i,x)-k*z);for(i=b;i<=E;i++)z=n.get(i,x-1),n.set(i,x-1,S*z+k*n.get(i,x)),n.set(i,x,S*n.get(i,x)-k*z)}else r[x-1]=d+k,r[x]=d+k,e[x-1]=z,e[x]=-z;x-=2,j=0}else{if(d=o.get(x,x),f=0,l=0,u<x&&(f=o.get(x-1,x-1),l=o.get(x,x-1)*o.get(x-1,x)),10===j){for(N+=d,i=b;i<=x;i++)o.set(i,i,o.get(i,i)-d);O=Math.abs(o.get(x,x-1))+Math.abs(o.get(x-1,x-2)),d=f=.75*O,l=-.4375*O*O}if(30===j&&(O=(f-d)/2,O=O*O+l,O>0)){for(O=Math.sqrt(O),f<d&&(O=-O),O=d-l/((f-d)/2+O),i=b;i<=x;i++)o.set(i,i,o.get(i,i)-O);N+=O,d=f=l=.964}for(j+=1,c=x-2;c>=u&&(z=o.get(c,c),A=d-z,O=f-z,k=(A*O-l)/o.get(c+1,c)+o.get(c,c+1),S=o.get(c+1,c+1)-z-A-O,A=o.get(c+2,c+1),O=Math.abs(k)+Math.abs(S)+Math.abs(A),k/=O,S/=O,A/=O,c!==u)&&!(Math.abs(o.get(c,c-1))*(Math.abs(S)+Math.abs(A))<M*(Math.abs(k)*(Math.abs(o.get(c-1,c-1))+Math.abs(z)+Math.abs(o.get(c+1,c+1)))));)c--;for(i=c+2;i<=x;i++)o.set(i,i-2,0),i>c+2&&o.set(i,i-3,0);for(a=c;a<=x-1&&(y=a!==x-1,a!==c&&(k=o.get(a,a-1),S=o.get(a+1,a-1),A=y?o.get(a+2,a-1):0,d=Math.abs(k)+Math.abs(S)+Math.abs(A),0!==d&&(k/=d,S/=d,A/=d)),0!==d);a++)if(O=Math.sqrt(k*k+S*S+A*A),k<0&&(O=-O),0!==O){for(a!==c?o.set(a,a-1,-O*d):u!==c&&o.set(a,a-1,-o.get(a,a-1)),k+=O,d=k/O,f=S/O,z=A/O,S/=k,A/=k,s=a;s<t;s++)k=o.get(a,s)+S*o.get(a+1,s),y&&(k+=A*o.get(a+2,s),o.set(a+2,s,o.get(a+2,s)-k*z)),o.set(a,s,o.get(a,s)-k*d),o.set(a+1,s,o.get(a+1,s)-k*f);for(i=0;i<=Math.min(x,a+3);i++)k=d*o.get(i,a)+f*o.get(i,a+1),y&&(k+=z*o.get(i,a+2),o.set(i,a+2,o.get(i,a+2)-k*A)),o.set(i,a,o.get(i,a)-k),o.set(i,a+1,o.get(i,a+1)-k*S);for(i=b;i<=E;i++)k=d*n.get(i,a)+f*n.get(i,a+1),y&&(k+=z*n.get(i,a+2),n.set(i,a+2,n.get(i,a+2)-k*A)),n.set(i,a,n.get(i,a)-k),n.set(i,a+1,n.get(i,a+1)-k*S)}}}if(0===_)return;for(x=t-1;x>=0;x--)if(k=r[x],S=e[x],0===S)for(u=x,o.set(x,x,1),i=x-1;i>=0;i--){for(l=o.get(i,i)-k,A=0,s=u;s<=x;s++)A+=o.get(i,s)*o.get(s,x);if(e[i]<0)z=l,O=A;else if(u=i,0===e[i]?o.set(i,x,0!==l?-A/l:-A/(M*_)):(d=o.get(i,i+1),f=o.get(i+1,i),S=(r[i]-k)*(r[i]-k)+e[i]*e[i],h=(d*O-z*A)/S,o.set(i,x,h),o.set(i+1,x,Math.abs(d)>Math.abs(z)?(-A-l*h)/d:(-O-f*h)/z)),h=Math.abs(o.get(i,x)),M*h*h>1)for(s=i;s<=x;s++)o.set(s,x,o.get(s,x)/h)}else if(S<0)for(u=x-1,Math.abs(o.get(x,x-1))>Math.abs(o.get(x-1,x))?(o.set(x-1,x-1,S/o.get(x,x-1)),o.set(x-1,x,-(o.get(x,x)-k)/o.get(x,x-1))):(w=T(0,-o.get(x-1,x),o.get(x-1,x-1)-k,S),o.set(x-1,x-1,w[0]),o.set(x-1,x,w[1])),o.set(x,x-1,0),o.set(x,x,1),i=x-2;i>=0;i--){for(g=0,p=0,s=u;s<=x;s++)g+=o.get(i,s)*o.get(s,x-1),p+=o.get(i,s)*o.get(s,x);if(l=o.get(i,i)-k,e[i]<0)z=l,A=g,O=p;else if(u=i,0===e[i]?(w=T(-g,-p,l,S),o.set(i,x-1,w[0]),o.set(i,x,w[1])):(d=o.get(i,i+1),f=o.get(i+1,i),v=(r[i]-k)*(r[i]-k)+e[i]*e[i]-S*S,m=2*(r[i]-k)*S,0===v&&0===m&&(v=M*_*(Math.abs(l)+Math.abs(S)+Math.abs(d)+Math.abs(f)+Math.abs(z))),w=T(d*A-z*g+S*p,d*O-z*p-S*g,v,m),o.set(i,x-1,w[0]),o.set(i,x,w[1]),Math.abs(d)>Math.abs(z)+Math.abs(S)?(o.set(i+1,x-1,(-g-l*o.get(i,x-1)+S*o.get(i,x))/d),o.set(i+1,x,(-p-l*o.get(i,x)-S*o.get(i,x-1))/d)):(w=T(-A-f*o.get(i,x-1),-O-f*o.get(i,x),z,S),o.set(i+1,x-1,w[0]),o.set(i+1,x,w[1]))),h=Math.max(Math.abs(o.get(i,x-1)),Math.abs(o.get(i,x))),M*h*h>1)for(s=i;s<=x;s++)o.set(s,x-1,o.get(s,x-1)/h),o.set(s,x,o.get(s,x)/h)}for(i=0;i<t;i++)if(i<b||i>E)for(s=i;s<t;s++)n.set(i,s,o.get(i,s));for(s=t-1;s>=b;s--)for(i=b;i<=E;i++){for(z=0,a=b;a<=Math.min(s,E);a++)z+=n.get(i,a)*o.get(a,s);n.set(i,s,z)}}(i,u,a,s,t)}this.n=i,this.e=u,this.d=a,this.V=s}get realEigenvalues(){return Array.from(this.d)}get imaginaryEigenvalues(){return Array.from(this.e)}get eigenvectorMatrix(){return this.V}get diagonalMatrix(){let t,e,r=this.n,n=this.e,o=this.d,i=new x(r,r);for(t=0;t<r;t++){for(e=0;e<r;e++)i.set(t,e,0);i.set(t,t,o[t]),n[t]>0?i.set(t,t+1,n[t]):n[t]<0&&i.set(t,t-1,n[t])}return i}}function T(t,e,r,n){let o,i;return Math.abs(r)>Math.abs(n)?(o=n/r,i=r+o*n,[(t+o*e)/i,(e-o*t)/i]):(o=r/n,i=n+o*r,[(o*t+e)/i,(o*e-t)/i])}class P{constructor(t){if(!(t=k.checkMatrix(t)).isSymmetric())throw new Error("Matrix is not symmetric");let e,r,n,o=t,i=o.rows,s=new x(i,i),a=!0;for(r=0;r<i;r++){let t=0;for(n=0;n<r;n++){let i=0;for(e=0;e<n;e++)i+=s.get(n,e)*s.get(r,e);i=(o.get(r,n)-i)/s.get(n,n),s.set(r,n,i),t+=i*i}for(t=o.get(r,r)-t,a&&=t>0,s.set(r,r,Math.sqrt(Math.max(t,0))),n=r+1;n<i;n++)s.set(r,n,0)}this.L=s,this.positiveDefinite=a}isPositiveDefinite(){return this.positiveDefinite}solve(t){t=k.checkMatrix(t);let e=this.L,r=e.rows;if(t.rows!==r)throw new Error("Matrix dimensions do not match");if(!1===this.isPositiveDefinite())throw new Error("Matrix is not positive definite");let n,o,i,s=t.columns,a=t.clone();for(i=0;i<r;i++)for(o=0;o<s;o++){for(n=0;n<i;n++)a.set(i,o,a.get(i,o)-a.get(n,o)*e.get(i,n));a.set(i,o,a.get(i,o)/e.get(i,i))}for(i=r-1;i>=0;i--)for(o=0;o<s;o++){for(n=i+1;n<r;n++)a.set(i,o,a.get(i,o)-a.get(n,o)*e.get(n,i));a.set(i,o,a.get(i,o)/e.get(i,i))}return a}get lowerTriangularMatrix(){return this.L}}class F{constructor(e,r={}){e=k.checkMatrix(e);let{Y:n}=r;const{scaleScores:o=!1,maxIterations:i=1e3,terminationCriteria:s=1e-10}=r;let a;if(n){if(n=t.isAnyArray(n)&&"number"==typeof n[0]?x.columnVector(n):k.checkMatrix(n),n.rows!==e.rows)throw new Error("Y should have the same number of rows as X");a=n.getColumnVector(0)}else a=e.getColumnVector(0);let u,c,h,l,d=1;for(let t=0;t<i&&d>s;t++)h=e.transpose().mmul(a).div(a.transpose().mmul(a).get(0,0)),h=h.div(h.norm()),u=e.mmul(h).div(h.transpose().mmul(h).get(0,0)),t>0&&(d=u.clone().sub(l).pow(2).sum()),l=u.clone(),n?(c=n.transpose().mmul(u).div(u.transpose().mmul(u).get(0,0)),c=c.div(c.norm()),a=n.mmul(c).div(c.transpose().mmul(c).get(0,0))):a=u;if(n){let t=e.transpose().mmul(u).div(u.transpose().mmul(u).get(0,0));t=t.div(t.norm());let r=e.clone().sub(u.clone().mmul(t.transpose())),o=a.transpose().mmul(u).div(u.transpose().mmul(u).get(0,0)),i=n.clone().sub(u.clone().mulS(o.get(0,0)).mmul(c.transpose()));this.t=u,this.p=t.transpose(),this.w=h.transpose(),this.q=c,this.u=a,this.s=u.transpose().mmul(u),this.xResidual=r,this.yResidual=i,this.betas=o}else this.w=h.transpose(),this.s=u.transpose().mmul(u).sqrt(),this.t=o?u.clone().div(this.s.get(0,0)):u,this.xResidual=e.sub(u.mmul(h.transpose()))}}return Xy.AbstractMatrix=m,Xy.CHO=P,Xy.CholeskyDecomposition=P,Xy.DistanceMatrix=E,Xy.EVD=R,Xy.EigenvalueDecomposition=R,Xy.LU=S,Xy.LuDecomposition=S,Xy.Matrix=x,Xy.MatrixColumnSelectionView=class extends M{constructor(t,e){d(t,e),super(t,t.rows,e.length),this.columnIndices=e}set(t,e,r){return this.matrix.set(t,this.columnIndices[e],r),this}get(t,e){return this.matrix.get(t,this.columnIndices[e])}},Xy.MatrixColumnView=class extends M{constructor(t,e){u(t,e),super(t,t.rows,1),this.column=e}set(t,e,r){return this.matrix.set(t,this.column,r),this}get(t){return this.matrix.get(t,this.column)}},Xy.MatrixFlipColumnView=class extends M{constructor(t){super(t,t.rows,t.columns)}set(t,e,r){return this.matrix.set(t,this.columns-e-1,r),this}get(t,e){return this.matrix.get(t,this.columns-e-1)}},Xy.MatrixFlipRowView=class extends M{constructor(t){super(t,t.rows,t.columns)}set(t,e,r){return this.matrix.set(this.rows-t-1,e,r),this}get(t,e){return this.matrix.get(this.rows-t-1,e)}},Xy.MatrixRowSelectionView=class extends M{constructor(t,e){l(t,e),super(t,e.length,t.columns),this.rowIndices=e}set(t,e,r){return this.matrix.set(this.rowIndices[t],e,r),this}get(t,e){return this.matrix.get(this.rowIndices[t],e)}},Xy.MatrixRowView=class extends M{constructor(t,e){a(t,e),super(t,1,t.columns),this.row=e}set(t,e,r){return this.matrix.set(this.row,e,r),this}get(t,e){return this.matrix.get(this.row,e)}},Xy.MatrixSelectionView=N,Xy.MatrixSubView=class extends M{constructor(t,e,r,n,o){f(t,e,r,n,o),super(t,r-e+1,o-n+1),this.startRow=e,this.startColumn=n}set(t,e,r){return this.matrix.set(this.startRow+t,this.startColumn+e,r),this}get(t,e){return this.matrix.get(this.startRow+t,this.startColumn+e)}},Xy.MatrixTransposeView=class extends M{constructor(t){super(t,t.columns,t.rows)}set(t,e,r){return this.matrix.set(e,t,r),this}get(t,e){return this.matrix.get(e,t)}},Xy.NIPALS=F,Xy.Nipals=F,Xy.QR=O,Xy.QrDecomposition=O,Xy.SVD=z,Xy.SingularValueDecomposition=z,Xy.SymmetricMatrix=b,Xy.WrapperMatrix1D=_,Xy.WrapperMatrix2D=k,Xy.correlation=function(e,r=e,n={}){e=new x(e);let o=!1;if("object"!=typeof r||x.isMatrix(r)||t.isAnyArray(r)?r=new x(r):(n=r,r=e,o=!0),e.rows!==r.rows)throw new TypeError("Both matrices must have the same number of rows");const{center:i=!0,scale:s=!0}=n;i&&(e.center("column"),o||r.center("column")),s&&(e.scale("column"),o||r.scale("column"));const a=e.standardDeviation("column",{unbiased:!0}),u=o?a:r.standardDeviation("column",{unbiased:!0}),c=e.transpose().mmul(r);for(let t=0;t<c.rows;t++)for(let r=0;r<c.columns;r++)c.set(t,r,c.get(t,r)*(1/(a[t]*u[r]))*(1/(e.rows-1)));return c},Xy.covariance=function(e,r=e,n={}){e=new x(e);let o=!1;if("object"!=typeof r||x.isMatrix(r)||t.isAnyArray(r)?r=new x(r):(n=r,r=e,o=!0),e.rows!==r.rows)throw new TypeError("Both matrices must have the same number of rows");const{center:i=!0}=n;i&&(e=e.center("column"),o||(r=r.center("column")));const s=e.transpose().mmul(r);for(let t=0;t<s.rows;t++)for(let r=0;r<s.columns;r++)s.set(t,r,s.get(t,r)*(1/(e.rows-1)));return s},Xy.default=x,Xy.determinant=function t(e){if((e=x.checkMatrix(e)).isSquare()){if(0===e.columns)return 1;let r,n,o,i;if(2===e.columns)return r=e.get(0,0),n=e.get(0,1),o=e.get(1,0),i=e.get(1,1),r*i-n*o;if(3===e.columns){let i,s,a;return i=new N(e,[1,2],[1,2]),s=new N(e,[1,2],[0,2]),a=new N(e,[1,2],[0,1]),r=e.get(0,0),n=e.get(0,1),o=e.get(0,2),r*t(i)-n*t(s)+o*t(a)}return new S(e).determinant}throw Error("determinant can only be calculated for a square matrix")},Xy.inverse=function(t,e=!1){return t=k.checkMatrix(t),e?new z(t).inverse():j(t,x.eye(t.rows))},Xy.linearDependencies=function(t,e={}){const{thresholdValue:r=1e-9,thresholdError:n=1e-9}=e;let o=(t=x.checkMatrix(t)).rows,i=new x(o,o);for(let e=0;e<o;e++){let s=x.columnVector(t.getRow(e)),a=t.subMatrixRow(C(o,e)).transpose(),u=new z(a).solve(s),c=x.sub(s,a.mmul(u)).abs().max();i.setRow(e,I(c,u,e,r,n))}return i},Xy.pseudoInverse=function(t,e=Number.EPSILON){if((t=x.checkMatrix(t)).isEmpty())return t.transpose();let r=new z(t,{autoTranspose:!0}),n=r.leftSingularVectors,o=r.rightSingularVectors,i=r.diagonal;for(let t=0;t<i.length;t++)Math.abs(i[t])>e?i[t]=1/i[t]:i[t]=0;return o.mmul(x.diag(i).mmul(n.transpose()))},Xy.solve=j,Xy.wrap=function(e,r){if(t.isAnyArray(e))return e[0]&&t.isAnyArray(e[0])?new k(e):new _(e,r);throw new Error("the argument is not an array")},Xy}var nw=rw(),ow=fs(nw);const iw=nw.Matrix,sw=nw.SingularValueDecomposition;ow.Matrix?ow.Matrix:nw.Matrix;const aw={center:[0,0],linkDistance:50};const uw=t=>{let e=Number.NEGATIVE_INFINITY;const r=[],n=t.length;for(let o=0;o<n;o++){const n=t[o],i=n.length;for(let t=0;t<i;t++){const i=n[t];i===1/0?r.push([o,t]):e<i&&(e=i)}}for(let n=0;n<r.length;n++){const[o,i]=r[n];t[o][i]=e}},cw=(t,e=2,r=aw.linkDistance)=>{try{const r=t.length,n=new iw(r,r);for(let e=0;e<r;e++)for(let o=0;o<r;o++){const r=t[e][o];n.set(e,o,-.5*r*r)}const o=n.mean("row"),i=n.mean("column"),s=n.mean();n.add(s).subRowVector(o).subColumnVector(i);const a=new sw(n),u=iw.sqrt(a.diagonalMatrix).diagonal(),c=a.leftSingularVectors,h=u,l=[];for(let t=0;t<c.rows;t++){const r=[];for(let n=0;n<e;n++)r.push(c.get(t,n)*h[n]);l.push(r)}return l}catch(e){const n=[];for(let e=0;e<t.length;e++){const t=Math.random()*r,e=Math.random()*r;n.push([t,e])}return n}},hw={maxIteration:10,width:10,speed:100,gravity:10,k:5},lw=(t,e,r,n,o)=>{let i=0;t.forEachNode(s=>{let a=0;t.forEachNode(t=>{if(a<=i)return void a++;if(s.id===t.id)return;if(n.get(s.id)!==n.get(t.id))return;let u=s.x-t.x,c=s.y-t.y,h=Math.sqrt(u*u+c*c);if(0===h){h=1;const t=i>a?1:-1;u=.01*t,c=.01*t}const l=Math.max(...o(s._original));if(h<Math.max(...o(t._original))/2+l/2){const n=r*r/h,o=e.get(s.id),i=e.get(t.id),a=u/h*n,l=c/h*n;e.set(s.id,{x:o.x+a,y:o.y+l}),e.set(t.id,{x:i.x-a,y:i.y-l})}a++}),i++})},dw=(t,e,r,n,o,i,s)=>{n&&t.forEachNode(t=>{const r=t.x-o.x,n=t.y-o.y,i=Math.sqrt(r*r+n*n);let s=n/i,a=-r/i;const u=e.get(t.id),c=Math.sqrt(u.x*u.x+u.y*u.y);let h=Math.acos((s*u.x+a*u.y)/c);h>Math.PI/2&&(h-=Math.PI/2,s*=-1,a*=-1);const l=Math.cos(h)*c;e.set(t.id,{x:s*l,y:a*l})});let a=0,u=0;return t.forEachNode(t=>{if(t.id===o.id)return;const c=e.get(t.id),h=Math.sqrt(c.x*c.x+c.y*c.y);if(h>0){const e=Math.min(i*(r/800),h);if(t.x+=c.x/h*e,t.y+=c.y/h*e,n){let e=t.x-o.x,r=t.y-o.y;const n=Math.sqrt(e*e+r*r);e=e/n*s.get(t.id),r=r/n*s.get(t.id),t.x=o.x+e,t.y=o.y+r}a+=e,u++}}),u>0?a/u:0},fw={focusNode:null,linkDistance:50,maxIteration:1e3,maxPreventOverlapIteration:200,preventOverlap:!1,sortStrength:10,strictRadial:!0,unitRadius:null,nodeSize:10,nodeSpacing:0};const gw=(t,e,r,n,o,i,s)=>{const a=e.length,u=new Array(a),c=new Array(a);for(let t=0;t<a;t++)c[t]=n[t]/o;const h=(r+o)/2,l=new Map,d=i&&"data"!==i?ct(i,["node"]):null,f="data"===i;for(let o=0;o<a;o++){const i=e[o],g=new Array(a);u[o]=g;const p=c[o]||1;for(let e=0;e<a;e++){if(o===e){g[e]=0;continue}const a=i[e];if(n[o]===n[e])if(f)g[e]=a*Math.abs(o-e)*s/p;else if(d){const r=t.nodeAt(o),n=t.nodeAt(e);let i=l.get(r.id);if(void 0===i){const t=d(r._original)||0;i="string"==typeof t?t.charCodeAt(0):Number(t||0),l.set(r.id,i)}let u=l.get(n.id);if(void 0===u){const t=d(n._original)||0;u="string"==typeof t?t.charCodeAt(0):Number(t||0),l.set(n.id,u)}g[e]=a*Math.abs(i-u)*s/p}else g[e]=a*r/p;else g[e]=a*h}}return u},pw=t=>{const e=t.length,r=t[0].length,n=[];for(let o=0;o<e;o++){const e=[];for(let n=0;n<r;n++)0!==t[o][n]?e.push(1/(t[o][n]*t[o][n])):e.push(0);n.push(e)}return n},vw=(t,e,r)=>{const n=t.length;for(let o=0;o<n;o++)if(t[e][o]===1/0){t[e][o]=r,t[o][e]=r;for(let 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(let r=0;r<n;r++)if(r!==e)for(let o=0;o<n;o++)if(t[r][o]===1/0){let n=Math.abs(t[e][r]-t[e][o]);n=0===n?1:n,t[r][o]=n}},mw=(t,e)=>{const r=t[e];let n=0;for(let t=0;t<r.length;t++)r[t]!==1/0&&(n=Math.max(n,r[t]));return n};const yw=t=>.9*(Math.random()-.5)*t,ww={"antv-dagre":class extends zt{constructor(){super(...arguments),this.id="antv-dagre"}getDefaultOptions(){return Nr}layout(t){return e(this,void 0,void 0,function*(){const{nodeSize:e,nodeSpacing:r,align:n,rankdir:o="TB",ranksep:i,nodesep:s,edgeLabelSpace:a,ranker:u="tight-tree",nodeOrder:c,begin:h,controlPoints:l,radial:d,sortByCombo:f,preset:g,ranksepFunc:p,nodesepFunc:v}=t,m=ht(p,null!=i?i:50,"node"),y=ht(v,null!=s?s:50,"node");let w=y,x=m;"LR"!==o&&"RL"!==o||(w=m,x=y);const b=new Ct({tree:[]}),E=this.model.nodes(),M=this.model.edges(),N=dt(e,r,Nr.nodeSize,Nr.nodeSpacing);E.forEach(t=>{var e;const r=t._original,n=N(r),o=x(r),i=w(r),s=n[0]+2*i,a=n[1]+2*o,u=null===(e=t.data)||void 0===e?void 0:e.layer;O(u)?b.addNode({id:t.id,data:{width:s,height:a,layer:u,originalWidth:n[0],originalHeight:n[1]}}):b.addNode({id:t.id,data:{width:s,height:a,originalWidth:n[0],originalHeight:n[1]}})}),M.forEach(t=>{b.addEdge({id:t.id,source:t.source,target:t.target,data:{}})}),f&&(b.attachTreeStructure("combo"),E.forEach(t=>{const e=null==t?void 0:t.parentId;void 0!==e&&b.hasNode(e)&&b.setParent(t.id,e,"combo")}));let _=null;(null==g?void 0:g.length)&&(_=new Ct,g.forEach(t=>{_.addNode({id:t.id,data:t.data})})),((t,e)=>{const{edgeLabelSpace:r,keepNodeOrder:n,prevGraph:o,rankdir:i,ranksep:s}=e;!n&&o&&rr(t,o);const a=cr(t);let u;r&&(e.ranksep=hr(a,{rankdir:i,ranksep:s}));try{u=er(a,e)}catch(t){if("Not possible to find intersection inside of the rectangle"===t.message)return void console.error("The following error may be caused by improper layer setting, please make sure your manual layer setting does not violate the graph's structure:\n",t);throw t}nr(t,a)})(b,{prevGraph:_,edgeLabelSpace:a,keepNodeOrder:!!c,nodeOrder:c||[],acyclicer:"greedy",ranker:u,rankdir:o,nodesep:s,align:n});const k=[0,0];if(h){let t=1/0,e=1/0;b.getAllNodes().forEach(r=>{t>r.data.x&&(t=r.data.x),e>r.data.y&&(e=r.data.y)}),b.getAllEdges().forEach(r=>{var n;null===(n=r.data.points)||void 0===n||n.forEach(r=>{t>r.x&&(t=r.x),e>r.y&&(e=r.y)})}),k[0]=h[0]-t,k[1]=h[1]-e}const S="LR"===o||"RL"===o;if(d);else{const t=new Set,e="BT"===o||"RL"===o?(t,e)=>e-t:(t,e)=>t-e;b.getAllNodes().forEach(e=>{e.data.x=e.data.x+k[0],e.data.y=e.data.y+k[1],t.add(S?e.data.x:e.data.y)});const r=Array.from(t).sort(e),n=S?(t,e)=>t.x!==e.x:(t,e)=>t.y!==e.y,i=S?(t,e,r)=>{const n=Math.max(e.y,r.y),o=Math.min(e.y,r.y);return t.filter(t=>t.y<=n&&t.y>=o)}:(t,e,r)=>{const n=Math.max(e.x,r.x),o=Math.min(e.x,r.x);return t.filter(t=>t.x<=n&&t.x>=o)};b.getAllEdges().forEach((t,e)=>{var o;a&&l&&"loop"!==t.data.type&&(t.data.controlPoints=_r(null===(o=t.data.points)||void 0===o?void 0:o.map(({x:t,y:e})=>({x:t+k[0],y:e+k[1]})),b.getNode(t.source),b.getNode(t.target),r,S,n,i))})}this.model.forEachNode(t=>{const e=b.getNode(t.id);if(e){const{x:r,y:n,width:o,height:i,originalWidth:s,originalHeight:a}=e.data,u=f?b.getChildren(t.id,"combo"):b.getChildren(t.id);if(u.length>0){let e=1/0,r=-1/0,n=1/0,o=-1/0;u.forEach(t=>{const i=t.id,s=b.getNode(i);if(null==s?void 0:s.data){const t=s.data.x,i=s.data.y,a=s.data.originalWidth||s.data.width||0,u=s.data.originalHeight||s.data.height||0;e=Math.min(e,t-a/2),r=Math.max(r,t+a/2),n=Math.min(n,i-u/2),o=Math.max(o,i+u/2)}});const i=20,s=(r-e||0)+2*i,a=(o-n||0)+2*i;t.x=(e+r)/2,t.y=(n+o)/2,t.size=[s,a]}else t.x=r,t.y=n,t.size=[s,a]}}),this.model.forEachEdge(t=>{const e=b.getEdge(t.id);e&&e.data.controlPoints&&(t.points=e.data.controlPoints.map(Et))})})}},"d3-force-3d":class extends Nn{constructor(){super(...arguments),this.id="d3-force-3d",this.config={simulationAttrs:["alpha","alphaMin","alphaDecay","alphaTarget","velocityDecay","randomSource","numDimensions"]},this.forceMap={link:Jn,manyBody:so,center:kn,collide:Xn,radial:ao,x:uo,y:co,z:ho}}getDefaultOptions(){return{numDimensions:3,link:{id:t=>t.id},manyBody:{},center:{x:0,y:0,z:0}}}initSimulation(){return io()}setupForces(t,e){Object.entries(this.forceMap).forEach(([r,n])=>{const o=r;if(e[r]){let r=t.force(o);r||(r=n(),t.force(o,r)),_n(r,Object.entries(e[o]))}else t.force(o,null)})}},"d3-force":Nn,"force-atlas2":class extends jt{constructor(){super(...arguments),this.id="force-atlas2",this.simulation=null}getDefaultOptions(){return Dy}layout(t){return e(this,void 0,void 0,function*(){const e=this.parseOptions(t),{width:r,height:n,prune:o,center:i}=e,s=this.model.nodeCount();if(!s||1===s)return D(this.model,i);St(this.model,r,n);const a=this.getSizes(e.nodeSize,e.nodeSpacing),u=this.setSimulation();u.data(this.model,a),u.initialize(e),u.restart();const c=()=>new Promise(t=>{u.on("end",t)});if(!o)return c();if(yield c(),o){const t=this.model.edges();for(let e=0;e<t.length;e+=1){const{source:r,target:n}=t[e],o=this.model.degree(r),i=this.model.degree(n),s=this.model.node(r),a=this.model.node(n);o<=1?(s.x=a.x,s.y=a.y):i<=1&&(a.x=s.x,a.y=s.y)}u.initialize(Object.assign(Object.assign({},e),{prune:!1,barnesHut:!1})),u.tick(100)}})}getSizes(t,e){const r={},n=dt(t,e,Dy.nodeSize,Dy.nodeSpacing);return this.model.forEachNode(t=>{r[t.id]=Math.max(...n(t._original))}),r}setSimulation(){const t=this.simulation||new Ly;return this.simulation||(this.simulation=t.on("tick",()=>{var t,e;return null===(e=(t=this.options).onTick)||void 0===e?void 0:e.call(t,this)})),this.simulation}parseOptions(t={}){const{barnesHut:e,prune:r,maxIteration:n,kr:o,kg:i}=t,s={},a=this.model.nodeCount();return void 0===e&&a>250&&(s.barnesHut=!0),void 0===r&&a>100&&(s.prune=!0),0!==n||r?0===n&&r&&(s.maxIteration=100,a<=200&&a>100?s.maxIteration=500:a>200&&(s.maxIteration=950)):(s.maxIteration=250,a<=200&&a>100?s.maxIteration=1e3:a>200&&(s.maxIteration=1200)),o||(s.kr=50,a>100&&a<=500?s.kr=20:a>500&&(s.kr=1)),i||(s.kg=20,a>100&&a<=500?s.kg=10:a>500&&(s.kg=1)),Object.assign(Object.assign(Object.assign({},t),s),Mt(t))}stop(){var t;null===(t=this.simulation)||void 0===t||t.stop()}tick(t=1){var e;null===(e=this.simulation)||void 0===e||e.tick(t)}restart(){var t;null===(t=this.simulation)||void 0===t||t.restart()}setFixedPosition(t,e){var r;null===(r=this.simulation)||void 0===r||r.setFixedPosition(t,e)}destroy(){var t;super.destroy(),this.stop(),null===(t=this.simulation)||void 0===t||t.destroy(),this.simulation=null}},circular:class extends zt{constructor(){super(...arguments),this.id="circular"}getDefaultOptions(){return kr}layout(){return e(this,void 0,void 0,function*(){const{width:t,height:e,center:r}=Mt(this.options),n=this.model.nodeCount();if(!n||1===n)return void D(this.model,r);const{ordering:o,nodeSpacing:i,nodeSize:s,endAngle:a=2*Math.PI,startAngle:u=0,divisions:c,angleRatio:h,clockwise:l}=this.options;"topology"===o?bt(this.model,!1):"topology-directed"===o?bt(this.model,!0):"degree"===o&&wt(this.model,"asc");let{radius:d,startRadius:f,endRadius:g}=this.options;const p=this.model.nodes(),v=dt(s,i,kr.nodeSize,kr.nodeSpacing);if(i){let t=0;for(const e of p)t+=Math.max(...v(e._original));d=t/(2*Math.PI)}else d||f||g?!f&&g?f=g:f&&!g&&(g=f):d=Math.min(e,t)/2;const m=(a-u)/n*h,y=Math.ceil(n/c),w=2*Math.PI/c;for(let t=0;t<n;){const e=p[t];let o=d;o||null===f||null===g||(o=f+t*(g-f)/(n-1)),o||(o=10+100*t/(n-1));const i=t%y*m+w*Math.floor(t/y);let s=u+i;l||(s=a-i),e.x=r[0]+Math.cos(s)*o,e.y=r[1]+Math.sin(s)*o,t++}})}},concentric:class extends zt{constructor(){super(...arguments),this.id="concentric"}getDefaultOptions(){return Sr}layout(){return e(this,void 0,void 0,function*(){const{width:t,height:e,center:r}=Mt(this.options),n=this.model.nodeCount();if(!n||1===n)return void D(this.model,r);const{sortBy:o,maxLevelDiff:i,sweep:s,clockwise:a,equidistant:u,preventOverlap:c,startAngle:h=Sr.startAngle,nodeSize:l,nodeSpacing:d}=this.options,f=o&&"degree"!==o?ct(o,["node"]):"degree";if("degree"===f)wt(this.model);else{const t=(t,e)=>{const r=f(t),n=f(e);return r===n?0:r>n?-1:1};xt(this.model,t)}const g=this.model.nodes(),p=new Map;for(const t of g){const e="degree"===f?this.model.degree(t.id):f(t._original);p.set(t.id,e)}const v=this.model.firstNode(),m=i||p.get(v.id)/4,y=dt(l,d,Sr.nodeSize,Sr.nodeSpacing),w=new Map;for(const t of g)w.set(t.id,Math.max(...y(t._original)));const x=[{nodes:[]}];let b=x[0];for(let t=0;t<n;t++){const e=g[t];if(b.nodes.length>0){const t=b.nodes[0],r=Math.abs(p.get(t.id)-p.get(e.id));m&&r>=m&&(b={nodes:[]},x.push(b))}b.nodes.push(e)}for(const t of x){const e=t.nodes.map(t=>w.get(t.id));t.nodeSizes=e,t.maxNodeSize=Math.max(...e)}if(x.forEach(t=>{const e=void 0===s?2*Math.PI-2*Math.PI/t.nodes.length:s;t.dTheta=e/Math.max(1,t.nodes.length-1)}),c){let t=0;for(let e=0;e<x.length;e++){const r=x[e];if(r.nodes.length>1){const e=r.nodeSizes||[];let n=0;for(let t=0;t<e.length-1;t++)n=Math.max(n,(e[t]+e[t+1])/2);const o=Math.cos(r.dTheta)-Math.cos(0),i=Math.sin(r.dTheta)-Math.sin(0),s=Math.sqrt(o*o+i*i),a=s>0?n/s:0;t=Math.max(a,t)}if(r.r=t,e<x.length-1){const n=x[e+1],o=((r.maxNodeSize||0)+(n.maxNodeSize||0))/2;t+=Math.max(0,o)}}}else{let r=0;x[0].r=0;for(let t=0;t<x.length-1;t++){const e=x[t],n=x[t+1],o=((e.maxNodeSize||0)+(n.maxNodeSize||0))/2;r+=Math.max(0,o),n.r=r}const n=Math.min(t,e)/2;let o=1;for(const t of x){const e=t.r||0;if(e<=0)continue;const r=n-(t.maxNodeSize||0);if(r<=0){o=0;break}o=Math.min(o,r/e)}if(o=Math.max(0,Math.min(1,o)),1!==o)for(const t of x)t.r=(t.r||0)*o}if(u){let t=0,e=0;for(let r=0;r<x.length;r++){const n=(x[r].r||0)-e;t=Math.max(t,n)}e=0,x.forEach((r,n)=>{0===n&&(e=r.r||0),r.r=e,e+=t})}x.forEach(t=>{const e=t.dTheta||0,n=t.r||0;t.nodes.forEach((t,o)=>{const i=h+(a?1:-1)*e*o;t.x=r[0]+n*Math.cos(i),t.y=r[1]+n*Math.sin(i)})})})}},dagre:class extends zt{constructor(){super(...arguments),this.id="dagre",this.isCompoundGraph=null,this.config={graphAttributes:["rankdir","align","nodesep","edgesep","ranksep","marginx","marginy","acyclicer","ranker"],nodeAttributes:["width","height"],edgeAttributes:["minlen","weight","width","height","labelpos","labeloffset"]}}getDefaultOptions(){return{directed:!0,multigraph:!0,rankdir:"TB",align:void 0,nodesep:50,edgesep:10,ranksep:50,marginx:0,marginy:0,acyclicer:void 0,ranker:"network-simplex",nodeSize:[0,0],edgeMinLen:1,edgeWeight:1,edgeLabelSize:[0,0],edgeLabelPos:"r",edgeLabelOffset:10}}layout(){return e(this,void 0,void 0,function*(){const t=new Ny.graphlib.Graph({directed:!!this.options.directed,multigraph:!!this.options.multigraph,compound:this.isCompound()});t.setGraph(L(this.options,this.config.graphAttributes)),t.setDefaultEdgeLabel(()=>({}));const e=lt(this.options.nodeSize,0);this.model.forEachNode(r=>{const n=r._original,[o,i]=ut(e(n)),s={width:o,height:i};if(t.setNode(String(r.id),s),this.isCompound()){if(M(r.parentId))return;t.setParent(String(r.id),String(r.parentId))}});const{edgeLabelSize:r,edgeLabelOffset:n,edgeLabelPos:o,edgeMinLen:i,edgeWeight:s}=this.options,a=lt(r,0,"edge"),u=ht(n,10,"edge"),c="string"==typeof o?()=>o:ct(o,["edge"]),h=ht(i,1,"edge"),l=ht(s,1,"edge");this.model.forEachEdge(e=>{const r=e._original,[n,o]=ut(a(r)),i={width:n,height:o,labelpos:c(r),labeloffset:u(r),minlen:h(r),weight:l(r)};t.setEdge(String(e.source),String(e.target),i,String(e.id))}),_y.layout(t),this.model.forEachNode(e=>{const r=t.node(String(e.id));r&&(e.x=r.x,e.y=r.y,e.size=[r.width,r.height])}),this.model.forEachEdge(e=>{const r=t.edge(String(e.source),String(e.target),String(e.id));if(!r)return;const{width:n,height:o,weight:i,minlen:s,labelpos:a,labeloffset:u,points:c}=r;e.labelSize=[n,o],e.weight=i,e.minLen=s,e.labelPos=a,e.labelOffset=u,e.points=c.map(Et)})})}isCompound(){return null!==this.isCompoundGraph?this.isCompoundGraph:(t=this.options.compound,k(t,"Boolean")?this.isCompoundGraph=this.options.compound:(this.isCompoundGraph=this.model.nodes().some(t=>!M(t.parentId)),this.isCompoundGraph));var t}},force:class extends jt{constructor(){super(...arguments),this.id="force",this.simulation=null}getDefaultOptions(){return Ry}layout(){var t;return e(this,void 0,void 0,function*(){const e=this.parseOptions(this.options),{width:r,height:n,dimensions:o}=e;if(this.initializePhysicsData(this.model,e),St(this.model,r,n,o),!(null===(t=this.model.nodes())||void 0===t?void 0:t.length))return;const i=this.setSimulation(e);return i.data(this.model),i.initialize(e),i.restart(),new Promise(t=>{i.on("end",()=>t())})})}initializePhysicsData(t,e){const{nodeSize:r,getMass:n,nodeStrength:o,edgeStrength:i,linkDistance:s}=e;t.forEachNode(t=>{const e=t._original;t.size=r(e),t.mass=n(e),t.nodeStrength=o(e)}),t.forEachEdge(e=>{const r=e._original;e.edgeStrength=i(r),e.linkDistance=s(r,t.originalNode(e.source),t.originalNode(e.target))})}setSimulation(t){const e=this.simulation||new Iy;return this.simulation||(this.simulation=e.on("tick",()=>{var e;null===(e=t.onTick)||void 0===e||e.call(t,this)})),this.setupRepulsiveForce(e,t),this.setupAttractiveForce(e,t),this.setupCollideForce(e,t),this.setupGravityForce(e,t),this.setupCentripetalForce(e,t),e}setupRepulsiveForce(t,e){const{factor:r,coulombDisScale:n,dimensions:o}=e;let i=t.force("repulsive");i||(i=Ay(r,n,o),t.force("repulsive",i)),i.factor&&i.factor(r),i.coulombDisScale&&i.coulombDisScale(n),i.dimensions&&i.dimensions(o)}setupAttractiveForce(t,e){const{dimensions:r,preventOverlap:n}=e;if((this.model.edges()||[]).length>0){let e=t.force("attractive");e||(e=function(t=2){let e=!1;function r(e,r){e.forEachEdge(n=>{var o,i;const{source:s,target:a}=n,u=e.node(s),c=e.node(a);if(!u||!c)return;let h=c.x-u.x,l=c.y-u.y,d=3===t?(null!==(o=c.z)&&void 0!==o?o:0)-(null!==(i=u.z)&&void 0!==i?i:0):0;h||l||(h=.01,l=.01,3!==t||d||(d=.01));const f=Math.sqrt(h*h+l*l+d*d);if(f<Number(u.size)+Number(c.size))return;const g=h/f,p=l/f,v=d/f,{linkDistance:m=200,edgeStrength:y=200}=n,w=(m-f)*y,x=1/(u.mass||1),b=1/(c.mass||1),E=g*w,M=p*w,N=v*w;r[s].x-=E*x,r[s].y-=M*x,r[s].z-=N*x,r[a].x+=E*b,r[a].y+=M*b,r[a].z+=N*b})}return r.dimensions=function(e){return arguments.length?(t=e,r):t},r.preventOverlap=function(t){return arguments.length?(e=t,r):e},r}(r),t.force("attractive",e)),e.dimensions&&e.dimensions(r),e.preventOverlap&&e.preventOverlap(n)}else t.force("attractive",null)}setupGravityForce(t,e){const{center:r,gravity:n,getCenter:o}=e;if(n){let e=t.force("gravity");e||(e=function(t=[0,0,0],e=10){let r;function n(n,o){n.nodes()&&n.forEachNode(i=>{const{id:s,mass:a,x:u,y:c,z:h=0}=i;let l=0,d=0,f=0,g=e;const p=n.degree(s),v=null==r?void 0:r(i,p);if(v){const[t,e,r]=v;l=u-t,d=c-e,g=r}else l=u-t[0],d=c-t[1],f=h-(t[2]||0);g&&(o[s].x-=g*l/a,o[s].y-=g*d/a,o[s].z-=g*f/a)})}return n.center=function(e){return arguments.length?(t=e,n):t},n.gravity=function(t){return arguments.length?(e=t,n):e},n.getCenter=function(t){return arguments.length?(r=t,n):r},n}(r,n),t.force("gravity",e)),e.center&&e.center(r),e.gravity&&e.gravity(n),e.getCenter&&e.getCenter(o)}else t.force("gravity",null)}setupCollideForce(t,e){const{preventOverlap:r,collideStrength:n=1,dimensions:o}=e;if(r&&n){let e=t.force("collide");e||(e=function(t=2){let e=1;function r(r,n){const o=r.nodes();if(o.length<2||e<=0)return;if(2===t){const t=o.map((t,e)=>({id:t.id,index:e,x:t.x,y:t.y,r:Number(t.size)/2,mass:t.mass||1,fx:t.fx,fy:t.fy})),e=Cr(t,t=>t.x,t=>t.y).visitAfter(Sy);for(const r of t)e.visit((t,e,o,s,a)=>{const u=t.r||0,c=r.r+u;if(e>r.x+c||s<r.x-c||o>r.y+c||a<r.y-c)return!0;if(!t.data)return!1;let h=t;do{const t=h.data;t&&t.index>r.index&&i(r,t,n),h=h.next}while(h);return!1});return}const a=o.map((t,e)=>{var r;return{id:t.id,index:e,x:t.x,y:t.y,z:null!==(r=t.z)&&void 0!==r?r:0,r:Number(t.size)/2,mass:t.mass||1,fx:t.fx,fy:t.fy,fz:t.fz}});for(let t=0;t<a.length;t++)for(let e=t+1;e<a.length;e++)s(a[t],a[e],n)}function n(t){return O(t.fx)&&O(t.fy)?0:1/(t.mass||1)}function o(t){return O(t.fx)&&O(t.fy)&&O(t.fz)?0:1/(t.mass||1)}function i(t,r,o){let i=t.x-r.x,s=t.y-r.y,a=Math.hypot(i,s);const u=t.r+r.r;if(a>=u)return;a<ky&&(i=t.index<r.index?ky:-ky,s=0,a=Math.abs(i));const c=i/a,h=s/a,l=(u-a)*e*500,d=n(t),f=n(r);d&&(o[t.id].x+=c*l*d,o[t.id].y+=h*l*d),f&&(o[r.id].x-=c*l*f,o[r.id].y-=h*l*f)}function s(t,r,n){let i=t.x-r.x,s=t.y-r.y,a=t.z-r.z,u=Math.sqrt(i*i+s*s+a*a);const c=t.r+r.r;if(u>=c)return;u<ky&&(i=t.index<r.index?ky:-ky,s=0,a=0,u=Math.abs(i));const h=i/u,l=s/u,d=a/u,f=(c-u)*e*500,g=o(t),p=o(r);g&&(n[t.id].x+=h*f*g,n[t.id].y+=l*f*g,n[t.id].z+=d*f*g),p&&(n[r.id].x-=h*f*p,n[r.id].y-=l*f*p,n[r.id].z-=d*f*p)}return r.dimensions=function(e){return arguments.length?(t=e,r):t},r.strength=function(t){return arguments.length?(e=t,r):e},r}(o),t.force("collide",e)),e.strength&&e.strength(n),e.dimensions&&e.dimensions(o)}else t.force("collide",null)}setupCentripetalForce(t,e){const{centripetalOptions:r,width:n,height:o}=e;if(r){let e=t.force("centripetal");e||(e=function(){let t,e=800,r=600;function n(n,o){if(!t)return;const{leaf:i,single:s,others:a,center:u}=t,c=n.nodes(),h=n.edges(),l=c.map(t=>Object.assign(Object.assign({},t),{data:t.data||{}})),d=h.map(t=>Object.assign(Object.assign({},t),{data:t.data||{}}));n.forEachNode(t=>{const{id:c,mass:h,x:f,y:g,z:p=0,data:v}=t,m=n.degree(c,"in"),y=n.degree(c,"out"),w=n.degree(c,"both"),x=Object.assign(Object.assign({},t),{data:v||{}}),{x:b,y:E,z:M,centerStrength:N}=(null==u?void 0:u(x,l,d,e,r))||{x:0,y:0,z:0,centerStrength:0};if(!O(b)||!O(E))return;const _=(f-b)/h,k=(g-E)/h,S=(p-(M||0))/h;if(N&&(o[c].x-=N*_,o[c].y-=N*k,o[c].z-=N*S),0===w){const t=s(x);if(!t)return;return o[c].x-=t*_,o[c].y-=t*k,void(o[c].z-=t*S)}if(0===m||0===y){const t=i(x,l,d);if(!t)return;return o[c].x-=t*_,o[c].y-=t*k,void(o[c].z-=t*S)}const A=a(x);A&&(o[c].x-=A*_,o[c].y-=A*k,o[c].z-=A*S)})}return n.options=function(e){return arguments.length?(t=e,n):t},n.width=function(t){return arguments.length?(e=t,n):e},n.height=function(t){return arguments.length?(r=t,n):r},n}(),t.force("centripetal",e)),e.options&&e.options(r),e.width&&e.width(n),e.height&&e.height(o)}else t.force("centripetal",null)}parseOptions(t){const e=Object.assign(Object.assign({},t),Mt(t));if(e.nodeClusterBy&&(e.nodeClusterBy=ct(e.nodeClusterBy,["node"])),t.getMass?e.getMass=ht(t.getMass,1):e.getMass=t=>{if(!t)return 1;const e=this.model.degree(t.id,"both");return!e||e<5?1:5*e*1},t.getCenter){const r=["node","degree"];e.getCenter=ct(t.getCenter,r)}const r=dt(t.nodeSize,t.nodeSpacing);return e.nodeSize=t=>{if(!t)return 0;const[e,n,o]=r(t);return Math.max(e,n,o)},e.linkDistance=t.linkDistance?ct(t.linkDistance,["edge","source","target"]):(t,e,r)=>1+t.nodeSize(e)+t.nodeSize(r),e.nodeStrength=ht(t.nodeStrength,1),e.edgeStrength=ht(t.edgeStrength,1,"edge"),e.clusterNodeStrength=ht(t.clusterNodeStrength,1),this.formatCentripetal(e),e}formatCentripetal(t){var e,r;const{dimensions:n,centripetalOptions:o,center:i,leafCluster:s,clustering:a,nodeClusterBy:u}=t,c=ct(null==o?void 0:o.leaf,["node","nodes","edges"]),h=ht(null==o?void 0:o.single,2),l=ht(null==o?void 0:o.others,1),d=ct(null!==(e=null==o?void 0:o.center)&&void 0!==e?e:t=>({x:i[0],y:i[1],z:3===n?i[2]:void 0}),["node","nodes","edges","width","height"]),f=Object.assign(Object.assign({},o),{leaf:c,single:h,others:l,center:d});let g,p;if(o&&(t.centripetalOptions=f),s&&u&&(g=this.getSameTypeLeafMap(u),p=Array.from(new Set(null===(r=this.model.nodes())||void 0===r?void 0:r.map(t=>u(t._original))))||[],t.centripetalOptions=Object.assign({},f,{single:()=>100,leaf:e=>{const{siblingLeaves:r,sameTypeLeaves:n}=g[e.id]||{};return(null==n?void 0:n.length)===(null==r?void 0:r.length)||1===(null==p?void 0:p.length)?1:t.clusterNodeStrength(e)},others:()=>1,center:t=>{const e=this.model.degree(t.id,"both");if(!e)return{x:100,y:100,z:0};let r;if(1===e){const{sameTypeLeaves:e=[]}=g[t.id]||{};1===e.length?r=void 0:e.length>1&&(r=this.getAvgNodePosition(e))}else r=void 0;return{x:null==r?void 0:r.x,y:null==r?void 0:r.y,z:null==r?void 0:r.z}}})),a&&u){g||(g=this.getSameTypeLeafMap(u));let e=[];P(e)&&this.model.forEachNode(t=>{const r=u(t._original);r&&!e.includes(r)&&e.push(r)});const r={};e.forEach(t=>{const e=this.model.nodes().filter(e=>u(e._original)===t);r[t]=this.getAvgNodePosition(e)}),t.centripetalOptions=Object.assign(f,{single:e=>t.clusterNodeStrength(e),leaf:e=>t.clusterNodeStrength(e),others:e=>t.clusterNodeStrength(e),center:t=>{const e=r[u(t._original)];return{x:null==e?void 0:e.x,y:null==e?void 0:e.y,z:null==e?void 0:e.z}}})}}getSameTypeLeafMap(t){const e={};return this.model.forEachNode(r=>{1===this.model.degree(r.id,"both")&&(e[r.id]=this.getCoreNodeAndSiblingLeaves(r,t))}),e}getCoreNodeAndSiblingLeaves(t,e){const r=this.model.degree(t.id,"in"),n=this.model.degree(t.id,"out");let o=t,i=[];if(0===r){const e=this.model.successors(t.id);o=this.model.node(e[0]),i=this.model.neighbors(o.id).map(t=>this.model.node(t))}else if(0===n){const e=this.model.predecessors(t.id);o=this.model.node(e[0]),i=this.model.neighbors(o.id).map(t=>this.model.node(t))}i=i.filter(t=>0===this.model.degree(t.id,"in")||0===this.model.degree(t.id,"out"));const s=e(t._original)||"",a=i.filter(t=>e(t._original)===s&&(0===this.model.degree(t.id,"in")||0===this.model.degree(t.id,"out")));return{coreNode:o,siblingLeaves:i,sameTypeLeaves:a}}getAvgNodePosition(t){const e={x:0,y:0};t.forEach(t=>{e.x+=t.x||0,e.y+=t.y||0});const r=t.length||1;return{x:e.x/r,y:e.y/r}}tick(t=1){return this.simulation&&this.simulation.tick(t),this}stop(){return this.simulation&&this.simulation.stop(),this}restart(){return this.simulation&&this.simulation.restart(),this}setFixedPosition(t,e){return this.simulation&&this.simulation.setFixedPosition(t,e),this}},fruchterman:class extends jt{constructor(){super(...arguments),this.id="fruchterman",this.simulation=null}getDefaultOptions(){return By}parseOptions(t={}){const{clustering:e,nodeClusterBy:r}=this.options,n=e&&!!r;return Object.assign(t,Mt(t),{clustering:n,nodeClusterBy:ct(r,["node"])}),t}layout(){return e(this,void 0,void 0,function*(){const t=this.parseOptions(this.options),{dimensions:e,center:r,width:n,height:o}=t,i=this.model.nodeCount();if(!i||1===i)return void D(this.model,r,e);St(this.model,n,o,e);const s=this.setSimulation();return s.data(this.model),s.initialize(t),s.restart(),new Promise(t=>{s.on("end",()=>t())})})}setSimulation(){const t=this.simulation||new qy;return this.simulation||(this.simulation=t.on("tick",()=>{var t,e;return null===(e=(t=this.options).onTick)||void 0===e?void 0:e.call(t,this)})),this.simulation}restart(){var t;null===(t=this.simulation)||void 0===t||t.restart()}stop(){var t;null===(t=this.simulation)||void 0===t||t.stop()}tick(t=1){var e;null===(e=this.simulation)||void 0===e||e.tick(t)}setFixedPosition(t,e){var r;null===(r=this.simulation)||void 0===r||r.setFixedPosition(t,e)}destroy(){var t;super.destroy(),this.stop(),null===(t=this.simulation)||void 0===t||t.destroy(),this.simulation=null}},grid:class extends zt{constructor(){super(...arguments),this.id="grid"}getDefaultOptions(){return Vy}parseOptions(t={},e){const{rows:r,cols:n,position:o,sortBy:i}=t,{width:s,height:a,center:u}=Mt(t);let c=t.rows,h=t.cols;const l=e.nodeCount();if(null!=r&&null!=n)c=r,h=n;else if(null!=r&&null==n)c=r,h=Math.ceil(l/c);else if(null==r&&null!=n)h=n,c=Math.ceil(l/h);else{const t=Math.sqrt(l*a/s);c=Math.round(t),h=Math.round(s/a*t)}c=Math.max(c,1),h=Math.max(h,1);const d={rows:c,cols:h};if(d.cols*d.rows>l){const t=Uy(d),e=$y(d);(t-1)*e>=l?Uy(d,t-1):(e-1)*t>=l&&$y(d,e-1)}else for(;d.cols*d.rows<l;){const t=Uy(d),e=$y(d);(e+1)*t>=l?$y(d,e+1):Uy(d,t+1)}const f=i?"degree"===i||"id"===i?i:ct(i,["nodeA","nodeB"]):Vy.sortBy;return Object.assign(Object.assign({},t),{sortBy:f,rcs:d,center:u,width:s,height:a,position:ct(o,["node"])})}layout(){return e(this,void 0,void 0,function*(){const{begin:t,rcs:e,sortBy:r,width:n,height:o,condense:i,preventOverlap:s,nodeSpacing:a,nodeSize:u,position:c}=this.parseOptions(this.options,this.model),h=this.model.nodeCount();if(!h||1===h)return void D(this.model,t);"degree"===r?wt(this.model):"id"===r?yt(this.model,(t,e)=>{const r=t.id,n=e.id;return"number"==typeof r&&"number"==typeof n?r-n:String(r).localeCompare(String(n))}):xt(this.model,r);let l=i?0:n/e.cols,d=i?0:o/e.rows;if(s){const t=dt(u,a,Vy.nodeSize,Vy.nodeSpacing);this.model.forEachNode(e=>{const[r,n]=t(e._original);l=Math.max(l,r),d=Math.max(d,n)})}const f={},g={row:0,col:0},p={};this.model.forEachNode(r=>{const n=r._original;let o;if(c&&(o=c(n)),o&&(void 0!==o.row||void 0!==o.col)){const t={row:o.row,col:o.col};if(void 0===t.col)for(t.col=0;Gy(f,t);)t.col++;else if(void 0===t.row)for(t.row=0;Gy(f,t);)t.row++;p[r.id]=t,Wy(f,t)}Hy(r,t,l,d,p,e,g,f)})})}},mds:class extends zt{constructor(){super(...arguments),this.id="mds"}getDefaultOptions(){return aw}layout(){return e(this,void 0,void 0,function*(){const{linkDistance:t=aw.linkDistance}=this.options,{center:e}=Mt(this.options),r=this.model.nodeCount();if(0===r||1===r)return void D(this.model,e);const n=gt(ft(this.model));uw(n);const o=((t,e)=>{const r=t.length,n=new Array(r);for(let o=0;o<r;o++){const r=t[o],i=r.length,s=new Array(i);for(let t=0;t<i;t++)s[t]=r[t]*e;n[o]=s}return n})(n,t),i=cw(o);let s=0;this.model.forEachNode(t=>{const r=i[s++];t.x=r[0]+e[0],t.y=r[1]+e[1]})})}},radial:class extends zt{constructor(){super(...arguments),this.id="radial"}getDefaultOptions(){return fw}layout(){return e(this,void 0,void 0,function*(){const{width:t,height:e,center:r}=Mt(this.options),n=this.model.nodeCount();if(!n||1===n)return D(this.model,r);const{focusNode:o,linkDistance:i=fw.linkDistance,maxIteration:s=fw.maxIteration,maxPreventOverlapIteration:a=fw.maxPreventOverlapIteration,nodeSize:u,nodeSpacing:c,preventOverlap:h,sortBy:l,sortStrength:d=fw.sortStrength,strictRadial:f,unitRadius:g}=this.options,p=o&&this.model.node(o)||this.model.firstNode(),v=this.model.nodeIndexOf(p.id),m=gt(ft(this.model)),y=mw(m,v);vw(m,v,y+1);const w=m[v],x=(t-r[0]>r[0]?r[0]:t-r[0])||t/2,b=(e-r[1]>r[1]?r[1]:e-r[1])||e/2,E=Math.min(x,b),M=Math.max(...w),N=[],_=new Map,k=null!=g?g:E/M;w.forEach((t,e)=>{const r=t*k;N.push(r),_.set(this.model.nodeAt(e).id,r)});const S=gw(this.model,m,i,N,k,l,d),A=cw(S,2,i),O=A[v];let z=0;if(this.model.forEachNode(t=>{const e=A[z];t.x=e[0]-O[0],t.y=e[1]-O[1],z++}),this.run(s,S,N,v),this.model.forEachNode(t=>{t.x+=r[0],t.y+=r[1]}),h){const e={nodeSizeFunc:dt(u,c,fw.nodeSize,fw.nodeSpacing),radiiMap:_,width:t,strictRadial:Boolean(f),focusNode:p,maxIteration:a,k:n/4.5};((t,e)=>{const r=Object.assign(Object.assign({},hw),e),{maxIteration:n,width:o,k:i,speed:s=hw.speed,strictRadial:a,focusNode:u,radiiMap:c,nodeSizeFunc:h}=r,l=.002*i,d=new Map,f=o/10;for(let e=0;e<n&&(t.forEachNode(t=>{d.set(t.id,{x:0,y:0})}),lw(t,d,i,c,h),!(dw(t,d,s,a,u,f,c)<l));e++);})(this.model,e)}})}run(t,e,r,n){const o=pw(e),i=this.model.nodeCount(),s=this.model.nodes(),a=new Float64Array(i),u=new Float64Array(i);for(let t=0;t<i;t++)a[t]=s[t].x,u[t]=s[t].y;for(let c=0;c<=t;c++){const h=c/t,l=1-h;for(let t=0;t<i;t++){if(t===n)continue;const c=a[t],d=u[t],f=Math.sqrt(c*c+d*d),g=0===f?0:1/f;let p=0,v=0,m=0;for(let r=0;r<i;r++){if(t===r)continue;const n=a[r],i=u[r],s=Math.sqrt((c-n)*(c-n)+(d-i)*(d-i)),h=0===s?0:1/s,l=e[r][t];m+=o[t][r],p+=o[t][r]*(n+l*(c-n)*h),v+=o[t][r]*(i+l*(d-i)*h)}const y=0===r[t]?0:1/r[t];m*=l,m+=h*y*y,p*=l,p+=h*y*c*g,v*=l,v+=h*y*d*g,a[t]=p/m,u[t]=v/m,s[t].x=a[t],s[t].y=u[t]}}}},random:class extends zt{constructor(){super(...arguments),this.id="random"}getDefaultOptions(){return{center:[0,0],width:300,height:300}}layout(){return e(this,void 0,void 0,function*(){const{width:t,height:e,center:r}=Mt(this.options);this.model.forEachNode(n=>{n.x=yw(t)+r[0],n.y=yw(e)+r[1]})})}}};let xw=null;c({execute(t,r,n){var o;return e(this,void 0,void 0,function*(){const e=ww[t];if(!e)throw new Error(`Layout "${t}" is not registered.`);null===(o=null==xw?void 0:xw.destroy)||void 0===o||o.call(xw),xw=new e;const i=function(t){if(!t)return t;const e=Object.assign({},t);return e.enableWorker=!1,e}(n);return yield xw.execute(r,i),xw.model.data()})},destroy(){var t;null===(t=null==xw?void 0:xw.destroy)||void 0===t||t.call(xw),xw=null,"undefined"!=typeof self&&"close"in self&&self.close()}})}();
|
|
7
|
+
const e=Symbol("Comlink.proxy"),r=Symbol("Comlink.endpoint"),n=Symbol("Comlink.releaseProxy"),o=Symbol("Comlink.finalizer"),i=Symbol("Comlink.thrown"),s=t=>"object"==typeof t&&null!==t||"function"==typeof t,a=new Map([["proxy",{canHandle:t=>s(t)&&t[e],serialize(t){const{port1:e,port2:r}=new MessageChannel;return u(t,e),[r,[r]]},deserialize:t=>(t.start(),h(t))}],["throw",{canHandle:t=>s(t)&&i in t,serialize({value:t}){let e;return e=t instanceof Error?{isError:!0,value:{message:t.message,name:t.name,stack:t.stack}}:{isError:!1,value:t},[e,[]]},deserialize(t){if(t.isError)throw Object.assign(new Error(t.value.message),t.value);throw t.value}}]]);function u(t,r=globalThis,n=["*"]){r.addEventListener("message",function s(a){if(!a||!a.data)return;if(!function(t,e){for(const r of t){if(e===r||"*"===r)return!0;if(r instanceof RegExp&&r.test(e))return!0}return!1}(n,a.origin))return void console.warn(`Invalid origin '${a.origin}' for comlink proxy`);const{id:h,type:l,path:d}=Object.assign({path:[]},a.data),f=(a.data.argumentList||[]).map(w);let g;try{const r=d.slice(0,-1).reduce((t,e)=>t[e],t),n=d.reduce((t,e)=>t[e],t);switch(l){case"GET":g=n;break;case"SET":r[d.slice(-1)[0]]=w(a.data.value),g=!0;break;case"APPLY":g=n.apply(r,f);break;case"CONSTRUCT":g=function(t){return Object.assign(t,{[e]:!0})}(new n(...f));break;case"ENDPOINT":{const{port1:e,port2:r}=new MessageChannel;u(t,r),g=function(t,e){return m.set(t,e),t}(e,[e])}break;case"RELEASE":g=void 0;break;default:return}}catch(t){g={value:t,[i]:0}}Promise.resolve(g).catch(t=>({value:t,[i]:0})).then(e=>{const[n,i]=y(e);r.postMessage(Object.assign(Object.assign({},n),{id:h}),i),"RELEASE"===l&&(r.removeEventListener("message",s),c(r),o in t&&"function"==typeof t[o]&&t[o]())}).catch(t=>{const[e,n]=y({value:new TypeError("Unserializable return value"),[i]:0});r.postMessage(Object.assign(Object.assign({},e),{id:h}),n)})}),r.start&&r.start()}function c(t){(function(t){return"MessagePort"===t.constructor.name})(t)&&t.close()}function h(t,e){const r=new Map;return t.addEventListener("message",function(t){const{data:e}=t;if(!e||!e.id)return;const n=r.get(e.id);if(n)try{n(e)}finally{r.delete(e.id)}}),p(t,r,[],e)}function l(t){if(t)throw new Error("Proxy has been released and is not useable")}function d(t){return x(t,new Map,{type:"RELEASE"}).then(()=>{c(t)})}const f=new WeakMap,g="FinalizationRegistry"in globalThis&&new FinalizationRegistry(t=>{const e=(f.get(t)||0)-1;f.set(t,e),0===e&&d(t)});function p(t,e,o=[],i=function(){}){let s=!1;const a=new Proxy(i,{get(r,i){if(l(s),i===n)return()=>{!function(t){g&&g.unregister(t)}(a),d(t),e.clear(),s=!0};if("then"===i){if(0===o.length)return{then:()=>a};const r=x(t,e,{type:"GET",path:o.map(t=>t.toString())}).then(w);return r.then.bind(r)}return p(t,e,[...o,i])},set(r,n,i){l(s);const[a,u]=y(i);return x(t,e,{type:"SET",path:[...o,n].map(t=>t.toString()),value:a},u).then(w)},apply(n,i,a){l(s);const u=o[o.length-1];if(u===r)return x(t,e,{type:"ENDPOINT"}).then(w);if("bind"===u)return p(t,e,o.slice(0,-1));const[c,h]=v(a);return x(t,e,{type:"APPLY",path:o.map(t=>t.toString()),argumentList:c},h).then(w)},construct(r,n){l(s);const[i,a]=v(n);return x(t,e,{type:"CONSTRUCT",path:o.map(t=>t.toString()),argumentList:i},a).then(w)}});return function(t,e){const r=(f.get(e)||0)+1;f.set(e,r),g&&g.register(t,e,t)}(a,t),a}function v(t){const e=t.map(y);return[e.map(t=>t[0]),(r=e.map(t=>t[1]),Array.prototype.concat.apply([],r))];var r}const m=new WeakMap;function y(t){for(const[e,r]of a)if(r.canHandle(t)){const[n,o]=r.serialize(t);return[{type:"HANDLER",name:e,value:n},o]}return[{type:"RAW",value:t},m.get(t)||[]]}function w(t){switch(t.type){case"HANDLER":return a.get(t.name).deserialize(t.value);case"RAW":return t.value}}function x(t,e,r,n){return new Promise(o=>{const i=new Array(4).fill(0).map(()=>Math.floor(Math.random()*Number.MAX_SAFE_INTEGER).toString(16)).join("-");e.set(i,o),t.start&&t.start(),t.postMessage(Object.assign({id:i},r),n)})}function b(t){return"function"==typeof t}function E(t){return null==t}function M(t){return Array.isArray(t)}var N={}.toString,_=function(t,e){return N.call(t)==="[object "+e+"]"},k=function(t){if(!function(t){return"object"==typeof t&&null!==t}(t)||!_(t,"Object"))return!1;if(null===Object.getPrototypeOf(t))return!0;for(var e=t;null!==Object.getPrototypeOf(e);)e=Object.getPrototypeOf(e);return Object.getPrototypeOf(t)===e};function S(t){return"string"==typeof t}function A(t){return"number"==typeof t}var O={}.toString,z=Object.prototype,j=function(t){if("object"!=typeof t||null===t)return t;var e;if(M(t)){e=[];for(var r=0,n=t.length;r<n;r++)"object"==typeof t[r]&&null!=t[r]?e[r]=j(t[r]):e[r]=t[r]}else for(var o in e={},t)"object"==typeof t[o]&&null!=t[o]?e[o]=j(t[o]):e[o]=t[o];return e};function C(t,e){if(Object.hasOwn)return Object.hasOwn(t,e);if(null==t)throw new TypeError("Cannot convert undefined or null to object");return Object.prototype.hasOwnProperty.call(Object(t),e)}function I(t,e,r,n){for(var o in r=r||0,n=n||5,e)if(C(e,o)){var i=e[o];null!==i&&k(i)?(k(t[o])||(t[o]={}),r<n?I(t[o],i,r+1,n):t[o]=e[o]):M(i)?(t[o]=[],t[o]=t[o].concat(i)):void 0!==i&&(t[o]=i)}}var R=Object.prototype.hasOwnProperty;function T(t){if(E(t))return!0;if(function(t){return null!==t&&"function"!=typeof t&&isFinite(t.length)}(t))return!t.length;var e=function(t){return O.call(t).replace(/^\[object /,"").replace(/]$/,"")}(t);if("Map"===e||"Set"===e)return!t.size;if(function(t){var e=t&&t.constructor;return t===("function"==typeof e&&e.prototype||z)}(t))return!Object.keys(t).length;for(var r in t)if(R.call(t,r))return!1;return!0}var P=Object.prototype.hasOwnProperty,F=function(t,e){if(null===t||!k(t))return{};var r={};return function(t,e){var r,n;if(t)if(M(t))for(var o=0,i=t.length;o<i&&!1!==e(t[o],o);o++);else if(n=typeof(r=t),null!==r&&"object"===n||"function"===n)for(var s in t)if(t.hasOwnProperty(s)&&!1===e(t[s],s))break}(e,function(e){P.call(t,e)&&(r[e]=t[e])}),r};function L(t,e,r=2){if(1===t.nodeCount()){const n=t.firstNode();n.x=e[0],n.y=e[1],3===r&&(n.z=e[2]||0)}}const D={abs:Math.abs,ceil:Math.ceil,floor:Math.floor,max:Math.max,min:Math.min,round:Math.round,sqrt:Math.sqrt,pow:Math.pow};class q extends Error{constructor(t,e,r){super(t),this.position=e,this.token=r,this.name="ExpressionError"}}var B;!function(t){t[t.STRING=0]="STRING",t[t.NUMBER=1]="NUMBER",t[t.BOOLEAN=2]="BOOLEAN",t[t.NULL=3]="NULL",t[t.IDENTIFIER=4]="IDENTIFIER",t[t.OPERATOR=5]="OPERATOR",t[t.FUNCTION=6]="FUNCTION",t[t.DOT=7]="DOT",t[t.BRACKET_LEFT=8]="BRACKET_LEFT",t[t.BRACKET_RIGHT=9]="BRACKET_RIGHT",t[t.PAREN_LEFT=10]="PAREN_LEFT",t[t.PAREN_RIGHT=11]="PAREN_RIGHT",t[t.COMMA=12]="COMMA",t[t.QUESTION=13]="QUESTION",t[t.COLON=14]="COLON",t[t.DOLLAR=15]="DOLLAR"}(B||(B={}));const V=new Set([32,9,10,13]),$=new Set([43,45,42,47,37,33,38,124,61,60,62]),U=new Map([["true",B.BOOLEAN],["false",B.BOOLEAN],["null",B.NULL]]),G=new Map([["===",!0],["!==",!0],["<=",!0],[">=",!0],["&&",!0],["||",!0],["+",!0],["-",!0],["*",!0],["/",!0],["%",!0],["!",!0],["<",!0],[">",!0]]),W=new Map([[46,B.DOT],[91,B.BRACKET_LEFT],[93,B.BRACKET_RIGHT],[40,B.PAREN_LEFT],[41,B.PAREN_RIGHT],[44,B.COMMA],[63,B.QUESTION],[58,B.COLON],[36,B.DOLLAR]]),Y=new Map;for(const[t,e]of W.entries())Y.set(t,{type:e,value:String.fromCharCode(t)});function H(t){return t>=48&&t<=57}function X(t){return t>=97&&t<=122||t>=65&&t<=90||95===t}function Q(t){return X(t)||H(t)}function K(t){return $.has(t)}var J;!function(t){t[t.Program=0]="Program",t[t.Literal=1]="Literal",t[t.Identifier=2]="Identifier",t[t.MemberExpression=3]="MemberExpression",t[t.CallExpression=4]="CallExpression",t[t.BinaryExpression=5]="BinaryExpression",t[t.UnaryExpression=6]="UnaryExpression",t[t.ConditionalExpression=7]="ConditionalExpression"}(J||(J={}));const Z=new Map([["||",2],["&&",3],["===",4],["!==",4],[">",5],[">=",5],["<",5],["<=",5],["+",6],["-",6],["*",7],["/",7],["%",7],["!",8]]),tt={type:J.Literal,value:null},et={type:J.Literal,value:!0},rt={type:J.Literal,value:!1},nt=t=>{let e=0;const r=t.length,n=()=>e>=r?null:t[e],o=()=>t[e++],i=t=>{const e=n();return null!==e&&e.type===t},s=t=>t.type===B.OPERATOR?Z.get(t.value)||-1:t.type===B.DOT||t.type===B.BRACKET_LEFT?9:t.type===B.QUESTION?1:-1,a=t=>{let r,s;if(o().type===B.DOT){if(!i(B.IDENTIFIER)){const t=n();throw new q("Expected property name",e,t?t.value:"<end of input>")}const t=o();r={type:J.Identifier,name:t.value},s=!1}else{if(r=c(0),!i(B.BRACKET_RIGHT)){const t=n();throw new q("Expected closing bracket",e,t?t.value:"<end of input>")}o(),s=!0}return{type:J.MemberExpression,object:t,property:r,computed:s}},u=()=>{const t=n();if(!t)throw new q("Unexpected end of input",e,"<end of input>");if(t.type===B.OPERATOR&&("!"===t.value||"-"===t.value)){o();const e=u();return{type:J.UnaryExpression,operator:t.value,argument:e,prefix:!0}}switch(t.type){case B.NUMBER:return o(),{type:J.Literal,value:Number(t.value)};case B.STRING:return o(),{type:J.Literal,value:t.value};case B.BOOLEAN:return o(),"true"===t.value?et:rt;case B.NULL:return o(),tt;case B.IDENTIFIER:return o(),{type:J.Identifier,name:t.value};case B.FUNCTION:return(()=>{const t=o(),r=[];if(!i(B.PAREN_LEFT)){const t=n();throw new q("Expected opening parenthesis after function name",e,t?t.value:"<end of input>")}for(o();;){if(i(B.PAREN_RIGHT)){o();break}if(!n()){const t=n();throw new q("Expected closing parenthesis",e,t?t.value:"<end of input>")}if(r.length>0){if(!i(B.COMMA)){const t=n();throw new q("Expected comma between function arguments",e,t?t.value:"<end of input>")}o()}const t=c(0);r.push(t)}return{type:J.CallExpression,callee:{type:J.Identifier,name:t.value},arguments:r}})();case B.PAREN_LEFT:{o();const t=c(0);if(!i(B.PAREN_RIGHT)){const t=n();throw new q("Expected closing parenthesis",e,t?t.value:"<end of input>")}return o(),t}default:throw new q(`Unexpected token: ${t.type}`,e,t.value)}},c=(h=0)=>{let l=u();for(;e<r;){const r=t[e],u=s(r);if(u<=h)break;if(r.type!==B.QUESTION)if(r.type!==B.OPERATOR){if(r.type!==B.DOT&&r.type!==B.BRACKET_LEFT)break;l=a(l)}else{o();const t=c(u);l={type:J.BinaryExpression,operator:r.value,left:l,right:t}}else{o();const t=c(0);if(!i(B.COLON)){const t=n();throw new q("Expected : in conditional expression",e,t?t.value:"<end of input>")}o();const r=c(0);l={type:J.ConditionalExpression,test:l,consequent:t,alternate:r}}}return l},h=c();return{type:J.Program,body:h}},ot=(t,e,r)=>{let n=e;r&&(n={...e,context:{...e.context,...r}});const o=t=>{switch(t.type){case J.Literal:return(t=>t.value)(t);case J.Identifier:return(t=>{if(!(t.name in n.context))throw new q(`Undefined variable: ${t.name}`);return n.context[t.name]})(t);case J.MemberExpression:return(t=>{const e=o(t.object);if(null==e)throw new q("Cannot access property of null or undefined");return e[t.computed?o(t.property):t.property.name]})(t);case J.CallExpression:return(t=>{const e=n.functions[t.callee.name];if(!e)throw new q(`Undefined function: ${t.callee.name}`);return e(...t.arguments.map(t=>o(t)))})(t);case J.BinaryExpression:return(t=>{if("&&"===t.operator){const e=o(t.left);return e?o(t.right):e}if("||"===t.operator)return o(t.left)||o(t.right);const e=o(t.left),r=o(t.right);switch(t.operator){case"+":return e+r;case"-":return e-r;case"*":return e*r;case"/":return e/r;case"%":return e%r;case"===":return e===r;case"!==":return e!==r;case">":return e>r;case">=":return e>=r;case"<":return e<r;case"<=":return e<=r;default:throw new q(`Unknown operator: ${t.operator}`)}})(t);case J.UnaryExpression:return(t=>{const e=o(t.argument);if(t.prefix)switch(t.operator){case"!":return!e;case"-":if("number"!=typeof e)throw new q(`Cannot apply unary - to non-number: ${e}`);return-e;default:throw new q(`Unknown operator: ${t.operator}`)}throw new q(`Postfix operators are not supported: ${t.operator}`)})(t);case J.ConditionalExpression:return(t=>{const e=o(t.test);return o(e?t.consequent:t.alternate)})(t);default:throw new q(`Evaluation error: Unsupported node type: ${t.type}`)}};return o(t.body)};function it(t){const e=(t=>{const e=t,r=e.length,n=new Array(Math.ceil(r/3));let o=0,i=0;function s(t){const n=i+1;i++;let o="",s=!1;for(;i<r;){const r=e.charCodeAt(i);if(r===t)return s||(o=e.substring(n,i)),i++,{type:B.STRING,value:o};92===r?(s||(o=e.substring(n,i),s=!0),i++,o+=e[i]):s&&(o+=e[i]),i++}throw new q(`Unterminated string starting with ${String.fromCharCode(t)}`,i,e.substring(Math.max(0,i-10),i))}function a(){const t=i;for(45===e.charCodeAt(i)&&i++;i<r&&H(e.charCodeAt(i));)i++;if(i<r&&46===e.charCodeAt(i))for(i++;i<r&&H(e.charCodeAt(i));)i++;const n=e.slice(t,i);return{type:B.NUMBER,value:n}}function u(){i++;const t=i;if(i<r&&X(e.charCodeAt(i)))for(i++;i<r&&Q(e.charCodeAt(i));)i++;const n=e.slice(t,i);return{type:B.FUNCTION,value:n}}function c(){const t=i++;for(;i<r&&Q(e.charCodeAt(i));)i++;const n=e.slice(t,i),o=U.get(n);return o?{type:o,value:n}:{type:B.IDENTIFIER,value:n}}function h(){if(i+2<r){const t=e.substring(i,i+3);if(G.has(t))return i+=3,{type:B.OPERATOR,value:t}}if(i+1<r){const t=e.substring(i,i+2);if(G.has(t))return i+=2,{type:B.OPERATOR,value:t}}const t=e[i];if(G.has(t))return i++,{type:B.OPERATOR,value:t};throw new q(`Unknown operator at position ${i}: ${e.substring(i,i+1)}`,i,e.substring(Math.max(0,i-10),i))}for(;i<r;){const t=e.charCodeAt(i);if(l=t,V.has(l)){i++;continue}const d=Y.get(t);if(d)n[o++]=d,i++;else if(34!==t&&39!==t)if(H(t)||45===t&&i+1<r&&H(e.charCodeAt(i+1)))n[o++]=a();else if(64!==t)if(X(t))n[o++]=c();else{if(!K(t))throw new q(`Unexpected character: ${e[i]}`,i,e.substring(Math.max(0,i-10),i));n[o++]=h()}else n[o++]=u();else n[o++]=s(t)}var l;return o===n.length?n:n.slice(0,o)})(t),r=nt(e),n=((t={},e={})=>({context:t,functions:e}))({},D);return(t={})=>ot(r,n,t)}function st(t,e){if("string"!=typeof t)return;const r=t.trim();if(r)try{return it(r),function(t,e={}){return it(t)(e)}(r,e)}catch(t){return}}function at(t){if(!t)return[0,0,0];if(A(t))return[t,t,t];if(Array.isArray(t)&&0===t.length)return[0,0,0];const[e,r=e,n=e]=t;return[e,r,n]}function ut(t,e){if("function"==typeof t)return t;if("string"==typeof t){const r=t;return(...t)=>{const n={};for(let r=0;r<e.length;r++)n[e[r]]=t[r];return st(r,n)}}return()=>t}function ct(t,e,r="node"){if(E(t))return()=>e;if(S(t)){const n=ut(t,[r]);return t=>{const r=n(t);return A(r)?r:e}}return b(t)?t:A(t)?()=>t:()=>e}function ht(t,e=10,r="node"){if(E(t))return()=>e;if(S(t)){const n=ut(t,[r]);return t=>{const r=n(t);return function(t){return!!A(t)||!!Array.isArray(t)&&t.every(t=>A(t))}(r)?r:e}}return b(t)?t:A(t)||Array.isArray(t)?()=>t:()=>e}const lt=(t,e,r=10,n=0)=>{const o=ht(e,n),i=ht(t,r);return t=>{const[e,r,n]=at(i(t)),[s,a,u]=at(o(t));return[e+s,r+a,n+u]}},dt=(t,e)=>{const r=t.nodeCount(),n=Array.from({length:r},()=>[]),o={};let i=0;return t.forEachNode(t=>{o[t.id]=i++}),t.forEachEdge(t=>{const e=o[t.source],r=o[t.target];null!=e&&null!=r&&(n[e].push(r),n[r].push(e))}),n};function ft(t){const e=t.length;new Array(e).fill(0);const r=Array.from({length:e},()=>new Array(e).fill(1/0));for(let n=0;n<e;n++)r[n]=gt(t,n);return r}function gt(t,e){const r=t.length,n=new Array(r).fill(1/0);n[e]=0;const o=new pt;for(o.push([0,e]);!o.empty();){const[e,r]=o.pop();if(e!==n[r])continue;const i=t[r];for(let t=0;t<i.length;t++){const r=i[t],s=e+1;s<n[r]&&(n[r]=s,o.push([s,r]))}}return n}class pt{constructor(){this.data=[]}push(t){this.data.push(t),this.bubbleUp(this.data.length-1)}pop(){const t=this.data[0],e=this.data.pop();return this.data.length>0&&(this.data[0]=e,this.bubbleDown(0)),t}empty(){return 0===this.data.length}bubbleUp(t){const e=this.data;for(;t>0;){const r=t-1>>1;if(e[r][0]<=e[t][0])break;[e[r],e[t]]=[e[t],e[r]],t=r}}bubbleDown(t){const e=this.data,r=e.length;for(;;){const n=2*t+1,o=2*t+2;let i=t;if(n<r&&e[n][0]<e[i][0]&&(i=n),o<r&&e[o][0]<e[i][0]&&(i=o),i===t)break;[e[t],e[i]]=[e[i],e[t]],t=i}}}function vt(t,...e){return e.forEach(e=>{e&&Object.keys(e).forEach(r=>{const n=e[r];void 0!==n&&(t[r]=n)})}),t}function mt(t,e){const r=t.nodes();return r.sort(e),t.setNodeOrder(r),t}function yt(t,e="desc"){return mt(t,(r,n)=>{const o=t.degree(r.id),i=t.degree(n.id);return"asc"===e?o-i:i-o})}function wt(t,e){return mt(t,(r,n)=>{const o=t.originalNode(r.id),i=t.originalNode(n.id);return e(o,i)})}function xt(t,e=!1){const r=t.nodeCount();if(0===r)return t;const n=t.nodes(),o=[n[0]],i={};i[n[0].id]=!0;let s=0,a=0;return t.forEachNode(u=>{if(0!==a){const c=t.degree(u.id,"both"),h=a<r-1?t.degree(n[a+1].id,"both"):0,l=o[s].id,d=t.neighbors(l,"both").includes(u.id);if(a!==r-1&&c===h&&!d||i[u.id]){const s=e?t.successors(l):t.neighbors(l);let a=!1;for(let e=0;e<s.length;e++){const r=s[e],n=t.node(r);if(n&&t.degree(r)===t.degree(u.id)&&!i[r]){o.push(n),i[r]=!0,a=!0;break}}let c=0;for(;!a&&(i[n[c].id]||(o.push(n[c]),i[n[c].id]=!0,a=!0),c++,c!==r););}else o.push(u),i[u.id]=!0,s++}a++}),t.setNodeOrder(o),t}function bt(t){var e;return[t.x,t.y,null!==(e=t.z)&&void 0!==e?e:0]}const Et=t=>{const{width:e,height:r,center:n}=t,o=null!=e?e:"undefined"!=typeof window?window.innerWidth:0,i=null!=r?r:"undefined"!=typeof window?window.innerHeight:0;return{width:o,height:i,center:null!=n?n:[o/2,i/2]}};class Mt{constructor(t,e={}){this.edgeIdCounter=new Map,this.nodeMap=function(t,e){if(!t)throw new Error("Data.nodes is required");const r=new Map;for(const n of t){const t={_original:n};for(const e of Nt){const r=n[e];E(r)||(t[e]=r)}if(e){const r=e(n);for(const e in r){const n=r[e];E(n)||(t[e]=n)}}if(E(t.id))throw new Error("Node is missing id field");r.set(t.id,t)}return r}(t.nodes,e.node),this.edgeMap=function(t,e,r){const n=new Map;for(const o of t){const t={_original:o};for(const e of _t){const r=o[e];E(r)||(t[e]=r)}if(e){const r=e(o);for(const e in r){const n=r[e];E(n)||(t[e]=n)}}if(E(t.source)||E(t.target))throw new Error("Edge is missing source or target field");E(t.id)&&(t.id=null==r?void 0:r(o)),n.set(t.id,t)}return n}(t.edges||[],e.edge,this.getEdgeId.bind(this))}data(){return{nodes:this.nodeMap,edges:this.edgeMap}}replace(t){this.nodeMap=t.nodes,this.edgeMap=t.edges,this.clearCache()}nodes(){return Array.from(this.nodeMap.values())}node(t){return this.nodeMap.get(t)}nodeAt(t){this.indexNodeCache||this.buildNodeIndexCache();const e=this.indexNodeCache.get(t);return e?this.nodeMap.get(e):void 0}nodeIndexOf(t){var e;return this.nodeIndexCache||this.buildNodeIndexCache(),null!==(e=this.nodeIndexCache.get(t))&&void 0!==e?e:-1}firstNode(){return this.nodeMap.values().next().value}forEachNode(t){let e=0;this.nodeMap.forEach(r=>t(r,e++))}originalNode(t){const e=this.nodeMap.get(t);return null==e?void 0:e._original}nodeCount(){return this.nodeMap.size}edges(){return Array.from(this.edgeMap.values())}edge(t){return this.edgeMap.get(t)}firstEdge(){return this.edgeMap.values().next().value}forEachEdge(t){let e=0;this.edgeMap.forEach(r=>t(r,e++))}originalEdge(t){const e=this.edgeMap.get(t);return null==e?void 0:e._original}edgeCount(){return this.edgeMap.size}getEdgeId(t){if(t.id)return t.id;const e=`${t.source}-${t.target}`,r=this.edgeIdCounter.get(e)||0,n=0===r?e:`${e}-${r}`;return this.edgeIdCounter.set(e,r+1),n}degree(t,e="both"){this.degreeCache||this.buildDegreeCache();const r=this.degreeCache.get(t);return r?r[e]:0}neighbors(t,e="both"){if(this.outAdjacencyCache&&this.inAdjacencyCache||this.buildAdjacencyCache(),"out"===e)return Array.from(this.outAdjacencyCache.get(t)||[]);if("in"===e)return Array.from(this.inAdjacencyCache.get(t)||[]);if(this.bothAdjacencyCache)return Array.from(this.bothAdjacencyCache.get(t)||[]);const r=this.inAdjacencyCache.get(t),n=this.outAdjacencyCache.get(t);if(!r&&!n)return[];if(!r)return Array.from(n);if(!n)return Array.from(r);const o=new Set;return r.forEach(t=>o.add(t)),n.forEach(t=>o.add(t)),Array.from(o)}successors(t){return this.neighbors(t,"out")}predecessors(t){return this.neighbors(t,"in")}setNodeOrder(t){const e=new Map;for(const r of t)e.set(r.id,r);this.nodeMap=e,this.nodeIndexCache=void 0,this.indexNodeCache=void 0}clearCache(){this.degreeCache=void 0,this.inAdjacencyCache=void 0,this.outAdjacencyCache=void 0,this.bothAdjacencyCache=void 0,this.nodeIndexCache=void 0,this.indexNodeCache=void 0}buildDegreeCache(){this.degreeCache=new Map;for(const t of this.edges()){const{source:e,target:r}=t;if(t.source===t.target)continue;this.degreeCache.has(e)||this.degreeCache.set(e,{in:0,out:0,both:0});const n=this.degreeCache.get(t.source);n&&(n.out++,n.both++),this.degreeCache.has(r)||this.degreeCache.set(r,{in:0,out:0,both:0});const o=this.degreeCache.get(t.target);o&&(o.in++,o.both++)}}buildAdjacencyCache(){this.inAdjacencyCache=new Map,this.outAdjacencyCache=new Map;for(const t of this.edges())this.nodeMap.has(t.source)&&this.nodeMap.has(t.target)&&(this.outAdjacencyCache.has(t.source)||this.outAdjacencyCache.set(t.source,new Set),this.outAdjacencyCache.get(t.source).add(t.target),this.inAdjacencyCache.has(t.target)||this.inAdjacencyCache.set(t.target,new Set),this.inAdjacencyCache.get(t.target).add(t.source))}buildNodeIndexCache(){this.nodeIndexCache=new Map,this.indexNodeCache=new Map;let t=0;this.nodeMap.forEach((e,r)=>{this.nodeIndexCache.set(r,t),this.indexNodeCache.set(t,r),t++})}destroy(){this.clearCache(),this.nodeMap.clear(),this.edgeMap.clear(),this.edgeIdCounter.clear()}}const Nt=["id","x","y","z","vx","vy","vz","fx","fy","fz","parentId"],_t=["id","source","target","points"];function kt(t,e,r,n=2){t.forEachNode(t=>{E(t.x)&&(t.x=Math.random()*e),E(t.y)&&(t.y=Math.random()*r),3===n&&E(t.z)&&(t.z=Math.random()*Math.min(e,r))})}class St{constructor(t,e={}){this.graph=new Mt(t,e)}export(){return this.graph.data()}replace(t){this.graph.replace(t)}forEachNode(t){this.graph.forEachNode(t)}forEachEdge(t){this.graph.forEachEdge((e,r)=>{e.sourceNode=this.graph.node(e.source),e.targetNode=this.graph.node(e.target),t(e,r)})}destroy(){this.graph.destroy()}}class At{constructor(){this.worker=null,this.workerApi=null}execute(e,r,n){return t(this,void 0,void 0,function*(){if(this.worker||(yield this.initWorker()),!this.workerApi)throw new Error("Worker API not initialized");return yield this.workerApi.execute(e,r,n)})}destroy(){this.workerApi&&this.workerApi.destroy(),this.worker&&(this.worker.terminate(),this.worker=null,this.workerApi=null)}initWorker(){return t(this,void 0,void 0,function*(){const t=this.resolveWorkerPath(),e=t.includes("/lib/")||t.endsWith(".mjs")?"module":"classic";this.worker=new Worker(t,{type:e}),this.workerApi=h(this.worker)})}resolveWorkerPath(){const t=(()=>{if("undefined"==typeof document)return null;const t=document.currentScript;if(null==t?void 0:t.src)return t.src;const e=document.getElementsByTagName("script");for(let t=e.length-1;t>=0;t--){const r=e[t].src;if(r&&(r.includes("index.js")||r.includes("index.min.js")))return r}return null})();if(t){if(t.includes("index.js")||t.includes("index.min.js")){const e=t.replace(/index(\.min)?\.(m?js)(\?.*)?$/,"worker.js");if(e!==t)return e}const e=t.replace(/\/runtime\/[^/]+\.(m?js)(\?.*)?$/,"/worker.js");if(e!==t)return e;const r=t.replace(/\/[^/]+\.(m?js)(\?.*)?$/,"/worker.js");if(r!==t)return r}return"./worker.js"}}class Ot{constructor(t){this.supervisor=null,this.initialOptions=this.mergeOptions(this.getDefaultOptions(),t)}get options(){return this.runtimeOptions||this.initialOptions}mergeOptions(t,e){return Object.assign({},t,e||{})}execute(e,r){return t(this,void 0,void 0,function*(){this.runtimeOptions=this.mergeOptions(this.initialOptions,r);const{node:t,edge:n,enableWorker:o}=this.runtimeOptions;this.context=new St(e,{node:t,edge:n}),this.model=this.context.graph;o&&"undefined"!=typeof Worker?yield this.layoutInWorker(e,this.runtimeOptions):yield this.layout(this.runtimeOptions)})}layoutInWorker(e,r){var n;return t(this,void 0,void 0,function*(){try{this.supervisor||(this.supervisor=new At);const t=yield this.supervisor.execute(this.id,e,r);null===(n=this.context)||void 0===n||n.replace(t)}catch(t){console.error("Layout in worker failed, fallback to main thread layout.",t),yield this.layout(r)}})}forEachNode(t){this.context.forEachNode(t)}forEachEdge(t){this.context.forEachEdge(t)}destroy(){var t;null===(t=this.context)||void 0===t||t.destroy(),this.model=null,this.context=null,this.supervisor&&(this.supervisor.destroy(),this.supervisor=null)}}class zt extends Ot{}class jt{constructor(t={}){this.options=t,this.nodes=new Map,this.edges=new Map,this.inEdges=new Map,this.outEdges=new Map,this.parentMap=new Map,this.childrenMap=new Map,t.tree&&Array.isArray(t.tree)&&t.tree.length>0&&("string"==typeof t.tree[0]?t.tree.forEach(t=>{this.parentMap.set(t,new Map),this.childrenMap.set(t,new Map)}):(this.attachTreeStructure("default"),this.addTree(t.tree))),t.nodes&&t.nodes.forEach(t=>this.addNode(t)),t.edges&&t.edges.forEach(t=>this.addEdge(t))}addNode(t){this.nodes.has(t.id)||(this.nodes.set(t.id,t),this.inEdges.set(t.id,new Set),this.outEdges.set(t.id,new Set))}addNodes(t){t.forEach(t=>this.addNode(t))}getNode(t){return this.nodes.get(t)}hasNode(t){return this.nodes.has(t)}removeNode(t){if(!this.nodes.has(t))return;const e=Array.from(this.inEdges.get(t)||[]),r=Array.from(this.outEdges.get(t)||[]);e.forEach(t=>this.removeEdge(t)),r.forEach(t=>this.removeEdge(t)),this.nodes.delete(t),this.inEdges.delete(t),this.outEdges.delete(t),this.parentMap.forEach(e=>{e.delete(t)}),this.childrenMap.forEach(e=>{e.delete(t)})}getAllNodes(){return Array.from(this.nodes.values())}addEdge(t){if(!this.nodes.has(t.source)||!this.nodes.has(t.target))throw new Error(`Cannot add edge ${t.id}: source ${t.source} or target ${t.target} does not exist`);this.edges.set(t.id,t),this.outEdges.get(t.source).add(t.id),this.inEdges.get(t.target).add(t.id)}addEdges(t){t.forEach(t=>this.addEdge(t))}getEdge(t){return this.edges.get(t)}hasEdge(t){return this.edges.has(t)}removeEdge(t){var e,r;const n=this.edges.get(t);n&&(this.edges.delete(t),null===(e=this.outEdges.get(n.source))||void 0===e||e.delete(t),null===(r=this.inEdges.get(n.target))||void 0===r||r.delete(t))}getAllEdges(){return Array.from(this.edges.values())}updateEdgeData(t,e){const r=this.edges.get(t);r&&Object.assign(r.data,e)}updateNodeData(t,e){const r=this.nodes.get(t);r&&Object.assign(r.data,e)}getRelatedEdges(t,e="both"){const r=[];if("in"===e||"both"===e){const e=this.inEdges.get(t);e&&e.forEach(t=>{const e=this.edges.get(t);e&&r.push(e)})}if("out"===e||"both"===e){const e=this.outEdges.get(t);e&&e.forEach(t=>{const e=this.edges.get(t);e&&r.push(e)})}return r}getSuccessors(t){const e=this.outEdges.get(t);if(!e||0===e.size)return[];const r=[];return e.forEach(t=>{const e=this.edges.get(t);if(e){const t=this.nodes.get(e.target);t&&r.push(t)}}),r.length>0?r:[]}getPredecessors(t){const e=this.inEdges.get(t);if(!e||0===e.size)return[];const r=[];return e.forEach(t=>{const e=this.edges.get(t);if(e){const t=this.nodes.get(e.source);t&&r.push(t)}}),r.length>0?r:[]}getNeighbors(t){const e=[...this.getSuccessors(t)||[],...this.getPredecessors(t)||[]],r=Array.from(new Map(e.map(t=>[t.id,t])).values());return r.length>0?r:[]}attachTreeStructure(t){this.parentMap.has(t)||(this.parentMap.set(t,new Map),this.childrenMap.set(t,new Map))}addTree(t,e){var r,n;const o=e||(null!==(n=null===(r=this.options.tree)||void 0===r?void 0:r[0])&&void 0!==n?n:"default");this.hasTreeStructure(o)||this.attachTreeStructure(o);const i=Array.isArray(t)?t:[t],s=(t,e)=>{this.addNode({id:t.id,data:t.data}),void 0!==e&&this.setParent(t.id,e,o),t.children&&t.children.length>0&&t.children.forEach(e=>{s(e,t.id)})};i.forEach(t=>s(t))}hasTreeStructure(t){return this.parentMap.has(t)}setParent(t,e,r){var n,o,i;const s=r||(null!==(o=null===(n=this.options.tree)||void 0===n?void 0:n[0])&&void 0!==o?o:"default");this.parentMap.has(s)||this.attachTreeStructure(s);const a=this.parentMap.get(s),u=this.childrenMap.get(s),c=a.get(t);void 0!==c&&(null===(i=u.get(c))||void 0===i||i.delete(t)),a.set(t,e),u.has(e)||u.set(e,new Set),u.get(e).add(t)}getParent(t,e){var r,n;const o=e||(null!==(n=null===(r=this.options.tree)||void 0===r?void 0:r[0])&&void 0!==n?n:"default");this.parentMap.has(o)||this.attachTreeStructure(o);const i=this.parentMap.get(o);if(!i)return;const s=i.get(t);return void 0===s?null:this.nodes.get(s)}getChildren(t,e){var r,n;const o=e||(null!==(n=null===(r=this.options.tree)||void 0===r?void 0:r[0])&&void 0!==n?n:"default"),i=this.childrenMap.get(o);if(!i)return[];const s=i.get(t);return s?Array.from(s).map(t=>this.nodes.get(t)).filter(t=>void 0!==t):[]}getRoots(t){var e,r;const n=t||(null!==(r=null===(e=this.options.tree)||void 0===e?void 0:e[0])&&void 0!==r?r:"default"),o=this.parentMap.get(n),i=[];return this.nodes.forEach(t=>{o&&void 0!==o.get(t.id)||i.push(t)}),i}dfsTree(t,e){const r=[t],n=new Set;for(;r.length>0;){const t=r.pop();if(n.has(t))continue;const o=this.getNode(t);if(o){n.add(t);if(!0===e(o))continue;const i=this.getChildren(t);for(let t=i.length-1;t>=0;t--)n.has(i[t].id)||r.push(i[t].id)}}}}const Ct=(t,e)=>{if("next"!==t&&"prev"!==t)return e},It=t=>{t.prev.next=t.next,t.next.prev=t.prev,delete t.next,delete t.prev};let Rt=class{constructor(){const t={};t.prev=t,t.next=t.prev,this.shortcut=t}dequeue(){const t=this.shortcut,e=t.prev;if(e&&e!==t)return It(e),e}enqueue(t){const e=this.shortcut;t.prev&&t.next&&It(t),t.next=e.next,e.next.prev=t,e.next=t,t.prev=e}toString(){const t=[],e=this.shortcut;let r=e.prev;for(;r!==e;)t.push(JSON.stringify(r,Ct)),r=null==r?void 0:r.prev;return`[${t.join(", ")}]`}};class Tt extends Rt{}const Pt=()=>1,Ft=(t,e,r)=>{let n=[];const o=e[e.length-1],i=e[0];let s;for(;t.getAllNodes().length;){for(;s=i.dequeue();)Lt(t,e,r,s);for(;s=o.dequeue();)Lt(t,e,r,s);if(t.getAllNodes().length)for(let o=e.length-2;o>0;--o)if(s=e[o].dequeue(),s){n=n.concat(Lt(t,e,r,s,!0));break}}return n},Lt=(t,e,r,n,o)=>{var i,s;const a=[];return t.hasNode(n.v)&&(null===(i=t.getRelatedEdges(n.v,"in"))||void 0===i||i.forEach(n=>{const i=n.data.weight,s=t.getNode(n.source);o&&a.push({v:n.source,w:n.target,in:0,out:0}),void 0===s.data.out&&(s.data.out=0),s.data.out-=i,qt(e,r,Object.assign({v:s.id},s.data))}),null===(s=t.getRelatedEdges(n.v,"out"))||void 0===s||s.forEach(n=>{const o=n.data.weight,i=n.target,s=t.getNode(i);void 0===s.data.in&&(s.data.in=0),s.data.in-=o,qt(e,r,Object.assign({v:s.id},s.data))}),t.removeNode(n.v)),o?a:void 0},Dt=(t,e)=>{const r=new jt;let n=0,o=0;t.getAllNodes().forEach(t=>{r.addNode({id:t.id,data:{v:t.id,in:0,out:0}})}),t.getAllEdges().forEach(t=>{const i=r.getRelatedEdges(t.source,"out").find(e=>e.target===t.target),s=(null==e?void 0:e(t))||1;i?r.updateEdgeData(null==i?void 0:i.id,Object.assign(Object.assign({},i.data),{weight:i.data.weight+s})):r.addEdge({id:t.id,source:t.source,target:t.target,data:{weight:s}}),o=Math.max(o,r.getNode(t.source).data.out+=s),n=Math.max(n,r.getNode(t.target).data.in+=s)});const i=[],s=o+n+3;for(let t=0;t<s;t++)i.push(new Tt);const a=n+1;return r.getAllNodes().forEach(t=>{qt(i,a,Object.assign({v:t.id},r.getNode(t.id).data))}),{buckets:i,zeroIdx:a,graph:r}},qt=(t,e,r)=>{r.out?r.in?t[r.out-r.in+e].enqueue(r):t[t.length-1].enqueue(r):t[0].enqueue(r)},Bt=(t,e)=>{const r=((t,e)=>{var r;if(t.getAllNodes().length<=1)return[];const n=Dt(t,e||Pt);return null===(r=Ft(n.graph,n.buckets,n.zeroIdx).map(e=>t.getRelatedEdges(e.v,"out").filter(({target:t})=>t===e.w)))||void 0===r?void 0:r.flat()})(t,t=>t.data.weight||1);null==r||r.forEach(e=>{const r=e.data;t.removeEdge(e.id),r.forwardName=e.data.name,r.reversed=!0,t.addEdge({id:e.id,source:e.target,target:e.source,data:Object.assign({},r)})})},Vt=(t,e,r,n)=>{let o;do{o=`${n}${Math.random()}`}while(t.hasNode(o));return r.dummy=e,t.addNode({id:o,data:r}),o},$t=t=>{const e=new jt;return t.getAllNodes().forEach(r=>{t.getChildren(r.id).length||e.addNode(Object.assign({},r))}),t.getAllEdges().forEach(t=>{e.addEdge(t)}),e},Ut=(t,e)=>{const r=Number(t.x),n=Number(t.y),o=Number(e.x)-r,i=Number(e.y)-n;let s,a,u=Number(t.width)/2,c=Number(t.height)/2;return o||i?(Math.abs(i)*u>Math.abs(o)*c?(i<0&&(c=-c),s=c*o/i,a=c):(o<0&&(u=-u),s=u,a=u*i/o),{x:r+s,y:n+a}):{x:0,y:0}},Gt=t=>{const e=[],r=Yt(t)+1;for(let t=0;t<r;t++)e.push([]);t.getAllNodes().forEach(t=>{const r=t.data.rank;void 0!==r&&e[r]&&e[r].push(t.id)});for(let n=0;n<r;n++)e[n]=e[n].sort((e,r)=>{return n=t.getNode(e).data.order,o=t.getNode(r).data.order,Number(n)-Number(o);var n,o});return e},Wt=(t,e,r,n)=>{const o={width:0,height:0};return A(r)&&A(n)&&(o.rank=r,o.order=n),Vt(t,"border",o,e)},Yt=t=>{let e;return t.getAllNodes().forEach(t=>{const r=t.data.rank;void 0!==r&&(void 0===e||r>e)&&(e=r)}),e||(e=0),e},Ht=(t,e)=>t.reduce((t,r)=>e(t)>e(r)?r:t),Xt=(t,e,r,n,o,i)=>{if(!n.includes(e.id)){n.push(e.id),r||i.push(e.id);const s=o(e.id);s&&s.forEach(e=>Xt(t,e,r,n,o,i)),r&&i.push(e.id)}},Qt=(t,e,r,n)=>{const o=Array.isArray(e)?e:[e],i=e=>t.getNeighbors(e),s=[],a=[];return o.forEach(e=>{if(!t.hasNode(e.id))throw new Error(`Graph does not have node: ${e}`);Xt(t,e,"post"===r,a,i,s)}),s},Kt=(t,e,r,n,o,i)=>{const s={rank:i,borderType:e,width:0,height:0},a=i-o.data.minRank,u=o.data[e][a-1],c=Vt(t,"border",s,r);o.data[e][a]=c,t.setParent(c,n),u&&t.addEdge({id:`e${Math.random()}`,source:u,target:c,data:{weight:1}})},Jt=t=>{t.getAllNodes().forEach(t=>{Zt(t)}),t.getAllEdges().forEach(t=>{Zt(t)})},Zt=t=>{const e=t.data.width;t.data.width=t.data.height,t.data.height=e},te=t=>{t.getAllNodes().forEach(t=>{ee(t.data)}),t.getAllEdges().forEach(t=>{var e;null===(e=t.data.points)||void 0===e||e.forEach(t=>ee(t)),t.data.hasOwnProperty("y")&&ee(t.data)})},ee=t=>{(null==t?void 0:t.y)&&(t.y=-t.y)},re=t=>{t.getAllNodes().forEach(t=>{ne(t.data)}),t.getAllEdges().forEach(t=>{var e;null===(e=t.data.points)||void 0===e||e.forEach(t=>ne(t)),t.data.hasOwnProperty("x")&&ne(t.data)})},ne=t=>{const e=t.x;t.x=t.y,t.y=e},oe=(t,e,r,n,o,i,s)=>{const a=t.getChildren(s);if(!(null==a?void 0:a.length))return void(s!==e&&t.addEdge({id:`e${Math.random()}`,source:e,target:s,data:{weight:0,minlen:r}}));const u=Wt(t,"_bt"),c=Wt(t,"_bb"),h=t.getNode(s);t.setParent(u,s),h.data.borderTop=u,t.setParent(c,s),h.data.borderBottom=c,null==a||a.forEach(a=>{oe(t,e,r,n,o,i,a.id);const h=a.data.borderTop?a.data.borderTop:a.id,l=a.data.borderBottom?a.data.borderBottom:a.id,d=a.data.borderTop?n:2*n,f=h!==l?1:o-i[s]+1;t.addEdge({id:`e${Math.random()}`,source:u,target:h,data:{minlen:f,weight:d,nestingEdge:!0}}),t.addEdge({id:`e${Math.random()}`,source:l,target:c,data:{minlen:f,weight:d,nestingEdge:!0}})}),t.getParent(s)||t.addEdge({id:`e${Math.random()}`,source:e,target:u,data:{weight:0,minlen:o+i[s]}})},ie=t=>{const e={},r=(n,o)=>{const i=t.getChildren(n);null==i||i.forEach(t=>r(t.id,o+1)),e[n]=o};return t.getRoots().forEach(t=>r(t.id,1)),e},se=t=>{let e=0;return t.getAllEdges().forEach(t=>{e+=t.data.weight}),e},ae="edge-label",ue=(t,e,r)=>{let n=e.source,o=t.getNode(n).data.rank;const i=e.target,s=t.getNode(i).data.rank,a=e.data.labelRank;if(s===o+1)return;let u,c,h;for(t.removeEdge(e.id),h=0,++o;o<s;++h,++o)e.data.points=[],c={originalEdge:e,width:0,height:0,rank:o},u=Vt(t,"edge",c,"_d"),o===a&&(c.width=e.data.width,c.height=e.data.height,c.dummy=ae,c.labelpos=e.data.labelpos),t.addEdge({id:`e${Math.random()}`,source:n,target:u,data:{weight:e.data.weight}}),0===h&&r.push(u),n=u;t.addEdge({id:`e${Math.random()}`,source:n,target:i,data:{weight:e.data.weight}})},ce=t=>{let e;for(;t.hasNode(e=`_root${Math.random()}`););return e},he=(t,e,r)=>{const n=(o=r,i=r.map((t,e)=>e),null==o?void 0:o.reduce((t,e,r)=>(t[e]=i[r],t),{}));var o,i;const s=e.map(e=>{const r=t.getRelatedEdges(e,"out").map(t=>({pos:n[t.target]||0,weight:t.data.weight}));return null==r?void 0:r.sort((t,e)=>t.pos-e.pos)}),a=s.flat().filter(t=>void 0!==t);let u=1;for(;u<r.length;)u<<=1;const c=2*u-1;u-=1;const h=Array(c).fill(0,0,c);let l=0;return null==a||a.forEach(t=>{if(t){let e=t.pos+u;h[e]+=t.weight;let r=0;for(;e>0;)e%2&&(r+=h[e+1]),e=e-1>>1,h[e]+=t.weight;l+=t.weight*r}}),l},le=(t,e)=>{let r=0;for(let n=1;n<(null==e?void 0:e.length);n+=1)r+=he(t,e[n-1],e[n]);return r},de=t=>{const e={},r=t.getAllNodes(),n=r.map(t=>{var e;return null!==(e=t.data.rank)&&void 0!==e?e:-1/0}),o=Math.max(...n),i=[];for(let t=0;t<o+1;t++)i.push([]);const s=r.sort((e,r)=>t.getNode(e.id).data.rank-t.getNode(r.id).data.rank),a=s.filter(e=>void 0!==t.getNode(e.id).data.fixorder),u=a.sort((e,r)=>t.getNode(e.id).data.fixorder-t.getNode(r.id).data.fixorder);return null==u||u.forEach(r=>{isNaN(t.getNode(r.id).data.rank)||i[t.getNode(r.id).data.rank].push(r.id),e[r.id]=!0}),null==s||s.forEach(r=>t.dfsTree(r.id,t=>{if(e.hasOwnProperty(t.id))return!0;e[t.id]=!0,isNaN(t.data.rank)||i[t.data.rank].push(t.id)})),i},fe=t=>{var e,r;const n=[];for(;null==t?void 0:t.length;){const o=t.pop();n.push(o),null===(e=o.in.reverse())||void 0===e||e.forEach(t=>{return(e=o,t=>{t.merged||(void 0===t.barycenter||void 0===e.barycenter||t.barycenter>=e.barycenter)&&ge(e,t)})(t);var e}),null===(r=o.out)||void 0===r||r.forEach(e=>{return(r=o,e=>{e.in.push(r),0===--e.indegree&&t.push(e)})(e);var r})}const o=n.filter(t=>!t.merged),i=["vs","i","barycenter","weight"];return o.map(t=>{const e={};return null==i||i.forEach(r=>{void 0!==t[r]&&(e[r]=t[r])}),e})},ge=(t,e)=>{var r;let n=0,o=0;t.weight&&(n+=t.barycenter*t.weight,o+=t.weight),e.weight&&(n+=e.barycenter*e.weight,o+=e.weight),t.vs=null===(r=e.vs)||void 0===r?void 0:r.concat(t.vs),t.barycenter=n/o,t.weight=o,t.i=Math.min(e.i,t.i),e.merged=!0},pe=(t,e,r)=>{let n,o=r;for(;e.length&&(n=e[e.length-1]).i<=o;)e.pop(),null==t||t.push(n.vs),o++;return o},ve=(t,e)=>(r,n)=>{if(void 0!==r.fixorder&&void 0!==n.fixorder)return r.fixorder-n.fixorder;if(r.barycenter<n.barycenter)return-1;if(r.barycenter>n.barycenter)return 1;if(e&&void 0!==r.order&&void 0!==n.order){if(r.order<n.order)return-1;if(r.order>n.order)return 1}return t?n.i-r.i:r.i-n.i},me=(t,e,r,n,o,i)=>{var s,a,u,c;let h=t.getChildren(e).map(t=>t.id);const l=t.getNode(e),d=l?l.data.borderLeft:void 0,f=l?l.data.borderRight:void 0,g={};d&&(h=null==h?void 0:h.filter(t=>t!==d&&t!==f));const p=((t,e)=>e.map(e=>{const r=t.getRelatedEdges(e,"in");if(!(null==r?void 0:r.length))return{v:e};const n={sum:0,weight:0};return null==r||r.forEach(e=>{const r=t.getNode(e.source);n.sum+=e.data.weight*r.data.order,n.weight+=e.data.weight}),{v:e,barycenter:n.sum/n.weight,weight:n.weight}}))(t,h||[]);null==p||p.forEach(e=>{var o;if(null===(o=t.getChildren(e.v))||void 0===o?void 0:o.length){const o=me(t,e.v,r,n,i);g[e.v]=o,o.hasOwnProperty("barycenter")&&we(e,o)}});const v=((t,e)=>{var r,n,o;const i={};null==t||t.forEach((t,e)=>{i[t.v]={i:e,indegree:0,in:[],out:[],vs:[t.v]};const r=i[t.v];void 0!==t.barycenter&&(r.barycenter=t.barycenter,r.weight=t.weight)}),null===(r=e.getAllEdges())||void 0===r||r.forEach(t=>{const e=i[t.source],r=i[t.target];void 0!==e&&void 0!==r&&(r.indegree++,e.out.push(i[t.target]))});const s=null===(o=(n=Object.values(i)).filter)||void 0===o?void 0:o.call(n,t=>!t.indegree);return fe(s)})(p,r);ye(v,g),null===(s=v.filter(t=>t.vs.length>0))||void 0===s||s.forEach(e=>{const r=t.getNode(e.vs[0]);r&&(e.fixorder=r.data.fixorder,e.order=r.data.order)});const m=((t,e,r,n)=>{const o=((t,e)=>{const r={lhs:[],rhs:[]};return null==t||t.forEach(t=>{e(t)?r.lhs.push(t):r.rhs.push(t)}),r})(t,t=>{const e=t.hasOwnProperty("fixorder")&&!isNaN(t.fixorder);return n?!e&&t.hasOwnProperty("barycenter"):e||t.hasOwnProperty("barycenter")}),i=o.lhs,s=o.rhs.sort((t,e)=>-t.i- -e.i),a=[];let u=0,c=0,h=0;null==i||i.sort(ve(!!e,!!r)),h=pe(a,s,h),null==i||i.forEach(t=>{var e;h+=null===(e=t.vs)||void 0===e?void 0:e.length,a.push(t.vs),u+=t.barycenter*t.weight,c+=t.weight,h=pe(a,s,h)});const l={vs:a.flat()};return c&&(l.barycenter=u/c,l.weight=c),l})(v,n,o,i);if(d&&(m.vs=[d,m.vs,f].flat(),null===(a=t.getPredecessors(d))||void 0===a?void 0:a.length)){const e=t.getNode((null===(u=t.getPredecessors(d))||void 0===u?void 0:u[0].id)||""),r=t.getNode((null===(c=t.getPredecessors(f))||void 0===c?void 0:c[0].id)||"");m.hasOwnProperty("barycenter")||(m.barycenter=0,m.weight=0),m.barycenter=(m.barycenter*m.weight+e.data.order+r.data.order)/(m.weight+2),m.weight+=2}return m},ye=(t,e)=>{null==t||t.forEach(t=>{var r;const n=null===(r=t.vs)||void 0===r?void 0:r.map(t=>e[t]?e[t].vs:t);t.vs=n.flat()})},we=(t,e)=>{void 0!==t.barycenter?(t.barycenter=(t.barycenter*t.weight+e.barycenter*e.weight)/(t.weight+e.weight),t.weight+=e.weight):(t.barycenter=e.barycenter,t.weight=e.weight)},xe=(t,e,r)=>e.map(e=>((t,e,r)=>{const n=ce(t),o=new jt;return o.addNode({id:n,data:{}}),t.getAllNodes().forEach(i=>{var s,a;const u=t.getParent(i.id);(i.data.rank===e||i.data.minRank<=e&&e<=i.data.maxRank)&&(o.hasNode(i.id)||o.addNode(Object.assign({},i)),(null==u?void 0:u.id)&&!o.hasNode(null==u?void 0:u.id)&&o.addNode(Object.assign({},u)),o.setParent(i.id,(null==u?void 0:u.id)||n),t.getRelatedEdges(i.id,r).forEach(e=>{const r=e.source===i.id?e.target:e.source;o.hasNode(r)||o.addNode(Object.assign({},t.getNode(r)));const n=o.getRelatedEdges(r,"out").find(({target:t})=>t===i.id),s=void 0!==n?n.data.weight:0;n?o.updateEdgeData(n.id,Object.assign(Object.assign({},n.data),{weight:e.data.weight+s})):o.addEdge({id:e.id,source:r,target:i.id,data:{weight:e.data.weight+s}})}),i.data.hasOwnProperty("minRank")&&o.updateNodeData(i.id,Object.assign(Object.assign({},i.data),{borderLeft:[null===(s=i.data.borderLeft)||void 0===s?void 0:s[e-i.data.minRank]],borderRight:[null===(a=i.data.borderRight)||void 0===a?void 0:a[e-i.data.minRank]]})))}),o})(t,e,r)),be=(t,e,r,n)=>{const o=new jt;null==t||t.forEach(t=>{var i;const s=t.getRoots()[0].id,a=me(t,s,o,e,r,n);for(let e=0;e<(null===(i=a.vs)||void 0===i?void 0:i.length);e++){const r=t.getNode(a.vs[e]);r&&(r.data.order=e)}((t,e,r)=>{const n={};let o;null==r||r.forEach(r=>{let i,s,a=t.getParent(r);for(;a;){if(i=t.getParent(a.id),i?(s=n[i.id],n[i.id]=a.id):(s=o,o=a.id),s&&s!==a.id)return e.hasNode(s)||e.addNode({id:s,data:{}}),e.hasNode(a.id)||e.addNode({id:a.id,data:{}}),void(e.hasEdge(`e${s}-${a.id}`)||e.addEdge({id:`e${s}-${a.id}`,source:s,target:a.id,data:{}}));a=i}})})(t,o,a.vs)})},Ee=(t,e)=>{null==e||e.forEach(e=>{null==e||e.forEach((e,r)=>{t.getNode(e).data.order=r})})},Me=(t,e)=>{const r=(t=>{const e={};let r=0;const n=o=>{const i=r;t.getChildren(o).forEach(t=>n(t.id)),e[o]={low:i,lim:r++}};return t.getRoots().forEach(t=>n(t.id)),e})(t);e.forEach(e=>{var n,o;let i=e,s=t.getNode(i);const a=s.data.originalEdge;if(!a)return;const u=((t,e,r,n)=>{var o,i;const s=[],a=[],u=Math.min(e[r].low,e[n].low),c=Math.max(e[r].lim,e[n].lim);let h,l;h=r;do{h=null===(o=t.getParent(h))||void 0===o?void 0:o.id,s.push(h)}while(h&&(e[h].low>u||c>e[h].lim));for(l=h,h=n;h&&h!==l;)a.push(h),h=null===(i=t.getParent(h))||void 0===i?void 0:i.id;return{lca:l,path:s.concat(a.reverse())}})(t,r,a.source,a.target),c=u.path,h=u.lca;let l=0,d=c[l],f=!0;for(;i!==a.target;){if(s=t.getNode(i),f){for(;d!==h&&(null===(n=t.getNode(d))||void 0===n?void 0:n.data.maxRank)<s.data.rank;)l++,d=c[l];d===h&&(f=!1)}if(!f){for(;l<c.length-1&&(null===(o=t.getNode(c[l+1]))||void 0===o?void 0:o.data.minRank)<=s.data.rank;)l++;d=c[l]}t.hasNode(d)&&t.setParent(i,d),i=t.getSuccessors(i)[0].id}})},Ne=(t,e)=>{const r={};function n(e,n){const o=function(t){return JSON.stringify(t.slice(1))}(e);n.get(o)||(!function(e,n,o,i,s){var a,u;let c;for(let h=n;h<o;h++)c=e[h],(null===(a=t.getNode(c))||void 0===a?void 0:a.data.dummy)&&(null===(u=t.getPredecessors(c))||void 0===u||u.forEach(e=>{const n=t.getNode(e.id);n.data.dummy&&(n.data.order<i||n.data.order>s)&&ke(r,e.id,c)}))}(...e),n.set(o,!0))}const o=(e,r)=>{let o,i=-1,s=0;const a=new Map;return null==r||r.forEach((u,c)=>{var h;if("border"===(null===(h=t.getNode(u))||void 0===h?void 0:h.data.dummy)){const e=t.getPredecessors(u)||[];e.length&&(o=t.getNode(e[0].id).data.order,n([r,s,c,i,o],a),s=c,i=o)}n([r,s,r.length,o,e.length],a)}),r};return(null==e?void 0:e.length)&&e.reduce(o),r},_e=(t,e)=>{var r,n;if(null===(r=t.getNode(e))||void 0===r?void 0:r.data.dummy)return null===(n=t.getPredecessors(e))||void 0===n?void 0:n.find(e=>t.getNode(e.id).data.dummy)},ke=(t,e,r)=>{let n=e,o=r;if(n>o){const t=n;n=o,o=t}let i=t[n];i||(t[n]=i={}),i[o]=!0},Se=(t,e,r)=>{let n=e,o=r;if(n>r){n=r,o=e}return!!t[n]},Ae=(t,e,r,n,o,i)=>{const s=new jt,a=Oe(n,o,i);return null==e||e.forEach(e=>{let n;null==e||e.forEach(e=>{const o=r[e];if(s.hasNode(o)||s.addNode({id:o,data:{}}),n){const i=r[n],u=s.getRelatedEdges(i,"out").find(t=>t.target===o);u?s.updateEdgeData(u.id,Object.assign(Object.assign({},u.data),{weight:Math.max(a(t,e,n),u.data.weight||0)})):s.addEdge({id:`e${Math.random()}`,source:i,target:o,data:{weight:Math.max(a(t,e,n),0)}})}n=e})}),s};const Oe=(t,e,r)=>(n,o,i)=>{const s=n.getNode(o),a=n.getNode(i);let u=0,c=0;if(u+=s.data.width/2,s.data.hasOwnProperty("labelpos"))switch((s.data.labelpos||"").toLowerCase()){case"l":c=-s.data.width/2;break;case"r":c=s.data.width/2}if(c&&(u+=r?c:-c),c=0,u+=(s.data.dummy?e:t)/2,u+=(a.data.dummy?e:t)/2,u+=a.data.width/2,a.data.labelpos)switch((a.data.labelpos||"").toLowerCase()){case"l":c=a.data.width/2;break;case"r":c=-a.data.width/2}return c&&(u+=r?c:-c),c=0,u},ze=(t,e)=>t.getNode(e).data.width||0,je=(t,e)=>{const{align:r,nodesep:n=0,edgesep:o=0}=e||{},i=Gt(t),s=Object.assign(((t,e)=>{const r={},n=(e,n)=>{let o=0,i=0;const s=e.length,a=null==n?void 0:n[(null==n?void 0:n.length)-1];return null==n||n.forEach((e,u)=>{var c;const h=_e(t,e),l=h?t.getNode(h.id).data.order:s;(h||e===a)&&(null===(c=n.slice(i,u+1))||void 0===c||c.forEach(e=>{var n;null===(n=t.getPredecessors(e))||void 0===n||n.forEach(n=>{var i;const s=t.getNode(n.id),a=s.data.order;!(a<o||l<a)||s.data.dummy&&(null===(i=t.getNode(e))||void 0===i?void 0:i.data.dummy)||ke(r,n.id,e)})}),i=u+1,o=l)}),n};return(null==e?void 0:e.length)&&e.reduce(n),r})(t,i),Ne(t,i)),a={};let u=[];["u","d"].forEach(e=>{u="u"===e?i:Object.values(i).reverse(),["l","r"].forEach(r=>{"r"===r&&(u=u.map(t=>Object.values(t).reverse()));const i=("u"===e?t.getPredecessors:t.getSuccessors).bind(t),c=((t,e,r,n)=>{const o={},i={},s={};return null==e||e.forEach(t=>{null==t||t.forEach((t,e)=>{o[t]=t,i[t]=t,s[t]=e})}),null==e||e.forEach(t=>{let e=-1;null==t||t.forEach(t=>{let a=n(t).map(t=>t.id);if(a.length){a=a.sort((t,e)=>s[t]-s[e]);const n=(a.length-1)/2;for(let u=Math.floor(n),c=Math.ceil(n);u<=c;++u){const n=a[u];i[t]===t&&e<s[n]&&!Se(r,t,n)&&(i[n]=t,i[t]=o[t]=o[n],e=s[n])}}})}),{root:o,align:i}})(0,u,s,i),h=((t,e,r,n,o,i,s)=>{var a;const u={},c=Ae(t,e,r,o,i,s),h=s?"borderLeft":"borderRight",l=(t,e)=>{let r=c.getAllNodes(),n=r.pop();const o={};for(;n;)o[n.id]?t(n.id):(o[n.id]=!0,r.push(n),r=r.concat(e(n.id))),n=r.pop()};return l(t=>{u[t]=(c.getRelatedEdges(t,"in")||[]).reduce((t,e)=>Math.max(t,(u[e.source]||0)+e.data.weight),0)},c.getPredecessors.bind(c)),l(e=>{const r=(c.getRelatedEdges(e,"out")||[]).reduce((t,e)=>Math.min(t,(u[e.target]||0)-e.data.weight),Number.POSITIVE_INFINITY),n=t.getNode(e);r!==Number.POSITIVE_INFINITY&&n.data.borderType!==h&&(u[e]=Math.max(u[e],r))},c.getSuccessors.bind(c)),null===(a=Object.values(n))||void 0===a||a.forEach(t=>{u[t]=u[r[t]]}),u})(t,u,c.root,c.align,n,o,"r"===r);"r"===r&&Object.keys(h).forEach(t=>h[t]=-h[t]),a[e+r]=h})});const c=((t,e)=>Ht(Object.values(e),e=>{var r;let n=Number.NEGATIVE_INFINITY,o=Number.POSITIVE_INFINITY;return null===(r=Object.keys(e))||void 0===r||r.forEach(r=>{const i=e[r],s=ze(t,r)/2;n=Math.max(i+s,n),o=Math.min(i-s,o)}),n-o}))(t,a);return c&&function(t,e){const r=Object.values(e),n=Math.min(...r),o=Math.max(...r);["u","d"].forEach(r=>{["l","r"].forEach(i=>{const s=r+i,a=t[s];let u;if(a===e)return;const c=Object.values(a);u="l"===i?n-Math.min(...c):o-Math.max(...c),u&&(t[s]={},Object.keys(a).forEach(e=>{t[s][e]=a[e]+u}))})})}(a,c),((t,e)=>{const r={};return Object.keys(t.ul).forEach(n=>{if(e)r[n]=t[e.toLowerCase()][n];else{const e=Object.values(t).map(t=>t[n]);r[n]=(e[0]+e[1])/2}}),r})(a,r)},Ce=(t,e)=>{var r;const n=$t(t);((t,e)=>{const{ranksep:r=0}=e||{},n=Gt(t);let o=0;null==n||n.forEach(e=>{const n=e.map(e=>t.getNode(e).data.height),i=Math.max(...n,0);null==e||e.forEach(e=>{t.getNode(e).data.y=o+i/2}),o+=i+r})})(n,e);const o=je(n,e);null===(r=Object.keys(o))||void 0===r||r.forEach(t=>{n.getNode(t).data.x=o[t]})},Ie=t=>{const e={},r=n=>{var o;const i=t.getNode(n);if(!i)return 0;if(e[n])return i.data.rank;let s;return e[n]=!0,null===(o=t.getRelatedEdges(n,"out"))||void 0===o||o.forEach(t=>{const e=r(t.target)-t.data.minlen;e&&(void 0===s||e<s)&&(s=e)}),s||(s=0),i.data.rank=s,s};t.getAllNodes().filter(e=>0===t.getRelatedEdges(e.id,"in").length).forEach(t=>r(t.id))},Re=(t,e)=>t.getNode(e.target).data.rank-t.getNode(e.source).data.rank-e.data.minlen,Te=(t,e)=>{const r=n=>{e.getRelatedEdges(n,"both").forEach(o=>{const i=o.source,s=n===i?o.target:i;t.hasNode(s)||Re(e,o)||(t.addNode({id:s,data:{}}),t.addEdge({id:o.id,source:n,target:s,data:{}}),r(s))})};return t.getAllNodes().forEach(t=>r(t.id)),t.getAllNodes().length},Pe=(t,e)=>{const r=n=>{var o;null===(o=e.getRelatedEdges(n,"both"))||void 0===o||o.forEach(o=>{const i=o.source,s=n===i?o.target:i;t.hasNode(s)||void 0===e.getNode(s).data.layer&&Re(e,o)||(t.addNode({id:s,data:{}}),t.addEdge({id:o.id,source:n,target:s,data:{}}),r(s))})};return t.getAllNodes().forEach(t=>r(t.id)),t.getAllNodes().length},Fe=(t,e)=>Ht(e.getAllEdges(),r=>t.hasNode(r.source)!==t.hasNode(r.target)?Re(e,r):1/0),Le=(t,e,r)=>{t.getAllNodes().forEach(t=>{const n=e.getNode(t.id);n.data.rank||(n.data.rank=0),n.data.rank+=r})},De=t=>{const e=(t=>{const e=new jt;return t.getAllNodes().forEach(t=>{e.addNode(Object.assign({},t))}),t.getAllEdges().forEach(t=>{const r=e.getRelatedEdges(t.source,"out").find(e=>e.target===t.target);r?e.updateEdgeData(null==r?void 0:r.id,Object.assign(Object.assign({},r.data),{weight:r.data.weight+t.data.weight||0,minlen:Math.max(r.data.minlen,t.data.minlen||1)})):e.addEdge({id:t.id,source:t.source,target:t.target,data:{weight:t.data.weight||0,minlen:t.data.minlen||1}})}),e})(t);Ie(e);const r=(t=>{const e=new jt({tree:[]}),r=t.getAllNodes()[0],n=t.getAllNodes().length;let o,i;for(e.addNode(r);Te(e,t)<n;)o=Fe(e,t),i=e.hasNode(o.source)?Re(t,o):-Re(t,o),Le(e,t,i);return e})(e);let n,o;for($e(r),qe(r,e);n=Ge(r);)o=We(r,e,n),Ye(r,e,n,o)},qe=(t,e)=>{let r=Qt(t,t.getAllNodes(),"post");r=r.slice(0,(null==r?void 0:r.length)-1),r.forEach(r=>{Be(t,e,r)})},Be=(t,e,r)=>{const n=t.getNode(r).data.parent,o=t.getRelatedEdges(r,"both").find(t=>t.target===n||t.source===n);o.data.cutvalue=Ve(t,e,r)},Ve=(t,e,r)=>{const n=t.getNode(r).data.parent;let o=!0,i=e.getRelatedEdges(r,"out").find(t=>t.target===n),s=0;return i||(o=!1,i=e.getRelatedEdges(n,"out").find(t=>t.target===r)),s=i.data.weight,e.getRelatedEdges(r,"both").forEach(e=>{const i=e.source===r,a=i?e.target:e.source;if(a!==n){const n=i===o,u=e.data.weight;if(s+=n?u:-u,Xe(t,r,a)){const e=t.getRelatedEdges(r,"both").find(t=>t.source===a||t.target===a).data.cutvalue;s+=n?-e:e}}}),s},$e=(t,e=t.getAllNodes()[0].id)=>{Ue(t,{},1,e)},Ue=(t,e,r,n,o)=>{var i;const s=r;let a=r;const u=t.getNode(n);return e[n]=!0,null===(i=t.getNeighbors(n))||void 0===i||i.forEach(r=>{e[r.id]||(a=Ue(t,e,a,r.id,n))}),u.data.low=s,u.data.lim=a++,o?u.data.parent=o:delete u.data.parent,a},Ge=t=>t.getAllEdges().find(t=>t.data.cutvalue<0),We=(t,e,r)=>{let n=r.source,o=r.target;e.getRelatedEdges(n,"out").find(t=>t.target===o)||(n=r.target,o=r.source);const i=t.getNode(n),s=t.getNode(o);let a=i,u=!1;i.data.lim>s.data.lim&&(a=s,u=!0);const c=e.getAllEdges().filter(e=>u===Qe(t.getNode(e.source),a)&&u!==Qe(t.getNode(e.target),a));return Ht(c,t=>Re(e,t))},Ye=(t,e,r,n)=>{const o=t.getRelatedEdges(r.source,"both").find(t=>t.source===r.target||t.target===r.target);o&&t.removeEdge(o.id),t.addEdge({id:`e${Math.random()}`,source:n.source,target:n.target,data:{}}),$e(t),qe(t,e),He(t,e)},He=(t,e)=>{const r=t.getAllNodes().find(t=>!t.data.parent);let n=Qt(t,r,"pre");n=n.slice(1),n.forEach(r=>{const n=t.getNode(r).data.parent;let o=e.getRelatedEdges(r,"out").find(t=>t.target===n),i=!1;!o&&e.hasNode(n)&&(o=e.getRelatedEdges(n,"out").find(t=>t.target===r),i=!0),e.getNode(r).data.rank=(e.hasNode(n)&&e.getNode(n).data.rank||0)+(i?null==o?void 0:o.data.minlen:-(null==o?void 0:o.data.minlen))})},Xe=(t,e,r)=>t.getRelatedEdges(e,"both").find(t=>t.source===r||t.target===r),Qe=(t,e)=>e.data.low<=t.data.lim&&t.data.lim<=e.data.lim,Ke=Ie,Je=t=>{(t=>{const e={};let r;const n=o=>{var i;const s=t.getNode(o);if(!s)return 0;if(e[o])return s.data.rank;let a;return e[o]=!0,null===(i=t.getRelatedEdges(o,"out"))||void 0===i||i.forEach(t=>{const e=n(t.target)-t.data.minlen;e&&(void 0===a||e<a)&&(a=e)}),a||(a=0),(void 0===r||a<r)&&(r=a),s.data.rank=a,a};t.getAllNodes().filter(e=>0===t.getRelatedEdges(e.id,"in").length).forEach(t=>{t&&n(t.id)}),void 0===r&&(r=0);const o={},i=(e,r)=>{var n;const s=t.getNode(e),a=isNaN(s.data.layer)?r:s.data.layer;(void 0===s.data.rank||s.data.rank<a)&&(s.data.rank=a),o[e]||(o[e]=!0,null===(n=t.getRelatedEdges(e,"out"))||void 0===n||n.forEach(t=>{i(t.target,a+t.data.minlen)}))};t.getAllNodes().forEach(t=>{const e=t.data;e&&(isNaN(e.layer)?e.rank-=r:i(t.id,e.layer))})})(t),(t=>{const e=new jt({tree:[]}),r=t.getAllNodes()[0],n=t.getAllNodes().length;let o,i;for(e.addNode(r);Pe(e,t)<n;)o=Fe(e,t),i=e.hasNode(o.source)?Re(t,o):-Re(t,o),Le(e,t,i)})(t)},Ze=t=>{De(t)},tr=(t,e)=>{const{ranker:r,rankdir:n="tb",nodeOrder:o,keepNodeOrder:i,align:s,nodesep:a=50,edgesep:u=20,ranksep:c=50}=e;yr(t),Bt(t);const{nestingRoot:h,nodeRankFactor:l}=(t=>{const e=Vt(t,"root",{},"_root"),r=ie(t);let n=Math.max(...Object.values(r));Math.abs(n)===1/0&&(n=1);const o=n-1,i=2*o+1;t.getAllEdges().forEach(t=>{t.data.minlen*=i});const s=se(t)+1;return t.getRoots().forEach(n=>{oe(t,e,i,s,o,r,n.id)}),{nestingRoot:e,nodeRankFactor:i}})(t);((t,e)=>{switch(e){case"network-simplex":Ze(t);break;case"tight-tree":default:Je(t);break;case"longest-path":Ke(t)}})($t(t),r),hr(t),((t,e=0)=>{const r=t.getAllNodes(),n=r.filter(t=>void 0!==t.data.rank).map(t=>t.data.rank),o=Math.min(...n),i=[];r.forEach(t=>{const e=(t.data.rank||0)-o;i[e]||(i[e]=[]),i[e].push(t.id)});let s=0;for(let r=0;r<i.length;r++){const n=i[r];void 0===n?r%e!==0&&(s-=1):s&&(null==n||n.forEach(e=>{const r=t.getNode(e);r&&(r.data.rank=r.data.rank||0,r.data.rank+=s)}))}})(t,l),((t,e)=>{e&&t.removeNode(e),t.getAllEdges().forEach(e=>{e.data.nestingEdge&&t.removeEdge(e.id)})})(t,h),(t=>{const e=t.getAllNodes().filter(t=>void 0!==t.data.rank).map(t=>t.data.rank),r=Math.min(...e);t.getAllNodes().forEach(t=>{t.data.hasOwnProperty("rank")&&r!==1/0&&(t.data.rank-=r)})})(t),lr(t),dr(t);const d=[];((t,e)=>{t.getAllEdges().forEach(r=>ue(t,r,e))})(t,d),Me(t,d),(t=>{const e=r=>{const n=t.getChildren(r),o=t.getNode(r);if((null==n?void 0:n.length)&&n.forEach(t=>e(t.id)),o.data.hasOwnProperty("minRank")){o.data.borderLeft=[],o.data.borderRight=[];for(let e=o.data.minRank,n=o.data.maxRank+1;e<n;e+=1)Kt(t,"borderLeft","_bl",r,o,e),Kt(t,"borderRight","_br",r,o,e)}};t.getRoots().forEach(t=>e(t.id))})(t),i&&((t,e)=>{const r=t.getAllNodes().filter(e=>{var r;return!(null===(r=t.getChildren(e.id))||void 0===r?void 0:r.length)}).map(t=>t.data.rank),n=Math.max(...r),o=[];for(let t=0;t<n+1;t++)o[t]=[];null==e||e.forEach(e=>{const r=t.getNode(e);r&&!r.data.dummy&&(isNaN(r.data.rank)||(r.data.fixorder=o[r.data.rank].length,o[r.data.rank].push(e)))})})(t,o),((t,e)=>{const r=Yt(t),n=[],o=[];for(let t=1;t<r+1;t++)n.push(t);for(let t=r-1;t>-1;t--)o.push(t);const i=xe(t,n,"in"),s=xe(t,o,"out");let a=de(t);Ee(t,a);let u,c=Number.POSITIVE_INFINITY;for(let r=0,n=0;n<4;++r,++n){be(r%2?i:s,r%4>=2,!1,e),a=Gt(t);const o=le(t,a);o<c&&(n=0,u=j(a),c=o)}a=de(t),Ee(t,a);for(let r=0,n=0;n<4;++r,++n){be(r%2?i:s,r%4>=2,!0,e),a=Gt(t);const o=le(t,a);o<c&&(n=0,u=j(a),c=o)}Ee(t,u)})(t,i),wr(t),((t,e)=>{const r=e.toLowerCase();"lr"!==r&&"rl"!==r||Jt(t)})(t,n),Ce(t,{align:s,nodesep:a,edgesep:u,ranksep:c}),xr(t),mr(t),((t,e)=>{e.forEach(e=>{let r=t.getNode(e);const{data:n}=r,o=n.originalEdge;let i;o&&t.addEdge(o);let s=e;for(;r.data.dummy;)i=t.getSuccessors(s)[0],t.removeNode(s),o.data.points.push({x:r.data.x,y:r.data.y}),r.data.dummy===ae&&(o.data.x=r.data.x,o.data.y=r.data.y,o.data.width=r.data.width,o.data.height=r.data.height),s=i.id,r=t.getNode(s)})})(t,d),pr(t),((t,e)=>{const r=e.toLowerCase();"bt"!==r&&"rl"!==r||te(t),"lr"!==r&&"rl"!==r||(re(t),Jt(t))})(t,n);const{width:f,height:g}=fr(t);return gr(t),vr(t),(t=>{t.getAllEdges().forEach(e=>{const r=e.data;if(r.reversed){t.removeEdge(e.id);const n=r.forwardName;delete r.reversed,delete r.forwardName,t.addEdge({id:e.id,source:e.target,target:e.source,data:Object.assign(Object.assign({},r),{forwardName:n})})}})})(t),{width:f,height:g}},er=(t,e)=>{t.getAllNodes().forEach(r=>{const n=t.getNode(r.id);if(e.hasNode(r.id)){const t=e.getNode(r.id);n.data.fixorder=t.data._order,delete t.data._order}else delete n.data.fixorder})},rr=(t,e)=>{t.getAllNodes().forEach(r=>{var n;const o=t.getNode(r.id);if(o){const t=e.getNode(r.id);o.data.x=t.data.x,o.data.y=t.data.y,o.data._order=t.data.order,o.data._rank=t.data.rank,(null===(n=e.getChildren(r.id))||void 0===n?void 0:n.length)&&(o.data.width=t.data.width,o.data.height=t.data.height)}}),t.getAllEdges().forEach(r=>{const n=t.getEdge(r.id),o=e.getEdge(r.id);n.data.points=o?o.data.points:[],o&&o.data.hasOwnProperty("x")&&(n.data.x=o.data.x,n.data.y=o.data.y)})},nr=["width","height","layer","fixorder"],or={width:0,height:0},ir=["minlen","weight","width","height","labeloffset"],sr={minlen:1,weight:1,width:0,height:0,labeloffset:10,labelpos:"r"},ar=["labelpos"],ur=t=>{const e=new jt({tree:[]});return t.getAllNodes().forEach(r=>{const n=Er(t.getNode(r.id).data),o=Object.assign(Object.assign({},or),n),i=br(o,nr);e.hasNode(r.id)||e.addNode({id:r.id,data:Object.assign({},i)});const s=t.hasTreeStructure("combo")?t.getParent(r.id,"combo"):t.getParent(r.id);E(s)||(e.hasNode(s.id)||e.addNode(Object.assign({},s)),e.setParent(r.id,s.id))}),t.getAllEdges().forEach(r=>{const n=Er(t.getEdge(r.id).data),o={};null==ar||ar.forEach(t=>{void 0!==n[t]&&(o[t]=n[t])}),e.addEdge({id:r.id,source:r.source,target:r.target,data:Object.assign({},sr,br(n,ir),o)})}),e},cr=(t,e)=>{const{ranksep:r=0,rankdir:n}=e;return t.getAllNodes().forEach(t=>{isNaN(t.data.layer)||t.data.layer||(t.data.layer=0)}),t.getAllEdges().forEach(t=>{var e;t.data.minlen*=2,"c"!==(null===(e=t.data.labelpos)||void 0===e?void 0:e.toLowerCase())&&("TB"===n||"BT"===n?t.data.width+=t.data.labeloffset:t.data.height+=t.data.labeloffset)}),r/2},hr=t=>{t.getAllEdges().forEach(e=>{if(e.data.width&&e.data.height){const r=t.getNode(e.source),n={e:e,rank:(t.getNode(e.target).data.rank-r.data.rank)/2+r.data.rank};Vt(t,"edge-proxy",n,"_ep")}})},lr=t=>{let e=0;return t.getAllNodes().forEach(r=>{var n,o;r.data.borderTop&&(r.data.minRank=null===(n=t.getNode(r.data.borderTop))||void 0===n?void 0:n.data.rank,r.data.maxRank=null===(o=t.getNode(r.data.borderBottom))||void 0===o?void 0:o.data.rank,e=Math.max(e,r.data.maxRank||-1/0))}),e},dr=t=>{t.getAllNodes().forEach(e=>{"edge-proxy"===e.data.dummy&&(t.getEdge(e.data.e.id).data.labelRank=e.data.rank,t.removeNode(e.id))})},fr=(t,e)=>{let r,n,o=0,i=0;const{marginx:s=0,marginy:a=0}={},u=t=>{if(!t.data)return;const e=t.data.x,s=t.data.y,a=t.data.width,u=t.data.height;isNaN(e)||isNaN(a)||(void 0===r&&(r=e-a/2),r=Math.min(r,e-a/2),o=Math.max(o,e+a/2)),isNaN(s)||isNaN(u)||(void 0===n&&(n=s-u/2),n=Math.min(n,s-u/2),i=Math.max(i,s+u/2))};return t.getAllNodes().forEach(t=>{u(t)}),t.getAllEdges().forEach(t=>{(null==t?void 0:t.data.hasOwnProperty("x"))&&u(t)}),r-=s,n-=a,t.getAllNodes().forEach(t=>{t.data.x-=r,t.data.y-=n}),t.getAllEdges().forEach(t=>{var e;null===(e=t.data.points)||void 0===e||e.forEach(t=>{t.x-=r,t.y-=n}),t.data.hasOwnProperty("x")&&(t.data.x-=r),t.data.hasOwnProperty("y")&&(t.data.y-=n)}),{width:o-r+s,height:i-n+a}},gr=t=>{t.getAllEdges().forEach(e=>{const r=t.getNode(e.source),n=t.getNode(e.target);let o,i;e.data.points?(o=e.data.points[0],i=e.data.points[e.data.points.length-1]):(e.data.points=[],o={x:n.data.x,y:n.data.y},i={x:r.data.x,y:r.data.y}),e.data.points.unshift(Ut(r.data,o)),e.data.points.push(Ut(n.data,i))})},pr=t=>{t.getAllEdges().forEach(t=>{if(t.data.hasOwnProperty("x"))switch("l"!==t.data.labelpos&&"r"!==t.data.labelpos||(t.data.width-=t.data.labeloffset),t.data.labelpos){case"l":t.data.x-=t.data.width/2+t.data.labeloffset;break;case"r":t.data.x+=t.data.width/2+t.data.labeloffset}})},vr=t=>{t.getAllEdges().forEach(t=>{var e;t.data.reversed&&(null===(e=t.data.points)||void 0===e||e.reverse())})},mr=t=>{t.getAllNodes().forEach(e=>{var r,n,o;if(null===(r=t.getChildren(e.id))||void 0===r?void 0:r.length){const r=t.getNode(e.id),i=t.getNode(r.data.borderTop),s=t.getNode(r.data.borderBottom),a=t.getNode(r.data.borderLeft[(null===(n=r.data.borderLeft)||void 0===n?void 0:n.length)-1]),u=t.getNode(r.data.borderRight[(null===(o=r.data.borderRight)||void 0===o?void 0:o.length)-1]);r.data.width=Math.abs((null==u?void 0:u.data.x)-(null==a?void 0:a.data.x))||10,r.data.height=Math.abs((null==s?void 0:s.data.y)-(null==i?void 0:i.data.y))||10,r.data.x=((null==a?void 0:a.data.x)||0)+r.data.width/2,r.data.y=((null==i?void 0:i.data.y)||0)+r.data.height/2}}),t.getAllNodes().forEach(e=>{"border"===e.data.dummy&&t.removeNode(e.id)})},yr=t=>{t.getAllEdges().forEach(e=>{if(e.source===e.target){const r=t.getNode(e.source);r.data.selfEdges||(r.data.selfEdges=[]),r.data.selfEdges.push(e),t.removeEdge(e.id)}})},wr=t=>{const e=Gt(t);null==e||e.forEach(e=>{let r=0;null==e||e.forEach((e,n)=>{var o;const i=t.getNode(e);i.data.order=n+r,null===(o=i.data.selfEdges)||void 0===o||o.forEach(e=>{Vt(t,"selfedge",{width:e.data.width,height:e.data.height,rank:i.data.rank,order:n+ ++r,e:e},"_se")}),delete i.data.selfEdges})})},xr=t=>{t.getAllNodes().forEach(e=>{const r=t.getNode(e.id);if("selfedge"===r.data.dummy){const n=t.getNode(r.data.e.source),o=n.data.x+n.data.width/2,i=n.data.y,s=r.data.x-o,a=n.data.height/2;t.hasEdge(r.data.e.id)?t.updateEdgeData(r.data.e.id,r.data.e.data):t.addEdge({id:r.data.e.id,source:r.data.e.source,target:r.data.e.target,data:r.data.e.data}),t.removeNode(e.id),r.data.e.data.points=[{x:o+2*s/3,y:i-a},{x:o+5*s/6,y:i-a},{y:i,x:o+s},{x:o+5*s/6,y:i+a},{x:o+2*s/3,y:i+a}],r.data.e.data.x=r.data.x,r.data.e.data.y=r.data.y}})},br=(t,e)=>{const r={};return null==e||e.forEach(e=>{void 0!==t[e]&&(r[e]=+t[e])}),r},Er=(t={})=>{const e={};return Object.keys(t).forEach(r=>{e[r.toLowerCase()]=t[r]}),e},Mr={nodeSize:10,nodeSpacing:0,rankdir:"TB",nodesep:50,ranksep:50,edgeLabelSpace:!0,ranker:"tight-tree",controlPoints:!1,radial:!1,focusNode:null};const Nr=(t,e,r,n,o,i,s)=>{let a=(null==t?void 0:t.slice(1,t.length-1))||[];if(e&&r){let{x:t,y:u}=e.data,{x:c,y:h}=r.data;if(o&&(t=e.data.y,u=e.data.x,c=r.data.y,h=r.data.x),h!==u&&t!==c){const l=n.indexOf(u),d=n[l+1];if(d){const t=a[0],e=o?{x:(u+d)/2,y:(null==t?void 0:t.y)||c}:{x:(null==t?void 0:t.x)||c,y:(u+d)/2};t&&!i(t,e)||a.unshift(e)}const f=n.indexOf(h),g=Math.abs(f-l);if(1===g)a=s(a,e.data,r.data),a.length||a.push(o?{x:(u+h)/2,y:t}:{x:t,y:(u+h)/2});else if(g>1){const e=n[f-1];if(e){const r=a[a.length-1],n=o?{x:(h+e)/2,y:(null==r?void 0:r.y)||c}:{x:(null==r?void 0:r.x)||t,y:(h+e)/2};r&&!i(r,n)||a.push(n)}}}}return a},_r={radius:null,startRadius:null,endRadius:null,startAngle:0,endAngle:2*Math.PI,clockwise:!0,divisions:1,ordering:null,angleRatio:1,nodeSize:10,nodeSpacing:0};const kr={nodeSize:30,nodeSpacing:10,preventOverlap:!1,sweep:void 0,equidistant:!1,startAngle:1.5*Math.PI,clockwise:!0,maxLevelDiff:void 0,sortBy:"degree"};function Sr(t,e,r,n){if(isNaN(e)||isNaN(r))return t;var o,i,s,a,u,c,h,l,d,f=t._root,g={data:n},p=t._x0,v=t._y0,m=t._x1,y=t._y1;if(!f)return t._root=g,t;for(;f.length;)if((c=e>=(i=(p+m)/2))?p=i:m=i,(h=r>=(s=(v+y)/2))?v=s:y=s,o=f,!(f=f[l=h<<1|c]))return o[l]=g,t;if(a=+t._x.call(null,f.data),u=+t._y.call(null,f.data),e===a&&r===u)return g.next=f,o?o[l]=g:t._root=g,t;do{o=o?o[l]=new Array(4):t._root=new Array(4),(c=e>=(i=(p+m)/2))?p=i:m=i,(h=r>=(s=(v+y)/2))?v=s:y=s}while((l=h<<1|c)==(d=(u>=s)<<1|a>=i));return o[d]=f,o[l]=g,t}function Ar(t,e,r,n,o){this.node=t,this.x0=e,this.y0=r,this.x1=n,this.y1=o}function Or(t){return t[0]}function zr(t){return t[1]}function jr(t,e,r){var n=new Cr(null==e?Or:e,null==r?zr:r,NaN,NaN,NaN,NaN);return null==t?n:n.addAll(t)}function Cr(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 Ir(t){for(var e={data:t.data},r=e;t=t.next;)r=r.next={data:t.data};return e}var Rr=jr.prototype=Cr.prototype;function Tr(t){return function(){return t}}function Pr(t){return 1e-6*(t()-.5)}function Fr(t){return t.x+t.vx}function Lr(t){return t.y+t.vy}function Dr(t){var e,r,n,o=1,i=1;function s(){for(var t,s,u,c,h,l,d,f=e.length,g=0;g<i;++g)for(s=jr(e,Fr,Lr).visitAfter(a),t=0;t<f;++t)u=e[t],l=r[u.index],d=l*l,c=u.x+u.vx,h=u.y+u.vy,s.visit(p);function p(t,e,r,i,s){var a=t.data,f=t.r,g=l+f;if(!a)return e>c+g||i<c-g||r>h+g||s<h-g;if(a.index>u.index){var p=c-a.x-a.vx,v=h-a.y-a.vy,m=p*p+v*v;m<g*g&&(0===p&&(m+=(p=Pr(n))*p),0===v&&(m+=(v=Pr(n))*v),m=(g-(m=Math.sqrt(m)))/m*o,u.vx+=(p*=m)*(g=(f*=f)/(d+f)),u.vy+=(v*=m)*g,a.vx-=p*(g=1-g),a.vy-=v*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=Tr(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:Tr(+e),u(),s):t},s}function qr(t){return t.index}function Br(t,e){var r=t.get(e);if(!r)throw new Error("node not found: "+e);return r}function Vr(t){var e,r,n,o,i,s,a=qr,u=function(t){return 1/Math.min(o[t.source.index],o[t.target.index])},c=Tr(30),h=1;function l(n){for(var o=0,a=t.length;o<h;++o)for(var u,c,l,d,f,g,p,v=0;v<a;++v)c=(u=t[v]).source,d=(l=u.target).x+l.vx-c.x-c.vx||Pr(s),f=l.y+l.vy-c.y-c.vy||Pr(s),d*=g=((g=Math.sqrt(d*d+f*f))-r[v])/g*n*e[v],f*=g,l.vx-=d*(p=i[v]),l.vy-=f*p,c.vx+=d*(p=1-p),c.vy+=f*p}function d(){if(n){var s,u,c=n.length,h=t.length,l=new Map(n.map((t,e)=>[a(t,e,n),t]));for(s=0,o=new Array(c);s<h;++s)(u=t[s]).index=s,"object"!=typeof u.source&&(u.source=Br(l,u.source)),"object"!=typeof u.target&&(u.target=Br(l,u.target)),o[u.source.index]=(o[u.source.index]||0)+1,o[u.target.index]=(o[u.target.index]||0)+1;for(s=0,i=new Array(h);s<h;++s)u=t[s],i[s]=o[u.source.index]/(o[u.source.index]+o[u.target.index]);e=new Array(h),f(),r=new Array(h),g()}}function f(){if(n)for(var r=0,o=t.length;r<o;++r)e[r]=+u(t[r],r,t)}function g(){if(n)for(var e=0,o=t.length;e<o;++e)r[e]=+c(t[e],e,t)}return null==t&&(t=[]),l.initialize=function(t,e){n=t,s=e,d()},l.links=function(e){return arguments.length?(t=e,d(),l):t},l.id=function(t){return arguments.length?(a=t,l):a},l.iterations=function(t){return arguments.length?(h=+t,l):h},l.strength=function(t){return arguments.length?(u="function"==typeof t?t:Tr(+t),f(),l):u},l.distance=function(t){return arguments.length?(c="function"==typeof t?t:Tr(+t),g(),l):c},l}Rr.copy=function(){var t,e,r=new Cr(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=Ir(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]=Ir(e));return r},Rr.add=function(t){const e=+this._x.call(null,t),r=+this._y.call(null,t);return Sr(this.cover(e,r),e,r,t)},Rr.addAll=function(t){var e,r,n,o,i=t.length,s=new Array(i),a=new Array(i),u=1/0,c=1/0,h=-1/0,l=-1/0;for(r=0;r<i;++r)isNaN(n=+this._x.call(null,e=t[r]))||isNaN(o=+this._y.call(null,e))||(s[r]=n,a[r]=o,n<u&&(u=n),n>h&&(h=n),o<c&&(c=o),o>l&&(l=o));if(u>h||c>l)return this;for(this.cover(u,c).cover(h,l),r=0;r<i;++r)Sr(this,s[r],a[r],t[r]);return this},Rr.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,c=this._root;r>t||t>=o||n>e||e>=i;)switch(a=(e<n)<<1|t<r,(s=new Array(4))[a]=c,c=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=c)}return this._x0=r,this._y0=n,this._x1=o,this._y1=i,this},Rr.data=function(){var t=[];return this.visit(function(e){if(!e.length)do{t.push(e.data)}while(e=e.next)}),t},Rr.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]]},Rr.find=function(t,e,r){var n,o,i,s,a,u,c,h=this._x0,l=this._y0,d=this._x1,f=this._y1,g=[],p=this._root;for(p&&g.push(new Ar(p,h,l,d,f)),null==r?r=1/0:(h=t-r,l=e-r,d=t+r,f=e+r,r*=r);u=g.pop();)if(!(!(p=u.node)||(o=u.x0)>d||(i=u.y0)>f||(s=u.x1)<h||(a=u.y1)<l))if(p.length){var v=(o+s)/2,m=(i+a)/2;g.push(new Ar(p[3],v,m,s,a),new Ar(p[2],o,m,v,a),new Ar(p[1],v,i,s,m),new Ar(p[0],o,i,v,m)),(c=(e>=m)<<1|t>=v)&&(u=g[g.length-1],g[g.length-1]=g[g.length-1-c],g[g.length-1-c]=u)}else{var y=t-+this._x.call(null,p.data),w=e-+this._y.call(null,p.data),x=y*y+w*w;if(x<r){var b=Math.sqrt(r=x);h=t-b,l=e-b,d=t+b,f=e+b,n=p.data}}return n},Rr.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,c,h,l,d,f=this._root,g=this._x0,p=this._y0,v=this._x1,m=this._y1;if(!f)return this;if(f.length)for(;;){if((c=i>=(a=(g+v)/2))?g=a:v=a,(h=s>=(u=(p+m)/2))?p=u:m=u,e=f,!(f=f[l=h<<1|c]))return this;if(!f.length)break;(e[l+1&3]||e[l+2&3]||e[l+3&3])&&(r=e,d=l)}for(;f.data!==t;)if(n=f,!(f=f.next))return this;return(o=f.next)&&delete f.next,n?(o?n.next=o:delete n.next,this):e?(o?e[l]=o:delete e[l],(f=e[0]||e[1]||e[2]||e[3])&&f===(e[3]||e[2]||e[1]||e[0])&&!f.length&&(r?r[d]=f:this._root=f),this):(this._root=o,this)},Rr.removeAll=function(t){for(var e=0,r=t.length;e<r;++e)this.remove(t[e]);return this},Rr.root=function(){return this._root},Rr.size=function(){var t=0;return this.visit(function(e){if(!e.length)do{++t}while(e=e.next)}),t},Rr.visit=function(t){var e,r,n,o,i,s,a=[],u=this._root;for(u&&a.push(new Ar(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 c=(n+i)/2,h=(o+s)/2;(r=u[3])&&a.push(new Ar(r,c,h,i,s)),(r=u[2])&&a.push(new Ar(r,n,h,c,s)),(r=u[1])&&a.push(new Ar(r,c,o,i,h)),(r=u[0])&&a.push(new Ar(r,n,o,c,h))}return this},Rr.visitAfter=function(t){var e,r=[],n=[];for(this._root&&r.push(new Ar(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,c=e.y1,h=(s+u)/2,l=(a+c)/2;(i=o[0])&&r.push(new Ar(i,s,a,h,l)),(i=o[1])&&r.push(new Ar(i,h,a,u,l)),(i=o[2])&&r.push(new Ar(i,s,l,h,c)),(i=o[3])&&r.push(new Ar(i,h,l,u,c))}n.push(e)}for(;e=n.pop();)t(e.node,e.x0,e.y0,e.x1,e.y1);return this},Rr.x=function(t){return arguments.length?(this._x=t,this):this._x},Rr.y=function(t){return arguments.length?(this._y=t,this):this._y};var $r={value:()=>{}};function Ur(){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 Gr(n)}function Gr(t){this._=t}function Wr(t,e){for(var r,n=0,o=t.length;n<o;++n)if((r=t[n]).name===e)return r.value}function Yr(t,e,r){for(var n=0,o=t.length;n<o;++n)if(t[n].name===e){t[n]=$r,t=t.slice(0,n).concat(t.slice(n+1));break}return null!=r&&t.push({name:e,value:r}),t}Gr.prototype=Ur.prototype={constructor:Gr,on:function(t,e){var r,n,o=this._,i=(n=o,(t+"").trim().split(/^|\s+/).map(function(t){var e="",r=t.indexOf(".");if(r>=0&&(e=t.slice(r+1),t=t.slice(0,r)),t&&!n.hasOwnProperty(t))throw new Error("unknown type: "+t);return{type:t,name:e}})),s=-1,a=i.length;if(!(arguments.length<2)){if(null!=e&&"function"!=typeof e)throw new Error("invalid callback: "+e);for(;++s<a;)if(r=(t=i[s]).type)o[r]=Yr(o[r],t.name,e);else if(null==e)for(r in o)o[r]=Yr(o[r],t.name,null);return this}for(;++s<a;)if((r=(t=i[s]).type)&&(r=Wr(o[r],t.name)))return r},copy:function(){var t={},e=this._;for(var r in e)t[r]=e[r].slice();return new Gr(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)}};var Hr,Xr,Qr=0,Kr=0,Jr=0,Zr=0,tn=0,en=0,rn="object"==typeof performance&&performance.now?performance:Date,nn="object"==typeof window&&window.requestAnimationFrame?window.requestAnimationFrame.bind(window):function(t){setTimeout(t,17)};function on(){return tn||(nn(sn),tn=rn.now()+en)}function sn(){tn=0}function an(){this._call=this._time=this._next=null}function un(t,e,r){var n=new an;return n.restart(t,e,r),n}function cn(){tn=(Zr=rn.now())+en,Qr=Kr=0;try{!function(){on(),++Qr;for(var t,e=Hr;e;)(t=tn-e._time)>=0&&e._call.call(void 0,t),e=e._next;--Qr}()}finally{Qr=0,function(){var t,e,r=Hr,n=1/0;for(;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:Hr=e);Xr=t,ln(n)}(),tn=0}}function hn(){var t=rn.now(),e=t-Zr;e>1e3&&(en-=e,Zr=t)}function ln(t){Qr||(Kr&&(Kr=clearTimeout(Kr)),t-tn>24?(t<1/0&&(Kr=setTimeout(cn,t-rn.now()-en)),Jr&&(Jr=clearInterval(Jr))):(Jr||(Zr=rn.now(),Jr=setInterval(hn,1e3)),Qr=1,nn(cn)))}an.prototype=un.prototype={constructor:an,restart:function(t,e,r){if("function"!=typeof t)throw new TypeError("callback is not a function");r=(null==r?on():+r)+(null==e?0:+e),this._next||Xr===this||(Xr?Xr._next=this:Hr=this,Xr=this),this._call=t,this._time=r,ln()},stop:function(){this._call&&(this._call=null,this._time=1/0,ln())}};const dn=4294967296;function fn(t){return t.x}function gn(t){return t.y}var pn=Math.PI*(3-Math.sqrt(5));function vn(t){var e,r=1,n=.001,o=1-Math.pow(n,1/300),i=0,s=.6,a=new Map,u=un(l),c=Ur("tick","end"),h=function(){let t=1;return()=>(t=(1664525*t+1013904223)%dn)/dn}();function l(){d(),c.call("tick",e),r<n&&(u.stop(),c.call("end",e))}function d(n){var u,c,h=t.length;void 0===n&&(n=1);for(var l=0;l<n;++l)for(r+=(i-r)*o,a.forEach(function(t){t(r)}),u=0;u<h;++u)null==(c=t[u]).fx?c.x+=c.vx*=s:(c.x=c.fx,c.vx=0),null==c.fy?c.y+=c.vy*=s:(c.y=c.fy,c.vy=0);return e}function f(){for(var e,r=0,n=t.length;r<n;++r){if((e=t[r]).index=r,null!=e.fx&&(e.x=e.fx),null!=e.fy&&(e.y=e.fy),isNaN(e.x)||isNaN(e.y)){var o=10*Math.sqrt(.5+r),i=r*pn;e.x=o*Math.cos(i),e.y=o*Math.sin(i)}(isNaN(e.vx)||isNaN(e.vy))&&(e.vx=e.vy=0)}}function g(e){return e.initialize&&e.initialize(t,h),e}return null==t&&(t=[]),f(),e={tick:d,restart:function(){return u.restart(l),e},stop:function(){return u.stop(),e},nodes:function(r){return arguments.length?(t=r,f(),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?(h=t,a.forEach(g),e):h},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,c=0,h=t.length;for(null==n?n=1/0:n*=n,c=0;c<h;++c)(s=(o=e-(a=t[c]).x)*o+(i=r-a.y)*i)<n&&(u=a,n=s);return u},on:function(t,r){return arguments.length>1?(c.on(t,r),e):c.on(t)}}}function mn(){var t,e,r,n,o,i=Tr(-30),s=1,a=1/0,u=.81;function c(r){var o,i=t.length,s=jr(t,fn,gn).visitAfter(l);for(n=r,o=0;o<i;++o)e=t[o],s.visit(d)}function h(){if(t){var e,r,n=t.length;for(o=new Array(n),e=0;e<n;++e)r=t[e],o[r.index]=+i(r,e,t)}}function l(t){var e,r,n,i,s,a=0,u=0;if(t.length){for(n=i=s=0;s<4;++s)(e=t[s])&&(r=Math.abs(e.value))&&(a+=e.value,u+=r,n+=r*e.x,i+=r*e.y);t.x=n/u,t.y=i/u}else{(e=t).x=e.data.x,e.y=e.data.y;do{a+=o[e.data.index]}while(e=e.next)}t.value=a}function d(t,i,c,h){if(!t.value)return!0;var l=t.x-e.x,d=t.y-e.y,f=h-i,g=l*l+d*d;if(f*f/u<g)return g<a&&(0===l&&(g+=(l=Pr(r))*l),0===d&&(g+=(d=Pr(r))*d),g<s&&(g=Math.sqrt(s*g)),e.vx+=l*t.value*n/g,e.vy+=d*t.value*n/g),!0;if(!(t.length||g>=a)){(t.data!==e||t.next)&&(0===l&&(g+=(l=Pr(r))*l),0===d&&(g+=(d=Pr(r))*d),g<s&&(g=Math.sqrt(s*g)));do{t.data!==e&&(f=o[t.data.index]*n/g,e.vx+=l*f,e.vy+=d*f)}while(t=t.next)}}return c.initialize=function(e,n){t=e,r=n,h()},c.strength=function(t){return arguments.length?(i="function"==typeof t?t:Tr(+t),h(),c):i},c.distanceMin=function(t){return arguments.length?(s=t*t,c):Math.sqrt(s)},c.distanceMax=function(t){return arguments.length?(a=t*t,c):Math.sqrt(a)},c.theta=function(t){return arguments.length?(u=t*t,c):Math.sqrt(u)},c}function yn(t){var e,r,n,o=Tr(.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=Tr(null==t?0:+t)),i.initialize=function(t){e=t,s()},i.strength=function(t){return arguments.length?(o="function"==typeof t?t:Tr(+t),s(),i):o},i.x=function(e){return arguments.length?(t="function"==typeof e?e:Tr(+e),s(),i):t},i}function wn(t){var e,r,n,o=Tr(.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=Tr(null==t?0:+t)),i.initialize=function(t){e=t,s()},i.strength=function(t){return arguments.length?(o="function"==typeof t?t:Tr(+t),s(),i):o},i.y=function(e){return arguments.length?(t="function"==typeof e?e:Tr(+e),s(),i):t},i}const xn=(t,e)=>t[e];function bn(){function t(t){return()=>t}let e,r=t=>t.cluster,n=t(1),o=t(-1),i=t(100),s=t(.1),a=[0,0],u=[],c={},h=[],l=100,d=100,f={none:{x:0,y:0}},g=[],p="force",v=!0,m=.1;function y(t){if(!v)return y;e.tick(),x();for(let e,n=0,o=u.length,i=t*m;n<o;++n)e=u[n],e.vx||(e.vx=0),e.vy||(e.vy=0),e.vx+=(f[r(e._original)].x-e.x)*i,e.vy+=(f[r(e._original)].y-e.y)*i}function w(){u&&function(){if(!u||!u.length)return;const t=u[0];if(void 0===r(t._original))throw Error("Couldnt find the grouping attribute for the nodes. Make sure to set it up with forceInABox.groupBy('clusterAttr') before calling .links()");const a=function(){const t=[],e=[],o={};let i=[],s={},a=[];return s=function(t){const e={};return t.forEach(t=>{const n=r(t._original);e[n]||(e[n]={count:0,sumforceNodeSize:0})}),t.forEach(t=>{const o=r(t._original),i=n(t._original),s=e[o];s.count=s.count+1,s.sumforceNodeSize=s.sumforceNodeSize+Math.PI*(i*i)*1.3,e[o]=s}),e}(u),a=function(t){const e={},n=[];t.forEach(t=>{const n=function(t){const e=xn(t,"source"),n=xn(t,"target"),o=r(c[e]._original),i=r(c[n]._original);return o<=i?`${o}~${i}`:`${i}~${o}`}(t);let o=0;void 0!==e[n]&&(o=e[n]),o+=1,e[n]=o});return Object.entries(e).forEach(([t,e])=>{const r=t.split("~")[0],o=t.split("~")[1];void 0!==r&&void 0!==o&&n.push({source:r,target:o,count:e})}),n}(h),i=Object.keys(s),i.forEach((e,r)=>{const n=s[e];t.push({id:e,size:n.count,r:Math.sqrt(n.sumforceNodeSize/Math.PI)}),o[e]=r}),a.forEach(t=>{const r=xn(t,"source"),n=xn(t,"target"),i=o[r],s=o[n];void 0!==i&&void 0!==s&&e.push({source:i,target:s,count:t.count})}),{nodes:t,links:e}}();e=vn(a.nodes).force("x",yn(l).strength(.1)).force("y",wn(d).strength(.1)).force("collide",Dr(t=>t.r).iterations(4)).force("charge",mn().strength(o)).force("links",Vr(a.nodes.length?a.links:[]).distance(i).strength(s)),g=e.nodes(),x()}()}function x(){return f={none:{x:0,y:0}},g.forEach(t=>{f[t.id]={x:t.x-a[0],y:t.y-a[1]}}),f}return y.initialize=t=>{u=t,w()},y.template=function(t){return arguments.length?(p=t,w(),y):p},y.groupBy=function(t){return arguments.length?"string"==typeof t?(r=e=>e[t],y):(r=t,y):r},y.enableGrouping=function(t){return arguments.length?(v=t,y):v},y.strength=function(t){return arguments.length?(m=t,y):m},y.centerX=function(t){return arguments.length?(l=t,y):l},y.centerY=function(t){return arguments.length?(d=t,y):d},y.nodes=function(t){return arguments.length?(function(t){c={},t.forEach(t=>{c[t.id]=t})}(t||[]),u=t||[],y):u},y.links=function(t){return arguments.length?(h=t||[],w(),y):h},y.forceNodeSize=function(e){return arguments.length?(n="function"==typeof e?e:t(+e),w(),y):n},y.nodeSize=y.forceNodeSize,y.forceCharge=function(e){return arguments.length?(o="function"==typeof e?e:t(+e),w(),y):o},y.forceLinkDistance=function(e){return arguments.length?(i="function"==typeof e?e:t(+e),w(),y):i},y.forceLinkStrength=function(e){return arguments.length?(s="function"==typeof e?e:t(+e),w(),y):s},y.offset=function(t){return arguments.length?(a=t,y):a},y.getFocis=x,y}const En={edgeId:"edge.id",manyBody:{strength:-30},preventOverlap:!1,nodeSize:10,nodeSpacing:0,x:!1,y:!1,clustering:!1,clusterNodeStrength:-1,clusterEdgeStrength:.1,clusterEdgeDistance:100,clusterFociStrength:.8,clusterNodeSize:10};class Mn extends zt{getDefaultOptions(){return En}mergeOptions(t,e){return function(t){for(var e=[],r=1;r<arguments.length;r++)e[r-1]=arguments[r];for(var n=0;n<e.length;n+=1)I(t,e[n]);return t}({},t,e)}constructor(t){super(t),this.id="d3-force",this.d3Nodes=[],this.d3Edges=[],this.config={simulationAttrs:["alpha","alphaMin","alphaDecay","alphaTarget","velocityDecay","randomSource"]},this.options.forceSimulation&&(this.simulation=this.options.forceSimulation)}stop(){return this.simulation&&this.simulation.stop(),this}tick(t=1){var e,r;if(this.simulation){for(let e=0;e<t;e++)this.simulation.tick();this.syncPositionsFromD3(),null===(r=(e=this.options).onTick)||void 0===r||r.call(e,this)}return this}restart(t){return this.simulation&&(void 0!==t&&this.simulation.alpha(t),this.simulation.restart()),this}reheat(){return this.restart(1)}getAlpha(){var t,e;return null!==(e=null===(t=this.simulation)||void 0===t?void 0:t.alpha())&&void 0!==e?e:0}setAlpha(t){return this.simulation&&this.simulation.alpha(t),this}getForce(t){var e;return null===(e=this.simulation)||void 0===e?void 0:e.force(t)}force(t,e){return this.simulation&&this.simulation.force(t,e),this}nodes(){var t,e;return null!==(e=null===(t=this.simulation)||void 0===t?void 0:t.nodes())&&void 0!==e?e:[]}find(t,e,r){if(this.simulation)return this.simulation.find(t,e,r)}setFixedPosition(t,e){const r=this.d3Nodes.find(e=>e.id===t),n=this.model.node(t);if(!n||!r)return;const o=["fx","fy","fz"];null!==e?e.forEach((t,e)=>{e<o.length&&("number"==typeof t||null===t)&&(n[o[e]]=t,r[o[e]]=t)}):o.forEach(t=>{delete n[t],delete r[t]})}parseOptions(t){const e=t;return void 0===e.iterations&&(e.link&&void 0===e.link.iterations&&(e.iterations=e.link.iterations),e.collide&&void 0===e.collide.iterations&&(e.iterations=e.collide.iterations)),e}layout(){var e;return t(this,void 0,void 0,function*(){const t=this.parseOptions(this.options||{});this.createD3Copies();const r=this.setSimulation(t);return r.nodes(this.d3Nodes),null===(e=r.force("link"))||void 0===e||e.links(this.d3Edges),new Promise(t=>{r.on("end",()=>{this.syncPositionsFromD3(),t()})})})}createD3Copies(){this.d3Nodes=[],this.d3Edges=[],this.model.forEachNode(t=>{this.d3Nodes.push(Object.assign({},t))}),this.model.forEachEdge(t=>{this.d3Edges.push(Object.assign({},t))})}syncPositionsFromD3(){this.d3Nodes.forEach(t=>{const e=this.model.node(t.id);e&&(e.x=t.x,e.y=t.y,void 0!==t.z&&(e.z=t.z),void 0!==t.fx&&(e.fx=t.fx),void 0!==t.fy&&(e.fy=t.fy),void 0!==t.fz&&(e.fz=t.fz),void 0!==t.vx&&(e.vx=t.vx),void 0!==t.vy&&(e.vy=t.vy),void 0!==t.vz&&(e.vz=t.vz))})}initSimulation(){return vn()}setSimulation(t){const e=this.simulation||this.options.forceSimulation||this.initSimulation();return this.simulation||(this.simulation=e.on("tick",()=>{var e;this.syncPositionsFromD3(),null===(e=t.onTick)||void 0===e||e.call(t,this)})),Nn(e,this.config.simulationAttrs.map(e=>[e,t[e]])),this.setupForces(e,t),e}setupForces(t,e){this.setupLinkForce(t,e),this.setupManyBodyForce(t,e),this.setupCenterForce(t,e),this.setupCollisionForce(t,e),this.setupXForce(t,e),this.setupYForce(t,e),this.setupRadialForce(t,e),this.setupClusterForce(t,e)}getCenterOptions(t){if(!1===t.center)return;const e=Et({width:t.width,height:t.height});return vt({},t.center||{},{x:e.width/2,y:e.height/2,strength:t.centerStrength})}setupCenterForce(t,e){const r=this.getCenterOptions(e);if(r){let e=t.force("center");e||(e=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}(r.x,r.y),t.force("center",e));const n=[];void 0!==r.x&&n.push(["x",r.x]),void 0!==r.y&&n.push(["y",r.y]),void 0!==r.strength&&n.push(["strength",r.strength]),Nn(e,n)}else t.force("center",null)}getManyBodyOptions(t){if(!1!==t.manyBody)return vt({},t.manyBody||{},{strength:t.nodeStrength?ut(t.nodeStrength,["node"]):void 0,distanceMin:t.distanceMin,distanceMax:t.distanceMax,theta:t.theta})}setupManyBodyForce(t,e){const r=this.getManyBodyOptions(e);if(r){let e=t.force("charge");e||(e=mn(),t.force("charge",e));const n=[];void 0!==r.strength&&n.push(["strength",r.strength]),void 0!==r.distanceMin&&n.push(["distanceMin",r.distanceMin]),void 0!==r.distanceMax&&n.push(["distanceMax",r.distanceMax]),void 0!==r.theta&&n.push(["theta",r.theta]),Nn(e,n)}else t.force("charge",null)}getLinkOptions(t){if(!1!==t.link)return vt({},t.link||{},{id:t.edgeId?ut(t.edgeId,["edge"]):void 0,distance:t.linkDistance?ut(t.linkDistance,["edge"]):void 0,strength:t.edgeStrength?ut(t.edgeStrength,["edge"]):void 0,iterations:t.edgeIterations})}setupLinkForce(t,e){const r=this.model.edges(),n=this.getLinkOptions(e);if(r.length>0&&n){let e=t.force("link");e||(e=Vr(),t.force("link",e));const r=[];void 0!==n.id&&r.push(["id",n.id]),void 0!==n.distance&&r.push(["distance",n.distance]),void 0!==n.strength&&r.push(["strength",n.strength]),void 0!==n.iterations&&r.push(["iterations",n.iterations]),Nn(e,r)}else t.force("link",null)}getCollisionOptions(t){if(!1===t.preventOverlap&&(!1===t.collide||void 0===t.collide))return;const e=lt(t.nodeSize,t.nodeSpacing,En.nodeSize,En.nodeSpacing);return vt({},t.collide||{},{radius:t.collide&&t.collide.radius||(t=>Math.max(...e(t._original))/2),strength:t.collideStrength,iterations:t.collideIterations})}setupCollisionForce(t,e){const r=this.getCollisionOptions(e);if(r){let e=t.force("collide");e||(e=Dr(),t.force("collide",e));const n=[];void 0!==r.radius&&n.push(["radius",r.radius]),void 0!==r.strength&&n.push(["strength",r.strength]),void 0!==r.iterations&&n.push(["iterations",r.iterations]),Nn(e,n)}else t.force("collide",null)}getXForceOptions(t){var e;if(!1===t.x)return;const r=this.getCenterOptions(t);return vt({},t.x||{},{x:null!==(e=t.forceXPosition)&&void 0!==e?e:r&&r.x,strength:t.forceXStrength})}setupXForce(t,e){const r=this.getXForceOptions(e);if(r){let e=t.force("x");e||(e=yn(),t.force("x",e));const n=[];void 0!==r.x&&n.push(["x",r.x]),void 0!==r.strength&&n.push(["strength",r.strength]),Nn(e,n)}else t.force("x",null)}getYForceOptions(t){var e;if(!1===t.y)return;const r=this.getCenterOptions(t);return vt({},t.y||{},{y:null!==(e=t.forceYPosition)&&void 0!==e?e:r&&r.y,strength:t.forceYStrength})}setupYForce(t,e){const r=this.getYForceOptions(e);if(r){let e=t.force("y");e||(e=wn(),t.force("y",e));const n=[];void 0!==r.y&&n.push(["y",r.y]),void 0!==r.strength&&n.push(["strength",r.strength]),Nn(e,n)}else t.force("y",null)}getRadialOptions(t){var e,r,n;if(void 0!==t.radial||void 0!==t.radialStrength||void 0!==t.radialRadius||void 0!==t.radialX||void 0!==t.radialY){const o=this.getCenterOptions(t);return vt({},t.radial||{},{strength:t.radialStrength,radius:null!==(e=t.radialRadius)&&void 0!==e?e:100,x:null!==(r=t.radialX)&&void 0!==r?r:o&&o.x,y:null!==(n=t.radialY)&&void 0!==n?n:o&&o.y})}}setupRadialForce(t,e){const r=this.getRadialOptions(e);if(r){let e=t.force("radial");e||(e=function(t,e,r){var n,o,i,s=Tr(.1);function a(t){for(var s=0,a=n.length;s<a;++s){var u=n[s],c=u.x-e||1e-6,h=u.y-r||1e-6,l=Math.sqrt(c*c+h*h),d=(i[s]-l)*o[s]*t/l;u.vx+=c*d,u.vy+=h*d}}function u(){if(n){var e,r=n.length;for(o=new Array(r),i=new Array(r),e=0;e<r;++e)i[e]=+t(n[e],e,n),o[e]=isNaN(i[e])?0:+s(n[e],e,n)}}return"function"!=typeof t&&(t=Tr(+t)),null==e&&(e=0),null==r&&(r=0),a.initialize=function(t){n=t,u()},a.strength=function(t){return arguments.length?(s="function"==typeof t?t:Tr(+t),u(),a):s},a.radius=function(e){return arguments.length?(t="function"==typeof e?e:Tr(+e),u(),a):t},a.x=function(t){return arguments.length?(e=+t,a):e},a.y=function(t){return arguments.length?(r=+t,a):r},a}(r.radius||100,r.x,r.y),t.force("radial",e));const n=[];void 0!==r.radius&&n.push(["radius",r.radius]),void 0!==r.strength&&n.push(["strength",r.strength]),void 0!==r.x&&n.push(["x",r.x]),void 0!==r.y&&n.push(["y",r.y]),Nn(e,n)}else t.force("radial",null)}setupClusterForce(t,e){const{clustering:r}=e;if(r){const{clusterFociStrength:r,clusterEdgeDistance:n,clusterEdgeStrength:o,clusterNodeStrength:i,clusterNodeSize:s,clusterBy:a}=e,u=this.getCenterOptions(e);let c=t.force("group");c||(c=bn(),t.force("group",c)),Nn(c,[["centerX",u&&u.x],["centerY",u&&u.y],["template","force"],["strength",r],["groupBy",a?ut(a,["node"]):void 0],["nodes",this.model.nodes()],["links",this.model.edges()],["forceLinkDistance",n],["forceLinkStrength",o],["forceCharge",i],["forceNodeSize",s]])}else t.force("group",null)}}const Nn=(t,e)=>e.reduce((e,[r,n])=>e[r]&&void 0!==n?e[r].call(t,n):e,t);function _n(t,e,r){var n,o=1;function i(){var i,s,a=n.length,u=0,c=0,h=0;for(i=0;i<a;++i)u+=(s=n[i]).x||0,c+=s.y||0,h+=s.z||0;for(u=(u/a-t)*o,c=(c/a-e)*o,h=(h/a-r)*o,i=0;i<a;++i)s=n[i],u&&(s.x-=u),c&&(s.y-=c),h&&(s.z-=h)}return null==t&&(t=0),null==e&&(e=0),null==r&&(r=0),i.initialize=function(t){n=t},i.x=function(e){return arguments.length?(t=+e,i):t},i.y=function(t){return arguments.length?(e=+t,i):e},i.z=function(t){return arguments.length?(r=+t,i):r},i.strength=function(t){return arguments.length?(o=+t,i):o},i}function kn(t,e,r){if(isNaN(e))return t;var n,o,i,s,a,u,c=t._root,h={data:r},l=t._x0,d=t._x1;if(!c)return t._root=h,t;for(;c.length;)if((s=e>=(o=(l+d)/2))?l=o:d=o,n=c,!(c=c[a=+s]))return n[a]=h,t;if(e===(i=+t._x.call(null,c.data)))return h.next=c,n?n[a]=h:t._root=h,t;do{n=n?n[a]=new Array(2):t._root=new Array(2),(s=e>=(o=(l+d)/2))?l=o:d=o}while((a=+s)===(u=+(i>=o)));return n[u]=c,n[a]=h,t}function Sn(t,e,r){this.node=t,this.x0=e,this.x1=r}function An(t){return t[0]}function On(t,e){var r=new zn(null==e?An:e,NaN,NaN);return null==t?r:r.addAll(t)}function zn(t,e,r){this._x=t,this._x0=e,this._x1=r,this._root=void 0}function jn(t){for(var e={data:t.data},r=e;t=t.next;)r=r.next={data:t.data};return e}var Cn=On.prototype=zn.prototype;function In(t,e,r,n,o){if(isNaN(e)||isNaN(r)||isNaN(n))return t;var i,s,a,u,c,h,l,d,f,g,p,v,m=t._root,y={data:o},w=t._x0,x=t._y0,b=t._z0,E=t._x1,M=t._y1,N=t._z1;if(!m)return t._root=y,t;for(;m.length;)if((d=e>=(s=(w+E)/2))?w=s:E=s,(f=r>=(a=(x+M)/2))?x=a:M=a,(g=n>=(u=(b+N)/2))?b=u:N=u,i=m,!(m=m[p=g<<2|f<<1|d]))return i[p]=y,t;if(c=+t._x.call(null,m.data),h=+t._y.call(null,m.data),l=+t._z.call(null,m.data),e===c&&r===h&&n===l)return y.next=m,i?i[p]=y:t._root=y,t;do{i=i?i[p]=new Array(8):t._root=new Array(8),(d=e>=(s=(w+E)/2))?w=s:E=s,(f=r>=(a=(x+M)/2))?x=a:M=a,(g=n>=(u=(b+N)/2))?b=u:N=u}while((p=g<<2|f<<1|d)==(v=(l>=u)<<2|(h>=a)<<1|c>=s));return i[v]=m,i[p]=y,t}function Rn(t,e,r,n,o,i,s){this.node=t,this.x0=e,this.y0=r,this.z0=n,this.x1=o,this.y1=i,this.z1=s}Cn.copy=function(){var t,e,r=new zn(this._x,this._x0,this._x1),n=this._root;if(!n)return r;if(!n.length)return r._root=jn(n),r;for(t=[{source:n,target:r._root=new Array(2)}];n=t.pop();)for(var o=0;o<2;++o)(e=n.source[o])&&(e.length?t.push({source:e,target:n.target[o]=new Array(2)}):n.target[o]=jn(e));return r},Cn.add=function(t){const e=+this._x.call(null,t);return kn(this.cover(e),e,t)},Cn.addAll=function(t){Array.isArray(t)||(t=Array.from(t));const e=t.length,r=new Float64Array(e);let n=1/0,o=-1/0;for(let i,s=0;s<e;++s)isNaN(i=+this._x.call(null,t[s]))||(r[s]=i,i<n&&(n=i),i>o&&(o=i));if(n>o)return this;this.cover(n).cover(o);for(let n=0;n<e;++n)kn(this,r[n],t[n]);return this},Cn.cover=function(t){if(isNaN(t=+t))return this;var e=this._x0,r=this._x1;if(isNaN(e))r=(e=Math.floor(t))+1;else{for(var n,o,i=r-e||1,s=this._root;e>t||t>=r;)switch(o=+(t<e),(n=new Array(2))[o]=s,s=n,i*=2,o){case 0:r=e+i;break;case 1:e=r-i}this._root&&this._root.length&&(this._root=s)}return this._x0=e,this._x1=r,this},Cn.data=function(){var t=[];return this.visit(function(e){if(!e.length)do{t.push(e.data)}while(e=e.next)}),t},Cn.extent=function(t){return arguments.length?this.cover(+t[0][0]).cover(+t[1][0]):isNaN(this._x0)?void 0:[[this._x0],[this._x1]]},Cn.find=function(t,e){var r,n,o,i,s,a=this._x0,u=this._x1,c=[],h=this._root;for(h&&c.push(new Sn(h,a,u)),null==e?e=1/0:(a=t-e,u=t+e);i=c.pop();)if(!(!(h=i.node)||(n=i.x0)>u||(o=i.x1)<a))if(h.length){var l=(n+o)/2;c.push(new Sn(h[1],l,o),new Sn(h[0],n,l)),(s=+(t>=l))&&(i=c[c.length-1],c[c.length-1]=c[c.length-1-s],c[c.length-1-s]=i)}else{var d=Math.abs(t-+this._x.call(null,h.data));d<e&&(e=d,a=t-d,u=t+d,r=h.data)}return r},Cn.remove=function(t){if(isNaN(i=+this._x.call(null,t)))return this;var e,r,n,o,i,s,a,u,c,h=this._root,l=this._x0,d=this._x1;if(!h)return this;if(h.length)for(;;){if((a=i>=(s=(l+d)/2))?l=s:d=s,e=h,!(h=h[u=+a]))return this;if(!h.length)break;e[u+1&1]&&(r=e,c=u)}for(;h.data!==t;)if(n=h,!(h=h.next))return this;return(o=h.next)&&delete h.next,n?(o?n.next=o:delete n.next,this):e?(o?e[u]=o:delete e[u],(h=e[0]||e[1])&&h===(e[1]||e[0])&&!h.length&&(r?r[c]=h:this._root=h),this):(this._root=o,this)},Cn.removeAll=function(t){for(var e=0,r=t.length;e<r;++e)this.remove(t[e]);return this},Cn.root=function(){return this._root},Cn.size=function(){var t=0;return this.visit(function(e){if(!e.length)do{++t}while(e=e.next)}),t},Cn.visit=function(t){var e,r,n,o,i=[],s=this._root;for(s&&i.push(new Sn(s,this._x0,this._x1));e=i.pop();)if(!t(s=e.node,n=e.x0,o=e.x1)&&s.length){var a=(n+o)/2;(r=s[1])&&i.push(new Sn(r,a,o)),(r=s[0])&&i.push(new Sn(r,n,a))}return this},Cn.visitAfter=function(t){var e,r=[],n=[];for(this._root&&r.push(new Sn(this._root,this._x0,this._x1));e=r.pop();){var o=e.node;if(o.length){var i,s=e.x0,a=e.x1,u=(s+a)/2;(i=o[0])&&r.push(new Sn(i,s,u)),(i=o[1])&&r.push(new Sn(i,u,a))}n.push(e)}for(;e=n.pop();)t(e.node,e.x0,e.x1);return this},Cn.x=function(t){return arguments.length?(this._x=t,this):this._x};const Tn=(t,e,r,n,o,i)=>Math.sqrt((t-n)**2+(e-o)**2+(r-i)**2);function Pn(t){return t[0]}function Fn(t){return t[1]}function Ln(t){return t[2]}function Dn(t,e,r,n){var o=new qn(null==e?Pn:e,null==r?Fn:r,null==n?Ln:n,NaN,NaN,NaN,NaN,NaN,NaN);return null==t?o:o.addAll(t)}function qn(t,e,r,n,o,i,s,a,u){this._x=t,this._y=e,this._z=r,this._x0=n,this._y0=o,this._z0=i,this._x1=s,this._y1=a,this._z1=u,this._root=void 0}function Bn(t){for(var e={data:t.data},r=e;t=t.next;)r=r.next={data:t.data};return e}var Vn=Dn.prototype=qn.prototype;function $n(t){return function(){return t}}function Un(t){return 1e-6*(t()-.5)}function Gn(t){return t.x+t.vx}function Wn(t){return t.y+t.vy}function Yn(t){return t.z+t.vz}function Hn(t){var e,r,n,o,i=1,s=1;function a(){for(var t,a,c,h,l,d,f,g,p=e.length,v=0;v<s;++v)for(a=(1===r?On(e,Gn):2===r?jr(e,Gn,Wn):3===r?Dn(e,Gn,Wn,Yn):null).visitAfter(u),t=0;t<p;++t)c=e[t],f=n[c.index],g=f*f,h=c.x+c.vx,r>1&&(l=c.y+c.vy),r>2&&(d=c.z+c.vz),a.visit(m);function m(t,e,n,s,a,u,p){var v=[e,n,s,a,u,p],m=v[0],y=v[1],w=v[2],x=v[r],b=v[r+1],E=v[r+2],M=t.data,N=t.r,_=f+N;if(!M)return m>h+_||x<h-_||r>1&&(y>l+_||b<l-_)||r>2&&(w>d+_||E<d-_);if(M.index>c.index){var k=h-M.x-M.vx,S=r>1?l-M.y-M.vy:0,A=r>2?d-M.z-M.vz:0,O=k*k+S*S+A*A;O<_*_&&(0===k&&(O+=(k=Un(o))*k),r>1&&0===S&&(O+=(S=Un(o))*S),r>2&&0===A&&(O+=(A=Un(o))*A),O=(_-(O=Math.sqrt(O)))/O*i,c.vx+=(k*=O)*(_=(N*=N)/(g+N)),r>1&&(c.vy+=(S*=O)*_),r>2&&(c.vz+=(A*=O)*_),M.vx-=k*(_=1-_),r>1&&(M.vy-=S*_),r>2&&(M.vz-=A*_))}}}function u(t){if(t.data)return t.r=n[t.data.index];for(var e=t.r=0;e<Math.pow(2,r);++e)t[e]&&t[e].r>t.r&&(t.r=t[e].r)}function c(){if(e){var r,o,i=e.length;for(n=new Array(i),r=0;r<i;++r)o=e[r],n[o.index]=+t(o,r,e)}}return"function"!=typeof t&&(t=$n(null==t?1:+t)),a.initialize=function(t,...n){e=t,o=n.find(t=>"function"==typeof t)||Math.random,r=n.find(t=>[1,2,3].includes(t))||2,c()},a.iterations=function(t){return arguments.length?(s=+t,a):s},a.strength=function(t){return arguments.length?(i=+t,a):i},a.radius=function(e){return arguments.length?(t="function"==typeof e?e:$n(+e),c(),a):t},a}function Xn(t){return t.index}function Qn(t,e){var r=t.get(e);if(!r)throw new Error("node not found: "+e);return r}function Kn(t){var e,r,n,o,i,s,a,u=Xn,c=function(t){return 1/Math.min(i[t.source.index],i[t.target.index])},h=$n(30),l=1;function d(n){for(var i=0,u=t.length;i<l;++i)for(var c,h,d,f,g,p=0,v=0,m=0,y=0;p<u;++p)h=(c=t[p]).source,v=(d=c.target).x+d.vx-h.x-h.vx||Un(a),o>1&&(m=d.y+d.vy-h.y-h.vy||Un(a)),o>2&&(y=d.z+d.vz-h.z-h.vz||Un(a)),v*=f=((f=Math.sqrt(v*v+m*m+y*y))-r[p])/f*n*e[p],m*=f,y*=f,d.vx-=v*(g=s[p]),o>1&&(d.vy-=m*g),o>2&&(d.vz-=y*g),h.vx+=v*(g=1-g),o>1&&(h.vy+=m*g),o>2&&(h.vz+=y*g)}function f(){if(n){var o,a,c=n.length,h=t.length,l=new Map(n.map((t,e)=>[u(t,e,n),t]));for(o=0,i=new Array(c);o<h;++o)(a=t[o]).index=o,"object"!=typeof a.source&&(a.source=Qn(l,a.source)),"object"!=typeof a.target&&(a.target=Qn(l,a.target)),i[a.source.index]=(i[a.source.index]||0)+1,i[a.target.index]=(i[a.target.index]||0)+1;for(o=0,s=new Array(h);o<h;++o)a=t[o],s[o]=i[a.source.index]/(i[a.source.index]+i[a.target.index]);e=new Array(h),g(),r=new Array(h),p()}}function g(){if(n)for(var r=0,o=t.length;r<o;++r)e[r]=+c(t[r],r,t)}function p(){if(n)for(var e=0,o=t.length;e<o;++e)r[e]=+h(t[e],e,t)}return null==t&&(t=[]),d.initialize=function(t,...e){n=t,a=e.find(t=>"function"==typeof t)||Math.random,o=e.find(t=>[1,2,3].includes(t))||2,f()},d.links=function(e){return arguments.length?(t=e,f(),d):t},d.id=function(t){return arguments.length?(u=t,d):u},d.iterations=function(t){return arguments.length?(l=+t,d):l},d.strength=function(t){return arguments.length?(c="function"==typeof t?t:$n(+t),g(),d):c},d.distance=function(t){return arguments.length?(h="function"==typeof t?t:$n(+t),p(),d):h},d}Vn.copy=function(){var t,e,r=new qn(this._x,this._y,this._z,this._x0,this._y0,this._z0,this._x1,this._y1,this._z1),n=this._root;if(!n)return r;if(!n.length)return r._root=Bn(n),r;for(t=[{source:n,target:r._root=new Array(8)}];n=t.pop();)for(var o=0;o<8;++o)(e=n.source[o])&&(e.length?t.push({source:e,target:n.target[o]=new Array(8)}):n.target[o]=Bn(e));return r},Vn.add=function(t){const e=+this._x.call(null,t),r=+this._y.call(null,t),n=+this._z.call(null,t);return In(this.cover(e,r,n),e,r,n,t)},Vn.addAll=function(t){Array.isArray(t)||(t=Array.from(t));const e=t.length,r=new Float64Array(e),n=new Float64Array(e),o=new Float64Array(e);let i=1/0,s=1/0,a=1/0,u=-1/0,c=-1/0,h=-1/0;for(let l,d,f,g,p=0;p<e;++p)isNaN(d=+this._x.call(null,l=t[p]))||isNaN(f=+this._y.call(null,l))||isNaN(g=+this._z.call(null,l))||(r[p]=d,n[p]=f,o[p]=g,d<i&&(i=d),d>u&&(u=d),f<s&&(s=f),f>c&&(c=f),g<a&&(a=g),g>h&&(h=g));if(i>u||s>c||a>h)return this;this.cover(i,s,a).cover(u,c,h);for(let i=0;i<e;++i)In(this,r[i],n[i],o[i],t[i]);return this},Vn.cover=function(t,e,r){if(isNaN(t=+t)||isNaN(e=+e)||isNaN(r=+r))return this;var n=this._x0,o=this._y0,i=this._z0,s=this._x1,a=this._y1,u=this._z1;if(isNaN(n))s=(n=Math.floor(t))+1,a=(o=Math.floor(e))+1,u=(i=Math.floor(r))+1;else{for(var c,h,l=s-n||1,d=this._root;n>t||t>=s||o>e||e>=a||i>r||r>=u;)switch(h=(r<i)<<2|(e<o)<<1|t<n,(c=new Array(8))[h]=d,d=c,l*=2,h){case 0:s=n+l,a=o+l,u=i+l;break;case 1:n=s-l,a=o+l,u=i+l;break;case 2:s=n+l,o=a-l,u=i+l;break;case 3:n=s-l,o=a-l,u=i+l;break;case 4:s=n+l,a=o+l,i=u-l;break;case 5:n=s-l,a=o+l,i=u-l;break;case 6:s=n+l,o=a-l,i=u-l;break;case 7:n=s-l,o=a-l,i=u-l}this._root&&this._root.length&&(this._root=d)}return this._x0=n,this._y0=o,this._z0=i,this._x1=s,this._y1=a,this._z1=u,this},Vn.data=function(){var t=[];return this.visit(function(e){if(!e.length)do{t.push(e.data)}while(e=e.next)}),t},Vn.extent=function(t){return arguments.length?this.cover(+t[0][0],+t[0][1],+t[0][2]).cover(+t[1][0],+t[1][1],+t[1][2]):isNaN(this._x0)?void 0:[[this._x0,this._y0,this._z0],[this._x1,this._y1,this._z1]]},Vn.find=function(t,e,r,n){var o,i,s,a,u,c,h,l,d,f=this._x0,g=this._y0,p=this._z0,v=this._x1,m=this._y1,y=this._z1,w=[],x=this._root;for(x&&w.push(new Rn(x,f,g,p,v,m,y)),null==n?n=1/0:(f=t-n,g=e-n,p=r-n,v=t+n,m=e+n,y=r+n,n*=n);l=w.pop();)if(!(!(x=l.node)||(i=l.x0)>v||(s=l.y0)>m||(a=l.z0)>y||(u=l.x1)<f||(c=l.y1)<g||(h=l.z1)<p))if(x.length){var b=(i+u)/2,E=(s+c)/2,M=(a+h)/2;w.push(new Rn(x[7],b,E,M,u,c,h),new Rn(x[6],i,E,M,b,c,h),new Rn(x[5],b,s,M,u,E,h),new Rn(x[4],i,s,M,b,E,h),new Rn(x[3],b,E,a,u,c,M),new Rn(x[2],i,E,a,b,c,M),new Rn(x[1],b,s,a,u,E,M),new Rn(x[0],i,s,a,b,E,M)),(d=(r>=M)<<2|(e>=E)<<1|t>=b)&&(l=w[w.length-1],w[w.length-1]=w[w.length-1-d],w[w.length-1-d]=l)}else{var N=t-+this._x.call(null,x.data),_=e-+this._y.call(null,x.data),k=r-+this._z.call(null,x.data),S=N*N+_*_+k*k;if(S<n){var A=Math.sqrt(n=S);f=t-A,g=e-A,p=r-A,v=t+A,m=e+A,y=r+A,o=x.data}}return o},Vn.findAllWithinRadius=function(t,e,r,n){const o=[],i=t-n,s=e-n,a=r-n,u=t+n,c=e+n,h=r+n;return this.visit((l,d,f,g,p,v,m)=>{if(!l.length)do{const i=l.data;Tn(t,e,r,this._x(i),this._y(i),this._z(i))<=n&&o.push(i)}while(l=l.next);return d>u||f>c||g>h||p<i||v<s||m<a}),o},Vn.remove=function(t){if(isNaN(i=+this._x.call(null,t))||isNaN(s=+this._y.call(null,t))||isNaN(a=+this._z.call(null,t)))return this;var e,r,n,o,i,s,a,u,c,h,l,d,f,g,p,v=this._root,m=this._x0,y=this._y0,w=this._z0,x=this._x1,b=this._y1,E=this._z1;if(!v)return this;if(v.length)for(;;){if((l=i>=(u=(m+x)/2))?m=u:x=u,(d=s>=(c=(y+b)/2))?y=c:b=c,(f=a>=(h=(w+E)/2))?w=h:E=h,e=v,!(v=v[g=f<<2|d<<1|l]))return this;if(!v.length)break;(e[g+1&7]||e[g+2&7]||e[g+3&7]||e[g+4&7]||e[g+5&7]||e[g+6&7]||e[g+7&7])&&(r=e,p=g)}for(;v.data!==t;)if(n=v,!(v=v.next))return this;return(o=v.next)&&delete v.next,n?(o?n.next=o:delete n.next,this):e?(o?e[g]=o:delete e[g],(v=e[0]||e[1]||e[2]||e[3]||e[4]||e[5]||e[6]||e[7])&&v===(e[7]||e[6]||e[5]||e[4]||e[3]||e[2]||e[1]||e[0])&&!v.length&&(r?r[p]=v:this._root=v),this):(this._root=o,this)},Vn.removeAll=function(t){for(var e=0,r=t.length;e<r;++e)this.remove(t[e]);return this},Vn.root=function(){return this._root},Vn.size=function(){var t=0;return this.visit(function(e){if(!e.length)do{++t}while(e=e.next)}),t},Vn.visit=function(t){var e,r,n,o,i,s,a,u,c=[],h=this._root;for(h&&c.push(new Rn(h,this._x0,this._y0,this._z0,this._x1,this._y1,this._z1));e=c.pop();)if(!t(h=e.node,n=e.x0,o=e.y0,i=e.z0,s=e.x1,a=e.y1,u=e.z1)&&h.length){var l=(n+s)/2,d=(o+a)/2,f=(i+u)/2;(r=h[7])&&c.push(new Rn(r,l,d,f,s,a,u)),(r=h[6])&&c.push(new Rn(r,n,d,f,l,a,u)),(r=h[5])&&c.push(new Rn(r,l,o,f,s,d,u)),(r=h[4])&&c.push(new Rn(r,n,o,f,l,d,u)),(r=h[3])&&c.push(new Rn(r,l,d,i,s,a,f)),(r=h[2])&&c.push(new Rn(r,n,d,i,l,a,f)),(r=h[1])&&c.push(new Rn(r,l,o,i,s,d,f)),(r=h[0])&&c.push(new Rn(r,n,o,i,l,d,f))}return this},Vn.visitAfter=function(t){var e,r=[],n=[];for(this._root&&r.push(new Rn(this._root,this._x0,this._y0,this._z0,this._x1,this._y1,this._z1));e=r.pop();){var o=e.node;if(o.length){var i,s=e.x0,a=e.y0,u=e.z0,c=e.x1,h=e.y1,l=e.z1,d=(s+c)/2,f=(a+h)/2,g=(u+l)/2;(i=o[0])&&r.push(new Rn(i,s,a,u,d,f,g)),(i=o[1])&&r.push(new Rn(i,d,a,u,c,f,g)),(i=o[2])&&r.push(new Rn(i,s,f,u,d,h,g)),(i=o[3])&&r.push(new Rn(i,d,f,u,c,h,g)),(i=o[4])&&r.push(new Rn(i,s,a,g,d,f,l)),(i=o[5])&&r.push(new Rn(i,d,a,g,c,f,l)),(i=o[6])&&r.push(new Rn(i,s,f,g,d,h,l)),(i=o[7])&&r.push(new Rn(i,d,f,g,c,h,l))}n.push(e)}for(;e=n.pop();)t(e.node,e.x0,e.y0,e.z0,e.x1,e.y1,e.z1);return this},Vn.x=function(t){return arguments.length?(this._x=t,this):this._x},Vn.y=function(t){return arguments.length?(this._y=t,this):this._y},Vn.z=function(t){return arguments.length?(this._z=t,this):this._z};const Jn=4294967296;function Zn(t){return t.x}function to(t){return t.y}function eo(t){return t.z}var ro=Math.PI*(3-Math.sqrt(5)),no=20*Math.PI/(9+Math.sqrt(221));function oo(t,e){e=e||2;var r,n=Math.min(3,Math.max(1,Math.round(e))),o=1,i=.001,s=1-Math.pow(i,1/300),a=0,u=.6,c=new Map,h=un(f),l=Ur("tick","end"),d=function(){let t=1;return()=>(t=(1664525*t+1013904223)%Jn)/Jn}();function f(){g(),l.call("tick",r),o<i&&(h.stop(),l.call("end",r))}function g(e){var i,h,l=t.length;void 0===e&&(e=1);for(var d=0;d<e;++d)for(o+=(a-o)*s,c.forEach(function(t){t(o)}),i=0;i<l;++i)null==(h=t[i]).fx?h.x+=h.vx*=u:(h.x=h.fx,h.vx=0),n>1&&(null==h.fy?h.y+=h.vy*=u:(h.y=h.fy,h.vy=0)),n>2&&(null==h.fz?h.z+=h.vz*=u:(h.z=h.fz,h.vz=0));return r}function p(){for(var e,r=0,o=t.length;r<o;++r){if((e=t[r]).index=r,null!=e.fx&&(e.x=e.fx),null!=e.fy&&(e.y=e.fy),null!=e.fz&&(e.z=e.fz),isNaN(e.x)||n>1&&isNaN(e.y)||n>2&&isNaN(e.z)){var i=10*(n>2?Math.cbrt(.5+r):n>1?Math.sqrt(.5+r):r),s=r*ro,a=r*no;1===n?e.x=i:2===n?(e.x=i*Math.cos(s),e.y=i*Math.sin(s)):(e.x=i*Math.sin(s)*Math.cos(a),e.y=i*Math.cos(s),e.z=i*Math.sin(s)*Math.sin(a))}(isNaN(e.vx)||n>1&&isNaN(e.vy)||n>2&&isNaN(e.vz))&&(e.vx=0,n>1&&(e.vy=0),n>2&&(e.vz=0))}}function v(e){return e.initialize&&e.initialize(t,d,n),e}return null==t&&(t=[]),p(),r={tick:g,restart:function(){return h.restart(f),r},stop:function(){return h.stop(),r},numDimensions:function(t){return arguments.length?(n=Math.min(3,Math.max(1,Math.round(t))),c.forEach(v),r):n},nodes:function(e){return arguments.length?(t=e,p(),c.forEach(v),r):t},alpha:function(t){return arguments.length?(o=+t,r):o},alphaMin:function(t){return arguments.length?(i=+t,r):i},alphaDecay:function(t){return arguments.length?(s=+t,r):+s},alphaTarget:function(t){return arguments.length?(a=+t,r):a},velocityDecay:function(t){return arguments.length?(u=1-t,r):1-u},randomSource:function(t){return arguments.length?(d=t,c.forEach(v),r):d},force:function(t,e){return arguments.length>1?(null==e?c.delete(t):c.set(t,v(e)),r):c.get(t)},find:function(){var e,r,o,i,s,a,u=Array.prototype.slice.call(arguments),c=u.shift()||0,h=(n>1?u.shift():null)||0,l=(n>2?u.shift():null)||0,d=u.shift()||1/0,f=0,g=t.length;for(d*=d,f=0;f<g;++f)(i=(e=c-(s=t[f]).x)*e+(r=h-(s.y||0))*r+(o=l-(s.z||0))*o)<d&&(a=s,d=i);return a},on:function(t,e){return arguments.length>1?(l.on(t,e),r):l.on(t)}}}function io(){var t,e,r,n,o,i,s=$n(-30),a=1,u=1/0,c=.81;function h(n){var i,s=t.length,a=(1===e?On(t,Zn):2===e?jr(t,Zn,to):3===e?Dn(t,Zn,to,eo):null).visitAfter(d);for(o=n,i=0;i<s;++i)r=t[i],a.visit(f)}function l(){if(t){var e,r,n=t.length;for(i=new Array(n),e=0;e<n;++e)r=t[e],i[r.index]=+s(r,e,t)}}function d(t){var r,n,o,s,a,u,c=0,h=0,l=t.length;if(l){for(o=s=a=u=0;u<l;++u)(r=t[u])&&(n=Math.abs(r.value))&&(c+=r.value,h+=n,o+=n*(r.x||0),s+=n*(r.y||0),a+=n*(r.z||0));c*=Math.sqrt(4/l),t.x=o/h,e>1&&(t.y=s/h),e>2&&(t.z=a/h)}else{(r=t).x=r.data.x,e>1&&(r.y=r.data.y),e>2&&(r.z=r.data.z);do{c+=i[r.data.index]}while(r=r.next)}t.value=c}function f(t,s,h,l,d){if(!t.value)return!0;var f=[h,l,d][e-1],g=t.x-r.x,p=e>1?t.y-r.y:0,v=e>2?t.z-r.z:0,m=f-s,y=g*g+p*p+v*v;if(m*m/c<y)return y<u&&(0===g&&(y+=(g=Un(n))*g),e>1&&0===p&&(y+=(p=Un(n))*p),e>2&&0===v&&(y+=(v=Un(n))*v),y<a&&(y=Math.sqrt(a*y)),r.vx+=g*t.value*o/y,e>1&&(r.vy+=p*t.value*o/y),e>2&&(r.vz+=v*t.value*o/y)),!0;if(!(t.length||y>=u)){(t.data!==r||t.next)&&(0===g&&(y+=(g=Un(n))*g),e>1&&0===p&&(y+=(p=Un(n))*p),e>2&&0===v&&(y+=(v=Un(n))*v),y<a&&(y=Math.sqrt(a*y)));do{t.data!==r&&(m=i[t.data.index]*o/y,r.vx+=g*m,e>1&&(r.vy+=p*m),e>2&&(r.vz+=v*m))}while(t=t.next)}}return h.initialize=function(r,...o){t=r,n=o.find(t=>"function"==typeof t)||Math.random,e=o.find(t=>[1,2,3].includes(t))||2,l()},h.strength=function(t){return arguments.length?(s="function"==typeof t?t:$n(+t),l(),h):s},h.distanceMin=function(t){return arguments.length?(a=t*t,h):Math.sqrt(a)},h.distanceMax=function(t){return arguments.length?(u=t*t,h):Math.sqrt(u)},h.theta=function(t){return arguments.length?(c=t*t,h):Math.sqrt(c)},h}function so(t,e,r,n){var o,i,s,a,u=$n(.1);function c(t){for(var u=0,c=o.length;u<c;++u){var h=o[u],l=h.x-e||1e-6,d=(h.y||0)-r||1e-6,f=(h.z||0)-n||1e-6,g=Math.sqrt(l*l+d*d+f*f),p=(a[u]-g)*s[u]*t/g;h.vx+=l*p,i>1&&(h.vy+=d*p),i>2&&(h.vz+=f*p)}}function h(){if(o){var e,r=o.length;for(s=new Array(r),a=new Array(r),e=0;e<r;++e)a[e]=+t(o[e],e,o),s[e]=isNaN(a[e])?0:+u(o[e],e,o)}}return"function"!=typeof t&&(t=$n(+t)),null==e&&(e=0),null==r&&(r=0),null==n&&(n=0),c.initialize=function(t,...e){o=t,i=e.find(t=>[1,2,3].includes(t))||2,h()},c.strength=function(t){return arguments.length?(u="function"==typeof t?t:$n(+t),h(),c):u},c.radius=function(e){return arguments.length?(t="function"==typeof e?e:$n(+e),h(),c):t},c.x=function(t){return arguments.length?(e=+t,c):e},c.y=function(t){return arguments.length?(r=+t,c):r},c.z=function(t){return arguments.length?(n=+t,c):n},c}function ao(t){var e,r,n,o=$n(.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=$n(null==t?0:+t)),i.initialize=function(t){e=t,s()},i.strength=function(t){return arguments.length?(o="function"==typeof t?t:$n(+t),s(),i):o},i.x=function(e){return arguments.length?(t="function"==typeof e?e:$n(+e),s(),i):t},i}function uo(t){var e,r,n,o=$n(.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=$n(null==t?0:+t)),i.initialize=function(t){e=t,s()},i.strength=function(t){return arguments.length?(o="function"==typeof t?t:$n(+t),s(),i):o},i.y=function(e){return arguments.length?(t="function"==typeof e?e:$n(+e),s(),i):t},i}function co(t){var e,r,n,o=$n(.1);function i(t){for(var o,i=0,s=e.length;i<s;++i)(o=e[i]).vz+=(n[i]-o.z)*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=$n(null==t?0:+t)),i.initialize=function(t){e=t,s()},i.strength=function(t){return arguments.length?(o="function"==typeof t?t:$n(+t),s(),i):o},i.z=function(e){return arguments.length?(t="function"==typeof e?e:$n(+e),s(),i):t},i}var ho,lo,fo,go,po,vo,mo,yo,wo,xo,bo,Eo,Mo,No,_o,ko,So,Ao,Oo,zo,jo,Co,Io,Ro,To,Po,Fo,Lo,Do,qo,Bo,Vo,$o,Uo,Go,Wo,Yo,Ho,Xo,Qo,Ko,Jo,Zo,ti,ei,ri,ni,oi,ii,si,ai,ui,ci,hi,li,di,fi,gi,pi,vi,mi,yi,wi,xi,bi,Ei,Mi,Ni,_i,ki,Si,Ai,Oi,zi,ji,Ci,Ii,Ri,Ti,Pi,Fi,Li,Di,qi,Bi,Vi,$i,Ui,Gi,Wi,Yi,Hi,Xi,Qi,Ki,Ji,Zi,ts,es,rs,ns,os,is,ss,as,us,cs,hs,ls="undefined"!=typeof globalThis?globalThis:"undefined"!=typeof window?window:"undefined"!=typeof global?global:"undefined"!=typeof self?self:{};function ds(t){return t&&t.__esModule&&Object.prototype.hasOwnProperty.call(t,"default")?t.default:t}function fs(t){if(Object.prototype.hasOwnProperty.call(t,"__esModule"))return t;var e=t.default;if("function"==typeof e){var r=function t(){var r=!1;try{r=this instanceof t}catch{}return r?Reflect.construct(e,arguments,this.constructor):e.apply(this,arguments)};r.prototype=e.prototype}else r={};return Object.defineProperty(r,"__esModule",{value:!0}),Object.keys(t).forEach(function(e){var n=Object.getOwnPropertyDescriptor(t,e);Object.defineProperty(r,e,n.get?n:{enumerable:!0,get:function(){return t[e]}})}),r}function gs(){if(go)return fo;return go=1,fo=function(t,e){return t===e||t!=t&&e!=e}}function ps(){if(vo)return po;vo=1;var t=gs();return po=function(e,r){for(var n=e.length;n--;)if(t(e[n][0],r))return n;return-1}}function vs(){if(ko)return _o;ko=1;var t=lo?ho:(lo=1,ho=function(){this.__data__=[],this.size=0}),e=function(){if(yo)return mo;yo=1;var t=ps(),e=Array.prototype.splice;return mo=function(r){var n=this.__data__,o=t(n,r);return!(o<0||(o==n.length-1?n.pop():e.call(n,o,1),--this.size,0))},mo}(),r=function(){if(xo)return wo;xo=1;var t=ps();return wo=function(e){var r=this.__data__,n=t(r,e);return n<0?void 0:r[n][1]},wo}(),n=function(){if(Eo)return bo;Eo=1;var t=ps();return bo=function(e){return t(this.__data__,e)>-1}}(),o=function(){if(No)return Mo;No=1;var t=ps();return Mo=function(e,r){var n=this.__data__,o=t(n,e);return o<0?(++this.size,n.push([e,r])):n[o][1]=r,this},Mo}();function i(t){var e=-1,r=null==t?0:t.length;for(this.clear();++e<r;){var n=t[e];this.set(n[0],n[1])}}return i.prototype.clear=t,i.prototype.delete=e,i.prototype.get=r,i.prototype.has=n,i.prototype.set=o,_o=i}function ms(){if(Po)return To;Po=1;var t="object"==typeof ls&&ls&&ls.Object===Object&&ls;return To=t}function ys(){if(Lo)return Fo;Lo=1;var t=ms(),e="object"==typeof self&&self&&self.Object===Object&&self,r=t||e||Function("return this")();return Fo=r}function ws(){if(qo)return Do;qo=1;var t=ys().Symbol;return Do=t}function xs(){if(Wo)return Go;Wo=1;var t=ws(),e=function(){if(Vo)return Bo;Vo=1;var t=ws(),e=Object.prototype,r=e.hasOwnProperty,n=e.toString,o=t?t.toStringTag:void 0;return Bo=function(t){var e=r.call(t,o),i=t[o];try{t[o]=void 0;var s=!0}catch(t){}var a=n.call(t);return s&&(e?t[o]=i:delete t[o]),a}}(),r=function(){if(Uo)return $o;Uo=1;var t=Object.prototype.toString;return $o=function(e){return t.call(e)}}(),n=t?t.toStringTag:void 0;return Go=function(t){return null==t?void 0===t?"[object Undefined]":"[object Null]":n&&n in Object(t)?e(t):r(t)}}function bs(){if(Ho)return Yo;return Ho=1,Yo=function(t){var e=typeof t;return null!=t&&("object"==e||"function"==e)}}function Es(){if(Qo)return Xo;Qo=1;var t=xs(),e=bs();return Xo=function(r){if(!e(r))return!1;var n=t(r);return"[object Function]"==n||"[object GeneratorFunction]"==n||"[object AsyncFunction]"==n||"[object Proxy]"==n}}function Ms(){if(ti)return Zo;ti=1;var t,e=function(){if(Jo)return Ko;Jo=1;var t=ys()["__core-js_shared__"];return Ko=t}(),r=(t=/[^.]+$/.exec(e&&e.keys&&e.keys.IE_PROTO||""))?"Symbol(src)_1."+t:"";return Zo=function(t){return!!r&&r in t}}function Ns(){if(ri)return ei;ri=1;var t=Function.prototype.toString;return ei=function(e){if(null!=e){try{return t.call(e)}catch(t){}try{return e+""}catch(t){}}return""}}function _s(){if(ui)return ai;ui=1;var t=function(){if(oi)return ni;oi=1;var t=Es(),e=Ms(),r=bs(),n=Ns(),o=/^\[object .+?Constructor\]$/,i=Function.prototype,s=Object.prototype,a=i.toString,u=s.hasOwnProperty,c=RegExp("^"+a.call(u).replace(/[\\^$.*+?()[\]{}|]/g,"\\$&").replace(/hasOwnProperty|(function).*?(?=\\\()| for .+?(?=\\\])/g,"$1.*?")+"$");return ni=function(i){return!(!r(i)||e(i))&&(t(i)?c:o).test(n(i))}}(),e=si?ii:(si=1,ii=function(t,e){return null==t?void 0:t[e]});return ai=function(r,n){var o=e(r,n);return t(o)?o:void 0}}function ks(){if(hi)return ci;hi=1;var t=_s()(ys(),"Map");return ci=t}function Ss(){if(di)return li;di=1;var t=_s()(Object,"create");return li=t}function As(){if(Ni)return Mi;Ni=1;var t=function(){if(gi)return fi;gi=1;var t=Ss();return fi=function(){this.__data__=t?t(null):{},this.size=0}}(),e=vi?pi:(vi=1,pi=function(t){var e=this.has(t)&&delete this.__data__[t];return this.size-=e?1:0,e}),r=function(){if(yi)return mi;yi=1;var t=Ss(),e=Object.prototype.hasOwnProperty;return mi=function(r){var n=this.__data__;if(t){var o=n[r];return"__lodash_hash_undefined__"===o?void 0:o}return e.call(n,r)?n[r]:void 0}}(),n=function(){if(xi)return wi;xi=1;var t=Ss(),e=Object.prototype.hasOwnProperty;return wi=function(r){var n=this.__data__;return t?void 0!==n[r]:e.call(n,r)}}(),o=function(){if(Ei)return bi;Ei=1;var t=Ss();return bi=function(e,r){var n=this.__data__;return this.size+=this.has(e)?0:1,n[e]=t&&void 0===r?"__lodash_hash_undefined__":r,this}}();function i(t){var e=-1,r=null==t?0:t.length;for(this.clear();++e<r;){var n=t[e];this.set(n[0],n[1])}}return i.prototype.clear=t,i.prototype.delete=e,i.prototype.get=r,i.prototype.has=n,i.prototype.set=o,Mi=i}function Os(){if(zi)return Oi;zi=1;var t=Ai?Si:(Ai=1,Si=function(t){var e=typeof t;return"string"==e||"number"==e||"symbol"==e||"boolean"==e?"__proto__"!==t:null===t});return Oi=function(e,r){var n=e.__data__;return t(r)?n["string"==typeof r?"string":"hash"]:n.map}}function zs(){if(qi)return Di;qi=1;var t=function(){if(ki)return _i;ki=1;var t=As(),e=vs(),r=ks();return _i=function(){this.size=0,this.__data__={hash:new t,map:new(r||e),string:new t}}}(),e=function(){if(Ci)return ji;Ci=1;var t=Os();return ji=function(e){var r=t(this,e).delete(e);return this.size-=r?1:0,r}}(),r=function(){if(Ri)return Ii;Ri=1;var t=Os();return Ii=function(e){return t(this,e).get(e)}}(),n=function(){if(Pi)return Ti;Pi=1;var t=Os();return Ti=function(e){return t(this,e).has(e)}}(),o=function(){if(Li)return Fi;Li=1;var t=Os();return Fi=function(e,r){var n=t(this,e),o=n.size;return n.set(e,r),this.size+=n.size==o?0:1,this}}();function i(t){var e=-1,r=null==t?0:t.length;for(this.clear();++e<r;){var n=t[e];this.set(n[0],n[1])}}return i.prototype.clear=t,i.prototype.delete=e,i.prototype.get=r,i.prototype.has=n,i.prototype.set=o,Di=i}function js(){if(Ui)return $i;Ui=1;var t=vs(),e=function(){if(Ao)return So;Ao=1;var t=vs();return So=function(){this.__data__=new t,this.size=0}}(),r=zo?Oo:(zo=1,Oo=function(t){var e=this.__data__,r=e.delete(t);return this.size=e.size,r}),n=Co?jo:(Co=1,jo=function(t){return this.__data__.get(t)}),o=Ro?Io:(Ro=1,Io=function(t){return this.__data__.has(t)}),i=function(){if(Vi)return Bi;Vi=1;var t=vs(),e=ks(),r=zs();return Bi=function(n,o){var i=this.__data__;if(i instanceof t){var s=i.__data__;if(!e||s.length<199)return s.push([n,o]),this.size=++i.size,this;i=this.__data__=new r(s)}return i.set(n,o),this.size=i.size,this}}();function s(e){var r=this.__data__=new t(e);this.size=r.size}return s.prototype.clear=e,s.prototype.delete=r,s.prototype.get=n,s.prototype.has=o,s.prototype.set=i,$i=s}function Cs(){if(Wi)return Gi;return Wi=1,Gi=function(t,e){for(var r=-1,n=null==t?0:t.length;++r<n&&!1!==e(t[r],r,t););return t},Gi}function Is(){if(Hi)return Yi;Hi=1;var t=_s(),e=function(){try{var e=t(Object,"defineProperty");return e({},"",{}),e}catch(t){}}();return Yi=e}function Rs(){if(Qi)return Xi;Qi=1;var t=Is();return Xi=function(e,r,n){"__proto__"==r&&t?t(e,r,{configurable:!0,enumerable:!0,value:n,writable:!0}):e[r]=n}}function Ts(){if(Ji)return Ki;Ji=1;var t=Rs(),e=gs(),r=Object.prototype.hasOwnProperty;return Ki=function(n,o,i){var s=n[o];r.call(n,o)&&e(s,i)&&(void 0!==i||o in n)||t(n,o,i)}}function Ps(){if(ts)return Zi;ts=1;var t=Ts(),e=Rs();return Zi=function(r,n,o,i){var s=!o;o||(o={});for(var a=-1,u=n.length;++a<u;){var c=n[a],h=i?i(o[c],r[c],c,o,r):void 0;void 0===h&&(h=r[c]),s?e(o,c,h):t(o,c,h)}return o},Zi}function Fs(){if(os)return ns;return os=1,ns=function(t){return null!=t&&"object"==typeof t}}function Ls(){if(us)return as;us=1;var t=function(){if(ss)return is;ss=1;var t=xs(),e=Fs();return is=function(r){return e(r)&&"[object Arguments]"==t(r)}}(),e=Fs(),r=Object.prototype,n=r.hasOwnProperty,o=r.propertyIsEnumerable,i=t(function(){return arguments}())?t:function(t){return e(t)&&n.call(t,"callee")&&!o.call(t,"callee")};return as=i}function Ds(){if(hs)return cs;hs=1;var t=Array.isArray;return cs=t}var qs,Bs,Vs,$s,Us,Gs,Ws,Ys,Hs,Xs,Qs,Ks={exports:{}};function Js(){return Vs||(Vs=1,function(t,e){var r=ys(),n=Bs?qs:(Bs=1,qs=function(){return!1}),o=e&&!e.nodeType&&e,i=o&&t&&!t.nodeType&&t,s=i&&i.exports===o?r.Buffer:void 0,a=(s?s.isBuffer:void 0)||n;t.exports=a}(Ks,Ks.exports)),Ks.exports}function Zs(){if(Us)return $s;Us=1;var t=/^(?:0|[1-9]\d*)$/;return $s=function(e,r){var n=typeof e;return!!(r=null==r?9007199254740991:r)&&("number"==n||"symbol"!=n&&t.test(e))&&e>-1&&e%1==0&&e<r}}function ta(){if(Ws)return Gs;Ws=1;return Gs=function(t){return"number"==typeof t&&t>-1&&t%1==0&&t<=9007199254740991}}function ea(){if(Qs)return Xs;return Qs=1,Xs=function(t){return function(e){return t(e)}}}var ra,na,oa,ia,sa,aa,ua,ca,ha,la,da,fa,ga,pa,va,ma,ya,wa,xa,ba,Ea,Ma,Na,_a,ka,Sa,Aa,Oa={exports:{}};function za(){return ra||(ra=1,t=Oa,e=Oa.exports,r=ms(),n=e&&!e.nodeType&&e,o=n&&t&&!t.nodeType&&t,i=o&&o.exports===n&&r.process,s=function(){try{var t=o&&o.require&&o.require("util").types;return t||i&&i.binding&&i.binding("util")}catch(t){}}(),t.exports=s),Oa.exports;var t,e,r,n,o,i,s}function ja(){if(oa)return na;oa=1;var t=function(){if(Hs)return Ys;Hs=1;var t=xs(),e=ta(),r=Fs(),n={};return n["[object Float32Array]"]=n["[object Float64Array]"]=n["[object Int8Array]"]=n["[object Int16Array]"]=n["[object Int32Array]"]=n["[object Uint8Array]"]=n["[object Uint8ClampedArray]"]=n["[object Uint16Array]"]=n["[object Uint32Array]"]=!0,n["[object Arguments]"]=n["[object Array]"]=n["[object ArrayBuffer]"]=n["[object Boolean]"]=n["[object DataView]"]=n["[object Date]"]=n["[object Error]"]=n["[object Function]"]=n["[object Map]"]=n["[object Number]"]=n["[object Object]"]=n["[object RegExp]"]=n["[object Set]"]=n["[object String]"]=n["[object WeakMap]"]=!1,Ys=function(o){return r(o)&&e(o.length)&&!!n[t(o)]}}(),e=ea(),r=za(),n=r&&r.isTypedArray,o=n?e(n):t;return na=o}function Ca(){if(sa)return ia;sa=1;var t=(rs||(rs=1,es=function(t,e){for(var r=-1,n=Array(t);++r<t;)n[r]=e(r);return n}),es),e=Ls(),r=Ds(),n=Js(),o=Zs(),i=ja(),s=Object.prototype.hasOwnProperty;return ia=function(a,u){var c=r(a),h=!c&&e(a),l=!c&&!h&&n(a),d=!c&&!h&&!l&&i(a),f=c||h||l||d,g=f?t(a.length,String):[],p=g.length;for(var v in a)!u&&!s.call(a,v)||f&&("length"==v||l&&("offset"==v||"parent"==v)||d&&("buffer"==v||"byteLength"==v||"byteOffset"==v)||o(v,p))||g.push(v);return g},ia}function Ia(){if(ua)return aa;ua=1;var t=Object.prototype;return aa=function(e){var r=e&&e.constructor;return e===("function"==typeof r&&r.prototype||t)}}function Ra(){if(ha)return ca;return ha=1,ca=function(t,e){return function(r){return t(e(r))}}}function Ta(){if(ga)return fa;ga=1;var t=Ia(),e=function(){if(da)return la;da=1;var t=Ra()(Object.keys,Object);return la=t}(),r=Object.prototype.hasOwnProperty;return fa=function(n){if(!t(n))return e(n);var o=[];for(var i in Object(n))r.call(n,i)&&"constructor"!=i&&o.push(i);return o}}function Pa(){if(va)return pa;va=1;var t=Es(),e=ta();return pa=function(r){return null!=r&&e(r.length)&&!t(r)}}function Fa(){if(ya)return ma;ya=1;var t=Ca(),e=Ta(),r=Pa();return ma=function(n){return r(n)?t(n):e(n)}}function La(){if(Na)return Ma;Na=1;var t=bs(),e=Ia(),r=Ea?ba:(Ea=1,ba=function(t){var e=[];if(null!=t)for(var r in Object(t))e.push(r);return e}),n=Object.prototype.hasOwnProperty;return Ma=function(o){if(!t(o))return r(o);var i=e(o),s=[];for(var a in o)("constructor"!=a||!i&&n.call(o,a))&&s.push(a);return s}}function Da(){if(ka)return _a;ka=1;var t=Ca(),e=La(),r=Pa();return _a=function(n){return r(n)?t(n,!0):e(n)}}var qa,Ba,Va,$a,Ua,Ga,Wa,Ya,Ha,Xa,Qa,Ka,Ja,Za,tu,eu,ru,nu,ou,iu,su,au,uu,cu,hu,lu,du,fu,gu,pu,vu,mu,yu,wu,xu,bu,Eu,Mu,Nu,_u,ku,Su,Au,Ou,zu,ju,Cu,Iu,Ru,Tu,Pu,Fu,Lu,Du,qu,Bu,Vu,$u,Uu,Gu,Wu,Yu,Hu,Xu,Qu,Ku,Ju,Zu,tc,ec,rc,nc,oc,ic,sc,ac,uc,cc,hc,lc,dc,fc,gc,pc,vc,mc,yc,wc,xc,bc,Ec,Mc,Nc,_c,kc,Sc,Ac,Oc,zc,jc,Cc,Ic,Rc,Tc,Pc,Fc,Lc,Dc,qc,Bc,Vc,$c,Uc,Gc,Wc,Yc,Hc,Xc,Qc,Kc,Jc,Zc,th,eh,rh,nh,oh,ih,sh,ah,uh,ch,hh,lh,dh,fh,gh,ph,vh,mh,yh,wh,xh,bh,Eh,Mh,Nh,_h,kh,Sh,Ah,Oh,zh,jh,Ch,Ih,Rh,Th,Ph,Fh,Lh,Dh,qh,Bh,Vh,$h,Uh,Gh,Wh,Yh,Hh,Xh,Qh,Kh,Jh,Zh,tl,el,rl,nl,ol,il,sl,al,ul,cl,hl,ll,dl,fl,gl,pl,vl,ml,yl,wl,xl,bl,El,Ml,Nl,_l,kl,Sl,Al,Ol,zl,jl,Cl,Il,Rl,Tl,Pl,Fl,Ll,Dl,ql,Bl,Vl,$l,Ul,Gl,Wl,Yl,Hl,Xl,Ql,Kl,Jl,Zl,td,ed,rd,nd,od,id,sd,ad,ud,cd,hd,ld,dd,fd,gd,pd,vd,md,yd,wd,xd,bd,Ed,Md,Nd,_d,kd,Sd,Ad,Od,zd,jd,Cd,Id,Rd,Td,Pd,Fd,Ld,Dd,qd,Bd,Vd,$d,Ud,Gd,Wd,Yd,Hd,Xd,Qd,Kd,Jd,Zd,tf,ef,rf,nf,of,sf,af,uf,cf,hf,lf,df,ff,gf,pf,vf,mf,yf,wf,xf,bf,Ef,Mf,Nf,_f,kf,Sf,Af,Of,zf,jf,Cf,If,Rf,Tf,Pf,Ff,Lf,Df,qf,Bf,Vf,$f,Uf,Gf,Wf,Yf,Hf,Xf,Qf,Kf,Jf,Zf,tg,eg,rg,ng,og,ig,sg,ag,ug,cg,hg,lg,dg,fg,gg,pg,vg,mg,yg,wg,xg,bg,Eg,Mg,Ng,_g,kg,Sg,Ag,Og,zg,jg,Cg,Ig,Rg,Tg,Pg,Fg,Lg,Dg,qg,Bg,Vg,$g,Ug,Gg,Wg,Yg,Hg,Xg,Qg,Kg,Jg,Zg,tp,ep,rp,np,op,ip,sp,ap,up,cp,hp,lp,dp,fp,gp,pp,vp,mp,yp,wp,xp,bp,Ep,Mp,Np,_p,kp,Sp,Ap,Op,zp,jp,Cp,Ip,Rp,Tp,Pp,Fp,Lp,Dp,qp={exports:{}};function Bp(){return qa||(qa=1,t=qp,e=qp.exports,r=ys(),n=e&&!e.nodeType&&e,o=n&&t&&!t.nodeType&&t,i=o&&o.exports===n?r.Buffer:void 0,s=i?i.allocUnsafe:void 0,t.exports=function(t,e){if(e)return t.slice();var r=t.length,n=s?s(r):new t.constructor(r);return t.copy(n),n}),qp.exports;var t,e,r,n,o,i,s}function Vp(){if(Va)return Ba;return Va=1,Ba=function(t,e){var r=-1,n=t.length;for(e||(e=Array(n));++r<n;)e[r]=t[r];return e},Ba}function $p(){if(Ua)return $a;return Ua=1,$a=function(t,e){for(var r=-1,n=null==t?0:t.length,o=0,i=[];++r<n;){var s=t[r];e(s,r,t)&&(i[o++]=s)}return i},$a}function Up(){if(Wa)return Ga;return Wa=1,Ga=function(){return[]}}function Gp(){if(Ha)return Ya;Ha=1;var t=$p(),e=Up(),r=Object.prototype.propertyIsEnumerable,n=Object.getOwnPropertySymbols;return Ya=n?function(e){return null==e?[]:(e=Object(e),t(n(e),function(t){return r.call(e,t)}))}:e}function Wp(){if(Ja)return Ka;return Ja=1,Ka=function(t,e){for(var r=-1,n=e.length,o=t.length;++r<n;)t[o+r]=e[r];return t},Ka}function Yp(){if(tu)return Za;tu=1;var t=Ra()(Object.getPrototypeOf,Object);return Za=t}function Hp(){if(ru)return eu;ru=1;var t=Wp(),e=Yp(),r=Gp(),n=Up(),o=Object.getOwnPropertySymbols;return eu=o?function(n){for(var o=[];n;)t(o,r(n)),n=e(n);return o}:n}function Xp(){if(su)return iu;su=1;var t=Wp(),e=Ds();return iu=function(r,n,o){var i=n(r);return e(r)?i:t(i,o(r))}}function Qp(){if(uu)return au;uu=1;var t=Xp(),e=Gp(),r=Fa();return au=function(n){return t(n,r,e)}}function Kp(){if(vu)return pu;vu=1;var t=_s()(ys(),"Set");return pu=t}function Jp(){if(xu)return wu;xu=1;var t=function(){if(du)return lu;du=1;var t=_s()(ys(),"DataView");return lu=t}(),e=ks(),r=function(){if(gu)return fu;gu=1;var t=_s()(ys(),"Promise");return fu=t}(),n=Kp(),o=function(){if(yu)return mu;yu=1;var t=_s()(ys(),"WeakMap");return mu=t}(),i=xs(),s=Ns(),a="[object Map]",u="[object Promise]",c="[object Set]",h="[object WeakMap]",l="[object DataView]",d=s(t),f=s(e),g=s(r),p=s(n),v=s(o),m=i;return(t&&m(new t(new ArrayBuffer(1)))!=l||e&&m(new e)!=a||r&&m(r.resolve())!=u||n&&m(new n)!=c||o&&m(new o)!=h)&&(m=function(t){var e=i(t),r="[object Object]"==e?t.constructor:void 0,n=r?s(r):"";if(n)switch(n){case d:return l;case f:return a;case g:return u;case p:return c;case v:return h}return e}),wu=m}function Zp(){if(Nu)return Mu;Nu=1;var t=ys().Uint8Array;return Mu=t}function tv(){if(ku)return _u;ku=1;var t=Zp();return _u=function(e){var r=new e.constructor(e.byteLength);return new t(r).set(new t(e)),r}}function ev(){if(Ru)return Iu;Ru=1;var t=tv();return Iu=function(e,r){var n=r?t(e.buffer):e.buffer;return new e.constructor(n,e.byteOffset,e.length)}}function rv(){if(Pu)return Tu;Pu=1;var t=tv(),e=function(){if(Au)return Su;Au=1;var t=tv();return Su=function(e,r){var n=r?t(e.buffer):e.buffer;return new e.constructor(n,e.byteOffset,e.byteLength)}}(),r=function(){if(zu)return Ou;zu=1;var t=/\w*$/;return Ou=function(e){var r=new e.constructor(e.source,t.exec(e));return r.lastIndex=e.lastIndex,r}}(),n=function(){if(Cu)return ju;Cu=1;var t=ws(),e=t?t.prototype:void 0,r=e?e.valueOf:void 0;return ju=function(t){return r?Object(r.call(t)):{}}}(),o=ev();return Tu=function(i,s,a){var u=i.constructor;switch(s){case"[object ArrayBuffer]":return t(i);case"[object Boolean]":case"[object Date]":return new u(+i);case"[object DataView]":return e(i,a);case"[object Float32Array]":case"[object Float64Array]":case"[object Int8Array]":case"[object Int16Array]":case"[object Int32Array]":case"[object Uint8Array]":case"[object Uint8ClampedArray]":case"[object Uint16Array]":case"[object Uint32Array]":return o(i,a);case"[object Map]":case"[object Set]":return new u;case"[object Number]":case"[object String]":return new u(i);case"[object RegExp]":return r(i);case"[object Symbol]":return n(i)}}}function nv(){if(Lu)return Fu;Lu=1;var t=bs(),e=Object.create,r=function(){function r(){}return function(n){if(!t(n))return{};if(e)return e(n);r.prototype=n;var o=new r;return r.prototype=void 0,o}}();return Fu=r}function ov(){if(qu)return Du;qu=1;var t=nv(),e=Yp(),r=Ia();return Du=function(n){return"function"!=typeof n.constructor||r(n)?{}:t(e(n))}}function iv(){if(Uu)return $u;Uu=1;var t=function(){if(Vu)return Bu;Vu=1;var t=Jp(),e=Fs();return Bu=function(r){return e(r)&&"[object Map]"==t(r)}}(),e=ea(),r=za(),n=r&&r.isMap,o=n?e(n):t;return $u=o}function sv(){if(Hu)return Yu;Hu=1;var t=function(){if(Wu)return Gu;Wu=1;var t=Jp(),e=Fs();return Gu=function(r){return e(r)&&"[object Set]"==t(r)}}(),e=ea(),r=za(),n=r&&r.isSet,o=n?e(n):t;return Yu=o}function av(){if(Qu)return Xu;Qu=1;var t=js(),e=Cs(),r=Ts(),n=function(){if(xa)return wa;xa=1;var t=Ps(),e=Fa();return wa=function(r,n){return r&&t(n,e(n),r)}}(),o=function(){if(Aa)return Sa;Aa=1;var t=Ps(),e=Da();return Sa=function(r,n){return r&&t(n,e(n),r)}}(),i=Bp(),s=Vp(),a=function(){if(Qa)return Xa;Qa=1;var t=Ps(),e=Gp();return Xa=function(r,n){return t(r,e(r),n)}}(),u=function(){if(ou)return nu;ou=1;var t=Ps(),e=Hp();return nu=function(r,n){return t(r,e(r),n)}}(),c=Qp(),h=function(){if(hu)return cu;hu=1;var t=Xp(),e=Hp(),r=Da();return cu=function(n){return t(n,r,e)}}(),l=Jp(),d=function(){if(Eu)return bu;Eu=1;var t=Object.prototype.hasOwnProperty;return bu=function(e){var r=e.length,n=new e.constructor(r);return r&&"string"==typeof e[0]&&t.call(e,"index")&&(n.index=e.index,n.input=e.input),n}}(),f=rv(),g=ov(),p=Ds(),v=Js(),m=iv(),y=bs(),w=sv(),x=Fa(),b=Da(),E="[object Arguments]",M="[object Function]",N="[object Object]",_={};return _[E]=_["[object Array]"]=_["[object ArrayBuffer]"]=_["[object DataView]"]=_["[object Boolean]"]=_["[object Date]"]=_["[object Float32Array]"]=_["[object Float64Array]"]=_["[object Int8Array]"]=_["[object Int16Array]"]=_["[object Int32Array]"]=_["[object Map]"]=_["[object Number]"]=_[N]=_["[object RegExp]"]=_["[object Set]"]=_["[object String]"]=_["[object Symbol]"]=_["[object Uint8Array]"]=_["[object Uint8ClampedArray]"]=_["[object Uint16Array]"]=_["[object Uint32Array]"]=!0,_["[object Error]"]=_[M]=_["[object WeakMap]"]=!1,Xu=function k(S,A,O,z,j,C){var I,R=1&A,T=2&A,P=4&A;if(O&&(I=j?O(S,z,j,C):O(S)),void 0!==I)return I;if(!y(S))return S;var F=p(S);if(F){if(I=d(S),!R)return s(S,I)}else{var L=l(S),D=L==M||"[object GeneratorFunction]"==L;if(v(S))return i(S,R);if(L==N||L==E||D&&!j){if(I=T||D?{}:g(S),!R)return T?u(S,o(I,S)):a(S,n(I,S))}else{if(!_[L])return j?S:{};I=f(S,L,R)}}C||(C=new t);var q=C.get(S);if(q)return q;C.set(S,I),w(S)?S.forEach(function(t){I.add(k(t,A,O,t,S,C))}):m(S)&&S.forEach(function(t,e){I.set(e,k(t,A,O,e,S,C))});var B=F?void 0:(P?T?h:c:T?b:x)(S);return e(B||S,function(t,e){B&&(t=S[e=t]),r(I,e,k(t,A,O,e,S,C))}),I},Xu}function uv(){if(Ju)return Ku;Ju=1;var t=av();return Ku=function(e){return t(e,4)}}function cv(){if(tc)return Zu;return tc=1,Zu=function(t){return function(){return t}}}function hv(){if(oc)return nc;oc=1;var t=(rc||(rc=1,ec=function(t){return function(e,r,n){for(var o=-1,i=Object(e),s=n(e),a=s.length;a--;){var u=s[t?a:++o];if(!1===r(i[u],u,i))break}return e}}),ec),e=t();return nc=e}function lv(){if(sc)return ic;sc=1;var t=hv(),e=Fa();return ic=function(r,n){return r&&t(r,n,e)}}function dv(){if(hc)return cc;hc=1;var t=lv(),e=function(){if(uc)return ac;uc=1;var t=Pa();return ac=function(e,r){return function(n,o){if(null==n)return n;if(!t(n))return e(n,o);for(var i=n.length,s=r?i:-1,a=Object(n);(r?s--:++s<i)&&!1!==o(a[s],s,a););return n}},ac}(),r=e(t);return cc=r}function fv(){if(dc)return lc;return dc=1,lc=function(t){return t}}function gv(){if(gc)return fc;gc=1;var t=fv();return fc=function(e){return"function"==typeof e?e:t}}function pv(){if(vc)return pc;vc=1;var t=Cs(),e=dv(),r=gv(),n=Ds();return pc=function(o,i){return(n(o)?t:e)(o,r(i))}}function vv(){return yc?mc:(yc=1,mc=pv())}function mv(){if(kc)return _c;kc=1;var t=zs(),e=Ec?bc:(Ec=1,bc=function(t){return this.__data__.set(t,"__lodash_hash_undefined__"),this}),r=Nc?Mc:(Nc=1,Mc=function(t){return this.__data__.has(t)});function n(e){var r=-1,n=null==e?0:e.length;for(this.__data__=new t;++r<n;)this.add(e[r])}return n.prototype.add=n.prototype.push=e,n.prototype.has=r,_c=n}function yv(){if(zc)return Oc;return zc=1,Oc=function(t,e){return t.has(e)}}function wv(){if(Cc)return jc;Cc=1;var t=mv(),e=(Ac||(Ac=1,Sc=function(t,e){for(var r=-1,n=null==t?0:t.length;++r<n;)if(e(t[r],r,t))return!0;return!1}),Sc),r=yv();return jc=function(n,o,i,s,a,u){var c=1&i,h=n.length,l=o.length;if(h!=l&&!(c&&l>h))return!1;var d=u.get(n),f=u.get(o);if(d&&f)return d==o&&f==n;var g=-1,p=!0,v=2&i?new t:void 0;for(u.set(n,o),u.set(o,n);++g<h;){var m=n[g],y=o[g];if(s)var w=c?s(y,m,g,o,n,u):s(m,y,g,n,o,u);if(void 0!==w){if(w)continue;p=!1;break}if(v){if(!e(o,function(t,e){if(!r(v,e)&&(m===t||a(m,t,i,s,u)))return v.push(e)})){p=!1;break}}else if(m!==y&&!a(m,y,i,s,u)){p=!1;break}}return u.delete(n),u.delete(o),p},jc}function xv(){if(Pc)return Tc;return Pc=1,Tc=function(t){var e=-1,r=Array(t.size);return t.forEach(function(t){r[++e]=t}),r},Tc}function bv(){if(Lc)return Fc;Lc=1;var t=ws(),e=Zp(),r=gs(),n=wv(),o=(Rc||(Rc=1,Ic=function(t){var e=-1,r=Array(t.size);return t.forEach(function(t,n){r[++e]=[n,t]}),r}),Ic),i=xv(),s=t?t.prototype:void 0,a=s?s.valueOf:void 0;return Fc=function(t,s,u,c,h,l,d){switch(u){case"[object DataView]":if(t.byteLength!=s.byteLength||t.byteOffset!=s.byteOffset)return!1;t=t.buffer,s=s.buffer;case"[object ArrayBuffer]":return!(t.byteLength!=s.byteLength||!l(new e(t),new e(s)));case"[object Boolean]":case"[object Date]":case"[object Number]":return r(+t,+s);case"[object Error]":return t.name==s.name&&t.message==s.message;case"[object RegExp]":case"[object String]":return t==s+"";case"[object Map]":var f=o;case"[object Set]":var g=1&c;if(f||(f=i),t.size!=s.size&&!g)return!1;var p=d.get(t);if(p)return p==s;c|=2,d.set(t,s);var v=n(f(t),f(s),c,h,l,d);return d.delete(t),v;case"[object Symbol]":if(a)return a.call(t)==a.call(s)}return!1}}function Ev(){if(Vc)return Bc;Vc=1;var t=js(),e=wv(),r=bv(),n=function(){if(qc)return Dc;qc=1;var t=Qp(),e=Object.prototype.hasOwnProperty;return Dc=function(r,n,o,i,s,a){var u=1&o,c=t(r),h=c.length;if(h!=t(n).length&&!u)return!1;for(var l=h;l--;){var d=c[l];if(!(u?d in n:e.call(n,d)))return!1}var f=a.get(r),g=a.get(n);if(f&&g)return f==n&&g==r;var p=!0;a.set(r,n),a.set(n,r);for(var v=u;++l<h;){var m=r[d=c[l]],y=n[d];if(i)var w=u?i(y,m,d,n,r,a):i(m,y,d,r,n,a);if(!(void 0===w?m===y||s(m,y,o,i,a):w)){p=!1;break}v||(v="constructor"==d)}if(p&&!v){var x=r.constructor,b=n.constructor;x==b||!("constructor"in r)||!("constructor"in n)||"function"==typeof x&&x instanceof x&&"function"==typeof b&&b instanceof b||(p=!1)}return a.delete(r),a.delete(n),p},Dc}(),o=Jp(),i=Ds(),s=Js(),a=ja(),u="[object Arguments]",c="[object Array]",h="[object Object]",l=Object.prototype.hasOwnProperty;return Bc=function(d,f,g,p,v,m){var y=i(d),w=i(f),x=y?c:o(d),b=w?c:o(f),E=(x=x==u?h:x)==h,M=(b=b==u?h:b)==h,N=x==b;if(N&&s(d)){if(!s(f))return!1;y=!0,E=!1}if(N&&!E)return m||(m=new t),y||a(d)?e(d,f,g,p,v,m):r(d,f,x,g,p,v,m);if(!(1&g)){var _=E&&l.call(d,"__wrapped__"),k=M&&l.call(f,"__wrapped__");if(_||k){var S=_?d.value():d,A=k?f.value():f;return m||(m=new t),v(S,A,g,p,m)}}return!!N&&(m||(m=new t),n(d,f,g,p,v,m))}}function Mv(){if(Uc)return $c;Uc=1;var t=Ev(),e=Fs();return $c=function r(n,o,i,s,a){return n===o||(null==n||null==o||!e(n)&&!e(o)?n!=n&&o!=o:t(n,o,i,s,r,a))},$c}function Nv(){if(Hc)return Yc;Hc=1;var t=bs();return Yc=function(e){return e==e&&!t(e)}}function _v(){if(Jc)return Kc;return Jc=1,Kc=function(t,e){return function(r){return null!=r&&(r[t]===e&&(void 0!==e||t in Object(r)))}}}function kv(){if(th)return Zc;th=1;var t=function(){if(Wc)return Gc;Wc=1;var t=js(),e=Mv();return Gc=function(r,n,o,i){var s=o.length,a=s,u=!i;if(null==r)return!a;for(r=Object(r);s--;){var c=o[s];if(u&&c[2]?c[1]!==r[c[0]]:!(c[0]in r))return!1}for(;++s<a;){var h=(c=o[s])[0],l=r[h],d=c[1];if(u&&c[2]){if(void 0===l&&!(h in r))return!1}else{var f=new t;if(i)var g=i(l,d,h,r,n,f);if(!(void 0===g?e(d,l,3,i,f):g))return!1}}return!0},Gc}(),e=function(){if(Qc)return Xc;Qc=1;var t=Nv(),e=Fa();return Xc=function(r){for(var n=e(r),o=n.length;o--;){var i=n[o],s=r[i];n[o]=[i,s,t(s)]}return n}}(),r=_v();return Zc=function(n){var o=e(n);return 1==o.length&&o[0][2]?r(o[0][0],o[0][1]):function(e){return e===n||t(e,n,o)}}}function Sv(){if(rh)return eh;rh=1;var t=xs(),e=Fs();return eh=function(r){return"symbol"==typeof r||e(r)&&"[object Symbol]"==t(r)}}function Av(){if(oh)return nh;oh=1;var t=Ds(),e=Sv(),r=/\.|\[(?:[^[\]]*|(["'])(?:(?!\1)[^\\]|\\.)*?\1)\]/,n=/^\w*$/;return nh=function(o,i){if(t(o))return!1;var s=typeof o;return!("number"!=s&&"symbol"!=s&&"boolean"!=s&&null!=o&&!e(o))||(n.test(o)||!r.test(o)||null!=i&&o in Object(i))}}function Ov(){if(uh)return ah;uh=1;var t=function(){if(sh)return ih;sh=1;var t=zs();function e(r,n){if("function"!=typeof r||null!=n&&"function"!=typeof n)throw new TypeError("Expected a function");var o=function(){var t=arguments,e=n?n.apply(this,t):t[0],i=o.cache;if(i.has(e))return i.get(e);var s=r.apply(this,t);return o.cache=i.set(e,s)||i,s};return o.cache=new(e.Cache||t),o}return e.Cache=t,ih=e}();return ah=function(e){var r=t(e,function(t){return 500===n.size&&n.clear(),t}),n=r.cache;return r}}function zv(){if(dh)return lh;return dh=1,lh=function(t,e){for(var r=-1,n=null==t?0:t.length,o=Array(n);++r<n;)o[r]=e(t[r],r,t);return o},lh}function jv(){if(vh)return ph;vh=1;var t=function(){if(gh)return fh;gh=1;var t=ws(),e=zv(),r=Ds(),n=Sv(),o=t?t.prototype:void 0,i=o?o.toString:void 0;return fh=function t(o){if("string"==typeof o)return o;if(r(o))return e(o,t)+"";if(n(o))return i?i.call(o):"";var s=o+"";return"0"==s&&1/o==-1/0?"-0":s},fh}();return ph=function(e){return null==e?"":t(e)}}function Cv(){if(yh)return mh;yh=1;var t=Ds(),e=Av(),r=function(){if(hh)return ch;hh=1;var t=Ov(),e=/[^.[\]]+|\[(?:(-?\d+(?:\.\d+)?)|(["'])((?:(?!\2)[^\\]|\\.)*?)\2)\]|(?=(?:\.|\[\])(?:\.|\[\]|$))/g,r=/\\(\\)?/g,n=t(function(t){var n=[];return 46===t.charCodeAt(0)&&n.push(""),t.replace(e,function(t,e,o,i){n.push(o?i.replace(r,"$1"):e||t)}),n});return ch=n}(),n=jv();return mh=function(o,i){return t(o)?o:e(o,i)?[o]:r(n(o))}}function Iv(){if(xh)return wh;xh=1;var t=Sv();return wh=function(e){if("string"==typeof e||t(e))return e;var r=e+"";return"0"==r&&1/e==-1/0?"-0":r}}function Rv(){if(Eh)return bh;Eh=1;var t=Cv(),e=Iv();return bh=function(r,n){for(var o=0,i=(n=t(n,r)).length;null!=r&&o<i;)r=r[e(n[o++])];return o&&o==i?r:void 0},bh}function Tv(){if(Ah)return Sh;Ah=1;var t=Cv(),e=Ls(),r=Ds(),n=Zs(),o=ta(),i=Iv();return Sh=function(s,a,u){for(var c=-1,h=(a=t(a,s)).length,l=!1;++c<h;){var d=i(a[c]);if(!(l=null!=s&&u(s,d)))break;s=s[d]}return l||++c!=h?l:!!(h=null==s?0:s.length)&&o(h)&&n(d,h)&&(r(s)||e(s))},Sh}function Pv(){if(zh)return Oh;zh=1;var t=kh?_h:(kh=1,_h=function(t,e){return null!=t&&e in Object(t)}),e=Tv();return Oh=function(r,n){return null!=r&&e(r,n,t)}}function Fv(){if(Ch)return jh;Ch=1;var t=Mv(),e=function(){if(Nh)return Mh;Nh=1;var t=Rv();return Mh=function(e,r,n){var o=null==e?void 0:t(e,r);return void 0===o?n:o}}(),r=Pv(),n=Av(),o=Nv(),i=_v(),s=Iv();return jh=function(a,u){return n(a)&&o(u)?i(s(a),u):function(n){var o=e(n,a);return void 0===o&&o===u?r(n,a):t(u,o,3)}}}function Lv(){if(Rh)return Ih;return Rh=1,Ih=function(t){return function(e){return null==e?void 0:e[t]}}}function Dv(){if(Lh)return Fh;Lh=1;var t=Lv(),e=function(){if(Ph)return Th;Ph=1;var t=Rv();return Th=function(e){return function(r){return t(r,e)}}}(),r=Av(),n=Iv();return Fh=function(o){return r(o)?t(n(o)):e(o)}}function qv(){if(qh)return Dh;qh=1;var t=kv(),e=Fv(),r=fv(),n=Ds(),o=Dv();return Dh=function(i){return"function"==typeof i?i:null==i?r:"object"==typeof i?n(i)?e(i[0],i[1]):t(i):o(i)}}function Bv(){if(Vh)return Bh;Vh=1;var t=$p(),e=function(){if(xc)return wc;xc=1;var t=dv();return wc=function(e,r){var n=[];return t(e,function(t,e,o){r(t,e,o)&&n.push(t)}),n},wc}(),r=qv(),n=Ds();return Bh=function(o,i){return(n(o)?t:e)(o,r(i,3))}}function Vv(){if(Wh)return Gh;Wh=1;var t=function(){if(Uh)return $h;Uh=1;var t=Object.prototype.hasOwnProperty;return $h=function(e,r){return null!=e&&t.call(e,r)}}(),e=Tv();return Gh=function(r,n){return null!=r&&e(r,n,t)}}function $v(){if(Hh)return Yh;Hh=1;var t=Ta(),e=Jp(),r=Ls(),n=Ds(),o=Pa(),i=Js(),s=Ia(),a=ja(),u=Object.prototype.hasOwnProperty;return Yh=function(c){if(null==c)return!0;if(o(c)&&(n(c)||"string"==typeof c||"function"==typeof c.splice||i(c)||a(c)||r(c)))return!c.length;var h=e(c);if("[object Map]"==h||"[object Set]"==h)return!c.size;if(s(c))return!t(c).length;for(var l in c)if(u.call(c,l))return!1;return!0}}function Uv(){if(Qh)return Xh;return Qh=1,Xh=function(t){return void 0===t}}function Gv(){if(Jh)return Kh;Jh=1;var t=dv(),e=Pa();return Kh=function(r,n){var o=-1,i=e(r)?Array(r.length):[];return t(r,function(t,e,r){i[++o]=n(t,e,r)}),i},Kh}function Wv(){if(tl)return Zh;tl=1;var t=zv(),e=qv(),r=Gv(),n=Ds();return Zh=function(o,i){return(n(o)?t:r)(o,e(i,3))}}function Yv(){if(sl)return il;sl=1;var t=(rl||(rl=1,el=function(t,e,r,n){var o=-1,i=null==t?0:t.length;for(n&&i&&(r=t[++o]);++o<i;)r=e(r,t[o],o,t);return r}),el),e=dv(),r=qv(),n=(ol||(ol=1,nl=function(t,e,r,n,o){return o(t,function(t,o,i){r=n?(n=!1,t):e(r,t,o,i)}),r}),nl),o=Ds();return il=function(i,s,a){var u=o(i)?t:n,c=arguments.length<3;return u(i,r(s,4),a,c,e)},il}function Hv(){if(vl)return pl;vl=1;var t=function(){if(hl)return cl;hl=1;var t=Lv()("length");return cl=t}(),e=function(){if(dl)return ll;dl=1;var t=RegExp("[\\u200d\\ud800-\\udfff\\u0300-\\u036f\\ufe20-\\ufe2f\\u20d0-\\u20ff\\ufe0e\\ufe0f]");return ll=function(e){return t.test(e)}}(),r=function(){if(gl)return fl;gl=1;var t="\\ud800-\\udfff",e="["+t+"]",r="[\\u0300-\\u036f\\ufe20-\\ufe2f\\u20d0-\\u20ff]",n="\\ud83c[\\udffb-\\udfff]",o="[^"+t+"]",i="(?:\\ud83c[\\udde6-\\uddff]){2}",s="[\\ud800-\\udbff][\\udc00-\\udfff]",a="(?:"+r+"|"+n+")?",u="[\\ufe0e\\ufe0f]?",c=u+a+"(?:\\u200d(?:"+[o,i,s].join("|")+")"+u+a+")*",h="(?:"+[o+r+"?",r,i,s,e].join("|")+")",l=RegExp(n+"(?="+n+")|"+h+c,"g");return fl=function(t){for(var e=l.lastIndex=0;l.test(t);)++e;return e}}();return pl=function(n){return e(n)?r(n):t(n)}}function Xv(){if(yl)return ml;yl=1;var t=Ta(),e=Jp(),r=Pa(),n=function(){if(ul)return al;ul=1;var t=xs(),e=Ds(),r=Fs();return al=function(n){return"string"==typeof n||!e(n)&&r(n)&&"[object String]"==t(n)}}(),o=Hv();return ml=function(i){if(null==i)return 0;if(r(i))return n(i)?o(i):i.length;var s=e(i);return"[object Map]"==s||"[object Set]"==s?i.size:t(i).length}}function Qv(){if(xl)return wl;xl=1;var t=Cs(),e=nv(),r=lv(),n=qv(),o=Yp(),i=Ds(),s=Js(),a=Es(),u=bs(),c=ja();return wl=function(h,l,d){var f=i(h),g=f||s(h)||c(h);if(l=n(l,4),null==d){var p=h&&h.constructor;d=g?f?new p:[]:u(h)&&a(p)?e(o(h)):{}}return(g?t:r)(h,function(t,e,r){return l(d,t,e,r)}),d},wl}function Kv(){if(Nl)return Ml;Nl=1;var t=Wp(),e=function(){if(El)return bl;El=1;var t=ws(),e=Ls(),r=Ds(),n=t?t.isConcatSpreadable:void 0;return bl=function(t){return r(t)||e(t)||!!(n&&t&&t[n])}}();return Ml=function r(n,o,i,s,a){var u=-1,c=n.length;for(i||(i=e),a||(a=[]);++u<c;){var h=n[u];o>0&&i(h)?o>1?r(h,o-1,i,s,a):t(a,h):s||(a[a.length]=h)}return a},Ml}function Jv(){if(Al)return Sl;Al=1;var t=kl?_l:(kl=1,_l=function(t,e,r){switch(r.length){case 0:return t.call(e);case 1:return t.call(e,r[0]);case 2:return t.call(e,r[0],r[1]);case 3:return t.call(e,r[0],r[1],r[2])}return t.apply(e,r)}),e=Math.max;return Sl=function(r,n,o){return n=e(void 0===n?r.length-1:n,0),function(){for(var i=arguments,s=-1,a=e(i.length-n,0),u=Array(a);++s<a;)u[s]=i[n+s];s=-1;for(var c=Array(n+1);++s<n;)c[s]=i[s];return c[n]=o(u),t(r,this,c)}},Sl}function Zv(){if(Rl)return Il;Rl=1;var t=function(){if(zl)return Ol;zl=1;var t=cv(),e=Is(),r=fv();return Ol=e?function(r,n){return e(r,"toString",{configurable:!0,enumerable:!1,value:t(n),writable:!0})}:r}(),e=function(){if(Cl)return jl;Cl=1;var t=Date.now;return jl=function(e){var r=0,n=0;return function(){var o=t(),i=16-(o-n);if(n=o,i>0){if(++r>=800)return arguments[0]}else r=0;return e.apply(void 0,arguments)}},jl}(),r=e(t);return Il=r}function tm(){if(Pl)return Tl;Pl=1;var t=fv(),e=Jv(),r=Zv();return Tl=function(n,o){return r(e(n,o,t),n+"")}}function em(){if(Ll)return Fl;return Ll=1,Fl=function(t,e,r,n){for(var o=t.length,i=r+(n?1:-1);n?i--:++i<o;)if(e(t[i],i,t))return i;return-1},Fl}function rm(){if(Ul)return $l;Ul=1;var t=em(),e=ql?Dl:(ql=1,Dl=function(t){return t!=t}),r=(Vl||(Vl=1,Bl=function(t,e,r){for(var n=r-1,o=t.length;++n<o;)if(t[n]===e)return n;return-1}),Bl);return $l=function(n,o,i){return o==o?r(n,o,i):t(n,e,i)}}function nm(){if(Jl)return Kl;Jl=1;var t=Kp(),e=Ql?Xl:(Ql=1,Xl=function(){}),r=xv(),n=t&&1/r(new t([,-0]))[1]==1/0?function(e){return new t(e)}:e;return Kl=n}function om(){if(td)return Zl;td=1;var t=mv(),e=function(){if(Wl)return Gl;Wl=1;var t=rm();return Gl=function(e,r){return!(null==e||!e.length)&&t(e,r,0)>-1}}(),r=(Hl||(Hl=1,Yl=function(t,e,r){for(var n=-1,o=null==t?0:t.length;++n<o;)if(r(e,t[n]))return!0;return!1}),Yl),n=yv(),o=nm(),i=xv();return Zl=function(s,a,u){var c=-1,h=e,l=s.length,d=!0,f=[],g=f;if(u)d=!1,h=r;else if(l>=200){var p=a?null:o(s);if(p)return i(p);d=!1,h=n,g=new t}else g=a?[]:f;t:for(;++c<l;){var v=s[c],m=a?a(v):v;if(v=u||0!==v?v:0,d&&m==m){for(var y=g.length;y--;)if(g[y]===m)continue t;a&&g.push(m),f.push(v)}else h(g,m,u)||(g!==f&&g.push(m),f.push(v))}return f},Zl}function im(){if(rd)return ed;rd=1;var t=Pa(),e=Fs();return ed=function(r){return e(r)&&t(r)}}function sm(){if(od)return nd;od=1;var t=Kv(),e=tm(),r=om(),n=im(),o=e(function(e){return r(t(e,1,n,!0))});return nd=o}function am(){if(ud)return ad;ud=1;var t=function(){if(sd)return id;sd=1;var t=zv();return id=function(e,r){return t(r,function(t){return e[t]})}}(),e=Fa();return ad=function(r){return null==r?[]:t(r,e(r))}}function um(){if(hd)return cd;var t;hd=1;try{t={clone:uv(),constant:cv(),each:vv(),filter:Bv(),has:Vv(),isArray:Ds(),isEmpty:$v(),isFunction:Es(),isUndefined:Uv(),keys:Fa(),map:Wv(),reduce:Yv(),size:Xv(),transform:Qv(),union:sm(),values:am()}}catch(t){}return t||(t=window._),cd=t}function cm(){if(dd)return ld;dd=1;var t=um();ld=r;var e="\0";function r(r){this._isDirected=!t.has(r,"directed")||r.directed,this._isMultigraph=!!t.has(r,"multigraph")&&r.multigraph,this._isCompound=!!t.has(r,"compound")&&r.compound,this._label=void 0,this._defaultNodeLabelFn=t.constant(void 0),this._defaultEdgeLabelFn=t.constant(void 0),this._nodes={},this._isCompound&&(this._parent={},this._children={},this._children[e]={}),this._in={},this._preds={},this._out={},this._sucs={},this._edgeObjs={},this._edgeLabels={}}function n(t,e){t[e]?t[e]++:t[e]=1}function o(t,e){--t[e]||delete t[e]}function i(e,r,n,o){var i=""+r,s=""+n;if(!e&&i>s){var a=i;i=s,s=a}return i+""+s+""+(t.isUndefined(o)?"\0":o)}function s(t,e){return i(t,e.v,e.w,e.name)}return r.prototype._nodeCount=0,r.prototype._edgeCount=0,r.prototype.isDirected=function(){return this._isDirected},r.prototype.isMultigraph=function(){return this._isMultigraph},r.prototype.isCompound=function(){return this._isCompound},r.prototype.setGraph=function(t){return this._label=t,this},r.prototype.graph=function(){return this._label},r.prototype.setDefaultNodeLabel=function(e){return t.isFunction(e)||(e=t.constant(e)),this._defaultNodeLabelFn=e,this},r.prototype.nodeCount=function(){return this._nodeCount},r.prototype.nodes=function(){return t.keys(this._nodes)},r.prototype.sources=function(){var e=this;return t.filter(this.nodes(),function(r){return t.isEmpty(e._in[r])})},r.prototype.sinks=function(){var e=this;return t.filter(this.nodes(),function(r){return t.isEmpty(e._out[r])})},r.prototype.setNodes=function(e,r){var n=arguments,o=this;return t.each(e,function(t){n.length>1?o.setNode(t,r):o.setNode(t)}),this},r.prototype.setNode=function(r,n){return t.has(this._nodes,r)?(arguments.length>1&&(this._nodes[r]=n),this):(this._nodes[r]=arguments.length>1?n:this._defaultNodeLabelFn(r),this._isCompound&&(this._parent[r]=e,this._children[r]={},this._children[e][r]=!0),this._in[r]={},this._preds[r]={},this._out[r]={},this._sucs[r]={},++this._nodeCount,this)},r.prototype.node=function(t){return this._nodes[t]},r.prototype.hasNode=function(e){return t.has(this._nodes,e)},r.prototype.removeNode=function(e){var r=this;if(t.has(this._nodes,e)){var n=function(t){r.removeEdge(r._edgeObjs[t])};delete this._nodes[e],this._isCompound&&(this._removeFromParentsChildList(e),delete this._parent[e],t.each(this.children(e),function(t){r.setParent(t)}),delete this._children[e]),t.each(t.keys(this._in[e]),n),delete this._in[e],delete this._preds[e],t.each(t.keys(this._out[e]),n),delete this._out[e],delete this._sucs[e],--this._nodeCount}return this},r.prototype.setParent=function(r,n){if(!this._isCompound)throw new Error("Cannot set parent in a non-compound graph");if(t.isUndefined(n))n=e;else{for(var o=n+="";!t.isUndefined(o);o=this.parent(o))if(o===r)throw new Error("Setting "+n+" as parent of "+r+" would create a cycle");this.setNode(n)}return this.setNode(r),this._removeFromParentsChildList(r),this._parent[r]=n,this._children[n][r]=!0,this},r.prototype._removeFromParentsChildList=function(t){delete this._children[this._parent[t]][t]},r.prototype.parent=function(t){if(this._isCompound){var r=this._parent[t];if(r!==e)return r}},r.prototype.children=function(r){if(t.isUndefined(r)&&(r=e),this._isCompound){var n=this._children[r];if(n)return t.keys(n)}else{if(r===e)return this.nodes();if(this.hasNode(r))return[]}},r.prototype.predecessors=function(e){var r=this._preds[e];if(r)return t.keys(r)},r.prototype.successors=function(e){var r=this._sucs[e];if(r)return t.keys(r)},r.prototype.neighbors=function(e){var r=this.predecessors(e);if(r)return t.union(r,this.successors(e))},r.prototype.isLeaf=function(t){return 0===(this.isDirected()?this.successors(t):this.neighbors(t)).length},r.prototype.filterNodes=function(e){var r=new this.constructor({directed:this._isDirected,multigraph:this._isMultigraph,compound:this._isCompound});r.setGraph(this.graph());var n=this;t.each(this._nodes,function(t,n){e(n)&&r.setNode(n,t)}),t.each(this._edgeObjs,function(t){r.hasNode(t.v)&&r.hasNode(t.w)&&r.setEdge(t,n.edge(t))});var o={};function i(t){var e=n.parent(t);return void 0===e||r.hasNode(e)?(o[t]=e,e):e in o?o[e]:i(e)}return this._isCompound&&t.each(r.nodes(),function(t){r.setParent(t,i(t))}),r},r.prototype.setDefaultEdgeLabel=function(e){return t.isFunction(e)||(e=t.constant(e)),this._defaultEdgeLabelFn=e,this},r.prototype.edgeCount=function(){return this._edgeCount},r.prototype.edges=function(){return t.values(this._edgeObjs)},r.prototype.setPath=function(e,r){var n=this,o=arguments;return t.reduce(e,function(t,e){return o.length>1?n.setEdge(t,e,r):n.setEdge(t,e),e}),this},r.prototype.setEdge=function(){var e,r,o,s,a=!1,u=arguments[0];"object"==typeof u&&null!==u&&"v"in u?(e=u.v,r=u.w,o=u.name,2===arguments.length&&(s=arguments[1],a=!0)):(e=u,r=arguments[1],o=arguments[3],arguments.length>2&&(s=arguments[2],a=!0)),e=""+e,r=""+r,t.isUndefined(o)||(o=""+o);var c=i(this._isDirected,e,r,o);if(t.has(this._edgeLabels,c))return a&&(this._edgeLabels[c]=s),this;if(!t.isUndefined(o)&&!this._isMultigraph)throw new Error("Cannot set a named edge when isMultigraph = false");this.setNode(e),this.setNode(r),this._edgeLabels[c]=a?s:this._defaultEdgeLabelFn(e,r,o);var h=function(t,e,r,n){var o=""+e,i=""+r;if(!t&&o>i){var s=o;o=i,i=s}var a={v:o,w:i};n&&(a.name=n);return a}(this._isDirected,e,r,o);return e=h.v,r=h.w,Object.freeze(h),this._edgeObjs[c]=h,n(this._preds[r],e),n(this._sucs[e],r),this._in[r][c]=h,this._out[e][c]=h,this._edgeCount++,this},r.prototype.edge=function(t,e,r){var n=1===arguments.length?s(this._isDirected,arguments[0]):i(this._isDirected,t,e,r);return this._edgeLabels[n]},r.prototype.hasEdge=function(e,r,n){var o=1===arguments.length?s(this._isDirected,arguments[0]):i(this._isDirected,e,r,n);return t.has(this._edgeLabels,o)},r.prototype.removeEdge=function(t,e,r){var n=1===arguments.length?s(this._isDirected,arguments[0]):i(this._isDirected,t,e,r),a=this._edgeObjs[n];return a&&(t=a.v,e=a.w,delete this._edgeLabels[n],delete this._edgeObjs[n],o(this._preds[e],t),o(this._sucs[t],e),delete this._in[e][n],delete this._out[t][n],this._edgeCount--),this},r.prototype.inEdges=function(e,r){var n=this._in[e];if(n){var o=t.values(n);return r?t.filter(o,function(t){return t.v===r}):o}},r.prototype.outEdges=function(e,r){var n=this._out[e];if(n){var o=t.values(n);return r?t.filter(o,function(t){return t.w===r}):o}},r.prototype.nodeEdges=function(t,e){var r=this.inEdges(t,e);if(r)return r.concat(this.outEdges(t,e))},ld}function hm(){return vd?pd:(vd=1,pd={Graph:cm(),version:gd?fd:(gd=1,fd="2.1.8")})}function lm(){if(yd)return md;yd=1;var t=um(),e=cm();function r(e){return t.map(e.nodes(),function(r){var n=e.node(r),o=e.parent(r),i={v:r};return t.isUndefined(n)||(i.value=n),t.isUndefined(o)||(i.parent=o),i})}function n(e){return t.map(e.edges(),function(r){var n=e.edge(r),o={v:r.v,w:r.w};return t.isUndefined(r.name)||(o.name=r.name),t.isUndefined(n)||(o.value=n),o})}return md={write:function(e){var o={options:{directed:e.isDirected(),multigraph:e.isMultigraph(),compound:e.isCompound()},nodes:r(e),edges:n(e)};t.isUndefined(e.graph())||(o.value=t.clone(e.graph()));return o},read:function(r){var n=new e(r.options).setGraph(r.value);return t.each(r.nodes,function(t){n.setNode(t.v,t.value),t.parent&&n.setParent(t.v,t.parent)}),t.each(r.edges,function(t){n.setEdge({v:t.v,w:t.w,name:t.name},t.value)}),n}}}function dm(){if(xd)return wd;xd=1;var t=um();return wd=function(e){var r,n={},o=[];function i(o){t.has(n,o)||(n[o]=!0,r.push(o),t.each(e.successors(o),i),t.each(e.predecessors(o),i))}return t.each(e.nodes(),function(t){r=[],i(t),r.length&&o.push(r)}),o},wd}function fm(){if(Ed)return bd;Ed=1;var t=um();function e(){this._arr=[],this._keyIndices={}}return bd=e,e.prototype.size=function(){return this._arr.length},e.prototype.keys=function(){return this._arr.map(function(t){return t.key})},e.prototype.has=function(e){return t.has(this._keyIndices,e)},e.prototype.priority=function(t){var e=this._keyIndices[t];if(void 0!==e)return this._arr[e].priority},e.prototype.min=function(){if(0===this.size())throw new Error("Queue underflow");return this._arr[0].key},e.prototype.add=function(e,r){var n=this._keyIndices;if(e=String(e),!t.has(n,e)){var o=this._arr,i=o.length;return n[e]=i,o.push({key:e,priority:r}),this._decrease(i),!0}return!1},e.prototype.removeMin=function(){this._swap(0,this._arr.length-1);var t=this._arr.pop();return delete this._keyIndices[t.key],this._heapify(0),t.key},e.prototype.decrease=function(t,e){var r=this._keyIndices[t];if(e>this._arr[r].priority)throw new Error("New priority is greater than current priority. Key: "+t+" Old: "+this._arr[r].priority+" New: "+e);this._arr[r].priority=e,this._decrease(r)},e.prototype._heapify=function(t){var e=this._arr,r=2*t,n=r+1,o=t;r<e.length&&(o=e[r].priority<e[o].priority?r:o,n<e.length&&(o=e[n].priority<e[o].priority?n:o),o!==t&&(this._swap(t,o),this._heapify(o)))},e.prototype._decrease=function(t){for(var e,r=this._arr,n=r[t].priority;0!==t&&!(r[e=t>>1].priority<n);)this._swap(t,e),t=e},e.prototype._swap=function(t,e){var r=this._arr,n=this._keyIndices,o=r[t],i=r[e];r[t]=i,r[e]=o,n[i.key]=t,n[o.key]=e},bd}function gm(){if(Nd)return Md;Nd=1;var t=um(),e=fm();Md=function(t,n,o,i){return function(t,r,n,o){var i,s,a={},u=new e,c=function(t){var e=t.v!==i?t.v:t.w,r=a[e],o=n(t),c=s.distance+o;if(o<0)throw new Error("dijkstra does not allow negative edge weights. Bad edge: "+t+" Weight: "+o);c<r.distance&&(r.distance=c,r.predecessor=i,u.decrease(e,c))};t.nodes().forEach(function(t){var e=t===r?0:Number.POSITIVE_INFINITY;a[t]={distance:e},u.add(t,e)});for(;u.size()>0&&(i=u.removeMin(),(s=a[i]).distance!==Number.POSITIVE_INFINITY);)o(i).forEach(c);return a}(t,String(n),o||r,i||function(e){return t.outEdges(e)})};var r=t.constant(1);return Md}function pm(){if(kd)return _d;kd=1;var t=gm(),e=um();return _d=function(r,n,o){return e.transform(r.nodes(),function(e,i){e[i]=t(r,i,n,o)},{})}}function vm(){if(Ad)return Sd;Ad=1;var t=um();return Sd=function(e){var r=0,n=[],o={},i=[];function s(a){var u=o[a]={onStack:!0,lowlink:r,index:r++};if(n.push(a),e.successors(a).forEach(function(e){t.has(o,e)?o[e].onStack&&(u.lowlink=Math.min(u.lowlink,o[e].index)):(s(e),u.lowlink=Math.min(u.lowlink,o[e].lowlink))}),u.lowlink===u.index){var c,h=[];do{c=n.pop(),o[c].onStack=!1,h.push(c)}while(a!==c);i.push(h)}}return e.nodes().forEach(function(e){t.has(o,e)||s(e)}),i},Sd}function mm(){if(zd)return Od;zd=1;var t=um(),e=vm();return Od=function(r){return t.filter(e(r),function(t){return t.length>1||1===t.length&&r.hasEdge(t[0],t[0])})}}function ym(){if(Cd)return jd;Cd=1;var t=um();jd=function(t,r,n){return function(t,e,r){var n={},o=t.nodes();return o.forEach(function(t){n[t]={},n[t][t]={distance:0},o.forEach(function(e){t!==e&&(n[t][e]={distance:Number.POSITIVE_INFINITY})}),r(t).forEach(function(r){var o=r.v===t?r.w:r.v,i=e(r);n[t][o]={distance:i,predecessor:t}})}),o.forEach(function(t){var e=n[t];o.forEach(function(r){var i=n[r];o.forEach(function(r){var n=i[t],o=e[r],s=i[r],a=n.distance+o.distance;a<s.distance&&(s.distance=a,s.predecessor=o.predecessor)})})}),n}(t,r||e,n||function(e){return t.outEdges(e)})};var e=t.constant(1);return jd}function wm(){if(Rd)return Id;Rd=1;var t=um();function e(e){var n={},o={},i=[];if(t.each(e.sinks(),function s(a){if(t.has(o,a))throw new r;t.has(n,a)||(o[a]=!0,n[a]=!0,t.each(e.predecessors(a),s),delete o[a],i.push(a))}),t.size(n)!==e.nodeCount())throw new r;return i}function r(){}return Id=e,e.CycleException=r,r.prototype=new Error,Id}function xm(){if(Pd)return Td;Pd=1;var t=wm();return Td=function(e){try{t(e)}catch(e){if(e instanceof t.CycleException)return!1;throw e}return!0},Td}function bm(){if(Ld)return Fd;Ld=1;var t=um();function e(r,n,o,i,s,a){t.has(i,n)||(i[n]=!0,o||a.push(n),t.each(s(n),function(t){e(r,t,o,i,s,a)}),o&&a.push(n))}return Fd=function(r,n,o){t.isArray(n)||(n=[n]);var i=(r.isDirected()?r.successors:r.neighbors).bind(r),s=[],a={};return t.each(n,function(t){if(!r.hasNode(t))throw new Error("Graph does not have node: "+t);e(r,t,"post"===o,a,i,s)}),s},Fd}function Em(){if(qd)return Dd;qd=1;var t=bm();return Dd=function(e,r){return t(e,r,"post")}}function Mm(){if(Vd)return Bd;Vd=1;var t=bm();return Bd=function(e,r){return t(e,r,"pre")}}function Nm(){if(Ud)return $d;Ud=1;var t=um(),e=cm(),r=fm();return $d=function(n,o){var i,s=new e,a={},u=new r;function c(t){var e=t.v===i?t.w:t.v,r=u.priority(e);if(void 0!==r){var n=o(t);n<r&&(a[e]=i,u.decrease(e,n))}}if(0===n.nodeCount())return s;t.each(n.nodes(),function(t){u.add(t,Number.POSITIVE_INFINITY),s.setNode(t)}),u.decrease(n.nodes()[0],0);var h=!1;for(;u.size()>0;){if(i=u.removeMin(),t.has(a,i))s.setEdge(i,a[i]);else{if(h)throw new Error("Input graph is not connected: "+n);h=!0}n.nodeEdges(i).forEach(c)}return s},$d}function _m(){if(Hd)return Yd;Hd=1;var t=hm();return Yd={Graph:t.Graph,json:lm(),alg:Wd?Gd:(Wd=1,Gd={components:dm(),dijkstra:gm(),dijkstraAll:pm(),findCycles:mm(),floydWarshall:ym(),isAcyclic:xm(),postorder:Em(),preorder:Mm(),prim:Nm(),tarjan:vm(),topsort:wm()}),version:t.version}}function km(){if(Qd)return Xd;var t;Qd=1;try{t=_m()}catch(t){}return t||(t=window.graphlib),Xd=t}function Sm(){if(Jd)return Kd;Jd=1;var t=av();return Kd=function(e){return t(e,5)}}function Am(){if(tf)return Zd;tf=1;var t=gs(),e=Pa(),r=Zs(),n=bs();return Zd=function(o,i,s){if(!n(s))return!1;var a=typeof i;return!!("number"==a?e(s)&&r(i,s.length):"string"==a&&i in s)&&t(s[i],o)},Zd}function Om(){if(rf)return ef;rf=1;var t=tm(),e=gs(),r=Am(),n=Da(),o=Object.prototype,i=o.hasOwnProperty,s=t(function(t,s){t=Object(t);var a=-1,u=s.length,c=u>2?s[2]:void 0;for(c&&r(s[0],s[1],c)&&(u=1);++a<u;)for(var h=s[a],l=n(h),d=-1,f=l.length;++d<f;){var g=l[d],p=t[g];(void 0===p||e(p,o[g])&&!i.call(t,g))&&(t[g]=h[g])}return t});return ef=s}function zm(){if(cf)return uf;cf=1;var t=function(){if(af)return sf;af=1;var t=/\s/;return sf=function(e){for(var r=e.length;r--&&t.test(e.charAt(r)););return r},sf}(),e=/^\s+/;return uf=function(r){return r?r.slice(0,t(r)+1).replace(e,""):r}}function jm(){if(ff)return df;ff=1;var t=function(){if(lf)return hf;lf=1;var t=zm(),e=bs(),r=Sv(),n=/^[-+]0x[0-9a-f]+$/i,o=/^0b[01]+$/i,i=/^0o[0-7]+$/i,s=parseInt;return hf=function(a){if("number"==typeof a)return a;if(r(a))return NaN;if(e(a)){var u="function"==typeof a.valueOf?a.valueOf():a;a=e(u)?u+"":u}if("string"!=typeof a)return 0===a?a:+a;a=t(a);var c=o.test(a);return c||i.test(a)?s(a.slice(2),c?2:8):n.test(a)?NaN:+a}}(),e=1/0;return df=function(r){return r?(r=t(r))===e||r===-1/0?17976931348623157e292*(r<0?-1:1):r==r?r:0:0===r?r:0}}function Cm(){if(mf)return vf;mf=1;var t=em(),e=qv(),r=function(){if(pf)return gf;pf=1;var t=jm();return gf=function(e){var r=t(e),n=r%1;return r==r?n?r-n:r:0}}(),n=Math.max;return vf=function(o,i,s){var a=null==o?0:o.length;if(!a)return-1;var u=null==s?0:r(s);return u<0&&(u=n(a+u,0)),t(o,e(i,3),u)},vf}function Im(){if(wf)return yf;wf=1;var t=function(){if(of)return nf;of=1;var t=qv(),e=Pa(),r=Fa();return nf=function(n){return function(o,i,s){var a=Object(o);if(!e(o)){var u=t(i,3);o=r(o),i=function(t){return u(a[t],t,a)}}var c=n(o,i,s);return c>-1?a[u?o[c]:c]:void 0}},nf}(),e=t(Cm());return yf=e}function Rm(){if(bf)return xf;bf=1;var t=Kv();return xf=function(e){return(null==e?0:e.length)?t(e,1):[]}}function Tm(){if(Mf)return Ef;Mf=1;var t=hv(),e=gv(),r=Da();return Ef=function(n,o){return null==n?n:t(n,e(o),r)}}function Pm(){if(_f)return Nf;return _f=1,Nf=function(t){var e=null==t?0:t.length;return e?t[e-1]:void 0}}function Fm(){if(Sf)return kf;Sf=1;var t=Rs(),e=lv(),r=qv();return kf=function(n,o){var i={};return o=r(o,3),e(n,function(e,r,n){t(i,r,o(e,r,n))}),i}}function Lm(){if(Of)return Af;Of=1;var t=Sv();return Af=function(e,r,n){for(var o=-1,i=e.length;++o<i;){var s=e[o],a=r(s);if(null!=a&&(void 0===u?a==a&&!t(a):n(a,u)))var u=a,c=s}return c},Af}function Dm(){if(If)return Cf;If=1;var t=Lm(),e=jf?zf:(jf=1,zf=function(t,e){return t>e}),r=fv();return Cf=function(n){return n&&n.length?t(n,r,e):void 0}}function qm(){if(Tf)return Rf;Tf=1;var t=Rs(),e=gs();return Rf=function(r,n,o){(void 0!==o&&!e(r[n],o)||void 0===o&&!(n in r))&&t(r,n,o)}}function Bm(){if(Df)return Lf;return Df=1,Lf=function(t,e){if(("constructor"!==e||"function"!=typeof t[e])&&"__proto__"!=e)return t[e]}}function Vm(){if($f)return Vf;$f=1;var t=qm(),e=Bp(),r=ev(),n=Vp(),o=ov(),i=Ls(),s=Ds(),a=im(),u=Js(),c=Es(),h=bs(),l=function(){if(Ff)return Pf;Ff=1;var t=xs(),e=Yp(),r=Fs(),n=Function.prototype,o=Object.prototype,i=n.toString,s=o.hasOwnProperty,a=i.call(Object);return Pf=function(n){if(!r(n)||"[object Object]"!=t(n))return!1;var o=e(n);if(null===o)return!0;var u=s.call(o,"constructor")&&o.constructor;return"function"==typeof u&&u instanceof u&&i.call(u)==a}}(),d=ja(),f=Bm(),g=function(){if(Bf)return qf;Bf=1;var t=Ps(),e=Da();return qf=function(r){return t(r,e(r))}}();return Vf=function(p,v,m,y,w,x,b){var E=f(p,m),M=f(v,m),N=b.get(M);if(N)t(p,m,N);else{var _=x?x(E,M,m+"",p,v,b):void 0,k=void 0===_;if(k){var S=s(M),A=!S&&u(M),O=!S&&!A&&d(M);_=M,S||A||O?s(E)?_=E:a(E)?_=n(E):A?(k=!1,_=e(M,!0)):O?(k=!1,_=r(M,!0)):_=[]:l(M)||i(M)?(_=E,i(E)?_=g(E):h(E)&&!c(E)||(_=o(M))):k=!1}k&&(b.set(M,_),w(_,M,y,x,b),b.delete(M)),t(p,m,_)}}}function $m(){if(Xf)return Hf;Xf=1;var t=function(){if(Gf)return Uf;Gf=1;var t=js(),e=qm(),r=hv(),n=Vm(),o=bs(),i=Da(),s=Bm();return Uf=function a(u,c,h,l,d){u!==c&&r(c,function(r,i){if(d||(d=new t),o(r))n(u,c,i,h,a,l,d);else{var f=l?l(s(u,i),r,i+"",u,c,d):void 0;void 0===f&&(f=r),e(u,i,f)}},i)},Uf}(),e=function(){if(Yf)return Wf;Yf=1;var t=tm(),e=Am();return Wf=function(r){return t(function(t,n){var o=-1,i=n.length,s=i>1?n[i-1]:void 0,a=i>2?n[2]:void 0;for(s=r.length>3&&"function"==typeof s?(i--,s):void 0,a&&e(n[0],n[1],a)&&(s=i<3?void 0:s,i=1),t=Object(t);++o<i;){var u=n[o];u&&r(t,u,o,s)}return t})},Wf}(),r=e(function(e,r,n){t(e,r,n)});return Hf=r}function Um(){if(Kf)return Qf;return Kf=1,Qf=function(t,e){return t<e}}function Gm(){if(Zf)return Jf;Zf=1;var t=Lm(),e=Um(),r=fv();return Jf=function(n){return n&&n.length?t(n,r,e):void 0}}function Wm(){if(eg)return tg;eg=1;var t=Lm(),e=qv(),r=Um();return tg=function(n,o){return n&&n.length?t(n,e(o,2),r):void 0}}function Ym(){if(ng)return rg;ng=1;var t=ys();return rg=function(){return t.Date.now()}}function Hm(){if(ag)return sg;ag=1;var t=Rv(),e=function(){if(ig)return og;ig=1;var t=Ts(),e=Cv(),r=Zs(),n=bs(),o=Iv();return og=function(i,s,a,u){if(!n(i))return i;for(var c=-1,h=(s=e(s,i)).length,l=h-1,d=i;null!=d&&++c<h;){var f=o(s[c]),g=a;if("__proto__"===f||"constructor"===f||"prototype"===f)return i;if(c!=l){var p=d[f];void 0===(g=u?u(p,f,d):void 0)&&(g=n(p)?p:r(s[c+1])?[]:{})}t(d,f,g),d=d[f]}return i},og}(),r=Cv();return sg=function(n,o,i){for(var s=-1,a=o.length,u={};++s<a;){var c=o[s],h=t(n,c);i(h,c)&&e(u,r(c,n),h)}return u},sg}function Xm(){if(fg)return dg;fg=1;var t=function(){if(cg)return ug;cg=1;var t=Hm(),e=Pv();return ug=function(r,n){return t(r,n,function(t,n){return e(r,n)})}}(),e=function(){if(lg)return hg;lg=1;var t=Rm(),e=Jv(),r=Zv();return hg=function(n){return r(e(n,void 0,t),n+"")}}()(function(e,r){return null==e?{}:t(e,r)});return dg=e}function Qm(){if(mg)return vg;mg=1;var t=function(){if(pg)return gg;pg=1;var t=Math.ceil,e=Math.max;return gg=function(r,n,o,i){for(var s=-1,a=e(t((n-r)/(o||1)),0),u=Array(a);a--;)u[i?a:++s]=r,r+=o;return u},gg}(),e=Am(),r=jm();return vg=function(n){return function(o,i,s){return s&&"number"!=typeof s&&e(o,i,s)&&(i=s=void 0),o=r(o),void 0===i?(i=o,o=0):i=r(i),s=void 0===s?o<i?1:-1:r(s),t(o,i,s,n)}}}function Km(){if(wg)return yg;wg=1;var t=Qm()();return yg=t}function Jm(){if(_g)return Ng;_g=1;var t=function(){if(Mg)return Eg;Mg=1;var t=Sv();return Eg=function(e,r){if(e!==r){var n=void 0!==e,o=null===e,i=e==e,s=t(e),a=void 0!==r,u=null===r,c=r==r,h=t(r);if(!u&&!h&&!s&&e>r||s&&a&&c&&!u&&!h||o&&a&&c||!n&&c||!i)return 1;if(!o&&!s&&!h&&e<r||h&&n&&i&&!o&&!s||u&&n&&i||!a&&i||!c)return-1}return 0}}();return Ng=function(e,r,n){for(var o=-1,i=e.criteria,s=r.criteria,a=i.length,u=n.length;++o<a;){var c=t(i[o],s[o]);if(c)return o>=u?c:c*("desc"==n[o]?-1:1)}return e.index-r.index},Ng}function Zm(){if(Sg)return kg;Sg=1;var t=zv(),e=Rv(),r=qv(),n=Gv(),o=bg?xg:(bg=1,xg=function(t,e){var r=t.length;for(t.sort(e);r--;)t[r]=t[r].value;return t}),i=ea(),s=Jm(),a=fv(),u=Ds();return kg=function(c,h,l){h=h.length?t(h,function(t){return u(t)?function(r){return e(r,1===t.length?t[0]:t)}:t}):[a];var d=-1;h=t(h,i(r));var f=n(c,function(e,r,n){return{criteria:t(h,function(t){return t(e)}),index:++d,value:e}});return o(f,function(t,e){return s(t,e,l)})},kg}function ty(){if(Og)return Ag;Og=1;var t=Kv(),e=Zm(),r=tm(),n=Am(),o=r(function(r,o){if(null==r)return[];var i=o.length;return i>1&&n(r,o[0],o[1])?o=[]:i>2&&n(o[0],o[1],o[2])&&(o=[o[0]]),e(r,t(o,1),[])});return Ag=o}function ey(){if(jg)return zg;jg=1;var t=jv(),e=0;return zg=function(r){var n=++e;return t(r)+n}}function ry(){if(Tg)return Rg;Tg=1;var t=Ts(),e=(Ig||(Ig=1,Cg=function(t,e,r){for(var n=-1,o=t.length,i=e.length,s={};++n<o;){var a=n<i?e[n]:void 0;r(s,t[n],a)}return s}),Cg);return Rg=function(r,n){return e(r||[],n||[],t)}}function ny(){if(Fg)return Pg;var t;Fg=1;try{t={cloneDeep:Sm(),constant:cv(),defaults:Om(),each:vv(),filter:Bv(),find:Im(),flatten:Rm(),forEach:pv(),forIn:Tm(),has:Vv(),isUndefined:Uv(),last:Pm(),map:Wv(),mapValues:Fm(),max:Dm(),merge:$m(),min:Gm(),minBy:Wm(),now:Ym(),pick:Xm(),range:Km(),reduce:Yv(),sortBy:ty(),uniqueId:ey(),values:am(),zipObject:ry()}}catch(t){}return t||(t=window._),Pg=t}function oy(){if(Bg)return qg;Bg=1;var t=ny(),e=km().Graph,r=function(){if(Dg)return Lg;function t(){var t={};t._next=t._prev=t,this._sentinel=t}function e(t){t._prev._next=t._next,t._next._prev=t._prev,delete t._next,delete t._prev}function r(t,e){if("_next"!==t&&"_prev"!==t)return e}return Dg=1,Lg=t,t.prototype.dequeue=function(){var t=this._sentinel,r=t._prev;if(r!==t)return e(r),r},t.prototype.enqueue=function(t){var r=this._sentinel;t._prev&&t._next&&e(t),t._next=r._next,r._next._prev=t,r._next=t,t._prev=r},t.prototype.toString=function(){for(var t=[],e=this._sentinel,n=e._prev;n!==e;)t.push(JSON.stringify(n,r)),n=n._prev;return"["+t.join(", ")+"]"},Lg}();qg=function(s,a){if(s.nodeCount()<=1)return[];var u=function(n,o){var s=new e,a=0,u=0;t.forEach(n.nodes(),function(t){s.setNode(t,{v:t,in:0,out:0})}),t.forEach(n.edges(),function(t){var e=s.edge(t.v,t.w)||0,r=o(t),n=e+r;s.setEdge(t.v,t.w,n),u=Math.max(u,s.node(t.v).out+=r),a=Math.max(a,s.node(t.w).in+=r)});var c=t.range(u+a+3).map(function(){return new r}),h=a+1;return t.forEach(s.nodes(),function(t){i(c,h,s.node(t))}),{graph:s,buckets:c,zeroIdx:h}}(s,a||n),c=function(t,e,r){var n,i=[],s=e[e.length-1],a=e[0];for(;t.nodeCount();){for(;n=a.dequeue();)o(t,e,r,n);for(;n=s.dequeue();)o(t,e,r,n);if(t.nodeCount())for(var u=e.length-2;u>0;--u)if(n=e[u].dequeue()){i=i.concat(o(t,e,r,n,!0));break}}return i}(u.graph,u.buckets,u.zeroIdx);return t.flatten(t.map(c,function(t){return s.outEdges(t.v,t.w)}),!0)};var n=t.constant(1);function o(e,r,n,o,s){var a=s?[]:void 0;return t.forEach(e.inEdges(o.v),function(t){var o=e.edge(t),u=e.node(t.v);s&&a.push({v:t.v,w:t.w}),u.out-=o,i(r,n,u)}),t.forEach(e.outEdges(o.v),function(t){var o=e.edge(t),s=t.w,a=e.node(s);a.in-=o,i(r,n,a)}),e.removeNode(o.v),a}function i(t,e,r){r.out?r.in?t[r.out-r.in+e].enqueue(r):t[t.length-1].enqueue(r):t[0].enqueue(r)}return qg}function iy(){if($g)return Vg;$g=1;var t=ny(),e=oy();return Vg={run:function(r){var n="greedy"===r.graph().acyclicer?e(r,function(t){return function(e){return t.edge(e).weight}}(r)):function(e){var r=[],n={},o={};function i(s){t.has(o,s)||(o[s]=!0,n[s]=!0,t.forEach(e.outEdges(s),function(e){t.has(n,e.w)?r.push(e):i(e.w)}),delete n[s])}return t.forEach(e.nodes(),i),r}(r);t.forEach(n,function(e){var n=r.edge(e);r.removeEdge(e),n.forwardName=e.name,n.reversed=!0,r.setEdge(e.w,e.v,n,t.uniqueId("rev"))})},undo:function(e){t.forEach(e.edges(),function(t){var r=e.edge(t);if(r.reversed){e.removeEdge(t);var n=r.forwardName;delete r.reversed,delete r.forwardName,e.setEdge(t.w,t.v,r,n)}})}},Vg}function sy(){if(Gg)return Ug;Gg=1;var t=ny(),e=km().Graph;function r(e,r,n,o){var i;do{i=t.uniqueId(o)}while(e.hasNode(i));return n.dummy=r,e.setNode(i,n),i}function n(e){return t.max(t.map(e.nodes(),function(r){var n=e.node(r).rank;if(!t.isUndefined(n))return n}))}return Ug={addDummyNode:r,simplify:function(r){var n=(new e).setGraph(r.graph());return t.forEach(r.nodes(),function(t){n.setNode(t,r.node(t))}),t.forEach(r.edges(),function(t){var e=n.edge(t.v,t.w)||{weight:0,minlen:1},o=r.edge(t);n.setEdge(t.v,t.w,{weight:e.weight+o.weight,minlen:Math.max(e.minlen,o.minlen)})}),n},asNonCompoundGraph:function(r){var n=new e({multigraph:r.isMultigraph()}).setGraph(r.graph());return t.forEach(r.nodes(),function(t){r.children(t).length||n.setNode(t,r.node(t))}),t.forEach(r.edges(),function(t){n.setEdge(t,r.edge(t))}),n},successorWeights:function(e){var r=t.map(e.nodes(),function(r){var n={};return t.forEach(e.outEdges(r),function(t){n[t.w]=(n[t.w]||0)+e.edge(t).weight}),n});return t.zipObject(e.nodes(),r)},predecessorWeights:function(e){var r=t.map(e.nodes(),function(r){var n={};return t.forEach(e.inEdges(r),function(t){n[t.v]=(n[t.v]||0)+e.edge(t).weight}),n});return t.zipObject(e.nodes(),r)},intersectRect:function(t,e){var r,n,o=t.x,i=t.y,s=e.x-o,a=e.y-i,u=t.width/2,c=t.height/2;if(!s&&!a)throw new Error("Not possible to find intersection inside of the rectangle");Math.abs(a)*u>Math.abs(s)*c?(a<0&&(c=-c),r=c*s/a,n=c):(s<0&&(u=-u),r=u,n=u*a/s);return{x:o+r,y:i+n}},buildLayerMatrix:function(e){var r=t.map(t.range(n(e)+1),function(){return[]});return t.forEach(e.nodes(),function(n){var o=e.node(n),i=o.rank;t.isUndefined(i)||(r[i][o.order]=n)}),r},normalizeRanks:function(e){var r=t.min(t.map(e.nodes(),function(t){return e.node(t).rank}));t.forEach(e.nodes(),function(n){var o=e.node(n);t.has(o,"rank")&&(o.rank-=r)})},removeEmptyRanks:function(e){var r=t.min(t.map(e.nodes(),function(t){return e.node(t).rank})),n=[];t.forEach(e.nodes(),function(t){var o=e.node(t).rank-r;n[o]||(n[o]=[]),n[o].push(t)});var o=0,i=e.graph().nodeRankFactor;t.forEach(n,function(r,n){t.isUndefined(r)&&n%i!==0?--o:o&&t.forEach(r,function(t){e.node(t).rank+=o})})},addBorderNode:function(t,e,n,o){var i={width:0,height:0};arguments.length>=4&&(i.rank=n,i.order=o);return r(t,"border",i,e)},maxRank:n,partition:function(e,r){var n={lhs:[],rhs:[]};return t.forEach(e,function(t){r(t)?n.lhs.push(t):n.rhs.push(t)}),n},time:function(e,r){var n=t.now();try{return r()}finally{console.log(e+" time: "+(t.now()-n)+"ms")}},notime:function(t,e){return e()}},Ug}function ay(){if(Yg)return Wg;Yg=1;var t=ny(),e=sy();return Wg={run:function(r){r.graph().dummyChains=[],t.forEach(r.edges(),function(t){!function(t,r){var n,o,i,s=r.v,a=t.node(s).rank,u=r.w,c=t.node(u).rank,h=r.name,l=t.edge(r),d=l.labelRank;if(c===a+1)return;for(t.removeEdge(r),i=0,++a;a<c;++i,++a)l.points=[],o={width:0,height:0,edgeLabel:l,edgeObj:r,rank:a},n=e.addDummyNode(t,"edge",o,"_d"),a===d&&(o.width=l.width,o.height=l.height,o.dummy="edge-label",o.labelpos=l.labelpos),t.setEdge(s,n,{weight:l.weight},h),0===i&&t.graph().dummyChains.push(n),s=n;t.setEdge(s,u,{weight:l.weight},h)}(r,t)})},undo:function(e){t.forEach(e.graph().dummyChains,function(t){var r,n=e.node(t),o=n.edgeLabel;for(e.setEdge(n.edgeObj,o);n.dummy;)r=e.successors(t)[0],e.removeNode(t),o.points.push({x:n.x,y:n.y}),"edge-label"===n.dummy&&(o.x=n.x,o.y=n.y,o.width=n.width,o.height=n.height),t=r,n=e.node(t)})}},Wg}function uy(){if(Xg)return Hg;Xg=1;var t=ny();return Hg={longestPath:function(e){var r={};t.forEach(e.sources(),function n(o){var i=e.node(o);if(t.has(r,o))return i.rank;r[o]=!0;var s=t.min(t.map(e.outEdges(o),function(t){return n(t.w)-e.edge(t).minlen}));return s!==Number.POSITIVE_INFINITY&&null!=s||(s=0),i.rank=s})},slack:function(t,e){return t.node(e.w).rank-t.node(e.v).rank-t.edge(e).minlen}},Hg}function cy(){if(Kg)return Qg;Kg=1;var t=ny(),e=km().Graph,r=uy().slack;function n(e,n){return t.forEach(e.nodes(),function o(i){t.forEach(n.nodeEdges(i),function(t){var s=t.v,a=i===s?t.w:s;e.hasNode(a)||r(n,t)||(e.setNode(a,{}),e.setEdge(i,a,{}),o(a))})}),e.nodeCount()}function o(e,n){return t.minBy(n.edges(),function(t){if(e.hasNode(t.v)!==e.hasNode(t.w))return r(n,t)})}function i(e,r,n){t.forEach(e.nodes(),function(t){r.node(t).rank+=n})}return Qg=function(t){var s,a,u=new e({directed:!1}),c=t.nodes()[0],h=t.nodeCount();u.setNode(c,{});for(;n(u,t)<h;)s=o(u,t),a=u.hasNode(s.v)?r(t,s):-r(t,s),i(u,t,a);return u}}function hy(){if(Zg)return Jg;Zg=1;var t=ny(),e=cy(),r=uy().slack,n=uy().longestPath,o=km().alg.preorder,i=km().alg.postorder,s=sy().simplify;function a(t){t=s(t),n(t);var r,o=e(t);for(h(o),u(o,t);r=d(o);)g(o,t,r,f(o,t,r))}function u(e,r){var n=i(e,e.nodes());n=n.slice(0,n.length-1),t.forEach(n,function(t){!function(t,e,r){var n=t.node(r),o=n.parent;t.edge(r,o).cutvalue=c(t,e,r)}(e,r,t)})}function c(e,r,n){var o=e.node(n).parent,i=!0,s=r.edge(n,o),a=0;return s||(i=!1,s=r.edge(o,n)),a=s.weight,t.forEach(r.nodeEdges(n),function(t){var s=t.v===n,u=s?t.w:t.v;if(u!==o){var c=s===i,h=r.edge(t).weight;if(a+=c?h:-h,function(t,e,r){return t.hasEdge(e,r)}(e,n,u)){var l=e.edge(n,u).cutvalue;a+=c?-l:l}}}),a}function h(t,e){arguments.length<2&&(e=t.nodes()[0]),l(t,{},1,e)}function l(e,r,n,o,i){var s=n,a=e.node(o);return r[o]=!0,t.forEach(e.neighbors(o),function(i){t.has(r,i)||(n=l(e,r,n,i,o))}),a.low=s,a.lim=n++,i?a.parent=i:delete a.parent,n}function d(e){return t.find(e.edges(),function(t){return e.edge(t).cutvalue<0})}function f(e,n,o){var i=o.v,s=o.w;n.hasEdge(i,s)||(i=o.w,s=o.v);var a=e.node(i),u=e.node(s),c=a,h=!1;a.lim>u.lim&&(c=u,h=!0);var l=t.filter(n.edges(),function(t){return h===p(e,e.node(t.v),c)&&h!==p(e,e.node(t.w),c)});return t.minBy(l,function(t){return r(n,t)})}function g(e,r,n,i){var s=n.v,a=n.w;e.removeEdge(s,a),e.setEdge(i.v,i.w,{}),h(e),u(e,r),function(e,r){var n=t.find(e.nodes(),function(t){return!r.node(t).parent}),i=o(e,n);i=i.slice(1),t.forEach(i,function(t){var n=e.node(t).parent,o=r.edge(t,n),i=!1;o||(o=r.edge(n,t),i=!0),r.node(t).rank=r.node(n).rank+(i?o.minlen:-o.minlen)})}(e,r)}function p(t,e,r){return r.low<=e.lim&&e.lim<=r.lim}return Jg=a,a.initLowLimValues=h,a.initCutValues=u,a.calcCutValue=c,a.leaveEdge=d,a.enterEdge=f,a.exchangeEdges=g,Jg}function ly(){if(ep)return tp;ep=1;var t=uy().longestPath,e=cy(),r=hy();tp=function(r){switch(r.graph().ranker){case"network-simplex":default:o(r);break;case"tight-tree":!function(r){t(r),e(r)}(r);break;case"longest-path":n(r)}};var n=t;function o(t){r(t)}return tp}function dy(){if(np)return rp;np=1;var t=ny();return rp=function(e){var r=function(e){var r={},n=0;function o(i){var s=n;t.forEach(e.children(i),o),r[i]={low:s,lim:n++}}return t.forEach(e.children(),o),r}(e);t.forEach(e.graph().dummyChains,function(t){for(var n=e.node(t),o=n.edgeObj,i=function(t,e,r,n){var o,i,s=[],a=[],u=Math.min(e[r].low,e[n].low),c=Math.max(e[r].lim,e[n].lim);o=r;do{o=t.parent(o),s.push(o)}while(o&&(e[o].low>u||c>e[o].lim));i=o,o=n;for(;(o=t.parent(o))!==i;)a.push(o);return{path:s.concat(a.reverse()),lca:i}}(e,r,o.v,o.w),s=i.path,a=i.lca,u=0,c=s[u],h=!0;t!==o.w;){if(n=e.node(t),h){for(;(c=s[u])!==a&&e.node(c).maxRank<n.rank;)u++;c===a&&(h=!1)}if(!h){for(;u<s.length-1&&e.node(c=s[u+1]).minRank<=n.rank;)u++;c=s[u]}e.setParent(t,c),t=e.successors(t)[0]}})},rp}function fy(){if(ip)return op;ip=1;var t=ny(),e=sy();function r(n,o,i,s,a,u,c){var h=n.children(c);if(h.length){var l=e.addBorderNode(n,"_bt"),d=e.addBorderNode(n,"_bb"),f=n.node(c);n.setParent(l,c),f.borderTop=l,n.setParent(d,c),f.borderBottom=d,t.forEach(h,function(t){r(n,o,i,s,a,u,t);var e=n.node(t),h=e.borderTop?e.borderTop:t,f=e.borderBottom?e.borderBottom:t,g=e.borderTop?s:2*s,p=h!==f?1:a-u[c]+1;n.setEdge(l,h,{weight:g,minlen:p,nestingEdge:!0}),n.setEdge(f,d,{weight:g,minlen:p,nestingEdge:!0})}),n.parent(c)||n.setEdge(o,l,{weight:0,minlen:a+u[c]})}else c!==o&&n.setEdge(o,c,{weight:0,minlen:i})}return op={run:function(n){var o=e.addDummyNode(n,"root",{},"_root"),i=function(e){var r={};function n(o,i){var s=e.children(o);s&&s.length&&t.forEach(s,function(t){n(t,i+1)}),r[o]=i}return t.forEach(e.children(),function(t){n(t,1)}),r}(n),s=t.max(t.values(i))-1,a=2*s+1;n.graph().nestingRoot=o,t.forEach(n.edges(),function(t){n.edge(t).minlen*=a});var u=function(e){return t.reduce(e.edges(),function(t,r){return t+e.edge(r).weight},0)}(n)+1;t.forEach(n.children(),function(t){r(n,o,a,u,s,i,t)}),n.graph().nodeRankFactor=a},cleanup:function(e){var r=e.graph();e.removeNode(r.nestingRoot),delete r.nestingRoot,t.forEach(e.edges(),function(t){e.edge(t).nestingEdge&&e.removeEdge(t)})}},op}function gy(){if(cp)return up;cp=1;var t=ny();function e(e){t.forEach(e.nodes(),function(t){r(e.node(t))}),t.forEach(e.edges(),function(t){r(e.edge(t))})}function r(t){var e=t.width;t.width=t.height,t.height=e}function n(t){t.y=-t.y}function o(t){var e=t.x;t.x=t.y,t.y=e}return up={adjust:function(t){var r=t.graph().rankdir.toLowerCase();"lr"!==r&&"rl"!==r||e(t)},undo:function(r){var i=r.graph().rankdir.toLowerCase();"bt"!==i&&"rl"!==i||function(e){t.forEach(e.nodes(),function(t){n(e.node(t))}),t.forEach(e.edges(),function(r){var o=e.edge(r);t.forEach(o.points,n),t.has(o,"y")&&n(o)})}(r);"lr"!==i&&"rl"!==i||(!function(e){t.forEach(e.nodes(),function(t){o(e.node(t))}),t.forEach(e.edges(),function(r){var n=e.edge(r);t.forEach(n.points,o),t.has(n,"x")&&o(n)})}(r),e(r))}},up}function py(){if(mp)return vp;mp=1;var t=ny();return vp=function(e,r){var n={};return t.forEach(e,function(e,r){var o=n[e.v]={indegree:0,in:[],out:[],vs:[e.v],i:r};t.isUndefined(e.barycenter)||(o.barycenter=e.barycenter,o.weight=e.weight)}),t.forEach(r.edges(),function(e){var r=n[e.v],o=n[e.w];t.isUndefined(r)||t.isUndefined(o)||(o.indegree++,r.out.push(n[e.w]))}),function(e){var r=[];function n(e){return function(r){r.merged||(t.isUndefined(r.barycenter)||t.isUndefined(e.barycenter)||r.barycenter>=e.barycenter)&&function(t,e){var r=0,n=0;t.weight&&(r+=t.barycenter*t.weight,n+=t.weight);e.weight&&(r+=e.barycenter*e.weight,n+=e.weight);t.vs=e.vs.concat(t.vs),t.barycenter=r/n,t.weight=n,t.i=Math.min(e.i,t.i),e.merged=!0}(e,r)}}function o(t){return function(r){r.in.push(t),0===--r.indegree&&e.push(r)}}for(;e.length;){var i=e.pop();r.push(i),t.forEach(i.in.reverse(),n(i)),t.forEach(i.out,o(i))}return t.map(t.filter(r,function(t){return!t.merged}),function(e){return t.pick(e,["vs","i","barycenter","weight"])})}(t.filter(n,function(t){return!t.indegree}))},vp}function vy(){if(bp)return xp;bp=1;var t=ny(),e=function(){if(pp)return gp;pp=1;var t=ny();return gp=function(e,r){return t.map(r,function(r){var n=e.inEdges(r);if(n.length){var o=t.reduce(n,function(t,r){var n=e.edge(r),o=e.node(r.v);return{sum:t.sum+n.weight*o.order,weight:t.weight+n.weight}},{sum:0,weight:0});return{v:r,barycenter:o.sum/o.weight,weight:o.weight}}return{v:r}})},gp}(),r=py(),n=function(){if(wp)return yp;wp=1;var t=ny(),e=sy();function r(e,r,n){for(var o;r.length&&(o=t.last(r)).i<=n;)r.pop(),e.push(o.vs),n++;return n}return yp=function(n,o){var i,s=e.partition(n,function(e){return t.has(e,"barycenter")}),a=s.lhs,u=t.sortBy(s.rhs,function(t){return-t.i}),c=[],h=0,l=0,d=0;a.sort((i=!!o,function(t,e){return t.barycenter<e.barycenter?-1:t.barycenter>e.barycenter?1:i?e.i-t.i:t.i-e.i})),d=r(c,u,d),t.forEach(a,function(t){d+=t.vs.length,c.push(t.vs),h+=t.barycenter*t.weight,l+=t.weight,d=r(c,u,d)});var f={vs:t.flatten(c,!0)};return l&&(f.barycenter=h/l,f.weight=l),f}}();return xp=function o(i,s,a,u){var c=i.children(s),h=i.node(s),l=h?h.borderLeft:void 0,d=h?h.borderRight:void 0,f={};l&&(c=t.filter(c,function(t){return t!==l&&t!==d}));var g=e(i,c);t.forEach(g,function(e){if(i.children(e.v).length){var r=o(i,e.v,a,u);f[e.v]=r,t.has(r,"barycenter")&&(n=e,s=r,t.isUndefined(n.barycenter)?(n.barycenter=s.barycenter,n.weight=s.weight):(n.barycenter=(n.barycenter*n.weight+s.barycenter*s.weight)/(n.weight+s.weight),n.weight+=s.weight))}var n,s});var p=r(g,a);!function(e,r){t.forEach(e,function(e){e.vs=t.flatten(e.vs.map(function(t){return r[t]?r[t].vs:t}),!0)})}(p,f);var v=n(p,u);if(l&&(v.vs=t.flatten([l,v.vs,d],!0),i.predecessors(l).length)){var m=i.node(i.predecessors(l)[0]),y=i.node(i.predecessors(d)[0]);t.has(v,"barycenter")||(v.barycenter=0,v.weight=0),v.barycenter=(v.barycenter*v.weight+m.order+y.order)/(v.weight+2),v.weight+=2}return v},xp}function my(){if(Mp)return Ep;Mp=1;var t=ny(),e=km().Graph;return Ep=function(r,n,o){var i=function(e){var r;for(;e.hasNode(r=t.uniqueId("_root")););return r}(r),s=new e({compound:!0}).setGraph({root:i}).setDefaultNodeLabel(function(t){return r.node(t)});return t.forEach(r.nodes(),function(e){var a=r.node(e),u=r.parent(e);(a.rank===n||a.minRank<=n&&n<=a.maxRank)&&(s.setNode(e),s.setParent(e,u||i),t.forEach(r[o](e),function(n){var o=n.v===e?n.w:n.v,i=s.edge(o,e),a=t.isUndefined(i)?0:i.weight;s.setEdge(o,e,{weight:r.edge(n).weight+a})}),t.has(a,"minRank")&&s.setNode(e,{borderLeft:a.borderLeft[n],borderRight:a.borderRight[n]}))}),s},Ep}function yy(){if(Sp)return kp;Sp=1;var t=ny(),e=function(){if(lp)return hp;lp=1;var t=ny();return hp=function(e){var r={},n=t.filter(e.nodes(),function(t){return!e.children(t).length}),o=t.max(t.map(n,function(t){return e.node(t).rank})),i=t.map(t.range(o+1),function(){return[]});function s(n){if(!t.has(r,n)){r[n]=!0;var o=e.node(n);i[o.rank].push(n),t.forEach(e.successors(n),s)}}var a=t.sortBy(n,function(t){return e.node(t).rank});return t.forEach(a,s),i},hp}(),r=function(){if(fp)return dp;fp=1;var t=ny();function e(e,r,n){for(var o=t.zipObject(n,t.map(n,function(t,e){return e})),i=t.flatten(t.map(r,function(r){return t.sortBy(t.map(e.outEdges(r),function(t){return{pos:o[t.w],weight:e.edge(t).weight}}),"pos")}),!0),s=1;s<n.length;)s<<=1;var a=2*s-1;s-=1;var u=t.map(new Array(a),function(){return 0}),c=0;return t.forEach(i.forEach(function(t){var e=t.pos+s;u[e]+=t.weight;for(var r=0;e>0;)e%2&&(r+=u[e+1]),u[e=e-1>>1]+=t.weight;c+=t.weight*r})),c}return dp=function(t,r){for(var n=0,o=1;o<r.length;++o)n+=e(t,r[o-1],r[o]);return n},dp}(),n=vy(),o=my(),i=function(){if(_p)return Np;_p=1;var t=ny();return Np=function(e,r,n){var o,i={};t.forEach(n,function(t){for(var n,s,a=e.parent(t);a;){if((n=e.parent(a))?(s=i[n],i[n]=a):(s=o,o=a),s&&s!==a)return void r.setEdge(s,a);a=n}})}}(),s=km().Graph,a=sy();function u(e,r,n){return t.map(r,function(t){return o(e,t,n)})}function c(e,r){var o=new s;t.forEach(e,function(e){var s=e.graph().root,a=n(e,s,o,r);t.forEach(a.vs,function(t,r){e.node(t).order=r}),i(e,o,a.vs)})}function h(e,r){t.forEach(r,function(r){t.forEach(r,function(t,r){e.node(t).order=r})})}return kp=function(n){var o=a.maxRank(n),i=u(n,t.range(1,o+1),"inEdges"),s=u(n,t.range(o-1,-1,-1),"outEdges"),l=e(n);h(n,l);for(var d,f=Number.POSITIVE_INFINITY,g=0,p=0;p<4;++g,++p){c(g%2?i:s,g%4>=2),l=a.buildLayerMatrix(n);var v=r(n,l);v<f&&(p=0,d=t.cloneDeep(l),f=v)}h(n,d)},kp}function wy(){if(Op)return Ap;Op=1;var t=ny(),e=km().Graph,r=sy();function n(e,r){var n={};return t.reduce(r,function(r,o){var s=0,a=0,u=r.length,c=t.last(o);return t.forEach(o,function(r,h){var l=function(e,r){if(e.node(r).dummy)return t.find(e.predecessors(r),function(t){return e.node(t).dummy})}(e,r),d=l?e.node(l).order:u;(l||r===c)&&(t.forEach(o.slice(a,h+1),function(r){t.forEach(e.predecessors(r),function(t){var o=e.node(t),a=o.order;!(a<s||d<a)||o.dummy&&e.node(r).dummy||i(n,t,r)})}),a=h+1,s=d)}),o}),n}function o(e,r){var n={};function o(r,o,s,a,u){var c;t.forEach(t.range(o,s),function(o){c=r[o],e.node(c).dummy&&t.forEach(e.predecessors(c),function(t){var r=e.node(t);r.dummy&&(r.order<a||r.order>u)&&i(n,t,c)})})}return t.reduce(r,function(r,n){var i,s=-1,a=0;return t.forEach(n,function(t,u){if("border"===e.node(t).dummy){var c=e.predecessors(t);c.length&&(i=e.node(c[0]).order,o(n,a,u,s,i),a=u,s=i)}o(n,a,n.length,i,r.length)}),n}),n}function i(t,e,r){if(e>r){var n=e;e=r,r=n}var o=t[e];o||(t[e]=o={}),o[r]=!0}function s(e,r,n){if(r>n){var o=r;r=n,n=o}return t.has(e[r],n)}function a(e,r,n,o){var i={},a={},u={};return t.forEach(r,function(e){t.forEach(e,function(t,e){i[t]=t,a[t]=t,u[t]=e})}),t.forEach(r,function(e){var r=-1;t.forEach(e,function(e){var c=o(e);if(c.length){c=t.sortBy(c,function(t){return u[t]});for(var h=(c.length-1)/2,l=Math.floor(h),d=Math.ceil(h);l<=d;++l){var f=c[l];a[e]===e&&r<u[f]&&!s(n,e,f)&&(a[f]=e,a[e]=i[e]=i[f],r=u[f])}}})}),{root:i,align:a}}function u(r,n,o,i,s){var a={},u=function(r,n,o,i){var s=new e,a=r.graph(),u=function(e,r,n){return function(o,i,s){var a,u=o.node(i),c=o.node(s),h=0;if(h+=u.width/2,t.has(u,"labelpos"))switch(u.labelpos.toLowerCase()){case"l":a=-u.width/2;break;case"r":a=u.width/2}if(a&&(h+=n?a:-a),a=0,h+=(u.dummy?r:e)/2,h+=(c.dummy?r:e)/2,h+=c.width/2,t.has(c,"labelpos"))switch(c.labelpos.toLowerCase()){case"l":a=c.width/2;break;case"r":a=-c.width/2}return a&&(h+=n?a:-a),a=0,h}}(a.nodesep,a.edgesep,i);return t.forEach(n,function(e){var n;t.forEach(e,function(t){var e=o[t];if(s.setNode(e),n){var i=o[n],a=s.edge(i,e);s.setEdge(i,e,Math.max(u(r,t,n),a||0))}n=t})}),s}(r,n,o,s),c=s?"borderLeft":"borderRight";function h(t,e){for(var r=u.nodes(),n=r.pop(),o={};n;)o[n]?t(n):(o[n]=!0,r.push(n),r=r.concat(e(n))),n=r.pop()}return h(function(t){a[t]=u.inEdges(t).reduce(function(t,e){return Math.max(t,a[e.v]+u.edge(e))},0)},u.predecessors.bind(u)),h(function(t){var e=u.outEdges(t).reduce(function(t,e){return Math.min(t,a[e.w]-u.edge(e))},Number.POSITIVE_INFINITY),n=r.node(t);e!==Number.POSITIVE_INFINITY&&n.borderType!==c&&(a[t]=Math.max(a[t],e))},u.successors.bind(u)),t.forEach(i,function(t){a[t]=a[o[t]]}),a}function c(e,r){return t.minBy(t.values(r),function(r){var n=Number.NEGATIVE_INFINITY,o=Number.POSITIVE_INFINITY;return t.forIn(r,function(t,r){var i=function(t,e){return t.node(e).width}(e,r)/2;n=Math.max(t+i,n),o=Math.min(t-i,o)}),n-o})}function h(e,r){var n=t.values(r),o=t.min(n),i=t.max(n);t.forEach(["u","d"],function(n){t.forEach(["l","r"],function(s){var a,u=n+s,c=e[u];if(c!==r){var h=t.values(c);(a="l"===s?o-t.min(h):i-t.max(h))&&(e[u]=t.mapValues(c,function(t){return t+a}))}})})}function l(e,r){return t.mapValues(e.ul,function(n,o){if(r)return e[r.toLowerCase()][o];var i=t.sortBy(t.map(e,o));return(i[1]+i[2])/2})}return Ap={positionX:function(e){var i,s=r.buildLayerMatrix(e),d=t.merge(n(e,s),o(e,s)),f={};t.forEach(["u","d"],function(r){i="u"===r?s:t.values(s).reverse(),t.forEach(["l","r"],function(n){"r"===n&&(i=t.map(i,function(e){return t.values(e).reverse()}));var o=("u"===r?e.predecessors:e.successors).bind(e),s=a(e,i,d,o),c=u(e,i,s.root,s.align,"r"===n);"r"===n&&(c=t.mapValues(c,function(t){return-t})),f[r+n]=c})});var g=c(e,f);return h(f,g),l(f,e.graph().align)},findType1Conflicts:n,findType2Conflicts:o,addConflict:i,hasConflict:s,verticalAlignment:a,horizontalCompaction:u,alignCoordinates:h,findSmallestWidthAlignment:c,balance:l},Ap}function xy(){if(jp)return zp;jp=1;var t=ny(),e=sy(),r=wy().positionX;return zp=function(n){(function(r){var n=e.buildLayerMatrix(r),o=r.graph().ranksep,i=0;t.forEach(n,function(e){var n=t.max(t.map(e,function(t){return r.node(t).height}));t.forEach(e,function(t){r.node(t).y=i+n/2}),i+=n+o})})(n=e.asNonCompoundGraph(n)),t.forEach(r(n),function(t,e){n.node(e).x=t})},zp}function by(){if(Ip)return Cp;Ip=1;var t=ny(),e=iy(),r=ay(),n=ly(),o=sy().normalizeRanks,i=dy(),s=sy().removeEmptyRanks,a=fy(),u=function(){if(ap)return sp;ap=1;var t=ny(),e=sy();function r(t,r,n,o,i,s){var a={width:0,height:0,rank:s,borderType:r},u=i[r][s-1],c=e.addDummyNode(t,"border",a,n);i[r][s]=c,t.setParent(c,o),u&&t.setEdge(u,c,{weight:1})}return sp=function(e){t.forEach(e.children(),function n(o){var i=e.children(o),s=e.node(o);if(i.length&&t.forEach(i,n),t.has(s,"minRank")){s.borderLeft=[],s.borderRight=[];for(var a=s.minRank,u=s.maxRank+1;a<u;++a)r(e,"borderLeft","_bl",o,s,a),r(e,"borderRight","_br",o,s,a)}})},sp}(),c=gy(),h=yy(),l=xy(),d=sy(),f=km().Graph;Cp=function(N,_){var k=_&&_.debugTiming?d.time:d.notime;k("layout",function(){var _=k(" buildLayoutGraph",function(){return function(e){var r=new f({multigraph:!0,compound:!0}),n=M(e.graph());return r.setGraph(t.merge({},p,E(n,g),t.pick(n,v))),t.forEach(e.nodes(),function(n){var o=M(e.node(n));r.setNode(n,t.defaults(E(o,m),y)),r.setParent(n,e.parent(n))}),t.forEach(e.edges(),function(n){var o=M(e.edge(n));r.setEdge(n,t.merge({},x,E(o,w),t.pick(o,b)))}),r}(N)});k(" runLayout",function(){!function(f,g){g(" makeSpaceForEdgeLabels",function(){!function(e){var r=e.graph();r.ranksep/=2,t.forEach(e.edges(),function(t){var n=e.edge(t);n.minlen*=2,"c"!==n.labelpos.toLowerCase()&&("TB"===r.rankdir||"BT"===r.rankdir?n.width+=n.labeloffset:n.height+=n.labeloffset)})}(f)}),g(" removeSelfEdges",function(){!function(e){t.forEach(e.edges(),function(t){if(t.v===t.w){var r=e.node(t.v);r.selfEdges||(r.selfEdges=[]),r.selfEdges.push({e:t,label:e.edge(t)}),e.removeEdge(t)}})}(f)}),g(" acyclic",function(){e.run(f)}),g(" nestingGraph.run",function(){a.run(f)}),g(" rank",function(){n(d.asNonCompoundGraph(f))}),g(" injectEdgeLabelProxies",function(){!function(e){t.forEach(e.edges(),function(t){var r=e.edge(t);if(r.width&&r.height){var n=e.node(t.v),o={rank:(e.node(t.w).rank-n.rank)/2+n.rank,e:t};d.addDummyNode(e,"edge-proxy",o,"_ep")}})}(f)}),g(" removeEmptyRanks",function(){s(f)}),g(" nestingGraph.cleanup",function(){a.cleanup(f)}),g(" normalizeRanks",function(){o(f)}),g(" assignRankMinMax",function(){!function(e){var r=0;t.forEach(e.nodes(),function(n){var o=e.node(n);o.borderTop&&(o.minRank=e.node(o.borderTop).rank,o.maxRank=e.node(o.borderBottom).rank,r=t.max(r,o.maxRank))}),e.graph().maxRank=r}(f)}),g(" removeEdgeLabelProxies",function(){!function(e){t.forEach(e.nodes(),function(t){var r=e.node(t);"edge-proxy"===r.dummy&&(e.edge(r.e).labelRank=r.rank,e.removeNode(t))})}(f)}),g(" normalize.run",function(){r.run(f)}),g(" parentDummyChains",function(){i(f)}),g(" addBorderSegments",function(){u(f)}),g(" order",function(){h(f)}),g(" insertSelfEdges",function(){!function(e){var r=d.buildLayerMatrix(e);t.forEach(r,function(r){var n=0;t.forEach(r,function(r,o){var i=e.node(r);i.order=o+n,t.forEach(i.selfEdges,function(t){d.addDummyNode(e,"selfedge",{width:t.label.width,height:t.label.height,rank:i.rank,order:o+ ++n,e:t.e,label:t.label},"_se")}),delete i.selfEdges})})}(f)}),g(" adjustCoordinateSystem",function(){c.adjust(f)}),g(" position",function(){l(f)}),g(" positionSelfEdges",function(){!function(e){t.forEach(e.nodes(),function(t){var r=e.node(t);if("selfedge"===r.dummy){var n=e.node(r.e.v),o=n.x+n.width/2,i=n.y,s=r.x-o,a=n.height/2;e.setEdge(r.e,r.label),e.removeNode(t),r.label.points=[{x:o+2*s/3,y:i-a},{x:o+5*s/6,y:i-a},{x:o+s,y:i},{x:o+5*s/6,y:i+a},{x:o+2*s/3,y:i+a}],r.label.x=r.x,r.label.y=r.y}})}(f)}),g(" removeBorderNodes",function(){!function(e){t.forEach(e.nodes(),function(r){if(e.children(r).length){var n=e.node(r),o=e.node(n.borderTop),i=e.node(n.borderBottom),s=e.node(t.last(n.borderLeft)),a=e.node(t.last(n.borderRight));n.width=Math.abs(a.x-s.x),n.height=Math.abs(i.y-o.y),n.x=s.x+n.width/2,n.y=o.y+n.height/2}}),t.forEach(e.nodes(),function(t){"border"===e.node(t).dummy&&e.removeNode(t)})}(f)}),g(" normalize.undo",function(){r.undo(f)}),g(" fixupEdgeLabelCoords",function(){!function(e){t.forEach(e.edges(),function(r){var n=e.edge(r);if(t.has(n,"x"))switch("l"!==n.labelpos&&"r"!==n.labelpos||(n.width-=n.labeloffset),n.labelpos){case"l":n.x-=n.width/2+n.labeloffset;break;case"r":n.x+=n.width/2+n.labeloffset}})}(f)}),g(" undoCoordinateSystem",function(){c.undo(f)}),g(" translateGraph",function(){!function(e){var r=Number.POSITIVE_INFINITY,n=0,o=Number.POSITIVE_INFINITY,i=0,s=e.graph(),a=s.marginx||0,u=s.marginy||0;function c(t){var e=t.x,s=t.y,a=t.width,u=t.height;r=Math.min(r,e-a/2),n=Math.max(n,e+a/2),o=Math.min(o,s-u/2),i=Math.max(i,s+u/2)}t.forEach(e.nodes(),function(t){c(e.node(t))}),t.forEach(e.edges(),function(r){var n=e.edge(r);t.has(n,"x")&&c(n)}),r-=a,o-=u,t.forEach(e.nodes(),function(t){var n=e.node(t);n.x-=r,n.y-=o}),t.forEach(e.edges(),function(n){var i=e.edge(n);t.forEach(i.points,function(t){t.x-=r,t.y-=o}),t.has(i,"x")&&(i.x-=r),t.has(i,"y")&&(i.y-=o)}),s.width=n-r+a,s.height=i-o+u}(f)}),g(" assignNodeIntersects",function(){!function(e){t.forEach(e.edges(),function(t){var r,n,o=e.edge(t),i=e.node(t.v),s=e.node(t.w);o.points?(r=o.points[0],n=o.points[o.points.length-1]):(o.points=[],r=s,n=i),o.points.unshift(d.intersectRect(i,r)),o.points.push(d.intersectRect(s,n))})}(f)}),g(" reversePoints",function(){!function(e){t.forEach(e.edges(),function(t){var r=e.edge(t);r.reversed&&r.points.reverse()})}(f)}),g(" acyclic.undo",function(){e.undo(f)})}(_,k)}),k(" updateInputGraph",function(){!function(e,r){t.forEach(e.nodes(),function(t){var n=e.node(t),o=r.node(t);n&&(n.x=o.x,n.y=o.y,r.children(t).length&&(n.width=o.width,n.height=o.height))}),t.forEach(e.edges(),function(n){var o=e.edge(n),i=r.edge(n);o.points=i.points,t.has(i,"x")&&(o.x=i.x,o.y=i.y)}),e.graph().width=r.graph().width,e.graph().height=r.graph().height}(N,_)})})};var g=["nodesep","edgesep","ranksep","marginx","marginy"],p={ranksep:50,edgesep:20,nodesep:50,rankdir:"tb"},v=["acyclicer","ranker","rankdir","align"],m=["width","height"],y={width:0,height:0},w=["minlen","weight","width","height","labeloffset"],x={minlen:1,weight:1,width:0,height:0,labeloffset:10,labelpos:"r"},b=["labelpos"];function E(e,r){return t.mapValues(t.pick(e,r),Number)}function M(e){var r={};return t.forEach(e,function(t,e){r[e.toLowerCase()]=t}),r}return Cp}function Ey(){if(Tp)return Rp;Tp=1;var t=ny(),e=sy(),r=km().Graph;return Rp={debugOrdering:function(n){var o=e.buildLayerMatrix(n),i=new r({compound:!0,multigraph:!0}).setGraph({});return t.forEach(n.nodes(),function(t){i.setNode(t,{label:t}),i.setParent(t,"layer"+n.node(t).rank)}),t.forEach(n.edges(),function(t){i.setEdge(t.v,t.w,{},t.name)}),t.forEach(o,function(e,r){var n="layer"+r;i.setNode(n,{rank:"same"}),t.reduce(e,function(t,e){return i.setEdge(t,e,{style:"invis"}),e})}),i}},Rp}var My=Dp?Lp:(Dp=1,Lp={graphlib:km(),layout:by(),debug:Ey(),util:{time:sy().time,notime:sy().notime},version:Fp?Pp:(Fp=1,Pp="0.8.5")}),Ny=ds(My);const _y=1e-6;function ky(t){var e;let r=0;if(t.length)for(let e=0;e<t.length;e++){const n=t[e];n&&n.r>r&&(r=n.r)}else if(t.data){r=t.data.r||0;let n=t.next;for(;n;)r=Math.max(r,(null===(e=n.data)||void 0===e?void 0:e.r)||0),n=n.next}t.r=r}function Sy(t=1,e=.005,r=2){function n(n,o){!function(t,e,r,n,o=2){const i=e/r,s=t.nodes(),a=s.map((t,e)=>{const{nodeStrength:r,x:n,y:o,z:s,size:a,mass:u}=t;return{x:n,y:o,z:s,size:a,index:e,id:t.id,vx:0,vy:0,vz:0,weight:i*r,mass:u||1}}),u=(2===o?jr(a,t=>t.x,t=>t.y):Dn(a,t=>t.x,t=>t.y,t=>t.z)).visitAfter(Ay),c=new Map;a.forEach(t=>{c.set(t.id,t),function(t,e,r){e.visit((e,n,o,i,s,a,u)=>Oy(e,n,o,i,s,a,u,t,r))}(t,u,o)}),a.map(t=>{const e=t.id;n[e]={x:t.vx/t.mass,y:t.vy/t.mass,z:t.vz/t.mass}})}(n,t,e*e,o,r)}return n.factor=function(e){return arguments.length?(t=e,n):t},n.coulombDisScale=function(t){return arguments.length?(e=t,n):e},n.dimensions=function(t){return arguments.length?(r=t,n):r},n}function Ay(t){let e=0,r=0,n=0,o=0,i=0;const s=t.length;if(s){for(let a=0;a<s;a++){const s=t[a];s&&s.weight&&(e+=s.weight,r+=s.x*s.weight,n+=s.y*s.weight,o+=s.z*s.weight,i+=s.size*s.weight)}t.x=r/e,t.y=n/e,t.z=o/e,t.size=i/e,t.weight=e}else{const e=t;t.x=e.data.x,t.y=e.data.y,t.z=e.data.z,t.size=e.data.size,t.weight=e.data.weight}}const Oy=(t,e,r,n,o,i,s,a,u)=>{var c;if((null===(c=t.data)||void 0===c?void 0:c.id)===a.id)return;const h=2===u?n:3===u?i:r,l=a.x-t.x||.1,d=a.y-t.y||.1,f=a.z-t.z||.1,g=[l,d,f],p=h-e;let v=0;for(let t=0;t<u;t++)v+=g[t]*g[t];const m=Math.sqrt(v)*v;if(p*p*.81<v){const e=t.weight/m;return a.vx+=l*e,a.vy+=d*e,a.vz+=f*e,!0}if(t.length)return!1;if(t.data!==a){const e=t.data.weight/m;a.vx+=l*e,a.vy+=d*e,a.vz+=f*e}};var zy=function(){function t(){this._events={}}return t.prototype.on=function(t,e,r){return this._events[t]||(this._events[t]=[]),this._events[t].push({callback:e,once:!!r}),this},t.prototype.once=function(t,e){return this.on(t,e,!0)},t.prototype.emit=function(t){for(var e=this,r=[],n=1;n<arguments.length;n++)r[n-1]=arguments[n];var o=this._events[t]||[],i=this._events["*"]||[],s=function(n){for(var o=n.length,i=0;i<o;i++)if(n[i]){var s=n[i],a=s.callback;s.once&&(n.splice(i,1),0===n.length&&delete e._events[t],o--,i--),a.apply(e,r)}};s(o),s(i)},t.prototype.off=function(t,e){if(t)if(e){for(var r=this._events[t]||[],n=r.length,o=0;o<n;o++)r[o].callback===e&&(r.splice(o,1),n--,o--);0===r.length&&delete this._events[t]}else delete this._events[t];else this._events={};return this},t.prototype.getEvents=function(){return this._events},t}();class jy extends zy{constructor(){super(...arguments),this.iteration=0,this.judgingDistance=1/0,this.running=!1,this.tickCallback=null,this.endCallback=null,this.timer=0}initialize(t){this.options=t,this.iteration=0,this.judgingDistance=1/0}on(t,e){return"tick"===t&&(this.tickCallback=e),"end"===t&&(this.endCallback=e),this}tick(t=1){var e;for(let r=0;r<t;r++){const t=this.runOneStep();this.judgingDistance=t,this.iteration++,null===(e=this.tickCallback)||void 0===e||e.call(this)}return this}restart(){if(this.running)return this;const{maxIteration:t=500,minMovement:e=0,animate:r=!0}=this.options;if(!r||"undefined"==typeof window){for(;this.iteration<t&&(this.judgingDistance>e||this.iteration<1);)this.tick(1);return Promise.resolve().then(()=>{var t;null===(t=this.endCallback)||void 0===t||t.call(this)}),this}return this.running=!0,this.timer=window.setInterval(()=>{var r;this.tick(1),(this.iteration>=t||this.judgingDistance<e)&&(this.stop(),null===(r=this.endCallback)||void 0===r||r.call(this))},0),this}stop(){return this.running=!1,this.timer&&(clearInterval(this.timer),this.timer=0),this}}class Cy extends jy{constructor(){super(...arguments),this.forces=new Map,this.velMap={}}data(t){return this.model=t,t.forEachNode(t=>{this.velMap[t.id]={x:0,y:0,z:0}}),this}force(t,e){return 1===arguments.length?this.forces.get(t)||null:(null===e?this.forces.delete(t):e&&this.forces.set(t,e),e||null)}runOneStep(){const t={},e=this.model.nodes();if(!e.length)return 0;e.forEach(e=>{t[e.id]={x:0,y:0,z:0}}),this.forces.forEach(e=>{e(this.model,t)}),this.updateVelocity(t);const r=this.updatePosition();return this.monitor(t,e),r}setFixedPosition(t,e){const r=this.model.node(t);if(!r)return;const n=["fx","fy","fz"];if(null===e)return void n.forEach(t=>delete r[t]);e.forEach((t,e)=>{e<n.length&&("number"==typeof t||null===t)&&(r[n[e]]=t)});const o=this.velMap[t];o&&(o.x=0,o.y=0,o.z=0)}updateVelocity(t){const{damping:e=.9,maxSpeed:r=100,interval:n=.02,dimensions:o=2}=this.options;this.model.nodes().forEach(i=>{const s=i.id;let a=(this.velMap[s].x+t[s].x*n)*e,u=(this.velMap[s].y+t[s].y*n)*e,c=3===o?(this.velMap[s].z+t[s].z*n)*e:0;const h=Math.sqrt(a*a+u*u+c*c);if(h>r){const t=r/h;a*=t,u*=t,c*=t}this.velMap[s]={x:a,y:u,z:c}})}updatePosition(){const{distanceThresholdMode:t="mean",interval:e=.02,dimensions:r=2}=this.options,n=this.model.nodes();let o=0,i="max"===t?-1/0:"min"===t?1/0:0;return n.forEach(n=>{const s=n.id;if(A(n.fx)&&A(n.fy))return n.x=n.fx,n.y=n.fy,void(3===r&&A(n.fz)&&(n.z=n.fz));const a=this.velMap[s].x*e,u=this.velMap[s].y*e,c=3===r?this.velMap[s].z*e:0;n.x+=a,n.y+=u,3===r&&(n.z=(n.z||0)+c);const h=Math.sqrt(a*a+u*u+c*c);"max"===t?i=Math.max(i,h):"min"===t?i=Math.min(i,h):o+=h}),"mean"===t?o/n.length:i}monitor(t,e){const{monitor:r,dimensions:n=2}=this.options;if(!r)return;let o=0;e.forEach(e=>{const r=t[e.id],i=r.x*r.x+r.y*r.y+(3===n?r.z*r.z:0);o+=(e.mass||1)*i*.5}),r({energy:o,nodes:e,edges:this.model.edges(),iterations:this.iteration})}}const Iy={nodeSize:30,dimensions:2,maxIteration:500,gravity:10,factor:1,edgeStrength:50,nodeStrength:1e3,coulombDisScale:.005,damping:.9,maxSpeed:200,minMovement:.4,interval:.02,linkDistance:200,clusterNodeStrength:20,collideStrength:1,preventOverlap:!0,distanceThresholdMode:"mean"};class Ry{constructor(t){this.id=t.id||0,this.rx=t.rx,this.ry=t.ry,this.fx=0,this.fy=0,this.mass=t.mass,this.degree=t.degree,this.g=t.g||0}distanceTo(t){const e=this.rx-t.rx,r=this.ry-t.ry;return Math.hypot(e,r)}setPos(t,e){this.rx=t,this.ry=e}resetForce(){this.fx=0,this.fy=0}addForce(t){const e=t.rx-this.rx,r=t.ry-this.ry;let n=Math.hypot(e,r);n=n<1e-4?1e-4:n;const o=this.g*(this.degree+1)*(t.degree+1)/n;this.fx+=o*e/n,this.fy+=o*r/n}in(t){return t.contains(this.rx,this.ry)}add(t){const e=this.mass+t.mass,r=(this.rx*this.mass+t.rx*t.mass)/e,n=(this.ry*this.mass+t.ry*t.mass)/e,o=this.degree+t.degree;return new Ry({rx:r,ry:n,mass:e,degree:o})}}class Ty{constructor(t){this.xmid=t.xmid,this.ymid=t.ymid,this.length=t.length,this.massCenter=t.massCenter||[0,0],this.mass=t.mass||1}getLength(){return this.length}contains(t,e){const r=this.length/2;return t<=this.xmid+r&&t>=this.xmid-r&&e<=this.ymid+r&&e>=this.ymid-r}NW(){const t=this.xmid-this.length/4,e=this.ymid+this.length/4,r=this.length/2;return new Ty({xmid:t,ymid:e,length:r})}NE(){const t=this.xmid+this.length/4,e=this.ymid+this.length/4,r=this.length/2;return new Ty({xmid:t,ymid:e,length:r})}SW(){const t=this.xmid-this.length/4,e=this.ymid-this.length/4,r=this.length/2;return new Ty({xmid:t,ymid:e,length:r})}SE(){const t=this.xmid+this.length/4,e=this.ymid-this.length/4,r=this.length/2;return new Ty({xmid:t,ymid:e,length:r})}}class Py{constructor(t){this.body=null,this.quad=null,this.NW=null,this.NE=null,this.SW=null,this.SE=null,this.theta=.5,null!=t&&(this.quad=t)}insert(t){null!=this.body?this._isExternal()?(this.quad&&(this.NW=new Py(this.quad.NW()),this.NE=new Py(this.quad.NE()),this.SW=new Py(this.quad.SW()),this.SE=new Py(this.quad.SE())),this._putBody(this.body),this._putBody(t),this.body=this.body.add(t)):(this.body=this.body.add(t),this._putBody(t)):this.body=t}_putBody(t){this.quad&&(t.in(this.quad.NW())&&this.NW?this.NW.insert(t):t.in(this.quad.NE())&&this.NE?this.NE.insert(t):t.in(this.quad.SW())&&this.SW?this.SW.insert(t):t.in(this.quad.SE())&&this.SE&&this.SE.insert(t))}_isExternal(){return null==this.NW&&null==this.NE&&null==this.SW&&null==this.SE}updateForce(t){if(null!=this.body&&t!==this.body)if(this._isExternal())t.addForce(this.body);else{(this.quad?this.quad.getLength():0)/this.body.distanceTo(t)<this.theta?t.addForce(this.body):(this.NW&&this.NW.updateForce(t),this.NE&&this.NE.updateForce(t),this.SW&&this.SW.updateForce(t),this.SE&&this.SE.updateForce(t))}}}let Fy=class extends jy{constructor(){super(...arguments),this.sg=0,this.forces={},this.preForces={},this.bodies={},this.sizes={},this.maxIteration=0}data(t,e){return this.model=t,this.sizes=e,this}initialize(t){super.initialize(t),this.maxIteration=t.maxIteration,this.sg=0,this.initForces()}initForces(){const{model:t,options:e}=this,{kr:r,barnesHut:n}=e,o=t.nodes();this.forces={},this.preForces={},this.bodies={};for(let e=0;e<o.length;e+=1){const i=o[e];if(this.forces[i.id]=[0,0],this.preForces[i.id]=[0,0],n){const n={id:e,rx:i.x,ry:i.y,mass:1,g:r,degree:t.degree(i.id)};this.bodies[i.id]=new Ry(n)}}}setFixedPosition(t,e){const r=this.model.node(t);if(!r)return;const n=["fx","fy","fz"];null!==e?e.forEach((t,e)=>{e<n.length&&("number"==typeof t||null===t)&&(r[n[e]]=t)}):n.forEach(t=>{delete r[t]})}isNodeFixed(t){return A(t.fx)&&A(t.fy)}syncFixedPositions(){this.model.forEachNode(t=>{this.isNodeFixed(t)&&(t.x=t.fx,t.y=t.fy)})}runOneStep(){const{model:t,options:e}=this,{preventOverlap:r,barnesHut:n}=e,o=this.maxIteration-this.iteration,i=t.nodes();for(let t=0;t<i.length;t+=1){const{id:e}=i[t];this.preForces[e]=[...this.forces[e]||[0,0]],this.forces[e]=[0,0]}return this.syncFixedPositions(),this.calculateAttractive(o),n&&!r?this.calculateOptRepulsiveGravity():this.calculateRepulsiveGravity(o,100),this.updatePositions()}calculateAttractive(t){const{model:e,options:r}=this,{preventOverlap:n,dissuadeHubs:o,mode:i,prune:s}=r,a=e.edges();for(let t=0;t<a.length;t+=1){const{source:r,target:u}=a[t],c=e.node(r),h=e.node(u),l=e.degree(r),d=e.degree(u);if(s&&(l<=1||d<=1))continue;const f=h.x-c.x,g=h.y-c.y;let p=Math.hypot(f,g);p=p<1e-4?1e-4:p;const v=f/p,m=g/p;let y=p;n&&(y=Math.max(0,p-this.sizes[r]-this.sizes[u]));let w=y,x=y;"linlog"===i&&(w=Math.log(1+y),x=w),o&&(w=y/l,x=y/d),this.forces[r][0]+=w*v,this.forces[r][1]+=w*m,this.forces[u][0]-=x*v,this.forces[u][1]-=x*m}}calculateOptRepulsiveGravity(){const{model:t,options:e}=this,{kg:r,center:n,prune:o,kr:i}=e,s=t.nodes(),a=s.length;let u=Number.POSITIVE_INFINITY,c=Number.NEGATIVE_INFINITY,h=Number.POSITIVE_INFINITY,l=Number.NEGATIVE_INFINITY;for(let e=0;e<a;e+=1){const r=s[e],{id:n,x:i,y:a}=r;if(o&&t.degree(n)<=1)continue;const d=this.bodies[n];d&&(d.setPos(i,a),i<u&&(u=i),i>c&&(c=i),a<h&&(h=a),a>l&&(l=a))}let d=Math.max(c-u,l-h);(!isFinite(d)||d<=0)&&(d=1);const f=new Ty({xmid:(c+u)/2,ymid:(l+h)/2,length:d,massCenter:n,mass:a}),g=new Py(f);for(let e=0;e<a;e+=1){const{id:r}=s[e];if(o&&t.degree(r)<=1)continue;const n=this.bodies[r];n&&n.in(f)&&g.insert(n)}for(let e=0;e<a;e+=1){const i=s[e],{id:a,x:u,y:c}=i,h=t.degree(a);if(o&&h<=1)continue;const l=this.bodies[a];if(!l)continue;l.resetForce(),g.updateForce(l),this.forces[a][0]-=l.fx,this.forces[a][1]-=l.fy;const d=u-n[0],f=c-n[1];let p=Math.hypot(d,f);p=p<1e-4?1e-4:p;const v=d/p,m=f/p,y=r*(h+1);this.forces[a][0]-=y*v,this.forces[a][1]-=y*m}}calculateRepulsiveGravity(t,e){const{model:r,options:n}=this,{preventOverlap:o,kr:i,kg:s,center:a,prune:u}=n,c=r.nodes(),h=c.length;for(let t=0;t<h;t+=1){const n=c[t],l=r.degree(n.id);for(let s=t+1;s<h;s+=1){const t=c[s],a=r.degree(t.id);if(u&&(l<=1||a<=1))continue;const h=t.x-n.x,d=t.y-n.y;let f=Math.hypot(h,d);f=f<1e-4?1e-4:f;const g=h/f,p=d/f;let v,m=f;if(o){const r=f-this.sizes[n.id]-this.sizes[t.id];r<0?v=e*(l+1)*(a+1):0===r?v=0:(m=r,v=i*(l+1)*(a+1)/m)}else v=i*(l+1)*(a+1)/m;this.forces[n.id][0]-=v*g,this.forces[n.id][1]-=v*p,this.forces[t.id][0]+=v*g,this.forces[t.id][1]+=v*p}const d=n.x-a[0],f=n.y-a[1];let g=Math.hypot(d,f);g=g<1e-4?1e-4:g;const p=d/g,v=f/g,m=s*(l+1);this.forces[n.id][0]-=m*p,this.forces[n.id][1]-=m*v}}updatePositions(){const{model:t,options:e}=this,{ks:r,tao:n,prune:o,ksmax:i,distanceThresholdMode:s="max"}=e,a=t.nodes(),u=a.length,c={},h={};let l=0,d=0;for(let e=0;e<u;e+=1){const{id:r}=a[e],n=t.degree(r);if(o&&n<=1)continue;const i=this.preForces[r]||[0,0],s=this.forces[r]||[0,0],u=s[0]-i[0],f=s[1]-i[1],g=Math.hypot(u,f),p=s[0]+i[0],v=s[1]+i[1],m=Math.hypot(p,v);c[r]=g,h[r]=m/2,l+=(n+1)*c[r],d+=(n+1)*h[r]}let f=this.sg;const g=this.sg;l<=0?f=g>0?g:1:(f=n*d/l,0!==g&&(f=f>1.5*g?1.5*g:f)),this.sg=f;let p=0,v=1/0,m=0,y=0;for(let e=0;e<u;e+=1){const n=a[e],s=n.id,u=t.degree(s);if(o&&u<=1)continue;if(this.isNodeFixed(n))continue;const h=c[s]||0;let l=r*f/(1+f*Math.sqrt(h)),d=Math.hypot(this.forces[s][0],this.forces[s][1]);d=d<1e-4?1e-4:d;const g=i/d;l>g&&(l=g);const w=l*this.forces[s][0],x=l*this.forces[s][1];n.x+=w,n.y+=x;const b=Math.hypot(w,x);b>0&&(y++,m+=b,b>p&&(p=b),b<v&&(v=b))}switch(s){case"min":return v;case"mean":return y>0?m/y:0;default:return p}}destroy(){this.stop(),this.forces={},this.preForces={},this.bodies={},this.sizes={},this.off()}};const Ly={nodeSize:10,nodeSpacing:0,width:300,height:300,kr:5,kg:1,mode:"normal",preventOverlap:!1,dissuadeHubs:!1,maxIteration:0,ks:.1,ksmax:10,tao:.1};class Dy extends jy{constructor(){super(...arguments),this.displacements=null,this.clusterMap=null}data(t){return this.model=t,this}initialize(t){super.initialize(t),this.recomputeConstants(),this.displacements=null,this.clusterMap=null,this.initDisplacements()}recomputeConstants(){const{model:t,options:e}=this,{width:r,height:n}=Et(e),o=r*n;this.k2=o/(t.nodeCount()+1),this.k=Math.sqrt(this.k2),this.maxDisplace=Math.sqrt(o)/10}runOneStep(){return this.syncFixedPositions(),this.initDisplacements(),this.calculateRepulsive(),this.calculateAttractive(),this.applyClusterGravity(),this.applyGlobalGravity(),this.updatePositions()}setFixedPosition(t,e){const r=this.model.node(t);if(!r)return;const n=["fx","fy","fz"];null!==e?e.forEach((t,e)=>{e<n.length&&("number"==typeof t||null===t)&&(r[n[e]]=t)}):n.forEach(t=>{delete r[t]})}isNodeFixed(t){return!E(t.fx)&&!E(t.fy)}syncFixedPositions(){const{model:t,options:e}=this,r=3===e.dimensions;t.forEachNode(t=>{this.isNodeFixed(t)&&(t.x=t.fx,t.y=t.fy,r&&void 0!==t.fz&&(t.z=t.fz))})}initDisplacements(){this.displacements||(this.displacements=new Map,this.model.forEachNode(t=>{this.displacements.set(t.id,{x:0,y:0,z:0})})),this.displacements.forEach(t=>{t.x=0,t.y=0,t.z=0})}calculateRepulsive(){const{model:t,options:e}=this,r=3===e.dimensions,n=t.nodes();for(let t=0;t<n.length;t++){const e=n[t],o=this.displacements.get(e.id),i=this.isNodeFixed(e);for(let s=t+1;s<n.length;s++){const t=n[s],a=this.displacements.get(t.id),u=this.isNodeFixed(t);let c=e.x-t.x,h=e.y-t.y,l=r?e.z-t.z:0,d=c*c+h*h+l*l;0===d&&(d=1,c=.01,h=.01,l=.01);const f=this.k2/d,g=c*f,p=h*f,v=l*f;i||u?i&&!u?(a.x-=2*g,a.y-=2*p,r&&(a.z-=2*v)):!i&&u&&(o.x+=2*g,o.y+=2*p,r&&(o.z+=2*v)):(o.x+=g,o.y+=p,a.x-=g,a.y-=p,r&&(o.z+=v,a.z-=v))}}}calculateAttractive(){const{model:t,options:e}=this,r=3===e.dimensions;t.forEachEdge(e=>{const{source:n,target:o}=e;if(!n||!o||n===o)return;const i=t.node(n),s=t.node(o),a=this.displacements.get(n),u=this.displacements.get(o),c=this.isNodeFixed(i),h=this.isNodeFixed(s),l=s.x-i.x,d=s.y-i.y,f=r?s.z-i.z:0,g=Math.sqrt(l*l+d*d+f*f);if(0===g)return;const p=g/this.k,v=l*p,m=d*p,y=f*p;c||h?c&&!h?(u.x-=2*v,u.y-=2*m,r&&(u.z-=2*y)):!c&&h&&(a.x+=2*v,a.y+=2*m,r&&(a.z+=2*y)):(a.x+=v,a.y+=m,u.x-=v,u.y-=m,r&&(a.z+=y,u.z-=y))})}applyClusterGravity(){const{model:t,options:e}=this,{nodeClusterBy:r,clusterGravity:n,dimensions:o,clustering:i}=e;if(!i)return;if(this.clusterMap||(this.clusterMap=new Map,t.forEachNode(e=>{const n=r(t.originalNode(e.id));this.clusterMap.has(n)||this.clusterMap.set(n,{name:n,cx:0,cy:0,cz:0,count:0})})),0===this.clusterMap.size)return;const s=3===o;this.clusterMap.forEach(t=>{t.cx=0,t.cy=0,t.cz=0,t.count=0}),t.forEachNode(e=>{const n=r(t.originalNode(e.id)),o=this.clusterMap.get(n);o&&(o.cx+=e.x,o.cy+=e.y,s&&(o.cz+=e.z),o.count++)}),this.clusterMap.forEach(t=>{t.count>0&&(t.cx/=t.count,t.cy/=t.count,t.cz/=t.count)}),t.forEachNode(e=>{const{id:o}=e;if(this.isNodeFixed(e))return;const i=r(t.originalNode(o)),a=this.clusterMap.get(i);if(!a)return;const u=this.displacements.get(o),c=e.x-a.cx,h=e.y-a.cy,l=s?e.z-a.cz:0,d=Math.sqrt(c*c+h*h+l*l);if(0===d)return;const f=this.k*n;u.x-=f*c/d,u.y-=f*h/d,s&&(u.z-=f*l/d)})}applyGlobalGravity(){const{model:t,options:e}=this,{gravity:r,center:n,dimensions:o}=e,i=3===o,s=.01*this.k*r;t.forEachNode(t=>{const{id:e}=t;if(this.isNodeFixed(t))return;const r=this.displacements.get(e);r.x-=s*(t.x-n[0]),r.y-=s*(t.y-n[1]),i&&(r.z-=s*(t.z-(n[2]||0)))})}updatePositions(){const{model:t,options:e}=this,{speed:r,dimensions:n,distanceThresholdMode:o="max"}=e,i=3===n;let s=0,a=1/0,u=0,c=0;if(t.forEachNode(t=>{const{id:e}=t;if(this.isNodeFixed(t))return;const n=this.displacements.get(e),o=Math.sqrt(n.x*n.x+n.y*n.y+(i?n.z*n.z:0));if(0===o)return;const h=Math.min(this.maxDisplace*(r/800),o),l=h/o;t.x+=n.x*l,t.y+=n.y*l,i&&(t.z=t.z+n.z*l),s=Math.max(s,h),a=Math.min(a,h),u+=h,c++}),0===c)return 0;switch(o){case"min":return a===1/0?0:a;case"mean":return u/c;default:return s}}destroy(){var t,e;this.stop(),null===(t=this.displacements)||void 0===t||t.clear(),null===(e=this.clusterMap)||void 0===e||e.clear()}}const qy={maxIteration:1e3,gravity:10,speed:5,clustering:!1,clusterGravity:10,width:300,height:300,nodeClusterBy:"node.cluster",dimensions:2};const By={begin:[0,0],preventOverlap:!0,condense:!1,rows:void 0,cols:void 0,position:void 0,sortBy:"degree",nodeSize:30,nodeSpacing:10,width:300,height:300};const Vy=(t,e)=>{let r;const n=t.rows||5,o=t.cols||5;if(null==e)r=Math.min(n,o);else{Math.min(n,o)===t.rows?t.rows=e:t.cols=e}return r},$y=(t,e)=>{let r;const n=t.rows||5,o=t.cols||5;if(null==e)r=Math.max(n,o);else{Math.max(n,o)===t.rows?t.rows=e:t.cols=e}return r},Uy=(t,e)=>t[`c-${e.row}-${e.col}`]||!1,Gy=(t,e)=>t[`c-${e.row}-${e.col}`]=!0,Wy=(t,e)=>{const r=t.cols||5;e.col++,e.col>=r&&(e.col=0,e.row++)},Yy=(t,e,r,n,o,i,s,a)=>{let u,c;const h=o[t.id];if(h)u=h.col*r+r/2+e[0],c=h.row*n+n/2+e[1];else{for(;Uy(a,s);)Wy(i,s);u=s.col*r+r/2+e[0],c=s.row*n+n/2+e[1],Gy(a,s),Wy(i,s)}t.x=u,t.y=c};var Hy={};const Xy=Object.prototype.toString;function Qy(t){const e=Xy.call(t);return e.endsWith("Array]")&&!e.includes("Big")}var Ky=fs(Object.freeze({__proto__:null,isAnyArray:Qy}));var Jy,Zy=Object.freeze({__proto__:null,default:function(t){var e,r=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};if(!Qy(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(!Qy(r.output))throw new TypeError("output option must be an array if specified");e=r.output}else e=new Array(t.length);var n=function(t){var e=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};if(!Qy(t))throw new TypeError("input must be an array");if(0===t.length)throw new TypeError("input must not be empty");var r=e.fromIndex,n=void 0===r?0:r,o=e.toIndex,i=void 0===o?t.length:o;if(n<0||n>=t.length||!Number.isInteger(n))throw new Error("fromIndex must be a positive integer smaller than length");if(i<=n||i>t.length||!Number.isInteger(i))throw new Error("toIndex must be an integer greater than fromIndex and at most equal to length");for(var s=t[n],a=n+1;a<i;a++)t[a]<s&&(s=t[a]);return s}(t),o=function(t){var e=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};if(!Qy(t))throw new TypeError("input must be an array");if(0===t.length)throw new TypeError("input must not be empty");var r=e.fromIndex,n=void 0===r?0:r,o=e.toIndex,i=void 0===o?t.length:o;if(n<0||n>=t.length||!Number.isInteger(n))throw new Error("fromIndex must be a positive integer smaller than length");if(i<=n||i>t.length||!Number.isInteger(i))throw new Error("toIndex must be an integer greater than fromIndex and at most equal to length");for(var s=t[n],a=n+1;a<i;a++)t[a]>s&&(s=t[a]);return s}(t);if(n===o)throw new RangeError("minimum and maximum input values are equal. Cannot rescale a constant array");var i=r.min,s=void 0===i?r.autoMinMax?n:0:i,a=r.max,u=void 0===a?r.autoMinMax?o:1:a;if(s>=u)throw new RangeError("min option must be smaller than max option");for(var c=(u-s)/(o-n),h=0;h<t.length;h++)e[h]=(t[h]-n)*c+s;return e}}),tw=fs(Zy);function ew(){if(Jy)return Hy;Jy=1,Object.defineProperty(Hy,"__esModule",{value:!0});var t=Ky,e=tw;const r=" ".repeat(2),n=" ".repeat(4);function o(t,e={}){const{maxRows:o=15,maxColumns:s=10,maxNumSize:a=8,padMinus:u="auto"}=e;return`${t.constructor.name} {\n${r}[\n${n}${function(t,e,r,o,s){const{rows:a,columns:u}=t,c=Math.min(a,e),h=Math.min(u,r),l=[];if("auto"===s){s=!1;t:for(let e=0;e<c;e++)for(let r=0;r<h;r++)if(t.get(e,r)<0){s=!0;break t}}for(let e=0;e<c;e++){let r=[];for(let n=0;n<h;n++)r.push(i(t.get(e,n),o,s));l.push(`${r.join(" ")}`)}h!==u&&(l[l.length-1]+=` ... ${u-r} more columns`);c!==a&&l.push(`... ${a-e} more rows`);return l.join(`\n${n}`)}(t,o,s,a,u)}\n${r}]\n${r}rows: ${t.rows}\n${r}columns: ${t.columns}\n}`}function i(t,e,r){return(t>=0&&r?` ${s(t,e-1)}`:s(t,e)).padEnd(e)}function s(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 a(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 u(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 c(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 h(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 l(e,r){if(!t.isAnyArray(r))throw new TypeError("row indices must be an array");for(let t=0;t<r.length;t++)if(r[t]<0||r[t]>=e.rows)throw new RangeError("row indices are out of range")}function d(e,r){if(!t.isAnyArray(r))throw new TypeError("column indices must be an array");for(let t=0;t<r.length;t++)if(r[t]<0||r[t]>=e.columns)throw new RangeError("column indices are out of range")}function f(t,e,r,n,o){if(5!==arguments.length)throw new RangeError("expected 4 arguments");if(p("startRow",e),p("endRow",r),p("startColumn",n),p("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 g(t,e=0){let r=[];for(let n=0;n<t;n++)r.push(e);return r}function p(t,e){if("number"!=typeof e)throw new TypeError(`${t} must be a number`)}function v(t){if(t.isEmpty())throw new Error("Empty matrix has no elements to index")}class m{static from1DArray(t,e,r){if(t*e!==r.length)throw new RangeError("data length does not match given dimensions");let n=new x(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 x(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 x(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 x(t,e)}static ones(t,e){return new x(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 x(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 x(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 x(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 m.isMatrix(t)?t:new x(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}isDistance(){if(!this.isSymmetric())return!1;for(let t=0;t<this.rows;t++)if(0!==this.get(t,t))return!1;return!0}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 x(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){a(this,t);let e=[];for(let r=0;r<this.columns;r++)e.push(this.get(t,r));return e}getRowVector(t){return x.rowVector(this.getRow(t))}setRow(t,e){a(this,t),e=c(this,e);for(let r=0;r<this.columns;r++)this.set(t,r,e[r]);return this}swapRows(t,e){a(this,t),a(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){u(this,t);let e=[];for(let r=0;r<this.rows;r++)e.push(this.get(r,t));return e}getColumnVector(t){return x.columnVector(this.getColumn(t))}setColumn(t,e){u(this,t),e=h(this,e);for(let r=0;r<this.rows;r++)this.set(r,t,e[r]);return this}swapColumns(t,e){u(this,t),u(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=c(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=c(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=c(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=c(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=h(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=h(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=h(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=h(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){a(this,t);for(let r=0;r<this.columns;r++)this.set(t,r,this.get(t,r)*e);return this}mulColumn(t,e){u(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(){v(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(){v(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(a(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){a(this,t),v(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(a(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){a(this,t),v(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(u(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){u(this,t),v(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(u(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){u(this,t),v(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"){switch(t){case"max":return this.max();case"frobenius":return Math.sqrt(this.dot(this));default: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){m.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=x.checkMatrix(t);let e=this.rows,r=this.columns,n=t.columns,o=new x(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}mpow(t){if(!this.isSquare())throw new RangeError("Matrix must be square");if(!Number.isInteger(t)||t<0)throw new RangeError("Exponent must be a non-negative integer");let e=x.eye(this.rows),r=this;for(let n=t;n>=1;n/=2)1&n&&(e=e.mmul(r)),r=r.mmul(r);return e}strassen2x2(t){t=x.checkMatrix(t);let e=new x(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),c=t.get(1,1),h=(r+u)*(n+c),l=(s+u)*n,d=r*(i-c),f=u*(a-n),g=(r+o)*c,p=h+f-g+(o-u)*(a+c),v=d+g,m=l+f,y=h-l+d+(s-r)*(n+i);return e.set(0,0,p),e.set(0,1,v),e.set(1,0,m),e.set(1,1,y),e}strassen3x3(t){t=x.checkMatrix(t);let e=new x(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),c=this.get(2,1),h=this.get(2,2),l=t.get(0,0),d=t.get(0,1),f=t.get(0,2),g=t.get(1,0),p=t.get(1,1),v=t.get(1,2),m=t.get(2,0),y=t.get(2,1),w=t.get(2,2),b=(r-i)*(-d+p),E=(-r+i+s)*(l-d+p),M=(i+s)*(-l+d),N=r*l,_=(-r+u+c)*(l-f+v),k=(-r+u)*(f-v),S=(u+c)*(-l+f),A=(-o+c+h)*(p+m-y),O=(o-h)*(p-y),z=o*m,j=(c+h)*(-m+y),C=(-o+s+a)*(v+m-w),I=(o-a)*(v-w),R=(s+a)*(-m+w),T=N+z+n*g,P=(r+n+o-i-s-c-h)*p+E+M+N+A+z+j,F=N+_+S+(r+n+o-s-a-u-c)*v+z+C+R,L=b+s*(-l+d+g-p-v-m+w)+E+N+z+C+I,D=b+E+M+N+a*y,q=z+C+I+R+i*f,B=N+_+k+c*(-l+f+g-p-v-m+y)+A+O+z,V=A+O+z+j+u*d,$=N+_+k+S+h*w;return e.set(0,0,T),e.set(0,1,P),e.set(0,2,F),e.set(1,0,L),e.set(1,1,D),e.set(1,2,q),e.set(2,0,B),e.set(2,1,V),e.set(2,2,$),e}mmulStrassen(t){t=x.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=m.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),c=r.subMatrix(0,i-1,0,a-1),h=e.subMatrix(0,i-1,a,e.columns-1),l=r.subMatrix(0,i-1,a,r.columns-1),d=e.subMatrix(i,e.rows-1,0,a-1),f=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),v=t(m.add(u,g),m.add(c,p),i,a),y=t(m.add(d,g),c,i,a),w=t(u,m.sub(l,p),i,a),x=t(g,m.sub(f,c),i,a),b=t(m.add(u,h),p,i,a),E=t(m.sub(d,u),m.add(c,l),i,a),M=t(m.sub(h,g),m.add(f,p),i,a),N=m.add(v,x);N.sub(b),N.add(M);let _=m.add(w,b),k=m.add(y,x),S=m.sub(v,y);S.add(w),S.add(E);let A=m.zeros(2*N.rows,2*N.columns);return A=A.setSubMatrix(N,0,0),A=A.setSubMatrix(_,N.rows,0),A=A.setSubMatrix(k,0,N.columns),A=A.setSubMatrix(S,N.rows,N.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:r=0,max:n=1}=t;if(!Number.isFinite(r))throw new TypeError("min must be a number");if(!Number.isFinite(n))throw new TypeError("max must be a number");if(r>=n)throw new RangeError("min must be smaller than max");let o=new x(this.rows,this.columns);for(let t=0;t<this.rows;t++){const i=this.getRow(t);i.length>0&&e(i,{min:r,max:n,output:i}),o.setRow(t,i)}return o}scaleColumns(t={}){if("object"!=typeof t)throw new TypeError("options must be an object");const{min:r=0,max:n=1}=t;if(!Number.isFinite(r))throw new TypeError("min must be a number");if(!Number.isFinite(n))throw new TypeError("max must be a number");if(r>=n)throw new RangeError("min must be smaller than max");let o=new x(this.rows,this.columns);for(let t=0;t<this.columns;t++){const i=this.getColumn(t);i.length&&e(i,{min:r,max:n,output:i}),o.setColumn(t,i)}return o}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=x.checkMatrix(t);let e=this.rows,r=this.columns,n=t.rows,o=t.columns,i=new x(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=x.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(x.eye(r,r)),o=x.eye(e,e).kroneckerProduct(t);return n.add(o)}transpose(){let t=new x(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=y){for(let e=0;e<this.rows;e++)this.setRow(e,this.getRow(e).sort(t));return this}sortColumns(t=y){for(let e=0;e<this.columns;e++)this.setColumn(e,this.getColumn(e).sort(t));return this}subMatrix(t,e,r,n){f(this,t,e,r,n);let o=new x(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 x(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 x(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=x.checkMatrix(t)).isEmpty())return this;f(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){l(this,t),d(this,e);let r=new x(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(){return this.constructor.copy(this,new x(this.rows,this.columns))}static copy(t,e){for(const[r,n,o]of t.entries())e.set(r,n,o);return e}sum(t){switch(t){case"row":return function(t){let e=g(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=g(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=g(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=g(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(e,r={}){if("object"==typeof e&&(r=e,e=void 0),"object"!=typeof r)throw new TypeError("options must be an object");const{unbiased:n=!0,mean:o=this.mean(e)}=r;if("boolean"!=typeof n)throw new TypeError("unbiased must be a boolean");switch(e){case"row":if(!t.isAnyArray(o))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,n,o);case"column":if(!t.isAnyArray(o))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,n,o);case void 0:if("number"!=typeof o)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,n,o);default:throw new Error(`invalid option: ${e}`)}}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(e,r={}){if("object"==typeof e&&(r=e,e=void 0),"object"!=typeof r)throw new TypeError("options must be an object");const{center:n=this.mean(e)}=r;switch(e){case"row":if(!t.isAnyArray(n))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,n),this;case"column":if(!t.isAnyArray(n))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,n),this;case void 0:if("number"!=typeof n)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,n),this;default:throw new Error(`invalid option: ${e}`)}}scale(e,r={}){if("object"==typeof e&&(r=e,e=void 0),"object"!=typeof r)throw new TypeError("options must be an object");let n=r.scale;switch(e){case"row":if(void 0===n)n=function(t){const e=[];for(let r=0;r<t.rows;r++){let n=0;for(let e=0;e<t.columns;e++)n+=t.get(r,e)**2/(t.columns-1);e.push(Math.sqrt(n))}return e}(this);else if(!t.isAnyArray(n))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,n),this;case"column":if(void 0===n)n=function(t){const e=[];for(let r=0;r<t.columns;r++){let n=0;for(let e=0;e<t.rows;e++)n+=t.get(e,r)**2/(t.rows-1);e.push(Math.sqrt(n))}return e}(this);else if(!t.isAnyArray(n))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,n),this;case void 0:if(void 0===n)n=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+=t.get(o,n)**2/e;return Math.sqrt(r)}(this);else if("number"!=typeof n)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,n),this;default:throw new Error(`invalid option: ${e}`)}}toString(t){return o(this,t)}[Symbol.iterator](){return this.entries()}*entries(){for(let t=0;t<this.rows;t++)for(let e=0;e<this.columns;e++)yield[t,e,this.get(t,e)]}*values(){for(let t=0;t<this.rows;t++)for(let e=0;e<this.columns;e++)yield this.get(t,e)}}function y(t,e){return t-e}function w(t){return t.every(t=>"number"==typeof t)}m.prototype.klass="Matrix","undefined"!=typeof Symbol&&(m.prototype[Symbol.for("nodejs.util.inspect.custom")]=function(){return o(this)}),m.random=m.rand,m.randomInt=m.randInt,m.diagonal=m.diag,m.prototype.diagonal=m.prototype.diag,m.identity=m.eye,m.prototype.negate=m.prototype.neg,m.prototype.tensorProduct=m.prototype.kroneckerProduct;class x extends m{data;#t(t,e){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));this.rows=t,this.columns=e}constructor(e,r){if(super(),x.isMatrix(e))this.#t(e.rows,e.columns),x.copy(e,this);else if(Number.isInteger(e)&&e>=0)this.#t(e,r);else{if(!t.isAnyArray(e))throw new TypeError("First argument must be a positive number or an array");{const t=e;if("number"!=typeof(r=(e=t.length)?t[0].length:0))throw new TypeError("Data must be a 2D array with at least one element");this.data=[];for(let n=0;n<e;n++){if(t[n].length!==r)throw new RangeError("Inconsistent array dimensions");if(!w(t[n]))throw new TypeError("Input data contains non-numeric values");this.data.push(Float64Array.from(t[n]))}this.rows=e,this.columns=r}}}set(t,e,r){return this.data[t][e]=r,this}get(t,e){return this.data[t][e]}removeRow(t){return a(this,t),this.data.splice(t,1),this.rows-=1,this}addRow(t,e){return void 0===e&&(e=t,t=this.rows),a(this,t,!0),e=Float64Array.from(c(this,e)),this.data.splice(t,0,e),this.rows+=1,this}removeColumn(t){u(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),u(this,t,!0),e=h(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,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,this.get(e,r)**t.get(e,r));return this}}(m,x);class b extends m{#e;get size(){return this.#e.size}get rows(){return this.#e.rows}get columns(){return this.#e.columns}get diagonalSize(){return this.rows}static isSymmetricMatrix(t){return x.isMatrix(t)&&"SymmetricMatrix"===t.klassType}static zeros(t){return new this(t)}static ones(t){return new this(t).fill(1)}constructor(t){if(super(),x.isMatrix(t)){if(!t.isSymmetric())throw new TypeError("not symmetric data");this.#e=x.copy(t,new x(t.rows,t.rows))}else if(Number.isInteger(t)&&t>=0)this.#e=new x(t,t);else if(this.#e=new x(t),!this.isSymmetric())throw new TypeError("not symmetric data")}clone(){const t=new b(this.diagonalSize);for(const[e,r,n]of this.upperRightEntries())t.set(e,r,n);return t}toMatrix(){return new x(this)}get(t,e){return this.#e.get(t,e)}set(t,e,r){return this.#e.set(t,e,r),this.#e.set(e,t,r),this}removeCross(t){return this.#e.removeRow(t),this.#e.removeColumn(t),this}addCross(t,e){void 0===e&&(e=t,t=this.diagonalSize);const r=e.slice();return r.splice(t,1),this.#e.addRow(t,r),this.#e.addColumn(t,e),this}applyMask(t){if(t.length!==this.diagonalSize)throw new RangeError("Mask size do not match with matrix size");const e=[];for(const[r,n]of t.entries())n||e.push(r);e.reverse();for(const t of e)this.removeCross(t);return this}toCompact(){const{diagonalSize:t}=this,e=new Array(t*(t+1)/2);for(let r=0,n=0,o=0;o<e.length;o++)e[o]=this.get(n,r),++r>=t&&(r=++n);return e}static fromCompact(t){const e=t.length,r=(Math.sqrt(8*e+1)-1)/2;if(!Number.isInteger(r))throw new TypeError(`This array is not a compact representation of a Symmetric Matrix, ${JSON.stringify(t)}`);const n=new b(r);for(let o=0,i=0,s=0;s<e;s++)n.set(o,i,t[s]),++o>=r&&(o=++i);return n}*upperRightEntries(){for(let t=0,e=0;t<this.diagonalSize;void 0){const r=this.get(t,e);yield[t,e,r],++e>=this.diagonalSize&&(e=++t)}}*upperRightValues(){for(let t=0,e=0;t<this.diagonalSize;void 0){const r=this.get(t,e);yield r,++e>=this.diagonalSize&&(e=++t)}}}b.prototype.klassType="SymmetricMatrix";class E extends b{static isDistanceMatrix(t){return b.isSymmetricMatrix(t)&&"DistanceMatrix"===t.klassSubType}constructor(t){if(super(t),!this.isDistance())throw new TypeError("Provided arguments do no produce a distance matrix")}set(t,e,r){return t===e&&(r=0),super.set(t,e,r)}addCross(t,e){return void 0===e&&(e=t,t=this.diagonalSize),(e=e.slice())[t]=0,super.addCross(t,e)}toSymmetricMatrix(){return new b(this)}clone(){const t=new E(this.diagonalSize);for(const[e,r,n]of this.upperRightEntries())e!==r&&t.set(e,r,n);return t}toCompact(){const{diagonalSize:t}=this,e=new Array((t-1)*t/2);for(let r=1,n=0,o=0;o<e.length;o++)e[o]=this.get(n,r),++r>=t&&(r=1+ ++n);return e}static fromCompact(t){const e=t.length;if(0===e)return new this(0);const r=(Math.sqrt(8*e+1)+1)/2;if(!Number.isInteger(r))throw new TypeError(`This array is not a compact representation of a DistanceMatrix, ${JSON.stringify(t)}`);const n=new this(r);for(let o=1,i=0,s=0;s<e;s++)n.set(o,i,t[s]),++o>=r&&(o=1+ ++i);return n}}E.prototype.klassSubType="DistanceMatrix";class M extends m{constructor(t,e,r){super(),this.matrix=t,this.rows=e,this.columns=r}}class N extends M{constructor(t,e,r){l(t,e),d(t,r),super(t,e.length,r.length),this.rowIndices=e,this.columnIndices=r}set(t,e,r){return this.matrix.set(this.rowIndices[t],this.columnIndices[e],r),this}get(t,e){return this.matrix.get(this.rowIndices[t],this.columnIndices[e])}}class _ extends m{constructor(t,e={}){const{rows:r=1}=e;if(t.length%r!==0)throw new Error("the data length is not divisible by the number of rows");super(),this.rows=r,this.columns=t.length/r,this.data=t}set(t,e,r){let n=this._calculateIndex(t,e);return this.data[n]=r,this}get(t,e){let r=this._calculateIndex(t,e);return this.data[r]}_calculateIndex(t,e){return t*this.columns+e}}class k extends m{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]}}class S{constructor(t){let e,r,n,o,i,s,a,u,c,h=(t=k.checkMatrix(t)).clone(),l=h.rows,d=h.columns,f=new Float64Array(l),g=1;for(e=0;e<l;e++)f[e]=e;for(u=new Float64Array(l),r=0;r<d;r++){for(e=0;e<l;e++)u[e]=h.get(e,r);for(e=0;e<l;e++){for(c=Math.min(e,r),i=0,n=0;n<c;n++)i+=h.get(e,n)*u[n];u[e]-=i,h.set(e,r,u[e])}for(o=r,e=r+1;e<l;e++)Math.abs(u[e])>Math.abs(u[o])&&(o=e);if(o!==r){for(n=0;n<d;n++)s=h.get(o,n),h.set(o,n,h.get(r,n)),h.set(r,n,s);a=f[o],f[o]=f[r],f[r]=a,g=-g}if(r<l&&0!==h.get(r,r))for(e=r+1;e<l;e++)h.set(e,r,h.get(e,r)/h.get(r,r))}this.LU=h,this.pivotVector=f,this.pivotSign=g}isSingular(){let t=this.LU,e=t.columns;for(let r=0;r<e;r++)if(0===t.get(r,r))return!0;return!1}solve(t){t=x.checkMatrix(t);let e=this.LU;if(e.rows!==t.rows)throw new Error("Invalid matrix dimensions");if(this.isSingular())throw new Error("LU matrix is singular");let r,n,o,i=t.columns,s=t.subMatrixRow(this.pivotVector,0,i-1),a=e.columns;for(o=0;o<a;o++)for(r=o+1;r<a;r++)for(n=0;n<i;n++)s.set(r,n,s.get(r,n)-s.get(o,n)*e.get(r,o));for(o=a-1;o>=0;o--){for(n=0;n<i;n++)s.set(o,n,s.get(o,n)/e.get(o,o));for(r=0;r<o;r++)for(n=0;n<i;n++)s.set(r,n,s.get(r,n)-s.get(o,n)*e.get(r,o))}return s}get determinant(){let t=this.LU;if(!t.isSquare())throw new Error("Matrix must be square");let e=this.pivotSign,r=t.columns;for(let n=0;n<r;n++)e*=t.get(n,n);return e}get lowerTriangularMatrix(){let t=this.LU,e=t.rows,r=t.columns,n=new x(e,r);for(let o=0;o<e;o++)for(let e=0;e<r;e++)o>e?n.set(o,e,t.get(o,e)):o===e?n.set(o,e,1):n.set(o,e,0);return n}get upperTriangularMatrix(){let t=this.LU,e=t.rows,r=t.columns,n=new x(e,r);for(let o=0;o<e;o++)for(let e=0;e<r;e++)o<=e?n.set(o,e,t.get(o,e)):n.set(o,e,0);return n}get pivotPermutationVector(){return Array.from(this.pivotVector)}}function A(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 O{constructor(t){let e,r,n,o,i=(t=k.checkMatrix(t)).clone(),s=t.rows,a=t.columns,u=new Float64Array(a);for(n=0;n<a;n++){let t=0;for(e=n;e<s;e++)t=A(t,i.get(e,n));if(0!==t){for(i.get(n,n)<0&&(t=-t),e=n;e<s;e++)i.set(e,n,i.get(e,n)/t);for(i.set(n,n,i.get(n,n)+1),r=n+1;r<a;r++){for(o=0,e=n;e<s;e++)o+=i.get(e,n)*i.get(e,r);for(o=-o/i.get(n,n),e=n;e<s;e++)i.set(e,r,i.get(e,r)+o*i.get(e,n))}}u[n]=-t}this.QR=i,this.Rdiag=u}solve(t){t=x.checkMatrix(t);let e=this.QR,r=e.rows;if(t.rows!==r)throw new Error("Matrix row dimensions must agree");if(!this.isFullRank())throw new Error("Matrix is rank deficient");let n,o,i,s,a=t.columns,u=t.clone(),c=e.columns;for(i=0;i<c;i++)for(o=0;o<a;o++){for(s=0,n=i;n<r;n++)s+=e.get(n,i)*u.get(n,o);for(s=-s/e.get(i,i),n=i;n<r;n++)u.set(n,o,u.get(n,o)+s*e.get(n,i))}for(i=c-1;i>=0;i--){for(o=0;o<a;o++)u.set(i,o,u.get(i,o)/this.Rdiag[i]);for(n=0;n<i;n++)for(o=0;o<a;o++)u.set(n,o,u.get(n,o)-u.get(i,o)*e.get(n,i))}return u.subMatrix(0,c-1,0,a-1)}isFullRank(){let t=this.QR.columns;for(let e=0;e<t;e++)if(0===this.Rdiag[e])return!1;return!0}get upperTriangularMatrix(){let t,e,r=this.QR,n=r.columns,o=new x(n,n);for(t=0;t<n;t++)for(e=0;e<n;e++)t<e?o.set(t,e,r.get(t,e)):t===e?o.set(t,e,this.Rdiag[t]):o.set(t,e,0);return o}get orthogonalMatrix(){let t,e,r,n,o=this.QR,i=o.rows,s=o.columns,a=new x(i,s);for(r=s-1;r>=0;r--){for(t=0;t<i;t++)a.set(t,r,0);for(a.set(r,r,1),e=r;e<s;e++)if(0!==o.get(r,r)){for(n=0,t=r;t<i;t++)n+=o.get(t,r)*a.get(t,e);for(n=-n/o.get(r,r),t=r;t<i;t++)a.set(t,e,a.get(t,e)+n*o.get(t,r))}}return a}}class z{constructor(t,e={}){if((t=k.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),c=Boolean(i),h=!1;if(r<n)if(s){a=t.transpose(),r=a.rows,n=a.columns,h=!0;let e=u;u=c,c=e}else a=t.clone(),console.warn("Computing SVD on a matrix with more columns than rows. Consider enabling autoTranspose");else a=t.clone();let l=Math.min(r,n),d=Math.min(r+1,n),f=new Float64Array(d),g=new x(r,l),p=new x(n,n),v=new Float64Array(n),m=new Float64Array(r),y=new Float64Array(d);for(let t=0;t<d;t++)y[t]=t;let w=Math.min(r-1,n),b=Math.max(0,Math.min(n-2,r)),E=Math.max(w,b);for(let t=0;t<E;t++){if(t<w){f[t]=0;for(let e=t;e<r;e++)f[t]=A(f[t],a.get(e,t));if(0!==f[t]){a.get(t,t)<0&&(f[t]=-f[t]);for(let e=t;e<r;e++)a.set(e,t,a.get(e,t)/f[t]);a.set(t,t,a.get(t,t)+1)}f[t]=-f[t]}for(let e=t+1;e<n;e++){if(t<w&&0!==f[t]){let n=0;for(let o=t;o<r;o++)n+=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))}v[e]=a.get(t,e)}if(u&&t<w)for(let e=t;e<r;e++)g.set(e,t,a.get(e,t));if(t<b){v[t]=0;for(let e=t+1;e<n;e++)v[t]=A(v[t],v[e]);if(0!==v[t]){v[t+1]<0&&(v[t]=0-v[t]);for(let e=t+1;e<n;e++)v[e]/=v[t];v[t+1]+=1}if(v[t]=-v[t],t+1<r&&0!==v[t]){for(let e=t+1;e<r;e++)m[e]=0;for(let e=t+1;e<r;e++)for(let r=t+1;r<n;r++)m[e]+=v[r]*a.get(e,r);for(let e=t+1;e<n;e++){let n=-v[e]/v[t+1];for(let o=t+1;o<r;o++)a.set(o,e,a.get(o,e)+n*m[o])}}if(c)for(let e=t+1;e<n;e++)p.set(e,t,v[e])}}let M=Math.min(n,r+1);if(w<n&&(f[w]=a.get(w,w)),r<M&&(f[M-1]=0),b+1<M&&(v[b]=a.get(b,M-1)),v[M-1]=0,u){for(let t=w;t<l;t++){for(let e=0;e<r;e++)g.set(e,t,0);g.set(t,t,1)}for(let t=w-1;t>=0;t--)if(0!==f[t]){for(let e=t+1;e<l;e++){let n=0;for(let o=t;o<r;o++)n+=g.get(o,t)*g.get(o,e);n=-n/g.get(t,t);for(let o=t;o<r;o++)g.set(o,e,g.get(o,e)+n*g.get(o,t))}for(let e=t;e<r;e++)g.set(e,t,-g.get(e,t));g.set(t,t,1+g.get(t,t));for(let e=0;e<t-1;e++)g.set(e,t,0)}else{for(let e=0;e<r;e++)g.set(e,t,0);g.set(t,t,1)}}if(c)for(let t=n-1;t>=0;t--){if(t<b&&0!==v[t])for(let e=t+1;e<n;e++){let r=0;for(let o=t+1;o<n;o++)r+=p.get(o,t)*p.get(o,e);r=-r/p.get(t+1,t);for(let o=t+1;o<n;o++)p.set(o,e,p.get(o,e)+r*p.get(o,t))}for(let e=0;e<n;e++)p.set(e,t,0);p.set(t,t,1)}let N=M-1,_=Number.EPSILON;for(;M>0;){let t,e;for(t=M-2;t>=-1&&-1!==t;t--){const e=Number.MIN_VALUE+_*Math.abs(f[t]+Math.abs(f[t+1]));if(Math.abs(v[t])<=e||Number.isNaN(v[t])){v[t]=0;break}}if(t===M-2)e=4;else{let r;for(r=M-1;r>=t&&r!==t;r--){let e=(r!==M?Math.abs(v[r]):0)+(r!==t+1?Math.abs(v[r-1]):0);if(Math.abs(f[r])<=_*e){f[r]=0;break}}r===t?e=3:r===M-1?e=1:(e=2,t=r)}switch(t++,e){case 1:{let e=v[M-2];v[M-2]=0;for(let r=M-2;r>=t;r--){let o=A(f[r],e),i=f[r]/o,s=e/o;if(f[r]=o,r!==t&&(e=-s*v[r-1],v[r-1]=i*v[r-1]),c)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=v[t-1];v[t-1]=0;for(let n=t;n<M;n++){let o=A(f[n],e),i=f[n]/o,s=e/o;if(f[n]=o,e=-s*v[n],v[n]=i*v[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(f[M-1]),Math.abs(f[M-2]),Math.abs(v[M-2]),Math.abs(f[t]),Math.abs(v[t])),o=f[M-1]/e,i=f[M-2]/e,s=v[M-2]/e,a=f[t]/e,h=v[t]/e,l=((i+o)*(i-o)+s*s)/2,d=o*s*(o*s);let m=0;0===l&&0===d||(m=l<0?0-Math.sqrt(l*l+d):Math.sqrt(l*l+d),m=d/(l+m));let y=(a+o)*(a-o)+m,w=a*h;for(let e=t;e<M-1;e++){let o=A(y,w);0===o&&(o=Number.MIN_VALUE);let i=y/o,s=w/o;if(e!==t&&(v[e-1]=o),y=i*f[e]+s*v[e],v[e]=i*v[e]-s*f[e],w=s*f[e+1],f[e+1]=i*f[e+1],c)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=A(y,w),0===o&&(o=Number.MIN_VALUE),i=y/o,s=w/o,f[e]=o,y=i*v[e]+s*f[e+1],f[e+1]=-s*v[e]+i*f[e+1],w=s*v[e+1],v[e+1]=i*v[e+1],u&&e<r-1)for(let t=0;t<r;t++)o=i*g.get(t,e)+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)}v[M-2]=y;break}case 4:if(f[t]<=0&&(f[t]=f[t]<0?-f[t]:0,c))for(let e=0;e<=N;e++)p.set(e,t,-p.get(e,t));for(;t<N&&!(f[t]>=f[t+1]);){let e=f[t];if(f[t]=f[t+1],f[t+1]=e,c&&t<n-1)for(let r=0;r<n;r++)e=p.get(r,t+1),p.set(r,t+1,p.get(r,t)),p.set(r,t,e);if(u&&t<r-1)for(let n=0;n<r;n++)e=g.get(n,t+1),g.set(n,t+1,g.get(n,t)),g.set(n,t,e);t++}M--}}if(h){let t=p;p=g,g=t}this.m=r,this.n=n,this.s=f,this.U=g,this.V=p}solve(t){let e=t,r=this.threshold,n=this.s.length,o=x.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,c=i.rows,h=x.zeros(u,c);for(let t=0;t<u;t++)for(let e=0;e<c;e++){let r=0;for(let o=0;o<n;o++)r+=a.get(t,o)*i.get(e,o);h.set(t,e,r)}return h.mmul(e)}solveForDiagonal(t){return this.solve(x.diag(t))}inverse(){let t=this.V,e=this.threshold,r=t.rows,n=t.columns,o=new x(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 x(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 x.diag(this.s)}}function j(t,e,r=!1){return t=k.checkMatrix(t),e=k.checkMatrix(e),r?new z(t).solve(e):t.isSquare()?new S(t).solve(e):new O(t).solve(e)}function C(t,e){let r=[];for(let n=0;n<t;n++)n!==e&&r.push(n);return r}function I(t,e,r,n=1e-9,o=1e-9){if(t>o)return new Array(e.rows+1).fill(0);{let t=e.addRow(r,[0]);for(let e=0;e<t.rows;e++)Math.abs(t.get(e,0))<n&&t.set(e,0,0);return t.to1DArray()}}class R{constructor(t,e={}){const{assumeSymmetric:r=!1}=e;if(!(t=k.checkMatrix(t)).isSquare())throw new Error("Matrix is not a square matrix");if(t.isEmpty())throw new Error("Matrix must be non-empty");let n,o,i=t.columns,s=new x(i,i),a=new Float64Array(i),u=new Float64Array(i),c=t,h=!1;if(h=!!r||t.isSymmetric(),h){for(n=0;n<i;n++)for(o=0;o<i;o++)s.set(n,o,c.get(n,o));!function(t,e,r,n){let o,i,s,a,u,c,h,l;for(u=0;u<t;u++)r[u]=n.get(t-1,u);for(a=t-1;a>0;a--){for(l=0,s=0,c=0;c<a;c++)l+=Math.abs(r[c]);if(0===l)for(e[a]=r[a-1],u=0;u<a;u++)r[u]=n.get(a-1,u),n.set(a,u,0),n.set(u,a,0);else{for(c=0;c<a;c++)r[c]/=l,s+=r[c]*r[c];for(o=r[a-1],i=Math.sqrt(s),o>0&&(i=-i),e[a]=l*i,s-=o*i,r[a-1]=o-i,u=0;u<a;u++)e[u]=0;for(u=0;u<a;u++){for(o=r[u],n.set(u,a,o),i=e[u]+n.get(u,u)*o,c=u+1;c<=a-1;c++)i+=n.get(c,u)*r[c],e[c]+=n.get(c,u)*o;e[u]=i}for(o=0,u=0;u<a;u++)e[u]/=s,o+=e[u]*r[u];for(h=o/(s+s),u=0;u<a;u++)e[u]-=h*r[u];for(u=0;u<a;u++){for(o=r[u],i=e[u],c=u;c<=a-1;c++)n.set(c,u,n.get(c,u)-(o*e[c]+i*r[c]));r[u]=n.get(a-1,u),n.set(a,u,0)}}r[a]=s}for(a=0;a<t-1;a++){if(n.set(t-1,a,n.get(a,a)),n.set(a,a,1),s=r[a+1],0!==s){for(c=0;c<=a;c++)r[c]=n.get(c,a+1)/s;for(u=0;u<=a;u++){for(i=0,c=0;c<=a;c++)i+=n.get(c,a+1)*n.get(c,u);for(c=0;c<=a;c++)n.set(c,u,n.get(c,u)-i*r[c])}}for(c=0;c<=a;c++)n.set(c,a+1,0)}for(u=0;u<t;u++)r[u]=n.get(t-1,u),n.set(t-1,u,0);n.set(t-1,t-1,1),e[0]=0}(i,u,a,s),function(t,e,r,n){let o,i,s,a,u,c,h,l,d,f,g,p,v,m,y,w;for(s=1;s<t;s++)e[s-1]=e[s];e[t-1]=0;let x=0,b=0,E=Number.EPSILON;for(c=0;c<t;c++){for(b=Math.max(b,Math.abs(r[c])+Math.abs(e[c])),h=c;h<t&&!(Math.abs(e[h])<=E*b);)h++;if(h>c)do{for(o=r[c],l=(r[c+1]-o)/(2*e[c]),d=A(l,1),l<0&&(d=-d),r[c]=e[c]/(l+d),r[c+1]=e[c]*(l+d),f=r[c+1],i=o-r[c],s=c+2;s<t;s++)r[s]-=i;for(x+=i,l=r[h],g=1,p=g,v=g,m=e[c+1],y=0,w=0,s=h-1;s>=c;s--)for(v=p,p=g,w=y,o=g*e[s],i=g*l,d=A(l,e[s]),e[s+1]=y*d,y=e[s]/d,g=l/d,l=g*r[s]-y*o,r[s+1]=i+y*(g*o+y*r[s]),u=0;u<t;u++)i=n.get(u,s+1),n.set(u,s+1,y*n.get(u,s)+g*i),n.set(u,s,g*n.get(u,s)-y*i);l=-y*w*v*m*e[c]/f,e[c]=y*l,r[c]=g*l}while(Math.abs(e[c])>E*b);r[c]=r[c]+x,e[c]=0}for(s=0;s<t-1;s++){for(u=s,l=r[s],a=s+1;a<t;a++)r[a]<l&&(u=a,l=r[a]);if(u!==s)for(r[u]=r[s],r[s]=l,a=0;a<t;a++)l=n.get(a,s),n.set(a,s,n.get(a,u)),n.set(a,u,l)}}(i,u,a,s)}else{let t=new x(i,i),e=new Float64Array(i);for(o=0;o<i;o++)for(n=0;n<i;n++)t.set(n,o,c.get(n,o));!function(t,e,r,n){let o,i,s,a,u,c,h,l=0,d=t-1;for(c=l+1;c<=d-1;c++){for(h=0,a=c;a<=d;a++)h+=Math.abs(e.get(a,c-1));if(0!==h){for(s=0,a=d;a>=c;a--)r[a]=e.get(a,c-1)/h,s+=r[a]*r[a];for(i=Math.sqrt(s),r[c]>0&&(i=-i),s-=r[c]*i,r[c]=r[c]-i,u=c;u<t;u++){for(o=0,a=d;a>=c;a--)o+=r[a]*e.get(a,u);for(o/=s,a=c;a<=d;a++)e.set(a,u,e.get(a,u)-o*r[a])}for(a=0;a<=d;a++){for(o=0,u=d;u>=c;u--)o+=r[u]*e.get(a,u);for(o/=s,u=c;u<=d;u++)e.set(a,u,e.get(a,u)-o*r[u])}r[c]=h*r[c],e.set(c,c-1,h*i)}}for(a=0;a<t;a++)for(u=0;u<t;u++)n.set(a,u,a===u?1:0);for(c=d-1;c>=l+1;c--)if(0!==e.get(c,c-1)){for(a=c+1;a<=d;a++)r[a]=e.get(a,c-1);for(u=c;u<=d;u++){for(i=0,a=c;a<=d;a++)i+=r[a]*n.get(a,u);for(i=i/r[c]/e.get(c,c-1),a=c;a<=d;a++)n.set(a,u,n.get(a,u)+i*r[a])}}}(i,t,e,s),function(t,e,r,n,o){let i,s,a,u,c,h,l,d,f,g,p,v,m,y,w,x=t-1,b=0,E=t-1,M=Number.EPSILON,N=0,_=0,k=0,S=0,A=0,O=0,z=0,j=0;for(i=0;i<t;i++)for((i<b||i>E)&&(r[i]=o.get(i,i),e[i]=0),s=Math.max(i-1,0);s<t;s++)_+=Math.abs(o.get(i,s));for(;x>=b;){for(u=x;u>b&&(O=Math.abs(o.get(u-1,u-1))+Math.abs(o.get(u,u)),0===O&&(O=_),!(Math.abs(o.get(u,u-1))<M*O));)u--;if(u===x)o.set(x,x,o.get(x,x)+N),r[x]=o.get(x,x),e[x]=0,x--,j=0;else if(u===x-1){if(l=o.get(x,x-1)*o.get(x-1,x),k=(o.get(x-1,x-1)-o.get(x,x))/2,S=k*k+l,z=Math.sqrt(Math.abs(S)),o.set(x,x,o.get(x,x)+N),o.set(x-1,x-1,o.get(x-1,x-1)+N),d=o.get(x,x),S>=0){for(z=k>=0?k+z:k-z,r[x-1]=d+z,r[x]=r[x-1],0!==z&&(r[x]=d-l/z),e[x-1]=0,e[x]=0,d=o.get(x,x-1),O=Math.abs(d)+Math.abs(z),k=d/O,S=z/O,A=Math.sqrt(k*k+S*S),k/=A,S/=A,s=x-1;s<t;s++)z=o.get(x-1,s),o.set(x-1,s,S*z+k*o.get(x,s)),o.set(x,s,S*o.get(x,s)-k*z);for(i=0;i<=x;i++)z=o.get(i,x-1),o.set(i,x-1,S*z+k*o.get(i,x)),o.set(i,x,S*o.get(i,x)-k*z);for(i=b;i<=E;i++)z=n.get(i,x-1),n.set(i,x-1,S*z+k*n.get(i,x)),n.set(i,x,S*n.get(i,x)-k*z)}else r[x-1]=d+k,r[x]=d+k,e[x-1]=z,e[x]=-z;x-=2,j=0}else{if(d=o.get(x,x),f=0,l=0,u<x&&(f=o.get(x-1,x-1),l=o.get(x,x-1)*o.get(x-1,x)),10===j){for(N+=d,i=b;i<=x;i++)o.set(i,i,o.get(i,i)-d);O=Math.abs(o.get(x,x-1))+Math.abs(o.get(x-1,x-2)),d=f=.75*O,l=-.4375*O*O}if(30===j&&(O=(f-d)/2,O=O*O+l,O>0)){for(O=Math.sqrt(O),f<d&&(O=-O),O=d-l/((f-d)/2+O),i=b;i<=x;i++)o.set(i,i,o.get(i,i)-O);N+=O,d=f=l=.964}for(j+=1,c=x-2;c>=u&&(z=o.get(c,c),A=d-z,O=f-z,k=(A*O-l)/o.get(c+1,c)+o.get(c,c+1),S=o.get(c+1,c+1)-z-A-O,A=o.get(c+2,c+1),O=Math.abs(k)+Math.abs(S)+Math.abs(A),k/=O,S/=O,A/=O,c!==u)&&!(Math.abs(o.get(c,c-1))*(Math.abs(S)+Math.abs(A))<M*(Math.abs(k)*(Math.abs(o.get(c-1,c-1))+Math.abs(z)+Math.abs(o.get(c+1,c+1)))));)c--;for(i=c+2;i<=x;i++)o.set(i,i-2,0),i>c+2&&o.set(i,i-3,0);for(a=c;a<=x-1&&(y=a!==x-1,a!==c&&(k=o.get(a,a-1),S=o.get(a+1,a-1),A=y?o.get(a+2,a-1):0,d=Math.abs(k)+Math.abs(S)+Math.abs(A),0!==d&&(k/=d,S/=d,A/=d)),0!==d);a++)if(O=Math.sqrt(k*k+S*S+A*A),k<0&&(O=-O),0!==O){for(a!==c?o.set(a,a-1,-O*d):u!==c&&o.set(a,a-1,-o.get(a,a-1)),k+=O,d=k/O,f=S/O,z=A/O,S/=k,A/=k,s=a;s<t;s++)k=o.get(a,s)+S*o.get(a+1,s),y&&(k+=A*o.get(a+2,s),o.set(a+2,s,o.get(a+2,s)-k*z)),o.set(a,s,o.get(a,s)-k*d),o.set(a+1,s,o.get(a+1,s)-k*f);for(i=0;i<=Math.min(x,a+3);i++)k=d*o.get(i,a)+f*o.get(i,a+1),y&&(k+=z*o.get(i,a+2),o.set(i,a+2,o.get(i,a+2)-k*A)),o.set(i,a,o.get(i,a)-k),o.set(i,a+1,o.get(i,a+1)-k*S);for(i=b;i<=E;i++)k=d*n.get(i,a)+f*n.get(i,a+1),y&&(k+=z*n.get(i,a+2),n.set(i,a+2,n.get(i,a+2)-k*A)),n.set(i,a,n.get(i,a)-k),n.set(i,a+1,n.get(i,a+1)-k*S)}}}if(0===_)return;for(x=t-1;x>=0;x--)if(k=r[x],S=e[x],0===S)for(u=x,o.set(x,x,1),i=x-1;i>=0;i--){for(l=o.get(i,i)-k,A=0,s=u;s<=x;s++)A+=o.get(i,s)*o.get(s,x);if(e[i]<0)z=l,O=A;else if(u=i,0===e[i]?o.set(i,x,0!==l?-A/l:-A/(M*_)):(d=o.get(i,i+1),f=o.get(i+1,i),S=(r[i]-k)*(r[i]-k)+e[i]*e[i],h=(d*O-z*A)/S,o.set(i,x,h),o.set(i+1,x,Math.abs(d)>Math.abs(z)?(-A-l*h)/d:(-O-f*h)/z)),h=Math.abs(o.get(i,x)),M*h*h>1)for(s=i;s<=x;s++)o.set(s,x,o.get(s,x)/h)}else if(S<0)for(u=x-1,Math.abs(o.get(x,x-1))>Math.abs(o.get(x-1,x))?(o.set(x-1,x-1,S/o.get(x,x-1)),o.set(x-1,x,-(o.get(x,x)-k)/o.get(x,x-1))):(w=T(0,-o.get(x-1,x),o.get(x-1,x-1)-k,S),o.set(x-1,x-1,w[0]),o.set(x-1,x,w[1])),o.set(x,x-1,0),o.set(x,x,1),i=x-2;i>=0;i--){for(g=0,p=0,s=u;s<=x;s++)g+=o.get(i,s)*o.get(s,x-1),p+=o.get(i,s)*o.get(s,x);if(l=o.get(i,i)-k,e[i]<0)z=l,A=g,O=p;else if(u=i,0===e[i]?(w=T(-g,-p,l,S),o.set(i,x-1,w[0]),o.set(i,x,w[1])):(d=o.get(i,i+1),f=o.get(i+1,i),v=(r[i]-k)*(r[i]-k)+e[i]*e[i]-S*S,m=2*(r[i]-k)*S,0===v&&0===m&&(v=M*_*(Math.abs(l)+Math.abs(S)+Math.abs(d)+Math.abs(f)+Math.abs(z))),w=T(d*A-z*g+S*p,d*O-z*p-S*g,v,m),o.set(i,x-1,w[0]),o.set(i,x,w[1]),Math.abs(d)>Math.abs(z)+Math.abs(S)?(o.set(i+1,x-1,(-g-l*o.get(i,x-1)+S*o.get(i,x))/d),o.set(i+1,x,(-p-l*o.get(i,x)-S*o.get(i,x-1))/d)):(w=T(-A-f*o.get(i,x-1),-O-f*o.get(i,x),z,S),o.set(i+1,x-1,w[0]),o.set(i+1,x,w[1]))),h=Math.max(Math.abs(o.get(i,x-1)),Math.abs(o.get(i,x))),M*h*h>1)for(s=i;s<=x;s++)o.set(s,x-1,o.get(s,x-1)/h),o.set(s,x,o.get(s,x)/h)}for(i=0;i<t;i++)if(i<b||i>E)for(s=i;s<t;s++)n.set(i,s,o.get(i,s));for(s=t-1;s>=b;s--)for(i=b;i<=E;i++){for(z=0,a=b;a<=Math.min(s,E);a++)z+=n.get(i,a)*o.get(a,s);n.set(i,s,z)}}(i,u,a,s,t)}this.n=i,this.e=u,this.d=a,this.V=s}get realEigenvalues(){return Array.from(this.d)}get imaginaryEigenvalues(){return Array.from(this.e)}get eigenvectorMatrix(){return this.V}get diagonalMatrix(){let t,e,r=this.n,n=this.e,o=this.d,i=new x(r,r);for(t=0;t<r;t++){for(e=0;e<r;e++)i.set(t,e,0);i.set(t,t,o[t]),n[t]>0?i.set(t,t+1,n[t]):n[t]<0&&i.set(t,t-1,n[t])}return i}}function T(t,e,r,n){let o,i;return Math.abs(r)>Math.abs(n)?(o=n/r,i=r+o*n,[(t+o*e)/i,(e-o*t)/i]):(o=r/n,i=n+o*r,[(o*t+e)/i,(o*e-t)/i])}class P{constructor(t){if(!(t=k.checkMatrix(t)).isSymmetric())throw new Error("Matrix is not symmetric");let e,r,n,o=t,i=o.rows,s=new x(i,i),a=!0;for(r=0;r<i;r++){let t=0;for(n=0;n<r;n++){let i=0;for(e=0;e<n;e++)i+=s.get(n,e)*s.get(r,e);i=(o.get(r,n)-i)/s.get(n,n),s.set(r,n,i),t+=i*i}for(t=o.get(r,r)-t,a&&=t>0,s.set(r,r,Math.sqrt(Math.max(t,0))),n=r+1;n<i;n++)s.set(r,n,0)}this.L=s,this.positiveDefinite=a}isPositiveDefinite(){return this.positiveDefinite}solve(t){t=k.checkMatrix(t);let e=this.L,r=e.rows;if(t.rows!==r)throw new Error("Matrix dimensions do not match");if(!1===this.isPositiveDefinite())throw new Error("Matrix is not positive definite");let n,o,i,s=t.columns,a=t.clone();for(i=0;i<r;i++)for(o=0;o<s;o++){for(n=0;n<i;n++)a.set(i,o,a.get(i,o)-a.get(n,o)*e.get(i,n));a.set(i,o,a.get(i,o)/e.get(i,i))}for(i=r-1;i>=0;i--)for(o=0;o<s;o++){for(n=i+1;n<r;n++)a.set(i,o,a.get(i,o)-a.get(n,o)*e.get(n,i));a.set(i,o,a.get(i,o)/e.get(i,i))}return a}get lowerTriangularMatrix(){return this.L}}class F{constructor(e,r={}){e=k.checkMatrix(e);let{Y:n}=r;const{scaleScores:o=!1,maxIterations:i=1e3,terminationCriteria:s=1e-10}=r;let a;if(n){if(n=t.isAnyArray(n)&&"number"==typeof n[0]?x.columnVector(n):k.checkMatrix(n),n.rows!==e.rows)throw new Error("Y should have the same number of rows as X");a=n.getColumnVector(0)}else a=e.getColumnVector(0);let u,c,h,l,d=1;for(let t=0;t<i&&d>s;t++)h=e.transpose().mmul(a).div(a.transpose().mmul(a).get(0,0)),h=h.div(h.norm()),u=e.mmul(h).div(h.transpose().mmul(h).get(0,0)),t>0&&(d=u.clone().sub(l).pow(2).sum()),l=u.clone(),n?(c=n.transpose().mmul(u).div(u.transpose().mmul(u).get(0,0)),c=c.div(c.norm()),a=n.mmul(c).div(c.transpose().mmul(c).get(0,0))):a=u;if(n){let t=e.transpose().mmul(u).div(u.transpose().mmul(u).get(0,0));t=t.div(t.norm());let r=e.clone().sub(u.clone().mmul(t.transpose())),o=a.transpose().mmul(u).div(u.transpose().mmul(u).get(0,0)),i=n.clone().sub(u.clone().mulS(o.get(0,0)).mmul(c.transpose()));this.t=u,this.p=t.transpose(),this.w=h.transpose(),this.q=c,this.u=a,this.s=u.transpose().mmul(u),this.xResidual=r,this.yResidual=i,this.betas=o}else this.w=h.transpose(),this.s=u.transpose().mmul(u).sqrt(),this.t=o?u.clone().div(this.s.get(0,0)):u,this.xResidual=e.sub(u.mmul(h.transpose()))}}return Hy.AbstractMatrix=m,Hy.CHO=P,Hy.CholeskyDecomposition=P,Hy.DistanceMatrix=E,Hy.EVD=R,Hy.EigenvalueDecomposition=R,Hy.LU=S,Hy.LuDecomposition=S,Hy.Matrix=x,Hy.MatrixColumnSelectionView=class extends M{constructor(t,e){d(t,e),super(t,t.rows,e.length),this.columnIndices=e}set(t,e,r){return this.matrix.set(t,this.columnIndices[e],r),this}get(t,e){return this.matrix.get(t,this.columnIndices[e])}},Hy.MatrixColumnView=class extends M{constructor(t,e){u(t,e),super(t,t.rows,1),this.column=e}set(t,e,r){return this.matrix.set(t,this.column,r),this}get(t){return this.matrix.get(t,this.column)}},Hy.MatrixFlipColumnView=class extends M{constructor(t){super(t,t.rows,t.columns)}set(t,e,r){return this.matrix.set(t,this.columns-e-1,r),this}get(t,e){return this.matrix.get(t,this.columns-e-1)}},Hy.MatrixFlipRowView=class extends M{constructor(t){super(t,t.rows,t.columns)}set(t,e,r){return this.matrix.set(this.rows-t-1,e,r),this}get(t,e){return this.matrix.get(this.rows-t-1,e)}},Hy.MatrixRowSelectionView=class extends M{constructor(t,e){l(t,e),super(t,e.length,t.columns),this.rowIndices=e}set(t,e,r){return this.matrix.set(this.rowIndices[t],e,r),this}get(t,e){return this.matrix.get(this.rowIndices[t],e)}},Hy.MatrixRowView=class extends M{constructor(t,e){a(t,e),super(t,1,t.columns),this.row=e}set(t,e,r){return this.matrix.set(this.row,e,r),this}get(t,e){return this.matrix.get(this.row,e)}},Hy.MatrixSelectionView=N,Hy.MatrixSubView=class extends M{constructor(t,e,r,n,o){f(t,e,r,n,o),super(t,r-e+1,o-n+1),this.startRow=e,this.startColumn=n}set(t,e,r){return this.matrix.set(this.startRow+t,this.startColumn+e,r),this}get(t,e){return this.matrix.get(this.startRow+t,this.startColumn+e)}},Hy.MatrixTransposeView=class extends M{constructor(t){super(t,t.columns,t.rows)}set(t,e,r){return this.matrix.set(e,t,r),this}get(t,e){return this.matrix.get(e,t)}},Hy.NIPALS=F,Hy.Nipals=F,Hy.QR=O,Hy.QrDecomposition=O,Hy.SVD=z,Hy.SingularValueDecomposition=z,Hy.SymmetricMatrix=b,Hy.WrapperMatrix1D=_,Hy.WrapperMatrix2D=k,Hy.correlation=function(e,r=e,n={}){e=new x(e);let o=!1;if("object"!=typeof r||x.isMatrix(r)||t.isAnyArray(r)?r=new x(r):(n=r,r=e,o=!0),e.rows!==r.rows)throw new TypeError("Both matrices must have the same number of rows");const{center:i=!0,scale:s=!0}=n;i&&(e.center("column"),o||r.center("column")),s&&(e.scale("column"),o||r.scale("column"));const a=e.standardDeviation("column",{unbiased:!0}),u=o?a:r.standardDeviation("column",{unbiased:!0}),c=e.transpose().mmul(r);for(let t=0;t<c.rows;t++)for(let r=0;r<c.columns;r++)c.set(t,r,c.get(t,r)*(1/(a[t]*u[r]))*(1/(e.rows-1)));return c},Hy.covariance=function(e,r=e,n={}){e=new x(e);let o=!1;if("object"!=typeof r||x.isMatrix(r)||t.isAnyArray(r)?r=new x(r):(n=r,r=e,o=!0),e.rows!==r.rows)throw new TypeError("Both matrices must have the same number of rows");const{center:i=!0}=n;i&&(e=e.center("column"),o||(r=r.center("column")));const s=e.transpose().mmul(r);for(let t=0;t<s.rows;t++)for(let r=0;r<s.columns;r++)s.set(t,r,s.get(t,r)*(1/(e.rows-1)));return s},Hy.default=x,Hy.determinant=function t(e){if((e=x.checkMatrix(e)).isSquare()){if(0===e.columns)return 1;let r,n,o,i;if(2===e.columns)return r=e.get(0,0),n=e.get(0,1),o=e.get(1,0),i=e.get(1,1),r*i-n*o;if(3===e.columns){let i,s,a;return i=new N(e,[1,2],[1,2]),s=new N(e,[1,2],[0,2]),a=new N(e,[1,2],[0,1]),r=e.get(0,0),n=e.get(0,1),o=e.get(0,2),r*t(i)-n*t(s)+o*t(a)}return new S(e).determinant}throw Error("determinant can only be calculated for a square matrix")},Hy.inverse=function(t,e=!1){return t=k.checkMatrix(t),e?new z(t).inverse():j(t,x.eye(t.rows))},Hy.linearDependencies=function(t,e={}){const{thresholdValue:r=1e-9,thresholdError:n=1e-9}=e;let o=(t=x.checkMatrix(t)).rows,i=new x(o,o);for(let e=0;e<o;e++){let s=x.columnVector(t.getRow(e)),a=t.subMatrixRow(C(o,e)).transpose(),u=new z(a).solve(s),c=x.sub(s,a.mmul(u)).abs().max();i.setRow(e,I(c,u,e,r,n))}return i},Hy.pseudoInverse=function(t,e=Number.EPSILON){if((t=x.checkMatrix(t)).isEmpty())return t.transpose();let r=new z(t,{autoTranspose:!0}),n=r.leftSingularVectors,o=r.rightSingularVectors,i=r.diagonal;for(let t=0;t<i.length;t++)Math.abs(i[t])>e?i[t]=1/i[t]:i[t]=0;return o.mmul(x.diag(i).mmul(n.transpose()))},Hy.solve=j,Hy.wrap=function(e,r){if(t.isAnyArray(e))return e[0]&&t.isAnyArray(e[0])?new k(e):new _(e,r);throw new Error("the argument is not an array")},Hy}var rw=ew(),nw=ds(rw);const ow=rw.Matrix,iw=rw.SingularValueDecomposition;nw.Matrix?nw.Matrix:rw.Matrix;const sw={center:[0,0],linkDistance:50};const aw=t=>{let e=Number.NEGATIVE_INFINITY;const r=[],n=t.length;for(let o=0;o<n;o++){const n=t[o],i=n.length;for(let t=0;t<i;t++){const i=n[t];i===1/0?r.push([o,t]):e<i&&(e=i)}}for(let n=0;n<r.length;n++){const[o,i]=r[n];t[o][i]=e}},uw=(t,e=2,r=sw.linkDistance)=>{try{const r=t.length,n=new ow(r,r);for(let e=0;e<r;e++)for(let o=0;o<r;o++){const r=t[e][o];n.set(e,o,-.5*r*r)}const o=n.mean("row"),i=n.mean("column"),s=n.mean();n.add(s).subRowVector(o).subColumnVector(i);const a=new iw(n),u=ow.sqrt(a.diagonalMatrix).diagonal(),c=a.leftSingularVectors,h=u,l=[];for(let t=0;t<c.rows;t++){const r=[];for(let n=0;n<e;n++)r.push(c.get(t,n)*h[n]);l.push(r)}return l}catch(e){const n=[];for(let e=0;e<t.length;e++){const t=Math.random()*r,e=Math.random()*r;n.push([t,e])}return n}},cw={maxIteration:10,width:10,speed:100,gravity:10,k:5},hw=(t,e,r,n,o)=>{let i=0;t.forEachNode(s=>{let a=0;t.forEachNode(t=>{if(a<=i)return void a++;if(s.id===t.id)return;if(n.get(s.id)!==n.get(t.id))return;let u=s.x-t.x,c=s.y-t.y,h=Math.sqrt(u*u+c*c);if(0===h){h=1;const t=i>a?1:-1;u=.01*t,c=.01*t}const l=Math.max(...o(s._original));if(h<Math.max(...o(t._original))/2+l/2){const n=r*r/h,o=e.get(s.id),i=e.get(t.id),a=u/h*n,l=c/h*n;e.set(s.id,{x:o.x+a,y:o.y+l}),e.set(t.id,{x:i.x-a,y:i.y-l})}a++}),i++})},lw=(t,e,r,n,o,i,s)=>{n&&t.forEachNode(t=>{const r=t.x-o.x,n=t.y-o.y,i=Math.sqrt(r*r+n*n);let s=n/i,a=-r/i;const u=e.get(t.id),c=Math.sqrt(u.x*u.x+u.y*u.y);let h=Math.acos((s*u.x+a*u.y)/c);h>Math.PI/2&&(h-=Math.PI/2,s*=-1,a*=-1);const l=Math.cos(h)*c;e.set(t.id,{x:s*l,y:a*l})});let a=0,u=0;return t.forEachNode(t=>{if(t.id===o.id)return;const c=e.get(t.id),h=Math.sqrt(c.x*c.x+c.y*c.y);if(h>0){const e=Math.min(i*(r/800),h);if(t.x+=c.x/h*e,t.y+=c.y/h*e,n){let e=t.x-o.x,r=t.y-o.y;const n=Math.sqrt(e*e+r*r);e=e/n*s.get(t.id),r=r/n*s.get(t.id),t.x=o.x+e,t.y=o.y+r}a+=e,u++}}),u>0?a/u:0},dw={focusNode:null,linkDistance:50,maxIteration:1e3,maxPreventOverlapIteration:200,preventOverlap:!1,sortStrength:10,strictRadial:!0,unitRadius:null,nodeSize:10,nodeSpacing:0};const fw=(t,e,r,n,o,i,s)=>{const a=e.length,u=new Array(a),c=new Array(a);for(let t=0;t<a;t++)c[t]=n[t]/o;const h=(r+o)/2,l=new Map,d=i&&"data"!==i?ut(i,["node"]):null,f="data"===i;for(let o=0;o<a;o++){const i=e[o],g=new Array(a);u[o]=g;const p=c[o]||1;for(let e=0;e<a;e++){if(o===e){g[e]=0;continue}const a=i[e];if(n[o]===n[e])if(f)g[e]=a*Math.abs(o-e)*s/p;else if(d){const r=t.nodeAt(o),n=t.nodeAt(e);let i=l.get(r.id);if(void 0===i){const t=d(r._original)||0;i="string"==typeof t?t.charCodeAt(0):Number(t||0),l.set(r.id,i)}let u=l.get(n.id);if(void 0===u){const t=d(n._original)||0;u="string"==typeof t?t.charCodeAt(0):Number(t||0),l.set(n.id,u)}g[e]=a*Math.abs(i-u)*s/p}else g[e]=a*r/p;else g[e]=a*h}}return u},gw=t=>{const e=t.length,r=t[0].length,n=[];for(let o=0;o<e;o++){const e=[];for(let n=0;n<r;n++)0!==t[o][n]?e.push(1/(t[o][n]*t[o][n])):e.push(0);n.push(e)}return n},pw=(t,e,r)=>{const n=t.length;for(let o=0;o<n;o++)if(t[e][o]===1/0){t[e][o]=r,t[o][e]=r;for(let 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(let r=0;r<n;r++)if(r!==e)for(let o=0;o<n;o++)if(t[r][o]===1/0){let n=Math.abs(t[e][r]-t[e][o]);n=0===n?1:n,t[r][o]=n}},vw=(t,e)=>{const r=t[e];let n=0;for(let t=0;t<r.length;t++)r[t]!==1/0&&(n=Math.max(n,r[t]));return n};const mw=t=>.9*(Math.random()-.5)*t,yw={"antv-dagre":class extends Ot{constructor(){super(...arguments),this.id="antv-dagre"}getDefaultOptions(){return Mr}layout(e){return t(this,void 0,void 0,function*(){const{nodeSize:t,nodeSpacing:r,align:n,rankdir:o="TB",ranksep:i,nodesep:s,edgeLabelSpace:a,ranker:u="tight-tree",nodeOrder:c,begin:h,controlPoints:l,radial:d,sortByCombo:f,preset:g,ranksepFunc:p,nodesepFunc:v}=e,m=ct(p,null!=i?i:50,"node"),y=ct(v,null!=s?s:50,"node");let w=y,x=m;"LR"!==o&&"RL"!==o||(w=m,x=y);const b=new jt({tree:[]}),E=this.model.nodes(),M=this.model.edges(),N=lt(t,r,Mr.nodeSize,Mr.nodeSpacing);E.forEach(t=>{var e;const r=t._original,n=N(r),o=x(r),i=w(r),s=n[0]+2*i,a=n[1]+2*o,u=null===(e=t.data)||void 0===e?void 0:e.layer;A(u)?b.addNode({id:t.id,data:{width:s,height:a,layer:u,originalWidth:n[0],originalHeight:n[1]}}):b.addNode({id:t.id,data:{width:s,height:a,originalWidth:n[0],originalHeight:n[1]}})}),M.forEach(t=>{b.addEdge({id:t.id,source:t.source,target:t.target,data:{}})}),f&&(b.attachTreeStructure("combo"),E.forEach(t=>{const e=null==t?void 0:t.parentId;void 0!==e&&b.hasNode(e)&&b.setParent(t.id,e,"combo")}));let _=null;(null==g?void 0:g.length)&&(_=new jt,g.forEach(t=>{_.addNode({id:t.id,data:t.data})})),((t,e)=>{const{edgeLabelSpace:r,keepNodeOrder:n,prevGraph:o,rankdir:i,ranksep:s}=e;!n&&o&&er(t,o);const a=ur(t);let u;r&&(e.ranksep=cr(a,{rankdir:i,ranksep:s}));try{u=tr(a,e)}catch(t){if("Not possible to find intersection inside of the rectangle"===t.message)return void console.error("The following error may be caused by improper layer setting, please make sure your manual layer setting does not violate the graph's structure:\n",t);throw t}rr(t,a)})(b,{prevGraph:_,edgeLabelSpace:a,keepNodeOrder:!!c,nodeOrder:c||[],acyclicer:"greedy",ranker:u,rankdir:o,nodesep:s,align:n});const k=[0,0];if(h){let t=1/0,e=1/0;b.getAllNodes().forEach(r=>{t>r.data.x&&(t=r.data.x),e>r.data.y&&(e=r.data.y)}),b.getAllEdges().forEach(r=>{var n;null===(n=r.data.points)||void 0===n||n.forEach(r=>{t>r.x&&(t=r.x),e>r.y&&(e=r.y)})}),k[0]=h[0]-t,k[1]=h[1]-e}const S="LR"===o||"RL"===o;if(d);else{const t=new Set,e="BT"===o||"RL"===o?(t,e)=>e-t:(t,e)=>t-e;b.getAllNodes().forEach(e=>{e.data.x=e.data.x+k[0],e.data.y=e.data.y+k[1],t.add(S?e.data.x:e.data.y)});const r=Array.from(t).sort(e),n=S?(t,e)=>t.x!==e.x:(t,e)=>t.y!==e.y,i=S?(t,e,r)=>{const n=Math.max(e.y,r.y),o=Math.min(e.y,r.y);return t.filter(t=>t.y<=n&&t.y>=o)}:(t,e,r)=>{const n=Math.max(e.x,r.x),o=Math.min(e.x,r.x);return t.filter(t=>t.x<=n&&t.x>=o)};b.getAllEdges().forEach((t,e)=>{var o;a&&l&&"loop"!==t.data.type&&(t.data.controlPoints=Nr(null===(o=t.data.points)||void 0===o?void 0:o.map(({x:t,y:e})=>({x:t+k[0],y:e+k[1]})),b.getNode(t.source),b.getNode(t.target),r,S,n,i))})}this.model.forEachNode(t=>{const e=b.getNode(t.id);if(e){const{x:r,y:n,width:o,height:i,originalWidth:s,originalHeight:a}=e.data,u=f?b.getChildren(t.id,"combo"):b.getChildren(t.id);if(u.length>0){let e=1/0,r=-1/0,n=1/0,o=-1/0;u.forEach(t=>{const i=t.id,s=b.getNode(i);if(null==s?void 0:s.data){const t=s.data.x,i=s.data.y,a=s.data.originalWidth||s.data.width||0,u=s.data.originalHeight||s.data.height||0;e=Math.min(e,t-a/2),r=Math.max(r,t+a/2),n=Math.min(n,i-u/2),o=Math.max(o,i+u/2)}});const i=20,s=(r-e||0)+2*i,a=(o-n||0)+2*i;t.x=(e+r)/2,t.y=(n+o)/2,t.size=[s,a]}else t.x=r,t.y=n,t.size=[s,a]}}),this.model.forEachEdge(t=>{const e=b.getEdge(t.id);e&&e.data.controlPoints&&(t.points=e.data.controlPoints.map(bt))})})}},"d3-force-3d":class extends Mn{constructor(){super(...arguments),this.id="d3-force-3d",this.config={simulationAttrs:["alpha","alphaMin","alphaDecay","alphaTarget","velocityDecay","randomSource","numDimensions"]},this.forceMap={link:Kn,manyBody:io,center:_n,collide:Hn,radial:so,x:ao,y:uo,z:co}}getDefaultOptions(){return{numDimensions:3,link:{id:t=>t.id},manyBody:{},center:{x:0,y:0,z:0}}}initSimulation(){return oo()}setupForces(t,e){Object.entries(this.forceMap).forEach(([r,n])=>{const o=r;if(e[r]){let r=t.force(o);r||(r=n(),t.force(o,r)),Nn(r,Object.entries(e[o]))}else t.force(o,null)})}},"d3-force":Mn,"force-atlas2":class extends zt{constructor(){super(...arguments),this.id="force-atlas2",this.simulation=null}getDefaultOptions(){return Ly}layout(e){return t(this,void 0,void 0,function*(){const t=this.parseOptions(e),{width:r,height:n,prune:o,center:i}=t,s=this.model.nodeCount();if(!s||1===s)return L(this.model,i);kt(this.model,r,n);const a=this.getSizes(t.nodeSize,t.nodeSpacing),u=this.setSimulation();u.data(this.model,a),u.initialize(t),u.restart();const c=()=>new Promise(t=>{u.on("end",t)});if(!o)return c();if(yield c(),o){const e=this.model.edges();for(let t=0;t<e.length;t+=1){const{source:r,target:n}=e[t],o=this.model.degree(r),i=this.model.degree(n),s=this.model.node(r),a=this.model.node(n);o<=1?(s.x=a.x,s.y=a.y):i<=1&&(a.x=s.x,a.y=s.y)}u.initialize(Object.assign(Object.assign({},t),{prune:!1,barnesHut:!1})),u.tick(100)}})}getSizes(t,e){const r={},n=lt(t,e,Ly.nodeSize,Ly.nodeSpacing);return this.model.forEachNode(t=>{r[t.id]=Math.max(...n(t._original))}),r}setSimulation(){const t=this.simulation||new Fy;return this.simulation||(this.simulation=t.on("tick",()=>{var t,e;return null===(e=(t=this.options).onTick)||void 0===e?void 0:e.call(t,this)})),this.simulation}parseOptions(t={}){const{barnesHut:e,prune:r,maxIteration:n,kr:o,kg:i}=t,s={},a=this.model.nodeCount();return void 0===e&&a>250&&(s.barnesHut=!0),void 0===r&&a>100&&(s.prune=!0),0!==n||r?0===n&&r&&(s.maxIteration=100,a<=200&&a>100?s.maxIteration=500:a>200&&(s.maxIteration=950)):(s.maxIteration=250,a<=200&&a>100?s.maxIteration=1e3:a>200&&(s.maxIteration=1200)),o||(s.kr=50,a>100&&a<=500?s.kr=20:a>500&&(s.kr=1)),i||(s.kg=20,a>100&&a<=500?s.kg=10:a>500&&(s.kg=1)),Object.assign(Object.assign(Object.assign({},t),s),Et(t))}stop(){var t;null===(t=this.simulation)||void 0===t||t.stop()}tick(t=1){var e;null===(e=this.simulation)||void 0===e||e.tick(t)}restart(){var t;null===(t=this.simulation)||void 0===t||t.restart()}setFixedPosition(t,e){var r;null===(r=this.simulation)||void 0===r||r.setFixedPosition(t,e)}destroy(){var t;super.destroy(),this.stop(),null===(t=this.simulation)||void 0===t||t.destroy(),this.simulation=null}},circular:class extends Ot{constructor(){super(...arguments),this.id="circular"}getDefaultOptions(){return _r}layout(){return t(this,void 0,void 0,function*(){const{width:t,height:e,center:r}=Et(this.options),n=this.model.nodeCount();if(!n||1===n)return void L(this.model,r);const{ordering:o,nodeSpacing:i,nodeSize:s,endAngle:a=2*Math.PI,startAngle:u=0,divisions:c,angleRatio:h,clockwise:l}=this.options;"topology"===o?xt(this.model,!1):"topology-directed"===o?xt(this.model,!0):"degree"===o&&yt(this.model,"asc");let{radius:d,startRadius:f,endRadius:g}=this.options;const p=this.model.nodes(),v=lt(s,i,_r.nodeSize,_r.nodeSpacing);if(i){let t=0;for(const e of p)t+=Math.max(...v(e._original));d=t/(2*Math.PI)}else d||f||g?!f&&g?f=g:f&&!g&&(g=f):d=Math.min(e,t)/2;const m=(a-u)/n*h,y=Math.ceil(n/c),w=2*Math.PI/c;for(let t=0;t<n;){const e=p[t];let o=d;o||null===f||null===g||(o=f+t*(g-f)/(n-1)),o||(o=10+100*t/(n-1));const i=t%y*m+w*Math.floor(t/y);let s=u+i;l||(s=a-i),e.x=r[0]+Math.cos(s)*o,e.y=r[1]+Math.sin(s)*o,t++}})}},concentric:class extends Ot{constructor(){super(...arguments),this.id="concentric"}getDefaultOptions(){return kr}layout(){return t(this,void 0,void 0,function*(){const{width:t,height:e,center:r}=Et(this.options),n=this.model.nodeCount();if(!n||1===n)return void L(this.model,r);const{sortBy:o,maxLevelDiff:i,sweep:s,clockwise:a,equidistant:u,preventOverlap:c,startAngle:h=kr.startAngle,nodeSize:l,nodeSpacing:d}=this.options,f=o&&"degree"!==o?ut(o,["node"]):"degree";if("degree"===f)yt(this.model);else{const t=(t,e)=>{const r=f(t),n=f(e);return r===n?0:r>n?-1:1};wt(this.model,t)}const g=this.model.nodes(),p=new Map;for(const t of g){const e="degree"===f?this.model.degree(t.id):f(t._original);p.set(t.id,e)}const v=this.model.firstNode(),m=i||p.get(v.id)/4,y=lt(l,d,kr.nodeSize,kr.nodeSpacing),w=new Map;for(const t of g)w.set(t.id,Math.max(...y(t._original)));const x=[{nodes:[]}];let b=x[0];for(let t=0;t<n;t++){const e=g[t];if(b.nodes.length>0){const t=b.nodes[0],r=Math.abs(p.get(t.id)-p.get(e.id));m&&r>=m&&(b={nodes:[]},x.push(b))}b.nodes.push(e)}for(const t of x){const e=t.nodes.map(t=>w.get(t.id));t.nodeSizes=e,t.maxNodeSize=Math.max(...e)}if(x.forEach(t=>{const e=void 0===s?2*Math.PI-2*Math.PI/t.nodes.length:s;t.dTheta=e/Math.max(1,t.nodes.length-1)}),c){let t=0;for(let e=0;e<x.length;e++){const r=x[e];if(r.nodes.length>1){const e=r.nodeSizes||[];let n=0;for(let t=0;t<e.length-1;t++)n=Math.max(n,(e[t]+e[t+1])/2);const o=Math.cos(r.dTheta)-Math.cos(0),i=Math.sin(r.dTheta)-Math.sin(0),s=Math.sqrt(o*o+i*i),a=s>0?n/s:0;t=Math.max(a,t)}if(r.r=t,e<x.length-1){const n=x[e+1],o=((r.maxNodeSize||0)+(n.maxNodeSize||0))/2;t+=Math.max(0,o)}}}else{let r=0;x[0].r=0;for(let t=0;t<x.length-1;t++){const e=x[t],n=x[t+1],o=((e.maxNodeSize||0)+(n.maxNodeSize||0))/2;r+=Math.max(0,o),n.r=r}const n=Math.min(t,e)/2;let o=1;for(const t of x){const e=t.r||0;if(e<=0)continue;const r=n-(t.maxNodeSize||0);if(r<=0){o=0;break}o=Math.min(o,r/e)}if(o=Math.max(0,Math.min(1,o)),1!==o)for(const t of x)t.r=(t.r||0)*o}if(u){let t=0,e=0;for(let r=0;r<x.length;r++){const n=(x[r].r||0)-e;t=Math.max(t,n)}e=0,x.forEach((r,n)=>{0===n&&(e=r.r||0),r.r=e,e+=t})}x.forEach(t=>{const e=t.dTheta||0,n=t.r||0;t.nodes.forEach((t,o)=>{const i=h+(a?1:-1)*e*o;t.x=r[0]+n*Math.cos(i),t.y=r[1]+n*Math.sin(i)})})})}},dagre:class extends Ot{constructor(){super(...arguments),this.id="dagre",this.isCompoundGraph=null,this.config={graphAttributes:["rankdir","align","nodesep","edgesep","ranksep","marginx","marginy","acyclicer","ranker"],nodeAttributes:["width","height"],edgeAttributes:["minlen","weight","width","height","labelpos","labeloffset"]}}getDefaultOptions(){return{directed:!0,multigraph:!0,rankdir:"TB",align:void 0,nodesep:50,edgesep:10,ranksep:50,marginx:0,marginy:0,acyclicer:void 0,ranker:"network-simplex",nodeSize:[0,0],edgeMinLen:1,edgeWeight:1,edgeLabelSize:[0,0],edgeLabelPos:"r",edgeLabelOffset:10}}layout(){return t(this,void 0,void 0,function*(){const t=new My.graphlib.Graph({directed:!!this.options.directed,multigraph:!!this.options.multigraph,compound:this.isCompound()});t.setGraph(F(this.options,this.config.graphAttributes)),t.setDefaultEdgeLabel(()=>({}));const e=ht(this.options.nodeSize,0);this.model.forEachNode(r=>{const n=r._original,[o,i]=at(e(n)),s={width:o,height:i};if(t.setNode(String(r.id),s),this.isCompound()){if(E(r.parentId))return;t.setParent(String(r.id),String(r.parentId))}});const{edgeLabelSize:r,edgeLabelOffset:n,edgeLabelPos:o,edgeMinLen:i,edgeWeight:s}=this.options,a=ht(r,0,"edge"),u=ct(n,10,"edge"),c="string"==typeof o?()=>o:ut(o,["edge"]),h=ct(i,1,"edge"),l=ct(s,1,"edge");this.model.forEachEdge(e=>{const r=e._original,[n,o]=at(a(r)),i={width:n,height:o,labelpos:c(r),labeloffset:u(r),minlen:h(r),weight:l(r)};t.setEdge(String(e.source),String(e.target),i,String(e.id))}),Ny.layout(t),this.model.forEachNode(e=>{const r=t.node(String(e.id));r&&(e.x=r.x,e.y=r.y,e.size=[r.width,r.height])}),this.model.forEachEdge(e=>{const r=t.edge(String(e.source),String(e.target),String(e.id));if(!r)return;const{width:n,height:o,weight:i,minlen:s,labelpos:a,labeloffset:u,points:c}=r;e.labelSize=[n,o],e.weight=i,e.minLen=s,e.labelPos=a,e.labelOffset=u,e.points=c.map(bt)})})}isCompound(){return null!==this.isCompoundGraph?this.isCompoundGraph:(t=this.options.compound,_(t,"Boolean")?this.isCompoundGraph=this.options.compound:(this.isCompoundGraph=this.model.nodes().some(t=>!E(t.parentId)),this.isCompoundGraph));var t}},force:class extends zt{constructor(){super(...arguments),this.id="force",this.simulation=null}getDefaultOptions(){return Iy}layout(){var e;return t(this,void 0,void 0,function*(){const t=this.parseOptions(this.options),{width:r,height:n,dimensions:o}=t;if(this.initializePhysicsData(this.model,t),kt(this.model,r,n,o),!(null===(e=this.model.nodes())||void 0===e?void 0:e.length))return;const i=this.setSimulation(t);return i.data(this.model),i.initialize(t),i.restart(),new Promise(t=>{i.on("end",()=>t())})})}initializePhysicsData(t,e){const{nodeSize:r,getMass:n,nodeStrength:o,edgeStrength:i,linkDistance:s}=e;t.forEachNode(t=>{const e=t._original;t.size=r(e),t.mass=n(e),t.nodeStrength=o(e)}),t.forEachEdge(e=>{const r=e._original;e.edgeStrength=i(r),e.linkDistance=s(r,t.originalNode(e.source),t.originalNode(e.target))})}setSimulation(t){const e=this.simulation||new Cy;return this.simulation||(this.simulation=e.on("tick",()=>{var e;null===(e=t.onTick)||void 0===e||e.call(t,this)})),this.setupRepulsiveForce(e,t),this.setupAttractiveForce(e,t),this.setupCollideForce(e,t),this.setupGravityForce(e,t),this.setupCentripetalForce(e,t),e}setupRepulsiveForce(t,e){const{factor:r,coulombDisScale:n,dimensions:o}=e;let i=t.force("repulsive");i||(i=Sy(r,n,o),t.force("repulsive",i)),i.factor&&i.factor(r),i.coulombDisScale&&i.coulombDisScale(n),i.dimensions&&i.dimensions(o)}setupAttractiveForce(t,e){const{dimensions:r,preventOverlap:n}=e;if((this.model.edges()||[]).length>0){let e=t.force("attractive");e||(e=function(t=2){let e=!1;function r(e,r){e.forEachEdge(n=>{var o,i;const{source:s,target:a}=n,u=e.node(s),c=e.node(a);if(!u||!c)return;let h=c.x-u.x,l=c.y-u.y,d=3===t?(null!==(o=c.z)&&void 0!==o?o:0)-(null!==(i=u.z)&&void 0!==i?i:0):0;h||l||(h=.01,l=.01,3!==t||d||(d=.01));const f=Math.sqrt(h*h+l*l+d*d);if(f<Number(u.size)+Number(c.size))return;const g=h/f,p=l/f,v=d/f,{linkDistance:m=200,edgeStrength:y=200}=n,w=(m-f)*y,x=1/(u.mass||1),b=1/(c.mass||1),E=g*w,M=p*w,N=v*w;r[s].x-=E*x,r[s].y-=M*x,r[s].z-=N*x,r[a].x+=E*b,r[a].y+=M*b,r[a].z+=N*b})}return r.dimensions=function(e){return arguments.length?(t=e,r):t},r.preventOverlap=function(t){return arguments.length?(e=t,r):e},r}(r),t.force("attractive",e)),e.dimensions&&e.dimensions(r),e.preventOverlap&&e.preventOverlap(n)}else t.force("attractive",null)}setupGravityForce(t,e){const{center:r,gravity:n,getCenter:o}=e;if(n){let e=t.force("gravity");e||(e=function(t=[0,0,0],e=10){let r;function n(n,o){n.nodes()&&n.forEachNode(i=>{const{id:s,mass:a,x:u,y:c,z:h=0}=i;let l=0,d=0,f=0,g=e;const p=n.degree(s),v=null==r?void 0:r(i,p);if(v){const[t,e,r]=v;l=u-t,d=c-e,g=r}else l=u-t[0],d=c-t[1],f=h-(t[2]||0);g&&(o[s].x-=g*l/a,o[s].y-=g*d/a,o[s].z-=g*f/a)})}return n.center=function(e){return arguments.length?(t=e,n):t},n.gravity=function(t){return arguments.length?(e=t,n):e},n.getCenter=function(t){return arguments.length?(r=t,n):r},n}(r,n),t.force("gravity",e)),e.center&&e.center(r),e.gravity&&e.gravity(n),e.getCenter&&e.getCenter(o)}else t.force("gravity",null)}setupCollideForce(t,e){const{preventOverlap:r,collideStrength:n=1,dimensions:o}=e;if(r&&n){let e=t.force("collide");e||(e=function(t=2){let e=1;function r(r,n){const o=r.nodes();if(o.length<2||e<=0)return;if(2===t){const t=o.map((t,e)=>({id:t.id,index:e,x:t.x,y:t.y,r:Number(t.size)/2,mass:t.mass||1,fx:t.fx,fy:t.fy})),e=jr(t,t=>t.x,t=>t.y).visitAfter(ky);for(const r of t)e.visit((t,e,o,s,a)=>{const u=t.r||0,c=r.r+u;if(e>r.x+c||s<r.x-c||o>r.y+c||a<r.y-c)return!0;if(!t.data)return!1;let h=t;do{const t=h.data;t&&t.index>r.index&&i(r,t,n),h=h.next}while(h);return!1});return}const a=o.map((t,e)=>{var r;return{id:t.id,index:e,x:t.x,y:t.y,z:null!==(r=t.z)&&void 0!==r?r:0,r:Number(t.size)/2,mass:t.mass||1,fx:t.fx,fy:t.fy,fz:t.fz}});for(let t=0;t<a.length;t++)for(let e=t+1;e<a.length;e++)s(a[t],a[e],n)}function n(t){return A(t.fx)&&A(t.fy)?0:1/(t.mass||1)}function o(t){return A(t.fx)&&A(t.fy)&&A(t.fz)?0:1/(t.mass||1)}function i(t,r,o){let i=t.x-r.x,s=t.y-r.y,a=Math.hypot(i,s);const u=t.r+r.r;if(a>=u)return;a<_y&&(i=t.index<r.index?_y:-_y,s=0,a=Math.abs(i));const c=i/a,h=s/a,l=(u-a)*e*500,d=n(t),f=n(r);d&&(o[t.id].x+=c*l*d,o[t.id].y+=h*l*d),f&&(o[r.id].x-=c*l*f,o[r.id].y-=h*l*f)}function s(t,r,n){let i=t.x-r.x,s=t.y-r.y,a=t.z-r.z,u=Math.sqrt(i*i+s*s+a*a);const c=t.r+r.r;if(u>=c)return;u<_y&&(i=t.index<r.index?_y:-_y,s=0,a=0,u=Math.abs(i));const h=i/u,l=s/u,d=a/u,f=(c-u)*e*500,g=o(t),p=o(r);g&&(n[t.id].x+=h*f*g,n[t.id].y+=l*f*g,n[t.id].z+=d*f*g),p&&(n[r.id].x-=h*f*p,n[r.id].y-=l*f*p,n[r.id].z-=d*f*p)}return r.dimensions=function(e){return arguments.length?(t=e,r):t},r.strength=function(t){return arguments.length?(e=t,r):e},r}(o),t.force("collide",e)),e.strength&&e.strength(n),e.dimensions&&e.dimensions(o)}else t.force("collide",null)}setupCentripetalForce(t,e){const{centripetalOptions:r,width:n,height:o}=e;if(r){let e=t.force("centripetal");e||(e=function(){let t,e=800,r=600;function n(n,o){if(!t)return;const{leaf:i,single:s,others:a,center:u}=t,c=n.nodes(),h=n.edges(),l=c.map(t=>Object.assign(Object.assign({},t),{data:t.data||{}})),d=h.map(t=>Object.assign(Object.assign({},t),{data:t.data||{}}));n.forEachNode(t=>{const{id:c,mass:h,x:f,y:g,z:p=0,data:v}=t,m=n.degree(c,"in"),y=n.degree(c,"out"),w=n.degree(c,"both"),x=Object.assign(Object.assign({},t),{data:v||{}}),{x:b,y:E,z:M,centerStrength:N}=(null==u?void 0:u(x,l,d,e,r))||{x:0,y:0,z:0,centerStrength:0};if(!A(b)||!A(E))return;const _=(f-b)/h,k=(g-E)/h,S=(p-(M||0))/h;if(N&&(o[c].x-=N*_,o[c].y-=N*k,o[c].z-=N*S),0===w){const t=s(x);if(!t)return;return o[c].x-=t*_,o[c].y-=t*k,void(o[c].z-=t*S)}if(0===m||0===y){const t=i(x,l,d);if(!t)return;return o[c].x-=t*_,o[c].y-=t*k,void(o[c].z-=t*S)}const O=a(x);O&&(o[c].x-=O*_,o[c].y-=O*k,o[c].z-=O*S)})}return n.options=function(e){return arguments.length?(t=e,n):t},n.width=function(t){return arguments.length?(e=t,n):e},n.height=function(t){return arguments.length?(r=t,n):r},n}(),t.force("centripetal",e)),e.options&&e.options(r),e.width&&e.width(n),e.height&&e.height(o)}else t.force("centripetal",null)}parseOptions(t){const e=Object.assign(Object.assign({},t),Et(t));if(e.nodeClusterBy&&(e.nodeClusterBy=ut(e.nodeClusterBy,["node"])),t.getMass?e.getMass=ct(t.getMass,1):e.getMass=t=>{if(!t)return 1;const e=this.model.degree(t.id,"both");return!e||e<5?1:5*e*1},t.getCenter){const r=["node","degree"];e.getCenter=ut(t.getCenter,r)}const r=lt(t.nodeSize,t.nodeSpacing);return e.nodeSize=t=>{if(!t)return 0;const[e,n,o]=r(t);return Math.max(e,n,o)},e.linkDistance=t.linkDistance?ut(t.linkDistance,["edge","source","target"]):(t,e,r)=>1+t.nodeSize(e)+t.nodeSize(r),e.nodeStrength=ct(t.nodeStrength,1),e.edgeStrength=ct(t.edgeStrength,1,"edge"),e.clusterNodeStrength=ct(t.clusterNodeStrength,1),this.formatCentripetal(e),e}formatCentripetal(t){var e,r;const{dimensions:n,centripetalOptions:o,center:i,leafCluster:s,clustering:a,nodeClusterBy:u}=t,c=ut(null==o?void 0:o.leaf,["node","nodes","edges"]),h=ct(null==o?void 0:o.single,2),l=ct(null==o?void 0:o.others,1),d=ut(null!==(e=null==o?void 0:o.center)&&void 0!==e?e:t=>({x:i[0],y:i[1],z:3===n?i[2]:void 0}),["node","nodes","edges","width","height"]),f=Object.assign(Object.assign({},o),{leaf:c,single:h,others:l,center:d});let g,p;if(o&&(t.centripetalOptions=f),s&&u&&(g=this.getSameTypeLeafMap(u),p=Array.from(new Set(null===(r=this.model.nodes())||void 0===r?void 0:r.map(t=>u(t._original))))||[],t.centripetalOptions=Object.assign({},f,{single:()=>100,leaf:e=>{const{siblingLeaves:r,sameTypeLeaves:n}=g[e.id]||{};return(null==n?void 0:n.length)===(null==r?void 0:r.length)||1===(null==p?void 0:p.length)?1:t.clusterNodeStrength(e)},others:()=>1,center:t=>{const e=this.model.degree(t.id,"both");if(!e)return{x:100,y:100,z:0};let r;if(1===e){const{sameTypeLeaves:e=[]}=g[t.id]||{};1===e.length?r=void 0:e.length>1&&(r=this.getAvgNodePosition(e))}else r=void 0;return{x:null==r?void 0:r.x,y:null==r?void 0:r.y,z:null==r?void 0:r.z}}})),a&&u){g||(g=this.getSameTypeLeafMap(u));let e=[];T(e)&&this.model.forEachNode(t=>{const r=u(t._original);r&&!e.includes(r)&&e.push(r)});const r={};e.forEach(t=>{const e=this.model.nodes().filter(e=>u(e._original)===t);r[t]=this.getAvgNodePosition(e)}),t.centripetalOptions=Object.assign(f,{single:e=>t.clusterNodeStrength(e),leaf:e=>t.clusterNodeStrength(e),others:e=>t.clusterNodeStrength(e),center:t=>{const e=r[u(t._original)];return{x:null==e?void 0:e.x,y:null==e?void 0:e.y,z:null==e?void 0:e.z}}})}}getSameTypeLeafMap(t){const e={};return this.model.forEachNode(r=>{1===this.model.degree(r.id,"both")&&(e[r.id]=this.getCoreNodeAndSiblingLeaves(r,t))}),e}getCoreNodeAndSiblingLeaves(t,e){const r=this.model.degree(t.id,"in"),n=this.model.degree(t.id,"out");let o=t,i=[];if(0===r){const e=this.model.successors(t.id);o=this.model.node(e[0]),i=this.model.neighbors(o.id).map(t=>this.model.node(t))}else if(0===n){const e=this.model.predecessors(t.id);o=this.model.node(e[0]),i=this.model.neighbors(o.id).map(t=>this.model.node(t))}i=i.filter(t=>0===this.model.degree(t.id,"in")||0===this.model.degree(t.id,"out"));const s=e(t._original)||"",a=i.filter(t=>e(t._original)===s&&(0===this.model.degree(t.id,"in")||0===this.model.degree(t.id,"out")));return{coreNode:o,siblingLeaves:i,sameTypeLeaves:a}}getAvgNodePosition(t){const e={x:0,y:0};t.forEach(t=>{e.x+=t.x||0,e.y+=t.y||0});const r=t.length||1;return{x:e.x/r,y:e.y/r}}tick(t=1){return this.simulation&&this.simulation.tick(t),this}stop(){return this.simulation&&this.simulation.stop(),this}restart(){return this.simulation&&this.simulation.restart(),this}setFixedPosition(t,e){return this.simulation&&this.simulation.setFixedPosition(t,e),this}},fruchterman:class extends zt{constructor(){super(...arguments),this.id="fruchterman",this.simulation=null}getDefaultOptions(){return qy}parseOptions(t={}){const{clustering:e,nodeClusterBy:r}=this.options,n=e&&!!r;return Object.assign(t,Et(t),{clustering:n,nodeClusterBy:ut(r,["node"])}),t}layout(){return t(this,void 0,void 0,function*(){const t=this.parseOptions(this.options),{dimensions:e,center:r,width:n,height:o}=t,i=this.model.nodeCount();if(!i||1===i)return void L(this.model,r,e);kt(this.model,n,o,e);const s=this.setSimulation();return s.data(this.model),s.initialize(t),s.restart(),new Promise(t=>{s.on("end",()=>t())})})}setSimulation(){const t=this.simulation||new Dy;return this.simulation||(this.simulation=t.on("tick",()=>{var t,e;return null===(e=(t=this.options).onTick)||void 0===e?void 0:e.call(t,this)})),this.simulation}restart(){var t;null===(t=this.simulation)||void 0===t||t.restart()}stop(){var t;null===(t=this.simulation)||void 0===t||t.stop()}tick(t=1){var e;null===(e=this.simulation)||void 0===e||e.tick(t)}setFixedPosition(t,e){var r;null===(r=this.simulation)||void 0===r||r.setFixedPosition(t,e)}destroy(){var t;super.destroy(),this.stop(),null===(t=this.simulation)||void 0===t||t.destroy(),this.simulation=null}},grid:class extends Ot{constructor(){super(...arguments),this.id="grid"}getDefaultOptions(){return By}parseOptions(t={},e){const{rows:r,cols:n,position:o,sortBy:i}=t,{width:s,height:a,center:u}=Et(t);let c=t.rows,h=t.cols;const l=e.nodeCount();if(null!=r&&null!=n)c=r,h=n;else if(null!=r&&null==n)c=r,h=Math.ceil(l/c);else if(null==r&&null!=n)h=n,c=Math.ceil(l/h);else{const t=Math.sqrt(l*a/s);c=Math.round(t),h=Math.round(s/a*t)}c=Math.max(c,1),h=Math.max(h,1);const d={rows:c,cols:h};if(d.cols*d.rows>l){const t=Vy(d),e=$y(d);(t-1)*e>=l?Vy(d,t-1):(e-1)*t>=l&&$y(d,e-1)}else for(;d.cols*d.rows<l;){const t=Vy(d),e=$y(d);(e+1)*t>=l?$y(d,e+1):Vy(d,t+1)}const f=i?"degree"===i||"id"===i?i:ut(i,["nodeA","nodeB"]):By.sortBy;return Object.assign(Object.assign({},t),{sortBy:f,rcs:d,center:u,width:s,height:a,position:ut(o,["node"])})}layout(){return t(this,void 0,void 0,function*(){const{begin:t,rcs:e,sortBy:r,width:n,height:o,condense:i,preventOverlap:s,nodeSpacing:a,nodeSize:u,position:c}=this.parseOptions(this.options,this.model),h=this.model.nodeCount();if(!h||1===h)return void L(this.model,t);"degree"===r?yt(this.model):"id"===r?mt(this.model,(t,e)=>{const r=t.id,n=e.id;return"number"==typeof r&&"number"==typeof n?r-n:String(r).localeCompare(String(n))}):wt(this.model,r);let l=i?0:n/e.cols,d=i?0:o/e.rows;if(s){const t=lt(u,a,By.nodeSize,By.nodeSpacing);this.model.forEachNode(e=>{const[r,n]=t(e._original);l=Math.max(l,r),d=Math.max(d,n)})}const f={},g={row:0,col:0},p={};this.model.forEachNode(r=>{const n=r._original;let o;if(c&&(o=c(n)),o&&(void 0!==o.row||void 0!==o.col)){const t={row:o.row,col:o.col};if(void 0===t.col)for(t.col=0;Uy(f,t);)t.col++;else if(void 0===t.row)for(t.row=0;Uy(f,t);)t.row++;p[r.id]=t,Gy(f,t)}Yy(r,t,l,d,p,e,g,f)})})}},mds:class extends Ot{constructor(){super(...arguments),this.id="mds"}getDefaultOptions(){return sw}layout(){return t(this,void 0,void 0,function*(){const{linkDistance:t=sw.linkDistance}=this.options,{center:e}=Et(this.options),r=this.model.nodeCount();if(0===r||1===r)return void L(this.model,e);const n=ft(dt(this.model));aw(n);const o=((t,e)=>{const r=t.length,n=new Array(r);for(let o=0;o<r;o++){const r=t[o],i=r.length,s=new Array(i);for(let t=0;t<i;t++)s[t]=r[t]*e;n[o]=s}return n})(n,t),i=uw(o);let s=0;this.model.forEachNode(t=>{const r=i[s++];t.x=r[0]+e[0],t.y=r[1]+e[1]})})}},radial:class extends Ot{constructor(){super(...arguments),this.id="radial"}getDefaultOptions(){return dw}layout(){return t(this,void 0,void 0,function*(){const{width:t,height:e,center:r}=Et(this.options),n=this.model.nodeCount();if(!n||1===n)return L(this.model,r);const{focusNode:o,linkDistance:i=dw.linkDistance,maxIteration:s=dw.maxIteration,maxPreventOverlapIteration:a=dw.maxPreventOverlapIteration,nodeSize:u,nodeSpacing:c,preventOverlap:h,sortBy:l,sortStrength:d=dw.sortStrength,strictRadial:f,unitRadius:g}=this.options,p=o&&this.model.node(o)||this.model.firstNode(),v=this.model.nodeIndexOf(p.id),m=ft(dt(this.model)),y=vw(m,v);pw(m,v,y+1);const w=m[v],x=(t-r[0]>r[0]?r[0]:t-r[0])||t/2,b=(e-r[1]>r[1]?r[1]:e-r[1])||e/2,E=Math.min(x,b),M=Math.max(...w),N=[],_=new Map,k=null!=g?g:E/M;w.forEach((t,e)=>{const r=t*k;N.push(r),_.set(this.model.nodeAt(e).id,r)});const S=fw(this.model,m,i,N,k,l,d),A=uw(S,2,i),O=A[v];let z=0;if(this.model.forEachNode(t=>{const e=A[z];t.x=e[0]-O[0],t.y=e[1]-O[1],z++}),this.run(s,S,N,v),this.model.forEachNode(t=>{t.x+=r[0],t.y+=r[1]}),h){const e={nodeSizeFunc:lt(u,c,dw.nodeSize,dw.nodeSpacing),radiiMap:_,width:t,strictRadial:Boolean(f),focusNode:p,maxIteration:a,k:n/4.5};((t,e)=>{const r=Object.assign(Object.assign({},cw),e),{maxIteration:n,width:o,k:i,speed:s=cw.speed,strictRadial:a,focusNode:u,radiiMap:c,nodeSizeFunc:h}=r,l=.002*i,d=new Map,f=o/10;for(let e=0;e<n&&(t.forEachNode(t=>{d.set(t.id,{x:0,y:0})}),hw(t,d,i,c,h),!(lw(t,d,s,a,u,f,c)<l));e++);})(this.model,e)}})}run(t,e,r,n){const o=gw(e),i=this.model.nodeCount(),s=this.model.nodes(),a=new Float64Array(i),u=new Float64Array(i);for(let t=0;t<i;t++)a[t]=s[t].x,u[t]=s[t].y;for(let c=0;c<=t;c++){const h=c/t,l=1-h;for(let t=0;t<i;t++){if(t===n)continue;const c=a[t],d=u[t],f=Math.sqrt(c*c+d*d),g=0===f?0:1/f;let p=0,v=0,m=0;for(let r=0;r<i;r++){if(t===r)continue;const n=a[r],i=u[r],s=Math.sqrt((c-n)*(c-n)+(d-i)*(d-i)),h=0===s?0:1/s,l=e[r][t];m+=o[t][r],p+=o[t][r]*(n+l*(c-n)*h),v+=o[t][r]*(i+l*(d-i)*h)}const y=0===r[t]?0:1/r[t];m*=l,m+=h*y*y,p*=l,p+=h*y*c*g,v*=l,v+=h*y*d*g,a[t]=p/m,u[t]=v/m,s[t].x=a[t],s[t].y=u[t]}}}},random:class extends Ot{constructor(){super(...arguments),this.id="random"}getDefaultOptions(){return{center:[0,0],width:300,height:300}}layout(){return t(this,void 0,void 0,function*(){const{width:t,height:e,center:r}=Et(this.options);this.model.forEachNode(n=>{n.x=mw(t)+r[0],n.y=mw(e)+r[1]})})}}};let ww=null;u({execute(e,r,n){var o;return t(this,void 0,void 0,function*(){const t=yw[e];if(!t)throw new Error(`Layout "${e}" is not registered.`);null===(o=null==ww?void 0:ww.destroy)||void 0===o||o.call(ww),ww=new t;const i=function(t){if(!t)return t;const e=Object.assign({},t);return e.enableWorker=!1,e}(n);return yield ww.execute(r,i),ww.model.data()})},destroy(){var t;null===(t=null==ww?void 0:ww.destroy)||void 0===t||t.call(ww),ww=null,"undefined"!=typeof self&&"close"in self&&self.close()}})}();
|
|
8
8
|
//# sourceMappingURL=worker.js.map
|