@moxa/graph 1.4.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.
Files changed (239) hide show
  1. package/assets/worker-CJB7i_ev.js +13 -0
  2. package/index.cjs +237 -4020
  3. package/index.d.ts +0 -5
  4. package/index.d.ts.map +1 -1
  5. package/index.js +53881 -70284
  6. package/lib/edge/custom/index.d.ts +4 -0
  7. package/lib/edge/custom/index.d.ts.map +1 -0
  8. package/lib/edge/custom/line-edge.d.ts +16 -0
  9. package/lib/edge/custom/line-edge.d.ts.map +1 -0
  10. package/lib/edge/custom/polyline-edge.d.ts +19 -0
  11. package/lib/edge/custom/polyline-edge.d.ts.map +1 -0
  12. package/lib/edge/custom/quadratic-edge.d.ts +16 -0
  13. package/lib/edge/custom/quadratic-edge.d.ts.map +1 -0
  14. package/lib/edge/helper/custom-edge.helper.d.ts +12 -0
  15. package/lib/edge/helper/custom-edge.helper.d.ts.map +1 -0
  16. package/lib/edge/helper/edge-g6.mapper.d.ts +18 -0
  17. package/lib/edge/helper/edge-g6.mapper.d.ts.map +1 -0
  18. package/lib/edge/helper/edge.mapper.d.ts +17 -0
  19. package/lib/edge/helper/edge.mapper.d.ts.map +1 -0
  20. package/lib/edge/helper/edge.theme.d.ts +9 -0
  21. package/lib/edge/helper/edge.theme.d.ts.map +1 -0
  22. package/lib/edge/helper/index.d.ts +5 -0
  23. package/lib/edge/helper/index.d.ts.map +1 -0
  24. package/lib/edge/index.d.ts +2 -10
  25. package/lib/edge/index.d.ts.map +1 -1
  26. package/lib/graph/graph.d.ts +73 -407
  27. package/lib/graph/graph.d.ts.map +1 -1
  28. package/lib/graph/graph.mapper.d.ts +15 -0
  29. package/lib/graph/graph.mapper.d.ts.map +1 -0
  30. package/lib/graph/index.d.ts +1 -0
  31. package/lib/graph/index.d.ts.map +1 -1
  32. package/lib/group/custom/device-group.d.ts +32 -0
  33. package/lib/group/custom/device-group.d.ts.map +1 -0
  34. package/lib/group/custom/index.d.ts +2 -0
  35. package/lib/group/custom/index.d.ts.map +1 -0
  36. package/lib/group/helper/group-g6.mapper.d.ts +7 -0
  37. package/lib/group/helper/group-g6.mapper.d.ts.map +1 -0
  38. package/lib/group/helper/group.mapper.d.ts +8 -0
  39. package/lib/group/helper/group.mapper.d.ts.map +1 -0
  40. package/lib/group/helper/index.d.ts +3 -0
  41. package/lib/group/helper/index.d.ts.map +1 -0
  42. package/lib/group/index.d.ts +2 -3
  43. package/lib/group/index.d.ts.map +1 -1
  44. package/lib/interaction/brush-select.d.ts +6 -0
  45. package/lib/interaction/brush-select.d.ts.map +1 -0
  46. package/lib/interaction/click-select.d.ts +5 -72
  47. package/lib/interaction/click-select.d.ts.map +1 -1
  48. package/lib/interaction/collapse-expand.d.ts +6 -0
  49. package/lib/interaction/collapse-expand.d.ts.map +1 -0
  50. package/lib/interaction/create-edge.d.ts +6 -0
  51. package/lib/interaction/create-edge.d.ts.map +1 -0
  52. package/lib/interaction/drag-canvas.d.ts +6 -0
  53. package/lib/interaction/drag-canvas.d.ts.map +1 -0
  54. package/lib/interaction/drag-element.d.ts +6 -0
  55. package/lib/interaction/drag-element.d.ts.map +1 -0
  56. package/lib/interaction/focus-element.d.ts +6 -0
  57. package/lib/interaction/focus-element.d.ts.map +1 -0
  58. package/lib/interaction/helper/behavior.mapper.d.ts +6 -0
  59. package/lib/interaction/helper/behavior.mapper.d.ts.map +1 -0
  60. package/lib/interaction/helper/index.d.ts +2 -0
  61. package/lib/interaction/helper/index.d.ts.map +1 -0
  62. package/lib/interaction/hover-activate.d.ts +5 -46
  63. package/lib/interaction/hover-activate.d.ts.map +1 -1
  64. package/lib/interaction/index.d.ts +1 -5
  65. package/lib/interaction/index.d.ts.map +1 -1
  66. package/lib/interaction/scroll-canvas.d.ts +6 -0
  67. package/lib/interaction/scroll-canvas.d.ts.map +1 -0
  68. package/lib/interaction/select-all.d.ts +14 -0
  69. package/lib/interaction/select-all.d.ts.map +1 -0
  70. package/lib/interaction/zoom-canvas.d.ts +6 -0
  71. package/lib/interaction/zoom-canvas.d.ts.map +1 -0
  72. package/lib/layout/grid.d.ts +12 -0
  73. package/lib/layout/grid.d.ts.map +1 -0
  74. package/lib/layout/helper/index.d.ts +2 -0
  75. package/lib/layout/helper/index.d.ts.map +1 -0
  76. package/lib/layout/helper/layout.mapper.d.ts +5 -0
  77. package/lib/layout/helper/layout.mapper.d.ts.map +1 -0
  78. package/lib/layout/index.d.ts +5 -4
  79. package/lib/layout/index.d.ts.map +1 -1
  80. package/lib/layout/mesh.d.ts +10 -0
  81. package/lib/layout/mesh.d.ts.map +1 -0
  82. package/lib/layout/ring.d.ts +10 -0
  83. package/lib/layout/ring.d.ts.map +1 -0
  84. package/lib/layout/tree.d.ts +12 -0
  85. package/lib/layout/tree.d.ts.map +1 -0
  86. package/lib/model/behavior.model.d.ts +45 -18
  87. package/lib/model/behavior.model.d.ts.map +1 -1
  88. package/lib/model/edge.model.d.ts +20 -43
  89. package/lib/model/edge.model.d.ts.map +1 -1
  90. package/lib/model/event.model.d.ts +207 -2
  91. package/lib/model/event.model.d.ts.map +1 -1
  92. package/lib/model/graph.model.d.ts +14 -55
  93. package/lib/model/graph.model.d.ts.map +1 -1
  94. package/lib/model/group.model.d.ts +7 -29
  95. package/lib/model/group.model.d.ts.map +1 -1
  96. package/lib/model/icon.model.d.ts +1 -1
  97. package/lib/model/icon.model.d.ts.map +1 -1
  98. package/lib/model/label.model.d.ts +0 -2
  99. package/lib/model/label.model.d.ts.map +1 -1
  100. package/lib/model/layout.model.d.ts +14 -22
  101. package/lib/model/layout.model.d.ts.map +1 -1
  102. package/lib/model/node.model.d.ts +7 -32
  103. package/lib/model/node.model.d.ts.map +1 -1
  104. package/lib/model/plugin.model.d.ts +11 -40
  105. package/lib/model/plugin.model.d.ts.map +1 -1
  106. package/lib/model/theme.model.d.ts +2 -6
  107. package/lib/model/theme.model.d.ts.map +1 -1
  108. package/lib/node/custom/device-node.d.ts +30 -0
  109. package/lib/node/custom/device-node.d.ts.map +1 -0
  110. package/lib/node/custom/index.d.ts +2 -0
  111. package/lib/node/custom/index.d.ts.map +1 -0
  112. package/lib/node/helper/icon-style.d.ts +4 -0
  113. package/lib/node/helper/icon-style.d.ts.map +1 -0
  114. package/lib/node/helper/index.d.ts +5 -0
  115. package/lib/node/helper/index.d.ts.map +1 -0
  116. package/lib/node/helper/key-style.d.ts +5 -0
  117. package/lib/node/helper/key-style.d.ts.map +1 -0
  118. package/lib/node/helper/node-g6.mapper.d.ts +13 -0
  119. package/lib/node/helper/node-g6.mapper.d.ts.map +1 -0
  120. package/lib/node/helper/node.mapper.d.ts +23 -0
  121. package/lib/node/helper/node.mapper.d.ts.map +1 -0
  122. package/lib/node/index.d.ts +2 -3
  123. package/lib/node/index.d.ts.map +1 -1
  124. package/lib/plugin/_minimap.d.ts +1 -0
  125. package/lib/plugin/_minimap.d.ts.map +1 -0
  126. package/lib/plugin/context-menu.d.ts +5 -0
  127. package/lib/plugin/context-menu.d.ts.map +1 -0
  128. package/lib/plugin/graph-background.d.ts +26 -19
  129. package/lib/plugin/graph-background.d.ts.map +1 -1
  130. package/lib/plugin/helper/index.d.ts +2 -0
  131. package/lib/plugin/helper/index.d.ts.map +1 -0
  132. package/lib/plugin/helper/plugin.mapper.d.ts +7 -0
  133. package/lib/plugin/helper/plugin.mapper.d.ts.map +1 -0
  134. package/lib/plugin/history.d.ts +5 -0
  135. package/lib/plugin/history.d.ts.map +1 -0
  136. package/lib/plugin/index.d.ts +3 -2
  137. package/lib/plugin/index.d.ts.map +1 -1
  138. package/lib/plugin/toolbar.d.ts +4 -2
  139. package/lib/plugin/toolbar.d.ts.map +1 -1
  140. package/lib/plugin/tooltip.d.ts +9 -97
  141. package/lib/plugin/tooltip.d.ts.map +1 -1
  142. package/lib/themes/dark.d.ts +3 -0
  143. package/lib/themes/dark.d.ts.map +1 -0
  144. package/lib/themes/index.d.ts +3 -3
  145. package/lib/themes/index.d.ts.map +1 -1
  146. package/lib/themes/light.d.ts +3 -0
  147. package/lib/themes/light.d.ts.map +1 -0
  148. package/lib/themes/light.theme.d.ts +3 -0
  149. package/lib/themes/light.theme.d.ts.map +1 -0
  150. package/lib/themes/theme.mapper.d.ts +65 -0
  151. package/lib/themes/theme.mapper.d.ts.map +1 -0
  152. package/lib/utils/edge.helper.d.ts +19 -0
  153. package/lib/utils/edge.helper.d.ts.map +1 -0
  154. package/lib/utils/graph.helper.d.ts +4 -0
  155. package/lib/utils/graph.helper.d.ts.map +1 -0
  156. package/lib/utils/index.d.ts +4 -0
  157. package/lib/utils/index.d.ts.map +1 -1
  158. package/lib/utils/rect.helper.d.ts +16 -0
  159. package/lib/utils/rect.helper.d.ts.map +1 -0
  160. package/lib/utils/state.helper.d.ts +1 -1
  161. package/lib/utils/state.helper.d.ts.map +1 -1
  162. package/lib/utils/tree.helper.d.ts +4 -0
  163. package/lib/utils/tree.helper.d.ts.map +1 -0
  164. package/package.json +2 -2
  165. package/assets/worker-DNGSJ4Eg.js +0 -13
  166. package/lib/data/data.d.ts +0 -2
  167. package/lib/data/data.d.ts.map +0 -1
  168. package/lib/data/index.d.ts +0 -2
  169. package/lib/data/index.d.ts.map +0 -1
  170. package/lib/edge/cubic-edge.d.ts +0 -47
  171. package/lib/edge/cubic-edge.d.ts.map +0 -1
  172. package/lib/edge/edge.controller.d.ts +0 -19
  173. package/lib/edge/edge.controller.d.ts.map +0 -1
  174. package/lib/edge/edge.helper.d.ts +0 -6
  175. package/lib/edge/edge.helper.d.ts.map +0 -1
  176. package/lib/edge/line-edge.d.ts +0 -28
  177. package/lib/edge/line-edge.d.ts.map +0 -1
  178. package/lib/edge/loop-edge.d.ts +0 -34
  179. package/lib/edge/loop-edge.d.ts.map +0 -1
  180. package/lib/edge/multi-label-edge-base.d.ts +0 -84
  181. package/lib/edge/multi-label-edge-base.d.ts.map +0 -1
  182. package/lib/edge/polyline-edge.d.ts +0 -40
  183. package/lib/edge/polyline-edge.d.ts.map +0 -1
  184. package/lib/edge/quadratic-edge.d.ts +0 -41
  185. package/lib/edge/quadratic-edge.d.ts.map +0 -1
  186. package/lib/graph/extendGraph.d.ts +0 -25
  187. package/lib/graph/extendGraph.d.ts.map +0 -1
  188. package/lib/group/device-group.d.ts +0 -179
  189. package/lib/group/device-group.d.ts.map +0 -1
  190. package/lib/group/group.controller.d.ts +0 -17
  191. package/lib/group/group.controller.d.ts.map +0 -1
  192. package/lib/group/group.helper.d.ts +0 -5
  193. package/lib/group/group.helper.d.ts.map +0 -1
  194. package/lib/interaction/collapse-expand-combo.d.ts +0 -26
  195. package/lib/interaction/collapse-expand-combo.d.ts.map +0 -1
  196. package/lib/interaction/drag-item.d.ts +0 -17
  197. package/lib/interaction/drag-item.d.ts.map +0 -1
  198. package/lib/interaction/interaction.controller.d.ts +0 -18
  199. package/lib/interaction/interaction.controller.d.ts.map +0 -1
  200. package/lib/interaction/mapping/edge-mapping.behavior.d.ts +0 -4
  201. package/lib/interaction/mapping/edge-mapping.behavior.d.ts.map +0 -1
  202. package/lib/interaction/mapping/graph-mapping.behavior.d.ts +0 -43
  203. package/lib/interaction/mapping/graph-mapping.behavior.d.ts.map +0 -1
  204. package/lib/interaction/mapping/group-mapping.behavior.d.ts +0 -4
  205. package/lib/interaction/mapping/group-mapping.behavior.d.ts.map +0 -1
  206. package/lib/interaction/mapping/node-mapping.behavior.d.ts +0 -4
  207. package/lib/interaction/mapping/node-mapping.behavior.d.ts.map +0 -1
  208. package/lib/interaction/select-all-item.behavior.d.ts +0 -6
  209. package/lib/interaction/select-all-item.behavior.d.ts.map +0 -1
  210. package/lib/layout/grid-layout.d.ts +0 -4
  211. package/lib/layout/grid-layout.d.ts.map +0 -1
  212. package/lib/layout/layout.mapper.d.ts +0 -4
  213. package/lib/layout/layout.mapper.d.ts.map +0 -1
  214. package/lib/layout/mesh-layout.d.ts +0 -4
  215. package/lib/layout/mesh-layout.d.ts.map +0 -1
  216. package/lib/layout/tree-layout.d.ts +0 -4
  217. package/lib/layout/tree-layout.d.ts.map +0 -1
  218. package/lib/node/device-node.d.ts +0 -172
  219. package/lib/node/device-node.d.ts.map +0 -1
  220. package/lib/node/node.controller.d.ts +0 -18
  221. package/lib/node/node.controller.d.ts.map +0 -1
  222. package/lib/node/node.helper.d.ts +0 -5
  223. package/lib/node/node.helper.d.ts.map +0 -1
  224. package/lib/plugin/minimap.d.ts +0 -3
  225. package/lib/plugin/minimap.d.ts.map +0 -1
  226. package/lib/plugin/plugin.mapper.d.ts +0 -4
  227. package/lib/plugin/plugin.mapper.d.ts.map +0 -1
  228. package/lib/themes/dark/dark.theme.d.ts +0 -4
  229. package/lib/themes/dark/dark.theme.d.ts.map +0 -1
  230. package/lib/themes/dark/index.d.ts +0 -2
  231. package/lib/themes/dark/index.d.ts.map +0 -1
  232. package/lib/themes/dark/node-dark.theme.d.ts +0 -3
  233. package/lib/themes/dark/node-dark.theme.d.ts.map +0 -1
  234. package/lib/themes/light/index.d.ts +0 -2
  235. package/lib/themes/light/index.d.ts.map +0 -1
  236. package/lib/themes/light/light.theme.d.ts +0 -4
  237. package/lib/themes/light/light.theme.d.ts.map +0 -1
  238. package/lib/themes/light/node-light.theme.d.ts +0 -3
  239. package/lib/themes/light/node-light.theme.d.ts.map +0 -1
@@ -1,13 +0,0 @@
1
- var Bu=Object.defineProperty;var Vu=(it,at,R)=>at in it?Bu(it,at,{enumerable:!0,configurable:!0,writable:!0,value:R}):it[at]=R;var ot=(it,at,R)=>(Vu(it,typeof at!="symbol"?at+"":at,R),R),tr=(it,at,R)=>{if(!at.has(it))throw TypeError("Cannot "+R)};var bt=(it,at,R)=>(tr(it,at,"read from private field"),R?R.call(it):at.get(it)),er=(it,at,R)=>{if(at.has(it))throw TypeError("Cannot add the same private member more than once");at instanceof WeakSet?at.add(it):at.set(it,R)},ke=(it,at,R,Wt)=>(tr(it,at,"write to private field"),Wt?Wt.call(it,R):at.set(it,R),R);var rr=(it,at,R)=>(tr(it,at,"access private method"),R);(function(){"use strict";var Ht,nr,Ut,dt;var it=function(i,e){return it=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(t,r){t.__proto__=r}||function(t,r){for(var n in r)Object.prototype.hasOwnProperty.call(r,n)&&(t[n]=r[n])},it(i,e)};function at(i,e){if(typeof e!="function"&&e!==null)throw new TypeError("Class extends value "+String(e)+" is not a constructor or null");it(i,e);function t(){this.constructor=i}i.prototype=e===null?Object.create(e):(t.prototype=e.prototype,new t)}var R=function(){return R=Object.assign||function(e){for(var t,r=1,n=arguments.length;r<n;r++){t=arguments[r];for(var o in t)Object.prototype.hasOwnProperty.call(t,o)&&(e[o]=t[o])}return e},R.apply(this,arguments)};function Wt(i,e){var t={};for(var r in i)Object.prototype.hasOwnProperty.call(i,r)&&e.indexOf(r)<0&&(t[r]=i[r]);if(i!=null&&typeof Object.getOwnPropertySymbols=="function")for(var n=0,r=Object.getOwnPropertySymbols(i);n<r.length;n++)e.indexOf(r[n])<0&&Object.prototype.propertyIsEnumerable.call(i,r[n])&&(t[r[n]]=i[r[n]]);return t}function K(i,e,t,r){function n(o){return o instanceof t?o:new t(function(a){a(o)})}return new(t||(t=Promise))(function(o,a){function s(l){try{u(r.next(l))}catch(h){a(h)}}function f(l){try{u(r.throw(l))}catch(h){a(h)}}function u(l){l.done?o(l.value):n(l.value).then(s,f)}u((r=r.apply(i,e||[])).next())})}function H(i,e){var t={label:0,sent:function(){if(o[0]&1)throw o[1];return o[1]},trys:[],ops:[]},r,n,o,a;return a={next:s(0),throw:s(1),return:s(2)},typeof Symbol=="function"&&(a[Symbol.iterator]=function(){return this}),a;function s(u){return function(l){return f([u,l])}}function f(u){if(r)throw new TypeError("Generator is already executing.");for(;a&&(a=0,u[0]&&(t=0)),t;)try{if(r=1,n&&(o=u[0]&2?n.return:u[0]?n.throw||((o=n.return)&&o.call(n),0):n.next)&&!(o=o.call(n,u[1])).done)return o;switch(n=0,o&&(u=[u[0]&2,o.value]),u[0]){case 0:case 1:o=u;break;case 4:return t.label++,{value:u[1],done:!1};case 5:t.label++,n=u[1],u=[0];continue;case 7:u=t.ops.pop(),t.trys.pop();continue;default:if(o=t.trys,!(o=o.length>0&&o[o.length-1])&&(u[0]===6||u[0]===2)){t=0;continue}if(u[0]===3&&(!o||u[1]>o[0]&&u[1]<o[3])){t.label=u[1];break}if(u[0]===6&&t.label<o[1]){t.label=o[1],o=u;break}if(o&&t.label<o[2]){t.label=o[2],t.ops.push(u);break}o[2]&&t.ops.pop(),t.trys.pop();continue}u=e.call(i,t)}catch(l){u=[6,l],n=0}finally{r=o=0}if(u[0]&5)throw u[1];return{value:u[0]?u[1]:void 0,done:!0}}}function st(i,e){var t=typeof Symbol=="function"&&i[Symbol.iterator];if(!t)return i;var r=t.call(i),n,o=[],a;try{for(;(e===void 0||e-- >0)&&!(n=r.next()).done;)o.push(n.value)}catch(s){a={error:s}}finally{try{n&&!n.done&&(t=r.return)&&t.call(r)}finally{if(a)throw a.error}}return o}function ut(i,e,t){if(t||arguments.length===2)for(var r=0,n=e.length,o;r<n;r++)(o||!(r in e))&&(o||(o=Array.prototype.slice.call(e,0,r)),o[r]=e[r]);return i.concat(o||Array.prototype.slice.call(e))}typeof SuppressedError=="function"&&SuppressedError;var In="*",Tn=function(){function i(){this._events={}}return i.prototype.on=function(e,t,r){return this._events[e]||(this._events[e]=[]),this._events[e].push({callback:t,once:!!r}),this},i.prototype.once=function(e,t){return this.on(e,t,!0)},i.prototype.emit=function(e){for(var t=this,r=[],n=1;n<arguments.length;n++)r[n-1]=arguments[n];var o=this._events[e]||[],a=this._events[In]||[],s=function(f){for(var u=f.length,l=0;l<u;l++)if(f[l]){var h=f[l],d=h.callback,g=h.once;g&&(f.splice(l,1),f.length===0&&delete t._events[e],u--,l--),d.apply(t,r)}};s(o),s(a)},i.prototype.off=function(e,t){if(!e)this._events={};else if(!t)delete this._events[e];else{for(var r=this._events[e]||[],n=r.length,o=0;o<n;o++)r[o].callback===t&&(r.splice(o,1),n--,o--);r.length===0&&delete this._events[e]}return this},i.prototype.getEvents=function(){return this._events},i}();function _e(i,e,t,r){for(;i.length;){const n=i.shift();if(t(n))return!0;e.add(n.id),r(n.id).forEach(a=>{e.has(a.id)||(e.add(a.id),i.push(a))})}return!1}function te(i,e,t,r){if(t(i))return!0;e.add(i.id);for(const o of r(i.id))if(!e.has(o.id)&&te(o,e,t,r))return!0;return!1}const ir=()=>!0;class Ln{constructor(e){ot(this,"graph");ot(this,"nodeFilter");ot(this,"edgeFilter");ot(this,"cacheEnabled");ot(this,"inEdgesMap",new Map);ot(this,"outEdgesMap",new Map);ot(this,"bothEdgesMap",new Map);ot(this,"allNodesMap",new Map);ot(this,"allEdgesMap",new Map);ot(this,"clearCache",()=>{this.inEdgesMap.clear(),this.outEdgesMap.clear(),this.bothEdgesMap.clear(),this.allNodesMap.clear(),this.allEdgesMap.clear()});ot(this,"refreshCache",()=>{this.clearCache(),this.updateCache(this.graph.getAllNodes().map(e=>e.id))});ot(this,"updateCache",e=>{const t=new Set;e.forEach(r=>{const n=this.bothEdgesMap.get(r);if(n&&n.forEach(o=>t.add(o.id)),!this.hasNode(r))this.inEdgesMap.delete(r),this.outEdgesMap.delete(r),this.bothEdgesMap.delete(r),this.allNodesMap.delete(r);else{const o=this.graph.getRelatedEdges(r,"in").filter(this.edgeFilter),a=this.graph.getRelatedEdges(r,"out").filter(this.edgeFilter),s=Array.from(new Set([...o,...a]));s.forEach(f=>t.add(f.id)),this.inEdgesMap.set(r,o),this.outEdgesMap.set(r,a),this.bothEdgesMap.set(r,s),this.allNodesMap.set(r,this.graph.getNode(r))}}),t.forEach(r=>{this.hasEdge(r)?this.allEdgesMap.set(r,this.graph.getEdge(r)):this.allEdgesMap.delete(r)})});ot(this,"handleGraphChanged",e=>{const t=new Set;e.changes.forEach(r=>{switch(r.type){case"NodeAdded":t.add(r.value.id);break;case"NodeDataUpdated":t.add(r.id);break;case"EdgeAdded":t.add(r.value.source),t.add(r.value.target);break;case"EdgeUpdated":(r.propertyName==="source"||r.propertyName==="target")&&(t.add(r.oldValue),t.add(r.newValue));break;case"EdgeDataUpdated":if(e.graph.hasEdge(r.id)){const n=e.graph.getEdge(r.id);t.add(n.source),t.add(n.target)}break;case"EdgeRemoved":t.add(r.value.source),t.add(r.value.target);break;case"NodeRemoved":t.add(r.value.id);break}}),this.updateCache(t)});this.graph=e.graph;const t=e.nodeFilter||ir,r=e.edgeFilter||ir;this.nodeFilter=t,this.edgeFilter=n=>{const{source:o,target:a}=this.graph.getEdgeDetail(n.id);return!t(o)||!t(a)?!1:r(n,o,a)},e.cache==="auto"?(this.cacheEnabled=!0,this.startAutoCache()):e.cache==="manual"?this.cacheEnabled=!0:this.cacheEnabled=!1}startAutoCache(){this.refreshCache(),this.graph.on("changed",this.handleGraphChanged)}stopAutoCache(){this.graph.off("changed",this.handleGraphChanged)}checkNodeExistence(e){this.getNode(e)}hasNode(e){if(!this.graph.hasNode(e))return!1;const t=this.graph.getNode(e);return this.nodeFilter(t)}areNeighbors(e,t){return this.checkNodeExistence(e),this.getNeighbors(t).some(r=>r.id===e)}getNode(e){const t=this.graph.getNode(e);if(!this.nodeFilter(t))throw new Error("Node not found for id: "+e);return t}getRelatedEdges(e,t){return this.checkNodeExistence(e),this.cacheEnabled?t==="in"?this.inEdgesMap.get(e):t==="out"?this.outEdgesMap.get(e):this.bothEdgesMap.get(e):this.graph.getRelatedEdges(e,t).filter(this.edgeFilter)}getDegree(e,t){return this.getRelatedEdges(e,t).length}getSuccessors(e){const r=this.getRelatedEdges(e,"out").map(n=>this.getNode(n.target));return Array.from(new Set(r))}getPredecessors(e){const r=this.getRelatedEdges(e,"in").map(n=>this.getNode(n.source));return Array.from(new Set(r))}getNeighbors(e){const t=this.getPredecessors(e),r=this.getSuccessors(e);return Array.from(new Set([...t,...r]))}hasEdge(e){if(!this.graph.hasEdge(e))return!1;const t=this.graph.getEdge(e);return this.edgeFilter(t)}getEdge(e){const t=this.graph.getEdge(e);if(!this.edgeFilter(t))throw new Error("Edge not found for id: "+e);return t}getEdgeDetail(e){const t=this.getEdge(e);return{edge:t,source:this.getNode(t.source),target:this.getNode(t.target)}}hasTreeStructure(e){return this.graph.hasTreeStructure(e)}getRoots(e){return this.graph.getRoots(e).filter(this.nodeFilter)}getChildren(e,t){return this.checkNodeExistence(e),this.graph.getChildren(e,t).filter(this.nodeFilter)}getParent(e,t){this.checkNodeExistence(e);const r=this.graph.getParent(e,t);return!r||!this.nodeFilter(r)?null:r}getAllNodes(){return this.cacheEnabled?Array.from(this.allNodesMap.values()):this.graph.getAllNodes().filter(this.nodeFilter)}getAllEdges(){return this.cacheEnabled?Array.from(this.allEdgesMap.values()):this.graph.getAllEdges().filter(this.edgeFilter)}bfs(e,t,r="out"){const n={in:this.getPredecessors.bind(this),out:this.getSuccessors.bind(this),both:this.getNeighbors.bind(this)}[r];_e([this.getNode(e)],new Set,t,n)}dfs(e,t,r="out"){const n={in:this.getPredecessors.bind(this),out:this.getSuccessors.bind(this),both:this.getNeighbors.bind(this)}[r];te(this.getNode(e),new Set,t,n)}}class ft extends Tn{constructor(t){super();ot(this,"nodeMap",new Map);ot(this,"edgeMap",new Map);ot(this,"inEdgesMap",new Map);ot(this,"outEdgesMap",new Map);ot(this,"bothEdgesMap",new Map);ot(this,"treeIndices",new Map);ot(this,"changes",[]);ot(this,"batchCount",0);ot(this,"onChanged",()=>{});ot(this,"batch",t=>{this.batchCount+=1,t(),this.batchCount-=1,this.batchCount||this.commit()});t&&(t.nodes&&this.addNodes(t.nodes),t.edges&&this.addEdges(t.edges),t.tree&&this.addTree(t.tree),t.onChanged&&(this.onChanged=t.onChanged))}commit(){const t=this.changes;this.changes=[];const r={graph:this,changes:t};this.emit("changed",r),this.onChanged(r)}reduceChanges(t){let r=[];return t.forEach(n=>{switch(n.type){case"NodeRemoved":{let o=!1;r=r.filter(a=>{if(a.type==="NodeAdded"){const s=a.value.id===n.value.id;return s&&(o=!0),!s}else{if(a.type==="NodeDataUpdated")return a.id!==n.value.id;if(a.type==="TreeStructureChanged")return a.nodeId!==n.value.id}return!0}),o||r.push(n);break}case"EdgeRemoved":{let o=!1;r=r.filter(a=>{if(a.type==="EdgeAdded"){const s=a.value.id===n.value.id;return s&&(o=!0),!s}else if(a.type==="EdgeDataUpdated"||a.type==="EdgeUpdated")return a.id!==n.value.id;return!0}),o||r.push(n);break}case"NodeDataUpdated":case"EdgeDataUpdated":case"EdgeUpdated":{const o=r.findIndex(s=>s.type===n.type&&s.id===n.id&&(n.propertyName===void 0||s.propertyName===n.propertyName)),a=r[o];a?n.propertyName!==void 0?a.newValue=n.newValue:(r.splice(o,1),r.push(n)):r.push(n);break}case"TreeStructureDetached":{r=r.filter(o=>o.type==="TreeStructureAttached"||o.type==="TreeStructureChanged"?o.treeKey!==n.treeKey:!0),r.push(n);break}case"TreeStructureChanged":{const o=r.find(a=>a.type==="TreeStructureChanged"&&a.treeKey===n.treeKey&&a.nodeId===n.nodeId);o?o.newParentId=n.newParentId:r.push(n);break}default:r.push(n);break}}),r}checkNodeExistence(t){this.getNode(t)}hasNode(t){return this.nodeMap.has(t)}areNeighbors(t,r){return this.getNeighbors(r).some(n=>n.id===t)}getNode(t){const r=this.nodeMap.get(t);if(!r)throw new Error("Node not found for id: "+t);return r}getRelatedEdges(t,r){if(this.checkNodeExistence(t),r==="in"){const n=this.inEdgesMap.get(t);return Array.from(n)}else if(r==="out"){const n=this.outEdgesMap.get(t);return Array.from(n)}else{const n=this.bothEdgesMap.get(t);return Array.from(n)}}getDegree(t,r){return this.getRelatedEdges(t,r).length}getSuccessors(t){const n=this.getRelatedEdges(t,"out").map(o=>this.getNode(o.target));return Array.from(new Set(n))}getPredecessors(t){const n=this.getRelatedEdges(t,"in").map(o=>this.getNode(o.source));return Array.from(new Set(n))}getNeighbors(t){const r=this.getPredecessors(t),n=this.getSuccessors(t);return Array.from(new Set([...r,...n]))}doAddNode(t){if(this.hasNode(t.id))throw new Error("Node already exists: "+t.id);this.nodeMap.set(t.id,t),this.inEdgesMap.set(t.id,new Set),this.outEdgesMap.set(t.id,new Set),this.bothEdgesMap.set(t.id,new Set),this.treeIndices.forEach(r=>{r.childrenMap.set(t.id,new Set)}),this.changes.push({type:"NodeAdded",value:t})}addNodes(t){this.batch(()=>{for(const r of t)this.doAddNode(r)})}addNode(t){this.addNodes([t])}doRemoveNode(t){const r=this.getNode(t),n=this.bothEdgesMap.get(t);n==null||n.forEach(o=>this.doRemoveEdge(o.id)),this.nodeMap.delete(t),this.treeIndices.forEach(o=>{var a;(a=o.childrenMap.get(t))==null||a.forEach(s=>{o.parentMap.delete(s.id)}),o.parentMap.delete(t),o.childrenMap.delete(t)}),this.changes.push({type:"NodeRemoved",value:r})}removeNodes(t){this.batch(()=>{t.forEach(r=>this.doRemoveNode(r))})}removeNode(t){this.removeNodes([t])}updateNodeDataProperty(t,r,n){const o=this.getNode(t);this.batch(()=>{const a=o.data[r],s=n;o.data[r]=s,this.changes.push({type:"NodeDataUpdated",id:t,propertyName:r,oldValue:a,newValue:s})})}mergeNodeData(t,r){this.batch(()=>{Object.entries(r).forEach(([n,o])=>{this.updateNodeDataProperty(t,n,o)})})}updateNodeData(...t){const r=t[0],n=this.getNode(r);if(typeof t[1]=="string"){this.updateNodeDataProperty(r,t[1],t[2]);return}let o;if(typeof t[1]=="function"){const a=t[1];o=a(n.data)}else typeof t[1]=="object"&&(o=t[1]);this.batch(()=>{const a=n.data,s=o;n.data=o,this.changes.push({type:"NodeDataUpdated",id:r,oldValue:a,newValue:s})})}checkEdgeExistence(t){if(!this.hasEdge(t))throw new Error("Edge not found for id: "+t)}hasEdge(t){return this.edgeMap.has(t)}getEdge(t){return this.checkEdgeExistence(t),this.edgeMap.get(t)}getEdgeDetail(t){const r=this.getEdge(t);return{edge:r,source:this.getNode(r.source),target:this.getNode(r.target)}}doAddEdge(t){if(this.hasEdge(t.id))throw new Error("Edge already exists: "+t.id);this.checkNodeExistence(t.source),this.checkNodeExistence(t.target),this.edgeMap.set(t.id,t);const r=this.inEdgesMap.get(t.target),n=this.outEdgesMap.get(t.source),o=this.bothEdgesMap.get(t.source),a=this.bothEdgesMap.get(t.target);r.add(t),n.add(t),o.add(t),a.add(t),this.changes.push({type:"EdgeAdded",value:t})}addEdges(t){this.batch(()=>{for(const r of t)this.doAddEdge(r)})}addEdge(t){this.addEdges([t])}doRemoveEdge(t){const r=this.getEdge(t),n=this.outEdgesMap.get(r.source),o=this.inEdgesMap.get(r.target),a=this.bothEdgesMap.get(r.source),s=this.bothEdgesMap.get(r.target);n.delete(r),o.delete(r),a.delete(r),s.delete(r),this.edgeMap.delete(t),this.changes.push({type:"EdgeRemoved",value:r})}removeEdges(t){this.batch(()=>{t.forEach(r=>this.doRemoveEdge(r))})}removeEdge(t){this.removeEdges([t])}updateEdgeSource(t,r){const n=this.getEdge(t);this.checkNodeExistence(r);const o=n.source,a=r;this.outEdgesMap.get(o).delete(n),this.bothEdgesMap.get(o).delete(n),this.outEdgesMap.get(a).add(n),this.bothEdgesMap.get(a).add(n),n.source=r,this.batch(()=>{this.changes.push({type:"EdgeUpdated",id:t,propertyName:"source",oldValue:o,newValue:a})})}updateEdgeTarget(t,r){const n=this.getEdge(t);this.checkNodeExistence(r);const o=n.target,a=r;this.inEdgesMap.get(o).delete(n),this.bothEdgesMap.get(o).delete(n),this.inEdgesMap.get(a).add(n),this.bothEdgesMap.get(a).add(n),n.target=r,this.batch(()=>{this.changes.push({type:"EdgeUpdated",id:t,propertyName:"target",oldValue:o,newValue:a})})}updateEdgeDataProperty(t,r,n){const o=this.getEdge(t);this.batch(()=>{const a=o.data[r],s=n;o.data[r]=s,this.changes.push({type:"EdgeDataUpdated",id:t,propertyName:r,oldValue:a,newValue:s})})}updateEdgeData(...t){const r=t[0],n=this.getEdge(r);if(typeof t[1]=="string"){this.updateEdgeDataProperty(r,t[1],t[2]);return}let o;if(typeof t[1]=="function"){const a=t[1];o=a(n.data)}else typeof t[1]=="object"&&(o=t[1]);this.batch(()=>{const a=n.data,s=o;n.data=o,this.changes.push({type:"EdgeDataUpdated",id:r,oldValue:a,newValue:s})})}mergeEdgeData(t,r){this.batch(()=>{Object.entries(r).forEach(([n,o])=>{this.updateEdgeDataProperty(t,n,o)})})}checkTreeExistence(t){if(!this.hasTreeStructure(t))throw new Error("Tree structure not found for treeKey: "+t)}hasTreeStructure(t){return this.treeIndices.has(t)}attachTreeStructure(t){this.treeIndices.has(t)||(this.treeIndices.set(t,{parentMap:new Map,childrenMap:new Map}),this.batch(()=>{this.changes.push({type:"TreeStructureAttached",treeKey:t})}))}detachTreeStructure(t){this.checkTreeExistence(t),this.treeIndices.delete(t),this.batch(()=>{this.changes.push({type:"TreeStructureDetached",treeKey:t})})}addTree(t,r){this.batch(()=>{this.attachTreeStructure(r);const n=[],o=Array.isArray(t)?t:[t];for(;o.length;){const a=o.shift();n.push(a),a.children&&o.push(...a.children)}this.addNodes(n),n.forEach(a=>{var s;(s=a.children)==null||s.forEach(f=>{this.setParent(f.id,a.id,r)})})})}getRoots(t){return this.checkTreeExistence(t),this.getAllNodes().filter(r=>!this.getParent(r.id,t))}getChildren(t,r){this.checkNodeExistence(t),this.checkTreeExistence(r);const o=this.treeIndices.get(r).childrenMap.get(t);return Array.from(o||[])}getParent(t,r){return this.checkNodeExistence(t),this.checkTreeExistence(r),this.treeIndices.get(r).parentMap.get(t)||null}getAncestors(t,r){const n=[];let o=this.getNode(t),a;for(;a=this.getParent(o.id,r);)n.push(a),o=a;return n}setParent(t,r,n){var l,h;this.checkTreeExistence(n);const o=this.treeIndices.get(n),a=this.getNode(t),s=o.parentMap.get(t);if((s==null?void 0:s.id)===r)return;if(r===void 0){s&&((l=o.childrenMap.get(s.id))==null||l.delete(a)),o.parentMap.delete(t);return}const f=this.getNode(r);o.parentMap.set(t,f),s&&((h=o.childrenMap.get(s.id))==null||h.delete(a));let u=o.childrenMap.get(f.id);u||(u=new Set,o.childrenMap.set(f.id,u)),u.add(a),this.batch(()=>{this.changes.push({type:"TreeStructureChanged",treeKey:n,nodeId:t,oldParentId:s==null?void 0:s.id,newParentId:f.id})})}dfsTree(t,r,n){const o=a=>this.getChildren(a,n);return te(this.getNode(t),new Set,r,o)}bfsTree(t,r,n){const o=a=>this.getChildren(a,n);return _e([this.getNode(t)],new Set,r,o)}getAllNodes(){return Array.from(this.nodeMap.values())}getAllEdges(){return Array.from(this.edgeMap.values())}bfs(t,r,n="out"){const o={in:this.getPredecessors.bind(this),out:this.getSuccessors.bind(this),both:this.getNeighbors.bind(this)}[n];return _e([this.getNode(t)],new Set,r,o)}dfs(t,r,n="out"){const o={in:this.getPredecessors.bind(this),out:this.getSuccessors.bind(this),both:this.getNeighbors.bind(this)}[n];return te(this.getNode(t),new Set,r,o)}clone(){const t=this.getAllNodes().map(o=>({...o,data:{...o.data}})),r=this.getAllEdges().map(o=>({...o,data:{...o.data}})),n=new ft({nodes:t,edges:r});return this.treeIndices.forEach(({parentMap:o,childrenMap:a},s)=>{const f=new Map;o.forEach((l,h)=>{f.set(h,n.getNode(l.id))});const u=new Map;a.forEach((l,h)=>{u.set(h,new Set(Array.from(l).map(d=>n.getNode(d.id))))}),n.treeIndices.set(s,{parentMap:f,childrenMap:u})}),n}toJSON(){return JSON.stringify({nodes:this.getAllNodes(),edges:this.getAllEdges()})}createView(t){return new Ln({graph:this,...t})}}/**
2
- * @license
3
- * Copyright 2019 Google LLC
4
- * SPDX-License-Identifier: Apache-2.0
5
- */const or=Symbol("Comlink.proxy"),Dn=Symbol("Comlink.endpoint"),Pn=Symbol("Comlink.releaseProxy"),ze=Symbol("Comlink.finalizer"),ee=Symbol("Comlink.thrown"),ar=i=>typeof i=="object"&&i!==null||typeof i=="function",jn={canHandle:i=>ar(i)&&i[or],serialize(i){const{port1:e,port2:t}=new MessageChannel;return Ae(i,e),[t,[t]]},deserialize(i){return i.start(),$n(i)}},Fn={canHandle:i=>ar(i)&&ee in i,serialize({value:i}){let e;return i instanceof Error?e={isError:!0,value:{message:i.message,name:i.name,stack:i.stack}}:e={isError:!1,value:i},[e,[]]},deserialize(i){throw i.isError?Object.assign(new Error(i.value.message),i.value):i.value}},sr=new Map([["proxy",jn],["throw",Fn]]);function Cn(i,e){for(const t of i)if(e===t||t==="*"||t instanceof RegExp&&t.test(e))return!0;return!1}function Ae(i,e=globalThis,t=["*"]){e.addEventListener("message",function r(n){if(!n||!n.data)return;if(!Cn(t,n.origin)){console.warn(`Invalid origin '${n.origin}' for comlink proxy`);return}const{id:o,type:a,path:s}=Object.assign({path:[]},n.data),f=(n.data.argumentList||[]).map(Tt);let u;try{const l=s.slice(0,-1).reduce((d,g)=>d[g],i),h=s.reduce((d,g)=>d[g],i);switch(a){case"GET":u=h;break;case"SET":l[s.slice(-1)[0]]=Tt(n.data.value),u=!0;break;case"APPLY":u=h.apply(l,f);break;case"CONSTRUCT":{const d=new h(...f);u=Yn(d)}break;case"ENDPOINT":{const{port1:d,port2:g}=new MessageChannel;Ae(i,g),u=Wn(d,[d])}break;case"RELEASE":u=void 0;break;default:return}}catch(l){u={value:l,[ee]:0}}Promise.resolve(u).catch(l=>({value:l,[ee]:0})).then(l=>{const[h,d]=oe(l);e.postMessage(Object.assign(Object.assign({},h),{id:o}),d),a==="RELEASE"&&(e.removeEventListener("message",r),ur(e),ze in i&&typeof i[ze]=="function"&&i[ze]())}).catch(l=>{const[h,d]=oe({value:new TypeError("Unserializable return value"),[ee]:0});e.postMessage(Object.assign(Object.assign({},h),{id:o}),d)})}),e.start&&e.start()}function qn(i){return i.constructor.name==="MessagePort"}function ur(i){qn(i)&&i.close()}function $n(i,e){return Re(i,[],e)}function re(i){if(i)throw new Error("Proxy has been released and is not useable")}function fr(i){return jt(i,{type:"RELEASE"}).then(()=>{ur(i)})}const ne=new WeakMap,ie="FinalizationRegistry"in globalThis&&new FinalizationRegistry(i=>{const e=(ne.get(i)||0)-1;ne.set(i,e),e===0&&fr(i)});function Bn(i,e){const t=(ne.get(e)||0)+1;ne.set(e,t),ie&&ie.register(i,e,i)}function Vn(i){ie&&ie.unregister(i)}function Re(i,e=[],t=function(){}){let r=!1;const n=new Proxy(t,{get(o,a){if(re(r),a===Pn)return()=>{Vn(n),fr(i),r=!0};if(a==="then"){if(e.length===0)return{then:()=>n};const s=jt(i,{type:"GET",path:e.map(f=>f.toString())}).then(Tt);return s.then.bind(s)}return Re(i,[...e,a])},set(o,a,s){re(r);const[f,u]=oe(s);return jt(i,{type:"SET",path:[...e,a].map(l=>l.toString()),value:f},u).then(Tt)},apply(o,a,s){re(r);const f=e[e.length-1];if(f===Dn)return jt(i,{type:"ENDPOINT"}).then(Tt);if(f==="bind")return Re(i,e.slice(0,-1));const[u,l]=lr(s);return jt(i,{type:"APPLY",path:e.map(h=>h.toString()),argumentList:u},l).then(Tt)},construct(o,a){re(r);const[s,f]=lr(a);return jt(i,{type:"CONSTRUCT",path:e.map(u=>u.toString()),argumentList:s},f).then(Tt)}});return Bn(n,i),n}function Un(i){return Array.prototype.concat.apply([],i)}function lr(i){const e=i.map(oe);return[e.map(t=>t[0]),Un(e.map(t=>t[1]))]}const hr=new WeakMap;function Wn(i,e){return hr.set(i,e),i}function Yn(i){return Object.assign(i,{[or]:!0})}function oe(i){for(const[e,t]of sr)if(t.canHandle(i)){const[r,n]=t.serialize(i);return[{type:"HANDLER",name:e,value:r},n]}return[{type:"RAW",value:i},hr.get(i)||[]]}function Tt(i){switch(i.type){case"HANDLER":return sr.get(i.name).deserialize(i.value);case"RAW":return i.value}}function jt(i,e,t){return new Promise(r=>{const n=Gn();i.addEventListener("message",function o(a){!a.data||!a.data.id||a.data.id!==n||(i.removeEventListener("message",o),r(a.data))}),i.start&&i.start(),i.postMessage(Object.assign({id:n},e),t)})}function Gn(){return new Array(4).fill(0).map(()=>Math.floor(Math.random()*Number.MAX_SAFE_INTEGER).toString(16)).join("-")}var lt=Array.isArray,yt=function(i){return typeof i=="function"},Xn=function(i){return i==null},Qn={}.toString,Oe=function(i,e){return Qn.call(i)==="[object "+e+"]"},Jn=function(i){return Array.isArray?Array.isArray(i):Oe(i,"Array")},_t=function(i){var e=typeof i;return i!==null&&e==="object"||e==="function"},Yt=function(i){return Oe(i,"String")},Q=function(i){return Oe(i,"Number")},ae=function(i){if(typeof i!="object"||i===null)return i;var e;if(Jn(i)){e=[];for(var t=0,r=i.length;t<r;t++)typeof i[t]=="object"&&i[t]!=null?e[t]=ae(i[t]):e[t]=i[t]}else{e={};for(var n in i)typeof i[n]=="object"&&i[n]!=null?e[n]=ae(i[n]):e[n]=i[n]}return e},dr=function(i){for(var e=[],t=i.length,r=0;r<t;r+=1){e[r]=[];for(var n=0;n<t;n+=1)r===n?e[r][n]=0:i[r][n]===0||!i[r][n]?e[r][n]=1/0:e[r][n]=i[r][n]}for(var o=0;o<t;o+=1)for(var r=0;r<t;r+=1)for(var n=0;n<t;n+=1)e[r][n]>e[r][o]+e[o][n]&&(e[r][n]=e[r][o]+e[o][n]);return e},cr=function(i,e){var t=i.nodes,r=i.edges,n=[],o={};if(!t)throw new Error("invalid nodes data!");return t&&t.forEach(function(a,s){o[a.id]=s;var f=[];n.push(f)}),r==null||r.forEach(function(a){var s=a.source,f=a.target,u=o[s],l=o[f];u===void 0||l===void 0||(n[u][l]=1,e||(n[l][u]=1))}),n},Zn=function(i,e){var t=[];return i.forEach(function(r){var n=[];r.forEach(function(o){n.push(o*e)}),t.push(n)}),t},Kn=function(i){var e=1/0,t=1/0,r=-1/0,n=-1/0;return i.forEach(function(o){var a=o.data.size;lt(a)?a.length===1&&(a=[a[0],a[0]]):Q(a)?a=[a,a]:(a===void 0||isNaN(a))&&(a=[30,30]);var s=[a[0]/2,a[1]/2],f=o.data.x-s[0],u=o.data.x+s[0],l=o.data.y-s[1],h=o.data.y+s[1];e>f&&(e=f),t>l&&(t=l),r<u&&(r=u),n<h&&(n=h)}),{minX:e,minY:t,maxX:r,maxY:n}},gr=function(i,e){return Math.sqrt((i.x-e.x)*(i.x-e.x)+(i.y-e.y)*(i.y-e.y))},Ie=function(i,e,t,r,n,o){if(r===void 0&&(r="TB"),o===void 0&&(o={}),!!(e!=null&&e.length))for(var a=o.stopBranchFn,s=o.stopAllFn,f=0;f<e.length;f++){var u=e[f];if(i.hasNode(u.id)&&!(a!=null&&a(u))){if(s!=null&&s(u))return;r==="TB"&&t(u),Ie(i,i.getChildren(u.id,n),t,r,n,o),r!=="TB"&&t(u)}}},Te=function(i){if(i===null)return i;if(i instanceof Date)return new Date(i.getTime());if(i instanceof Array){var e=[];return i.forEach(function(r){e.push(r)}),e.map(function(r){return Te(r)})}if(typeof i=="object"){var t={};return Object.keys(i).forEach(function(r){t[r]=Te(i[r])}),t}return i},ct=function(i,e){var t=Te(i);return t.data=t.data||{},e&&(Q(t.data.x)||(t.data.x=Math.random()*e[0]),Q(t.data.y)||(t.data.y=Math.random()*e[1])),t};function zt(i,e){var t;return yt(e)?t=e:Q(e)?t=function(){return e}:t=function(){return i},t}function vr(i,e,t){return t===void 0&&(t=!0),!e&&e!==0?function(r){var n=(r.data||{}).size;return n?Array.isArray(n)?n[0]>n[1]?n[0]:n[1]:_t(n)?n.width>n.height?n.width:n.height:n:i}:yt(e)?e:Q(e)?function(){return e}:Array.isArray(e)?function(){if(t){var r=Math.max.apply(Math,ut([],st(e)));return isNaN(r)?i:r}return e}:_t(e)?function(){if(t){var r=Math.max(e.width,e.height);return isNaN(r)?i:r}return[e.width,e.height]}:function(){return i}}var pr=function(i,e){var t,r;return Q(e)?r=function(){return e}:yt(e)?r=e:r=function(){return 0},i?Array.isArray(i)?t=function(n){var o=i[0]>i[1]?i[0]:i[1];return o+r(n)}:yt(i)?t=i:t=function(n){return i+r(n)}:t=function(n){var o,a;if(!((o=n.data)===null||o===void 0)&&o.bboxSize)return Math.max(n.data.bboxSize[0],n.data.bboxSize[1])+r(n);if(!((a=n.data)===null||a===void 0)&&a.size){if(Array.isArray(n.data.size))return Math.max(n.data.size[0],n.data.size[1])+r(n);var s=n.data.size;if(_t(s)){var f=s.width>s.height?s.width:s.height;return f+r(n)}return s+r(n)}return 10+r(n)},t},Lt=function(i,e,t){var r=i.getAllNodes(),n=i.getAllEdges();if(!(r!=null&&r.length)){var o={nodes:[],edges:n};return o}if(r.length===1){e&&i.mergeNodeData(r[0].id,{x:t[0],y:t[1]});var o={nodes:[R(R({},r[0]),{data:R(R({},r[0].data),{x:t[0],y:t[1]})})],edges:n};return o}},Hn={radius:null,startRadius:null,endRadius:null,startAngle:0,endAngle:2*Math.PI,clockwise:!0,divisions:1,ordering:null,angleRatio:1},ti=function(){function i(e){e===void 0&&(e={}),this.options=e,this.id="circular",this.options=R(R({},Hn),e)}return i.prototype.execute=function(e,t){return K(this,void 0,void 0,function(){return H(this,function(r){return[2,this.genericCircularLayout(!1,e,t)]})})},i.prototype.assign=function(e,t){return K(this,void 0,void 0,function(){return H(this,function(r){switch(r.label){case 0:return[4,this.genericCircularLayout(!0,e,t)];case 1:return r.sent(),[2]}})})},i.prototype.genericCircularLayout=function(e,t,r){return K(this,void 0,void 0,function(){var n,o,a,s,f,u,l,h,d,g,v,p,w,c,m,E,x,N,z,k,b,A,y,S,_,M,T,L,D,$,C,G,V,X,W,P;return H(this,function(I){if(n=R(R({},this.options),r),o=n.width,a=n.height,s=n.center,f=n.divisions,u=n.startAngle,l=u===void 0?0:u,h=n.endAngle,d=h===void 0?2*Math.PI:h,g=n.angleRatio,v=n.ordering,p=n.clockwise,w=n.nodeSpacing,c=n.nodeSize,m=t.getAllNodes(),E=t.getAllEdges(),x=st(ri(o,a,s),3),N=x[0],z=x[1],k=x[2],b=m==null?void 0:m.length,!b||b===1)return[2,Lt(t,e,k)];for(A=(d-l)/b,y=n.radius,S=n.startRadius,_=n.endRadius,w?(M=zt(10,w),T=vr(10,c),L=-1/0,m.forEach(function(U){var q=T(U);L<q&&(L=q)}),D=0,m.forEach(function(U,q){q===0?D+=L||10:D+=(M(U)||0)+(L||10)}),y=D/(2*Math.PI)):!y&&!S&&!_?y=Math.min(z,N)/2:!S&&_?S=_:S&&!_&&(_=S),$=A*g,C=[],v==="topology"?C=wr(t,m):v==="topology-directed"?C=wr(t,m,!0):v==="degree"?C=ei(t,m):C=m.map(function(U){return ct(U)}),G=Math.ceil(b/f),V=0;V<b;++V)X=y,!X&&S!==null&&_!==null&&(X=S+V*(_-S)/(b-1)),X||(X=10+V*100/(b-1)),W=l+V%G*$+2*Math.PI/f*Math.floor(V/G),p||(W=d-V%G*$-2*Math.PI/f*Math.floor(V/G)),C[V].data.x=k[0]+Math.cos(W)*X,C[V].data.y=k[1]+Math.sin(W)*X;return e&&C.forEach(function(U){t.mergeNodeData(U.id,{x:U.data.x,y:U.data.y})}),P={nodes:C,edges:E},[2,P]})})},i}(),wr=function(i,e,t){t===void 0&&(t=!1);var r=[ct(e[0])],n={},o=e.length;n[e[0].id]=!0;var a=0;return e.forEach(function(s,f){if(f!==0)if((f===o-1||i.getDegree(s.id,"both")!==i.getDegree(e[f+1].id,"both")||i.areNeighbors(r[a].id,s.id))&&!n[s.id])r.push(ct(s)),n[s.id]=!0,a++;else{for(var u=t?i.getSuccessors(r[a].id):i.getNeighbors(r[a].id),l=!1,h=0;h<u.length;h++){var d=u[h];if(i.getDegree(d.id)===i.getDegree(s.id)&&!n[d.id]){r.push(ct(d)),n[d.id]=!0,l=!0;break}}for(var g=0;!l&&(n[e[g].id]||(r.push(ct(e[g])),n[e[g].id]=!0,l=!0),g++,g!==o););}}),r};function ei(i,e){var t=[];return e.forEach(function(r,n){t.push(ct(r))}),t.sort(function(r,n){return i.getDegree(r.id,"both")-i.getDegree(n.id,"both")}),t}var ri=function(i,e,t){var r=i,n=e,o=t;return!r&&typeof window<"u"&&(r=window.innerWidth),!n&&typeof window<"u"&&(n=window.innerHeight),o||(o=[r/2,n/2]),[r,n,o]};function mr(i){if(i.__esModule)return i;var e=i.default;if(typeof e=="function"){var t=function r(){return this instanceof r?Reflect.construct(e,arguments,this.constructor):e.apply(this,arguments)};t.prototype=e.prototype}else t={};return Object.defineProperty(t,"__esModule",{value:!0}),Object.keys(i).forEach(function(r){var n=Object.getOwnPropertyDescriptor(i,r);Object.defineProperty(t,r,n.get?n:{enumerable:!0,get:function(){return i[r]}})}),t}var tt={};const ni=Object.prototype.toString;function Gt(i){const e=ni.call(i);return e.endsWith("Array]")&&!e.includes("Big")}var ii=Object.freeze({__proto__:null,isAnyArray:Gt}),oi=mr(ii);function ai(i){var e=arguments.length>1&&arguments[1]!==void 0?arguments[1]:{};if(!Gt(i))throw new TypeError("input must be an array");if(i.length===0)throw new TypeError("input must not be empty");var t=e.fromIndex,r=t===void 0?0:t,n=e.toIndex,o=n===void 0?i.length:n;if(r<0||r>=i.length||!Number.isInteger(r))throw new Error("fromIndex must be a positive integer smaller than length");if(o<=r||o>i.length||!Number.isInteger(o))throw new Error("toIndex must be an integer greater than fromIndex and at most equal to length");for(var a=i[r],s=r+1;s<o;s++)i[s]>a&&(a=i[s]);return a}function si(i){var e=arguments.length>1&&arguments[1]!==void 0?arguments[1]:{};if(!Gt(i))throw new TypeError("input must be an array");if(i.length===0)throw new TypeError("input must not be empty");var t=e.fromIndex,r=t===void 0?0:t,n=e.toIndex,o=n===void 0?i.length:n;if(r<0||r>=i.length||!Number.isInteger(r))throw new Error("fromIndex must be a positive integer smaller than length");if(o<=r||o>i.length||!Number.isInteger(o))throw new Error("toIndex must be an integer greater than fromIndex and at most equal to length");for(var a=i[r],s=r+1;s<o;s++)i[s]<a&&(a=i[s]);return a}function ui(i){var e=arguments.length>1&&arguments[1]!==void 0?arguments[1]:{};if(Gt(i)){if(i.length===0)throw new TypeError("input must not be empty")}else throw new TypeError("input must be an array");var t;if(e.output!==void 0){if(!Gt(e.output))throw new TypeError("output option must be an array if specified");t=e.output}else t=new Array(i.length);var r=si(i),n=ai(i);if(r===n)throw new RangeError("minimum and maximum input values are equal. Cannot rescale a constant array");var o=e.min,a=o===void 0?e.autoMinMax?r:0:o,s=e.max,f=s===void 0?e.autoMinMax?n:1:s;if(a>=f)throw new RangeError("min option must be smaller than max option");for(var u=(f-a)/(n-r),l=0;l<i.length;l++)t[l]=(i[l]-r)*u+a;return t}var fi=Object.freeze({__proto__:null,default:ui}),li=mr(fi);Object.defineProperty(tt,"__esModule",{value:!0});var wt=oi,yr=li;const se=" ".repeat(2),Er=" ".repeat(4);function hi(){return xr(this)}function xr(i,e={}){const{maxRows:t=15,maxColumns:r=10,maxNumSize:n=8,padMinus:o="auto"}=e;return`${i.constructor.name} {
6
- ${se}[
7
- ${Er}${di(i,t,r,n,o)}
8
- ${se}]
9
- ${se}rows: ${i.rows}
10
- ${se}columns: ${i.columns}
11
- }`}function di(i,e,t,r,n){const{rows:o,columns:a}=i,s=Math.min(o,e),f=Math.min(a,t),u=[];if(n==="auto"){n=!1;t:for(let l=0;l<s;l++)for(let h=0;h<f;h++)if(i.get(l,h)<0){n=!0;break t}}for(let l=0;l<s;l++){let h=[];for(let d=0;d<f;d++)h.push(ci(i.get(l,d),r,n));u.push(`${h.join(" ")}`)}return f!==a&&(u[u.length-1]+=` ... ${a-t} more columns`),s!==o&&u.push(`... ${o-e} more rows`),u.join(`
12
- ${Er}`)}function ci(i,e,t){return(i>=0&&t?` ${Nr(i,e-1)}`:Nr(i,e)).padEnd(e)}function Nr(i,e){let t=i.toString();if(t.length<=e)return t;let r=i.toFixed(e);if(r.length>e&&(r=i.toFixed(Math.max(0,e-(r.length-e)))),r.length<=e&&!r.startsWith("0.000")&&!r.startsWith("-0.000"))return r;let n=i.toExponential(e);return n.length>e&&(n=i.toExponential(Math.max(0,e-(n.length-e)))),n.slice(0)}function gi(i,e){i.prototype.add=function(r){return typeof r=="number"?this.addS(r):this.addM(r)},i.prototype.addS=function(r){for(let n=0;n<this.rows;n++)for(let o=0;o<this.columns;o++)this.set(n,o,this.get(n,o)+r);return this},i.prototype.addM=function(r){if(r=e.checkMatrix(r),this.rows!==r.rows||this.columns!==r.columns)throw new RangeError("Matrices dimensions must be equal");for(let n=0;n<this.rows;n++)for(let o=0;o<this.columns;o++)this.set(n,o,this.get(n,o)+r.get(n,o));return this},i.add=function(r,n){return new e(r).add(n)},i.prototype.sub=function(r){return typeof r=="number"?this.subS(r):this.subM(r)},i.prototype.subS=function(r){for(let n=0;n<this.rows;n++)for(let o=0;o<this.columns;o++)this.set(n,o,this.get(n,o)-r);return this},i.prototype.subM=function(r){if(r=e.checkMatrix(r),this.rows!==r.rows||this.columns!==r.columns)throw new RangeError("Matrices dimensions must be equal");for(let n=0;n<this.rows;n++)for(let o=0;o<this.columns;o++)this.set(n,o,this.get(n,o)-r.get(n,o));return this},i.sub=function(r,n){return new e(r).sub(n)},i.prototype.subtract=i.prototype.sub,i.prototype.subtractS=i.prototype.subS,i.prototype.subtractM=i.prototype.subM,i.subtract=i.sub,i.prototype.mul=function(r){return typeof r=="number"?this.mulS(r):this.mulM(r)},i.prototype.mulS=function(r){for(let n=0;n<this.rows;n++)for(let o=0;o<this.columns;o++)this.set(n,o,this.get(n,o)*r);return this},i.prototype.mulM=function(r){if(r=e.checkMatrix(r),this.rows!==r.rows||this.columns!==r.columns)throw new RangeError("Matrices dimensions must be equal");for(let n=0;n<this.rows;n++)for(let o=0;o<this.columns;o++)this.set(n,o,this.get(n,o)*r.get(n,o));return this},i.mul=function(r,n){return new e(r).mul(n)},i.prototype.multiply=i.prototype.mul,i.prototype.multiplyS=i.prototype.mulS,i.prototype.multiplyM=i.prototype.mulM,i.multiply=i.mul,i.prototype.div=function(r){return typeof r=="number"?this.divS(r):this.divM(r)},i.prototype.divS=function(r){for(let n=0;n<this.rows;n++)for(let o=0;o<this.columns;o++)this.set(n,o,this.get(n,o)/r);return this},i.prototype.divM=function(r){if(r=e.checkMatrix(r),this.rows!==r.rows||this.columns!==r.columns)throw new RangeError("Matrices dimensions must be equal");for(let n=0;n<this.rows;n++)for(let o=0;o<this.columns;o++)this.set(n,o,this.get(n,o)/r.get(n,o));return this},i.div=function(r,n){return new e(r).div(n)},i.prototype.divide=i.prototype.div,i.prototype.divideS=i.prototype.divS,i.prototype.divideM=i.prototype.divM,i.divide=i.div,i.prototype.mod=function(r){return typeof r=="number"?this.modS(r):this.modM(r)},i.prototype.modS=function(r){for(let n=0;n<this.rows;n++)for(let o=0;o<this.columns;o++)this.set(n,o,this.get(n,o)%r);return this},i.prototype.modM=function(r){if(r=e.checkMatrix(r),this.rows!==r.rows||this.columns!==r.columns)throw new RangeError("Matrices dimensions must be equal");for(let n=0;n<this.rows;n++)for(let o=0;o<this.columns;o++)this.set(n,o,this.get(n,o)%r.get(n,o));return this},i.mod=function(r,n){return new e(r).mod(n)},i.prototype.modulus=i.prototype.mod,i.prototype.modulusS=i.prototype.modS,i.prototype.modulusM=i.prototype.modM,i.modulus=i.mod,i.prototype.and=function(r){return typeof r=="number"?this.andS(r):this.andM(r)},i.prototype.andS=function(r){for(let n=0;n<this.rows;n++)for(let o=0;o<this.columns;o++)this.set(n,o,this.get(n,o)&r);return this},i.prototype.andM=function(r){if(r=e.checkMatrix(r),this.rows!==r.rows||this.columns!==r.columns)throw new RangeError("Matrices dimensions must be equal");for(let n=0;n<this.rows;n++)for(let o=0;o<this.columns;o++)this.set(n,o,this.get(n,o)&r.get(n,o));return this},i.and=function(r,n){return new e(r).and(n)},i.prototype.or=function(r){return typeof r=="number"?this.orS(r):this.orM(r)},i.prototype.orS=function(r){for(let n=0;n<this.rows;n++)for(let o=0;o<this.columns;o++)this.set(n,o,this.get(n,o)|r);return this},i.prototype.orM=function(r){if(r=e.checkMatrix(r),this.rows!==r.rows||this.columns!==r.columns)throw new RangeError("Matrices dimensions must be equal");for(let n=0;n<this.rows;n++)for(let o=0;o<this.columns;o++)this.set(n,o,this.get(n,o)|r.get(n,o));return this},i.or=function(r,n){return new e(r).or(n)},i.prototype.xor=function(r){return typeof r=="number"?this.xorS(r):this.xorM(r)},i.prototype.xorS=function(r){for(let n=0;n<this.rows;n++)for(let o=0;o<this.columns;o++)this.set(n,o,this.get(n,o)^r);return this},i.prototype.xorM=function(r){if(r=e.checkMatrix(r),this.rows!==r.rows||this.columns!==r.columns)throw new RangeError("Matrices dimensions must be equal");for(let n=0;n<this.rows;n++)for(let o=0;o<this.columns;o++)this.set(n,o,this.get(n,o)^r.get(n,o));return this},i.xor=function(r,n){return new e(r).xor(n)},i.prototype.leftShift=function(r){return typeof r=="number"?this.leftShiftS(r):this.leftShiftM(r)},i.prototype.leftShiftS=function(r){for(let n=0;n<this.rows;n++)for(let o=0;o<this.columns;o++)this.set(n,o,this.get(n,o)<<r);return this},i.prototype.leftShiftM=function(r){if(r=e.checkMatrix(r),this.rows!==r.rows||this.columns!==r.columns)throw new RangeError("Matrices dimensions must be equal");for(let n=0;n<this.rows;n++)for(let o=0;o<this.columns;o++)this.set(n,o,this.get(n,o)<<r.get(n,o));return this},i.leftShift=function(r,n){return new e(r).leftShift(n)},i.prototype.signPropagatingRightShift=function(r){return typeof r=="number"?this.signPropagatingRightShiftS(r):this.signPropagatingRightShiftM(r)},i.prototype.signPropagatingRightShiftS=function(r){for(let n=0;n<this.rows;n++)for(let o=0;o<this.columns;o++)this.set(n,o,this.get(n,o)>>r);return this},i.prototype.signPropagatingRightShiftM=function(r){if(r=e.checkMatrix(r),this.rows!==r.rows||this.columns!==r.columns)throw new RangeError("Matrices dimensions must be equal");for(let n=0;n<this.rows;n++)for(let o=0;o<this.columns;o++)this.set(n,o,this.get(n,o)>>r.get(n,o));return this},i.signPropagatingRightShift=function(r,n){return new e(r).signPropagatingRightShift(n)},i.prototype.rightShift=function(r){return typeof r=="number"?this.rightShiftS(r):this.rightShiftM(r)},i.prototype.rightShiftS=function(r){for(let n=0;n<this.rows;n++)for(let o=0;o<this.columns;o++)this.set(n,o,this.get(n,o)>>>r);return this},i.prototype.rightShiftM=function(r){if(r=e.checkMatrix(r),this.rows!==r.rows||this.columns!==r.columns)throw new RangeError("Matrices dimensions must be equal");for(let n=0;n<this.rows;n++)for(let o=0;o<this.columns;o++)this.set(n,o,this.get(n,o)>>>r.get(n,o));return this},i.rightShift=function(r,n){return new e(r).rightShift(n)},i.prototype.zeroFillRightShift=i.prototype.rightShift,i.prototype.zeroFillRightShiftS=i.prototype.rightShiftS,i.prototype.zeroFillRightShiftM=i.prototype.rightShiftM,i.zeroFillRightShift=i.rightShift,i.prototype.not=function(){for(let r=0;r<this.rows;r++)for(let n=0;n<this.columns;n++)this.set(r,n,~this.get(r,n));return this},i.not=function(r){return new e(r).not()},i.prototype.abs=function(){for(let r=0;r<this.rows;r++)for(let n=0;n<this.columns;n++)this.set(r,n,Math.abs(this.get(r,n)));return this},i.abs=function(r){return new e(r).abs()},i.prototype.acos=function(){for(let r=0;r<this.rows;r++)for(let n=0;n<this.columns;n++)this.set(r,n,Math.acos(this.get(r,n)));return this},i.acos=function(r){return new e(r).acos()},i.prototype.acosh=function(){for(let r=0;r<this.rows;r++)for(let n=0;n<this.columns;n++)this.set(r,n,Math.acosh(this.get(r,n)));return this},i.acosh=function(r){return new e(r).acosh()},i.prototype.asin=function(){for(let r=0;r<this.rows;r++)for(let n=0;n<this.columns;n++)this.set(r,n,Math.asin(this.get(r,n)));return this},i.asin=function(r){return new e(r).asin()},i.prototype.asinh=function(){for(let r=0;r<this.rows;r++)for(let n=0;n<this.columns;n++)this.set(r,n,Math.asinh(this.get(r,n)));return this},i.asinh=function(r){return new e(r).asinh()},i.prototype.atan=function(){for(let r=0;r<this.rows;r++)for(let n=0;n<this.columns;n++)this.set(r,n,Math.atan(this.get(r,n)));return this},i.atan=function(r){return new e(r).atan()},i.prototype.atanh=function(){for(let r=0;r<this.rows;r++)for(let n=0;n<this.columns;n++)this.set(r,n,Math.atanh(this.get(r,n)));return this},i.atanh=function(r){return new e(r).atanh()},i.prototype.cbrt=function(){for(let r=0;r<this.rows;r++)for(let n=0;n<this.columns;n++)this.set(r,n,Math.cbrt(this.get(r,n)));return this},i.cbrt=function(r){return new e(r).cbrt()},i.prototype.ceil=function(){for(let r=0;r<this.rows;r++)for(let n=0;n<this.columns;n++)this.set(r,n,Math.ceil(this.get(r,n)));return this},i.ceil=function(r){return new e(r).ceil()},i.prototype.clz32=function(){for(let r=0;r<this.rows;r++)for(let n=0;n<this.columns;n++)this.set(r,n,Math.clz32(this.get(r,n)));return this},i.clz32=function(r){return new e(r).clz32()},i.prototype.cos=function(){for(let r=0;r<this.rows;r++)for(let n=0;n<this.columns;n++)this.set(r,n,Math.cos(this.get(r,n)));return this},i.cos=function(r){return new e(r).cos()},i.prototype.cosh=function(){for(let r=0;r<this.rows;r++)for(let n=0;n<this.columns;n++)this.set(r,n,Math.cosh(this.get(r,n)));return this},i.cosh=function(r){return new e(r).cosh()},i.prototype.exp=function(){for(let r=0;r<this.rows;r++)for(let n=0;n<this.columns;n++)this.set(r,n,Math.exp(this.get(r,n)));return this},i.exp=function(r){return new e(r).exp()},i.prototype.expm1=function(){for(let r=0;r<this.rows;r++)for(let n=0;n<this.columns;n++)this.set(r,n,Math.expm1(this.get(r,n)));return this},i.expm1=function(r){return new e(r).expm1()},i.prototype.floor=function(){for(let r=0;r<this.rows;r++)for(let n=0;n<this.columns;n++)this.set(r,n,Math.floor(this.get(r,n)));return this},i.floor=function(r){return new e(r).floor()},i.prototype.fround=function(){for(let r=0;r<this.rows;r++)for(let n=0;n<this.columns;n++)this.set(r,n,Math.fround(this.get(r,n)));return this},i.fround=function(r){return new e(r).fround()},i.prototype.log=function(){for(let r=0;r<this.rows;r++)for(let n=0;n<this.columns;n++)this.set(r,n,Math.log(this.get(r,n)));return this},i.log=function(r){return new e(r).log()},i.prototype.log1p=function(){for(let r=0;r<this.rows;r++)for(let n=0;n<this.columns;n++)this.set(r,n,Math.log1p(this.get(r,n)));return this},i.log1p=function(r){return new e(r).log1p()},i.prototype.log10=function(){for(let r=0;r<this.rows;r++)for(let n=0;n<this.columns;n++)this.set(r,n,Math.log10(this.get(r,n)));return this},i.log10=function(r){return new e(r).log10()},i.prototype.log2=function(){for(let r=0;r<this.rows;r++)for(let n=0;n<this.columns;n++)this.set(r,n,Math.log2(this.get(r,n)));return this},i.log2=function(r){return new e(r).log2()},i.prototype.round=function(){for(let r=0;r<this.rows;r++)for(let n=0;n<this.columns;n++)this.set(r,n,Math.round(this.get(r,n)));return this},i.round=function(r){return new e(r).round()},i.prototype.sign=function(){for(let r=0;r<this.rows;r++)for(let n=0;n<this.columns;n++)this.set(r,n,Math.sign(this.get(r,n)));return this},i.sign=function(r){return new e(r).sign()},i.prototype.sin=function(){for(let r=0;r<this.rows;r++)for(let n=0;n<this.columns;n++)this.set(r,n,Math.sin(this.get(r,n)));return this},i.sin=function(r){return new e(r).sin()},i.prototype.sinh=function(){for(let r=0;r<this.rows;r++)for(let n=0;n<this.columns;n++)this.set(r,n,Math.sinh(this.get(r,n)));return this},i.sinh=function(r){return new e(r).sinh()},i.prototype.sqrt=function(){for(let r=0;r<this.rows;r++)for(let n=0;n<this.columns;n++)this.set(r,n,Math.sqrt(this.get(r,n)));return this},i.sqrt=function(r){return new e(r).sqrt()},i.prototype.tan=function(){for(let r=0;r<this.rows;r++)for(let n=0;n<this.columns;n++)this.set(r,n,Math.tan(this.get(r,n)));return this},i.tan=function(r){return new e(r).tan()},i.prototype.tanh=function(){for(let r=0;r<this.rows;r++)for(let n=0;n<this.columns;n++)this.set(r,n,Math.tanh(this.get(r,n)));return this},i.tanh=function(r){return new e(r).tanh()},i.prototype.trunc=function(){for(let r=0;r<this.rows;r++)for(let n=0;n<this.columns;n++)this.set(r,n,Math.trunc(this.get(r,n)));return this},i.trunc=function(r){return new e(r).trunc()},i.pow=function(r,n){return new e(r).pow(n)},i.prototype.pow=function(r){return typeof r=="number"?this.powS(r):this.powM(r)},i.prototype.powS=function(r){for(let n=0;n<this.rows;n++)for(let o=0;o<this.columns;o++)this.set(n,o,Math.pow(this.get(n,o),r));return this},i.prototype.powM=function(r){if(r=e.checkMatrix(r),this.rows!==r.rows||this.columns!==r.columns)throw new RangeError("Matrices dimensions must be equal");for(let n=0;n<this.rows;n++)for(let o=0;o<this.columns;o++)this.set(n,o,Math.pow(this.get(n,o),r.get(n,o)));return this}}function xt(i,e,t){let r=t?i.rows:i.rows-1;if(e<0||e>r)throw new RangeError("Row index out of range")}function Nt(i,e,t){let r=t?i.columns:i.columns-1;if(e<0||e>r)throw new RangeError("Column index out of range")}function Ft(i,e){if(e.to1DArray&&(e=e.to1DArray()),e.length!==i.columns)throw new RangeError("vector size must be the same as the number of columns");return e}function Ct(i,e){if(e.to1DArray&&(e=e.to1DArray()),e.length!==i.rows)throw new RangeError("vector size must be the same as the number of rows");return e}function Le(i,e){if(!wt.isAnyArray(e))throw new TypeError("row indices must be an array");for(let t=0;t<e.length;t++)if(e[t]<0||e[t]>=i.rows)throw new RangeError("row indices are out of range")}function De(i,e){if(!wt.isAnyArray(e))throw new TypeError("column indices must be an array");for(let t=0;t<e.length;t++)if(e[t]<0||e[t]>=i.columns)throw new RangeError("column indices are out of range")}function Pe(i,e,t,r,n){if(arguments.length!==5)throw new RangeError("expected 4 arguments");if(fe("startRow",e),fe("endRow",t),fe("startColumn",r),fe("endColumn",n),e>t||r>n||e<0||e>=i.rows||t<0||t>=i.rows||r<0||r>=i.columns||n<0||n>=i.columns)throw new RangeError("Submatrix indices are out of range")}function ue(i,e=0){let t=[];for(let r=0;r<i;r++)t.push(e);return t}function fe(i,e){if(typeof e!="number")throw new TypeError(`${i} must be a number`)}function qt(i){if(i.isEmpty())throw new Error("Empty matrix has no elements to index")}function vi(i){let e=ue(i.rows);for(let t=0;t<i.rows;++t)for(let r=0;r<i.columns;++r)e[t]+=i.get(t,r);return e}function pi(i){let e=ue(i.columns);for(let t=0;t<i.rows;++t)for(let r=0;r<i.columns;++r)e[r]+=i.get(t,r);return e}function wi(i){let e=0;for(let t=0;t<i.rows;t++)for(let r=0;r<i.columns;r++)e+=i.get(t,r);return e}function mi(i){let e=ue(i.rows,1);for(let t=0;t<i.rows;++t)for(let r=0;r<i.columns;++r)e[t]*=i.get(t,r);return e}function yi(i){let e=ue(i.columns,1);for(let t=0;t<i.rows;++t)for(let r=0;r<i.columns;++r)e[r]*=i.get(t,r);return e}function Ei(i){let e=1;for(let t=0;t<i.rows;t++)for(let r=0;r<i.columns;r++)e*=i.get(t,r);return e}function xi(i,e,t){const r=i.rows,n=i.columns,o=[];for(let a=0;a<r;a++){let s=0,f=0,u=0;for(let l=0;l<n;l++)u=i.get(a,l)-t[a],s+=u,f+=u*u;e?o.push((f-s*s/n)/(n-1)):o.push((f-s*s/n)/n)}return o}function Ni(i,e,t){const r=i.rows,n=i.columns,o=[];for(let a=0;a<n;a++){let s=0,f=0,u=0;for(let l=0;l<r;l++)u=i.get(l,a)-t[a],s+=u,f+=u*u;e?o.push((f-s*s/r)/(r-1)):o.push((f-s*s/r)/r)}return o}function bi(i,e,t){const r=i.rows,n=i.columns,o=r*n;let a=0,s=0,f=0;for(let u=0;u<r;u++)for(let l=0;l<n;l++)f=i.get(u,l)-t,a+=f,s+=f*f;return e?(s-a*a/o)/(o-1):(s-a*a/o)/o}function Mi(i,e){for(let t=0;t<i.rows;t++)for(let r=0;r<i.columns;r++)i.set(t,r,i.get(t,r)-e[t])}function Si(i,e){for(let t=0;t<i.rows;t++)for(let r=0;r<i.columns;r++)i.set(t,r,i.get(t,r)-e[r])}function ki(i,e){for(let t=0;t<i.rows;t++)for(let r=0;r<i.columns;r++)i.set(t,r,i.get(t,r)-e)}function _i(i){const e=[];for(let t=0;t<i.rows;t++){let r=0;for(let n=0;n<i.columns;n++)r+=Math.pow(i.get(t,n),2)/(i.columns-1);e.push(Math.sqrt(r))}return e}function zi(i,e){for(let t=0;t<i.rows;t++)for(let r=0;r<i.columns;r++)i.set(t,r,i.get(t,r)/e[t])}function Ai(i){const e=[];for(let t=0;t<i.columns;t++){let r=0;for(let n=0;n<i.rows;n++)r+=Math.pow(i.get(n,t),2)/(i.rows-1);e.push(Math.sqrt(r))}return e}function Ri(i,e){for(let t=0;t<i.rows;t++)for(let r=0;r<i.columns;r++)i.set(t,r,i.get(t,r)/e[r])}function Oi(i){const e=i.size-1;let t=0;for(let r=0;r<i.columns;r++)for(let n=0;n<i.rows;n++)t+=Math.pow(i.get(n,r),2)/e;return Math.sqrt(t)}function Ii(i,e){for(let t=0;t<i.rows;t++)for(let r=0;r<i.columns;r++)i.set(t,r,i.get(t,r)/e)}class J{static from1DArray(e,t,r){if(e*t!==r.length)throw new RangeError("data length does not match given dimensions");let o=new j(e,t);for(let a=0;a<e;a++)for(let s=0;s<t;s++)o.set(a,s,r[a*t+s]);return o}static rowVector(e){let t=new j(1,e.length);for(let r=0;r<e.length;r++)t.set(0,r,e[r]);return t}static columnVector(e){let t=new j(e.length,1);for(let r=0;r<e.length;r++)t.set(r,0,e[r]);return t}static zeros(e,t){return new j(e,t)}static ones(e,t){return new j(e,t).fill(1)}static rand(e,t,r={}){if(typeof r!="object")throw new TypeError("options must be an object");const{random:n=Math.random}=r;let o=new j(e,t);for(let a=0;a<e;a++)for(let s=0;s<t;s++)o.set(a,s,n());return o}static randInt(e,t,r={}){if(typeof r!="object")throw new TypeError("options must be an object");const{min:n=0,max:o=1e3,random:a=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,f=new j(e,t);for(let u=0;u<e;u++)for(let l=0;l<t;l++){let h=n+Math.round(a()*s);f.set(u,l,h)}return f}static eye(e,t,r){t===void 0&&(t=e),r===void 0&&(r=1);let n=Math.min(e,t),o=this.zeros(e,t);for(let a=0;a<n;a++)o.set(a,a,r);return o}static diag(e,t,r){let n=e.length;t===void 0&&(t=n),r===void 0&&(r=t);let o=Math.min(n,t,r),a=this.zeros(t,r);for(let s=0;s<o;s++)a.set(s,s,e[s]);return a}static min(e,t){e=this.checkMatrix(e),t=this.checkMatrix(t);let r=e.rows,n=e.columns,o=new j(r,n);for(let a=0;a<r;a++)for(let s=0;s<n;s++)o.set(a,s,Math.min(e.get(a,s),t.get(a,s)));return o}static max(e,t){e=this.checkMatrix(e),t=this.checkMatrix(t);let r=e.rows,n=e.columns,o=new this(r,n);for(let a=0;a<r;a++)for(let s=0;s<n;s++)o.set(a,s,Math.max(e.get(a,s),t.get(a,s)));return o}static checkMatrix(e){return J.isMatrix(e)?e:new j(e)}static isMatrix(e){return e!=null&&e.klass==="Matrix"}get size(){return this.rows*this.columns}apply(e){if(typeof e!="function")throw new TypeError("callback must be a function");for(let t=0;t<this.rows;t++)for(let r=0;r<this.columns;r++)e.call(this,t,r);return this}to1DArray(){let e=[];for(let t=0;t<this.rows;t++)for(let r=0;r<this.columns;r++)e.push(this.get(t,r));return e}to2DArray(){let e=[];for(let t=0;t<this.rows;t++){e.push([]);for(let r=0;r<this.columns;r++)e[t].push(this.get(t,r))}return e}toJSON(){return this.to2DArray()}isRowVector(){return this.rows===1}isColumnVector(){return this.columns===1}isVector(){return this.rows===1||this.columns===1}isSquare(){return this.rows===this.columns}isEmpty(){return this.rows===0||this.columns===0}isSymmetric(){if(this.isSquare()){for(let e=0;e<this.rows;e++)for(let t=0;t<=e;t++)if(this.get(e,t)!==this.get(t,e))return!1;return!0}return!1}isDistance(){if(!this.isSymmetric())return!1;for(let e=0;e<this.rows;e++)if(this.get(e,e)!==0)return!1;return!0}isEchelonForm(){let e=0,t=0,r=-1,n=!0,o=!1;for(;e<this.rows&&n;){for(t=0,o=!1;t<this.columns&&o===!1;)this.get(e,t)===0?t++:this.get(e,t)===1&&t>r?(o=!0,r=t):(n=!1,o=!0);e++}return n}isReducedEchelonForm(){let e=0,t=0,r=-1,n=!0,o=!1;for(;e<this.rows&&n;){for(t=0,o=!1;t<this.columns&&o===!1;)this.get(e,t)===0?t++:this.get(e,t)===1&&t>r?(o=!0,r=t):(n=!1,o=!0);for(let a=t+1;a<this.rows;a++)this.get(e,a)!==0&&(n=!1);e++}return n}echelonForm(){let e=this.clone(),t=0,r=0;for(;t<e.rows&&r<e.columns;){let n=t;for(let o=t;o<e.rows;o++)e.get(o,r)>e.get(n,r)&&(n=o);if(e.get(n,r)===0)r++;else{e.swapRows(t,n);let o=e.get(t,r);for(let a=r;a<e.columns;a++)e.set(t,a,e.get(t,a)/o);for(let a=t+1;a<e.rows;a++){let s=e.get(a,r)/e.get(t,r);e.set(a,r,0);for(let f=r+1;f<e.columns;f++)e.set(a,f,e.get(a,f)-e.get(t,f)*s)}t++,r++}}return e}reducedEchelonForm(){let e=this.echelonForm(),t=e.columns,r=e.rows,n=r-1;for(;n>=0;)if(e.maxRow(n)===0)n--;else{let o=0,a=!1;for(;o<r&&a===!1;)e.get(n,o)===1?a=!0:o++;for(let s=0;s<n;s++){let f=e.get(s,o);for(let u=o;u<t;u++){let l=e.get(s,u)-f*e.get(n,u);e.set(s,u,l)}}n--}return e}set(){throw new Error("set method is unimplemented")}get(){throw new Error("get method is unimplemented")}repeat(e={}){if(typeof e!="object")throw new TypeError("options must be an object");const{rows:t=1,columns:r=1}=e;if(!Number.isInteger(t)||t<=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 j(this.rows*t,this.columns*r);for(let o=0;o<t;o++)for(let a=0;a<r;a++)n.setSubMatrix(this,this.rows*o,this.columns*a);return n}fill(e){for(let t=0;t<this.rows;t++)for(let r=0;r<this.columns;r++)this.set(t,r,e);return this}neg(){return this.mulS(-1)}getRow(e){xt(this,e);let t=[];for(let r=0;r<this.columns;r++)t.push(this.get(e,r));return t}getRowVector(e){return j.rowVector(this.getRow(e))}setRow(e,t){xt(this,e),t=Ft(this,t);for(let r=0;r<this.columns;r++)this.set(e,r,t[r]);return this}swapRows(e,t){xt(this,e),xt(this,t);for(let r=0;r<this.columns;r++){let n=this.get(e,r);this.set(e,r,this.get(t,r)),this.set(t,r,n)}return this}getColumn(e){Nt(this,e);let t=[];for(let r=0;r<this.rows;r++)t.push(this.get(r,e));return t}getColumnVector(e){return j.columnVector(this.getColumn(e))}setColumn(e,t){Nt(this,e),t=Ct(this,t);for(let r=0;r<this.rows;r++)this.set(r,e,t[r]);return this}swapColumns(e,t){Nt(this,e),Nt(this,t);for(let r=0;r<this.rows;r++){let n=this.get(r,e);this.set(r,e,this.get(r,t)),this.set(r,t,n)}return this}addRowVector(e){e=Ft(this,e);for(let t=0;t<this.rows;t++)for(let r=0;r<this.columns;r++)this.set(t,r,this.get(t,r)+e[r]);return this}subRowVector(e){e=Ft(this,e);for(let t=0;t<this.rows;t++)for(let r=0;r<this.columns;r++)this.set(t,r,this.get(t,r)-e[r]);return this}mulRowVector(e){e=Ft(this,e);for(let t=0;t<this.rows;t++)for(let r=0;r<this.columns;r++)this.set(t,r,this.get(t,r)*e[r]);return this}divRowVector(e){e=Ft(this,e);for(let t=0;t<this.rows;t++)for(let r=0;r<this.columns;r++)this.set(t,r,this.get(t,r)/e[r]);return this}addColumnVector(e){e=Ct(this,e);for(let t=0;t<this.rows;t++)for(let r=0;r<this.columns;r++)this.set(t,r,this.get(t,r)+e[t]);return this}subColumnVector(e){e=Ct(this,e);for(let t=0;t<this.rows;t++)for(let r=0;r<this.columns;r++)this.set(t,r,this.get(t,r)-e[t]);return this}mulColumnVector(e){e=Ct(this,e);for(let t=0;t<this.rows;t++)for(let r=0;r<this.columns;r++)this.set(t,r,this.get(t,r)*e[t]);return this}divColumnVector(e){e=Ct(this,e);for(let t=0;t<this.rows;t++)for(let r=0;r<this.columns;r++)this.set(t,r,this.get(t,r)/e[t]);return this}mulRow(e,t){xt(this,e);for(let r=0;r<this.columns;r++)this.set(e,r,this.get(e,r)*t);return this}mulColumn(e,t){Nt(this,e);for(let r=0;r<this.rows;r++)this.set(r,e,this.get(r,e)*t);return this}max(e){if(this.isEmpty())return NaN;switch(e){case"row":{const t=new Array(this.rows).fill(Number.NEGATIVE_INFINITY);for(let r=0;r<this.rows;r++)for(let n=0;n<this.columns;n++)this.get(r,n)>t[r]&&(t[r]=this.get(r,n));return t}case"column":{const t=new Array(this.columns).fill(Number.NEGATIVE_INFINITY);for(let r=0;r<this.rows;r++)for(let n=0;n<this.columns;n++)this.get(r,n)>t[n]&&(t[n]=this.get(r,n));return t}case void 0:{let t=this.get(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));return t}default:throw new Error(`invalid option: ${e}`)}}maxIndex(){qt(this);let e=this.get(0,0),t=[0,0];for(let r=0;r<this.rows;r++)for(let n=0;n<this.columns;n++)this.get(r,n)>e&&(e=this.get(r,n),t[0]=r,t[1]=n);return t}min(e){if(this.isEmpty())return NaN;switch(e){case"row":{const t=new Array(this.rows).fill(Number.POSITIVE_INFINITY);for(let r=0;r<this.rows;r++)for(let n=0;n<this.columns;n++)this.get(r,n)<t[r]&&(t[r]=this.get(r,n));return t}case"column":{const t=new Array(this.columns).fill(Number.POSITIVE_INFINITY);for(let r=0;r<this.rows;r++)for(let n=0;n<this.columns;n++)this.get(r,n)<t[n]&&(t[n]=this.get(r,n));return t}case void 0:{let t=this.get(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));return t}default:throw new Error(`invalid option: ${e}`)}}minIndex(){qt(this);let e=this.get(0,0),t=[0,0];for(let r=0;r<this.rows;r++)for(let n=0;n<this.columns;n++)this.get(r,n)<e&&(e=this.get(r,n),t[0]=r,t[1]=n);return t}maxRow(e){if(xt(this,e),this.isEmpty())return NaN;let t=this.get(e,0);for(let r=1;r<this.columns;r++)this.get(e,r)>t&&(t=this.get(e,r));return t}maxRowIndex(e){xt(this,e),qt(this);let t=this.get(e,0),r=[e,0];for(let n=1;n<this.columns;n++)this.get(e,n)>t&&(t=this.get(e,n),r[1]=n);return r}minRow(e){if(xt(this,e),this.isEmpty())return NaN;let t=this.get(e,0);for(let r=1;r<this.columns;r++)this.get(e,r)<t&&(t=this.get(e,r));return t}minRowIndex(e){xt(this,e),qt(this);let t=this.get(e,0),r=[e,0];for(let n=1;n<this.columns;n++)this.get(e,n)<t&&(t=this.get(e,n),r[1]=n);return r}maxColumn(e){if(Nt(this,e),this.isEmpty())return NaN;let t=this.get(0,e);for(let r=1;r<this.rows;r++)this.get(r,e)>t&&(t=this.get(r,e));return t}maxColumnIndex(e){Nt(this,e),qt(this);let t=this.get(0,e),r=[0,e];for(let n=1;n<this.rows;n++)this.get(n,e)>t&&(t=this.get(n,e),r[0]=n);return r}minColumn(e){if(Nt(this,e),this.isEmpty())return NaN;let t=this.get(0,e);for(let r=1;r<this.rows;r++)this.get(r,e)<t&&(t=this.get(r,e));return t}minColumnIndex(e){Nt(this,e),qt(this);let t=this.get(0,e),r=[0,e];for(let n=1;n<this.rows;n++)this.get(n,e)<t&&(t=this.get(n,e),r[0]=n);return r}diag(){let e=Math.min(this.rows,this.columns),t=[];for(let r=0;r<e;r++)t.push(this.get(r,r));return t}norm(e="frobenius"){switch(e){case"max":return this.max();case"frobenius":return Math.sqrt(this.dot(this));default:throw new RangeError(`unknown norm type: ${e}`)}}cumulativeSum(){let e=0;for(let t=0;t<this.rows;t++)for(let r=0;r<this.columns;r++)e+=this.get(t,r),this.set(t,r,e);return this}dot(e){J.isMatrix(e)&&(e=e.to1DArray());let t=this.to1DArray();if(t.length!==e.length)throw new RangeError("vectors do not have the same size");let r=0;for(let n=0;n<t.length;n++)r+=t[n]*e[n];return r}mmul(e){e=j.checkMatrix(e);let t=this.rows,r=this.columns,n=e.columns,o=new j(t,n),a=new Float64Array(r);for(let s=0;s<n;s++){for(let f=0;f<r;f++)a[f]=e.get(f,s);for(let f=0;f<t;f++){let u=0;for(let l=0;l<r;l++)u+=this.get(f,l)*a[l];o.set(f,s,u)}}return o}strassen2x2(e){e=j.checkMatrix(e);let t=new j(2,2);const r=this.get(0,0),n=e.get(0,0),o=this.get(0,1),a=e.get(0,1),s=this.get(1,0),f=e.get(1,0),u=this.get(1,1),l=e.get(1,1),h=(r+u)*(n+l),d=(s+u)*n,g=r*(a-l),v=u*(f-n),p=(r+o)*l,w=(s-r)*(n+a),c=(o-u)*(f+l),m=h+v-p+c,E=g+p,x=d+v,N=h-d+g+w;return t.set(0,0,m),t.set(0,1,E),t.set(1,0,x),t.set(1,1,N),t}strassen3x3(e){e=j.checkMatrix(e);let t=new j(3,3);const r=this.get(0,0),n=this.get(0,1),o=this.get(0,2),a=this.get(1,0),s=this.get(1,1),f=this.get(1,2),u=this.get(2,0),l=this.get(2,1),h=this.get(2,2),d=e.get(0,0),g=e.get(0,1),v=e.get(0,2),p=e.get(1,0),w=e.get(1,1),c=e.get(1,2),m=e.get(2,0),E=e.get(2,1),x=e.get(2,2),N=(r+n+o-a-s-l-h)*w,z=(r-a)*(-g+w),k=s*(-d+g+p-w-c-m+x),b=(-r+a+s)*(d-g+w),A=(a+s)*(-d+g),y=r*d,S=(-r+u+l)*(d-v+c),_=(-r+u)*(v-c),M=(u+l)*(-d+v),T=(r+n+o-s-f-u-l)*c,L=l*(-d+v+p-w-c-m+E),D=(-o+l+h)*(w+m-E),$=(o-h)*(w-E),C=o*m,G=(l+h)*(-m+E),V=(-o+s+f)*(c+m-x),X=(o-f)*(c-x),W=(s+f)*(-m+x),P=n*p,I=f*E,U=a*v,q=u*g,B=h*x,O=y+C+P,F=N+b+A+y+D+C+G,Y=y+S+M+T+C+V+W,Z=z+k+b+y+C+V+X,rt=z+b+A+y+I,et=C+V+X+W+U,mt=y+S+_+L+D+$+C,It=D+$+C+G+q,Se=y+S+_+M+B;return t.set(0,0,O),t.set(0,1,F),t.set(0,2,Y),t.set(1,0,Z),t.set(1,1,rt),t.set(1,2,et),t.set(2,0,mt),t.set(2,1,It),t.set(2,2,Se),t}mmulStrassen(e){e=j.checkMatrix(e);let t=this.clone(),r=t.rows,n=t.columns,o=e.rows,a=e.columns;n!==o&&console.warn(`Multiplying ${r} x ${n} and ${o} x ${a} matrix: dimensions do not match.`);function s(h,d,g){let v=h.rows,p=h.columns;if(v===d&&p===g)return h;{let w=J.zeros(d,g);return w=w.setSubMatrix(h,0,0),w}}let f=Math.max(r,o),u=Math.max(n,a);t=s(t,f,u),e=s(e,f,u);function l(h,d,g,v){if(g<=512||v<=512)return h.mmul(d);g%2===1&&v%2===1?(h=s(h,g+1,v+1),d=s(d,g+1,v+1)):g%2===1?(h=s(h,g+1,v),d=s(d,g+1,v)):v%2===1&&(h=s(h,g,v+1),d=s(d,g,v+1));let p=parseInt(h.rows/2,10),w=parseInt(h.columns/2,10),c=h.subMatrix(0,p-1,0,w-1),m=d.subMatrix(0,p-1,0,w-1),E=h.subMatrix(0,p-1,w,h.columns-1),x=d.subMatrix(0,p-1,w,d.columns-1),N=h.subMatrix(p,h.rows-1,0,w-1),z=d.subMatrix(p,d.rows-1,0,w-1),k=h.subMatrix(p,h.rows-1,w,h.columns-1),b=d.subMatrix(p,d.rows-1,w,d.columns-1),A=l(J.add(c,k),J.add(m,b),p,w),y=l(J.add(N,k),m,p,w),S=l(c,J.sub(x,b),p,w),_=l(k,J.sub(z,m),p,w),M=l(J.add(c,E),b,p,w),T=l(J.sub(N,c),J.add(m,x),p,w),L=l(J.sub(E,k),J.add(z,b),p,w),D=J.add(A,_);D.sub(M),D.add(L);let $=J.add(S,M),C=J.add(y,_),G=J.sub(A,y);G.add(S),G.add(T);let V=J.zeros(2*D.rows,2*D.columns);return V=V.setSubMatrix(D,0,0),V=V.setSubMatrix($,D.rows,0),V=V.setSubMatrix(C,0,D.columns),V=V.setSubMatrix(G,D.rows,D.columns),V.subMatrix(0,g-1,0,v-1)}return l(t,e,f,u)}scaleRows(e={}){if(typeof e!="object")throw new TypeError("options must be an object");const{min:t=0,max:r=1}=e;if(!Number.isFinite(t))throw new TypeError("min must be a number");if(!Number.isFinite(r))throw new TypeError("max must be a number");if(t>=r)throw new RangeError("min must be smaller than max");let n=new j(this.rows,this.columns);for(let o=0;o<this.rows;o++){const a=this.getRow(o);a.length>0&&yr(a,{min:t,max:r,output:a}),n.setRow(o,a)}return n}scaleColumns(e={}){if(typeof e!="object")throw new TypeError("options must be an object");const{min:t=0,max:r=1}=e;if(!Number.isFinite(t))throw new TypeError("min must be a number");if(!Number.isFinite(r))throw new TypeError("max must be a number");if(t>=r)throw new RangeError("min must be smaller than max");let n=new j(this.rows,this.columns);for(let o=0;o<this.columns;o++){const a=this.getColumn(o);a.length&&yr(a,{min:t,max:r,output:a}),n.setColumn(o,a)}return n}flipRows(){const e=Math.ceil(this.columns/2);for(let t=0;t<this.rows;t++)for(let r=0;r<e;r++){let n=this.get(t,r),o=this.get(t,this.columns-1-r);this.set(t,r,o),this.set(t,this.columns-1-r,n)}return this}flipColumns(){const e=Math.ceil(this.rows/2);for(let t=0;t<this.columns;t++)for(let r=0;r<e;r++){let n=this.get(r,t),o=this.get(this.rows-1-r,t);this.set(r,t,o),this.set(this.rows-1-r,t,n)}return this}kroneckerProduct(e){e=j.checkMatrix(e);let t=this.rows,r=this.columns,n=e.rows,o=e.columns,a=new j(t*n,r*o);for(let s=0;s<t;s++)for(let f=0;f<r;f++)for(let u=0;u<n;u++)for(let l=0;l<o;l++)a.set(n*s+u,o*f+l,this.get(s,f)*e.get(u,l));return a}kroneckerSum(e){if(e=j.checkMatrix(e),!this.isSquare()||!e.isSquare())throw new Error("Kronecker Sum needs two Square Matrices");let t=this.rows,r=e.rows,n=this.kroneckerProduct(j.eye(r,r)),o=j.eye(t,t).kroneckerProduct(e);return n.add(o)}transpose(){let e=new j(this.columns,this.rows);for(let t=0;t<this.rows;t++)for(let r=0;r<this.columns;r++)e.set(r,t,this.get(t,r));return e}sortRows(e=br){for(let t=0;t<this.rows;t++)this.setRow(t,this.getRow(t).sort(e));return this}sortColumns(e=br){for(let t=0;t<this.columns;t++)this.setColumn(t,this.getColumn(t).sort(e));return this}subMatrix(e,t,r,n){Pe(this,e,t,r,n);let o=new j(t-e+1,n-r+1);for(let a=e;a<=t;a++)for(let s=r;s<=n;s++)o.set(a-e,s-r,this.get(a,s));return o}subMatrixRow(e,t,r){if(t===void 0&&(t=0),r===void 0&&(r=this.columns-1),t>r||t<0||t>=this.columns||r<0||r>=this.columns)throw new RangeError("Argument out of range");let n=new j(e.length,r-t+1);for(let o=0;o<e.length;o++)for(let a=t;a<=r;a++){if(e[o]<0||e[o]>=this.rows)throw new RangeError(`Row index out of range: ${e[o]}`);n.set(o,a-t,this.get(e[o],a))}return n}subMatrixColumn(e,t,r){if(t===void 0&&(t=0),r===void 0&&(r=this.rows-1),t>r||t<0||t>=this.rows||r<0||r>=this.rows)throw new RangeError("Argument out of range");let n=new j(r-t+1,e.length);for(let o=0;o<e.length;o++)for(let a=t;a<=r;a++){if(e[o]<0||e[o]>=this.columns)throw new RangeError(`Column index out of range: ${e[o]}`);n.set(a-t,o,this.get(a,e[o]))}return n}setSubMatrix(e,t,r){if(e=j.checkMatrix(e),e.isEmpty())return this;let n=t+e.rows-1,o=r+e.columns-1;Pe(this,t,n,r,o);for(let a=0;a<e.rows;a++)for(let s=0;s<e.columns;s++)this.set(t+a,r+s,e.get(a,s));return this}selection(e,t){Le(this,e),De(this,t);let r=new j(e.length,t.length);for(let n=0;n<e.length;n++){let o=e[n];for(let a=0;a<t.length;a++){let s=t[a];r.set(n,a,this.get(o,s))}}return r}trace(){let e=Math.min(this.rows,this.columns),t=0;for(let r=0;r<e;r++)t+=this.get(r,r);return t}clone(){return this.constructor.copy(this,new j(this.rows,this.columns))}static copy(e,t){for(const[r,n,o]of e.entries())t.set(r,n,o);return t}sum(e){switch(e){case"row":return vi(this);case"column":return pi(this);case void 0:return wi(this);default:throw new Error(`invalid option: ${e}`)}}product(e){switch(e){case"row":return mi(this);case"column":return yi(this);case void 0:return Ei(this);default:throw new Error(`invalid option: ${e}`)}}mean(e){const t=this.sum(e);switch(e){case"row":{for(let r=0;r<this.rows;r++)t[r]/=this.columns;return t}case"column":{for(let r=0;r<this.columns;r++)t[r]/=this.rows;return t}case void 0:return t/this.size;default:throw new Error(`invalid option: ${e}`)}}variance(e,t={}){if(typeof e=="object"&&(t=e,e=void 0),typeof t!="object")throw new TypeError("options must be an object");const{unbiased:r=!0,mean:n=this.mean(e)}=t;if(typeof r!="boolean")throw new TypeError("unbiased must be a boolean");switch(e){case"row":{if(!wt.isAnyArray(n))throw new TypeError("mean must be an array");return xi(this,r,n)}case"column":{if(!wt.isAnyArray(n))throw new TypeError("mean must be an array");return Ni(this,r,n)}case void 0:{if(typeof n!="number")throw new TypeError("mean must be a number");return bi(this,r,n)}default:throw new Error(`invalid option: ${e}`)}}standardDeviation(e,t){typeof e=="object"&&(t=e,e=void 0);const r=this.variance(e,t);if(e===void 0)return Math.sqrt(r);for(let n=0;n<r.length;n++)r[n]=Math.sqrt(r[n]);return r}center(e,t={}){if(typeof e=="object"&&(t=e,e=void 0),typeof t!="object")throw new TypeError("options must be an object");const{center:r=this.mean(e)}=t;switch(e){case"row":{if(!wt.isAnyArray(r))throw new TypeError("center must be an array");return Mi(this,r),this}case"column":{if(!wt.isAnyArray(r))throw new TypeError("center must be an array");return Si(this,r),this}case void 0:{if(typeof r!="number")throw new TypeError("center must be a number");return ki(this,r),this}default:throw new Error(`invalid option: ${e}`)}}scale(e,t={}){if(typeof e=="object"&&(t=e,e=void 0),typeof t!="object")throw new TypeError("options must be an object");let r=t.scale;switch(e){case"row":{if(r===void 0)r=_i(this);else if(!wt.isAnyArray(r))throw new TypeError("scale must be an array");return zi(this,r),this}case"column":{if(r===void 0)r=Ai(this);else if(!wt.isAnyArray(r))throw new TypeError("scale must be an array");return Ri(this,r),this}case void 0:{if(r===void 0)r=Oi(this);else if(typeof r!="number")throw new TypeError("scale must be a number");return Ii(this,r),this}default:throw new Error(`invalid option: ${e}`)}}toString(e){return xr(this,e)}[Symbol.iterator](){return this.entries()}*entries(){for(let e=0;e<this.rows;e++)for(let t=0;t<this.columns;t++)yield[e,t,this.get(e,t)]}*values(){for(let e=0;e<this.rows;e++)for(let t=0;t<this.columns;t++)yield this.get(e,t)}}J.prototype.klass="Matrix",typeof Symbol<"u"&&(J.prototype[Symbol.for("nodejs.util.inspect.custom")]=hi);function br(i,e){return i-e}function Ti(i){return i.every(e=>typeof e=="number")}J.random=J.rand,J.randomInt=J.randInt,J.diagonal=J.diag,J.prototype.diagonal=J.prototype.diag,J.identity=J.eye,J.prototype.negate=J.prototype.neg,J.prototype.tensorProduct=J.prototype.kroneckerProduct;let j=(Ut=class extends J{constructor(t,r){super();er(this,Ht);ot(this,"data");if(Ut.isMatrix(t))rr(this,Ht,nr).call(this,t.rows,t.columns),Ut.copy(t,this);else if(Number.isInteger(t)&&t>=0)rr(this,Ht,nr).call(this,t,r);else if(wt.isAnyArray(t)){const n=t;if(t=n.length,r=t?n[0].length:0,typeof r!="number")throw new TypeError("Data must be a 2D array with at least one element");this.data=[];for(let o=0;o<t;o++){if(n[o].length!==r)throw new RangeError("Inconsistent array dimensions");if(!Ti(n[o]))throw new TypeError("Input data contains non-numeric values");this.data.push(Float64Array.from(n[o]))}this.rows=t,this.columns=r}else throw new TypeError("First argument must be a positive number or an array")}set(t,r,n){return this.data[t][r]=n,this}get(t,r){return this.data[t][r]}removeRow(t){return xt(this,t),this.data.splice(t,1),this.rows-=1,this}addRow(t,r){return r===void 0&&(r=t,t=this.rows),xt(this,t,!0),r=Float64Array.from(Ft(this,r)),this.data.splice(t,0,r),this.rows+=1,this}removeColumn(t){Nt(this,t);for(let r=0;r<this.rows;r++){const n=new Float64Array(this.columns-1);for(let o=0;o<t;o++)n[o]=this.data[r][o];for(let o=t+1;o<this.columns;o++)n[o-1]=this.data[r][o];this.data[r]=n}return this.columns-=1,this}addColumn(t,r){typeof r>"u"&&(r=t,t=this.columns),Nt(this,t,!0),r=Ct(this,r);for(let n=0;n<this.rows;n++){const o=new Float64Array(this.columns+1);let a=0;for(;a<t;a++)o[a]=this.data[n][a];for(o[a++]=r[n];a<this.columns+1;a++)o[a]=this.data[n][a-1];this.data[n]=o}return this.columns+=1,this}},Ht=new WeakSet,nr=function(t,r){if(this.data=[],Number.isInteger(r)&&r>=0)for(let n=0;n<t;n++)this.data.push(new Float64Array(r));else throw new TypeError("nColumns must be a positive integer");this.rows=t,this.columns=r},Ut);gi(J,j);const Me=class Me extends J{constructor(t){super();er(this,dt,void 0);if(j.isMatrix(t)){if(!t.isSymmetric())throw new TypeError("not symmetric data");ke(this,dt,j.copy(t,new j(t.rows,t.rows)))}else if(Number.isInteger(t)&&t>=0)ke(this,dt,new j(t,t));else if(ke(this,dt,new j(t)),!this.isSymmetric())throw new TypeError("not symmetric data")}get size(){return bt(this,dt).size}get rows(){return bt(this,dt).rows}get columns(){return bt(this,dt).columns}get diagonalSize(){return this.rows}static isSymmetricMatrix(t){return j.isMatrix(t)&&t.klassType==="SymmetricMatrix"}static zeros(t){return new this(t)}static ones(t){return new this(t).fill(1)}clone(){const t=new Me(this.diagonalSize);for(const[r,n,o]of this.upperRightEntries())t.set(r,n,o);return t}toMatrix(){return new j(this)}get(t,r){return bt(this,dt).get(t,r)}set(t,r,n){return bt(this,dt).set(t,r,n),bt(this,dt).set(r,t,n),this}removeCross(t){return bt(this,dt).removeRow(t),bt(this,dt).removeColumn(t),this}addCross(t,r){r===void 0&&(r=t,t=this.diagonalSize);const n=r.slice();return n.splice(t,1),bt(this,dt).addRow(t,n),bt(this,dt).addColumn(t,r),this}applyMask(t){if(t.length!==this.diagonalSize)throw new RangeError("Mask size do not match with matrix size");const r=[];for(const[n,o]of t.entries())o||r.push(n);r.reverse();for(const n of r)this.removeCross(n);return this}toCompact(){const{diagonalSize:t}=this,r=new Array(t*(t+1)/2);for(let n=0,o=0,a=0;a<r.length;a++)r[a]=this.get(o,n),++n>=t&&(n=++o);return r}static fromCompact(t){const r=t.length,n=(Math.sqrt(8*r+1)-1)/2;if(!Number.isInteger(n))throw new TypeError(`This array is not a compact representation of a Symmetric Matrix, ${JSON.stringify(t)}`);const o=new Me(n);for(let a=0,s=0,f=0;f<r;f++)o.set(a,s,t[f]),++a>=n&&(a=++s);return o}*upperRightEntries(){for(let t=0,r=0;t<this.diagonalSize;void 0){const n=this.get(t,r);yield[t,r,n],++r>=this.diagonalSize&&(r=++t)}}*upperRightValues(){for(let t=0,r=0;t<this.diagonalSize;void 0)yield this.get(t,r),++r>=this.diagonalSize&&(r=++t)}};dt=new WeakMap;let Dt=Me;Dt.prototype.klassType="SymmetricMatrix";class le extends Dt{static isDistanceMatrix(e){return Dt.isSymmetricMatrix(e)&&e.klassSubType==="DistanceMatrix"}constructor(e){if(super(e),!this.isDistance())throw new TypeError("Provided arguments do no produce a distance matrix")}set(e,t,r){return e===t&&(r=0),super.set(e,t,r)}addCross(e,t){return t===void 0&&(t=e,e=this.diagonalSize),t=t.slice(),t[e]=0,super.addCross(e,t)}toSymmetricMatrix(){return new Dt(this)}clone(){const e=new le(this.diagonalSize);for(const[t,r,n]of this.upperRightEntries())t!==r&&e.set(t,r,n);return e}toCompact(){const{diagonalSize:e}=this,t=(e-1)*e/2,r=new Array(t);for(let n=1,o=0,a=0;a<r.length;a++)r[a]=this.get(o,n),++n>=e&&(n=++o+1);return r}static fromCompact(e){const t=e.length,r=(Math.sqrt(8*t+1)+1)/2;if(!Number.isInteger(r))throw new TypeError(`This array is not a compact representation of a DistanceMatrix, ${JSON.stringify(e)}`);const n=new this(r);for(let o=1,a=0,s=0;s<t;s++)n.set(o,a,e[s]),++o>=r&&(o=++a+1);return n}}le.prototype.klassSubType="DistanceMatrix";class Mt extends J{constructor(e,t,r){super(),this.matrix=e,this.rows=t,this.columns=r}}class Li extends Mt{constructor(e,t){Nt(e,t),super(e,e.rows,1),this.column=t}set(e,t,r){return this.matrix.set(e,this.column,r),this}get(e){return this.matrix.get(e,this.column)}}class Di extends Mt{constructor(e,t){De(e,t),super(e,e.rows,t.length),this.columnIndices=t}set(e,t,r){return this.matrix.set(e,this.columnIndices[t],r),this}get(e,t){return this.matrix.get(e,this.columnIndices[t])}}class Pi extends Mt{constructor(e){super(e,e.rows,e.columns)}set(e,t,r){return this.matrix.set(e,this.columns-t-1,r),this}get(e,t){return this.matrix.get(e,this.columns-t-1)}}class ji extends Mt{constructor(e){super(e,e.rows,e.columns)}set(e,t,r){return this.matrix.set(this.rows-e-1,t,r),this}get(e,t){return this.matrix.get(this.rows-e-1,t)}}class Fi extends Mt{constructor(e,t){xt(e,t),super(e,1,e.columns),this.row=t}set(e,t,r){return this.matrix.set(this.row,t,r),this}get(e,t){return this.matrix.get(this.row,t)}}class Ci extends Mt{constructor(e,t){Le(e,t),super(e,t.length,e.columns),this.rowIndices=t}set(e,t,r){return this.matrix.set(this.rowIndices[e],t,r),this}get(e,t){return this.matrix.get(this.rowIndices[e],t)}}class he extends Mt{constructor(e,t,r){Le(e,t),De(e,r),super(e,t.length,r.length),this.rowIndices=t,this.columnIndices=r}set(e,t,r){return this.matrix.set(this.rowIndices[e],this.columnIndices[t],r),this}get(e,t){return this.matrix.get(this.rowIndices[e],this.columnIndices[t])}}class qi extends Mt{constructor(e,t,r,n,o){Pe(e,t,r,n,o),super(e,r-t+1,o-n+1),this.startRow=t,this.startColumn=n}set(e,t,r){return this.matrix.set(this.startRow+e,this.startColumn+t,r),this}get(e,t){return this.matrix.get(this.startRow+e,this.startColumn+t)}}class $i extends Mt{constructor(e){super(e,e.columns,e.rows)}set(e,t,r){return this.matrix.set(t,e,r),this}get(e,t){return this.matrix.get(t,e)}}class Mr extends J{constructor(e,t={}){const{rows:r=1}=t;if(e.length%r!==0)throw new Error("the data length is not divisible by the number of rows");super(),this.rows=r,this.columns=e.length/r,this.data=e}set(e,t,r){let n=this._calculateIndex(e,t);return this.data[n]=r,this}get(e,t){let r=this._calculateIndex(e,t);return this.data[r]}_calculateIndex(e,t){return e*this.columns+t}}class Et extends J{constructor(e){super(),this.data=e,this.rows=e.length,this.columns=e[0].length}set(e,t,r){return this.data[e][t]=r,this}get(e,t){return this.data[e][t]}}function Bi(i,e){if(wt.isAnyArray(i))return i[0]&&wt.isAnyArray(i[0])?new Et(i):new Mr(i,e);throw new Error("the argument is not an array")}class de{constructor(e){e=Et.checkMatrix(e);let t=e.clone(),r=t.rows,n=t.columns,o=new Float64Array(r),a=1,s,f,u,l,h,d,g,v,p;for(s=0;s<r;s++)o[s]=s;for(v=new Float64Array(r),f=0;f<n;f++){for(s=0;s<r;s++)v[s]=t.get(s,f);for(s=0;s<r;s++){for(p=Math.min(s,f),h=0,u=0;u<p;u++)h+=t.get(s,u)*v[u];v[s]-=h,t.set(s,f,v[s])}for(l=f,s=f+1;s<r;s++)Math.abs(v[s])>Math.abs(v[l])&&(l=s);if(l!==f){for(u=0;u<n;u++)d=t.get(l,u),t.set(l,u,t.get(f,u)),t.set(f,u,d);g=o[l],o[l]=o[f],o[f]=g,a=-a}if(f<r&&t.get(f,f)!==0)for(s=f+1;s<r;s++)t.set(s,f,t.get(s,f)/t.get(f,f))}this.LU=t,this.pivotVector=o,this.pivotSign=a}isSingular(){let e=this.LU,t=e.columns;for(let r=0;r<t;r++)if(e.get(r,r)===0)return!0;return!1}solve(e){e=j.checkMatrix(e);let t=this.LU;if(t.rows!==e.rows)throw new Error("Invalid matrix dimensions");if(this.isSingular())throw new Error("LU matrix is singular");let n=e.columns,o=e.subMatrixRow(this.pivotVector,0,n-1),a=t.columns,s,f,u;for(u=0;u<a;u++)for(s=u+1;s<a;s++)for(f=0;f<n;f++)o.set(s,f,o.get(s,f)-o.get(u,f)*t.get(s,u));for(u=a-1;u>=0;u--){for(f=0;f<n;f++)o.set(u,f,o.get(u,f)/t.get(u,u));for(s=0;s<u;s++)for(f=0;f<n;f++)o.set(s,f,o.get(s,f)-o.get(u,f)*t.get(s,u))}return o}get determinant(){let e=this.LU;if(!e.isSquare())throw new Error("Matrix must be square");let t=this.pivotSign,r=e.columns;for(let n=0;n<r;n++)t*=e.get(n,n);return t}get lowerTriangularMatrix(){let e=this.LU,t=e.rows,r=e.columns,n=new j(t,r);for(let o=0;o<t;o++)for(let a=0;a<r;a++)o>a?n.set(o,a,e.get(o,a)):o===a?n.set(o,a,1):n.set(o,a,0);return n}get upperTriangularMatrix(){let e=this.LU,t=e.rows,r=e.columns,n=new j(t,r);for(let o=0;o<t;o++)for(let a=0;a<r;a++)o<=a?n.set(o,a,e.get(o,a)):n.set(o,a,0);return n}get pivotPermutationVector(){return Array.from(this.pivotVector)}}function St(i,e){let t=0;return Math.abs(i)>Math.abs(e)?(t=e/i,Math.abs(i)*Math.sqrt(1+t*t)):e!==0?(t=i/e,Math.abs(e)*Math.sqrt(1+t*t)):0}class je{constructor(e){e=Et.checkMatrix(e);let t=e.clone(),r=e.rows,n=e.columns,o=new Float64Array(n),a,s,f,u;for(f=0;f<n;f++){let l=0;for(a=f;a<r;a++)l=St(l,t.get(a,f));if(l!==0){for(t.get(f,f)<0&&(l=-l),a=f;a<r;a++)t.set(a,f,t.get(a,f)/l);for(t.set(f,f,t.get(f,f)+1),s=f+1;s<n;s++){for(u=0,a=f;a<r;a++)u+=t.get(a,f)*t.get(a,s);for(u=-u/t.get(f,f),a=f;a<r;a++)t.set(a,s,t.get(a,s)+u*t.get(a,f))}}o[f]=-l}this.QR=t,this.Rdiag=o}solve(e){e=j.checkMatrix(e);let t=this.QR,r=t.rows;if(e.rows!==r)throw new Error("Matrix row dimensions must agree");if(!this.isFullRank())throw new Error("Matrix is rank deficient");let n=e.columns,o=e.clone(),a=t.columns,s,f,u,l;for(u=0;u<a;u++)for(f=0;f<n;f++){for(l=0,s=u;s<r;s++)l+=t.get(s,u)*o.get(s,f);for(l=-l/t.get(u,u),s=u;s<r;s++)o.set(s,f,o.get(s,f)+l*t.get(s,u))}for(u=a-1;u>=0;u--){for(f=0;f<n;f++)o.set(u,f,o.get(u,f)/this.Rdiag[u]);for(s=0;s<u;s++)for(f=0;f<n;f++)o.set(s,f,o.get(s,f)-o.get(u,f)*t.get(s,u))}return o.subMatrix(0,a-1,0,n-1)}isFullRank(){let e=this.QR.columns;for(let t=0;t<e;t++)if(this.Rdiag[t]===0)return!1;return!0}get upperTriangularMatrix(){let e=this.QR,t=e.columns,r=new j(t,t),n,o;for(n=0;n<t;n++)for(o=0;o<t;o++)n<o?r.set(n,o,e.get(n,o)):n===o?r.set(n,o,this.Rdiag[n]):r.set(n,o,0);return r}get orthogonalMatrix(){let e=this.QR,t=e.rows,r=e.columns,n=new j(t,r),o,a,s,f;for(s=r-1;s>=0;s--){for(o=0;o<t;o++)n.set(o,s,0);for(n.set(s,s,1),a=s;a<r;a++)if(e.get(s,s)!==0){for(f=0,o=s;o<t;o++)f+=e.get(o,s)*n.get(o,a);for(f=-f/e.get(s,s),o=s;o<t;o++)n.set(o,a,n.get(o,a)+f*e.get(o,s))}}return n}}let $t=class{constructor(e,t={}){if(e=Et.checkMatrix(e),e.isEmpty())throw new Error("Matrix must be non-empty");let r=e.rows,n=e.columns;const{computeLeftSingularVectors:o=!0,computeRightSingularVectors:a=!0,autoTranspose:s=!1}=t;let f=!!o,u=!!a,l=!1,h;if(r<n)if(!s)h=e.clone(),console.warn("Computing SVD on a matrix with more columns than rows. Consider enabling autoTranspose");else{h=e.transpose(),r=h.rows,n=h.columns,l=!0;let y=f;f=u,u=y}else h=e.clone();let d=Math.min(r,n),g=Math.min(r+1,n),v=new Float64Array(g),p=new j(r,d),w=new j(n,n),c=new Float64Array(n),m=new Float64Array(r),E=new Float64Array(g);for(let y=0;y<g;y++)E[y]=y;let x=Math.min(r-1,n),N=Math.max(0,Math.min(n-2,r)),z=Math.max(x,N);for(let y=0;y<z;y++){if(y<x){v[y]=0;for(let S=y;S<r;S++)v[y]=St(v[y],h.get(S,y));if(v[y]!==0){h.get(y,y)<0&&(v[y]=-v[y]);for(let S=y;S<r;S++)h.set(S,y,h.get(S,y)/v[y]);h.set(y,y,h.get(y,y)+1)}v[y]=-v[y]}for(let S=y+1;S<n;S++){if(y<x&&v[y]!==0){let _=0;for(let M=y;M<r;M++)_+=h.get(M,y)*h.get(M,S);_=-_/h.get(y,y);for(let M=y;M<r;M++)h.set(M,S,h.get(M,S)+_*h.get(M,y))}c[S]=h.get(y,S)}if(f&&y<x)for(let S=y;S<r;S++)p.set(S,y,h.get(S,y));if(y<N){c[y]=0;for(let S=y+1;S<n;S++)c[y]=St(c[y],c[S]);if(c[y]!==0){c[y+1]<0&&(c[y]=0-c[y]);for(let S=y+1;S<n;S++)c[S]/=c[y];c[y+1]+=1}if(c[y]=-c[y],y+1<r&&c[y]!==0){for(let S=y+1;S<r;S++)m[S]=0;for(let S=y+1;S<r;S++)for(let _=y+1;_<n;_++)m[S]+=c[_]*h.get(S,_);for(let S=y+1;S<n;S++){let _=-c[S]/c[y+1];for(let M=y+1;M<r;M++)h.set(M,S,h.get(M,S)+_*m[M])}}if(u)for(let S=y+1;S<n;S++)w.set(S,y,c[S])}}let k=Math.min(n,r+1);if(x<n&&(v[x]=h.get(x,x)),r<k&&(v[k-1]=0),N+1<k&&(c[N]=h.get(N,k-1)),c[k-1]=0,f){for(let y=x;y<d;y++){for(let S=0;S<r;S++)p.set(S,y,0);p.set(y,y,1)}for(let y=x-1;y>=0;y--)if(v[y]!==0){for(let S=y+1;S<d;S++){let _=0;for(let M=y;M<r;M++)_+=p.get(M,y)*p.get(M,S);_=-_/p.get(y,y);for(let M=y;M<r;M++)p.set(M,S,p.get(M,S)+_*p.get(M,y))}for(let S=y;S<r;S++)p.set(S,y,-p.get(S,y));p.set(y,y,1+p.get(y,y));for(let S=0;S<y-1;S++)p.set(S,y,0)}else{for(let S=0;S<r;S++)p.set(S,y,0);p.set(y,y,1)}}if(u)for(let y=n-1;y>=0;y--){if(y<N&&c[y]!==0)for(let S=y+1;S<n;S++){let _=0;for(let M=y+1;M<n;M++)_+=w.get(M,y)*w.get(M,S);_=-_/w.get(y+1,y);for(let M=y+1;M<n;M++)w.set(M,S,w.get(M,S)+_*w.get(M,y))}for(let S=0;S<n;S++)w.set(S,y,0);w.set(y,y,1)}let b=k-1,A=Number.EPSILON;for(;k>0;){let y,S;for(y=k-2;y>=-1&&y!==-1;y--){const _=Number.MIN_VALUE+A*Math.abs(v[y]+Math.abs(v[y+1]));if(Math.abs(c[y])<=_||Number.isNaN(c[y])){c[y]=0;break}}if(y===k-2)S=4;else{let _;for(_=k-1;_>=y&&_!==y;_--){let M=(_!==k?Math.abs(c[_]):0)+(_!==y+1?Math.abs(c[_-1]):0);if(Math.abs(v[_])<=A*M){v[_]=0;break}}_===y?S=3:_===k-1?S=1:(S=2,y=_)}switch(y++,S){case 1:{let _=c[k-2];c[k-2]=0;for(let M=k-2;M>=y;M--){let T=St(v[M],_),L=v[M]/T,D=_/T;if(v[M]=T,M!==y&&(_=-D*c[M-1],c[M-1]=L*c[M-1]),u)for(let $=0;$<n;$++)T=L*w.get($,M)+D*w.get($,k-1),w.set($,k-1,-D*w.get($,M)+L*w.get($,k-1)),w.set($,M,T)}break}case 2:{let _=c[y-1];c[y-1]=0;for(let M=y;M<k;M++){let T=St(v[M],_),L=v[M]/T,D=_/T;if(v[M]=T,_=-D*c[M],c[M]=L*c[M],f)for(let $=0;$<r;$++)T=L*p.get($,M)+D*p.get($,y-1),p.set($,y-1,-D*p.get($,M)+L*p.get($,y-1)),p.set($,M,T)}break}case 3:{const _=Math.max(Math.abs(v[k-1]),Math.abs(v[k-2]),Math.abs(c[k-2]),Math.abs(v[y]),Math.abs(c[y])),M=v[k-1]/_,T=v[k-2]/_,L=c[k-2]/_,D=v[y]/_,$=c[y]/_,C=((T+M)*(T-M)+L*L)/2,G=M*L*(M*L);let V=0;(C!==0||G!==0)&&(C<0?V=0-Math.sqrt(C*C+G):V=Math.sqrt(C*C+G),V=G/(C+V));let X=(D+M)*(D-M)+V,W=D*$;for(let P=y;P<k-1;P++){let I=St(X,W);I===0&&(I=Number.MIN_VALUE);let U=X/I,q=W/I;if(P!==y&&(c[P-1]=I),X=U*v[P]+q*c[P],c[P]=U*c[P]-q*v[P],W=q*v[P+1],v[P+1]=U*v[P+1],u)for(let B=0;B<n;B++)I=U*w.get(B,P)+q*w.get(B,P+1),w.set(B,P+1,-q*w.get(B,P)+U*w.get(B,P+1)),w.set(B,P,I);if(I=St(X,W),I===0&&(I=Number.MIN_VALUE),U=X/I,q=W/I,v[P]=I,X=U*c[P]+q*v[P+1],v[P+1]=-q*c[P]+U*v[P+1],W=q*c[P+1],c[P+1]=U*c[P+1],f&&P<r-1)for(let B=0;B<r;B++)I=U*p.get(B,P)+q*p.get(B,P+1),p.set(B,P+1,-q*p.get(B,P)+U*p.get(B,P+1)),p.set(B,P,I)}c[k-2]=X;break}case 4:{if(v[y]<=0&&(v[y]=v[y]<0?-v[y]:0,u))for(let _=0;_<=b;_++)w.set(_,y,-w.get(_,y));for(;y<b&&!(v[y]>=v[y+1]);){let _=v[y];if(v[y]=v[y+1],v[y+1]=_,u&&y<n-1)for(let M=0;M<n;M++)_=w.get(M,y+1),w.set(M,y+1,w.get(M,y)),w.set(M,y,_);if(f&&y<r-1)for(let M=0;M<r;M++)_=p.get(M,y+1),p.set(M,y+1,p.get(M,y)),p.set(M,y,_);y++}k--;break}}}if(l){let y=w;w=p,p=y}this.m=r,this.n=n,this.s=v,this.U=p,this.V=w}solve(e){let t=e,r=this.threshold,n=this.s.length,o=j.zeros(n,n);for(let d=0;d<n;d++)Math.abs(this.s[d])<=r?o.set(d,d,0):o.set(d,d,1/this.s[d]);let a=this.U,s=this.rightSingularVectors,f=s.mmul(o),u=s.rows,l=a.rows,h=j.zeros(u,l);for(let d=0;d<u;d++)for(let g=0;g<l;g++){let v=0;for(let p=0;p<n;p++)v+=f.get(d,p)*a.get(g,p);h.set(d,g,v)}return h.mmul(t)}solveForDiagonal(e){return this.solve(j.diag(e))}inverse(){let e=this.V,t=this.threshold,r=e.rows,n=e.columns,o=new j(r,this.s.length);for(let l=0;l<r;l++)for(let h=0;h<n;h++)Math.abs(this.s[h])>t&&o.set(l,h,e.get(l,h)/this.s[h]);let a=this.U,s=a.rows,f=a.columns,u=new j(r,s);for(let l=0;l<r;l++)for(let h=0;h<s;h++){let d=0;for(let g=0;g<f;g++)d+=o.get(l,g)*a.get(h,g);u.set(l,h,d)}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 e=Math.max(this.m,this.n)*this.s[0]*Number.EPSILON,t=0,r=this.s;for(let n=0,o=r.length;n<o;n++)r[n]>e&&t++;return t}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 j.diag(this.s)}};function Vi(i,e=!1){return i=Et.checkMatrix(i),e?new $t(i).inverse():Sr(i,j.eye(i.rows))}function Sr(i,e,t=!1){return i=Et.checkMatrix(i),e=Et.checkMatrix(e),t?new $t(i).solve(e):i.isSquare()?new de(i).solve(e):new je(i).solve(e)}function ce(i){if(i=j.checkMatrix(i),i.isSquare()){if(i.columns===0)return 1;let e,t,r,n;if(i.columns===2)return e=i.get(0,0),t=i.get(0,1),r=i.get(1,0),n=i.get(1,1),e*n-t*r;if(i.columns===3){let o,a,s;return o=new he(i,[1,2],[1,2]),a=new he(i,[1,2],[0,2]),s=new he(i,[1,2],[0,1]),e=i.get(0,0),t=i.get(0,1),r=i.get(0,2),e*ce(o)-t*ce(a)+r*ce(s)}else return new de(i).determinant}else throw Error("determinant can only be calculated for a square matrix")}function Ui(i,e){let t=[];for(let r=0;r<i;r++)r!==e&&t.push(r);return t}function Wi(i,e,t,r=1e-9,n=1e-9){if(i>n)return new Array(e.rows+1).fill(0);{let o=e.addRow(t,[0]);for(let a=0;a<o.rows;a++)Math.abs(o.get(a,0))<r&&o.set(a,0,0);return o.to1DArray()}}function Yi(i,e={}){const{thresholdValue:t=1e-9,thresholdError:r=1e-9}=e;i=j.checkMatrix(i);let n=i.rows,o=new j(n,n);for(let a=0;a<n;a++){let s=j.columnVector(i.getRow(a)),f=i.subMatrixRow(Ui(n,a)).transpose(),l=new $t(f).solve(s),h=j.sub(s,f.mmul(l)).abs().max();o.setRow(a,Wi(h,l,a,t,r))}return o}function Gi(i,e=Number.EPSILON){if(i=j.checkMatrix(i),i.isEmpty())return i.transpose();let t=new $t(i,{autoTranspose:!0}),r=t.leftSingularVectors,n=t.rightSingularVectors,o=t.diagonal;for(let a=0;a<o.length;a++)Math.abs(o[a])>e?o[a]=1/o[a]:o[a]=0;return n.mmul(j.diag(o).mmul(r.transpose()))}function Xi(i,e=i,t={}){i=new j(i);let r=!1;if(typeof e=="object"&&!j.isMatrix(e)&&!wt.isAnyArray(e)?(t=e,e=i,r=!0):e=new j(e),i.rows!==e.rows)throw new TypeError("Both matrices must have the same number of rows");const{center:n=!0}=t;n&&(i=i.center("column"),r||(e=e.center("column")));const o=i.transpose().mmul(e);for(let a=0;a<o.rows;a++)for(let s=0;s<o.columns;s++)o.set(a,s,o.get(a,s)*(1/(i.rows-1)));return o}function Qi(i,e=i,t={}){i=new j(i);let r=!1;if(typeof e=="object"&&!j.isMatrix(e)&&!wt.isAnyArray(e)?(t=e,e=i,r=!0):e=new j(e),i.rows!==e.rows)throw new TypeError("Both matrices must have the same number of rows");const{center:n=!0,scale:o=!0}=t;n&&(i.center("column"),r||e.center("column")),o&&(i.scale("column"),r||e.scale("column"));const a=i.standardDeviation("column",{unbiased:!0}),s=r?a:e.standardDeviation("column",{unbiased:!0}),f=i.transpose().mmul(e);for(let u=0;u<f.rows;u++)for(let l=0;l<f.columns;l++)f.set(u,l,f.get(u,l)*(1/(a[u]*s[l]))*(1/(i.rows-1)));return f}class kr{constructor(e,t={}){const{assumeSymmetric:r=!1}=t;if(e=Et.checkMatrix(e),!e.isSquare())throw new Error("Matrix is not a square matrix");if(e.isEmpty())throw new Error("Matrix must be non-empty");let n=e.columns,o=new j(n,n),a=new Float64Array(n),s=new Float64Array(n),f=e,u,l,h=!1;if(r?h=!0:h=e.isSymmetric(),h){for(u=0;u<n;u++)for(l=0;l<n;l++)o.set(u,l,f.get(u,l));Ji(n,s,a,o),Zi(n,s,a,o)}else{let d=new j(n,n),g=new Float64Array(n);for(l=0;l<n;l++)for(u=0;u<n;u++)d.set(u,l,f.get(u,l));Ki(n,d,g,o),Hi(n,s,a,o,d)}this.n=n,this.e=s,this.d=a,this.V=o}get realEigenvalues(){return Array.from(this.d)}get imaginaryEigenvalues(){return Array.from(this.e)}get eigenvectorMatrix(){return this.V}get diagonalMatrix(){let e=this.n,t=this.e,r=this.d,n=new j(e,e),o,a;for(o=0;o<e;o++){for(a=0;a<e;a++)n.set(o,a,0);n.set(o,o,r[o]),t[o]>0?n.set(o,o+1,t[o]):t[o]<0&&n.set(o,o-1,t[o])}return n}}function Ji(i,e,t,r){let n,o,a,s,f,u,l,h;for(f=0;f<i;f++)t[f]=r.get(i-1,f);for(s=i-1;s>0;s--){for(h=0,a=0,u=0;u<s;u++)h=h+Math.abs(t[u]);if(h===0)for(e[s]=t[s-1],f=0;f<s;f++)t[f]=r.get(s-1,f),r.set(s,f,0),r.set(f,s,0);else{for(u=0;u<s;u++)t[u]/=h,a+=t[u]*t[u];for(n=t[s-1],o=Math.sqrt(a),n>0&&(o=-o),e[s]=h*o,a=a-n*o,t[s-1]=n-o,f=0;f<s;f++)e[f]=0;for(f=0;f<s;f++){for(n=t[f],r.set(f,s,n),o=e[f]+r.get(f,f)*n,u=f+1;u<=s-1;u++)o+=r.get(u,f)*t[u],e[u]+=r.get(u,f)*n;e[f]=o}for(n=0,f=0;f<s;f++)e[f]/=a,n+=e[f]*t[f];for(l=n/(a+a),f=0;f<s;f++)e[f]-=l*t[f];for(f=0;f<s;f++){for(n=t[f],o=e[f],u=f;u<=s-1;u++)r.set(u,f,r.get(u,f)-(n*e[u]+o*t[u]));t[f]=r.get(s-1,f),r.set(s,f,0)}}t[s]=a}for(s=0;s<i-1;s++){if(r.set(i-1,s,r.get(s,s)),r.set(s,s,1),a=t[s+1],a!==0){for(u=0;u<=s;u++)t[u]=r.get(u,s+1)/a;for(f=0;f<=s;f++){for(o=0,u=0;u<=s;u++)o+=r.get(u,s+1)*r.get(u,f);for(u=0;u<=s;u++)r.set(u,f,r.get(u,f)-o*t[u])}}for(u=0;u<=s;u++)r.set(u,s+1,0)}for(f=0;f<i;f++)t[f]=r.get(i-1,f),r.set(i-1,f,0);r.set(i-1,i-1,1),e[0]=0}function Zi(i,e,t,r){let n,o,a,s,f,u,l,h,d,g,v,p,w,c,m,E;for(a=1;a<i;a++)e[a-1]=e[a];e[i-1]=0;let x=0,N=0,z=Number.EPSILON;for(u=0;u<i;u++){for(N=Math.max(N,Math.abs(t[u])+Math.abs(e[u])),l=u;l<i&&!(Math.abs(e[l])<=z*N);)l++;if(l>u)do{for(n=t[u],h=(t[u+1]-n)/(2*e[u]),d=St(h,1),h<0&&(d=-d),t[u]=e[u]/(h+d),t[u+1]=e[u]*(h+d),g=t[u+1],o=n-t[u],a=u+2;a<i;a++)t[a]-=o;for(x=x+o,h=t[l],v=1,p=v,w=v,c=e[u+1],m=0,E=0,a=l-1;a>=u;a--)for(w=p,p=v,E=m,n=v*e[a],o=v*h,d=St(h,e[a]),e[a+1]=m*d,m=e[a]/d,v=h/d,h=v*t[a]-m*n,t[a+1]=o+m*(v*n+m*t[a]),f=0;f<i;f++)o=r.get(f,a+1),r.set(f,a+1,m*r.get(f,a)+v*o),r.set(f,a,v*r.get(f,a)-m*o);h=-m*E*w*c*e[u]/g,e[u]=m*h,t[u]=v*h}while(Math.abs(e[u])>z*N);t[u]=t[u]+x,e[u]=0}for(a=0;a<i-1;a++){for(f=a,h=t[a],s=a+1;s<i;s++)t[s]<h&&(f=s,h=t[s]);if(f!==a)for(t[f]=t[a],t[a]=h,s=0;s<i;s++)h=r.get(s,a),r.set(s,a,r.get(s,f)),r.set(s,f,h)}}function Ki(i,e,t,r){let n=0,o=i-1,a,s,f,u,l,h,d;for(h=n+1;h<=o-1;h++){for(d=0,u=h;u<=o;u++)d=d+Math.abs(e.get(u,h-1));if(d!==0){for(f=0,u=o;u>=h;u--)t[u]=e.get(u,h-1)/d,f+=t[u]*t[u];for(s=Math.sqrt(f),t[h]>0&&(s=-s),f=f-t[h]*s,t[h]=t[h]-s,l=h;l<i;l++){for(a=0,u=o;u>=h;u--)a+=t[u]*e.get(u,l);for(a=a/f,u=h;u<=o;u++)e.set(u,l,e.get(u,l)-a*t[u])}for(u=0;u<=o;u++){for(a=0,l=o;l>=h;l--)a+=t[l]*e.get(u,l);for(a=a/f,l=h;l<=o;l++)e.set(u,l,e.get(u,l)-a*t[l])}t[h]=d*t[h],e.set(h,h-1,d*s)}}for(u=0;u<i;u++)for(l=0;l<i;l++)r.set(u,l,u===l?1:0);for(h=o-1;h>=n+1;h--)if(e.get(h,h-1)!==0){for(u=h+1;u<=o;u++)t[u]=e.get(u,h-1);for(l=h;l<=o;l++){for(s=0,u=h;u<=o;u++)s+=t[u]*r.get(u,l);for(s=s/t[h]/e.get(h,h-1),u=h;u<=o;u++)r.set(u,l,r.get(u,l)+s*t[u])}}}function Hi(i,e,t,r,n){let o=i-1,a=0,s=i-1,f=Number.EPSILON,u=0,l=0,h=0,d=0,g=0,v=0,p=0,w=0,c,m,E,x,N,z,k,b,A,y,S,_,M,T,L;for(c=0;c<i;c++)for((c<a||c>s)&&(t[c]=n.get(c,c),e[c]=0),m=Math.max(c-1,0);m<i;m++)l=l+Math.abs(n.get(c,m));for(;o>=a;){for(x=o;x>a&&(v=Math.abs(n.get(x-1,x-1))+Math.abs(n.get(x,x)),v===0&&(v=l),!(Math.abs(n.get(x,x-1))<f*v));)x--;if(x===o)n.set(o,o,n.get(o,o)+u),t[o]=n.get(o,o),e[o]=0,o--,w=0;else if(x===o-1){if(k=n.get(o,o-1)*n.get(o-1,o),h=(n.get(o-1,o-1)-n.get(o,o))/2,d=h*h+k,p=Math.sqrt(Math.abs(d)),n.set(o,o,n.get(o,o)+u),n.set(o-1,o-1,n.get(o-1,o-1)+u),b=n.get(o,o),d>=0){for(p=h>=0?h+p:h-p,t[o-1]=b+p,t[o]=t[o-1],p!==0&&(t[o]=b-k/p),e[o-1]=0,e[o]=0,b=n.get(o,o-1),v=Math.abs(b)+Math.abs(p),h=b/v,d=p/v,g=Math.sqrt(h*h+d*d),h=h/g,d=d/g,m=o-1;m<i;m++)p=n.get(o-1,m),n.set(o-1,m,d*p+h*n.get(o,m)),n.set(o,m,d*n.get(o,m)-h*p);for(c=0;c<=o;c++)p=n.get(c,o-1),n.set(c,o-1,d*p+h*n.get(c,o)),n.set(c,o,d*n.get(c,o)-h*p);for(c=a;c<=s;c++)p=r.get(c,o-1),r.set(c,o-1,d*p+h*r.get(c,o)),r.set(c,o,d*r.get(c,o)-h*p)}else t[o-1]=b+h,t[o]=b+h,e[o-1]=p,e[o]=-p;o=o-2,w=0}else{if(b=n.get(o,o),A=0,k=0,x<o&&(A=n.get(o-1,o-1),k=n.get(o,o-1)*n.get(o-1,o)),w===10){for(u+=b,c=a;c<=o;c++)n.set(c,c,n.get(c,c)-b);v=Math.abs(n.get(o,o-1))+Math.abs(n.get(o-1,o-2)),b=A=.75*v,k=-.4375*v*v}if(w===30&&(v=(A-b)/2,v=v*v+k,v>0)){for(v=Math.sqrt(v),A<b&&(v=-v),v=b-k/((A-b)/2+v),c=a;c<=o;c++)n.set(c,c,n.get(c,c)-v);u+=v,b=A=k=.964}for(w=w+1,N=o-2;N>=x&&(p=n.get(N,N),g=b-p,v=A-p,h=(g*v-k)/n.get(N+1,N)+n.get(N,N+1),d=n.get(N+1,N+1)-p-g-v,g=n.get(N+2,N+1),v=Math.abs(h)+Math.abs(d)+Math.abs(g),h=h/v,d=d/v,g=g/v,!(N===x||Math.abs(n.get(N,N-1))*(Math.abs(d)+Math.abs(g))<f*(Math.abs(h)*(Math.abs(n.get(N-1,N-1))+Math.abs(p)+Math.abs(n.get(N+1,N+1))))));)N--;for(c=N+2;c<=o;c++)n.set(c,c-2,0),c>N+2&&n.set(c,c-3,0);for(E=N;E<=o-1&&(T=E!==o-1,E!==N&&(h=n.get(E,E-1),d=n.get(E+1,E-1),g=T?n.get(E+2,E-1):0,b=Math.abs(h)+Math.abs(d)+Math.abs(g),b!==0&&(h=h/b,d=d/b,g=g/b)),b!==0);E++)if(v=Math.sqrt(h*h+d*d+g*g),h<0&&(v=-v),v!==0){for(E!==N?n.set(E,E-1,-v*b):x!==N&&n.set(E,E-1,-n.get(E,E-1)),h=h+v,b=h/v,A=d/v,p=g/v,d=d/h,g=g/h,m=E;m<i;m++)h=n.get(E,m)+d*n.get(E+1,m),T&&(h=h+g*n.get(E+2,m),n.set(E+2,m,n.get(E+2,m)-h*p)),n.set(E,m,n.get(E,m)-h*b),n.set(E+1,m,n.get(E+1,m)-h*A);for(c=0;c<=Math.min(o,E+3);c++)h=b*n.get(c,E)+A*n.get(c,E+1),T&&(h=h+p*n.get(c,E+2),n.set(c,E+2,n.get(c,E+2)-h*g)),n.set(c,E,n.get(c,E)-h),n.set(c,E+1,n.get(c,E+1)-h*d);for(c=a;c<=s;c++)h=b*r.get(c,E)+A*r.get(c,E+1),T&&(h=h+p*r.get(c,E+2),r.set(c,E+2,r.get(c,E+2)-h*g)),r.set(c,E,r.get(c,E)-h),r.set(c,E+1,r.get(c,E+1)-h*d)}}}if(l!==0){for(o=i-1;o>=0;o--)if(h=t[o],d=e[o],d===0)for(x=o,n.set(o,o,1),c=o-1;c>=0;c--){for(k=n.get(c,c)-h,g=0,m=x;m<=o;m++)g=g+n.get(c,m)*n.get(m,o);if(e[c]<0)p=k,v=g;else if(x=c,e[c]===0?n.set(c,o,k!==0?-g/k:-g/(f*l)):(b=n.get(c,c+1),A=n.get(c+1,c),d=(t[c]-h)*(t[c]-h)+e[c]*e[c],z=(b*v-p*g)/d,n.set(c,o,z),n.set(c+1,o,Math.abs(b)>Math.abs(p)?(-g-k*z)/b:(-v-A*z)/p)),z=Math.abs(n.get(c,o)),f*z*z>1)for(m=c;m<=o;m++)n.set(m,o,n.get(m,o)/z)}else if(d<0)for(x=o-1,Math.abs(n.get(o,o-1))>Math.abs(n.get(o-1,o))?(n.set(o-1,o-1,d/n.get(o,o-1)),n.set(o-1,o,-(n.get(o,o)-h)/n.get(o,o-1))):(L=ge(0,-n.get(o-1,o),n.get(o-1,o-1)-h,d),n.set(o-1,o-1,L[0]),n.set(o-1,o,L[1])),n.set(o,o-1,0),n.set(o,o,1),c=o-2;c>=0;c--){for(y=0,S=0,m=x;m<=o;m++)y=y+n.get(c,m)*n.get(m,o-1),S=S+n.get(c,m)*n.get(m,o);if(k=n.get(c,c)-h,e[c]<0)p=k,g=y,v=S;else if(x=c,e[c]===0?(L=ge(-y,-S,k,d),n.set(c,o-1,L[0]),n.set(c,o,L[1])):(b=n.get(c,c+1),A=n.get(c+1,c),_=(t[c]-h)*(t[c]-h)+e[c]*e[c]-d*d,M=(t[c]-h)*2*d,_===0&&M===0&&(_=f*l*(Math.abs(k)+Math.abs(d)+Math.abs(b)+Math.abs(A)+Math.abs(p))),L=ge(b*g-p*y+d*S,b*v-p*S-d*y,_,M),n.set(c,o-1,L[0]),n.set(c,o,L[1]),Math.abs(b)>Math.abs(p)+Math.abs(d)?(n.set(c+1,o-1,(-y-k*n.get(c,o-1)+d*n.get(c,o))/b),n.set(c+1,o,(-S-k*n.get(c,o)-d*n.get(c,o-1))/b)):(L=ge(-g-A*n.get(c,o-1),-v-A*n.get(c,o),p,d),n.set(c+1,o-1,L[0]),n.set(c+1,o,L[1]))),z=Math.max(Math.abs(n.get(c,o-1)),Math.abs(n.get(c,o))),f*z*z>1)for(m=c;m<=o;m++)n.set(m,o-1,n.get(m,o-1)/z),n.set(m,o,n.get(m,o)/z)}for(c=0;c<i;c++)if(c<a||c>s)for(m=c;m<i;m++)r.set(c,m,n.get(c,m));for(m=i-1;m>=a;m--)for(c=a;c<=s;c++){for(p=0,E=a;E<=Math.min(m,s);E++)p=p+r.get(c,E)*n.get(E,m);r.set(c,m,p)}}}function ge(i,e,t,r){let n,o;return Math.abs(t)>Math.abs(r)?(n=r/t,o=t+n*r,[(i+n*e)/o,(e-n*i)/o]):(n=t/r,o=r+n*t,[(n*i+e)/o,(n*e-i)/o])}class _r{constructor(e){if(e=Et.checkMatrix(e),!e.isSymmetric())throw new Error("Matrix is not symmetric");let t=e,r=t.rows,n=new j(r,r),o=!0,a,s,f;for(s=0;s<r;s++){let u=0;for(f=0;f<s;f++){let l=0;for(a=0;a<f;a++)l+=n.get(f,a)*n.get(s,a);l=(t.get(s,f)-l)/n.get(f,f),n.set(s,f,l),u=u+l*l}for(u=t.get(s,s)-u,o&=u>0,n.set(s,s,Math.sqrt(Math.max(u,0))),f=s+1;f<r;f++)n.set(s,f,0)}this.L=n,this.positiveDefinite=!!o}isPositiveDefinite(){return this.positiveDefinite}solve(e){e=Et.checkMatrix(e);let t=this.L,r=t.rows;if(e.rows!==r)throw new Error("Matrix dimensions do not match");if(this.isPositiveDefinite()===!1)throw new Error("Matrix is not positive definite");let n=e.columns,o=e.clone(),a,s,f;for(f=0;f<r;f++)for(s=0;s<n;s++){for(a=0;a<f;a++)o.set(f,s,o.get(f,s)-o.get(a,s)*t.get(f,a));o.set(f,s,o.get(f,s)/t.get(f,f))}for(f=r-1;f>=0;f--)for(s=0;s<n;s++){for(a=f+1;a<r;a++)o.set(f,s,o.get(f,s)-o.get(a,s)*t.get(a,f));o.set(f,s,o.get(f,s)/t.get(f,f))}return o}get lowerTriangularMatrix(){return this.L}}class zr{constructor(e,t={}){e=Et.checkMatrix(e);let{Y:r}=t;const{scaleScores:n=!1,maxIterations:o=1e3,terminationCriteria:a=1e-10}=t;let s;if(r){if(wt.isAnyArray(r)&&typeof r[0]=="number"?r=j.columnVector(r):r=Et.checkMatrix(r),r.rows!==e.rows)throw new Error("Y should have the same number of rows as X");s=r.getColumnVector(0)}else s=e.getColumnVector(0);let f=1,u,l,h,d;for(let g=0;g<o&&f>a;g++)h=e.transpose().mmul(s).div(s.transpose().mmul(s).get(0,0)),h=h.div(h.norm()),u=e.mmul(h).div(h.transpose().mmul(h).get(0,0)),g>0&&(f=u.clone().sub(d).pow(2).sum()),d=u.clone(),r?(l=r.transpose().mmul(u).div(u.transpose().mmul(u).get(0,0)),l=l.div(l.norm()),s=r.mmul(l).div(l.transpose().mmul(l).get(0,0))):s=u;if(r){let g=e.transpose().mmul(u).div(u.transpose().mmul(u).get(0,0));g=g.div(g.norm());let v=e.clone().sub(u.clone().mmul(g.transpose())),p=s.transpose().mmul(u).div(u.transpose().mmul(u).get(0,0)),w=r.clone().sub(u.clone().mulS(p.get(0,0)).mmul(l.transpose()));this.t=u,this.p=g.transpose(),this.w=h.transpose(),this.q=l,this.u=s,this.s=u.transpose().mmul(u),this.xResidual=v,this.yResidual=w,this.betas=p}else this.w=h.transpose(),this.s=u.transpose().mmul(u).sqrt(),n?this.t=u.clone().div(this.s.get(0,0)):this.t=u,this.xResidual=e.sub(u.mmul(h.transpose()))}}tt.AbstractMatrix=J,tt.CHO=_r,tt.CholeskyDecomposition=_r,tt.DistanceMatrix=le,tt.EVD=kr,tt.EigenvalueDecomposition=kr,tt.LU=de,tt.LuDecomposition=de;var Ar=tt.Matrix=j;tt.MatrixColumnSelectionView=Di,tt.MatrixColumnView=Li,tt.MatrixFlipColumnView=Pi,tt.MatrixFlipRowView=ji,tt.MatrixRowSelectionView=Ci,tt.MatrixRowView=Fi,tt.MatrixSelectionView=he,tt.MatrixSubView=qi,tt.MatrixTransposeView=$i,tt.NIPALS=zr,tt.Nipals=zr,tt.QR=je,tt.QrDecomposition=je,tt.SVD=$t;var to=tt.SingularValueDecomposition=$t;tt.SymmetricMatrix=Dt,tt.WrapperMatrix1D=Mr,tt.WrapperMatrix2D=Et,tt.correlation=Qi,tt.covariance=Xi;var Rr=tt.default=j;tt.determinant=ce,tt.inverse=Vi,tt.linearDependencies=Yi,tt.pseudoInverse=Gi,tt.solve=Sr,tt.wrap=Bi;const At=Ar,Or=to;Rr.Matrix&&Rr.Matrix;var eo={center:[0,0],linkDistance:50},Ir=function(){function i(e){e===void 0&&(e={}),this.options=e,this.id="mds",this.options=R(R({},eo),e)}return i.prototype.execute=function(e,t){return K(this,void 0,void 0,function(){return H(this,function(r){return[2,this.genericMDSLayout(!1,e,t)]})})},i.prototype.assign=function(e,t){return K(this,void 0,void 0,function(){return H(this,function(r){return this.genericMDSLayout(!0,e,t),[2]})})},i.prototype.genericMDSLayout=function(e,t,r){return K(this,void 0,void 0,function(){var n,o,a,s,f,u,l,h,d,g,v,p,w;return H(this,function(c){return n=R(R({},this.options),r),o=n.center,a=o===void 0?[0,0]:o,s=n.linkDistance,f=s===void 0?50:s,u=t.getAllNodes(),l=t.getAllEdges(),!(u!=null&&u.length)||u.length===1?[2,Lt(t,e,a)]:(h=cr({nodes:u,edges:l},!1),d=dr(h),ro(d),g=Zn(d,f),v=no(g),p=[],v.forEach(function(m,E){var x=ct(u[E]);x.data.x=m[0]+a[0],x.data.y=m[1]+a[1],p.push(x)}),e&&p.forEach(function(m){return t.mergeNodeData(m.id,{x:m.data.x,y:m.data.y})}),w={nodes:p,edges:l},[2,w])})})},i}(),ro=function(i){var e=-999999;i.forEach(function(t){t.forEach(function(r){r!==1/0&&e<r&&(e=r)})}),i.forEach(function(t,r){t.forEach(function(n,o){n===1/0&&(i[r][o]=e)})})},no=function(i){var e=2,t=At.mul(At.pow(i,2),-.5),r=t.mean("row"),n=t.mean("column"),o=t.mean();t.add(o).subRowVector(r).subColumnVector(n);var a=new Or(t),s=At.sqrt(a.diagonalMatrix).diagonal();return a.leftSingularVectors.toJSON().map(function(f){return At.mul([f],[s]).toJSON()[0].splice(0,e)})};function io(i){const e=+this._x.call(null,i),t=+this._y.call(null,i);return Tr(this.cover(e,t),e,t,i)}function Tr(i,e,t,r){if(isNaN(e)||isNaN(t))return i;var n,o=i._root,a={data:r},s=i._x0,f=i._y0,u=i._x1,l=i._y1,h,d,g,v,p,w,c,m;if(!o)return i._root=a,i;for(;o.length;)if((p=e>=(h=(s+u)/2))?s=h:u=h,(w=t>=(d=(f+l)/2))?f=d:l=d,n=o,!(o=o[c=w<<1|p]))return n[c]=a,i;if(g=+i._x.call(null,o.data),v=+i._y.call(null,o.data),e===g&&t===v)return a.next=o,n?n[c]=a:i._root=a,i;do n=n?n[c]=new Array(4):i._root=new Array(4),(p=e>=(h=(s+u)/2))?s=h:u=h,(w=t>=(d=(f+l)/2))?f=d:l=d;while((c=w<<1|p)===(m=(v>=d)<<1|g>=h));return n[m]=o,n[c]=a,i}function oo(i){var e,t,r=i.length,n,o,a=new Array(r),s=new Array(r),f=1/0,u=1/0,l=-1/0,h=-1/0;for(t=0;t<r;++t)isNaN(n=+this._x.call(null,e=i[t]))||isNaN(o=+this._y.call(null,e))||(a[t]=n,s[t]=o,n<f&&(f=n),n>l&&(l=n),o<u&&(u=o),o>h&&(h=o));if(f>l||u>h)return this;for(this.cover(f,u).cover(l,h),t=0;t<r;++t)Tr(this,a[t],s[t],i[t]);return this}function ao(i,e){if(isNaN(i=+i)||isNaN(e=+e))return this;var t=this._x0,r=this._y0,n=this._x1,o=this._y1;if(isNaN(t))n=(t=Math.floor(i))+1,o=(r=Math.floor(e))+1;else{for(var a=n-t||1,s=this._root,f,u;t>i||i>=n||r>e||e>=o;)switch(u=(e<r)<<1|i<t,f=new Array(4),f[u]=s,s=f,a*=2,u){case 0:n=t+a,o=r+a;break;case 1:t=n-a,o=r+a;break;case 2:n=t+a,r=o-a;break;case 3:t=n-a,r=o-a;break}this._root&&this._root.length&&(this._root=s)}return this._x0=t,this._y0=r,this._x1=n,this._y1=o,this}function so(){var i=[];return this.visit(function(e){if(!e.length)do i.push(e.data);while(e=e.next)}),i}function uo(i){return arguments.length?this.cover(+i[0][0],+i[0][1]).cover(+i[1][0],+i[1][1]):isNaN(this._x0)?void 0:[[this._x0,this._y0],[this._x1,this._y1]]}function gt(i,e,t,r,n){this.node=i,this.x0=e,this.y0=t,this.x1=r,this.y1=n}function fo(i,e,t){var r,n=this._x0,o=this._y0,a,s,f,u,l=this._x1,h=this._y1,d=[],g=this._root,v,p;for(g&&d.push(new gt(g,n,o,l,h)),t==null?t=1/0:(n=i-t,o=e-t,l=i+t,h=e+t,t*=t);v=d.pop();)if(!(!(g=v.node)||(a=v.x0)>l||(s=v.y0)>h||(f=v.x1)<n||(u=v.y1)<o))if(g.length){var w=(a+f)/2,c=(s+u)/2;d.push(new gt(g[3],w,c,f,u),new gt(g[2],a,c,w,u),new gt(g[1],w,s,f,c),new gt(g[0],a,s,w,c)),(p=(e>=c)<<1|i>=w)&&(v=d[d.length-1],d[d.length-1]=d[d.length-1-p],d[d.length-1-p]=v)}else{var m=i-+this._x.call(null,g.data),E=e-+this._y.call(null,g.data),x=m*m+E*E;if(x<t){var N=Math.sqrt(t=x);n=i-N,o=e-N,l=i+N,h=e+N,r=g.data}}return r}function lo(i){if(isNaN(l=+this._x.call(null,i))||isNaN(h=+this._y.call(null,i)))return this;var e,t=this._root,r,n,o,a=this._x0,s=this._y0,f=this._x1,u=this._y1,l,h,d,g,v,p,w,c;if(!t)return this;if(t.length)for(;;){if((v=l>=(d=(a+f)/2))?a=d:f=d,(p=h>=(g=(s+u)/2))?s=g:u=g,e=t,!(t=t[w=p<<1|v]))return this;if(!t.length)break;(e[w+1&3]||e[w+2&3]||e[w+3&3])&&(r=e,c=w)}for(;t.data!==i;)if(n=t,!(t=t.next))return this;return(o=t.next)&&delete t.next,n?(o?n.next=o:delete n.next,this):e?(o?e[w]=o:delete e[w],(t=e[0]||e[1]||e[2]||e[3])&&t===(e[3]||e[2]||e[1]||e[0])&&!t.length&&(r?r[c]=t:this._root=t),this):(this._root=o,this)}function ho(i){for(var e=0,t=i.length;e<t;++e)this.remove(i[e]);return this}function co(){return this._root}function go(){var i=0;return this.visit(function(e){if(!e.length)do++i;while(e=e.next)}),i}function vo(i){var e=[],t,r=this._root,n,o,a,s,f;for(r&&e.push(new gt(r,this._x0,this._y0,this._x1,this._y1));t=e.pop();)if(!i(r=t.node,o=t.x0,a=t.y0,s=t.x1,f=t.y1)&&r.length){var u=(o+s)/2,l=(a+f)/2;(n=r[3])&&e.push(new gt(n,u,l,s,f)),(n=r[2])&&e.push(new gt(n,o,l,u,f)),(n=r[1])&&e.push(new gt(n,u,a,s,l)),(n=r[0])&&e.push(new gt(n,o,a,u,l))}return this}function po(i){var e=[],t=[],r;for(this._root&&e.push(new gt(this._root,this._x0,this._y0,this._x1,this._y1));r=e.pop();){var n=r.node;if(n.length){var o,a=r.x0,s=r.y0,f=r.x1,u=r.y1,l=(a+f)/2,h=(s+u)/2;(o=n[0])&&e.push(new gt(o,a,s,l,h)),(o=n[1])&&e.push(new gt(o,l,s,f,h)),(o=n[2])&&e.push(new gt(o,a,h,l,u)),(o=n[3])&&e.push(new gt(o,l,h,f,u))}t.push(r)}for(;r=t.pop();)i(r.node,r.x0,r.y0,r.x1,r.y1);return this}function wo(i){return i[0]}function mo(i){return arguments.length?(this._x=i,this):this._x}function yo(i){return i[1]}function Eo(i){return arguments.length?(this._y=i,this):this._y}function ve(i,e,t){var r=new Fe(e??wo,t??yo,NaN,NaN,NaN,NaN);return i==null?r:r.addAll(i)}function Fe(i,e,t,r,n,o){this._x=i,this._y=e,this._x0=t,this._y0=r,this._x1=n,this._y1=o,this._root=void 0}function Lr(i){for(var e={data:i.data},t=e;i=i.next;)t=t.next={data:i.data};return e}var vt=ve.prototype=Fe.prototype;vt.copy=function(){var i=new Fe(this._x,this._y,this._x0,this._y0,this._x1,this._y1),e=this._root,t,r;if(!e)return i;if(!e.length)return i._root=Lr(e),i;for(t=[{source:e,target:i._root=new Array(4)}];e=t.pop();)for(var n=0;n<4;++n)(r=e.source[n])&&(r.length?t.push({source:r,target:e.target[n]=new Array(4)}):e.target[n]=Lr(r));return i},vt.add=io,vt.addAll=oo,vt.cover=ao,vt.data=so,vt.extent=uo,vt.find=fo,vt.remove=lo,vt.removeAll=ho,vt.root=co,vt.size=go,vt.visit=vo,vt.visitAfter=po,vt.x=mo,vt.y=Eo;function xo(i){const e=+this._x.call(null,i),t=+this._y.call(null,i),r=+this._z.call(null,i);return Dr(this.cover(e,t,r),e,t,r,i)}function Dr(i,e,t,r,n){if(isNaN(e)||isNaN(t)||isNaN(r))return i;var o,a=i._root,s={data:n},f=i._x0,u=i._y0,l=i._z0,h=i._x1,d=i._y1,g=i._z1,v,p,w,c,m,E,x,N,z,k,b;if(!a)return i._root=s,i;for(;a.length;)if((x=e>=(v=(f+h)/2))?f=v:h=v,(N=t>=(p=(u+d)/2))?u=p:d=p,(z=r>=(w=(l+g)/2))?l=w:g=w,o=a,!(a=a[k=z<<2|N<<1|x]))return o[k]=s,i;if(c=+i._x.call(null,a.data),m=+i._y.call(null,a.data),E=+i._z.call(null,a.data),e===c&&t===m&&r===E)return s.next=a,o?o[k]=s:i._root=s,i;do o=o?o[k]=new Array(8):i._root=new Array(8),(x=e>=(v=(f+h)/2))?f=v:h=v,(N=t>=(p=(u+d)/2))?u=p:d=p,(z=r>=(w=(l+g)/2))?l=w:g=w;while((k=z<<2|N<<1|x)===(b=(E>=w)<<2|(m>=p)<<1|c>=v));return o[b]=a,o[k]=s,i}function No(i){Array.isArray(i)||(i=Array.from(i));const e=i.length,t=new Float64Array(e),r=new Float64Array(e),n=new Float64Array(e);let o=1/0,a=1/0,s=1/0,f=-1/0,u=-1/0,l=-1/0;for(let h=0,d,g,v,p;h<e;++h)isNaN(g=+this._x.call(null,d=i[h]))||isNaN(v=+this._y.call(null,d))||isNaN(p=+this._z.call(null,d))||(t[h]=g,r[h]=v,n[h]=p,g<o&&(o=g),g>f&&(f=g),v<a&&(a=v),v>u&&(u=v),p<s&&(s=p),p>l&&(l=p));if(o>f||a>u||s>l)return this;this.cover(o,a,s).cover(f,u,l);for(let h=0;h<e;++h)Dr(this,t[h],r[h],n[h],i[h]);return this}function bo(i,e,t){if(isNaN(i=+i)||isNaN(e=+e)||isNaN(t=+t))return this;var r=this._x0,n=this._y0,o=this._z0,a=this._x1,s=this._y1,f=this._z1;if(isNaN(r))a=(r=Math.floor(i))+1,s=(n=Math.floor(e))+1,f=(o=Math.floor(t))+1;else{for(var u=a-r||1,l=this._root,h,d;r>i||i>=a||n>e||e>=s||o>t||t>=f;)switch(d=(t<o)<<2|(e<n)<<1|i<r,h=new Array(8),h[d]=l,l=h,u*=2,d){case 0:a=r+u,s=n+u,f=o+u;break;case 1:r=a-u,s=n+u,f=o+u;break;case 2:a=r+u,n=s-u,f=o+u;break;case 3:r=a-u,n=s-u,f=o+u;break;case 4:a=r+u,s=n+u,o=f-u;break;case 5:r=a-u,s=n+u,o=f-u;break;case 6:a=r+u,n=s-u,o=f-u;break;case 7:r=a-u,n=s-u,o=f-u;break}this._root&&this._root.length&&(this._root=l)}return this._x0=r,this._y0=n,this._z0=o,this._x1=a,this._y1=s,this._z1=f,this}function Mo(){var i=[];return this.visit(function(e){if(!e.length)do i.push(e.data);while(e=e.next)}),i}function So(i){return arguments.length?this.cover(+i[0][0],+i[0][1],+i[0][2]).cover(+i[1][0],+i[1][1],+i[1][2]):isNaN(this._x0)?void 0:[[this._x0,this._y0,this._z0],[this._x1,this._y1,this._z1]]}function nt(i,e,t,r,n,o,a){this.node=i,this.x0=e,this.y0=t,this.z0=r,this.x1=n,this.y1=o,this.z1=a}function ko(i,e,t,r){var n,o=this._x0,a=this._y0,s=this._z0,f,u,l,h,d,g,v=this._x1,p=this._y1,w=this._z1,c=[],m=this._root,E,x;for(m&&c.push(new nt(m,o,a,s,v,p,w)),r==null?r=1/0:(o=i-r,a=e-r,s=t-r,v=i+r,p=e+r,w=t+r,r*=r);E=c.pop();)if(!(!(m=E.node)||(f=E.x0)>v||(u=E.y0)>p||(l=E.z0)>w||(h=E.x1)<o||(d=E.y1)<a||(g=E.z1)<s))if(m.length){var N=(f+h)/2,z=(u+d)/2,k=(l+g)/2;c.push(new nt(m[7],N,z,k,h,d,g),new nt(m[6],f,z,k,N,d,g),new nt(m[5],N,u,k,h,z,g),new nt(m[4],f,u,k,N,z,g),new nt(m[3],N,z,l,h,d,k),new nt(m[2],f,z,l,N,d,k),new nt(m[1],N,u,l,h,z,k),new nt(m[0],f,u,l,N,z,k)),(x=(t>=k)<<2|(e>=z)<<1|i>=N)&&(E=c[c.length-1],c[c.length-1]=c[c.length-1-x],c[c.length-1-x]=E)}else{var b=i-+this._x.call(null,m.data),A=e-+this._y.call(null,m.data),y=t-+this._z.call(null,m.data),S=b*b+A*A+y*y;if(S<r){var _=Math.sqrt(r=S);o=i-_,a=e-_,s=t-_,v=i+_,p=e+_,w=t+_,n=m.data}}return n}function _o(i){if(isNaN(d=+this._x.call(null,i))||isNaN(g=+this._y.call(null,i))||isNaN(v=+this._z.call(null,i)))return this;var e,t=this._root,r,n,o,a=this._x0,s=this._y0,f=this._z0,u=this._x1,l=this._y1,h=this._z1,d,g,v,p,w,c,m,E,x,N,z;if(!t)return this;if(t.length)for(;;){if((m=d>=(p=(a+u)/2))?a=p:u=p,(E=g>=(w=(s+l)/2))?s=w:l=w,(x=v>=(c=(f+h)/2))?f=c:h=c,e=t,!(t=t[N=x<<2|E<<1|m]))return this;if(!t.length)break;(e[N+1&7]||e[N+2&7]||e[N+3&7]||e[N+4&7]||e[N+5&7]||e[N+6&7]||e[N+7&7])&&(r=e,z=N)}for(;t.data!==i;)if(n=t,!(t=t.next))return this;return(o=t.next)&&delete t.next,n?(o?n.next=o:delete n.next,this):e?(o?e[N]=o:delete e[N],(t=e[0]||e[1]||e[2]||e[3]||e[4]||e[5]||e[6]||e[7])&&t===(e[7]||e[6]||e[5]||e[4]||e[3]||e[2]||e[1]||e[0])&&!t.length&&(r?r[z]=t:this._root=t),this):(this._root=o,this)}function zo(i){for(var e=0,t=i.length;e<t;++e)this.remove(i[e]);return this}function Ao(){return this._root}function Ro(){var i=0;return this.visit(function(e){if(!e.length)do++i;while(e=e.next)}),i}function Oo(i){var e=[],t,r=this._root,n,o,a,s,f,u,l;for(r&&e.push(new nt(r,this._x0,this._y0,this._z0,this._x1,this._y1,this._z1));t=e.pop();)if(!i(r=t.node,o=t.x0,a=t.y0,s=t.z0,f=t.x1,u=t.y1,l=t.z1)&&r.length){var h=(o+f)/2,d=(a+u)/2,g=(s+l)/2;(n=r[7])&&e.push(new nt(n,h,d,g,f,u,l)),(n=r[6])&&e.push(new nt(n,o,d,g,h,u,l)),(n=r[5])&&e.push(new nt(n,h,a,g,f,d,l)),(n=r[4])&&e.push(new nt(n,o,a,g,h,d,l)),(n=r[3])&&e.push(new nt(n,h,d,s,f,u,g)),(n=r[2])&&e.push(new nt(n,o,d,s,h,u,g)),(n=r[1])&&e.push(new nt(n,h,a,s,f,d,g)),(n=r[0])&&e.push(new nt(n,o,a,s,h,d,g))}return this}function Io(i){var e=[],t=[],r;for(this._root&&e.push(new nt(this._root,this._x0,this._y0,this._z0,this._x1,this._y1,this._z1));r=e.pop();){var n=r.node;if(n.length){var o,a=r.x0,s=r.y0,f=r.z0,u=r.x1,l=r.y1,h=r.z1,d=(a+u)/2,g=(s+l)/2,v=(f+h)/2;(o=n[0])&&e.push(new nt(o,a,s,f,d,g,v)),(o=n[1])&&e.push(new nt(o,d,s,f,u,g,v)),(o=n[2])&&e.push(new nt(o,a,g,f,d,l,v)),(o=n[3])&&e.push(new nt(o,d,g,f,u,l,v)),(o=n[4])&&e.push(new nt(o,a,s,v,d,g,h)),(o=n[5])&&e.push(new nt(o,d,s,v,u,g,h)),(o=n[6])&&e.push(new nt(o,a,g,v,d,l,h)),(o=n[7])&&e.push(new nt(o,d,g,v,u,l,h))}t.push(r)}for(;r=t.pop();)i(r.node,r.x0,r.y0,r.z0,r.x1,r.y1,r.z1);return this}function To(i){return i[0]}function Lo(i){return arguments.length?(this._x=i,this):this._x}function Do(i){return i[1]}function Po(i){return arguments.length?(this._y=i,this):this._y}function jo(i){return i[2]}function Fo(i){return arguments.length?(this._z=i,this):this._z}function Pr(i,e,t,r){var n=new Ce(e??To,t??Do,r??jo,NaN,NaN,NaN,NaN,NaN,NaN);return i==null?n:n.addAll(i)}function Ce(i,e,t,r,n,o,a,s,f){this._x=i,this._y=e,this._z=t,this._x0=r,this._y0=n,this._z0=o,this._x1=a,this._y1=s,this._z1=f,this._root=void 0}function jr(i){for(var e={data:i.data},t=e;i=i.next;)t=t.next={data:i.data};return e}var ht=Pr.prototype=Ce.prototype;ht.copy=function(){var i=new Ce(this._x,this._y,this._z,this._x0,this._y0,this._z0,this._x1,this._y1,this._z1),e=this._root,t,r;if(!e)return i;if(!e.length)return i._root=jr(e),i;for(t=[{source:e,target:i._root=new Array(8)}];e=t.pop();)for(var n=0;n<8;++n)(r=e.source[n])&&(r.length?t.push({source:r,target:e.target[n]=new Array(8)}):e.target[n]=jr(r));return i},ht.add=xo,ht.addAll=No,ht.cover=bo,ht.data=Mo,ht.extent=So,ht.find=ko,ht.remove=_o,ht.removeAll=zo,ht.root=Ao,ht.size=Ro,ht.visit=Oo,ht.visitAfter=Io,ht.x=Lo,ht.y=Po,ht.z=Fo;var Co=.81,qe=.1;function qo(i,e,t,r,n){n===void 0&&(n=2);var o=e/t,a=i.getAllNodes(),s=a.map(function(l,h){var d=l.data,g=d.nodeStrength,v=d.x,p=d.y,w=d.z,c=d.size;return{x:v,y:p,z:w,size:c,index:h,id:l.id,vx:0,vy:0,vz:0,weight:o*g}}),f=(n===2?ve(s,function(l){return l.x},function(l){return l.y}):Pr(s,function(l){return l.x},function(l){return l.y},function(l){return l.z})).visitAfter($o),u=new Map;return s.forEach(function(l){u.set(l.id,l),Vo(l,f,n)}),s.map(function(l,h){var d=a[h],g=d.id,v=d.data,p=v.mass,w=p===void 0?1:p;r[g]={x:l.vx/w,y:l.vy/w,z:l.vz/w}}),r}function $o(i){var e=0,t=0,r=0,n=0,o=0,a=i.length;if(a){for(var s=0;s<a;s++){var f=i[s];f&&f.weight&&(e+=f.weight,t+=f.x*f.weight,r+=f.y*f.weight,n+=f.z*f.weight,o+=f.size*f.weight)}i.x=t/e,i.y=r/e,i.z=n/e,i.size=o/e,i.weight=e}else{var f=i;i.x=f.data.x,i.y=f.data.y,i.z=f.data.z,i.size=f.data.size,i.weight=f.data.weight}}var Bo=function(i,e,t,r,n,o,a){var s;if(((s=i.data)===null||s===void 0?void 0:s.id)!==o.id){for(var f=[t,r,n][a-1],u=o.x-i.x||qe,l=o.y-i.y||qe,h=o.z-i.z||qe,d=[u,l,h],g=f-e,v=0,p=0;p<a;p++)v+=d[p]*d[p];var w=Math.sqrt(v),c=w*v;if(g*g*Co<v){var m=i.weight/c;return o.vx+=u*m,o.vy+=l*m,o.vz+=h*m,!0}if(i.length)return!1;if(i.data!==o){var m=i.data.weight/c;o.vx+=u*m,o.vy+=l*m,o.vz+=h*m}}};function Vo(i,e,t){e.visit(function(r,n,o,a,s){return Bo(r,n,o,a,s,i,t)})}var Uo={dimensions:2,maxIteration:500,gravity:10,factor:1,edgeStrength:50,nodeStrength:1e3,coulombDisScale:.005,damping:.9,maxSpeed:200,minMovement:.4,interval:.02,linkDistance:200,clusterNodeStrength:20,preventOverlap:!0,distanceThresholdMode:"mean"},Fr=function(){function i(e){e===void 0&&(e={}),this.options=e,this.id="force",this.timeInterval=0,this.judgingDistance=0,this.running=!1,this.options=R(R({},Uo),e)}return i.prototype.execute=function(e,t){return K(this,void 0,void 0,function(){return H(this,function(r){return[2,this.genericForceLayout(!1,e,t)]})})},i.prototype.assign=function(e,t){return K(this,void 0,void 0,function(){return H(this,function(r){return this.genericForceLayout(!0,e,t),[2]})})},i.prototype.stop=function(){this.timeInterval&&typeof window<"u"&&window.clearInterval(this.timeInterval),this.running=!1},i.prototype.tick=function(e){var t=this;if(e===void 0&&(e=this.options.maxIteration||1),this.lastResult)return this.lastResult;for(var r=0;(this.judgingDistance>this.lastOptions.minMovement||r<1)&&r<e;r++)this.runOneStep(this.lastCalcGraph,this.lastGraph,r,this.lastVelMap,this.lastOptions),this.updatePosition(this.lastGraph,this.lastCalcGraph,this.lastVelMap,this.lastOptions);var n={nodes:this.lastLayoutNodes,edges:this.lastLayoutEdges};return this.lastAssign&&n.nodes.forEach(function(o){return t.lastGraph.mergeNodeData(o.id,{x:o.data.x,y:o.data.y,z:t.options.dimensions===3?o.data.z:void 0})}),n},i.prototype.genericForceLayout=function(e,t,r){return K(this,void 0,void 0,function(){var n,o,a,s,f,u,l,h,d,g,v,p,w,c,m,E,x,N,z,k,b=this;return H(this,function(A){return n=R(R({},this.options),r),o=t.getAllNodes(),a=t.getAllEdges(),s=this.formatOptions(n,t),f=s.dimensions,u=s.width,l=s.height,h=s.nodeSize,d=s.getMass,g=s.nodeStrength,v=s.edgeStrength,p=s.linkDistance,w=o.map(function(y,S){return R(R({},y),{data:R(R({},y.data),{x:Q(y.data.x)?y.data.x:Math.random()*u,y:Q(y.data.y)?y.data.y:Math.random()*l,z:Q(y.data.z)?y.data.z:Math.random()*Math.sqrt(u*l),size:h(y)||30,mass:d(y),nodeStrength:g(y)})})}),c=a.map(function(y){return R(R({},y),{data:R(R({},y.data),{edgeStrength:v(y),linkDistance:p(y,t.getNode(y.source),t.getNode(y.target))})})}),o!=null&&o.length?(m={},o.forEach(function(y,S){m[y.id]={x:0,y:0,z:0}}),E=new ft({nodes:w,edges:c}),this.formatCentripetal(s,E),x=s.maxIteration,N=s.minMovement,z=s.onTick,this.lastLayoutNodes=w,this.lastLayoutEdges=c,this.lastAssign=e,this.lastGraph=t,this.lastCalcGraph=E,this.lastOptions=s,this.lastVelMap=m,typeof window>"u"?[2]:(k=0,[2,new Promise(function(y){b.timeInterval=window.setInterval(function(){(!o||!b.running)&&y({nodes:$e(t,w),edges:a}),b.runOneStep(E,t,k,m,s),b.updatePosition(t,E,m,s),e&&w.forEach(function(S){return t.mergeNodeData(S.id,{x:S.data.x,y:S.data.y,z:f===3?S.data.z:void 0})}),z==null||z({nodes:$e(t,w),edges:a}),k++,(k>=x||b.judgingDistance<N)&&(window.clearInterval(b.timeInterval),y({nodes:$e(t,w),edges:a}))},0),b.running=!0})])):(this.lastResult={nodes:[],edges:a},[2,{nodes:[],edges:a}])})})},i.prototype.formatOptions=function(e,t){var r=R({},e),n=e.width,o=e.height,a=e.getMass,s=e.nodeSize;r.width=!n&&typeof window<"u"?window.innerWidth:n,r.height=!o&&typeof window<"u"?window.innerHeight:o,e.center||(r.center=[r.width/2,r.height/2]),a||(r.getMass=function(h){var d=1;Q(h==null?void 0:h.data.mass)&&(d=h==null?void 0:h.data.mass);var g=t.getDegree(h.id,"both");return!g||g<5?d:g*5*d});var f=zt(0,e.nodeSpacing),u;s?yt(s)?u=function(h){return s(h)+f(h)}:lt(s)?u=function(h){var d=s;return Math.max(d[0],d[1])+f(h)}:u=function(h){return s+f(h)}:u=function(h){var d=((h==null?void 0:h.data)||{}).size;return d?lt(d)?Math.max(d[0],d[1])+f(h):_t(d)?Math.max(d.width,d.height)+f(h):d+f(h):10+f(h)},r.nodeSize=u;var l=e.linkDistance?zt(1,e.linkDistance):function(h){return 1+r.nodeSize(t.getNode(h.source))+r.nodeSize(t.getNode(h.target))};return r.linkDistance=l,r.nodeStrength=zt(1,e.nodeStrength),r.edgeStrength=zt(1,e.edgeStrength),r},i.prototype.formatCentripetal=function(e,t){var r=e.dimensions,n=e.centripetalOptions,o=e.center,a=e.clusterNodeStrength,s=e.leafCluster,f=e.clustering,u=e.nodeClusterBy,l=t.getAllNodes(),h=n||{leaf:2,single:2,others:1,center:function(E){return{x:o[0],y:o[1],z:r===3?o[2]:void 0}}};typeof a!="function"&&(e.clusterNodeStrength=function(E){return a});var d,g;if(s&&u&&(d=Cr(t,u),g=Array.from(new Set(l==null?void 0:l.map(function(E){return E.data[u]})))||[],e.centripetalOptions=Object.assign(h,{single:100,leaf:function(E){var x=d[E.id]||{},N=x.siblingLeaves,z=x.sameTypeLeaves;return(z==null?void 0:z.length)===(N==null?void 0:N.length)||(g==null?void 0:g.length)===1?1:e.clusterNodeStrength(E)},others:1,center:function(E){var x=t.getDegree(E.id,"both");if(!x)return{x:100,y:100,z:0};var N;if(x===1){var z=(d[E.id]||{}).sameTypeLeaves,k=z===void 0?[]:z;k.length===1?N=void 0:k.length>1&&(N=qr(k))}else N=void 0;return{x:N==null?void 0:N.x,y:N==null?void 0:N.y,z:N==null?void 0:N.z}}})),f&&u){d||(d=Cr(t,u)),g||(g=Array.from(new Set(l.map(function(E){return E.data[u]})))),g=g.filter(function(E){return E!==void 0});var v={};g.forEach(function(E){var x=l.filter(function(N){return N.data[u]===E}).map(function(N){return t.getNode(N.id)});v[E]=qr(x)}),e.centripetalOptions=Object.assign(h,{single:function(E){return e.clusterNodeStrength(E)},leaf:function(E){return e.clusterNodeStrength(E)},others:function(E){return e.clusterNodeStrength(E)},center:function(E){var x=v[E.data[u]];return{x:x==null?void 0:x.x,y:x==null?void 0:x.y,z:x==null?void 0:x.z}}})}var p=e.centripetalOptions||{},w=p.leaf,c=p.single,m=p.others;w&&typeof w!="function"&&(e.centripetalOptions.leaf=function(){return w}),c&&typeof c!="function"&&(e.centripetalOptions.single=function(){return c}),m&&typeof m!="function"&&(e.centripetalOptions.others=function(){return m})},i.prototype.runOneStep=function(e,t,r,n,o){var a={},s=e.getAllNodes(),f=e.getAllEdges();if(s!=null&&s.length){var u=o.monitor;if(this.calRepulsive(e,a,o),f&&this.calAttractive(e,a,o),this.calGravity(e,t,a,o),this.updateVelocity(e,a,n,o),u){var l=this.calTotalEnergy(a,s);u({energy:l,nodes:t.getAllNodes(),edges:t.getAllEdges(),iterations:r})}}},i.prototype.calTotalEnergy=function(e,t){var r=this;if(!(t!=null&&t.length))return 0;var n=0;return t.forEach(function(o,a){var s=e[o.id].x,f=e[o.id].y,u=r.options.dimensions===3?e[o.id].z:0,l=s*s+f*f+u*u,h=o.data.mass,d=h===void 0?1:h;n+=d*l*.5}),n},i.prototype.calRepulsive=function(e,t,r){var n=r.dimensions,o=r.factor,a=r.coulombDisScale;qo(e,o,a*a,t,n)},i.prototype.calAttractive=function(e,t,r){var n=r.dimensions,o=r.nodeSize;e.getAllEdges().forEach(function(a,s){var f=a.source,u=a.target,l=e.getNode(f),h=e.getNode(u);if(!(!l||!h)){var d=h.data.x-l.data.x,g=h.data.y-l.data.y,v=n===3?h.data.z-l.data.z:0;!d&&!g&&(d=Math.random()*.01,g=Math.random()*.01,n===3&&!v&&(v=Math.random()*.01));var p=Math.sqrt(d*d+g*g+v*v);if(!(p<o(l)+o(h))){var w=d/p,c=g/p,m=v/p,E=a.data||{},x=E.linkDistance,N=x===void 0?200:x,z=E.edgeStrength,k=z===void 0?200:z,b=N-p,A=b*k,y=l.data.mass||1,S=h.data.mass||1,_=1/y,M=1/S,T=w*A,L=c*A,D=m*A;t[f].x-=T*_,t[f].y-=L*_,t[f].z-=D*_,t[u].x+=T*M,t[u].y+=L*M,t[u].z+=D*M}}})},i.prototype.calGravity=function(e,t,r,n){var o=n.getCenter,a=e.getAllNodes(),s=t.getAllNodes(),f=t.getAllEdges(),u=n.width,l=n.height,h=n.center,d=n.gravity,g=n.centripetalOptions;a&&a.forEach(function(v){var p=v.id,w=v.data,c=w.mass,m=w.x,E=w.y,x=w.z,N=t.getNode(p),z=0,k=0,b=0,A=d,y=e.getDegree(p,"in"),S=e.getDegree(p,"out"),_=e.getDegree(p,"both"),M=o==null?void 0:o(N,_);if(M){var T=st(M,3),L=T[0],D=T[1],$=T[2];z=m-L,k=E-D,A=$}else z=m-h[0],k=E-h[1],b=x-h[2];if(A&&(r[p].x-=A*z/c,r[p].y-=A*k/c,r[p].z-=A*b/c),g){var C=g.leaf,G=g.single,V=g.others,X=g.center,W=(X==null?void 0:X(N,s,f,u,l))||{x:0,y:0,z:0,centerStrength:0},P=W.x,I=W.y,U=W.z,q=W.centerStrength;if(!Q(P)||!Q(I))return;var B=(m-P)/c,O=(E-I)/c,F=(x-U)/c;if(q&&(r[p].x-=q*B,r[p].y-=q*O,r[p].z-=q*F),_===0){var Y=G(N);if(!Y)return;r[p].x-=Y*B,r[p].y-=Y*O,r[p].z-=Y*F;return}if(y===0||S===0){var Z=C(N,s,f);if(!Z)return;r[p].x-=Z*B,r[p].y-=Z*O,r[p].z-=Z*F;return}var rt=V(N);if(!rt)return;r[p].x-=rt*B,r[p].y-=rt*O,r[p].z-=rt*F}})},i.prototype.updateVelocity=function(e,t,r,n){var o=n.damping,a=n.maxSpeed,s=n.interval,f=n.dimensions,u=e.getAllNodes();u!=null&&u.length&&u.forEach(function(l){var h=l.id,d=(r[h].x+t[h].x*s)*o||.01,g=(r[h].y+t[h].y*s)*o||.01,v=f===3?(r[h].z+t[h].z*s)*o||.01:0,p=Math.sqrt(d*d+g*g+v*v);if(p>a){var w=a/p;d=w*d,g=w*g,v=w*v}r[h]={x:d,y:g,z:v}})},i.prototype.updatePosition=function(e,t,r,n){var o=this,a=n.distanceThresholdMode,s=n.interval,f=n.dimensions,u=t.getAllNodes();if(!(u!=null&&u.length)){this.judgingDistance=0;return}var l=0;a==="max"?this.judgingDistance=-1/0:a==="min"&&(this.judgingDistance=1/0),u.forEach(function(h){var d=h.id,g=e.getNode(d);if(Q(g.data.fx)&&Q(g.data.fy)){t.mergeNodeData(d,{x:g.data.fx,y:g.data.fy,z:f===3?g.data.fz:void 0});return}var v=r[d].x*s,p=r[d].y*s,w=f===3?r[d].z*s:0;t.mergeNodeData(d,{x:h.data.x+v,y:h.data.y+p,z:h.data.z+w});var c=Math.sqrt(v*v+p*p+w*w);switch(a){case"max":o.judgingDistance<c&&(o.judgingDistance=c);break;case"min":o.judgingDistance>c&&(o.judgingDistance=c);break;default:l=l+c;break}}),(!a||a==="mean")&&(this.judgingDistance=l/u.length)},i}(),Cr=function(i,e){var t=i.getAllNodes();if(!(t!=null&&t.length))return{};var r={};return t.forEach(function(n,o){var a=i.getDegree(n.id,"both");a===1&&(r[n.id]=Wo(i,"leaf",n,e))}),r},Wo=function(i,e,t,r){var n=i.getDegree(t.id,"in"),o=i.getDegree(t.id,"out"),a=t,s=[];n===0?(a=i.getSuccessors(t.id)[0],s=i.getNeighbors(a.id)):o===0&&(a=i.getPredecessors(t.id)[0],s=i.getNeighbors(a.id)),s=s.filter(function(u){return i.getDegree(u.id,"in")===0||i.getDegree(u.id,"out")===0});var f=Yo(i,e,r,t,s);return{coreNode:a,siblingLeaves:s,sameTypeLeaves:f}},Yo=function(i,e,t,r,n){var o=r.data[t]||"",a=(n==null?void 0:n.filter(function(s){return s.data[t]===o}))||[];return e==="leaf"&&(a=a.filter(function(s){return i.getDegree(s.id,"in")===0||i.getDegree(s.id,"out")===0})),a},qr=function(i){var e={x:0,y:0};i.forEach(function(r){var n=r.data,o=n.x,a=n.y;e.x+=o||0,e.y+=a||0});var t=i.length||1;return{x:e.x/t,y:e.y/t}},$e=function(i,e){return e.map(function(t){var r=t.id,n=t.data,o=i.getNode(r);return R(R({},o),{data:R(R({},o.data),{x:n.x,y:n.y,z:n.z})})})},Go={nodeSize:30,nodeSpacing:10,preventOverlap:!1,sweep:void 0,equidistant:!1,startAngle:3/2*Math.PI,clockwise:!0,maxLevelDiff:void 0,sortBy:"degree"},Be=function(){function i(e){e===void 0&&(e={}),this.options=e,this.id="concentric",this.options=R(R({},Go),e)}return i.prototype.execute=function(e,t){return K(this,void 0,void 0,function(){return H(this,function(r){return[2,this.genericConcentricLayout(!1,e,t)]})})},i.prototype.assign=function(e,t){return K(this,void 0,void 0,function(){return H(this,function(r){return this.genericConcentricLayout(!0,e,t),[2]})})},i.prototype.genericConcentricLayout=function(e,t,r){return K(this,void 0,void 0,function(){var n,o,a,s,f,u,l,h,d,g,v,p,w,c,m,E,x,N,z,k,b,A,y,S,_,M,T,L,D,$,C,G,V,X,W,P,I,U,q;return H(this,function(B){if(n=R(R({},this.options),r),o=n.center,a=n.width,s=n.height,f=n.sortBy,u=n.maxLevelDiff,l=n.sweep,h=n.clockwise,d=n.equidistant,g=n.preventOverlap,v=n.startAngle,p=v===void 0?3/2*Math.PI:v,w=n.nodeSize,c=n.nodeSpacing,m=t.getAllNodes(),E=t.getAllEdges(),x=!a&&typeof window<"u"?window.innerWidth:a,N=!s&&typeof window<"u"?window.innerHeight:s,z=o||[x/2,N/2],!(m!=null&&m.length)||m.length===1)return[2,Lt(t,e,z)];if(k=[],A=0,lt(w)?b=Math.max(w[0],w[1]):yt(w)?(b=-1/0,m.forEach(function(O){var F=w(O);F>b&&(b=F)})):b=w,lt(c)?A=Math.max(c[0],c[1]):Q(c)&&(A=c),m.forEach(function(O){var F=ct(O);k.push(F);var Y=b,Z=F.data;lt(Z.size)?Y=Math.max(Z.size[0],Z.size[1]):Q(Z.size)?Y=Z.size:_t(Z.size)&&(Y=Math.max(Z.size.width,Z.size.height)),b=Math.max(b,Y),yt(c)&&(A=Math.max(c(O),A))}),y={},k.forEach(function(O,F){y[O.id]=F}),S=f,(!Yt(S)||k[0].data[S]===void 0)&&(S="degree"),S==="degree"?k.sort(function(O,F){return t.getDegree(F.id,"both")-t.getDegree(O.id,"both")}):k.sort(function(O,F){return F.data[S]-O.data[S]}),_=k[0],M=(u||(S==="degree"?t.getDegree(_.id,"both"):_.data[S]))/4,T=[{nodes:[]}],L=T[0],k.forEach(function(O){if(L.nodes.length>0){var F=Math.abs(S==="degree"?t.getDegree(L.nodes[0].id,"both")-t.getDegree(O.id,"both"):L.nodes[0].data[S]-O.data[S]);M&&F>=M&&(L={nodes:[]},T.push(L))}L.nodes.push(O)}),D=b+A,g||($=T.length>0&&T[0].nodes.length>1,C=Math.min(x,N)/2-D,G=C/(T.length+($?1:0)),D=Math.min(D,G)),V=0,T.forEach(function(O){var F=l===void 0?2*Math.PI-2*Math.PI/O.nodes.length:l;if(O.dTheta=F/Math.max(1,O.nodes.length-1),O.nodes.length>1&&g){var Y=Math.cos(O.dTheta)-Math.cos(0),Z=Math.sin(O.dTheta)-Math.sin(0),rt=Math.sqrt(D*D/(Y*Y+Z*Z));V=Math.max(rt,V)}O.r=V,V+=D}),d){for(X=0,W=0,P=0;P<T.length;P++)I=T[P],U=(I.r||0)-W,X=Math.max(X,U);W=0,T.forEach(function(O,F){F===0&&(W=O.r||0),O.r=W,W+=X})}return T.forEach(function(O){var F=O.dTheta||0,Y=O.r||0;O.nodes.forEach(function(Z,rt){var et=p+(h?1:-1)*F*rt;Z.data.x=z[0]+Y*Math.cos(et),Z.data.y=z[1]+Y*Math.sin(et)})}),e&&k.forEach(function(O){return t.mergeNodeData(O.id,{x:O.data.x,y:O.data.y})}),q={nodes:k,edges:E},[2,q]})})},i}(),Xo={gForce:!0,force2:!0,d3force:!0,fruchterman:!0,forceAtlas2:!0,force:!0,"graphin-force":!0},Qo={center:[0,0],comboPadding:10,treeKey:"combo"},Jo=function(){function i(e){e===void 0&&(e={}),this.options=e,this.id="comboCombined",this.options=R(R({},Qo),e)}return i.prototype.execute=function(e,t){return K(this,void 0,void 0,function(){return H(this,function(r){return[2,this.genericComboCombinedLayout(!1,e,t)]})})},i.prototype.assign=function(e,t){return K(this,void 0,void 0,function(){return H(this,function(r){switch(r.label){case 0:return[4,this.genericComboCombinedLayout(!0,e,t)];case 1:return r.sent(),[2]}})})},i.prototype.genericComboCombinedLayout=function(e,t,r){return K(this,void 0,void 0,function(){var n,o,a,s,f,u,l,h,d,g,v,p,w,c,m,E,x,N,z,k,b,A,y;return H(this,function(S){switch(S.label){case 0:return n=this.initVals(R(R({},this.options),r)),o=n.center,a=n.treeKey,s=n.outerLayout,f=t.getAllNodes().filter(function(_){return!_.data._isCombo}),u=t.getAllNodes().filter(function(_){return _.data._isCombo}),l=t.getAllEdges(),h=f==null?void 0:f.length,!h||h===1?[2,Lt(t,e,o)]:(d=[],g=new Map,f.forEach(function(_){g.set(_.id,_)}),v=new Map,u.forEach(function(_){v.set(_.id,_)}),p=new Map,w=this.getInnerGraphs(t,a,g,v,l,n,p),[4,Promise.all(w)]);case 1:return S.sent(),c=new Map,m=[],E=new Map,x=!0,t.getRoots(a).forEach(function(_){var M=p.get(_.id),T=v.get(_.id)||g.get(_.id),L={id:_.id,data:R(R({},_.data),{x:M.data.x||T.data.x,y:M.data.y||T.data.y,fx:M.data.fx||T.data.fx,fy:M.data.fy||T.data.fy,mass:M.data.mass||T.data.mass,size:M.data.size})};m.push(L),c.set(_.id,!0),!isNaN(L.data.x)&&L.data.x!==0&&!isNaN(L.data.y)&&L.data.y!==0?x=!1:(L.data.x=Math.random()*100,L.data.y=Math.random()*100),Ie(t,[_],function(D){D.id!==_.id&&E.set(D.id,_.id)},"TB",a)}),N=[],l.forEach(function(_){var M=E.get(_.source)||_.source,T=E.get(_.target)||_.target;M!==T&&c.has(M)&&c.has(T)&&N.push({id:_.id,source:M,target:T,data:{}})}),m!=null&&m.length?m.length!==1?[3,2]:(m[0].data.x=o[0],m[0].data.y=o[1],[3,6]):[3,7];case 2:return k=new ft({nodes:m,edges:N}),b=s||new Fr,x&&Xo[b.id]?(A=m.length<100?new Ir:new Be,[4,A.assign(k)]):[3,4];case 3:S.sent(),S.label=4;case 4:return[4,b.execute(k,R({center:o,kg:5,preventOverlap:!0,animate:!1},b.id==="force"?{gravity:1,factor:4,linkDistance:function(_,M,T){var L=Math.max.apply(Math,ut([],st(M.data.size)))||32,D=Math.max.apply(Math,ut([],st(T.data.size)))||32;return L/2+D/2+200}}:{}))];case 5:z=S.sent(),S.label=6;case 6:p.forEach(function(_){var M,T=z.nodes.find(function(X){return X.id===_.id});if(T){var L=T.data,D=L.x,$=L.y;_.data.visited=!0,_.data.x=D,_.data.y=$,d.push({id:_.id,data:{x:D,y:$}})}var C=_.data,G=C.x,V=C.y;(M=_.data.nodes)===null||M===void 0||M.forEach(function(X){d.push({id:X.id,data:{x:X.data.x+G,y:X.data.y+V}})})}),p.forEach(function(_){var M,T=_.data,L=T.x,D=T.y,$=T.visited,C=T.nodes;(M=C)===null||M===void 0||M.forEach(function(G){if(!$){var V=d.find(function(X){return X.id===G.id});V.data.x+=L||0,V.data.y+=D||0}})}),S.label=7;case 7:return e&&d.forEach(function(_){t.mergeNodeData(_.id,{x:_.data.x,y:_.data.y})}),y={nodes:d,edges:l},[2,y]}})})},i.prototype.initVals=function(e){var t=R({},e),r=e.nodeSize,n=e.spacing,o=e.comboPadding,a,s;if(Q(n)?s=function(){return n}:yt(n)?s=n:s=function(){return 0},t.spacing=s,!r)a=function(d){var g=s(d);if(d.size){if(lt(d.size)){var v=d.size[0]>d.size[1]?d.size[0]:d.size[1];return(v+g)/2}if(_t(d.size)){var v=d.size.width>d.size.height?d.size.width:d.size.height;return(v+g)/2}return(d.size+g)/2}return 32+g/2};else if(yt(r))a=function(d){var g=r(d),v=s(d);if(lt(d.size)){var p=d.size[0]>d.size[1]?d.size[0]:d.size[1];return(p+v)/2}return((g||32)+v)/2};else if(lt(r)){var f=r[0]>r[1]?r[0]:r[1],u=f/2;a=function(d){return u+s(d)/2}}else{var l=r/2;a=function(d){return l+s(d)/2}}t.nodeSize=a;var h;return Q(o)?h=function(){return o}:lt(o)?h=function(){return Math.max.apply(null,o)}:yt(o)?h=o:h=function(){return 0},t.comboPadding=h,t},i.prototype.getInnerGraphs=function(e,t,r,n,o,a,s){var f=this,u=a.nodeSize,l=a.comboPadding,h=a.spacing,d=a.innerLayout,g=d||new Be({}),v={center:[0,0],preventOverlap:!0,nodeSpacing:h},p=[],w=function(c){var m=(l==null?void 0:l(c))||10;return lt(m)&&(m=Math.max.apply(Math,ut([],st(m)))),{size:m?[m*2,m*2]:[30,30],padding:m}};return e.getRoots(t).forEach(function(c){s.set(c.id,{id:c.id,data:{nodes:[],size:w(c).size}});var m=Promise.resolve();Ie(e,[c],function(E){var x;if(E.data._isCombo){var N=w(E),z=N.size,k=N.padding;if(!(!((x=e.getChildren(E.id,t))===null||x===void 0)&&x.length))s.set(E.id,{id:E.id,data:R(R({},E.data),{size:z})});else{var b=s.get(E.id);s.set(E.id,{id:E.id,data:R({nodes:[]},b==null?void 0:b.data)});var A=new Map,y=e.getChildren(E.id,t).map(function(M){if(M.data._isCombo)return s.has(M.id)||s.set(M.id,{id:M.id,data:R({},M.data)}),A.set(M.id,!0),s.get(M.id);var T=r.get(M.id)||n.get(M.id);return A.set(M.id,!0),{id:M.id,data:R(R({},T.data),M.data)}}),S={nodes:y,edges:o.filter(function(M){return A.has(M.source)&&A.has(M.target)})},_=1/0;y.forEach(function(M){var T,L,D=M.data.size;D||(D=((T=s.get(M.id))===null||T===void 0?void 0:T.data.size)||((L=u)===null||L===void 0?void 0:L(M))||[30,30]),Q(D)&&(D=[D,D]);var $=st(D,2),C=$[0],G=$[1];_>C&&(_=C),_>G&&(_=G),M.data.size=D}),m=m.then(function(){return K(f,void 0,void 0,function(){var M,T,L,D,$,C,G,V,X;return H(this,function(W){switch(W.label){case 0:return M=new ft(S),[4,g.assign(M,v)];case 1:return T=W.sent(),L=Kn(y),D=L.minX,$=L.minY,C=L.maxX,G=L.maxY,V={x:(C+D)/2,y:(G+$)/2},S.nodes.forEach(function(P){P.data.x-=V.x,P.data.y-=V.y}),X=[Math.max(C-D,_)+k*2,Math.max(G-$,_)+k*2],s.get(E.id).data.size=X,s.get(E.id).data.nodes=y,[2,T]}})})})}return!0}},"BT",t),p.push(m)}),p},i}();function Zo(i,e){var t,r=1;i==null&&(i=0),e==null&&(e=0);function n(){var o,a=t.length,s,f=0,u=0;for(o=0;o<a;++o)s=t[o],f+=s.x,u+=s.y;for(f=(f/a-i)*r,u=(u/a-e)*r,o=0;o<a;++o)s=t[o],s.x-=f,s.y-=u}return n.initialize=function(o){t=o},n.x=function(o){return arguments.length?(i=+o,n):i},n.y=function(o){return arguments.length?(e=+o,n):e},n.strength=function(o){return arguments.length?(r=+o,n):r},n}function pt(i){return function(){return i}}function Rt(i){return(i()-.5)*1e-6}function Ko(i){return i.x+i.vx}function Ho(i){return i.y+i.vy}function $r(i){var e,t,r,n=1,o=1;typeof i!="function"&&(i=pt(i==null?1:+i));function a(){for(var u,l=e.length,h,d,g,v,p,w,c=0;c<o;++c)for(h=ve(e,Ko,Ho).visitAfter(s),u=0;u<l;++u)d=e[u],p=t[d.index],w=p*p,g=d.x+d.vx,v=d.y+d.vy,h.visit(m);function m(E,x,N,z,k){var b=E.data,A=E.r,y=p+A;if(b){if(b.index>d.index){var S=g-b.x-b.vx,_=v-b.y-b.vy,M=S*S+_*_;M<y*y&&(S===0&&(S=Rt(r),M+=S*S),_===0&&(_=Rt(r),M+=_*_),M=(y-(M=Math.sqrt(M)))/M*n,d.vx+=(S*=M)*(y=(A*=A)/(w+A)),d.vy+=(_*=M)*y,b.vx-=S*(y=1-y),b.vy-=_*y)}return}return x>g+y||z<g-y||N>v+y||k<v-y}}function s(u){if(u.data)return u.r=t[u.data.index];for(var l=u.r=0;l<4;++l)u[l]&&u[l].r>u.r&&(u.r=u[l].r)}function f(){if(e){var u,l=e.length,h;for(t=new Array(l),u=0;u<l;++u)h=e[u],t[h.index]=+i(h,u,e)}}return a.initialize=function(u,l){e=u,r=l,f()},a.iterations=function(u){return arguments.length?(o=+u,a):o},a.strength=function(u){return arguments.length?(n=+u,a):n},a.radius=function(u){return arguments.length?(i=typeof u=="function"?u:pt(+u),f(),a):i},a}function ta(i){return i.index}function Br(i,e){var t=i.get(e);if(!t)throw new Error("node not found: "+e);return t}function Ve(i){var e=ta,t=h,r,n=pt(30),o,a,s,f,u,l=1;i==null&&(i=[]);function h(w){return 1/Math.min(s[w.source.index],s[w.target.index])}function d(w){for(var c=0,m=i.length;c<l;++c)for(var E=0,x,N,z,k,b,A,y;E<m;++E)x=i[E],N=x.source,z=x.target,k=z.x+z.vx-N.x-N.vx||Rt(u),b=z.y+z.vy-N.y-N.vy||Rt(u),A=Math.sqrt(k*k+b*b),A=(A-o[E])/A*w*r[E],k*=A,b*=A,z.vx-=k*(y=f[E]),z.vy-=b*y,N.vx+=k*(y=1-y),N.vy+=b*y}function g(){if(a){var w,c=a.length,m=i.length,E=new Map(a.map((N,z)=>[e(N,z,a),N])),x;for(w=0,s=new Array(c);w<m;++w)x=i[w],x.index=w,typeof x.source!="object"&&(x.source=Br(E,x.source)),typeof x.target!="object"&&(x.target=Br(E,x.target)),s[x.source.index]=(s[x.source.index]||0)+1,s[x.target.index]=(s[x.target.index]||0)+1;for(w=0,f=new Array(m);w<m;++w)x=i[w],f[w]=s[x.source.index]/(s[x.source.index]+s[x.target.index]);r=new Array(m),v(),o=new Array(m),p()}}function v(){if(a)for(var w=0,c=i.length;w<c;++w)r[w]=+t(i[w],w,i)}function p(){if(a)for(var w=0,c=i.length;w<c;++w)o[w]=+n(i[w],w,i)}return d.initialize=function(w,c){a=w,u=c,g()},d.links=function(w){return arguments.length?(i=w,g(),d):i},d.id=function(w){return arguments.length?(e=w,d):e},d.iterations=function(w){return arguments.length?(l=+w,d):l},d.strength=function(w){return arguments.length?(t=typeof w=="function"?w:pt(+w),v(),d):t},d.distance=function(w){return arguments.length?(n=typeof w=="function"?w:pt(+w),p(),d):n},d}var ea={value:()=>{}};function Vr(){for(var i=0,e=arguments.length,t={},r;i<e;++i){if(!(r=arguments[i]+"")||r in t||/[\s.]/.test(r))throw new Error("illegal type: "+r);t[r]=[]}return new pe(t)}function pe(i){this._=i}function ra(i,e){return i.trim().split(/^|\s+/).map(function(t){var r="",n=t.indexOf(".");if(n>=0&&(r=t.slice(n+1),t=t.slice(0,n)),t&&!e.hasOwnProperty(t))throw new Error("unknown type: "+t);return{type:t,name:r}})}pe.prototype=Vr.prototype={constructor:pe,on:function(i,e){var t=this._,r=ra(i+"",t),n,o=-1,a=r.length;if(arguments.length<2){for(;++o<a;)if((n=(i=r[o]).type)&&(n=na(t[n],i.name)))return n;return}if(e!=null&&typeof e!="function")throw new Error("invalid callback: "+e);for(;++o<a;)if(n=(i=r[o]).type)t[n]=Ur(t[n],i.name,e);else if(e==null)for(n in t)t[n]=Ur(t[n],i.name,null);return this},copy:function(){var i={},e=this._;for(var t in e)i[t]=e[t].slice();return new pe(i)},call:function(i,e){if((n=arguments.length-2)>0)for(var t=new Array(n),r=0,n,o;r<n;++r)t[r]=arguments[r+2];if(!this._.hasOwnProperty(i))throw new Error("unknown type: "+i);for(o=this._[i],r=0,n=o.length;r<n;++r)o[r].value.apply(e,t)},apply:function(i,e,t){if(!this._.hasOwnProperty(i))throw new Error("unknown type: "+i);for(var r=this._[i],n=0,o=r.length;n<o;++n)r[n].value.apply(e,t)}};function na(i,e){for(var t=0,r=i.length,n;t<r;++t)if((n=i[t]).name===e)return n.value}function Ur(i,e,t){for(var r=0,n=i.length;r<n;++r)if(i[r].name===e){i[r]=ea,i=i.slice(0,r).concat(i.slice(r+1));break}return t!=null&&i.push({name:e,value:t}),i}var Bt=0,Xt=0,Qt=0,Wr=1e3,we,Jt,me=0,Pt=0,ye=0,Zt=typeof performance=="object"&&performance.now?performance:Date,Yr=typeof window=="object"&&window.requestAnimationFrame?window.requestAnimationFrame.bind(window):function(i){setTimeout(i,17)};function Gr(){return Pt||(Yr(ia),Pt=Zt.now()+ye)}function ia(){Pt=0}function Ue(){this._call=this._time=this._next=null}Ue.prototype=Xr.prototype={constructor:Ue,restart:function(i,e,t){if(typeof i!="function")throw new TypeError("callback is not a function");t=(t==null?Gr():+t)+(e==null?0:+e),!this._next&&Jt!==this&&(Jt?Jt._next=this:we=this,Jt=this),this._call=i,this._time=t,We()},stop:function(){this._call&&(this._call=null,this._time=1/0,We())}};function Xr(i,e,t){var r=new Ue;return r.restart(i,e,t),r}function oa(){Gr(),++Bt;for(var i=we,e;i;)(e=Pt-i._time)>=0&&i._call.call(void 0,e),i=i._next;--Bt}function Qr(){Pt=(me=Zt.now())+ye,Bt=Xt=0;try{oa()}finally{Bt=0,sa(),Pt=0}}function aa(){var i=Zt.now(),e=i-me;e>Wr&&(ye-=e,me=i)}function sa(){for(var i,e=we,t,r=1/0;e;)e._call?(r>e._time&&(r=e._time),i=e,e=e._next):(t=e._next,e._next=null,e=i?i._next=t:we=t);Jt=i,We(r)}function We(i){if(!Bt){Xt&&(Xt=clearTimeout(Xt));var e=i-Pt;e>24?(i<1/0&&(Xt=setTimeout(Qr,i-Zt.now()-ye)),Qt&&(Qt=clearInterval(Qt))):(Qt||(me=Zt.now(),Qt=setInterval(aa,Wr)),Bt=1,Yr(Qr))}}const ua=1664525,fa=1013904223,Jr=4294967296;function la(){let i=1;return()=>(i=(ua*i+fa)%Jr)/Jr}function ha(i){return i.x}function da(i){return i.y}var ca=10,ga=Math.PI*(3-Math.sqrt(5));function Zr(i){var e,t=1,r=.001,n=1-Math.pow(r,1/300),o=0,a=.6,s=new Map,f=Xr(h),u=Vr("tick","end"),l=la();i==null&&(i=[]);function h(){d(),u.call("tick",e),t<r&&(f.stop(),u.call("end",e))}function d(p){var w,c=i.length,m;p===void 0&&(p=1);for(var E=0;E<p;++E)for(t+=(o-t)*n,s.forEach(function(x){x(t)}),w=0;w<c;++w)m=i[w],m.fx==null?m.x+=m.vx*=a:(m.x=m.fx,m.vx=0),m.fy==null?m.y+=m.vy*=a:(m.y=m.fy,m.vy=0);return e}function g(){for(var p=0,w=i.length,c;p<w;++p){if(c=i[p],c.index=p,c.fx!=null&&(c.x=c.fx),c.fy!=null&&(c.y=c.fy),isNaN(c.x)||isNaN(c.y)){var m=ca*Math.sqrt(.5+p),E=p*ga;c.x=m*Math.cos(E),c.y=m*Math.sin(E)}(isNaN(c.vx)||isNaN(c.vy))&&(c.vx=c.vy=0)}}function v(p){return p.initialize&&p.initialize(i,l),p}return g(),e={tick:d,restart:function(){return f.restart(h),e},stop:function(){return f.stop(),e},nodes:function(p){return arguments.length?(i=p,g(),s.forEach(v),e):i},alpha:function(p){return arguments.length?(t=+p,e):t},alphaMin:function(p){return arguments.length?(r=+p,e):r},alphaDecay:function(p){return arguments.length?(n=+p,e):+n},alphaTarget:function(p){return arguments.length?(o=+p,e):o},velocityDecay:function(p){return arguments.length?(a=1-p,e):1-a},randomSource:function(p){return arguments.length?(l=p,s.forEach(v),e):l},force:function(p,w){return arguments.length>1?(w==null?s.delete(p):s.set(p,v(w)),e):s.get(p)},find:function(p,w,c){var m=0,E=i.length,x,N,z,k,b;for(c==null?c=1/0:c*=c,m=0;m<E;++m)k=i[m],x=p-k.x,N=w-k.y,z=x*x+N*N,z<c&&(b=k,c=z);return b},on:function(p,w){return arguments.length>1?(u.on(p,w),e):u.on(p)}}}function Kr(){var i,e,t,r,n=pt(-30),o,a=1,s=1/0,f=.81;function u(g){var v,p=i.length,w=ve(i,ha,da).visitAfter(h);for(r=g,v=0;v<p;++v)e=i[v],w.visit(d)}function l(){if(i){var g,v=i.length,p;for(o=new Array(v),g=0;g<v;++g)p=i[g],o[p.index]=+n(p,g,i)}}function h(g){var v=0,p,w,c=0,m,E,x;if(g.length){for(m=E=x=0;x<4;++x)(p=g[x])&&(w=Math.abs(p.value))&&(v+=p.value,c+=w,m+=w*p.x,E+=w*p.y);g.x=m/c,g.y=E/c}else{p=g,p.x=p.data.x,p.y=p.data.y;do v+=o[p.data.index];while(p=p.next)}g.value=v}function d(g,v,p,w){if(!g.value)return!0;var c=g.x-e.x,m=g.y-e.y,E=w-v,x=c*c+m*m;if(E*E/f<x)return x<s&&(c===0&&(c=Rt(t),x+=c*c),m===0&&(m=Rt(t),x+=m*m),x<a&&(x=Math.sqrt(a*x)),e.vx+=c*g.value*r/x,e.vy+=m*g.value*r/x),!0;if(g.length||x>=s)return;(g.data!==e||g.next)&&(c===0&&(c=Rt(t),x+=c*c),m===0&&(m=Rt(t),x+=m*m),x<a&&(x=Math.sqrt(a*x)));do g.data!==e&&(E=o[g.data.index]*r/x,e.vx+=c*E,e.vy+=m*E);while(g=g.next)}return u.initialize=function(g,v){i=g,t=v,l()},u.strength=function(g){return arguments.length?(n=typeof g=="function"?g:pt(+g),l(),u):n},u.distanceMin=function(g){return arguments.length?(a=g*g,u):Math.sqrt(a)},u.distanceMax=function(g){return arguments.length?(s=g*g,u):Math.sqrt(s)},u.theta=function(g){return arguments.length?(f=g*g,u):Math.sqrt(f)},u}function va(i){var e=pt(.1),t,r,n;typeof i!="function"&&(i=pt(i==null?0:+i));function o(s){for(var f=0,u=t.length,l;f<u;++f)l=t[f],l.vx+=(n[f]-l.x)*r[f]*s}function a(){if(t){var s,f=t.length;for(r=new Array(f),n=new Array(f),s=0;s<f;++s)r[s]=isNaN(n[s]=+i(t[s],s,t))?0:+e(t[s],s,t)}}return o.initialize=function(s){t=s,a()},o.strength=function(s){return arguments.length?(e=typeof s=="function"?s:pt(+s),a(),o):e},o.x=function(s){return arguments.length?(i=typeof s=="function"?s:pt(+s),a(),o):i},o}function pa(i){var e=pt(.1),t,r,n;typeof i!="function"&&(i=pt(i==null?0:+i));function o(s){for(var f=0,u=t.length,l;f<u;++f)l=t[f],l.vy+=(n[f]-l.y)*r[f]*s}function a(){if(t){var s,f=t.length;for(r=new Array(f),n=new Array(f),s=0;s<f;++s)r[s]=isNaN(n[s]=+i(t[s],s,t))?0:+e(t[s],s,t)}}return o.initialize=function(s){t=s,a()},o.strength=function(s){return arguments.length?(e=typeof s=="function"?s:pt(+s),a(),o):e},o.y=function(s){return arguments.length?(i=typeof s=="function"?s:pt(+s),a(),o):i},o}function Hr(){function i(I){return function(){return I}}var e=function(I){return I.cluster},t=i(1),r=i(-1),n=i(100),o=i(.1),a=[0,0],s=[],f={},u=[],l=100,h=100,d={none:{x:0,y:0}},g=[],v,p="force",w=!0,c=.1;function m(I){if(!w)return m;v.tick(),b();for(var U=0,q=s.length,B=void 0,O=I*c;U<q;++U)B=s[U],B.vx+=(d[e(B)].x-B.x)*O,B.vy+=(d[e(B)].y-B.y)*O}function E(){s&&x()}function x(){if(!(!s||!s.length)){if(e(s[0])===void 0)throw Error("Couldnt find the grouping attribute for the nodes. Make sure to set it up with forceInBox.groupBy('clusterAttr') before calling .links()");var I=N();v=Zr(I.nodes).force("x",va(l).strength(.1)).force("y",pa(h).strength(.1)).force("collide",$r(function(U){return U.r}).iterations(4)).force("charge",Kr().strength(r)).force("links",Ve(I.nodes.length?I.links:[]).distance(n).strength(o)),g=v.nodes(),b()}}function N(){var I=[],U=[],q={},B=[],O={},F=[];return O=z(s),F=k(u),B=Object.keys(O),B.forEach(function(Y,Z){var rt=O[Y];I.push({id:Y,size:rt.count,r:Math.sqrt(rt.sumforceNodeSize/Math.PI)}),q[Y]=Z}),F.forEach(function(Y){var Z=Y.source,rt=Y.target,et=q[Z],mt=q[rt];et!==void 0&&mt!==void 0&&U.push({source:et,target:mt,count:Y.count})}),{nodes:I,links:U}}function z(I){var U={};return I.forEach(function(q){var B=e(q);U[B]||(U[B]={count:0,sumforceNodeSize:0})}),I.forEach(function(q){var B=e(q),O=t(q),F=U[B];F.count=F.count+1,F.sumforceNodeSize=F.sumforceNodeSize+Math.PI*(O*O)*1.3,U[B]=F}),U}function k(I){var U={},q=[];I.forEach(function(O){var F=A(O),Y=0;U[F]!==void 0&&(Y=U[F]),Y+=1,U[F]=Y});var B=Object.entries(U);return B.forEach(function(O){var F=st(O,2),Y=F[0],Z=F[1],rt=Y.split("~")[0],et=Y.split("~")[1];rt!==void 0&&et!==void 0&&q.push({source:rt,target:et,count:Z})}),q}function b(){return d={none:{x:0,y:0}},g.forEach(function(I){d[I.id]={x:I.x-a[0],y:I.y-a[1]}}),d}function A(I){var U=I.source,q=I.target,B=e(f[U]),O=e(f[q]);return B<=O?B+"~"+O:O+"~"+B}function y(I){f={},I.forEach(function(U){f[U.id]=U})}function S(I){return arguments.length?(p=I,E(),m):p}function _(I){return arguments.length?typeof I=="string"?(e=function(U){return U[I]},m):(e=I,m):e}function M(I){return arguments.length?(w=I,m):w}function T(I){return arguments.length?(c=I,m):c}function L(I){return arguments.length?(l=I,m):l}function D(I){return arguments.length?(h=I,m):h}function $(I){return arguments.length?(y(I||[]),s=I||[],m):s}function C(I){return arguments.length?(u=I||[],E(),m):u}function G(I){return arguments.length?(typeof I=="function"?t=I:t=i(+I),E(),m):t}function V(I){return arguments.length?(typeof I=="function"?r=I:r=i(+I),E(),m):r}function X(I){return arguments.length?(typeof I=="function"?n=I:n=i(+I),E(),m):n}function W(I){return arguments.length?(typeof I=="function"?o=I:o=i(+I),E(),m):o}function P(I){return arguments.length?(a=I,m):a}return m.initialize=function(I){s=I,E()},m.template=S,m.groupBy=_,m.enableGrouping=M,m.strength=T,m.centerX=L,m.centerY=D,m.nodes=$,m.links=C,m.forceNodeSize=G,m.nodeSize=m.forceNodeSize,m.forceCharge=V,m.forceLinkDistance=X,m.forceLinkStrength=W,m.offset=P,m.getFocis=b,m}var wa={center:[0,0],preventOverlap:!1,nodeSize:void 0,nodeSpacing:void 0,linkDistance:50,forceSimulation:null,alphaDecay:.028,alphaMin:.001,alpha:.3,collideStrength:1,clustering:!1,clusterNodeStrength:-1,clusterEdgeStrength:.1,clusterEdgeDistance:100,clusterFociStrength:.8,clusterNodeSize:10},ma=function(){function i(e){e===void 0&&(e={}),this.options=e,this.id="d3force",this.options=R(R({},wa),e)}return i.prototype.execute=function(e,t){return K(this,void 0,void 0,function(){return H(this,function(r){return[2,this.genericForceLayout(!1,e,t)]})})},i.prototype.assign=function(e,t){return K(this,void 0,void 0,function(){return H(this,function(r){return this.genericForceLayout(!0,e,t),[2]})})},i.prototype.stop=function(){var e;(e=this.forceSimulation)===null||e===void 0||e.stop()},i.prototype.tick=function(e){var t=this;e===void 0&&(e=1),this.forceSimulation.tick(e);var r={nodes:Ee(this.lastLayoutNodes),edges:xe(this.lastLayoutEdges)};return this.lastAssign&&r.nodes.forEach(function(n){return t.lastGraph.mergeNodeData(n.id,{x:n.data.x,y:n.data.y})}),r},i.prototype.genericForceLayout=function(e,t,r){return K(this,void 0,void 0,function(){var n,o,a,s,f,u,l,h,d,g,v,p,w,c,m,E,x,N,z,k,b,A,y,S,_,M,T=this;return H(this,function(L){return n=R(R({},this.options),r),o=t.getAllNodes(),a=t.getAllEdges(),s=o.map(function(D){var $,C;return R(R({},ct(D)),{x:($=D.data)===null||$===void 0?void 0:$.x,y:(C=D.data)===null||C===void 0?void 0:C.y})}),f=a.map(function(D){return ct(D)}),this.lastLayoutNodes=s,this.lastLayoutEdges=f,this.lastAssign=e,this.lastGraph=t,u=n.alphaMin,l=n.alphaDecay,h=n.alpha,d=n.nodeStrength,g=n.edgeStrength,v=n.linkDistance,p=n.clustering,w=n.clusterFociStrength,c=n.clusterEdgeDistance,m=n.clusterEdgeStrength,E=n.clusterNodeStrength,x=n.clusterNodeSize,N=n.collideStrength,z=N===void 0?1:N,k=n.center,b=k===void 0?[0,0]:k,A=n.preventOverlap,y=n.nodeSize,S=n.nodeSpacing,_=n.onTick,M=n.forceSimulation,[2,new Promise(function(D){if(M){if(p){var C=Hr();C.nodes(s),C.links(f)}if(M.nodes(s),f){var G=Ve().id(function(P){return P.id}).links(f);g&&G.strength(g),v&&G.distance(v),M.force("link",G)}A&&T.overlapProcess(M,{nodeSize:y,nodeSpacing:S,collideStrength:z}),M.alpha(h).restart();var V=Ee(s),X=xe(f);e&&V.forEach(function(W){return t.mergeNodeData(W.id,{x:W.data.x,y:W.data.y})}),D({nodes:V,edges:X})}else try{var $=Kr();if(d&&$.strength(d),M=Zr().nodes(s),p){var C=Hr();C.centerX(b[0]).centerY(b[1]).template("force").strength(w),f&&C.links(f),s&&C.nodes(s),C.forceLinkDistance(c).forceLinkStrength(m).forceCharge(E).forceNodeSize(x),M.force("group",C)}if(M.force("center",Zo(b[0],b[1])).force("charge",$).alpha(h).alphaDecay(l).alphaMin(u),A&&T.overlapProcess(M,{nodeSize:y,nodeSpacing:S,collideStrength:z}),f){var G=Ve().id(function(W){return W.id}).links(f);g&&G.strength(g),v&&G.distance(v),M.force("link",G)}M.on("tick",function(){var W=Ee(s);_==null||_({nodes:W,edges:xe(f)}),e&&W.forEach(function(P){return t.mergeNodeData(P.id,{x:P.data.x,y:P.data.y})})}).on("end",function(){var W=Ee(s);e&&W.forEach(function(P){return t.mergeNodeData(P.id,{x:P.data.x,y:P.data.y})}),D({nodes:W,edges:xe(f)})})}catch(W){console.warn(W)}T.forceSimulation=M})]})})},i.prototype.overlapProcess=function(e,t){var r=t.nodeSize,n=t.nodeSpacing,o=t.collideStrength,a,s;if(Q(n)?s=function(){return n}:yt(n)?s=n:s=function(){return 0},!r)a=function(h){if(h.size){if(lt(h.size)){var d=h.size[0]>h.size[1]?h.size[0]:h.size[1];return d/2+s(h)}if(_t(h.size)){var d=h.size.width>h.size.height?h.size.width:h.size.height;return d/2+s(h)}return h.size/2+s(h)}return 10+s(h)};else if(yt(r))a=function(h){var d=r(h);return d+s(h)};else if(lt(r)){var f=r[0]>r[1]?r[0]:r[1],u=f/2;a=function(h){return u+s(h)}}else if(Q(r)){var l=r/2;a=function(h){return l+s(h)}}else a=function(){return 10};e.force("collisionForce",$r(a).strength(o))},i}(),Ee=function(i){return i.map(function(e){var t=e.x,r=e.y,n=Wt(e,["x","y"]);return R(R({},n),{data:R(R({},n.data),{x:t,y:r})})})},xe=function(i){return i.map(function(e){var t=e.source,r=e.target,n=Wt(e,["source","target"]);return R(R({},n),{source:t.id,target:r.id})})},ya=function(i,e){if(i!=="next"&&i!=="prev")return e},tn=function(i){i.prev.next=i.next,i.next.prev=i.prev,delete i.next,delete i.prev},Ea=function(){function i(){var e={};e.prev=e,e.next=e.prev,this.shortcut=e}return i.prototype.dequeue=function(){var e=this.shortcut,t=e.prev;if(t&&t!==e)return tn(t),t},i.prototype.enqueue=function(e){var t=this.shortcut;e.prev&&e.next&&tn(e),e.next=t.next,t.next.prev=e,t.next=e,e.prev=t},i.prototype.toString=function(){for(var e=[],t=this.shortcut,r=t.prev;r!==t;)e.push(JSON.stringify(r,ya)),r=r==null?void 0:r.prev;return"["+e.join(", ")+"]"},i}(),xa=Ea,Na=function(i){at(e,i);function e(){return i!==null&&i.apply(this,arguments)||this}return e}(xa),ba=function(){return 1},Ma=function(i,e){var t;if(i.getAllNodes().length<=1)return[];var r=ka(i,e||ba),n=Sa(r.graph,r.buckets,r.zeroIdx);return(t=n.map(function(o){return i.getRelatedEdges(o.v,"out").filter(function(a){var s=a.target;return s===o.w})}))===null||t===void 0?void 0:t.flat()},Sa=function(i,e,t){for(var r=[],n=e[e.length-1],o=e[0],a;i.getAllNodes().length;){for(;a=o.dequeue();)Ye(i,e,t,a);for(;a=n.dequeue();)Ye(i,e,t,a);if(i.getAllNodes().length){for(var s=e.length-2;s>0;--s)if(a=e[s].dequeue(),a){r=r.concat(Ye(i,e,t,a,!0));break}}}return r},Ye=function(i,e,t,r,n){var o,a,s=[];return i.hasNode(r.v)&&((o=i.getRelatedEdges(r.v,"in"))===null||o===void 0||o.forEach(function(f){var u=f.data.weight,l=i.getNode(f.source);n&&s.push({v:f.source,w:f.target,in:0,out:0}),l.data.out===void 0&&(l.data.out=0),l.data.out-=u,Ge(e,t,R({v:l.id},l.data))}),(a=i.getRelatedEdges(r.v,"out"))===null||a===void 0||a.forEach(function(f){var u=f.data.weight,l=f.target,h=i.getNode(l);h.data.in===void 0&&(h.data.in=0),h.data.in-=u,Ge(e,t,R({v:h.id},h.data))}),i.removeNode(r.v)),n?s:void 0},ka=function(i,e){var t=new ft,r=0,n=0;i.getAllNodes().forEach(function(u){t.addNode({id:u.id,data:{v:u.id,in:0,out:0}})}),i.getAllEdges().forEach(function(u){var l=t.getRelatedEdges(u.source,"out").find(function(d){return d.target===u.target}),h=(e==null?void 0:e(u))||1;l?t.updateEdgeData(l==null?void 0:l.id,R(R({},l.data),{weight:l.data.weight+h})):t.addEdge({id:u.id,source:u.source,target:u.target,data:{weight:h}}),n=Math.max(n,t.getNode(u.source).data.out+=h),r=Math.max(r,t.getNode(u.target).data.in+=h)});for(var o=[],a=n+r+3,s=0;s<a;s++)o.push(new Na);var f=r+1;return t.getAllNodes().forEach(function(u){Ge(o,f,R({v:u.id},t.getNode(u.id).data))}),{buckets:o,zeroIdx:f,graph:t}},Ge=function(i,e,t){t.out?t.in?i[t.out-t.in+e].enqueue(t):i[i.length-1].enqueue(t):i[0].enqueue(t)},_a=function(i,e){var t=function(n){return function(o){return o.data.weight||1}},r=e==="greedy"?Ma(i,t()):za(i);r==null||r.forEach(function(n){var o=n.data;i.removeEdge(n.id),o.forwardName=n.data.name,o.reversed=!0,i.addEdge({id:n.id,source:n.target,target:n.source,data:R({},o)})})},za=function(i){var e=[],t={},r={},n=function(o){r[o]||(r[o]=!0,t[o]=!0,i.getRelatedEdges(o,"out").forEach(function(a){t[a.target]?e.push(a):n(a.target)}),delete t[o])};return i.getAllNodes().forEach(function(o){return n(o.id)}),e},Aa=function(i){i.getAllEdges().forEach(function(e){var t=e.data;if(t.reversed){i.removeEdge(e.id);var r=t.forwardName;delete t.reversed,delete t.forwardName,i.addEdge({id:e.id,source:e.target,target:e.source,data:R(R({},t),{forwardName:r})})}})},Ra=function(i,e){return Number(i)-Number(e)},Vt=function(i,e,t,r){var n;do n=""+r+Math.random();while(i.hasNode(n));return t.dummy=e,i.addNode({id:n,data:t}),n},Oa=function(i){var e=new ft;return i.getAllNodes().forEach(function(t){e.addNode(R({},t))}),i.getAllEdges().forEach(function(t){var r=e.getRelatedEdges(t.source,"out").find(function(n){return n.target===t.target});r?e.updateEdgeData(r==null?void 0:r.id,R(R({},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},en=function(i){var e=new ft;return i.getAllNodes().forEach(function(t){i.getChildren(t.id).length||e.addNode(R({},t))}),i.getAllEdges().forEach(function(t){e.addEdge(t)}),e},Ia=function(i,e){return i==null?void 0:i.reduce(function(t,r,n){return t[r]=e[n],t},{})},rn=function(i,e){var t=Number(i.x),r=Number(i.y),n=Number(e.x)-t,o=Number(e.y)-r,a=Number(i.width)/2,s=Number(i.height)/2;if(!n&&!o)return{x:0,y:0};var f,u;return Math.abs(o)*a>Math.abs(n)*s?(o<0&&(s=-s),f=s*n/o,u=s):(n<0&&(a=-a),f=a,u=a*o/n),{x:t+f,y:r+u}},Kt=function(i){for(var e=[],t=on(i)+1,r=0;r<t;r++)e.push([]);i.getAllNodes().forEach(function(n){var o=n.data.rank;o!==void 0&&e[o]&&e[o].push(n.id)});for(var r=0;r<t;r++)e[r]=e[r].sort(function(o,a){return Ra(i.getNode(o).data.order,i.getNode(a).data.order)});return e},Ta=function(i){var e=i.getAllNodes().filter(function(r){return r.data.rank!==void 0}).map(function(r){return r.data.rank}),t=Math.min.apply(Math,ut([],st(e)));i.getAllNodes().forEach(function(r){r.data.hasOwnProperty("rank")&&t!==1/0&&(r.data.rank-=t)})},La=function(i,e){e===void 0&&(e=0);var t=i.getAllNodes(),r=t.filter(function(u){return u.data.rank!==void 0}).map(function(u){return u.data.rank}),n=Math.min.apply(Math,ut([],st(r))),o=[];t.forEach(function(u){var l=(u.data.rank||0)-n;o[l]||(o[l]=[]),o[l].push(u.id)});for(var a=0,s=0;s<o.length;s++){var f=o[s];f===void 0?s%e!==0&&(a-=1):a&&(f==null||f.forEach(function(u){var l=i.getNode(u);l&&(l.data.rank=l.data.rank||0,l.data.rank+=a)}))}},nn=function(i,e,t,r){var n={width:0,height:0};return Q(t)&&Q(r)&&(n.rank=t,n.order=r),Vt(i,"border",n,e)},on=function(i){var e;return i.getAllNodes().forEach(function(t){var r=t.data.rank;r!==void 0&&(e===void 0||r>e)&&(e=r)}),e||(e=0),e},Da=function(i,e){var t={lhs:[],rhs:[]};return i==null||i.forEach(function(r){e(r)?t.lhs.push(r):t.rhs.push(r)}),t},Xe=function(i,e){return i.reduce(function(t,r){var n=e(t),o=e(r);return n>o?r:t})},an=function(i,e,t,r,n,o){r.includes(e.id)||(r.push(e.id),t||o.push(e.id),n(e.id).forEach(function(a){return an(i,a,t,r,n,o)}),t&&o.push(e.id))},sn=function(i,e,t,r){var n=Array.isArray(e)?e:[e],o=function(f){return r?i.getSuccessors(f):i.getNeighbors(f)},a=[],s=[];return n.forEach(function(f){if(i.hasNode(f.id))an(i,f,t==="post",s,o,a);else throw new Error("Graph does not have node: "+f)}),a},Pa="edge",un="edge-label",ja=function(i,e){i.getAllEdges().forEach(function(t){return Fa(i,t,e)})},Fa=function(i,e,t){var r=e.source,n=i.getNode(r).data.rank,o=e.target,a=i.getNode(o).data.rank,s=e.data.labelRank;if(a!==n+1){i.removeEdge(e.id);var f,u,l;for(l=0,++n;n<a;++l,++n)e.data.points=[],u={originalEdge:e,width:0,height:0,rank:n},f=Vt(i,Pa,u,"_d"),n===s&&(u.width=e.data.width,u.height=e.data.height,u.dummy=un,u.labelpos=e.data.labelpos),i.addEdge({id:"e"+Math.random(),source:r,target:f,data:{weight:e.data.weight}}),l===0&&t.push(f),r=f;i.addEdge({id:"e"+Math.random(),source:r,target:o,data:{weight:e.data.weight}})}},Ca=function(i,e){e.forEach(function(t){var r=i.getNode(t),n=r.data,o=n.originalEdge,a;o&&i.addEdge(o);for(var s=t;r.data.dummy;)a=i.getSuccessors(s)[0],i.removeNode(s),o.data.points.push({x:r.data.x,y:r.data.y}),r.data.dummy===un&&(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=a.id,r=i.getNode(s)})},fn=function(i){var e={},t=function(r){var n,o=i.getNode(r);if(!o)return 0;if(e[r])return o.data.rank;e[r]=!0;var a;return(n=i.getRelatedEdges(r,"out"))===null||n===void 0||n.forEach(function(s){var f=t(s.target),u=s.data.minlen,l=f-u;l&&(a===void 0||l<a)&&(a=l)}),a||(a=0),o.data.rank=a,a};i.getAllNodes().filter(function(r){return i.getRelatedEdges(r.id,"in").length===0}).forEach(function(r){return t(r.id)})},qa=function(i){var e={},t,r=function(a){var s,f=i.getNode(a);if(!f)return 0;if(e[a])return f.data.rank;e[a]=!0;var u;return(s=i.getRelatedEdges(a,"out"))===null||s===void 0||s.forEach(function(l){var h=r(l.target),d=l.data.minlen,g=h-d;g&&(u===void 0||g<u)&&(u=g)}),u||(u=0),(t===void 0||u<t)&&(t=u),f.data.rank=u,u};i.getAllNodes().filter(function(a){return i.getRelatedEdges(a.id,"in").length===0}).forEach(function(a){a&&r(a.id)}),t===void 0&&(t=0);var n={},o=function(a,s){var f,u=i.getNode(a),l=isNaN(u.data.layer)?s:u.data.layer;(u.data.rank===void 0||u.data.rank<l)&&(u.data.rank=l),!n[a]&&(n[a]=!0,(f=i.getRelatedEdges(a,"out"))===null||f===void 0||f.forEach(function(h){o(h.target,l+h.data.minlen)}))};i.getAllNodes().forEach(function(a){var s=a.data;s&&(isNaN(s.layer)?s.rank-=t:o(a.id,s.layer))})},Ot=function(i,e){return i.getNode(e.target).data.rank-i.getNode(e.source).data.rank-e.data.minlen},$a=function(i){var e=new ft({tree:[]}),t=i.getAllNodes()[0],r=i.getAllNodes().length;e.addNode(t);for(var n,o;Ba(e,i)<r;)n=ln(e,i),o=e.hasNode(n.source)?Ot(i,n):-Ot(i,n),hn(e,i,o);return e},Ba=function(i,e){var t=function(r){e.getRelatedEdges(r,"both").forEach(function(n){var o=n.source,a=r===o?n.target:o;!i.hasNode(a)&&!Ot(e,n)&&(i.addNode({id:a,data:{}}),i.addEdge({id:n.id,source:r,target:a,data:{}}),t(a))})};return i.getAllNodes().forEach(function(r){return t(r.id)}),i.getAllNodes().length},Va=function(i){var e=new ft({tree:[]}),t=i.getAllNodes()[0],r=i.getAllNodes().length;e.addNode(t);for(var n,o;Ua(e,i)<r;)n=ln(e,i),o=e.hasNode(n.source)?Ot(i,n):-Ot(i,n),hn(e,i,o);return e},Ua=function(i,e){var t=function(r){var n;(n=e.getRelatedEdges(r,"both"))===null||n===void 0||n.forEach(function(o){var a=o.source,s=r===a?o.target:a;!i.hasNode(s)&&(e.getNode(s).data.layer!==void 0||!Ot(e,o))&&(i.addNode({id:s,data:{}}),i.addEdge({id:o.id,source:r,target:s,data:{}}),t(s))})};return i.getAllNodes().forEach(function(r){return t(r.id)}),i.getAllNodes().length},ln=function(i,e){return Xe(e.getAllEdges(),function(t){return i.hasNode(t.source)!==i.hasNode(t.target)?Ot(e,t):1/0})},hn=function(i,e,t){i.getAllNodes().forEach(function(r){var n=e.getNode(r.id);n.data.rank||(n.data.rank=0),n.data.rank+=t})},Wa=function(i){var e=Oa(i);fn(e);var t=$a(e);cn(t),dn(t,e);for(var r,n;r=Xa(t);)n=Qa(t,e,r),Ja(t,e,r,n)},dn=function(i,e){var t=sn(i,i.getAllNodes(),"post",!1);t=t.slice(0,(t==null?void 0:t.length)-1),t.forEach(function(r){Ya(i,e,r)})},Ya=function(i,e,t){var r=i.getNode(t),n=r.data.parent,o=i.getRelatedEdges(t,"both").find(function(a){return a.target===n||a.source===n});o.data.cutvalue=Ga(i,e,t)},Ga=function(i,e,t){var r=i.getNode(t),n=r.data.parent,o=!0,a=e.getRelatedEdges(t,"out").find(function(f){return f.target===n}),s=0;return a||(o=!1,a=e.getRelatedEdges(n,"out").find(function(f){return f.target===t})),s=a.data.weight,e.getRelatedEdges(t,"both").forEach(function(f){var u=f.source===t,l=u?f.target:f.source;if(l!==n){var h=u===o,d=f.data.weight;if(s+=h?d:-d,Ka(i,t,l)){var g=i.getRelatedEdges(t,"both").find(function(v){return v.source===l||v.target===l}).data.cutvalue;s+=h?-g:g}}}),s},cn=function(i,e){e===void 0&&(e=i.getAllNodes()[0].id),gn(i,{},1,e)},gn=function(i,e,t,r,n){var o,a=t,s=t,f=i.getNode(r);return e[r]=!0,(o=i.getNeighbors(r))===null||o===void 0||o.forEach(function(u){e[u.id]||(s=gn(i,e,s,u.id,r))}),f.data.low=a,f.data.lim=s++,n?f.data.parent=n:delete f.data.parent,s},Xa=function(i){return i.getAllEdges().find(function(e){return e.data.cutvalue<0})},Qa=function(i,e,t){var r=t.source,n=t.target;e.getRelatedEdges(r,"out").find(function(l){return l.target===n})||(r=t.target,n=t.source);var o=i.getNode(r),a=i.getNode(n),s=o,f=!1;o.data.lim>a.data.lim&&(s=a,f=!0);var u=e.getAllEdges().filter(function(l){return f===vn(i.getNode(l.source),s)&&f!==vn(i.getNode(l.target),s)});return Xe(u,function(l){return Ot(e,l)})},Ja=function(i,e,t,r){var n=i.getRelatedEdges(t.source,"both").find(function(o){return o.source===t.target||o.target===t.target});n&&i.removeEdge(n.id),i.addEdge({id:"e"+Math.random(),source:r.source,target:r.target,data:{}}),cn(i),dn(i,e),Za(i,e)},Za=function(i,e){var t=i.getAllNodes().find(function(n){return!n.data.parent}),r=sn(i,t,"pre",!1);r=r.slice(1),r.forEach(function(n){var o=i.getNode(n).data.parent,a=e.getRelatedEdges(n,"out").find(function(f){return f.target===o}),s=!1;!a&&e.hasNode(o)&&(a=e.getRelatedEdges(o,"out").find(function(f){return f.target===n}),s=!0),e.getNode(n).data.rank=(e.hasNode(o)&&e.getNode(o).data.rank||0)+(s?a==null?void 0:a.data.minlen:-(a==null?void 0:a.data.minlen))})},Ka=function(i,e,t){return i.getRelatedEdges(e,"both").find(function(r){return r.source===t||r.target===t})},vn=function(i,e){return e.data.low<=i.data.lim&&i.data.lim<=e.data.lim},Ha=function(i,e){switch(e){case"network-simplex":es(i);break;case"tight-tree":pn(i);break;case"longest-path":ts(i);break;default:pn(i)}},ts=fn,pn=function(i){qa(i),Va(i)},es=function(i){Wa(i)},rs=function(i){var e={},t=0,r=function(n){var o=t;i.getChildren(n).forEach(function(a){return r(a.id)}),e[n]={low:o,lim:t++}};return i.getRoots().forEach(function(n){return r(n.id)}),e},ns=function(i,e,t,r){var n,o,a=[],s=[],f=Math.min(e[t].low,e[r].low),u=Math.max(e[t].lim,e[r].lim),l,h;l=t;do l=(n=i.getParent(l))===null||n===void 0?void 0:n.id,a.push(l);while(l&&(e[l].low>f||u>e[l].lim));for(h=l,l=r;l&&l!==h;)s.push(l),l=(o=i.getParent(l))===null||o===void 0?void 0:o.id;return{lca:h,path:a.concat(s.reverse())}},is=function(i,e){var t=rs(i);e.forEach(function(r){var n,o,a=r,s=i.getNode(a),f=s.data.originalEdge;if(f)for(var u=ns(i,t,f.source,f.target),l=u.path,h=u.lca,d=0,g=l[d],v=!0;a!==f.target;){if(s=i.getNode(a),v){for(;g!==h&&((n=i.getNode(g))===null||n===void 0?void 0:n.data.maxRank)<s.data.rank;)d++,g=l[d];g===h&&(v=!1)}if(!v){for(;d<l.length-1&&((o=i.getNode(l[d+1]))===null||o===void 0?void 0:o.data.minRank)<=s.data.rank;)d++;g=l[d]}i.hasNode(g)&&i.setParent(a,g),a=i.getSuccessors(a)[0].id}})},os=function(i){var e=Vt(i,"root",{},"_root"),t=as(i),r=Math.max.apply(Math,ut([],st(Object.values(t))));Math.abs(r)===1/0&&(r=1);var n=r-1,o=2*n+1;i.getAllEdges().forEach(function(s){s.data.minlen*=o});var a=ss(i)+1;return i.getRoots().forEach(function(s){wn(i,e,o,a,n,t,s.id)}),{nestingRoot:e,nodeRankFactor:o}},wn=function(i,e,t,r,n,o,a){var s=i.getChildren(a);if(!(s!=null&&s.length)){a!==e&&i.addEdge({id:"e"+Math.random(),source:e,target:a,data:{weight:0,minlen:t}});return}var f=nn(i,"_bt"),u=nn(i,"_bb"),l=i.getNode(a);i.setParent(f,a),l.data.borderTop=f,i.setParent(u,a),l.data.borderBottom=u,s==null||s.forEach(function(h){wn(i,e,t,r,n,o,h.id);var d=h.data.borderTop?h.data.borderTop:h.id,g=h.data.borderBottom?h.data.borderBottom:h.id,v=h.data.borderTop?r:2*r,p=d!==g?1:n-o[a]+1;i.addEdge({id:"e"+Math.random(),source:f,target:d,data:{minlen:p,weight:v,nestingEdge:!0}}),i.addEdge({id:"e"+Math.random(),source:g,target:u,data:{minlen:p,weight:v,nestingEdge:!0}})}),i.getParent(a)||i.addEdge({id:"e"+Math.random(),source:e,target:f,data:{weight:0,minlen:n+o[a]}})},as=function(i){var e={},t=function(r,n){var o=i.getChildren(r);o==null||o.forEach(function(a){return t(a.id,n+1)}),e[r]=n};return i.getRoots().forEach(function(r){return t(r.id,1)}),e},ss=function(i){var e=0;return i.getAllEdges().forEach(function(t){e+=t.data.weight}),e},us=function(i,e){e&&i.removeNode(e),i.getAllEdges().forEach(function(t){t.data.nestingEdge&&i.removeEdge(t.id)})},fs=function(i){var e=function(t){var r=i.getChildren(t),n=i.getNode(t);if(r!=null&&r.length&&r.forEach(function(s){return e(s.id)}),n.data.hasOwnProperty("minRank")){n.data.borderLeft=[],n.data.borderRight=[];for(var o=n.data.minRank,a=n.data.maxRank+1;o<a;o+=1)mn(i,"borderLeft","_bl",t,n,o),mn(i,"borderRight","_br",t,n,o)}};i.getRoots().forEach(function(t){return e(t.id)})},mn=function(i,e,t,r,n,o){var a={rank:o,borderType:e,width:0,height:0},s=n.data[e][o-1],f=Vt(i,"border",a,t);n.data[e][o]=f,i.setParent(f,r),s&&i.addEdge({id:"e"+Math.random(),source:s,target:f,data:{weight:1}})},ls=function(i,e){var t=e.toLowerCase();(t==="lr"||t==="rl")&&yn(i)},hs=function(i,e){var t=e.toLowerCase();(t==="bt"||t==="rl")&&ds(i),(t==="lr"||t==="rl")&&(cs(i),yn(i))},yn=function(i){i.getAllNodes().forEach(function(e){En(e)}),i.getAllEdges().forEach(function(e){En(e)})},En=function(i){var e=i.data.width;i.data.width=i.data.height,i.data.height=e},ds=function(i){i.getAllNodes().forEach(function(e){Qe(e.data)}),i.getAllEdges().forEach(function(e){var t;(t=e.data.points)===null||t===void 0||t.forEach(function(r){return Qe(r)}),e.data.hasOwnProperty("y")&&Qe(e.data)})},Qe=function(i){i!=null&&i.y&&(i.y=-i.y)},cs=function(i){i.getAllNodes().forEach(function(e){Je(e.data)}),i.getAllEdges().forEach(function(e){var t;(t=e.data.points)===null||t===void 0||t.forEach(function(r){return Je(r)}),e.data.hasOwnProperty("x")&&Je(e.data)})},Je=function(i){var e=i.x;i.x=i.y,i.y=e},xn=function(i){for(var e={},t=i.getAllNodes(),r=t.map(function(l){var h;return(h=l.data.rank)!==null&&h!==void 0?h:-1/0}),n=Math.max.apply(Math,ut([],st(r))),o=[],a=0;a<n+1;a++)o.push([]);var s=t.sort(function(l,h){return i.getNode(l.id).data.rank-i.getNode(h.id).data.rank}),f=s.filter(function(l){return i.getNode(l.id).data.fixorder!==void 0}),u=f.sort(function(l,h){return i.getNode(l.id).data.fixorder-i.getNode(h.id).data.fixorder});return u==null||u.forEach(function(l){isNaN(i.getNode(l.id).data.rank)||o[i.getNode(l.id).data.rank].push(l.id),e[l.id]=!0}),s==null||s.forEach(function(l){return i.dfsTree(l.id,function(h){if(e.hasOwnProperty(h.id))return!0;e[h.id]=!0,isNaN(h.data.rank)||o[h.data.rank].push(h.id)})}),o},gs=function(i,e,t){for(var r=Ia(t,t.map(function(l,h){return h})),n=e.map(function(l){var h=i.getRelatedEdges(l,"out").map(function(d){return{pos:r[d.target]||0,weight:d.data.weight}});return h==null?void 0:h.sort(function(d,g){return d.pos-g.pos})}),o=n.flat().filter(function(l){return l!==void 0}),a=1;a<t.length;)a<<=1;var s=2*a-1;a-=1;var f=Array(s).fill(0,0,s),u=0;return o==null||o.forEach(function(l){if(l){var h=l.pos+a;f[h]+=l.weight;for(var d=0;h>0;)h%2&&(d+=f[h+1]),h=h-1>>1,f[h]+=l.weight;u+=l.weight*d}}),u},Nn=function(i,e){for(var t=0,r=1;r<(e==null?void 0:e.length);r+=1)t+=gs(i,e[r-1],e[r]);return t},vs=function(i,e,t){var r=ps(i),n=new ft({tree:[{id:r,children:[],data:{}}]});return i.getAllNodes().forEach(function(o){var a=i.getParent(o.id);(o.data.rank===e||o.data.minRank<=e&&e<=o.data.maxRank)&&(n.hasNode(o.id)||n.addNode(R({},o)),a!=null&&a.id&&!n.hasNode(a==null?void 0:a.id)&&n.addNode(R({},a)),n.setParent(o.id,(a==null?void 0:a.id)||r),i.getRelatedEdges(o.id,t).forEach(function(s){var f=s.source===o.id?s.target:s.source;n.hasNode(f)||n.addNode(R({},i.getNode(f)));var u=n.getRelatedEdges(f,"out").find(function(h){var d=h.target;return d===o.id}),l=u!==void 0?u.data.weight:0;u?n.updateEdgeData(u.id,R(R({},u.data),{weight:s.data.weight+l})):n.addEdge({id:s.id,source:f,target:o.id,data:{weight:s.data.weight+l}})}),o.data.hasOwnProperty("minRank")&&n.updateNodeData(o.id,R(R({},o.data),{borderLeft:o.data.borderLeft[e],borderRight:o.data.borderRight[e]})))}),n},ps=function(i){for(var e;i.hasNode(e="_root"+Math.random()););return e},ws=function(i,e,t){var r={},n;t==null||t.forEach(function(o){for(var a=i.getParent(o),s,f;a;){if(s=i.getParent(a.id),s?(f=r[s.id],r[s.id]=a.id):(f=n,n=a.id),f&&f!==a.id){e.hasNode(f)||e.addNode({id:f,data:{}}),e.hasNode(a.id)||e.addNode({id:a.id,data:{}}),e.hasEdge("e"+f+"-"+a.id)||e.addEdge({id:"e"+f+"-"+a.id,source:f,target:a.id,data:{}});return}a=s}})},ms=function(i,e){return e.map(function(t){var r=i.getRelatedEdges(t,"in");if(!(r!=null&&r.length))return{v:t};var n={sum:0,weight:0};return r==null||r.forEach(function(o){var a=i.getNode(o.source);n.sum+=o.data.weight*a.data.order,n.weight+=o.data.weight}),{v:t,barycenter:n.sum/n.weight,weight:n.weight}})},ys=function(i,e){var t,r,n,o={};i==null||i.forEach(function(s,f){o[s.v]={i:f,indegree:0,in:[],out:[],vs:[s.v]};var u=o[s.v];s.barycenter!==void 0&&(u.barycenter=s.barycenter,u.weight=s.weight)}),(t=e.getAllEdges())===null||t===void 0||t.forEach(function(s){var f=o[s.source],u=o[s.target];f!==void 0&&u!==void 0&&(u.indegree++,f.out.push(o[s.target]))});var a=(n=(r=Object.values(o)).filter)===null||n===void 0?void 0:n.call(r,function(s){return!s.indegree});return Es(a)},Es=function(i){for(var e,t,r=[],n=function(u){return function(l){l.merged||(l.barycenter===void 0||u.barycenter===void 0||l.barycenter>=u.barycenter)&&xs(u,l)}},o=function(u){return function(l){l.in.push(u),--l.indegree===0&&i.push(l)}},a=function(){var u=i.pop();r.push(u),(e=u.in.reverse())===null||e===void 0||e.forEach(function(l){return n(u)(l)}),(t=u.out)===null||t===void 0||t.forEach(function(l){return o(u)(l)})};i!=null&&i.length;)a();var s=r.filter(function(u){return!u.merged}),f=["vs","i","barycenter","weight"];return s.map(function(u){var l={};return f==null||f.forEach(function(h){u[h]!==void 0&&(l[h]=u[h])}),l})},xs=function(i,e){var t,r=0,n=0;i.weight&&(r+=i.barycenter*i.weight,n+=i.weight),e.weight&&(r+=e.barycenter*e.weight,n+=e.weight),i.vs=(t=e.vs)===null||t===void 0?void 0:t.concat(i.vs),i.barycenter=r/n,i.weight=n,i.i=Math.min(e.i,i.i),e.merged=!0},Ns=function(i,e,t,r){var n=Da(i,function(d){var g=d.hasOwnProperty("fixorder")&&!isNaN(d.fixorder);return r?!g&&d.hasOwnProperty("barycenter"):g||d.hasOwnProperty("barycenter")}),o=n.lhs,a=n.rhs.sort(function(d,g){return-d.i- -g.i}),s=[],f=0,u=0,l=0;o==null||o.sort(bs(!!e,!!t)),l=bn(s,a,l),o==null||o.forEach(function(d){var g;l+=(g=d.vs)===null||g===void 0?void 0:g.length,s.push(d.vs),f+=d.barycenter*d.weight,u+=d.weight,l=bn(s,a,l)});var h={vs:s.flat()};return u&&(h.barycenter=f/u,h.weight=u),h},bn=function(i,e,t){for(var r=t,n;e.length&&(n=e[e.length-1]).i<=r;)e.pop(),i==null||i.push(n.vs),r++;return r},bs=function(i,e){return function(t,r){if(t.fixorder!==void 0&&r.fixorder!==void 0)return t.fixorder-r.fixorder;if(t.barycenter<r.barycenter)return-1;if(t.barycenter>r.barycenter)return 1;if(e&&t.order!==void 0&&r.order!==void 0){if(t.order<r.order)return-1;if(t.order>r.order)return 1}return i?r.i-t.i:t.i-r.i}},Mn=function(i,e,t,r,n,o){var a,s,f,u,l=i.getChildren(e).map(function(x){return x.id}),h=i.getNode(e),d=h?h.data.borderLeft:void 0,g=h?h.data.borderRight:void 0,v={};d&&(l=l==null?void 0:l.filter(function(x){return x!==d&&x!==g}));var p=ms(i,l||[]);p==null||p.forEach(function(x){var N;if(!((N=i.getChildren(x.v))===null||N===void 0)&&N.length){var z=Mn(i,x.v,t,r,o);v[x.v]=z,z.hasOwnProperty("barycenter")&&Ss(x,z)}});var w=ys(p,t);Ms(w,v),(a=w.filter(function(x){return x.vs.length>0}))===null||a===void 0||a.forEach(function(x){var N=i.getNode(x.vs[0]);N&&(x.fixorder=N.data.fixorder,x.order=N.data.order)});var c=Ns(w,r,n,o);if(d&&(c.vs=[d,c.vs,g].flat(),!((s=i.getPredecessors(d))===null||s===void 0)&&s.length)){var m=i.getNode(((f=i.getPredecessors(d))===null||f===void 0?void 0:f[0].id)||""),E=i.getNode(((u=i.getPredecessors(g))===null||u===void 0?void 0:u[0].id)||"");c.hasOwnProperty("barycenter")||(c.barycenter=0,c.weight=0),c.barycenter=(c.barycenter*c.weight+m.data.order+E.data.order)/(c.weight+2),c.weight+=2}return c},Ms=function(i,e){i==null||i.forEach(function(t){var r,n=(r=t.vs)===null||r===void 0?void 0:r.map(function(o){return e[o]?e[o].vs:o});t.vs=n.flat()})},Ss=function(i,e){i.barycenter!==void 0?(i.barycenter=(i.barycenter*i.weight+e.barycenter*e.weight)/(i.weight+e.weight),i.weight+=e.weight):(i.barycenter=e.barycenter,i.weight=e.weight)},ks=function(i,e){for(var t=on(i),r=[],n=[],o=1;o<t+1;o++)r.push(o);for(var o=t-1;o>-1;o--)n.push(o);var a=Sn(i,r,"in"),s=Sn(i,n,"out"),f=xn(i);Ze(i,f);for(var u=Number.POSITIVE_INFINITY,l,o=0,h=0;h<4;++o,++h){kn(o%2?a:s,o%4>=2,!1,e),f=Kt(i);var d=Nn(i,f);d<u&&(h=0,l=ae(f),u=d)}f=xn(i),Ze(i,f);for(var o=0,h=0;h<4;++o,++h){kn(o%2?a:s,o%4>=2,!0,e),f=Kt(i);var d=Nn(i,f);d<u&&(h=0,l=ae(f),u=d)}Ze(i,l)},Sn=function(i,e,t){return e.map(function(r){return vs(i,r,t)})},kn=function(i,e,t,r){var n=new ft;i==null||i.forEach(function(o){for(var a,s=o.getRoots()[0].id,f=Mn(o,s,n,e,t,r),u=0;u<((a=f.vs)===null||a===void 0?void 0:a.length);u++){var l=o.getNode(f.vs[u]);l&&(l.data.order=u)}ws(o,n,f.vs)})},Ze=function(i,e){e==null||e.forEach(function(t){t==null||t.forEach(function(r,n){i.getNode(r).data.order=n})})},_s=function(i,e){var t={},r=function(n,o){var a=0,s=0,f=n.length,u=o==null?void 0:o[(o==null?void 0:o.length)-1];return o==null||o.forEach(function(l,h){var d,g=As(i,l),v=g?i.getNode(g.id).data.order:f;(g||l===u)&&((d=o.slice(s,h+1))===null||d===void 0||d.forEach(function(p){var w;(w=i.getPredecessors(p))===null||w===void 0||w.forEach(function(c){var m,E=i.getNode(c.id),x=E.data.order;(x<a||v<x)&&!(E.data.dummy&&(!((m=i.getNode(p))===null||m===void 0)&&m.data.dummy))&&_n(t,c.id,p)})}),s=h+1,a=v)}),o};return e!=null&&e.length&&e.reduce(r),t},zs=function(i,e){var t={};function r(s,f,u,l,h){for(var d,g,v,p=f;p<u;p++)v=s[p],!((d=i.getNode(v))===null||d===void 0)&&d.data.dummy&&((g=i.getPredecessors(v))===null||g===void 0||g.forEach(function(w){var c=i.getNode(w.id);c.data.dummy&&(c.data.order<l||c.data.order>h)&&_n(t,w.id,v)}))}function n(s){return JSON.stringify(s.slice(1))}function o(s,f){var u=n(s);f.get(u)||(r.apply(void 0,ut([],st(s))),f.set(u,!0))}var a=function(s,f){var u=-1,l,h=0,d=new Map;return f==null||f.forEach(function(g,v){var p;if(((p=i.getNode(g))===null||p===void 0?void 0:p.data.dummy)==="border"){var w=i.getPredecessors(g)||[];w.length&&(l=i.getNode(w[0].id).data.order,o([f,h,v,u,l],d),h=v,u=l)}o([f,h,f.length,l,s.length],d)}),f};return e!=null&&e.length&&e.reduce(a),t},As=function(i,e){var t,r;if(!((t=i.getNode(e))===null||t===void 0)&&t.data.dummy)return(r=i.getPredecessors(e))===null||r===void 0?void 0:r.find(function(n){return i.getNode(n.id).data.dummy})},_n=function(i,e,t){var r=e,n=t;if(r>n){var o=r;r=n,n=o}var a=i[r];a||(i[r]=a={}),a[n]=!0},Rs=function(i,e,t){var r=e,n=t;if(r>n){var o=e;r=n,n=o}return!!i[r]},Os=function(i,e,t,r){var n={},o={},a={};return e==null||e.forEach(function(s){s==null||s.forEach(function(f,u){n[f]=f,o[f]=f,a[f]=u})}),e==null||e.forEach(function(s){var f=-1;s==null||s.forEach(function(u){var l=r(u).map(function(p){return p.id});if(l.length){l=l.sort(function(p,w){return a[p]-a[w]});for(var h=(l.length-1)/2,d=Math.floor(h),g=Math.ceil(h);d<=g;++d){var v=l[d];o[u]===u&&f<a[v]&&!Rs(t,u,v)&&(o[v]=u,o[u]=n[u]=n[v],f=a[v])}}})}),{root:n,align:o}},Is=function(i,e,t,r,n,o,a){var s,f={},u=Ts(i,e,t,n,o,a),l=a?"borderLeft":"borderRight",h=function(v,p){for(var w=u.getAllNodes(),c=w.pop(),m={};c;)m[c.id]?v(c.id):(m[c.id]=!0,w.push(c),w=w.concat(p(c.id))),c=w.pop()},d=function(v){f[v]=(u.getRelatedEdges(v,"in")||[]).reduce(function(p,w){return Math.max(p,(f[w.source]||0)+w.data.weight)},0)},g=function(v){var p=(u.getRelatedEdges(v,"out")||[]).reduce(function(c,m){return Math.min(c,(f[m.target]||0)-m.data.weight)},Number.POSITIVE_INFINITY),w=i.getNode(v);p!==Number.POSITIVE_INFINITY&&w.data.borderType!==l&&(f[v]=Math.max(f[v],p))};return h(d,u.getPredecessors.bind(u)),h(g,u.getSuccessors.bind(u)),(s=Object.values(r))===null||s===void 0||s.forEach(function(v){f[v]=f[t[v]]}),f},Ts=function(i,e,t,r,n,o){var a=new ft,s=js(r,n,o);return e==null||e.forEach(function(f){var u;f==null||f.forEach(function(l){var h=t[l];if(a.hasNode(h)||a.addNode({id:h,data:{}}),u){var d=t[u],g=a.getRelatedEdges(d,"out").find(function(v){return v.target===h});g?a.updateEdgeData(g.id,R(R({},g.data),{weight:Math.max(s(i,l,u),g.data.weight||0)})):a.addEdge({id:"e"+Math.random(),source:d,target:h,data:{weight:Math.max(s(i,l,u),0)}})}u=l})}),a},Ls=function(i,e){return Xe(Object.values(e),function(t){var r,n=Number.NEGATIVE_INFINITY,o=Number.POSITIVE_INFINITY;return(r=Object.keys(t))===null||r===void 0||r.forEach(function(a){var s=t[a],f=Fs(i,a)/2;n=Math.max(s+f,n),o=Math.min(s-f,o)}),n-o})};function Ds(i,e){var t=Object.values(e),r=Math.min.apply(Math,ut([],st(t))),n=Math.max.apply(Math,ut([],st(t)));["u","d"].forEach(function(o){["l","r"].forEach(function(a){var s=o+a,f=i[s],u;if(f!==e){var l=Object.values(f);u=a==="l"?r-Math.min.apply(Math,ut([],st(l))):n-Math.max.apply(Math,ut([],st(l))),u&&(i[s]={},Object.keys(f).forEach(function(h){i[s][h]=f[h]+u}))}})})}var Ps=function(i,e){var t={};return Object.keys(i.ul).forEach(function(r){if(e)t[r]=i[e.toLowerCase()][r];else{var n=Object.values(i).map(function(o){return o[r]});t[r]=(n[0]+n[1])/2}}),t},js=function(i,e,t){return function(r,n,o){var a=r.getNode(n),s=r.getNode(o),f=0,u=0;if(f+=a.data.width/2,a.data.hasOwnProperty("labelpos"))switch((a.data.labelpos||"").toLowerCase()){case"l":u=-a.data.width/2;break;case"r":u=a.data.width/2;break}if(u&&(f+=t?u:-u),u=0,f+=(a.data.dummy?e:i)/2,f+=(s.data.dummy?e:i)/2,f+=s.data.width/2,s.data.labelpos)switch((s.data.labelpos||"").toLowerCase()){case"l":u=s.data.width/2;break;case"r":u=-s.data.width/2;break}return u&&(f+=t?u:-u),u=0,f}},Fs=function(i,e){return i.getNode(e).data.width||0},Cs=function(i,e){var t=(e||{}).ranksep,r=t===void 0?0:t,n=Kt(i),o=0;n==null||n.forEach(function(a){var s=a.map(function(u){return i.getNode(u).data.height}),f=Math.max.apply(Math,ut(ut([],st(s)),[0]));a==null||a.forEach(function(u){i.getNode(u).data.y=o+f/2}),o+=f+r})},qs=function(i,e){var t=e||{},r=t.align,n=t.nodesep,o=n===void 0?0:n,a=t.edgesep,s=a===void 0?0:a,f=Kt(i),u=Object.assign(_s(i,f),zs(i,f)),l={},h=[];["u","d"].forEach(function(g){h=g==="u"?f:Object.values(f).reverse(),["l","r"].forEach(function(v){v==="r"&&(h=h.map(function(m){return Object.values(m).reverse()}));var p=(g==="u"?i.getPredecessors:i.getSuccessors).bind(i),w=Os(i,h,u,p),c=Is(i,h,w.root,w.align,o,s,v==="r");v==="r"&&Object.keys(c).forEach(function(m){return c[m]=-c[m]}),l[g+v]=c})});var d=Ls(i,l);return d&&Ds(l,d),Ps(l,r)},$s=function(i,e){var t,r=en(i);Cs(r,e);var n=qs(r,e);(t=Object.keys(n))===null||t===void 0||t.forEach(function(o){r.getNode(o).data.x=n[o]})},Bs=function(i,e){for(var t=i.getAllNodes().filter(function(s){var f;return!(!((f=i.getChildren(s.id))===null||f===void 0)&&f.length)}),r=t.map(function(s){return s.data.rank}),n=Math.max.apply(Math,ut([],st(r))),o=[],a=0;a<n+1;a++)o[a]=[];e==null||e.forEach(function(s){var f=i.getNode(s);!f||f.data.dummy||isNaN(f.data.rank)||(f.data.fixorder=o[f.data.rank].length,o[f.data.rank].push(s))})},Vs=function(i,e){var t=e.edgeLabelSpace,r=e.keepNodeOrder,n=e.prevGraph,o=e.rankdir,a=e.ranksep;!r&&n&&Ws(i,n);var s=Zs(i);t&&(e.ranksep=Ks(s,{rankdir:o,ranksep:a}));var f;try{f=Us(s,e)}catch(u){if(u.message==="Not possible to find intersection inside of the rectangle"){console.error(`The following error may be caused by improper layer setting, please make sure your manual layer setting does not violate the graph's structure:
13
- `,u);return}throw u}return Ys(i,s),f},Us=function(i,e){var t=e.acyclicer,r=e.ranker,n=e.rankdir,o=n===void 0?"tb":n,a=e.nodeOrder,s=e.keepNodeOrder,f=e.align,u=e.nodesep,l=u===void 0?50:u,h=e.edgesep,d=h===void 0?20:h,g=e.ranksep,v=g===void 0?50:g;su(i),_a(i,t);var p=os(i),w=p.nestingRoot,c=p.nodeRankFactor;Ha(en(i),r),Hs(i),La(i,c),us(i,w),Ta(i),tu(i),eu(i);var m=[];ja(i,m),is(i,m),fs(i),s&&Bs(i,a),ks(i,s),uu(i),ls(i,o),$s(i,{align:f,nodesep:l,edgesep:d,ranksep:v}),fu(i),au(i),Ca(i,m),iu(i),hs(i,o);var E=ru(i),x=E.width,N=E.height;return nu(i),ou(i),Aa(i),{width:x,height:N}},Ws=function(i,e){i.getAllNodes().forEach(function(t){var r=i.getNode(t.id);if(e.hasNode(t.id)){var n=e.getNode(t.id);r.data.fixorder=n.data._order,delete n.data._order}else delete r.data.fixorder})},Ys=function(i,e){i.getAllNodes().forEach(function(t){var r,n=i.getNode(t.id);if(n){var o=e.getNode(t.id);n.data.x=o.data.x,n.data.y=o.data.y,n.data._order=o.data.order,n.data._rank=o.data.rank,!((r=e.getChildren(t.id))===null||r===void 0)&&r.length&&(n.data.width=o.data.width,n.data.height=o.data.height)}}),i.getAllEdges().forEach(function(t){var r=i.getEdge(t.id),n=e.getEdge(t.id);r.data.points=n?n.data.points:[],n&&n.data.hasOwnProperty("x")&&(r.data.x=n.data.x,r.data.y=n.data.y)})},Gs=["width","height","layer","fixorder"],Xs={width:0,height:0},Qs=["minlen","weight","width","height","labeloffset"],Js={minlen:1,weight:1,width:0,height:0,labeloffset:10,labelpos:"r"},Ke=["labelpos"],Zs=function(i){var e=new ft({tree:[]});return i.getAllNodes().forEach(function(t){var r=An(i.getNode(t.id).data),n=R(R({},Xs),r),o=zn(n,Gs);e.hasNode(t.id)||e.addNode({id:t.id,data:R({},o)});var a=i.hasTreeStructure("combo")?i.getParent(t.id,"combo"):i.getParent(t.id);Xn(a)||(e.hasNode(a.id)||e.addNode(R({},a)),e.setParent(t.id,a.id))}),i.getAllEdges().forEach(function(t){var r=An(i.getEdge(t.id).data),n={};Ke==null||Ke.forEach(function(o){r[o]!==void 0&&(n[o]=r[o])}),e.addEdge({id:t.id,source:t.source,target:t.target,data:Object.assign({},Js,zn(r,Qs),n)})}),e},Ks=function(i,e){var t=e.ranksep,r=t===void 0?0:t,n=e.rankdir;return i.getAllNodes().forEach(function(o){isNaN(o.data.layer)||o.data.layer||(o.data.layer=0)}),i.getAllEdges().forEach(function(o){var a;o.data.minlen*=2,((a=o.data.labelpos)===null||a===void 0?void 0:a.toLowerCase())!=="c"&&(n==="TB"||n==="BT"?o.data.width+=o.data.labeloffset:o.data.height+=o.data.labeloffset)}),r/2},Hs=function(i){i.getAllEdges().forEach(function(e){if(e.data.width&&e.data.height){var t=i.getNode(e.source),r=i.getNode(e.target),n={e,rank:(r.data.rank-t.data.rank)/2+t.data.rank};Vt(i,"edge-proxy",n,"_ep")}})},tu=function(i){var e=0;return i.getAllNodes().forEach(function(t){var r,n;t.data.borderTop&&(t.data.minRank=(r=i.getNode(t.data.borderTop))===null||r===void 0?void 0:r.data.rank,t.data.maxRank=(n=i.getNode(t.data.borderBottom))===null||n===void 0?void 0:n.data.rank,e=Math.max(e,t.data.maxRank||-1/0))}),e},eu=function(i){i.getAllNodes().forEach(function(e){e.data.dummy==="edge-proxy"&&(i.getEdge(e.data.e.id).data.labelRank=e.data.rank,i.removeNode(e.id))})},ru=function(i,e){var t,r=0,n,o=0,a=e||{},s=a.marginx,f=s===void 0?0:s,u=a.marginy,l=u===void 0?0:u,h=function(d){if(d.data){var g=d.data.x,v=d.data.y,p=d.data.width,w=d.data.height;!isNaN(g)&&!isNaN(p)&&(t===void 0&&(t=g-p/2),t=Math.min(t,g-p/2),r=Math.max(r,g+p/2)),!isNaN(v)&&!isNaN(w)&&(n===void 0&&(n=v-w/2),n=Math.min(n,v-w/2),o=Math.max(o,v+w/2))}};return i.getAllNodes().forEach(function(d){h(d)}),i.getAllEdges().forEach(function(d){d!=null&&d.data.hasOwnProperty("x")&&h(d)}),t-=f,n-=l,i.getAllNodes().forEach(function(d){d.data.x-=t,d.data.y-=n}),i.getAllEdges().forEach(function(d){var g;(g=d.data.points)===null||g===void 0||g.forEach(function(v){v.x-=t,v.y-=n}),d.data.hasOwnProperty("x")&&(d.data.x-=t),d.data.hasOwnProperty("y")&&(d.data.y-=n)}),{width:r-t+f,height:o-n+l}},nu=function(i){i.getAllEdges().forEach(function(e){var t=i.getNode(e.source),r=i.getNode(e.target),n,o;e.data.points?(n=e.data.points[0],o=e.data.points[e.data.points.length-1]):(e.data.points=[],n={x:r.data.x,y:r.data.y},o={x:t.data.x,y:t.data.y}),e.data.points.unshift(rn(t.data,n)),e.data.points.push(rn(r.data,o))})},iu=function(i){i.getAllEdges().forEach(function(e){if(e.data.hasOwnProperty("x"))switch((e.data.labelpos==="l"||e.data.labelpos==="r")&&(e.data.width-=e.data.labeloffset),e.data.labelpos){case"l":e.data.x-=e.data.width/2+e.data.labeloffset;break;case"r":e.data.x+=e.data.width/2+e.data.labeloffset;break}})},ou=function(i){i.getAllEdges().forEach(function(e){var t;e.data.reversed&&((t=e.data.points)===null||t===void 0||t.reverse())})},au=function(i){i.getAllNodes().forEach(function(e){var t,r,n;if(!((t=i.getChildren(e.id))===null||t===void 0)&&t.length){var o=i.getNode(e.id),a=i.getNode(o.data.borderTop),s=i.getNode(o.data.borderBottom),f=i.getNode(o.data.borderLeft[((r=o.data.borderLeft)===null||r===void 0?void 0:r.length)-1]),u=i.getNode(o.data.borderRight[((n=o.data.borderRight)===null||n===void 0?void 0:n.length)-1]);o.data.width=Math.abs((u==null?void 0:u.data.x)-(f==null?void 0:f.data.x))||10,o.data.height=Math.abs((s==null?void 0:s.data.y)-(a==null?void 0:a.data.y))||10,o.data.x=((f==null?void 0:f.data.x)||0)+o.data.width/2,o.data.y=((a==null?void 0:a.data.y)||0)+o.data.height/2}}),i.getAllNodes().forEach(function(e){e.data.dummy==="border"&&i.removeNode(e.id)})},su=function(i){i.getAllEdges().forEach(function(e){if(e.source===e.target){var t=i.getNode(e.source);t.data.selfEdges||(t.data.selfEdges=[]),t.data.selfEdges.push(e),i.removeEdge(e.id)}})},uu=function(i){var e=Kt(i);e==null||e.forEach(function(t){var r=0;t==null||t.forEach(function(n,o){var a,s=i.getNode(n);s.data.order=o+r,(a=s.data.selfEdges)===null||a===void 0||a.forEach(function(f){Vt(i,"selfedge",{width:f.data.width,height:f.data.height,rank:s.data.rank,order:o+ ++r,e:f},"_se")}),delete s.data.selfEdges})})},fu=function(i){i.getAllNodes().forEach(function(e){var t=i.getNode(e.id);if(t.data.dummy==="selfedge"){var r=i.getNode(t.data.e.source),n=r.data.x+r.data.width/2,o=r.data.y,a=t.data.x-n,s=r.data.height/2;i.hasEdge(t.data.e.id)?i.updateEdgeData(t.data.e.id,t.data.e.data):i.addEdge({id:t.data.e.id,source:t.data.e.source,target:t.data.e.target,data:t.data.e.data}),i.removeNode(e.id),t.data.e.data.points=[{x:n+2*a/3,y:o-s},{x:n+5*a/6,y:o-s},{y:o,x:n+a},{x:n+5*a/6,y:o+s},{x:n+2*a/3,y:o+s}],t.data.e.data.x=t.data.x,t.data.e.data.y=t.data.y}})},zn=function(i,e){var t={};return e==null||e.forEach(function(r){i[r]!==void 0&&(t[r]=+i[r])}),t},An=function(i){i===void 0&&(i={});var e={};return Object.keys(i).forEach(function(t){e[t.toLowerCase()]=i[t]}),e},lu={rankdir:"TB",nodesep:50,ranksep:50,edgeLabelSpace:!0,ranker:"tight-tree",controlPoints:!1,radial:!1,focusNode:null},hu=function(){function i(e){e===void 0&&(e={}),this.options=e,this.id="dagre",this.options=R(R({},lu),e)}return i.prototype.execute=function(e,t){return K(this,void 0,void 0,function(){return H(this,function(r){return[2,this.genericDagreLayout(!1,e,t)]})})},i.prototype.assign=function(e,t){return K(this,void 0,void 0,function(){return H(this,function(r){switch(r.label){case 0:return[4,this.genericDagreLayout(!0,e,t)];case 1:return r.sent(),[2]}})})},i.prototype.genericDagreLayout=function(e,t,r){return K(this,void 0,void 0,function(){var n,o,a,s,f,u,l,h,d,g,v,p,w,c,m,E,x,N,z,k,b,A,y,S,_,M,T,L,D,$,C,G,V,X,W,P,I,U,q;return H(this,function(B){return n=R(R({},this.options),r),o=n.nodeSize,a=n.align,s=n.rankdir,f=s===void 0?"TB":s,u=n.ranksep,l=n.nodesep,h=n.ranksepFunc,d=n.nodesepFunc,g=n.edgeLabelSpace,v=n.ranker,p=n.nodeOrder,w=n.begin,c=n.controlPoints,m=n.radial,E=n.sortByCombo,x=n.preset,N=new ft({tree:[]}),z=zt(u||50,h),k=zt(l||50,d),b=k,A=z,(f==="LR"||f==="RL")&&(b=z,A=k),y=pr(o,void 0),S=t.getAllNodes(),_=t.getAllEdges(),S.forEach(function(O){var F=y(O),Y=A(O),Z=b(O),rt=F+2*Z,et=F+2*Y,mt=O.data.layer;Q(mt)?N.addNode({id:O.id,data:{width:rt,height:et,layer:mt}}):N.addNode({id:O.id,data:{width:rt,height:et}})}),E&&(N.attachTreeStructure("combo"),S.forEach(function(O){var F=O.data.parentId;F!==void 0&&N.hasNode(F)&&N.setParent(O.id,F,"combo")})),_.forEach(function(O){N.addEdge({id:O.id,source:O.source,target:O.target,data:{weight:O.data.weight||1}})}),M=void 0,x!=null&&x.length&&(M=new ft({nodes:x})),Vs(N,{prevGraph:M,edgeLabelSpace:g,keepNodeOrder:!!p,nodeOrder:p||[],acyclicer:"greedy",ranker:v,rankdir:f,nodesep:l,align:a}),T=[0,0],w&&(L=1/0,D=1/0,N.getAllNodes().forEach(function(O){L>O.data.x&&(L=O.data.x),D>O.data.y&&(D=O.data.y)}),N.getAllEdges().forEach(function(O){var F;(F=O.data.points)===null||F===void 0||F.forEach(function(Y){L>Y.x&&(L=Y.x),D>Y.y&&(D=Y.y)})}),T[0]=w[0]-L,T[1]=w[1]-D),$=f==="LR"||f==="RL",m||(C=new Set,G=f==="BT"||f==="RL",V=G?function(O,F){return F-O}:function(O,F){return O-F},N.getAllNodes().forEach(function(O){O.data.x=O.data.x+T[0],O.data.y=O.data.y+T[1],C.add($?O.data.x:O.data.y)}),X=Array.from(C).sort(V),W=$?function(O,F){return O.x!==F.x}:function(O,F){return O.y!==F.y},P=$?function(O,F,Y){var Z=Math.max(F.y,Y.y),rt=Math.min(F.y,Y.y);return O.filter(function(et){return et.y<=Z&&et.y>=rt})}:function(O,F,Y){var Z=Math.max(F.x,Y.x),rt=Math.min(F.x,Y.x);return O.filter(function(et){return et.x<=Z&&et.x>=rt})},N.getAllEdges().forEach(function(O,F){var Y;g&&c&&O.data.type!=="loop"&&(O.data.controlPoints=du((Y=O.data.points)===null||Y===void 0?void 0:Y.map(function(Z){var rt=Z.x,et=Z.y;return{x:rt+T[0],y:et+T[1]}}),N.getNode(O.source),N.getNode(O.target),X,$,W,P))})),I=[],I=N.getAllNodes().map(function(O){return ct(O)}),U=N.getAllEdges(),e&&(I.forEach(function(O){t.mergeNodeData(O.id,{x:O.data.x,y:O.data.y})}),U.forEach(function(O){t.mergeEdgeData(O.id,{controlPoints:O.data.controlPoints})})),q={nodes:I,edges:U},[2,q]})})},i}(),du=function(i,e,t,r,n,o,a){var s=(i==null?void 0:i.slice(1,i.length-1))||[];if(e&&t){var f=e.data,u=f.x,l=f.y,h=t.data,d=h.x,g=h.y;if(n&&(u=e.data.y,l=e.data.x,d=t.data.y,g=t.data.x),g!==l&&u!==d){var v=r.indexOf(l),p=r[v+1];if(p){var w=s[0],c=n?{x:(l+p)/2,y:(w==null?void 0:w.y)||d}:{x:(w==null?void 0:w.x)||d,y:(l+p)/2};(!w||o(w,c))&&s.unshift(c)}var m=r.indexOf(g),E=Math.abs(m-v);if(E===1)s=a(s,e.data,t.data),s.length||s.push(n?{x:(l+g)/2,y:u}:{x:u,y:(l+g)/2});else if(E>1){var x=r[m-1];if(x){var N=s[s.length-1],z=n?{x:(g+x)/2,y:(N==null?void 0:N.y)||d}:{x:(N==null?void 0:N.x)||u,y:(g+x)/2};(!N||o(N,z))&&s.push(z)}}}}return s},cu=function(){function i(e){this.id=e.id||0,this.rx=e.rx,this.ry=e.ry,this.fx=0,this.fy=0,this.mass=e.mass,this.degree=e.degree,this.g=e.g||0}return i.prototype.distanceTo=function(e){var t=this.rx-e.rx,r=this.ry-e.ry;return Math.hypot(t,r)},i.prototype.setPos=function(e,t){this.rx=e,this.ry=t},i.prototype.resetForce=function(){this.fx=0,this.fy=0},i.prototype.addForce=function(e){var t=e.rx-this.rx,r=e.ry-this.ry,n=Math.hypot(t,r);n=n<1e-4?1e-4:n;var o=this.g*(this.degree+1)*(e.degree+1)/n;this.fx+=o*t/n,this.fy+=o*r/n},i.prototype.in=function(e){return e.contains(this.rx,this.ry)},i.prototype.add=function(e){var t=this.mass+e.mass,r=(this.rx*this.mass+e.rx*e.mass)/t,n=(this.ry*this.mass+e.ry*e.mass)/t,o=this.degree+e.degree,a={rx:r,ry:n,mass:t,degree:o};return new i(a)},i}(),gu=function(){function i(e){this.xmid=e.xmid,this.ymid=e.ymid,this.length=e.length,this.massCenter=e.massCenter||[0,0],this.mass=e.mass||1}return i.prototype.getLength=function(){return this.length},i.prototype.contains=function(e,t){var r=this.length/2;return e<=this.xmid+r&&e>=this.xmid-r&&t<=this.ymid+r&&t>=this.ymid-r},i.prototype.NW=function(){var e=this.xmid-this.length/4,t=this.ymid+this.length/4,r=this.length/2,n={xmid:e,ymid:t,length:r},o=new i(n);return o},i.prototype.NE=function(){var e=this.xmid+this.length/4,t=this.ymid+this.length/4,r=this.length/2,n={xmid:e,ymid:t,length:r},o=new i(n);return o},i.prototype.SW=function(){var e=this.xmid-this.length/4,t=this.ymid-this.length/4,r=this.length/2,n={xmid:e,ymid:t,length:r},o=new i(n);return o},i.prototype.SE=function(){var e=this.xmid+this.length/4,t=this.ymid-this.length/4,r=this.length/2,n={xmid:e,ymid:t,length:r},o=new i(n);return o},i}(),vu=function(){function i(e){this.body=null,this.quad=null,this.NW=null,this.NE=null,this.SW=null,this.SE=null,this.theta=.5,e!=null&&(this.quad=e)}return i.prototype.insert=function(e){if(this.body==null){this.body=e;return}this._isExternal()?(this.quad&&(this.NW=new i(this.quad.NW()),this.NE=new i(this.quad.NE()),this.SW=new i(this.quad.SW()),this.SE=new i(this.quad.SE())),this._putBody(this.body),this._putBody(e),this.body=this.body.add(e)):(this.body=this.body.add(e),this._putBody(e))},i.prototype._putBody=function(e){this.quad&&(e.in(this.quad.NW())&&this.NW?this.NW.insert(e):e.in(this.quad.NE())&&this.NE?this.NE.insert(e):e.in(this.quad.SW())&&this.SW?this.SW.insert(e):e.in(this.quad.SE())&&this.SE&&this.SE.insert(e))},i.prototype._isExternal=function(){return this.NW==null&&this.NE==null&&this.SW==null&&this.SE==null},i.prototype.updateForce=function(e){if(!(this.body==null||e===this.body))if(this._isExternal())e.addForce(this.body);else{var t=this.quad?this.quad.getLength():0,r=this.body.distanceTo(e);t/r<this.theta?e.addForce(this.body):(this.NW&&this.NW.updateForce(e),this.NE&&this.NE.updateForce(e),this.SW&&this.SW.updateForce(e),this.SE&&this.SE.updateForce(e))}},i}(),pu={center:[0,0],width:300,height:300,kr:5,kg:1,mode:"normal",preventOverlap:!1,dissuadeHubs:!1,maxIteration:0,ks:.1,ksmax:10,tao:.1},wu=function(){function i(e){e===void 0&&(e={}),this.options=e,this.id="forceAtlas2",this.options=R(R({},pu),e)}return i.prototype.execute=function(e,t){return K(this,void 0,void 0,function(){return H(this,function(r){return[2,this.genericForceAtlas2Layout(!1,e,t)]})})},i.prototype.assign=function(e,t){return K(this,void 0,void 0,function(){return H(this,function(r){return this.genericForceAtlas2Layout(!0,e,t),[2]})})},i.prototype.genericForceAtlas2Layout=function(e,t,r){return K(this,void 0,void 0,function(){var n,o,a,s,f,u,l,h,d,g,v,p,w,c,m,E,x,N,z,k,b,A;return H(this,function(y){if(n=t.getAllEdges(),o=t.getAllNodes(),a=this.formatOptions(r,o.length),s=a.width,f=a.height,u=a.prune,l=a.maxIteration,h=a.nodeSize,d=a.center,!(o!=null&&o.length)||o.length===1)return[2,Lt(t,e,d)];if(g=o.map(function(S){return ct(S,[s,f])}),v=n.filter(function(S){var _=S.source,M=S.target;return _!==M}),p=new ft({nodes:g,edges:v}),w=this.getSizes(p,t,h),this.run(p,t,l,w,e,a),u){for(c=0;c<v.length;c+=1)m=v[c],E=m.source,x=m.target,N=p.getDegree(E),z=p.getDegree(E),N<=1?(k=p.getNode(x),p.mergeNodeData(E,{x:k.data.x,y:k.data.y})):z<=1&&(b=p.getNode(E),p.mergeNodeData(x,{x:b.data.x,y:b.data.y}));A=R(R({},a),{prune:!1,barnesHut:!1}),this.run(p,t,100,w,e,A)}return[2,{nodes:g,edges:n}]})})},i.prototype.getSizes=function(e,t,r){for(var n=e.getAllNodes(),o={},a=0;a<n.length;a+=1){var s=n[a],f=s.id,u=s.data;if(o[f]=10,Q(u.size))o[f]=u.size;else if(lt(u.size))isNaN(u.size[0])||(o[f]=Math.max(u.size[0])),isNaN(u.size[1])||(o[f]=Math.max(u.size[1]));else if(_t(u.size))o[f]=Math.max(u.size.width,u.size.height);else if(yt(r)){var l=t.getNode(f),h=r(l);lt(h)?o[f]=Math.max.apply(Math,ut([],st(h))):o[f]=h}else lt(r)?o[f]=Math.max.apply(Math,ut([],st(r))):Q(r)&&(o[f]=r)}return o},i.prototype.formatOptions=function(e,t){e===void 0&&(e={});var r=R(R({},this.options),e),n=r.center,o=r.width,a=r.height,s=r.barnesHut,f=r.prune,u=r.maxIteration,l=r.kr,h=r.kg;return r.width=!o&&typeof window<"u"?window.innerWidth:o,r.height=!a&&typeof window<"u"?window.innerHeight:a,r.center=n||[r.width/2,r.height/2],s===void 0&&t>250&&(r.barnesHut=!0),f===void 0&&t>100&&(r.prune=!0),u===0&&!f?(r.maxIteration=250,t<=200&&t>100?r.maxIteration=1e3:t>200&&(r.maxIteration=1200)):u===0&&f&&(r.maxIteration=100,t<=200&&t>100?r.maxIteration=500:t>200&&(r.maxIteration=950)),l||(r.kr=50,t>100&&t<=500?r.kr=20:t>500&&(r.kr=1)),h||(r.kg=20,t>100&&t<=500?r.kg=10:t>500&&(r.kg=1)),r},i.prototype.run=function(e,t,r,n,o,a){for(var s=a.kr,f=a.barnesHut,u=a.onTick,l=e.getAllNodes(),h=0,d=r,g={},v={},p={},w=0;w<l.length;w+=1){var c=l[w],m=c.data,E=c.id;if(g[E]=[0,0],f){var x={id:w,rx:m.x,ry:m.y,mass:1,g:s,degree:e.getDegree(E)};p[E]=new cu(x)}}for(;d>0;)h=this.oneStep(e,{iter:d,preventOverlapIters:50,krPrime:100,sg:h,forces:g,preForces:v,bodies:p,sizes:n},a),d--,u==null||u({nodes:l,edges:t.getAllEdges()});return e},i.prototype.oneStep=function(e,t,r){for(var n=t.iter,o=t.preventOverlapIters,a=t.krPrime,s=t.sg,f=t.preForces,u=t.bodies,l=t.sizes,h=t.forces,d=r.preventOverlap,g=r.barnesHut,v=e.getAllNodes(),p=0;p<v.length;p+=1){var w=v[p].id;f[w]=ut([],st(h[w])),h[w]=[0,0]}return h=this.getAttrForces(e,n,o,l,h,r),g&&(d&&n>o||!d)?h=this.getOptRepGraForces(e,h,u,r):h=this.getRepGraForces(e,n,o,h,a,l,r),this.updatePos(e,h,f,s,r)},i.prototype.getAttrForces=function(e,t,r,n,o,a){for(var s=a.preventOverlap,f=a.dissuadeHubs,u=a.mode,l=a.prune,h=e.getAllEdges(),d=0;d<h.length;d+=1){var g=h[d],v=g.source,p=g.target,w=e.getNode(v),c=e.getNode(p),m=e.getDegree(v),E=e.getDegree(p);if(!(l&&(m<=1||E<=1))){var x=[c.data.x-w.data.x,c.data.y-w.data.y],N=Math.hypot(x[0],x[1]);N=N<1e-4?1e-4:N,x[0]=x[0]/N,x[1]=x[1]/N,s&&t<r&&(N=N-n[v]-n[p]);var z=N,k=z;u==="linlog"&&(z=Math.log(1+N),k=z),f&&(z=N/m,k=N/E),s&&t<r&&N<=0?(z=0,k=0):s&&t<r&&N>0&&(z=N,k=N),o[v][0]+=z*x[0],o[p][0]-=k*x[0],o[v][1]+=z*x[1],o[p][1]-=k*x[1]}}return o},i.prototype.getOptRepGraForces=function(e,t,r,n){for(var o=n.kg,a=n.center,s=n.prune,f=e.getAllNodes(),u=f.length,l=9e10,h=-9e10,d=9e10,g=-9e10,v=0;v<u;v+=1){var p=f[v],w=p.id,c=p.data;s&&e.getDegree(w)<=1||(r[w].setPos(c.x,c.y),c.x>=h&&(h=c.x),c.x<=l&&(l=c.x),c.y>=g&&(g=c.y),c.y<=d&&(d=c.y))}for(var m=Math.max(h-l,g-d),E={xmid:(h+l)/2,ymid:(g+d)/2,length:m,massCenter:a,mass:u},x=new gu(E),N=new vu(x),v=0;v<u;v+=1){var w=f[v].id;s&&e.getDegree(w)<=1||r[w].in(x)&&N.insert(r[w])}for(var v=0;v<u;v+=1){var z=f[v],w=z.id,c=z.data,k=e.getDegree(w);if(!(s&&k<=1)){r[w].resetForce(),N.updateForce(r[w]),t[w][0]-=r[w].fx,t[w][1]-=r[w].fy;var b=[c.x-a[0],c.y-a[1]],A=Math.hypot(b[0],b[1]);A=A<1e-4?1e-4:A,b[0]=b[0]/A,b[1]=b[1]/A;var y=o*(k+1);t[w][0]-=y*b[0],t[w][1]-=y*b[1]}}return t},i.prototype.getRepGraForces=function(e,t,r,n,o,a,s){for(var f=s.preventOverlap,u=s.kr,l=s.kg,h=s.center,d=s.prune,g=e.getAllNodes(),v=g.length,p=0;p<v;p+=1){for(var w=g[p],c=e.getDegree(w.id),m=p+1;m<v;m+=1){var E=g[m],x=e.getDegree(E.id);if(!(d&&(c<=1||x<=1))){var N=[E.data.x-w.data.x,E.data.y-w.data.y],z=Math.hypot(N[0],N[1]);z=z<1e-4?1e-4:z,N[0]=N[0]/z,N[1]=N[1]/z,f&&t<r&&(z=z-a[w.id]-a[E.id]);var k=u*(c+1)*(x+1)/z;f&&t<r&&z<0?k=o*(c+1)*(x+1):f&&t<r&&z===0?k=0:f&&t<r&&z>0&&(k=u*(c+1)*(x+1)/z),n[w.id][0]-=k*N[0],n[E.id][0]+=k*N[0],n[w.id][1]-=k*N[1],n[E.id][1]+=k*N[1]}}var b=[w.data.x-h[0],w.data.y-h[1]],A=Math.hypot(b[0],b[1]);b[0]=b[0]/A,b[1]=b[1]/A;var y=l*(c+1);n[w.id][0]-=y*b[0],n[w.id][1]-=y*b[1]}return n},i.prototype.updatePos=function(e,t,r,n,o){for(var a=o.ks,s=o.tao,f=o.prune,u=o.ksmax,l=e.getAllNodes(),h=l.length,d=[],g=[],v=0,p=0,w=n,c=0;c<h;c+=1){var m=l[c].id,E=e.getDegree(m);if(!(f&&E<=1)){var x=[t[m][0]-r[m][0],t[m][1]-r[m][1]],N=Math.hypot(x[0],x[1]),z=[t[m][0]+r[m][0],t[m][1]+r[m][1]],k=Math.hypot(z[0],z[1]);d[c]=N,g[c]=k/2,v+=(E+1)*d[c],p+=(E+1)*g[c]}}var b=w;w=s*p/v,b!==0&&(w=w>1.5*b?1.5*b:w);for(var c=0;c<h;c+=1){var A=l[c],m=A.id,y=A.data,E=e.getDegree(m);if(!(f&&E<=1)&&!(Q(y.fx)&&Q(y.fy))){var S=a*w/(1+w*Math.sqrt(d[c])),_=Math.hypot(t[m][0],t[m][1]);_=_<1e-4?1e-4:_;var M=u/_;S=S>M?M:S;var T=S*t[m][0],L=S*t[m][1];e.mergeNodeData(m,{x:y.x+T,y:y.y+L})}}return w},i}(),mu={maxIteration:1e3,gravity:10,speed:5,clustering:!1,clusterGravity:10,width:300,height:300,nodeClusterBy:"cluster"},yu=800,Eu=function(){function i(e){e===void 0&&(e={}),this.options=e,this.id="fruchterman",this.timeInterval=0,this.running=!1,this.options=R(R({},mu),e)}return i.prototype.execute=function(e,t){return K(this,void 0,void 0,function(){return H(this,function(r){return[2,this.genericFruchtermanLayout(!1,e,t)]})})},i.prototype.assign=function(e,t){return K(this,void 0,void 0,function(){return H(this,function(r){return this.genericFruchtermanLayout(!0,e,t),[2]})})},i.prototype.stop=function(){this.timeInterval&&typeof window<"u"&&window.clearInterval(this.timeInterval),this.running=!1},i.prototype.tick=function(e){var t=this;if(e===void 0&&(e=this.options.maxIteration||1),this.lastResult)return this.lastResult;for(var r=0;r<e;r++)this.runOneStep(this.lastGraph,this.lastClusterMap,this.lastOptions);var n={nodes:this.lastLayoutNodes,edges:this.lastLayoutEdges};return this.lastAssign&&n.nodes.forEach(function(o){return t.lastGraph.mergeNodeData(o.id,{x:o.data.x,y:o.data.y,z:t.options.dimensions===3?o.data.z:void 0})}),n},i.prototype.genericFruchtermanLayout=function(e,t,r){return K(this,void 0,void 0,function(){var n,o,a,s,f,u,l,h,d,g,v,p,p,w,c,m,E,x=this;return H(this,function(N){return this.running?[2]:(n=this.formatOptions(r),o=n.dimensions,a=n.width,s=n.height,f=n.center,u=n.clustering,l=n.nodeClusterBy,h=n.maxIteration,d=n.onTick,g=t.getAllNodes(),v=t.getAllEdges(),g!=null&&g.length?g.length===1?(e&&t.mergeNodeData(g[0].id,{x:f[0],y:f[1],z:o===3?f[2]:void 0}),p={nodes:[R(R({},g[0]),{data:R(R({},g[0].data),{x:f[0],y:f[1],z:o===3?f[2]:void 0})})],edges:v},this.lastResult=p,[2,p]):(w=g.map(function(z){return ct(z,[a,s])}),c=new ft({nodes:w,edges:v}),m={},u&&w.forEach(function(z){var k=z.data[l];m[k]||(m[k]={name:k,cx:0,cy:0,count:0})}),this.lastLayoutNodes=w,this.lastLayoutEdges=v,this.lastAssign=e,this.lastGraph=c,this.lastOptions=n,this.lastClusterMap=m,typeof window>"u"?[2]:(E=0,[2,new Promise(function(z){x.timeInterval=window.setInterval(function(){if(!x.running){z({nodes:w,edges:v});return}x.runOneStep(c,m,n),e&&w.forEach(function(k){var b=k.id,A=k.data;return t.mergeNodeData(b,{x:A.x,y:A.y,z:o===3?A.z:void 0})}),d==null||d({nodes:w,edges:v}),E++,E>=h&&(window.clearInterval(x.timeInterval),z({nodes:w,edges:v}))},0),x.running=!0})])):(p={nodes:[],edges:v},this.lastResult=p,[2,p]))})})},i.prototype.formatOptions=function(e){e===void 0&&(e={});var t=R(R({},this.options),e),r=t.clustering,n=t.nodeClusterBy,o=t.center,a=t.width,s=t.height;return t.width=!a&&typeof window<"u"?window.innerWidth:a,t.height=!s&&typeof window<"u"?window.innerHeight:s,t.center=o||[t.width/2,t.height/2],t.clustering=r&&!!n,t},i.prototype.runOneStep=function(e,t,r){var n=r.dimensions,o=r.height,a=r.width,s=r.gravity,f=r.center,u=r.speed,l=r.clustering,h=r.nodeClusterBy,d=r.clusterGravity,g=o*a,v=Math.sqrt(g)/10,p=e.getAllNodes(),w=g/(p.length+1),c=Math.sqrt(w),m={};if(this.applyCalculate(e,m,c,w),l){for(var E in t)t[E].cx=0,t[E].cy=0,t[E].count=0;p.forEach(function(N){var z=N.data,k=t[z[h]];Q(z.x)&&(k.cx+=z.x),Q(z.y)&&(k.cy+=z.y),k.count++});for(var E in t)t[E].cx/=t[E].count,t[E].cy/=t[E].count;var x=d||s;p.forEach(function(N,z){var k=N.id,b=N.data;if(!(!Q(b.x)||!Q(b.y))){var A=t[b[h]],y=Math.sqrt((b.x-A.cx)*(b.x-A.cx)+(b.y-A.cy)*(b.y-A.cy)),S=c*x;m[k].x-=S*(b.x-A.cx)/y,m[k].y-=S*(b.y-A.cy)/y}})}p.forEach(function(N,z){var k=N.id,b=N.data;if(!(!Q(b.x)||!Q(b.y))){var A=.01*c*s;m[k].x-=A*(b.x-f[0]),m[k].y-=A*(b.y-f[1]),n===3&&(m[k].z-=A*(b.z-f[2]))}}),p.forEach(function(N,z){var k=N.id,b=N.data;if(Q(b.fx)&&Q(b.fy)){b.x=b.fx,b.y=b.fy,n===3&&(b.z=b.fz);return}if(!(!Q(b.x)||!Q(b.y))){var A=Math.sqrt(m[k].x*m[k].x+m[k].y*m[k].y+(n===3?m[k].z*m[k].z:0));if(A>0){var y=Math.min(v*(u/yu),A);e.mergeNodeData(k,{x:b.x+m[k].x/A*y,y:b.y+m[k].y/A*y,z:n===3?b.z+m[k].z/A*y:void 0})}}})},i.prototype.applyCalculate=function(e,t,r,n){this.calRepulsive(e,t,n),this.calAttractive(e,t,r)},i.prototype.calRepulsive=function(e,t,r){var n=this,o=e.getAllNodes();o.forEach(function(a,s){var f=a.data,u=a.id;t[u]={x:0,y:0,z:0},o.forEach(function(l,h){var d=l.data,g=l.id;if(!(s<=h||!Q(f.x)||!Q(d.x)||!Q(f.y)||!Q(d.y))){var v=f.x-d.x,p=f.y-d.y,w=n.options.dimensions===3?f.z-d.z:0,c=v*v+p*p+w*w;c===0&&(c=1,v=.01,p=.01,w=.01);var m=r/c,E=v*m,x=p*m,N=w*m;t[u].x+=E,t[u].y+=x,t[g].x-=E,t[g].y-=x,n.options.dimensions===3&&(t[u].z+=N,t[g].z-=N)}})})},i.prototype.calAttractive=function(e,t,r){var n=this,o=e.getAllEdges();o.forEach(function(a){var s=a.source,f=a.target;if(!(!s||!f||s===f)){var u=e.getNode(s).data,l=e.getNode(f).data;if(!(!Q(l.x)||!Q(u.x)||!Q(l.y)||!Q(u.y))){var h=l.x-u.x,d=l.y-u.y,g=n.options.dimensions===3?l.z-u.z:0,v=Math.sqrt(h*h+d*d+g*g)/r,p=h*v,w=d*v,c=g*v;t[s].x+=p,t[s].y+=w,t[f].x-=p,t[f].y-=w,n.options.dimensions===3&&(t[s].z+=c,t[f].z-=c)}}})},i}(),xu={begin:[0,0],preventOverlap:!0,preventOverlapPadding:10,condense:!1,rows:void 0,cols:void 0,position:void 0,sortBy:"degree",nodeSize:30,width:300,height:300},Nu=function(){function i(e){e===void 0&&(e={}),this.options=e,this.id="grid",this.options=R(R({},xu),e)}return i.prototype.execute=function(e,t){return K(this,void 0,void 0,function(){return H(this,function(r){return[2,this.genericGridLayout(!1,e,t)]})})},i.prototype.assign=function(e,t){return K(this,void 0,void 0,function(){return H(this,function(r){return this.genericGridLayout(!0,e,t),[2]})})},i.prototype.genericGridLayout=function(e,t,r){return K(this,void 0,void 0,function(){var n,o,a,s,f,u,l,h,d,g,v,p,w,c,m,E,x,N,z,k,b,A,y,S,_,S,_,M,T,L,D,$,C,G,V,X,W,P,I;return H(this,function(U){if(n=R(R({},this.options),r),o=n.begin,a=o===void 0?[0,0]:o,s=n.condense,f=n.preventOverlapPadding,u=n.preventOverlap,l=n.rows,h=n.cols,d=n.nodeSpacing,g=n.nodeSize,v=n.width,p=n.height,w=n.position,c=n.sortBy,m=t.getAllNodes(),E=t.getAllEdges(),x=m==null?void 0:m.length,!x||x===1)return[2,Lt(t,e,a)];if(N=m.map(function(q){return ct(q)}),c!=="id"&&(!Yt(c)||N[0].data[c]===void 0)&&(c="degree"),c==="degree"?N.sort(function(q,B){return t.getDegree(B.id,"both")-t.getDegree(q.id,"both")}):c==="id"?N.sort(function(q,B){return Q(B.id)&&Q(q.id)?B.id-q.id:(""+q.id).localeCompare(""+B.id)}):N.sort(function(q,B){return B.data[c]-q.data[c]}),z=!v&&typeof window<"u"?window.innerWidth:v,k=!p&&typeof window<"u"?window.innerHeight:p,b=x,A={rows:l,cols:h},l!=null&&h!=null?(A.rows=l,A.cols=h):l!=null&&h==null?(A.rows=l,A.cols=Math.ceil(b/A.rows)):l==null&&h!=null?(A.cols=h,A.rows=Math.ceil(b/A.cols)):(y=Math.sqrt(b*k/z),A.rows=Math.round(y),A.cols=Math.round(z/k*y)),A.rows=Math.max(A.rows,1),A.cols=Math.max(A.cols,1),A.cols*A.rows>b)S=Ne(A),_=be(A),(S-1)*_>=b?Ne(A,S-1):(_-1)*S>=b&&be(A,_-1);else for(;A.cols*A.rows<b;)S=Ne(A),_=be(A),(_+1)*S>=b?be(A,_+1):Ne(A,S+1);for(M=s?0:z/A.cols,T=s?0:k/A.rows,(u||d)&&(L=zt(10,d),D=vr(30,g,!1),N.forEach(function(q){(!q.data.x||!q.data.y)&&(q.data.x=0,q.data.y=0);var B=t.getNode(q.id),O=D(B)||30,F,Y;lt(O)?(F=O[0],Y=O[1]):(F=O,Y=O);var Z=L!==void 0?L(q):f,rt=F+Z,et=Y+Z;M=Math.max(M,rt),T=Math.max(T,et)})),$={},C={row:0,col:0},G={},V=0;V<N.length;V++){if(X=N[V],W=void 0,w&&(W=w(t.getNode(X.id))),W&&(W.row!==void 0||W.col!==void 0)){if(P={row:W.row,col:W.col},P.col===void 0)for(P.col=0;He($,P);)P.col++;else if(P.row===void 0)for(P.row=0;He($,P);)P.row++;G[X.id]=P,Rn($,P)}bu(X,a,M,T,G,A,C,$)}return I={nodes:N,edges:E},e&&N.forEach(function(q){t.mergeNodeData(q.id,{x:q.data.x,y:q.data.y})}),[2,I]})})},i}(),Ne=function(i,e){var t,r=i.rows||5,n=i.cols||5;if(e==null)t=Math.min(r,n);else{var o=Math.min(r,n);o===i.rows?i.rows=e:i.cols=e}return t},be=function(i,e){var t,r=i.rows||5,n=i.cols||5;if(e==null)t=Math.max(r,n);else{var o=Math.max(r,n);o===i.rows?i.rows=e:i.cols=e}return t},He=function(i,e){return i["c-"+e.row+"-"+e.col]||!1},Rn=function(i,e){return i["c-"+e.row+"-"+e.col]=!0},On=function(i,e){var t=i.cols||5;e.col++,e.col>=t&&(e.col=0,e.row++)},bu=function(i,e,t,r,n,o,a,s){var f,u,l=n[i.id];if(l)f=l.col*t+t/2+e[0],u=l.row*r+r/2+e[1];else{for(;He(s,a);)On(o,a);f=a.col*t+t/2+e[0],u=a.row*r+r/2+e[1],Rn(s,a),On(o,a)}i.data.x=f,i.data.y=u},Mu=function(i,e,t){try{var r=At.mul(At.pow(e,2),-.5),n=r.mean("row"),o=r.mean("column"),a=r.mean();r.add(a).subRowVector(n).subColumnVector(o);var s=new Or(r),f=At.sqrt(s.diagonalMatrix).diagonal();return s.leftSingularVectors.toJSON().map(function(g){return At.mul([g],[f]).toJSON()[0].splice(0,i)})}catch{for(var u=[],l=0;l<e.length;l++){var h=Math.random()*t,d=Math.random()*t;u.push([h,d])}return u}},Su=800,ku={iterations:10,height:10,width:10,speed:100,gravity:10,k:5},_u=function(i,e){for(var t=R(R({},ku),e),r=t.positions,n=t.iterations,o=t.width,a=t.k,s=t.speed,f=s===void 0?100:s,u=t.strictRadial,l=t.focusIdx,h=t.radii,d=h===void 0?[]:h,g=t.nodeSizeFunc,v=i.getAllNodes(),p=[],w=o/10,c=0;c<n;c++)r.forEach(function(m,E){p[E]={x:0,y:0}}),zu(v,r,p,a,d,g),Au(r,p,f,u,l,w,o,d);return r},zu=function(i,e,t,r,n,o){e.forEach(function(a,s){t[s]={x:0,y:0},e.forEach(function(f,u){if(s!==u&&n[s]===n[u]){var l=a.x-f.x,h=a.y-f.y,d=Math.sqrt(l*l+h*h);if(d===0){d=1;var g=s>u?1:-1;l=.01*g,h=.01*g}if(d<o(i[s])/2+o(i[u])/2){var v=r*r/d;t[s].x+=l/d*v,t[s].y+=h/d*v}}})})},Au=function(i,e,t,r,n,o,a,s){var f=o||a/10;return r&&e.forEach(function(u,l){var h=i[l].x-i[n].x,d=i[l].y-i[n].y,g=Math.sqrt(h*h+d*d),v=d/g,p=-h/g,w=Math.sqrt(u.x*u.x+u.y*u.y),c=Math.acos((v*u.x+p*u.y)/w);c>Math.PI/2&&(c-=Math.PI/2,v*=-1,p*=-1);var m=Math.cos(c)*w;u.x=v*m,u.y=p*m}),i.forEach(function(u,l){if(l!==n){var h=Math.sqrt(e[l].x*e[l].x+e[l].y*e[l].y);if(h>0&&l!==n){var d=Math.min(f*(t/Su),h);if(u.x+=e[l].x/h*d,u.y+=e[l].y/h*d,r){var g=u.x-i[n].x,v=u.y-i[n].y,p=Math.sqrt(g*g+v*v);g=g/p*s[l],v=v/p*s[l],u.x=i[n].x+g,u.y=i[n].y+v}}}}),i},Ru={maxIteration:1e3,focusNode:null,unitRadius:null,linkDistance:50,preventOverlap:!1,strictRadial:!0,maxPreventOverlapIteration:200,sortStrength:10},Ou=function(){function i(e){e===void 0&&(e={}),this.options=e,this.id="radial",this.options=R(R({},Ru),e)}return i.prototype.execute=function(e,t){return K(this,void 0,void 0,function(){return H(this,function(r){return[2,this.genericRadialLayout(!1,e,t)]})})},i.prototype.assign=function(e,t){return K(this,void 0,void 0,function(){return H(this,function(r){return this.genericRadialLayout(!0,e,t),[2]})})},i.prototype.genericRadialLayout=function(e,t,r){return K(this,void 0,void 0,function(){var n,o,a,s,f,u,l,h,d,g,v,p,w,c,m,E,x,N,z,k,b,A,y,S,_,M,T,L,D,$,C,G,V,X,W,P,I,U,q,B,O,F,Y,Z;return H(this,function(rt){if(n=R(R({},this.options),r),o=n.width,a=n.height,s=n.center,f=n.focusNode,u=n.unitRadius,l=n.nodeSize,h=n.nodeSpacing,d=n.strictRadial,g=n.preventOverlap,v=n.maxPreventOverlapIteration,p=n.sortBy,w=n.linkDistance,c=w===void 0?50:w,m=n.sortStrength,E=m===void 0?10:m,x=n.maxIteration,N=x===void 0?1e3:x,z=t.getAllNodes(),k=t.getAllEdges(),b=!o&&typeof window<"u"?window.innerWidth:o,A=!a&&typeof window<"u"?window.innerHeight:a,y=s||[b/2,A/2],!(z!=null&&z.length)||z.length===1)return[2,Lt(t,e,y)];if(S=z[0],Yt(f)){for(_=0;_<z.length;_++)if(z[_].id===f){S=z[_];break}}else S=f||z[0];return M=Lu(z,S.id),T=cr({nodes:z,edges:k},!1),L=dr(T),D=Pu(L,M),Du(L,M,D+1),$=L[M],C=b-y[0]>y[0]?y[0]:b-y[0],G=A-y[1]>y[1]?y[1]:A-y[1],C===0&&(C=b/2),G===0&&(G=A/2),V=Math.min(C,G),X=Math.max.apply(Math,ut([],st($))),W=[],P=u||V/X,$.forEach(function(et,mt){W[mt]=et*P}),I=Iu(z,L,c,W,P,p,E),U=Tu(I),q=Mu(c,I,c),B=q.map(function(et){var mt=st(et,2),It=mt[0],Se=mt[1];return{x:(isNaN(It)?Math.random()*c:It)-q[M][0],y:(isNaN(Se)?Math.random()*c:Se)-q[M][1]}}),this.run(N,B,U,I,W,M),g&&(O=pr(l,h),F={nodes:z,nodeSizeFunc:O,positions:B,radii:W,height:A,width:b,strictRadial:!!d,focusIdx:M,iterations:v||200,k:B.length/4.5},B=_u(t,F)),Y=[],B.forEach(function(et,mt){var It=ct(z[mt]);It.data.x=et.x+y[0],It.data.y=et.y+y[1],Y.push(It)}),e&&Y.forEach(function(et){return t.mergeNodeData(et.id,{x:et.data.x,y:et.data.y})}),Z={nodes:Y,edges:k},[2,Z]})})},i.prototype.run=function(e,t,r,n,o,a){for(var s=0;s<=e;s++){var f=s/e;this.oneIteration(f,t,o,n,r,a)}},i.prototype.oneIteration=function(e,t,r,n,o,a){var s=1-e;t.forEach(function(f,u){var l=gr(f,{x:0,y:0}),h=l===0?0:1/l;if(u!==a){var d=0,g=0,v=0;t.forEach(function(w,c){if(u!==c){var m=gr(f,w),E=m===0?0:1/m,x=n[c][u];v+=o[u][c],d+=o[u][c]*(w.x+x*(f.x-w.x)*E),g+=o[u][c]*(w.y+x*(f.y-w.y)*E)}});var p=r[u]===0?0:1/r[u];v*=s,v+=e*p*p,d*=s,d+=e*p*f.x*h,f.x=d/v,g*=s,g+=e*p*f.y*h,f.y=g/v}})},i}(),Iu=function(i,e,t,r,n,o,a){if(!i)return[];var s=[];if(e){var f={};e.forEach(function(u,l){var h=[];u.forEach(function(d,g){var v,p;if(l===g)h.push(0);else if(r[l]===r[g])if(o==="data")h.push(d*(Math.abs(l-g)*a)/(r[l]/n));else if(o){var w=void 0,c=void 0;if(f[i[l].id])w=f[i[l].id];else{var m=(o==="id"?i[l].id:(v=i[l].data)===null||v===void 0?void 0:v[o])||0;Yt(m)?w=m.charCodeAt(0):w=m,f[i[l].id]=w}if(f[i[g].id])c=f[i[g].id];else{var m=(o==="id"?i[g].id:(p=i[g].data)===null||p===void 0?void 0:p[o])||0;Yt(m)?c=m.charCodeAt(0):c=m,f[i[g].id]=c}h.push(d*(Math.abs(w-c)*a)/(r[l]/n))}else h.push(d*t/(r[l]/n));else{var E=(t+n)/2;h.push(d*E)}}),s.push(h)})}return s},Tu=function(i){for(var e=i.length,t=i[0].length,r=[],n=0;n<e;n++){for(var o=[],a=0;a<t;a++)i[n][a]!==0?o.push(1/(i[n][a]*i[n][a])):o.push(0);r.push(o)}return r},Lu=function(i,e){var t=-1;return i.forEach(function(r,n){r.id===e&&(t=n)}),Math.max(t,0)},Du=function(i,e,t){for(var r=i.length,n=0;n<r;n++)if(i[e][n]===1/0){i[e][n]=t,i[n][e]=t;for(var o=0;o<r;o++)i[n][o]!==1/0&&i[e][o]===1/0&&(i[e][o]=t+i[n][o],i[o][e]=t+i[n][o])}for(var n=0;n<r;n++)if(n!==e){for(var o=0;o<r;o++)if(i[n][o]===1/0){var a=Math.abs(i[e][n]-i[e][o]);a=a===0?1:a,i[n][o]=a}}},Pu=function(i,e){for(var t=0,r=0;r<i[e].length;r++)i[e][r]!==1/0&&(t=i[e][r]>t?i[e][r]:t);return t},ju={center:[0,0],width:300,height:300},Fu=function(){function i(e){e===void 0&&(e={}),this.options=e,this.id="random",this.options=R(R({},ju),e)}return i.prototype.execute=function(e,t){return K(this,void 0,void 0,function(){return H(this,function(r){return[2,this.genericRandomLayout(!1,e,t)]})})},i.prototype.assign=function(e,t){return K(this,void 0,void 0,function(){return H(this,function(r){return this.genericRandomLayout(!0,e,t),[2]})})},i.prototype.genericRandomLayout=function(e,t,r){return K(this,void 0,void 0,function(){var n,o,a,s,f,u,l,h,d,g,v;return H(this,function(p){return n=R(R({},this.options),r),o=n.center,a=n.width,s=n.height,f=t.getAllNodes(),u=.9,l=!a&&typeof window<"u"?window.innerWidth:a,h=!s&&typeof window<"u"?window.innerHeight:s,d=o||[l/2,h/2],g=[],f&&f.forEach(function(w){g.push({id:w.id,data:{x:(Math.random()-.5)*u*l+d[0],y:(Math.random()-.5)*u*h+d[1]}})}),e&&g.forEach(function(w){return t.mergeNodeData(w.id,{x:w.data.x,y:w.data.y})}),v={nodes:g,edges:t.getAllEdges()},[2,v]})})},i}(),Cu={circular:ti,concentric:Be,mds:Ir,random:Fu,grid:Nu,radial:Ou,force:Fr,d3force:ma,fruchterman:Eu,forceAtlas2:wu,dagre:hu,comboCombined:Jo};function qu(i){return!!i.tick&&!!i.stop}var kt,$u={stopLayout:function(){kt!=null&&kt.stop&&kt.stop()},calculateLayout:function(i,e){return K(this,void 0,void 0,function(){var t,r,n,o,a,s,f,u,l;return H(this,function(h){switch(h.label){case 0:if(t=i.layout,r=t.id,n=t.options,o=t.iterations,a=i.nodes,s=i.edges,f=new ft({nodes:a,edges:s}),u=Cu[r],u)kt=new u(n);else throw new Error("Unknown layout id: "+r);return[4,kt.execute(f)];case 1:return l=h.sent(),qu(kt)&&(kt.stop(),l=kt.tick(o)),[2,[l,e]]}})})}};Ae($u)})();
@@ -1,2 +0,0 @@
1
- export {};
2
- //# sourceMappingURL=data.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"data.d.ts","sourceRoot":"","sources":["../../../../libs/graph/src/lib/data/data.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,CAAC"}
@@ -1,2 +0,0 @@
1
- export * from './data';
2
- //# sourceMappingURL=index.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../libs/graph/src/lib/data/index.ts"],"names":[],"mappings":"AAAA,cAAc,QAAQ,CAAC"}