@antv/g6 5.0.0-beta.29 → 5.0.0-beta.30

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 (172) hide show
  1. package/dist/g6.min.js +2 -3
  2. package/dist/lib/__tests__/demo/case/index.d.ts +7 -2
  3. package/dist/lib/__tests__/demo/case/layout-antv-dagre-flow-combo.d.ts +2 -0
  4. package/dist/lib/__tests__/demo/case/layout-antv-dagre-flow.d.ts +2 -0
  5. package/dist/lib/__tests__/demo/case/layout-dagre.d.ts +2 -0
  6. package/dist/lib/__tests__/demo/case/plugin-contextmenu.d.ts +2 -0
  7. package/dist/lib/__tests__/demo/case/plugin-tooltip.d.ts +2 -0
  8. package/dist/lib/__tests__/demo/case/plugin-watermark-image.d.ts +2 -0
  9. package/dist/lib/__tests__/demo/case/plugin-watermark.d.ts +2 -0
  10. package/dist/lib/__tests__/demo/static/common.d.ts +1 -1
  11. package/dist/lib/__tests__/demo/static/controller-layout-antv-dagre.d.ts +2 -0
  12. package/dist/lib/__tests__/setup.d.ts +1 -0
  13. package/dist/lib/__tests__/unit/layouts/dagre.spec.d.ts +1 -0
  14. package/dist/lib/__tests__/unit/plugins/plugin-contextmenu.spec.d.ts +1 -0
  15. package/dist/lib/__tests__/unit/plugins/plugin-watermark.spec.d.ts +1 -0
  16. package/dist/lib/__tests__/unit/plugins/tooltip.spec.d.ts +1 -0
  17. package/dist/lib/src/behaviors/drag-element.d.ts +4 -10
  18. package/dist/lib/src/behaviors/zoom-canvas.d.ts +1 -0
  19. package/dist/lib/src/elements/nodes/base-node.d.ts +1 -1
  20. package/dist/lib/src/exports.d.ts +2 -2
  21. package/dist/lib/src/layouts/index.d.ts +1 -1
  22. package/dist/lib/src/layouts/types.d.ts +8 -2
  23. package/dist/lib/src/plugins/contextmenu.d.ts +88 -0
  24. package/dist/lib/src/plugins/grid-line.d.ts +0 -1
  25. package/dist/lib/src/plugins/index.d.ts +6 -0
  26. package/dist/lib/src/plugins/tooltip.d.ts +39 -0
  27. package/dist/lib/src/plugins/watermark.d.ts +51 -0
  28. package/dist/lib/src/registry/extension/types.d.ts +5 -3
  29. package/dist/lib/src/runtime/element.d.ts +2 -2
  30. package/dist/lib/src/runtime/graph.d.ts +40 -0
  31. package/dist/lib/src/spec/behavior.d.ts +10 -2
  32. package/dist/lib/src/spec/plugin.d.ts +10 -2
  33. package/dist/lib/src/types/event.d.ts +6 -2
  34. package/dist/lib/src/types/plugin.d.ts +5 -0
  35. package/dist/lib/src/utils/contextmenu.d.ts +26 -0
  36. package/dist/lib/src/utils/dom.d.ts +7 -0
  37. package/dist/lib/src/utils/watermark.d.ts +18 -0
  38. package/esm/behaviors/drag-element.d.ts +4 -10
  39. package/esm/behaviors/drag-element.js +17 -20
  40. package/esm/behaviors/drag-element.js.map +1 -1
  41. package/esm/behaviors/zoom-canvas.d.ts +1 -0
  42. package/esm/behaviors/zoom-canvas.js +8 -7
  43. package/esm/behaviors/zoom-canvas.js.map +1 -1
  44. package/esm/elements/nodes/base-node.d.ts +1 -1
  45. package/esm/exports.d.ts +2 -2
  46. package/esm/layouts/index.d.ts +1 -1
  47. package/esm/layouts/index.js +1 -1
  48. package/esm/layouts/index.js.map +1 -1
  49. package/esm/layouts/types.d.ts +8 -2
  50. package/esm/plugins/contextmenu.d.ts +88 -0
  51. package/esm/plugins/contextmenu.js +123 -0
  52. package/esm/plugins/contextmenu.js.map +1 -0
  53. package/esm/plugins/grid-line.d.ts +0 -1
  54. package/esm/plugins/grid-line.js +5 -13
  55. package/esm/plugins/grid-line.js.map +1 -1
  56. package/esm/plugins/index.d.ts +6 -0
  57. package/esm/plugins/index.js +3 -0
  58. package/esm/plugins/index.js.map +1 -1
  59. package/esm/plugins/tooltip.d.ts +39 -0
  60. package/esm/plugins/tooltip.js +232 -0
  61. package/esm/plugins/tooltip.js.map +1 -0
  62. package/esm/plugins/watermark.d.ts +51 -0
  63. package/esm/plugins/watermark.js +53 -0
  64. package/esm/plugins/watermark.js.map +1 -0
  65. package/esm/registry/build-in.js +6 -2
  66. package/esm/registry/build-in.js.map +1 -1
  67. package/esm/registry/extension/types.d.ts +5 -3
  68. package/esm/runtime/behavior.js +1 -1
  69. package/esm/runtime/element.d.ts +2 -2
  70. package/esm/runtime/graph.d.ts +40 -0
  71. package/esm/runtime/graph.js +52 -0
  72. package/esm/runtime/graph.js.map +1 -1
  73. package/esm/runtime/layout.js +7 -1
  74. package/esm/runtime/layout.js.map +1 -1
  75. package/esm/spec/behavior.d.ts +10 -2
  76. package/esm/spec/plugin.d.ts +10 -2
  77. package/esm/types/event.d.ts +6 -2
  78. package/esm/types/plugin.d.ts +5 -0
  79. package/esm/types/plugin.js +2 -0
  80. package/esm/types/plugin.js.map +1 -0
  81. package/esm/utils/contextmenu.d.ts +26 -0
  82. package/esm/utils/contextmenu.js +45 -0
  83. package/esm/utils/contextmenu.js.map +1 -0
  84. package/esm/utils/dom.d.ts +7 -0
  85. package/esm/utils/dom.js +21 -0
  86. package/esm/utils/dom.js.map +1 -1
  87. package/esm/utils/layout.js +1 -1
  88. package/esm/utils/layout.js.map +1 -1
  89. package/esm/utils/watermark.d.ts +18 -0
  90. package/esm/utils/watermark.js +73 -0
  91. package/esm/utils/watermark.js.map +1 -0
  92. package/lib/behaviors/drag-element.d.ts +4 -10
  93. package/lib/behaviors/drag-element.js +16 -19
  94. package/lib/behaviors/drag-element.js.map +1 -1
  95. package/lib/behaviors/zoom-canvas.d.ts +1 -0
  96. package/lib/behaviors/zoom-canvas.js +7 -6
  97. package/lib/behaviors/zoom-canvas.js.map +1 -1
  98. package/lib/elements/nodes/base-node.d.ts +1 -1
  99. package/lib/exports.d.ts +2 -2
  100. package/lib/layouts/index.d.ts +1 -1
  101. package/lib/layouts/index.js +2 -1
  102. package/lib/layouts/index.js.map +1 -1
  103. package/lib/layouts/types.d.ts +8 -2
  104. package/lib/plugins/contextmenu.d.ts +88 -0
  105. package/lib/plugins/contextmenu.js +127 -0
  106. package/lib/plugins/contextmenu.js.map +1 -0
  107. package/lib/plugins/grid-line.d.ts +0 -1
  108. package/lib/plugins/grid-line.js +5 -13
  109. package/lib/plugins/grid-line.js.map +1 -1
  110. package/lib/plugins/index.d.ts +6 -0
  111. package/lib/plugins/index.js +7 -1
  112. package/lib/plugins/index.js.map +1 -1
  113. package/lib/plugins/tooltip.d.ts +39 -0
  114. package/lib/plugins/tooltip.js +236 -0
  115. package/lib/plugins/tooltip.js.map +1 -0
  116. package/lib/plugins/watermark.d.ts +51 -0
  117. package/lib/plugins/watermark.js +57 -0
  118. package/lib/plugins/watermark.js.map +1 -0
  119. package/lib/registry/build-in.js +4 -0
  120. package/lib/registry/build-in.js.map +1 -1
  121. package/lib/registry/extension/types.d.ts +5 -3
  122. package/lib/runtime/behavior.js +1 -1
  123. package/lib/runtime/element.d.ts +2 -2
  124. package/lib/runtime/graph.d.ts +40 -0
  125. package/lib/runtime/graph.js +52 -0
  126. package/lib/runtime/graph.js.map +1 -1
  127. package/lib/runtime/layout.js +7 -1
  128. package/lib/runtime/layout.js.map +1 -1
  129. package/lib/spec/behavior.d.ts +10 -2
  130. package/lib/spec/plugin.d.ts +10 -2
  131. package/lib/types/event.d.ts +6 -2
  132. package/lib/types/plugin.d.ts +5 -0
  133. package/lib/types/plugin.js +3 -0
  134. package/lib/types/plugin.js.map +1 -0
  135. package/lib/utils/contextmenu.d.ts +26 -0
  136. package/lib/utils/contextmenu.js +49 -0
  137. package/lib/utils/contextmenu.js.map +1 -0
  138. package/lib/utils/dom.d.ts +7 -0
  139. package/lib/utils/dom.js +23 -1
  140. package/lib/utils/dom.js.map +1 -1
  141. package/lib/utils/layout.js +1 -1
  142. package/lib/utils/layout.js.map +1 -1
  143. package/lib/utils/watermark.d.ts +18 -0
  144. package/lib/utils/watermark.js +78 -0
  145. package/lib/utils/watermark.js.map +1 -0
  146. package/package.json +13 -5
  147. package/src/behaviors/drag-element.ts +20 -28
  148. package/src/behaviors/zoom-canvas.ts +12 -7
  149. package/src/layouts/index.ts +1 -0
  150. package/src/layouts/types.ts +17 -5
  151. package/src/plugins/contextmenu.ts +199 -0
  152. package/src/plugins/grid-line.ts +7 -14
  153. package/src/plugins/index.ts +6 -0
  154. package/src/plugins/tooltip.ts +268 -0
  155. package/src/plugins/watermark.ts +98 -0
  156. package/src/registry/build-in.ts +6 -1
  157. package/src/registry/extension/types.ts +5 -3
  158. package/src/runtime/behavior.ts +1 -1
  159. package/src/runtime/graph.ts +60 -0
  160. package/src/runtime/layout.ts +7 -1
  161. package/src/spec/behavior.ts +11 -2
  162. package/src/spec/plugin.ts +11 -2
  163. package/src/types/event.ts +7 -2
  164. package/src/types/plugin.ts +6 -0
  165. package/src/utils/contextmenu.ts +62 -0
  166. package/src/utils/dom.ts +26 -0
  167. package/src/utils/layout.ts +1 -1
  168. package/src/utils/watermark.ts +93 -0
  169. package/dist/lib/__tests__/demo/case/layout-dagre-flow-combo.d.ts +0 -2
  170. package/dist/lib/__tests__/demo/case/layout-dagre-flow.d.ts +0 -2
  171. package/dist/lib/__tests__/demo/static/controller-layout-dagre.d.ts +0 -2
  172. /package/dist/lib/__tests__/unit/{layouts/dagre-flow.spec.d.ts → behaviors/drag-element-bug.spec.d.ts} +0 -0
package/dist/g6.min.js CHANGED
@@ -1,7 +1,6 @@
1
- !function(t,e){"object"==typeof exports&&"undefined"!=typeof module?e(exports):"function"==typeof define&&define.amd?define(["exports"],e):e((t="undefined"!=typeof globalThis?globalThis:t||self).G6V5={})}(this,(function(t){"use strict";var e="undefined"!=typeof document?document.currentScript:null,n=function(t,e){return n=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(t,e){t.__proto__=e}||function(t,e){for(var n in e)Object.prototype.hasOwnProperty.call(e,n)&&(t[n]=e[n])},n(t,e)};function r(t,e){if("function"!=typeof e&&null!==e)throw new TypeError("Class extends value "+String(e)+" is not a constructor or null");function r(){this.constructor=t}n(t,e),t.prototype=null===e?Object.create(e):(r.prototype=e.prototype,new r)}var i=function(){return i=Object.assign||function(t){for(var e,n=1,r=arguments.length;n<r;n++)for(var i in e=arguments[n])Object.prototype.hasOwnProperty.call(e,i)&&(t[i]=e[i]);return t},i.apply(this,arguments)};function o(t,e){var n={};for(var r in t)Object.prototype.hasOwnProperty.call(t,r)&&e.indexOf(r)<0&&(n[r]=t[r]);if(null!=t&&"function"==typeof Object.getOwnPropertySymbols){var i=0;for(r=Object.getOwnPropertySymbols(t);i<r.length;i++)e.indexOf(r[i])<0&&Object.prototype.propertyIsEnumerable.call(t,r[i])&&(n[r[i]]=t[r[i]])}return n}function a(t,e,n,r){return new(n||(n=Promise))((function(i,o){function a(t){try{u(r.next(t))}catch(t){o(t)}}function s(t){try{u(r.throw(t))}catch(t){o(t)}}function u(t){var e;t.done?i(t.value):(e=t.value,e instanceof n?e:new n((function(t){t(e)}))).then(a,s)}u((r=r.apply(t,e||[])).next())}))}function s(t,e){var n,r,i,o,a={label:0,sent:function(){if(1&i[0])throw i[1];return i[1]},trys:[],ops:[]};return o={next:s(0),throw:s(1),return:s(2)},"function"==typeof Symbol&&(o[Symbol.iterator]=function(){return this}),o;function s(s){return function(u){return function(s){if(n)throw new TypeError("Generator is already executing.");for(;o&&(o=0,s[0]&&(a=0)),a;)try{if(n=1,r&&(i=2&s[0]?r.return:s[0]?r.throw||((i=r.return)&&i.call(r),0):r.next)&&!(i=i.call(r,s[1])).done)return i;switch(r=0,i&&(s=[2&s[0],i.value]),s[0]){case 0:case 1:i=s;break;case 4:return a.label++,{value:s[1],done:!1};case 5:a.label++,r=s[1],s=[0];continue;case 7:s=a.ops.pop(),a.trys.pop();continue;default:if(!(i=a.trys,(i=i.length>0&&i[i.length-1])||6!==s[0]&&2!==s[0])){a=0;continue}if(3===s[0]&&(!i||s[1]>i[0]&&s[1]<i[3])){a.label=s[1];break}if(6===s[0]&&a.label<i[1]){a.label=i[1],i=s;break}if(i&&a.label<i[2]){a.label=i[2],a.ops.push(s);break}i[2]&&a.ops.pop(),a.trys.pop();continue}s=e.call(t,a)}catch(t){s=[6,t],r=0}finally{n=i=0}if(5&s[0])throw s[1];return{value:s[0]?s[1]:void 0,done:!0}}([s,u])}}}function u(t){var e="function"==typeof Symbol&&Symbol.iterator,n=e&&t[e],r=0;if(n)return n.call(t);if(t&&"number"==typeof t.length)return{next:function(){return t&&r>=t.length&&(t=void 0),{value:t&&t[r++],done:!t}}};throw new TypeError(e?"Object is not iterable.":"Symbol.iterator is not defined.")}function c(t,e){var n="function"==typeof Symbol&&t[Symbol.iterator];if(!n)return t;var r,i,o=n.call(t),a=[];try{for(;(void 0===e||e-- >0)&&!(r=o.next()).done;)a.push(r.value)}catch(t){i={error:t}}finally{try{r&&!r.done&&(n=o.return)&&n.call(o)}finally{if(i)throw i.error}}return a}function h(t,e,n){if(n||2===arguments.length)for(var r,i=0,o=e.length;i<o;i++)!r&&i in e||(r||(r=Array.prototype.slice.call(e,0,i)),r[i]=e[i]);return t.concat(r||Array.prototype.slice.call(e))}function l(t){return t&&t.__esModule&&Object.prototype.hasOwnProperty.call(t,"default")?t.default:t}function d(t){if(t.__esModule)return t;var e=t.default;if("function"==typeof e){var n=function t(){return this instanceof t?Reflect.construct(e,arguments,this.constructor):e.apply(this,arguments)};n.prototype=e.prototype}else n={};return Object.defineProperty(n,"__esModule",{value:!0}),Object.keys(t).forEach((function(e){var r=Object.getOwnPropertyDescriptor(t,e);Object.defineProperty(n,e,r.get?r:{enumerable:!0,get:function(){return t[e]}})})),n}"function"==typeof SuppressedError&&SuppressedError;var f={exports:{}};!function(t){var e=Object.prototype.hasOwnProperty,n="~";function r(){}function i(t,e,n){this.fn=t,this.context=e,this.once=n||!1}function o(t,e,r,o,a){if("function"!=typeof r)throw new TypeError("The listener must be a function");var s=new i(r,o||t,a),u=n?n+e:e;return t._events[u]?t._events[u].fn?t._events[u]=[t._events[u],s]:t._events[u].push(s):(t._events[u]=s,t._eventsCount++),t}function a(t,e){0==--t._eventsCount?t._events=new r:delete t._events[e]}function s(){this._events=new r,this._eventsCount=0}Object.create&&(r.prototype=Object.create(null),(new r).__proto__||(n=!1)),s.prototype.eventNames=function(){var t,r,i=[];if(0===this._eventsCount)return i;for(r in t=this._events)e.call(t,r)&&i.push(n?r.slice(1):r);return Object.getOwnPropertySymbols?i.concat(Object.getOwnPropertySymbols(t)):i},s.prototype.listeners=function(t){var e=n?n+t:t,r=this._events[e];if(!r)return[];if(r.fn)return[r.fn];for(var i=0,o=r.length,a=new Array(o);i<o;i++)a[i]=r[i].fn;return a},s.prototype.listenerCount=function(t){var e=n?n+t:t,r=this._events[e];return r?r.fn?1:r.length:0},s.prototype.emit=function(t,e,r,i,o,a){var s=n?n+t:t;if(!this._events[s])return!1;var u,c,h=this._events[s],l=arguments.length;if(h.fn){switch(h.once&&this.removeListener(t,h.fn,void 0,!0),l){case 1:return h.fn.call(h.context),!0;case 2:return h.fn.call(h.context,e),!0;case 3:return h.fn.call(h.context,e,r),!0;case 4:return h.fn.call(h.context,e,r,i),!0;case 5:return h.fn.call(h.context,e,r,i,o),!0;case 6:return h.fn.call(h.context,e,r,i,o,a),!0}for(c=1,u=new Array(l-1);c<l;c++)u[c-1]=arguments[c];h.fn.apply(h.context,u)}else{var d,f=h.length;for(c=0;c<f;c++)switch(h[c].once&&this.removeListener(t,h[c].fn,void 0,!0),l){case 1:h[c].fn.call(h[c].context);break;case 2:h[c].fn.call(h[c].context,e);break;case 3:h[c].fn.call(h[c].context,e,r);break;case 4:h[c].fn.call(h[c].context,e,r,i);break;default:if(!u)for(d=1,u=new Array(l-1);d<l;d++)u[d-1]=arguments[d];h[c].fn.apply(h[c].context,u)}}return!0},s.prototype.on=function(t,e,n){return o(this,t,e,n,!1)},s.prototype.once=function(t,e,n){return o(this,t,e,n,!0)},s.prototype.removeListener=function(t,e,r,i){var o=n?n+t:t;if(!this._events[o])return this;if(!e)return a(this,o),this;var s=this._events[o];if(s.fn)s.fn!==e||i&&!s.once||r&&s.context!==r||a(this,o);else{for(var u=0,c=[],h=s.length;u<h;u++)(s[u].fn!==e||i&&!s[u].once||r&&s[u].context!==r)&&c.push(s[u]);c.length?this._events[o]=1===c.length?c[0]:c:a(this,o)}return this},s.prototype.removeAllListeners=function(t){var e;return t?(e=n?n+t:t,this._events[e]&&a(this,e)):(this._events=new r,this._eventsCount=0),this},s.prototype.off=s.prototype.removeListener,s.prototype.addListener=s.prototype.on,s.prefixed=n,s.EventEmitter=s,t.exports=s}(f);var p=l(f.exports),g=1e-6,m="undefined"!=typeof Float32Array?Float32Array:Array;function v(){var t=new m(9);return m!=Float32Array&&(t[1]=0,t[2]=0,t[3]=0,t[5]=0,t[6]=0,t[7]=0),t[0]=1,t[4]=1,t[8]=1,t}function y(){var t=new m(16);return m!=Float32Array&&(t[1]=0,t[2]=0,t[3]=0,t[4]=0,t[6]=0,t[7]=0,t[8]=0,t[9]=0,t[11]=0,t[12]=0,t[13]=0,t[14]=0),t[0]=1,t[5]=1,t[10]=1,t[15]=1,t}function E(t){var e=new m(16);return e[0]=t[0],e[1]=t[1],e[2]=t[2],e[3]=t[3],e[4]=t[4],e[5]=t[5],e[6]=t[6],e[7]=t[7],e[8]=t[8],e[9]=t[9],e[10]=t[10],e[11]=t[11],e[12]=t[12],e[13]=t[13],e[14]=t[14],e[15]=t[15],e}function x(t,e){return t[0]=e[0],t[1]=e[1],t[2]=e[2],t[3]=e[3],t[4]=e[4],t[5]=e[5],t[6]=e[6],t[7]=e[7],t[8]=e[8],t[9]=e[9],t[10]=e[10],t[11]=e[11],t[12]=e[12],t[13]=e[13],t[14]=e[14],t[15]=e[15],t}function b(t,e,n,r,i,o,a,s,u,c,h,l,d,f,p,g,m){return t[0]=e,t[1]=n,t[2]=r,t[3]=i,t[4]=o,t[5]=a,t[6]=s,t[7]=u,t[8]=c,t[9]=h,t[10]=l,t[11]=d,t[12]=f,t[13]=p,t[14]=g,t[15]=m,t}function w(t){return t[0]=1,t[1]=0,t[2]=0,t[3]=0,t[4]=0,t[5]=1,t[6]=0,t[7]=0,t[8]=0,t[9]=0,t[10]=1,t[11]=0,t[12]=0,t[13]=0,t[14]=0,t[15]=1,t}function M(t,e){if(t===e){var n=e[1],r=e[2],i=e[3],o=e[6],a=e[7],s=e[11];t[1]=e[4],t[2]=e[8],t[3]=e[12],t[4]=n,t[6]=e[9],t[7]=e[13],t[8]=r,t[9]=o,t[11]=e[14],t[12]=i,t[13]=a,t[14]=s}else t[0]=e[0],t[1]=e[4],t[2]=e[8],t[3]=e[12],t[4]=e[1],t[5]=e[5],t[6]=e[9],t[7]=e[13],t[8]=e[2],t[9]=e[6],t[10]=e[10],t[11]=e[14],t[12]=e[3],t[13]=e[7],t[14]=e[11],t[15]=e[15];return t}function N(t,e){var n=e[0],r=e[1],i=e[2],o=e[3],a=e[4],s=e[5],u=e[6],c=e[7],h=e[8],l=e[9],d=e[10],f=e[11],p=e[12],g=e[13],m=e[14],v=e[15],y=n*s-r*a,E=n*u-i*a,x=n*c-o*a,b=r*u-i*s,w=r*c-o*s,M=i*c-o*u,N=h*g-l*p,S=h*m-d*p,T=h*v-f*p,P=l*m-d*g,C=l*v-f*g,k=d*v-f*m,A=y*k-E*C+x*P+b*T-w*S+M*N;return A?(A=1/A,t[0]=(s*k-u*C+c*P)*A,t[1]=(i*C-r*k-o*P)*A,t[2]=(g*M-m*w+v*b)*A,t[3]=(d*w-l*M-f*b)*A,t[4]=(u*T-a*k-c*S)*A,t[5]=(n*k-i*T+o*S)*A,t[6]=(m*x-p*M-v*E)*A,t[7]=(h*M-d*x+f*E)*A,t[8]=(a*C-s*T+c*N)*A,t[9]=(r*T-n*C-o*N)*A,t[10]=(p*w-g*x+v*y)*A,t[11]=(l*x-h*w-f*y)*A,t[12]=(s*S-a*P-u*N)*A,t[13]=(n*P-r*S+i*N)*A,t[14]=(g*E-p*b-m*y)*A,t[15]=(h*b-l*E+d*y)*A,t):null}function S(t){var e=t[0],n=t[1],r=t[2],i=t[3],o=t[4],a=t[5],s=t[6],u=t[7],c=t[8],h=t[9],l=t[10],d=t[11],f=t[12],p=t[13],g=t[14],m=t[15];return(e*a-n*o)*(l*m-d*g)-(e*s-r*o)*(h*m-d*p)+(e*u-i*o)*(h*g-l*p)+(n*s-r*a)*(c*m-d*f)-(n*u-i*a)*(c*g-l*f)+(r*u-i*s)*(c*p-h*f)}function T(t,e,n){var r=e[0],i=e[1],o=e[2],a=e[3],s=e[4],u=e[5],c=e[6],h=e[7],l=e[8],d=e[9],f=e[10],p=e[11],g=e[12],m=e[13],v=e[14],y=e[15],E=n[0],x=n[1],b=n[2],w=n[3];return t[0]=E*r+x*s+b*l+w*g,t[1]=E*i+x*u+b*d+w*m,t[2]=E*o+x*c+b*f+w*v,t[3]=E*a+x*h+b*p+w*y,E=n[4],x=n[5],b=n[6],w=n[7],t[4]=E*r+x*s+b*l+w*g,t[5]=E*i+x*u+b*d+w*m,t[6]=E*o+x*c+b*f+w*v,t[7]=E*a+x*h+b*p+w*y,E=n[8],x=n[9],b=n[10],w=n[11],t[8]=E*r+x*s+b*l+w*g,t[9]=E*i+x*u+b*d+w*m,t[10]=E*o+x*c+b*f+w*v,t[11]=E*a+x*h+b*p+w*y,E=n[12],x=n[13],b=n[14],w=n[15],t[12]=E*r+x*s+b*l+w*g,t[13]=E*i+x*u+b*d+w*m,t[14]=E*o+x*c+b*f+w*v,t[15]=E*a+x*h+b*p+w*y,t}function P(t,e,n){var r,i,o,a,s,u,c,h,l,d,f,p,g=n[0],m=n[1],v=n[2];return e===t?(t[12]=e[0]*g+e[4]*m+e[8]*v+e[12],t[13]=e[1]*g+e[5]*m+e[9]*v+e[13],t[14]=e[2]*g+e[6]*m+e[10]*v+e[14],t[15]=e[3]*g+e[7]*m+e[11]*v+e[15]):(r=e[0],i=e[1],o=e[2],a=e[3],s=e[4],u=e[5],c=e[6],h=e[7],l=e[8],d=e[9],f=e[10],p=e[11],t[0]=r,t[1]=i,t[2]=o,t[3]=a,t[4]=s,t[5]=u,t[6]=c,t[7]=h,t[8]=l,t[9]=d,t[10]=f,t[11]=p,t[12]=r*g+s*m+l*v+e[12],t[13]=i*g+u*m+d*v+e[13],t[14]=o*g+c*m+f*v+e[14],t[15]=a*g+h*m+p*v+e[15]),t}function C(t,e,n){var r=n[0],i=n[1],o=n[2];return t[0]=e[0]*r,t[1]=e[1]*r,t[2]=e[2]*r,t[3]=e[3]*r,t[4]=e[4]*i,t[5]=e[5]*i,t[6]=e[6]*i,t[7]=e[7]*i,t[8]=e[8]*o,t[9]=e[9]*o,t[10]=e[10]*o,t[11]=e[11]*o,t[12]=e[12],t[13]=e[13],t[14]=e[14],t[15]=e[15],t}function k(t,e,n){var r=Math.sin(n),i=Math.cos(n),o=e[4],a=e[5],s=e[6],u=e[7],c=e[8],h=e[9],l=e[10],d=e[11];return e!==t&&(t[0]=e[0],t[1]=e[1],t[2]=e[2],t[3]=e[3],t[12]=e[12],t[13]=e[13],t[14]=e[14],t[15]=e[15]),t[4]=o*i+c*r,t[5]=a*i+h*r,t[6]=s*i+l*r,t[7]=u*i+d*r,t[8]=c*i-o*r,t[9]=h*i-a*r,t[10]=l*i-s*r,t[11]=d*i-u*r,t}function A(t,e,n){var r=Math.sin(n),i=Math.cos(n),o=e[0],a=e[1],s=e[2],u=e[3],c=e[8],h=e[9],l=e[10],d=e[11];return e!==t&&(t[4]=e[4],t[5]=e[5],t[6]=e[6],t[7]=e[7],t[12]=e[12],t[13]=e[13],t[14]=e[14],t[15]=e[15]),t[0]=o*i-c*r,t[1]=a*i-h*r,t[2]=s*i-l*r,t[3]=u*i-d*r,t[8]=o*r+c*i,t[9]=a*r+h*i,t[10]=s*r+l*i,t[11]=u*r+d*i,t}function O(t,e){return t[0]=1,t[1]=0,t[2]=0,t[3]=0,t[4]=0,t[5]=1,t[6]=0,t[7]=0,t[8]=0,t[9]=0,t[10]=1,t[11]=0,t[12]=e[0],t[13]=e[1],t[14]=e[2],t[15]=1,t}function R(t,e){return t[0]=e[0],t[1]=0,t[2]=0,t[3]=0,t[4]=0,t[5]=e[1],t[6]=0,t[7]=0,t[8]=0,t[9]=0,t[10]=e[2],t[11]=0,t[12]=0,t[13]=0,t[14]=0,t[15]=1,t}function D(t,e,n){var r=e[0],i=e[1],o=e[2],a=e[3],s=r+r,u=i+i,c=o+o,h=r*s,l=r*u,d=r*c,f=i*u,p=i*c,g=o*c,m=a*s,v=a*u,y=a*c;return t[0]=1-(f+g),t[1]=l+y,t[2]=d-v,t[3]=0,t[4]=l-y,t[5]=1-(h+g),t[6]=p+m,t[7]=0,t[8]=d+v,t[9]=p-m,t[10]=1-(h+f),t[11]=0,t[12]=n[0],t[13]=n[1],t[14]=n[2],t[15]=1,t}function I(t,e){return t[0]=e[12],t[1]=e[13],t[2]=e[14],t}function L(t,e){var n=e[0],r=e[1],i=e[2],o=e[4],a=e[5],s=e[6],u=e[8],c=e[9],h=e[10];return t[0]=Math.hypot(n,r,i),t[1]=Math.hypot(o,a,s),t[2]=Math.hypot(u,c,h),t}function _(t,e){var n=new m(3);L(n,e);var r=1/n[0],i=1/n[1],o=1/n[2],a=e[0]*r,s=e[1]*i,u=e[2]*o,c=e[4]*r,h=e[5]*i,l=e[6]*o,d=e[8]*r,f=e[9]*i,p=e[10]*o,g=a+h+p,v=0;return g>0?(v=2*Math.sqrt(g+1),t[3]=.25*v,t[0]=(l-f)/v,t[1]=(d-u)/v,t[2]=(s-c)/v):a>h&&a>p?(v=2*Math.sqrt(1+a-h-p),t[3]=(l-f)/v,t[0]=.25*v,t[1]=(s+c)/v,t[2]=(d+u)/v):h>p?(v=2*Math.sqrt(1+h-a-p),t[3]=(d-u)/v,t[0]=(s+c)/v,t[1]=.25*v,t[2]=(l+f)/v):(v=2*Math.sqrt(1+p-a-h),t[3]=(s-c)/v,t[0]=(d+u)/v,t[1]=(l+f)/v,t[2]=.25*v),t}function z(t,e,n,r,i){var o=e[0],a=e[1],s=e[2],u=e[3],c=o+o,h=a+a,l=s+s,d=o*c,f=o*h,p=o*l,g=a*h,m=a*l,v=s*l,y=u*c,E=u*h,x=u*l,b=r[0],w=r[1],M=r[2],N=i[0],S=i[1],T=i[2],P=(1-(g+v))*b,C=(f+x)*b,k=(p-E)*b,A=(f-x)*w,O=(1-(d+v))*w,R=(m+y)*w,D=(p+E)*M,I=(m-y)*M,L=(1-(d+g))*M;return t[0]=P,t[1]=C,t[2]=k,t[3]=0,t[4]=A,t[5]=O,t[6]=R,t[7]=0,t[8]=D,t[9]=I,t[10]=L,t[11]=0,t[12]=n[0]+N-(P*N+A*S+D*T),t[13]=n[1]+S-(C*N+O*S+I*T),t[14]=n[2]+T-(k*N+R*S+L*T),t[15]=1,t}function F(t,e){var n=e[0],r=e[1],i=e[2],o=e[3],a=n+n,s=r+r,u=i+i,c=n*a,h=r*a,l=r*s,d=i*a,f=i*s,p=i*u,g=o*a,m=o*s,v=o*u;return t[0]=1-l-p,t[1]=h+v,t[2]=d-m,t[3]=0,t[4]=h-v,t[5]=1-c-p,t[6]=f+g,t[7]=0,t[8]=d+m,t[9]=f-g,t[10]=1-c-l,t[11]=0,t[12]=0,t[13]=0,t[14]=0,t[15]=1,t}function B(t,e,n,r,i){var o,a=1/Math.tan(e/2);return t[0]=a/n,t[1]=0,t[2]=0,t[3]=0,t[4]=0,t[5]=a,t[6]=0,t[7]=0,t[8]=0,t[9]=0,t[11]=-1,t[12]=0,t[13]=0,t[15]=0,null!=i&&i!==1/0?(o=1/(r-i),t[10]=(i+r)*o,t[14]=2*i*r*o):(t[10]=-1,t[14]=-2*r),t}Math.hypot||(Math.hypot=function(){for(var t=0,e=arguments.length;e--;)t+=arguments[e]*arguments[e];return Math.sqrt(t)});var G=B;function j(t,e,n,r,i,o,a){var s=1/(e-n),u=1/(r-i),c=1/(o-a);return t[0]=-2*s,t[1]=0,t[2]=0,t[3]=0,t[4]=0,t[5]=-2*u,t[6]=0,t[7]=0,t[8]=0,t[9]=0,t[10]=2*c,t[11]=0,t[12]=(e+n)*s,t[13]=(i+r)*u,t[14]=(a+o)*c,t[15]=1,t}var V=j;function U(t,e,n,r,i,o,a){var s=1/(e-n),u=1/(r-i),c=1/(o-a);return t[0]=-2*s,t[1]=0,t[2]=0,t[3]=0,t[4]=0,t[5]=-2*u,t[6]=0,t[7]=0,t[8]=0,t[9]=0,t[10]=c,t[11]=0,t[12]=(e+n)*s,t[13]=(i+r)*u,t[14]=o*c,t[15]=1,t}function W(t,e,n,r){var i,o,a,s,u,c,h,l,d,f,p=e[0],m=e[1],v=e[2],y=r[0],E=r[1],x=r[2],b=n[0],M=n[1],N=n[2];return Math.abs(p-b)<g&&Math.abs(m-M)<g&&Math.abs(v-N)<g?w(t):(h=p-b,l=m-M,d=v-N,i=E*(d*=f=1/Math.hypot(h,l,d))-x*(l*=f),o=x*(h*=f)-y*d,a=y*l-E*h,(f=Math.hypot(i,o,a))?(i*=f=1/f,o*=f,a*=f):(i=0,o=0,a=0),s=l*a-d*o,u=d*i-h*a,c=h*o-l*i,(f=Math.hypot(s,u,c))?(s*=f=1/f,u*=f,c*=f):(s=0,u=0,c=0),t[0]=i,t[1]=s,t[2]=h,t[3]=0,t[4]=o,t[5]=u,t[6]=l,t[7]=0,t[8]=a,t[9]=c,t[10]=d,t[11]=0,t[12]=-(i*p+o*m+a*v),t[13]=-(s*p+u*m+c*v),t[14]=-(h*p+l*m+d*v),t[15]=1,t)}function H(t,e,n){return t[0]=e[0]-n[0],t[1]=e[1]-n[1],t[2]=e[2]-n[2],t[3]=e[3]-n[3],t[4]=e[4]-n[4],t[5]=e[5]-n[5],t[6]=e[6]-n[6],t[7]=e[7]-n[7],t[8]=e[8]-n[8],t[9]=e[9]-n[9],t[10]=e[10]-n[10],t[11]=e[11]-n[11],t[12]=e[12]-n[12],t[13]=e[13]-n[13],t[14]=e[14]-n[14],t[15]=e[15]-n[15],t}var q=T,Y=H,X=Object.freeze({__proto__:null,add:function(t,e,n){return t[0]=e[0]+n[0],t[1]=e[1]+n[1],t[2]=e[2]+n[2],t[3]=e[3]+n[3],t[4]=e[4]+n[4],t[5]=e[5]+n[5],t[6]=e[6]+n[6],t[7]=e[7]+n[7],t[8]=e[8]+n[8],t[9]=e[9]+n[9],t[10]=e[10]+n[10],t[11]=e[11]+n[11],t[12]=e[12]+n[12],t[13]=e[13]+n[13],t[14]=e[14]+n[14],t[15]=e[15]+n[15],t},adjoint:function(t,e){var n=e[0],r=e[1],i=e[2],o=e[3],a=e[4],s=e[5],u=e[6],c=e[7],h=e[8],l=e[9],d=e[10],f=e[11],p=e[12],g=e[13],m=e[14],v=e[15];return t[0]=s*(d*v-f*m)-l*(u*v-c*m)+g*(u*f-c*d),t[1]=-(r*(d*v-f*m)-l*(i*v-o*m)+g*(i*f-o*d)),t[2]=r*(u*v-c*m)-s*(i*v-o*m)+g*(i*c-o*u),t[3]=-(r*(u*f-c*d)-s*(i*f-o*d)+l*(i*c-o*u)),t[4]=-(a*(d*v-f*m)-h*(u*v-c*m)+p*(u*f-c*d)),t[5]=n*(d*v-f*m)-h*(i*v-o*m)+p*(i*f-o*d),t[6]=-(n*(u*v-c*m)-a*(i*v-o*m)+p*(i*c-o*u)),t[7]=n*(u*f-c*d)-a*(i*f-o*d)+h*(i*c-o*u),t[8]=a*(l*v-f*g)-h*(s*v-c*g)+p*(s*f-c*l),t[9]=-(n*(l*v-f*g)-h*(r*v-o*g)+p*(r*f-o*l)),t[10]=n*(s*v-c*g)-a*(r*v-o*g)+p*(r*c-o*s),t[11]=-(n*(s*f-c*l)-a*(r*f-o*l)+h*(r*c-o*s)),t[12]=-(a*(l*m-d*g)-h*(s*m-u*g)+p*(s*d-u*l)),t[13]=n*(l*m-d*g)-h*(r*m-i*g)+p*(r*d-i*l),t[14]=-(n*(s*m-u*g)-a*(r*m-i*g)+p*(r*u-i*s)),t[15]=n*(s*d-u*l)-a*(r*d-i*l)+h*(r*u-i*s),t},clone:E,copy:x,create:y,determinant:S,equals:function(t,e){var n=t[0],r=t[1],i=t[2],o=t[3],a=t[4],s=t[5],u=t[6],c=t[7],h=t[8],l=t[9],d=t[10],f=t[11],p=t[12],m=t[13],v=t[14],y=t[15],E=e[0],x=e[1],b=e[2],w=e[3],M=e[4],N=e[5],S=e[6],T=e[7],P=e[8],C=e[9],k=e[10],A=e[11],O=e[12],R=e[13],D=e[14],I=e[15];return Math.abs(n-E)<=g*Math.max(1,Math.abs(n),Math.abs(E))&&Math.abs(r-x)<=g*Math.max(1,Math.abs(r),Math.abs(x))&&Math.abs(i-b)<=g*Math.max(1,Math.abs(i),Math.abs(b))&&Math.abs(o-w)<=g*Math.max(1,Math.abs(o),Math.abs(w))&&Math.abs(a-M)<=g*Math.max(1,Math.abs(a),Math.abs(M))&&Math.abs(s-N)<=g*Math.max(1,Math.abs(s),Math.abs(N))&&Math.abs(u-S)<=g*Math.max(1,Math.abs(u),Math.abs(S))&&Math.abs(c-T)<=g*Math.max(1,Math.abs(c),Math.abs(T))&&Math.abs(h-P)<=g*Math.max(1,Math.abs(h),Math.abs(P))&&Math.abs(l-C)<=g*Math.max(1,Math.abs(l),Math.abs(C))&&Math.abs(d-k)<=g*Math.max(1,Math.abs(d),Math.abs(k))&&Math.abs(f-A)<=g*Math.max(1,Math.abs(f),Math.abs(A))&&Math.abs(p-O)<=g*Math.max(1,Math.abs(p),Math.abs(O))&&Math.abs(m-R)<=g*Math.max(1,Math.abs(m),Math.abs(R))&&Math.abs(v-D)<=g*Math.max(1,Math.abs(v),Math.abs(D))&&Math.abs(y-I)<=g*Math.max(1,Math.abs(y),Math.abs(I))},exactEquals:function(t,e){return t[0]===e[0]&&t[1]===e[1]&&t[2]===e[2]&&t[3]===e[3]&&t[4]===e[4]&&t[5]===e[5]&&t[6]===e[6]&&t[7]===e[7]&&t[8]===e[8]&&t[9]===e[9]&&t[10]===e[10]&&t[11]===e[11]&&t[12]===e[12]&&t[13]===e[13]&&t[14]===e[14]&&t[15]===e[15]},frob:function(t){return Math.hypot(t[0],t[1],t[2],t[3],t[4],t[5],t[6],t[7],t[8],t[9],t[10],t[11],t[12],t[13],t[14],t[15])},fromQuat:F,fromQuat2:function(t,e){var n=new m(3),r=-e[0],i=-e[1],o=-e[2],a=e[3],s=e[4],u=e[5],c=e[6],h=e[7],l=r*r+i*i+o*o+a*a;return l>0?(n[0]=2*(s*a+h*r+u*o-c*i)/l,n[1]=2*(u*a+h*i+c*r-s*o)/l,n[2]=2*(c*a+h*o+s*i-u*r)/l):(n[0]=2*(s*a+h*r+u*o-c*i),n[1]=2*(u*a+h*i+c*r-s*o),n[2]=2*(c*a+h*o+s*i-u*r)),D(t,e,n),t},fromRotation:function(t,e,n){var r,i,o,a=n[0],s=n[1],u=n[2],c=Math.hypot(a,s,u);return c<g?null:(a*=c=1/c,s*=c,u*=c,r=Math.sin(e),o=1-(i=Math.cos(e)),t[0]=a*a*o+i,t[1]=s*a*o+u*r,t[2]=u*a*o-s*r,t[3]=0,t[4]=a*s*o-u*r,t[5]=s*s*o+i,t[6]=u*s*o+a*r,t[7]=0,t[8]=a*u*o+s*r,t[9]=s*u*o-a*r,t[10]=u*u*o+i,t[11]=0,t[12]=0,t[13]=0,t[14]=0,t[15]=1,t)},fromRotationTranslation:D,fromRotationTranslationScale:function(t,e,n,r){var i=e[0],o=e[1],a=e[2],s=e[3],u=i+i,c=o+o,h=a+a,l=i*u,d=i*c,f=i*h,p=o*c,g=o*h,m=a*h,v=s*u,y=s*c,E=s*h,x=r[0],b=r[1],w=r[2];return t[0]=(1-(p+m))*x,t[1]=(d+E)*x,t[2]=(f-y)*x,t[3]=0,t[4]=(d-E)*b,t[5]=(1-(l+m))*b,t[6]=(g+v)*b,t[7]=0,t[8]=(f+y)*w,t[9]=(g-v)*w,t[10]=(1-(l+p))*w,t[11]=0,t[12]=n[0],t[13]=n[1],t[14]=n[2],t[15]=1,t},fromRotationTranslationScaleOrigin:z,fromScaling:R,fromTranslation:O,fromValues:function(t,e,n,r,i,o,a,s,u,c,h,l,d,f,p,g){var v=new m(16);return v[0]=t,v[1]=e,v[2]=n,v[3]=r,v[4]=i,v[5]=o,v[6]=a,v[7]=s,v[8]=u,v[9]=c,v[10]=h,v[11]=l,v[12]=d,v[13]=f,v[14]=p,v[15]=g,v},fromXRotation:function(t,e){var n=Math.sin(e),r=Math.cos(e);return t[0]=1,t[1]=0,t[2]=0,t[3]=0,t[4]=0,t[5]=r,t[6]=n,t[7]=0,t[8]=0,t[9]=-n,t[10]=r,t[11]=0,t[12]=0,t[13]=0,t[14]=0,t[15]=1,t},fromYRotation:function(t,e){var n=Math.sin(e),r=Math.cos(e);return t[0]=r,t[1]=0,t[2]=-n,t[3]=0,t[4]=0,t[5]=1,t[6]=0,t[7]=0,t[8]=n,t[9]=0,t[10]=r,t[11]=0,t[12]=0,t[13]=0,t[14]=0,t[15]=1,t},fromZRotation:function(t,e){var n=Math.sin(e),r=Math.cos(e);return t[0]=r,t[1]=n,t[2]=0,t[3]=0,t[4]=-n,t[5]=r,t[6]=0,t[7]=0,t[8]=0,t[9]=0,t[10]=1,t[11]=0,t[12]=0,t[13]=0,t[14]=0,t[15]=1,t},frustum:function(t,e,n,r,i,o,a){var s=1/(n-e),u=1/(i-r),c=1/(o-a);return t[0]=2*o*s,t[1]=0,t[2]=0,t[3]=0,t[4]=0,t[5]=2*o*u,t[6]=0,t[7]=0,t[8]=(n+e)*s,t[9]=(i+r)*u,t[10]=(a+o)*c,t[11]=-1,t[12]=0,t[13]=0,t[14]=a*o*2*c,t[15]=0,t},getRotation:_,getScaling:L,getTranslation:I,identity:w,invert:N,lookAt:W,mul:q,multiply:T,multiplyScalar:function(t,e,n){return t[0]=e[0]*n,t[1]=e[1]*n,t[2]=e[2]*n,t[3]=e[3]*n,t[4]=e[4]*n,t[5]=e[5]*n,t[6]=e[6]*n,t[7]=e[7]*n,t[8]=e[8]*n,t[9]=e[9]*n,t[10]=e[10]*n,t[11]=e[11]*n,t[12]=e[12]*n,t[13]=e[13]*n,t[14]=e[14]*n,t[15]=e[15]*n,t},multiplyScalarAndAdd:function(t,e,n,r){return t[0]=e[0]+n[0]*r,t[1]=e[1]+n[1]*r,t[2]=e[2]+n[2]*r,t[3]=e[3]+n[3]*r,t[4]=e[4]+n[4]*r,t[5]=e[5]+n[5]*r,t[6]=e[6]+n[6]*r,t[7]=e[7]+n[7]*r,t[8]=e[8]+n[8]*r,t[9]=e[9]+n[9]*r,t[10]=e[10]+n[10]*r,t[11]=e[11]+n[11]*r,t[12]=e[12]+n[12]*r,t[13]=e[13]+n[13]*r,t[14]=e[14]+n[14]*r,t[15]=e[15]+n[15]*r,t},ortho:V,orthoNO:j,orthoZO:U,perspective:G,perspectiveFromFieldOfView:function(t,e,n,r){var i=Math.tan(e.upDegrees*Math.PI/180),o=Math.tan(e.downDegrees*Math.PI/180),a=Math.tan(e.leftDegrees*Math.PI/180),s=Math.tan(e.rightDegrees*Math.PI/180),u=2/(a+s),c=2/(i+o);return t[0]=u,t[1]=0,t[2]=0,t[3]=0,t[4]=0,t[5]=c,t[6]=0,t[7]=0,t[8]=-(a-s)*u*.5,t[9]=(i-o)*c*.5,t[10]=r/(n-r),t[11]=-1,t[12]=0,t[13]=0,t[14]=r*n/(n-r),t[15]=0,t},perspectiveNO:B,perspectiveZO:function(t,e,n,r,i){var o,a=1/Math.tan(e/2);return t[0]=a/n,t[1]=0,t[2]=0,t[3]=0,t[4]=0,t[5]=a,t[6]=0,t[7]=0,t[8]=0,t[9]=0,t[11]=-1,t[12]=0,t[13]=0,t[15]=0,null!=i&&i!==1/0?(o=1/(r-i),t[10]=i*o,t[14]=i*r*o):(t[10]=-1,t[14]=-r),t},rotate:function(t,e,n,r){var i,o,a,s,u,c,h,l,d,f,p,m,v,y,E,x,b,w,M,N,S,T,P,C,k=r[0],A=r[1],O=r[2],R=Math.hypot(k,A,O);return R<g?null:(k*=R=1/R,A*=R,O*=R,i=Math.sin(n),a=1-(o=Math.cos(n)),s=e[0],u=e[1],c=e[2],h=e[3],l=e[4],d=e[5],f=e[6],p=e[7],m=e[8],v=e[9],y=e[10],E=e[11],x=k*k*a+o,b=A*k*a+O*i,w=O*k*a-A*i,M=k*A*a-O*i,N=A*A*a+o,S=O*A*a+k*i,T=k*O*a+A*i,P=A*O*a-k*i,C=O*O*a+o,t[0]=s*x+l*b+m*w,t[1]=u*x+d*b+v*w,t[2]=c*x+f*b+y*w,t[3]=h*x+p*b+E*w,t[4]=s*M+l*N+m*S,t[5]=u*M+d*N+v*S,t[6]=c*M+f*N+y*S,t[7]=h*M+p*N+E*S,t[8]=s*T+l*P+m*C,t[9]=u*T+d*P+v*C,t[10]=c*T+f*P+y*C,t[11]=h*T+p*P+E*C,e!==t&&(t[12]=e[12],t[13]=e[13],t[14]=e[14],t[15]=e[15]),t)},rotateX:k,rotateY:A,rotateZ:function(t,e,n){var r=Math.sin(n),i=Math.cos(n),o=e[0],a=e[1],s=e[2],u=e[3],c=e[4],h=e[5],l=e[6],d=e[7];return e!==t&&(t[8]=e[8],t[9]=e[9],t[10]=e[10],t[11]=e[11],t[12]=e[12],t[13]=e[13],t[14]=e[14],t[15]=e[15]),t[0]=o*i+c*r,t[1]=a*i+h*r,t[2]=s*i+l*r,t[3]=u*i+d*r,t[4]=c*i-o*r,t[5]=h*i-a*r,t[6]=l*i-s*r,t[7]=d*i-u*r,t},scale:C,set:b,str:function(t){return"mat4("+t[0]+", "+t[1]+", "+t[2]+", "+t[3]+", "+t[4]+", "+t[5]+", "+t[6]+", "+t[7]+", "+t[8]+", "+t[9]+", "+t[10]+", "+t[11]+", "+t[12]+", "+t[13]+", "+t[14]+", "+t[15]+")"},sub:Y,subtract:H,targetTo:function(t,e,n,r){var i=e[0],o=e[1],a=e[2],s=r[0],u=r[1],c=r[2],h=i-n[0],l=o-n[1],d=a-n[2],f=h*h+l*l+d*d;f>0&&(h*=f=1/Math.sqrt(f),l*=f,d*=f);var p=u*d-c*l,g=c*h-s*d,m=s*l-u*h;return(f=p*p+g*g+m*m)>0&&(p*=f=1/Math.sqrt(f),g*=f,m*=f),t[0]=p,t[1]=g,t[2]=m,t[3]=0,t[4]=l*m-d*g,t[5]=d*p-h*m,t[6]=h*g-l*p,t[7]=0,t[8]=h,t[9]=l,t[10]=d,t[11]=0,t[12]=i,t[13]=o,t[14]=a,t[15]=1,t},translate:P,transpose:M});function K(){var t=new m(3);return m!=Float32Array&&(t[0]=0,t[1]=0,t[2]=0),t}function $(t){var e=new m(3);return e[0]=t[0],e[1]=t[1],e[2]=t[2],e}function Z(t){var e=t[0],n=t[1],r=t[2];return Math.hypot(e,n,r)}function Q(t,e,n){var r=new m(3);return r[0]=t,r[1]=e,r[2]=n,r}function J(t,e){return t[0]=e[0],t[1]=e[1],t[2]=e[2],t}function tt(t,e,n,r){return t[0]=e,t[1]=n,t[2]=r,t}function et(t,e,n){return t[0]=e[0]+n[0],t[1]=e[1]+n[1],t[2]=e[2]+n[2],t}function nt(t,e,n){return t[0]=e[0]-n[0],t[1]=e[1]-n[1],t[2]=e[2]-n[2],t}function rt(t,e,n){return t[0]=e[0]*n,t[1]=e[1]*n,t[2]=e[2]*n,t}function it(t,e){var n=e[0],r=e[1],i=e[2],o=n*n+r*r+i*i;return o>0&&(o=1/Math.sqrt(o)),t[0]=e[0]*o,t[1]=e[1]*o,t[2]=e[2]*o,t}function ot(t,e){return t[0]*e[0]+t[1]*e[1]+t[2]*e[2]}function at(t,e,n){var r=e[0],i=e[1],o=e[2],a=n[0],s=n[1],u=n[2];return t[0]=i*u-o*s,t[1]=o*a-r*u,t[2]=r*s-i*a,t}function st(t,e,n,r){var i=e[0],o=e[1],a=e[2];return t[0]=i+r*(n[0]-i),t[1]=o+r*(n[1]-o),t[2]=a+r*(n[2]-a),t}function ut(t,e,n){var r=e[0],i=e[1],o=e[2],a=n[3]*r+n[7]*i+n[11]*o+n[15];return a=a||1,t[0]=(n[0]*r+n[4]*i+n[8]*o+n[12])/a,t[1]=(n[1]*r+n[5]*i+n[9]*o+n[13])/a,t[2]=(n[2]*r+n[6]*i+n[10]*o+n[14])/a,t}function ct(t,e){var n=t[0],r=t[1],i=t[2],o=e[0],a=e[1],s=e[2];return Math.abs(n-o)<=g*Math.max(1,Math.abs(n),Math.abs(o))&&Math.abs(r-a)<=g*Math.max(1,Math.abs(r),Math.abs(a))&&Math.abs(i-s)<=g*Math.max(1,Math.abs(i),Math.abs(s))}var ht=function(t,e){var n=e[0]-t[0],r=e[1]-t[1],i=e[2]-t[2];return Math.hypot(n,r,i)},lt=Z;function dt(){var t=new m(4);return m!=Float32Array&&(t[0]=0,t[1]=0,t[2]=0,t[3]=0),t}function ft(t,e,n){var r=e[0],i=e[1],o=e[2],a=e[3];return t[0]=n[0]*r+n[4]*i+n[8]*o+n[12]*a,t[1]=n[1]*r+n[5]*i+n[9]*o+n[13]*a,t[2]=n[2]*r+n[6]*i+n[10]*o+n[14]*a,t[3]=n[3]*r+n[7]*i+n[11]*o+n[15]*a,t}function pt(){var t=new m(4);return m!=Float32Array&&(t[0]=0,t[1]=0,t[2]=0),t[3]=1,t}function gt(t,e,n){n*=.5;var r=Math.sin(n);return t[0]=r*e[0],t[1]=r*e[1],t[2]=r*e[2],t[3]=Math.cos(n),t}function mt(t,e,n){var r=e[0],i=e[1],o=e[2],a=e[3],s=n[0],u=n[1],c=n[2],h=n[3];return t[0]=r*h+a*s+i*c-o*u,t[1]=i*h+a*u+o*s-r*c,t[2]=o*h+a*c+r*u-i*s,t[3]=a*h-r*s-i*u-o*c,t}function vt(t,e){var n=e[0],r=e[1],i=e[2],o=e[3],a=n*n+r*r+i*i+o*o,s=a?1/a:0;return t[0]=-n*s,t[1]=-r*s,t[2]=-i*s,t[3]=o*s,t}function yt(t,e,n,r){var i=.5*Math.PI/180;e*=i,n*=i,r*=i;var o=Math.sin(e),a=Math.cos(e),s=Math.sin(n),u=Math.cos(n),c=Math.sin(r),h=Math.cos(r);return t[0]=o*u*h-a*s*c,t[1]=a*s*h+o*u*c,t[2]=a*u*c-o*s*h,t[3]=a*u*h+o*s*c,t}K(),function(){var t=dt()}();var Et=function(t,e,n,r){var i=new m(4);return i[0]=t,i[1]=e,i[2]=n,i[3]=r,i},xt=function(t,e){return t[0]=e[0],t[1]=e[1],t[2]=e[2],t[3]=e[3],t},bt=mt,wt=function(t,e){var n=e[0],r=e[1],i=e[2],o=e[3],a=n*n+r*r+i*i+o*o;return a>0&&(a=1/Math.sqrt(a)),t[0]=n*a,t[1]=r*a,t[2]=i*a,t[3]=o*a,t};K(),Q(1,0,0),Q(0,1,0),pt(),pt(),v(),function(){var t,e=(t=new m(2),m!=Float32Array&&(t[0]=0,t[1]=0),t)}();var Mt=function(t){return null!==t&&"function"!=typeof t&&isFinite(t.length)},Nt=function(t,e){return!!Mt(t)&&t.indexOf(e)>-1},St=function(t,e){return void 0===e&&(e=[]),function(t,e){if(!Mt(t))return t;for(var n=[],r=0;r<t.length;r++){var i=t[r];e(i,r)&&n.push(i)}return n}(t,(function(t){return!Nt(e,t)}))},Tt=function(t){return"function"==typeof t},Pt=function(t){return null==t},Ct={}.toString,kt=function(t,e){return Ct.call(t)==="[object "+e+"]"},At=function(t){return Array.isArray?Array.isArray(t):kt(t,"Array")},Ot=function(t){var e=typeof t;return null!==t&&"object"===e||"function"===e};function Rt(t,e){if(t)if(At(t))for(var n=0,r=t.length;n<r&&!1!==e(t[n],n);n++);else if(Ot(t))for(var i in t)if(t.hasOwnProperty(i)&&!1===e(t[i],i))break}var Dt=function(t){return"object"==typeof t&&null!==t},It=function(t){if(!Dt(t)||!kt(t,"Object"))return!1;if(null===Object.getPrototypeOf(t))return!0;for(var e=t;null!==Object.getPrototypeOf(e);)e=Object.getPrototypeOf(e);return Object.getPrototypeOf(t)===e},Lt=function(t){if(At(t))return t.reduce((function(t,e){return Math.max(t,e)}),t[0])},_t=function(t){if(At(t))return t.reduce((function(t,e){return Math.min(t,e)}),t[0])},zt=function(t){return kt(t,"String")},Ft=Object.prototype.hasOwnProperty;function Bt(t,e){if(!e||!At(t))return{};for(var n,r={},i=Tt(e)?e:function(t){return t[e]},o=0;o<t.length;o++){var a=t[o];n=i(a),Ft.call(r,n)?r[n].push(a):r[n]=[a]}return r}var Gt=function(t,e,n){return t<e?e:t>n?n:t},jt=function(t){return kt(t,"Number")},Vt=1e-5;function Ut(t,e,n){return void 0===n&&(n=Vt),Math.abs(t-e)<n}var Wt=function(t,e){return(t%e+e)%e},Ht=function(t){return Pt(t)?"":t.toString()},qt=function(t){var e=Ht(t);return e.charAt(0).toLowerCase()+e.substring(1)},Yt={}.toString,Xt=function(t){return kt(t,"Boolean")},Kt=Object.prototype,$t=function(t){return void 0===t},Zt=function(t){if("object"!=typeof t||null===t)return t;var e;if(At(t)){e=[];for(var n=0,r=t.length;n<r;n++)"object"==typeof t[n]&&null!=t[n]?e[n]=Zt(t[n]):e[n]=t[n]}else for(var i in e={},t)"object"==typeof t[i]&&null!=t[i]?e[i]=Zt(t[i]):e[i]=t[i];return e};function Qt(t,e){if(Object.hasOwn)return Object.hasOwn(t,e);if(null==t)throw new TypeError("Cannot convert undefined or null to object");return Object.prototype.hasOwnProperty.call(Object(t),e)}function Jt(t,e,n,r){for(var i in n=n||0,r=r||5,e)if(Qt(e,i)){var o=e[i];null!==o&&It(o)?(It(t[i])||(t[i]={}),n<r?Jt(t[i],o,n+1,r):t[i]=e[i]):At(o)?(t[i]=[],t[i]=t[i].concat(o)):void 0!==o&&(t[i]=o)}}var te=function(t){for(var e=[],n=1;n<arguments.length;n++)e[n-1]=arguments[n];for(var r=0;r<e.length;r+=1)Jt(t,e[r]);return t},ee=Object.prototype.hasOwnProperty;function ne(t){if(Pt(t))return!0;if(Mt(t))return!t.length;var e=function(t){return Yt.call(t).replace(/^\[object /,"").replace(/]$/,"")}(t);if("Map"===e||"Set"===e)return!t.size;if(function(t){var e=t&&t.constructor;return t===("function"==typeof e&&e.prototype||Kt)}(t))return!Object.keys(t).length;for(var n in t)if(ee.call(t,n))return!1;return!0}var re=function(t,e){if(t===e)return!0;if(!t||!e)return!1;if(zt(t)||zt(e))return!1;if(Mt(t)||Mt(e)){if(t.length!==e.length)return!1;for(var n=!0,r=0;r<t.length&&(n=re(t[r],e[r]));r++);return n}if(Dt(t)||Dt(e)){var i=Object.keys(t),o=Object.keys(e);if(i.length!==o.length)return!1;for(n=!0,r=0;r<i.length&&(n=re(t[i[r]],e[i[r]]));r++);return n}return!1},ie=function(t,e,n){for(var r=0,i=zt(e)?e.split("."):e;t&&r<i.length;)t=t[i[r++]];return void 0===t||r<i.length?n:t},oe=function(t,e,n){var r=t,i=zt(e)?e.split("."):e;return i.forEach((function(t,e){e<i.length-1?(Ot(r[t])||(r[t]=jt(i[e+1])?[]:{}),r=r[t]):r[t]=n})),t},ae=Object.prototype.hasOwnProperty,se=function(t,e){return function(t,e,n){if(!At(t)&&!It(t))return t;var r=n;return Rt(t,(function(t,n){r=e(r,t,n)})),r}(t,(function(t,n,r){return e.includes(r)||(t[r]=n),t}),{})},ue={x1:0,y1:0,x2:0,y2:0,x:0,y:0,qx:null,qy:null};function ce(t,e,n){if(t[n].length>7){t[n].shift();for(var r=t[n],i=n;r.length;)e[n]="A",t.splice(i+=1,0,["C"].concat(r.splice(0,6)));t.splice(n,1)}}var he={a:7,c:6,h:1,l:2,m:2,r:4,q:4,s:4,t:2,v:1,z:0};function le(t){return Array.isArray(t)&&t.every((function(t){var e=t[0].toLowerCase();return he[e]===t.length-1&&"achlmqstvz".includes(e)}))}function de(t){return le(t)&&t.every((function(t){var e=t[0];return e===e.toUpperCase()}))}function fe(t){return de(t)&&t.every((function(t){var e=t[0];return"ACLMQZ".includes(e)}))}function pe(t){for(var e=t.pathValue[t.segmentStart],n=e.toLowerCase(),r=t.data;r.length>=he[n]&&("m"===n&&r.length>2?(t.segments.push([e].concat(r.splice(0,2))),n="l",e="m"===e?"l":"L"):t.segments.push([e].concat(r.splice(0,he[n]))),he[n]););}function ge(t){var e=t.index,n=t.pathValue,r=n.charCodeAt(e);return 48===r?(t.param=0,void(t.index+=1)):49===r?(t.param=1,void(t.index+=1)):void(t.err='[path-util]: invalid Arc flag "'+n[e]+'", expecting 0 or 1 at index '+e)}function me(t){return t>=48&&t<=57||43===t||45===t||46===t}function ve(t){return t>=48&&t<=57}function ye(t){var e,n=t.max,r=t.pathValue,i=t.index,o=i,a=!1,s=!1,u=!1,c=!1;if(o>=n)t.err="[path-util]: Invalid path value at index "+o+', "pathValue" is missing param';else if(43!==(e=r.charCodeAt(o))&&45!==e||(o+=1,e=r.charCodeAt(o)),ve(e)||46===e){if(46!==e){if(a=48===e,o+=1,e=r.charCodeAt(o),a&&o<n&&e&&ve(e))return void(t.err="[path-util]: Invalid path value at index "+i+', "'+r[i]+'" illegal number');for(;o<n&&ve(r.charCodeAt(o));)o+=1,s=!0;e=r.charCodeAt(o)}if(46===e){for(c=!0,o+=1;ve(r.charCodeAt(o));)o+=1,u=!0;e=r.charCodeAt(o)}if(101===e||69===e){if(c&&!s&&!u)return void(t.err="[path-util]: Invalid path value at index "+o+', "'+r[o]+'" invalid float exponent');if(o+=1,43!==(e=r.charCodeAt(o))&&45!==e||(o+=1),!(o<n&&ve(r.charCodeAt(o))))return void(t.err="[path-util]: Invalid path value at index "+o+', "'+r[o]+'" invalid integer exponent');for(;o<n&&ve(r.charCodeAt(o));)o+=1}t.index=o,t.param=+t.pathValue.slice(i,o)}else t.err="[path-util]: Invalid path value at index "+o+', "'+r[o]+'" is not a number'}function Ee(t){for(var e,n=t.pathValue,r=t.max;t.index<r&&(10===(e=n.charCodeAt(t.index))||13===e||8232===e||8233===e||32===e||9===e||11===e||12===e||160===e||e>=5760&&[5760,6158,8192,8193,8194,8195,8196,8197,8198,8199,8200,8201,8202,8239,8287,12288,65279].includes(e));)t.index+=1}function xe(t){var e=t.max,n=t.pathValue,r=t.index,i=n.charCodeAt(r),o=he[n[r].toLowerCase()];if(t.segmentStart=r,function(t){switch(32|t){case 109:case 122:case 108:case 104:case 118:case 99:case 115:case 113:case 116:case 97:return!0;default:return!1}}(i))if(t.index+=1,Ee(t),t.data=[],o){for(;;){for(var a=o;a>0;a-=1){if(97!=(32|i)||3!==a&&4!==a?ye(t):ge(t),t.err.length)return;t.data.push(t.param),Ee(t),t.index<e&&44===n.charCodeAt(t.index)&&(t.index+=1,Ee(t))}if(t.index>=t.max)break;if(!me(n.charCodeAt(t.index)))break}pe(t)}else pe(t);else t.err='[path-util]: Invalid path value "'+n[r]+'" is not a path command'}var be=function(t){this.pathValue=t,this.segments=[],this.max=t.length,this.index=0,this.param=0,this.segmentStart=0,this.data=[],this.err=""};function we(t){if(de(t))return[].concat(t);var e=function(t){if(le(t))return[].concat(t);var e=new be(t);for(Ee(e);e.index<e.max&&!e.err.length;)xe(e);return e.err?e.err:e.segments}(t),n=0,r=0,i=0,o=0;return e.map((function(t){var e,a=t.slice(1).map(Number),s=t[0],u=s.toUpperCase();if("M"===s)return n=a[0],r=a[1],i=n,o=r,["M",n,r];if(s!==u)switch(u){case"A":e=[u,a[0],a[1],a[2],a[3],a[4],a[5]+n,a[6]+r];break;case"V":e=[u,a[0]+r];break;case"H":e=[u,a[0]+n];break;default:var c=a.map((function(t,e){return t+(e%2?r:n)}));e=[u].concat(c)}else e=[u].concat(a);var h=e.length;switch(u){case"Z":n=i,r=o;break;case"H":n=e[1];break;case"V":r=e[1];break;default:n=e[h-2],r=e[h-1],"M"===u&&(i=n,o=r)}return e}))}function Me(t,e){var n=t[0],r=e.x1,i=e.y1,o=e.x2,a=e.y2,s=t.slice(1).map(Number),u=t;if("TQ".includes(n)||(e.qx=null,e.qy=null),"H"===n)u=["L",t[1],i];else if("V"===n)u=["L",r,t[1]];else if("S"===n){var c=2*r-o,h=2*i-a;e.x1=c,e.y1=h,u=["C",c,h].concat(s)}else if("T"===n){var l=2*r-e.qx,d=2*i-e.qy;e.qx=l,e.qy=d,u=["Q",l,d].concat(s)}else if("Q"===n){var f=s[0],p=s[1];e.qx=f,e.qy=p}return u}function Ne(t){if(fe(t))return[].concat(t);for(var e=we(t),n=i({},ue),r=0;r<e.length;r+=1){e[r]=Me(e[r],n);var o=e[r],a=o.length;n.x1=+o[a-2],n.y1=+o[a-1],n.x2=+o[a-4]||n.x1,n.y2=+o[a-3]||n.y1}return e}function Se(t,e,n){return{x:t*Math.cos(n)-e*Math.sin(n),y:t*Math.sin(n)+e*Math.cos(n)}}function Te(t,e,n,r,i,o,a,s,u,c){var h,l,d,f,p,g=t,m=e,v=n,y=r,E=s,x=u,b=120*Math.PI/180,w=Math.PI/180*(+i||0),M=[];if(c)l=c[0],d=c[1],f=c[2],p=c[3];else{g=(h=Se(g,m,-w)).x,m=h.y;var N=(g-(E=(h=Se(E,x,-w)).x))/2,S=(m-(x=h.y))/2,T=N*N/(v*v)+S*S/(y*y);T>1&&(v*=T=Math.sqrt(T),y*=T);var P=v*v,C=y*y,k=(o===a?-1:1)*Math.sqrt(Math.abs((P*C-P*S*S-C*N*N)/(P*S*S+C*N*N)));f=k*v*S/y+(g+E)/2,p=k*-y*N/v+(m+x)/2,l=Math.asin(((m-p)/y*Math.pow(10,9)|0)/Math.pow(10,9)),d=Math.asin(((x-p)/y*Math.pow(10,9)|0)/Math.pow(10,9)),l=g<f?Math.PI-l:l,d=E<f?Math.PI-d:d,l<0&&(l=2*Math.PI+l),d<0&&(d=2*Math.PI+d),a&&l>d&&(l-=2*Math.PI),!a&&d>l&&(d-=2*Math.PI)}var A=d-l;if(Math.abs(A)>b){var O=d,R=E,D=x;d=l+b*(a&&d>l?1:-1),M=Te(E=f+v*Math.cos(d),x=p+y*Math.sin(d),v,y,i,0,a,R,D,[d,O,f,p])}A=d-l;var I=Math.cos(l),L=Math.sin(l),_=Math.cos(d),z=Math.sin(d),F=Math.tan(A/4),B=4/3*v*F,G=4/3*y*F,j=[g,m],V=[g+B*L,m-G*I],U=[E+B*z,x-G*_],W=[E,x];if(V[0]=2*j[0]-V[0],V[1]=2*j[1]-V[1],c)return V.concat(U,W,M);for(var H=[],q=0,Y=(M=V.concat(U,W,M)).length;q<Y;q+=1)H[q]=q%2?Se(M[q-1],M[q],w).y:Se(M[q],M[q+1],w).x;return H}function Pe(t,e,n){var r=t[0],i=t[1];return[r+(e[0]-r)*n,i+(e[1]-i)*n]}var Ce=function(t,e,n,r){return h(h([],Pe([t,e],[n,r],.5),!0),[n,r,n,r],!1)};function ke(t,e){var n,r,i,o,a,s,u,c,h,l=t[0],d=t.slice(1).map(Number),f=d[0],p=d[1],g=e.x1,m=e.y1,v=e.x,y=e.y;switch("TQ".includes(l)||(e.qx=null,e.qy=null),l){case"M":return e.x=f,e.y=p,t;case"A":return n=[g,m].concat(d),["C"].concat(Te(n[0],n[1],n[2],n[3],n[4],n[5],n[6],n[7],n[8],n[9]));case"Q":return e.qx=f,e.qy=p,n=[g,m].concat(d),["C"].concat((r=n[0],i=n[1],o=n[2],a=n[3],s=n[4],u=n[5],[(c=1/3)*r+(h=2/3)*o,c*i+h*a,c*s+h*o,c*u+h*a,s,u]));case"L":return["C"].concat(Ce(g,m,f,p));case"Z":return g===v&&m===y?["C",g,m,v,y,v,y]:["C"].concat(Ce(g,m,v,y))}return t}function Ae(t,e){if(void 0===e&&(e=!1),function(t){return fe(t)&&t.every((function(t){var e=t[0];return"MC".includes(e)}))}(t)){var n=[].concat(t);return e?[n,[]]:n}for(var r,o,a=Ne(t),s=i({},ue),u=[],c="",h=a.length,l=[],d=0;d<h;d+=1){a[d]&&(c=a[d][0]),u[d]=c;var f=ke(a[d],s);a[d]=f,ce(a,u,d),h=a.length,"Z"===c&&l.push(d),o=(r=a[d]).length,s.x1=+r[o-2],s.y1=+r[o-1],s.x2=+r[o-4]||s.x1,s.y2=+r[o-3]||s.y1}return e?[a,l]:a}function Oe(t,e){return Math.sqrt((t[0]-e[0])*(t[0]-e[0])+(t[1]-e[1])*(t[1]-e[1]))}function Re(t,e,n,r,i){var o=Oe([t,e],[n,r]),a={x:0,y:0};if("number"==typeof i)if(i<=0)a={x:t,y:e};else if(i>=o)a={x:n,y:r};else{var s=Pe([t,e],[n,r],i/o);a={x:s[0],y:s[1]}}return{length:o,point:a,min:{x:Math.min(t,n),y:Math.min(e,r)},max:{x:Math.max(t,n),y:Math.max(e,r)}}}function De(t,e){var n=t.x,r=t.y,i=e.x,o=e.y,a=n*i+r*o,s=Math.sqrt((Math.pow(n,2)+Math.pow(r,2))*(Math.pow(i,2)+Math.pow(o,2)));return(n*o-r*i<0?-1:1)*Math.acos(a/s)}function Ie(t,e,n,r,i,o,a,s,u,c){var h=Math.abs,l=Math.sin,d=Math.cos,f=Math.sqrt,p=Math.PI,g=h(n),m=h(r),v=(i%360+360)%360*(p/180);if(t===s&&e===u)return{x:t,y:e};if(0===g||0===m)return Re(t,e,s,u,c).point;var y=(t-s)/2,E=(e-u)/2,x={x:d(v)*y+l(v)*E,y:-l(v)*y+d(v)*E},b=Math.pow(x.x,2)/Math.pow(g,2)+Math.pow(x.y,2)/Math.pow(m,2);b>1&&(g*=f(b),m*=f(b));var w=(Math.pow(g,2)*Math.pow(m,2)-Math.pow(g,2)*Math.pow(x.y,2)-Math.pow(m,2)*Math.pow(x.x,2))/(Math.pow(g,2)*Math.pow(x.y,2)+Math.pow(m,2)*Math.pow(x.x,2)),M=(o!==a?1:-1)*f(w=w<0?0:w),N=M*(g*x.y/m),S=M*(-m*x.x/g),T=d(v)*N-l(v)*S+(t+s)/2,P=l(v)*N+d(v)*S+(e+u)/2,C={x:(x.x-N)/g,y:(x.y-S)/m},k=De({x:1,y:0},C),A=De(C,{x:(-x.x-N)/g,y:(-x.y-S)/m});!a&&A>0?A-=2*p:a&&A<0&&(A+=2*p);var O=k+(A%=2*p)*c,R=g*d(O),D=m*l(O);return{x:d(v)*R-l(v)*D+T,y:l(v)*R+d(v)*D+P}}function Le(t,e,n,r,i,o,a,s,u,c,h){var l,d=h.bbox,f=void 0===d||d,p=h.length,g=void 0===p||p,m=h.sampleSize,v=void 0===m?30:m,y="number"==typeof c,E=t,x=e,b=0,w=[E,x,b],M=[E,x],N={x:0,y:0},S=[{x:E,y:x}];y&&c<=0&&(N={x:E,y:x});for(var T=0;T<=v;T+=1){if(E=(l=Ie(t,e,n,r,i,o,a,s,u,T/v)).x,x=l.y,f&&S.push({x:E,y:x}),g&&(b+=Oe(M,[E,x])),M=[E,x],y&&b>=c&&c>w[2]){var P=(b-c)/(b-w[2]);N={x:M[0]*(1-P)+w[0]*P,y:M[1]*(1-P)+w[1]*P}}w=[E,x,b]}return y&&c>=b&&(N={x:s,y:u}),{length:b,point:N,min:{x:Math.min.apply(null,S.map((function(t){return t.x}))),y:Math.min.apply(null,S.map((function(t){return t.y})))},max:{x:Math.max.apply(null,S.map((function(t){return t.x}))),y:Math.max.apply(null,S.map((function(t){return t.y})))}}}function _e(t,e,n,r,i,o,a,s,u){var c=1-u;return{x:Math.pow(c,3)*t+3*Math.pow(c,2)*u*n+3*c*Math.pow(u,2)*i+Math.pow(u,3)*a,y:Math.pow(c,3)*e+3*Math.pow(c,2)*u*r+3*c*Math.pow(u,2)*o+Math.pow(u,3)*s}}function ze(t,e,n,r,i,o,a,s,u,c){var h,l=c.bbox,d=void 0===l||l,f=c.length,p=void 0===f||f,g=c.sampleSize,m=void 0===g?10:g,v="number"==typeof u,y=t,E=e,x=0,b=[y,E,x],w=[y,E],M={x:0,y:0},N=[{x:y,y:E}];v&&u<=0&&(M={x:y,y:E});for(var S=0;S<=m;S+=1){if(y=(h=_e(t,e,n,r,i,o,a,s,S/m)).x,E=h.y,d&&N.push({x:y,y:E}),p&&(x+=Oe(w,[y,E])),w=[y,E],v&&x>=u&&u>b[2]){var T=(x-u)/(x-b[2]);M={x:w[0]*(1-T)+b[0]*T,y:w[1]*(1-T)+b[1]*T}}b=[y,E,x]}return v&&u>=x&&(M={x:a,y:s}),{length:x,point:M,min:{x:Math.min.apply(null,N.map((function(t){return t.x}))),y:Math.min.apply(null,N.map((function(t){return t.y})))},max:{x:Math.max.apply(null,N.map((function(t){return t.x}))),y:Math.max.apply(null,N.map((function(t){return t.y})))}}}function Fe(t,e,n,r,i,o,a){var s=1-a;return{x:Math.pow(s,2)*t+2*s*a*n+Math.pow(a,2)*i,y:Math.pow(s,2)*e+2*s*a*r+Math.pow(a,2)*o}}function Be(t,e,n,r,i,o,a,s){var u,c=s.bbox,h=void 0===c||c,l=s.length,d=void 0===l||l,f=s.sampleSize,p=void 0===f?10:f,g="number"==typeof a,m=t,v=e,y=0,E=[m,v,y],x=[m,v],b={x:0,y:0},w=[{x:m,y:v}];g&&a<=0&&(b={x:m,y:v});for(var M=0;M<=p;M+=1){if(m=(u=Fe(t,e,n,r,i,o,M/p)).x,v=u.y,h&&w.push({x:m,y:v}),d&&(y+=Oe(x,[m,v])),x=[m,v],g&&y>=a&&a>E[2]){var N=(y-a)/(y-E[2]);b={x:x[0]*(1-N)+E[0]*N,y:x[1]*(1-N)+E[1]*N}}E=[m,v,y]}return g&&a>=y&&(b={x:i,y:o}),{length:y,point:b,min:{x:Math.min.apply(null,w.map((function(t){return t.x}))),y:Math.min.apply(null,w.map((function(t){return t.y})))},max:{x:Math.max.apply(null,w.map((function(t){return t.x}))),y:Math.max.apply(null,w.map((function(t){return t.y})))}}}function Ge(t,e,n){for(var r,i,o,a,s,u,c,h,l,d=Ne(t),f="number"==typeof e,p=[],g=0,m=0,v=0,y=0,E=[],x=[],b=0,w={x:0,y:0},M=w,N=w,S=w,T=0,P=0,C=d.length;P<C;P+=1)p=(c="M"===(h=(l=d[P])[0]))?p:[g,m].concat(l.slice(1)),c?(M=w={x:v=l[1],y:y=l[2]},b=0,f&&e<.001&&(S=w)):"L"===h?(b=(r=Re(p[0],p[1],p[2],p[3],(e||0)-T)).length,w=r.min,M=r.max,N=r.point):"A"===h?(b=(i=Le(p[0],p[1],p[2],p[3],p[4],p[5],p[6],p[7],p[8],(e||0)-T,n||{})).length,w=i.min,M=i.max,N=i.point):"C"===h?(b=(o=ze(p[0],p[1],p[2],p[3],p[4],p[5],p[6],p[7],(e||0)-T,n||{})).length,w=o.min,M=o.max,N=o.point):"Q"===h?(b=(a=Be(p[0],p[1],p[2],p[3],p[4],p[5],(e||0)-T,n||{})).length,w=a.min,M=a.max,N=a.point):"Z"===h&&(b=(s=Re((p=[g,m,v,y])[0],p[1],p[2],p[3],(e||0)-T)).length,w=s.min,M=s.max,N=s.point),f&&T<e&&T+b>=e&&(S=N),x.push(M),E.push(w),T+=b,g=(u="Z"!==h?l.slice(-2):[v,y])[0],m=u[1];return f&&e>=T&&(S={x:g,y:m}),{length:T,point:S,min:{x:Math.min.apply(null,E.map((function(t){return t.x}))),y:Math.min.apply(null,E.map((function(t){return t.y})))},max:{x:Math.max.apply(null,x.map((function(t){return t.x}))),y:Math.max.apply(null,x.map((function(t){return t.y})))}}}function je(t,e){var n=t.length-1,r=[],i=0,o=function(t){var e=t.length,n=e-1;return t.map((function(r,i){return t.map((function(r,o){var a,s=i+o;return 0===o||t[s]&&"M"===t[s][0]?(a=t[s],["M"].concat(a.slice(-2))):(s>=e&&(s-=n),t[s])}))}))}(t);return o.forEach((function(o,a){t.slice(1).forEach((function(r,o){i+=Oe(t[(a+o)%n].slice(-2),e[o%n].slice(-2))})),r[a]=i,i=0})),o[r.indexOf(Math.min.apply(null,r))]}function Ve(t){return function(t){var e=0,n=0,r=0;return Ae(t).map((function(t){var i;if("M"===t[0])return e=t[1],n=t[2],0;var o=t.slice(1),a=o[0],s=o[1],u=o[2],c=o[3],h=o[4],l=o[5];return r=function(t,e,n,r,i,o,a,s){return 3*((s-e)*(n+i)-(a-t)*(r+o)+r*(t-i)-n*(e-o)+s*(i+t/3)-a*(o+e/3))/20}(e,n,a,s,u,c,h,l),i=t.slice(-2),e=i[0],n=i[1],r})).reduce((function(t,e){return t+e}),0)}(t)>=0}function Ue(t){return t.map((function(t,e,n){var r=e&&n[e-1].slice(-2).concat(t.slice(1)),i=e?ze(r[0],r[1],r[2],r[3],r[4],r[5],r[6],r[7],r[8],{bbox:!1}).length:0;return{s:t,ss:e?i?function(t,e){void 0===e&&(e=.5);var n=t.slice(0,2),r=t.slice(2,4),i=t.slice(4,6),o=t.slice(6,8),a=Pe(n,r,e),s=Pe(r,i,e),u=Pe(i,o,e),c=Pe(a,s,e),h=Pe(s,u,e),l=Pe(c,h,e);return[["C"].concat(a,c,l),["C"].concat(h,u,o)]}(r):[t,t]:[t],l:i}}))}function We(t,e,n){var r=Ue(t),i=Ue(e),o=r.length,a=i.length,s=r.filter((function(t){return t.l})).length,u=i.filter((function(t){return t.l})).length,c=r.filter((function(t){return t.l})).reduce((function(t,e){return t+e.l}),0)/s||0,h=i.filter((function(t){return t.l})).reduce((function(t,e){return t+e.l}),0)/u||0,l=n||Math.max(o,a),d=[c,h],f=[l-o,l-a],p=0,g=[r,i].map((function(t,e){return t.l===l?t.map((function(t){return t.s})):t.map((function(t,n){return p=n&&f[e]&&t.l>=d[e],f[e]-=p?1:0,p?t.ss:[t.s]})).flat()}));return g[0].length===g[1].length?g:We(g[0],g[1],l)}function He(t,e,n){t.prototype=e.prototype=n,n.constructor=t}function qe(t,e){var n=Object.create(t.prototype);for(var r in e)n[r]=e[r];return n}function Ye(){}var Xe=.7,Ke=1/Xe,$e="\\s*([+-]?\\d+)\\s*",Ze="\\s*([+-]?\\d*\\.?\\d+(?:[eE][+-]?\\d+)?)\\s*",Qe="\\s*([+-]?\\d*\\.?\\d+(?:[eE][+-]?\\d+)?)%\\s*",Je=/^#([0-9a-f]{3,8})$/,tn=new RegExp("^rgb\\("+[$e,$e,$e]+"\\)$"),en=new RegExp("^rgb\\("+[Qe,Qe,Qe]+"\\)$"),nn=new RegExp("^rgba\\("+[$e,$e,$e,Ze]+"\\)$"),rn=new RegExp("^rgba\\("+[Qe,Qe,Qe,Ze]+"\\)$"),on=new RegExp("^hsl\\("+[Ze,Qe,Qe]+"\\)$"),an=new RegExp("^hsla\\("+[Ze,Qe,Qe,Ze]+"\\)$"),sn={aliceblue:15792383,antiquewhite:16444375,aqua:65535,aquamarine:8388564,azure:15794175,beige:16119260,bisque:16770244,black:0,blanchedalmond:16772045,blue:255,blueviolet:9055202,brown:10824234,burlywood:14596231,cadetblue:6266528,chartreuse:8388352,chocolate:13789470,coral:16744272,cornflowerblue:6591981,cornsilk:16775388,crimson:14423100,cyan:65535,darkblue:139,darkcyan:35723,darkgoldenrod:12092939,darkgray:11119017,darkgreen:25600,darkgrey:11119017,darkkhaki:12433259,darkmagenta:9109643,darkolivegreen:5597999,darkorange:16747520,darkorchid:10040012,darkred:9109504,darksalmon:15308410,darkseagreen:9419919,darkslateblue:4734347,darkslategray:3100495,darkslategrey:3100495,darkturquoise:52945,darkviolet:9699539,deeppink:16716947,deepskyblue:49151,dimgray:6908265,dimgrey:6908265,dodgerblue:2003199,firebrick:11674146,floralwhite:16775920,forestgreen:2263842,fuchsia:16711935,gainsboro:14474460,ghostwhite:16316671,gold:16766720,goldenrod:14329120,gray:8421504,green:32768,greenyellow:11403055,grey:8421504,honeydew:15794160,hotpink:16738740,indianred:13458524,indigo:4915330,ivory:16777200,khaki:15787660,lavender:15132410,lavenderblush:16773365,lawngreen:8190976,lemonchiffon:16775885,lightblue:11393254,lightcoral:15761536,lightcyan:14745599,lightgoldenrodyellow:16448210,lightgray:13882323,lightgreen:9498256,lightgrey:13882323,lightpink:16758465,lightsalmon:16752762,lightseagreen:2142890,lightskyblue:8900346,lightslategray:7833753,lightslategrey:7833753,lightsteelblue:11584734,lightyellow:16777184,lime:65280,limegreen:3329330,linen:16445670,magenta:16711935,maroon:8388608,mediumaquamarine:6737322,mediumblue:205,mediumorchid:12211667,mediumpurple:9662683,mediumseagreen:3978097,mediumslateblue:8087790,mediumspringgreen:64154,mediumturquoise:4772300,mediumvioletred:13047173,midnightblue:1644912,mintcream:16121850,mistyrose:16770273,moccasin:16770229,navajowhite:16768685,navy:128,oldlace:16643558,olive:8421376,olivedrab:7048739,orange:16753920,orangered:16729344,orchid:14315734,palegoldenrod:15657130,palegreen:10025880,paleturquoise:11529966,palevioletred:14381203,papayawhip:16773077,peachpuff:16767673,peru:13468991,pink:16761035,plum:14524637,powderblue:11591910,purple:8388736,rebeccapurple:6697881,red:16711680,rosybrown:12357519,royalblue:4286945,saddlebrown:9127187,salmon:16416882,sandybrown:16032864,seagreen:3050327,seashell:16774638,sienna:10506797,silver:12632256,skyblue:8900331,slateblue:6970061,slategray:7372944,slategrey:7372944,snow:16775930,springgreen:65407,steelblue:4620980,tan:13808780,teal:32896,thistle:14204888,tomato:16737095,turquoise:4251856,violet:15631086,wheat:16113331,white:16777215,whitesmoke:16119285,yellow:16776960,yellowgreen:10145074};function un(){return this.rgb().formatHex()}function cn(){return this.rgb().formatRgb()}function hn(t){var e,n;return t=(t+"").trim().toLowerCase(),(e=Je.exec(t))?(n=e[1].length,e=parseInt(e[1],16),6===n?ln(e):3===n?new fn(e>>8&15|e>>4&240,e>>4&15|240&e,(15&e)<<4|15&e,1):8===n?dn(e>>24&255,e>>16&255,e>>8&255,(255&e)/255):4===n?dn(e>>12&15|e>>8&240,e>>8&15|e>>4&240,e>>4&15|240&e,((15&e)<<4|15&e)/255):null):(e=tn.exec(t))?new fn(e[1],e[2],e[3],1):(e=en.exec(t))?new fn(255*e[1]/100,255*e[2]/100,255*e[3]/100,1):(e=nn.exec(t))?dn(e[1],e[2],e[3],e[4]):(e=rn.exec(t))?dn(255*e[1]/100,255*e[2]/100,255*e[3]/100,e[4]):(e=on.exec(t))?vn(e[1],e[2]/100,e[3]/100,1):(e=an.exec(t))?vn(e[1],e[2]/100,e[3]/100,e[4]):sn.hasOwnProperty(t)?ln(sn[t]):"transparent"===t?new fn(NaN,NaN,NaN,0):null}function ln(t){return new fn(t>>16&255,t>>8&255,255&t,1)}function dn(t,e,n,r){return r<=0&&(t=e=n=NaN),new fn(t,e,n,r)}function fn(t,e,n,r){this.r=+t,this.g=+e,this.b=+n,this.opacity=+r}function pn(){return"#"+mn(this.r)+mn(this.g)+mn(this.b)}function gn(){var t=this.opacity;return(1===(t=isNaN(t)?1:Math.max(0,Math.min(1,t)))?"rgb(":"rgba(")+Math.max(0,Math.min(255,Math.round(this.r)||0))+", "+Math.max(0,Math.min(255,Math.round(this.g)||0))+", "+Math.max(0,Math.min(255,Math.round(this.b)||0))+(1===t?")":", "+t+")")}function mn(t){return((t=Math.max(0,Math.min(255,Math.round(t)||0)))<16?"0":"")+t.toString(16)}function vn(t,e,n,r){return r<=0?t=e=n=NaN:n<=0||n>=1?t=e=NaN:e<=0&&(t=NaN),new En(t,e,n,r)}function yn(t){if(t instanceof En)return new En(t.h,t.s,t.l,t.opacity);if(t instanceof Ye||(t=hn(t)),!t)return new En;if(t instanceof En)return t;var e=(t=t.rgb()).r/255,n=t.g/255,r=t.b/255,i=Math.min(e,n,r),o=Math.max(e,n,r),a=NaN,s=o-i,u=(o+i)/2;return s?(a=e===o?(n-r)/s+6*(n<r):n===o?(r-e)/s+2:(e-n)/s+4,s/=u<.5?o+i:2-o-i,a*=60):s=u>0&&u<1?0:a,new En(a,s,u,t.opacity)}function En(t,e,n,r){this.h=+t,this.s=+e,this.l=+n,this.opacity=+r}function xn(t,e,n){return 255*(t<60?e+(n-e)*t/60:t<180?n:t<240?e+(n-e)*(240-t)/60:e)}function bn(t,e,n,r){var i=t-n,o=e-r;return Math.sqrt(i*i+o*o)}function wn(t,e){var n=Math.min.apply(Math,h([],c(t),!1)),r=Math.min.apply(Math,h([],c(e),!1));return{x:n,y:r,width:Math.max.apply(Math,h([],c(t),!1))-n,height:Math.max.apply(Math,h([],c(e),!1))-r}}function Mn(t,e,n,r,i,o){return n*Math.cos(i)*Math.cos(o)-r*Math.sin(i)*Math.sin(o)+t}function Nn(t,e,n,r,i,o){return n*Math.sin(i)*Math.cos(o)+r*Math.cos(i)*Math.sin(o)+e}function Sn(t,e,n,r,i,o,a){for(var s=function(t,e,n){return Math.atan(-e/t*Math.tan(n))}(n,r,i),u=1/0,c=-1/0,h=[o,a],l=2*-Math.PI;l<=2*Math.PI;l+=Math.PI){var d=s+l;o<a?o<d&&d<a&&h.push(d):a<d&&d<o&&h.push(d)}for(l=0;l<h.length;l++){var f=Mn(t,0,n,r,i,h[l]);f<u&&(u=f),f>c&&(c=f)}var p=function(t,e,n){return Math.atan(e/(t*Math.tan(n)))}(n,r,i),g=1/0,m=-1/0,v=[o,a];for(l=2*-Math.PI;l<=2*Math.PI;l+=Math.PI){var y=p+l;o<a?o<y&&y<a&&v.push(y):a<y&&y<o&&v.push(y)}for(l=0;l<v.length;l++){var E=Nn(0,e,n,r,i,v[l]);E<g&&(g=E),E>m&&(m=E)}return{x:u,y:g,width:c-u,height:m-g}}He(Ye,hn,{copy:function(t){return Object.assign(new this.constructor,this,t)},displayable:function(){return this.rgb().displayable()},hex:un,formatHex:un,formatHsl:function(){return yn(this).formatHsl()},formatRgb:cn,toString:cn}),He(fn,(function(t,e,n,r){return 1===arguments.length?((i=t)instanceof Ye||(i=hn(i)),i?new fn((i=i.rgb()).r,i.g,i.b,i.opacity):new fn):new fn(t,e,n,null==r?1:r);var i}),qe(Ye,{brighter:function(t){return t=null==t?Ke:Math.pow(Ke,t),new fn(this.r*t,this.g*t,this.b*t,this.opacity)},darker:function(t){return t=null==t?Xe:Math.pow(Xe,t),new fn(this.r*t,this.g*t,this.b*t,this.opacity)},rgb:function(){return this},displayable:function(){return-.5<=this.r&&this.r<255.5&&-.5<=this.g&&this.g<255.5&&-.5<=this.b&&this.b<255.5&&0<=this.opacity&&this.opacity<=1},hex:pn,formatHex:pn,formatRgb:gn,toString:gn})),He(En,(function(t,e,n,r){return 1===arguments.length?yn(t):new En(t,e,n,null==r?1:r)}),qe(Ye,{brighter:function(t){return t=null==t?Ke:Math.pow(Ke,t),new En(this.h,this.s,this.l*t,this.opacity)},darker:function(t){return t=null==t?Xe:Math.pow(Xe,t),new En(this.h,this.s,this.l*t,this.opacity)},rgb:function(){var t=this.h%360+360*(this.h<0),e=isNaN(t)||isNaN(this.s)?0:this.s,n=this.l,r=n+(n<.5?n:1-n)*e,i=2*n-r;return new fn(xn(t>=240?t-240:t+120,i,r),xn(t,i,r),xn(t<120?t+240:t-120,i,r),this.opacity)},displayable:function(){return(0<=this.s&&this.s<=1||isNaN(this.s))&&0<=this.l&&this.l<=1&&0<=this.opacity&&this.opacity<=1},formatHsl:function(){var t=this.opacity;return(1===(t=isNaN(t)?1:Math.max(0,Math.min(1,t)))?"hsl(":"hsla(")+(this.h||0)+", "+100*(this.s||0)+"%, "+100*(this.l||0)+"%"+(1===t?")":", "+t+")")}}));var Tn=1e-4;function Pn(t,e,n,r,i,o){var a=-1,s=1/0,u=[n,r],l=20;o&&o>200&&(l=o/10);for(var d=1/l,f=d/10,p=0;p<=l;p++){var g=p*d,m=[i.apply(void 0,h([],c(t.concat([g])),!1)),i.apply(void 0,h([],c(e.concat([g])),!1))];(x=bn(u[0],u[1],m[0],m[1]))<s&&(a=g,s=x)}if(0===a)return{x:t[0],y:e[0]};if(1===a){var v=t.length;return{x:t[v-1],y:e[v-1]}}s=1/0;for(p=0;p<32&&!(f<Tn);p++){var y=a-f,E=a+f,x=(m=[i.apply(void 0,h([],c(t.concat([y])),!1)),i.apply(void 0,h([],c(e.concat([y])),!1))],bn(u[0],u[1],m[0],m[1]));if(y>=0&&x<s)a=y,s=x;else{var b=[i.apply(void 0,h([],c(t.concat([E])),!1)),i.apply(void 0,h([],c(e.concat([E])),!1))],w=bn(u[0],u[1],b[0],b[1]);E<=1&&w<s?(a=E,s=w):f*=.5}}return{x:i.apply(void 0,h([],c(t.concat([a])),!1)),y:i.apply(void 0,h([],c(e.concat([a])),!1))}}function Cn(t,e,n,r){return bn(t,e,n,r)}function kn(t,e,n,r,i){return{x:(1-i)*t+i*n,y:(1-i)*e+i*r}}function An(t,e,n,r,i,o){var a=[n-t,r-e];if(function(t,e){return t[0]===e[0]&&t[1]===e[1]}(a,[0,0]))return Math.sqrt((i-t)*(i-t)+(o-e)*(o-e));var s=[-a[1],a[0]];!function(t,e){var n=e[0],r=e[1],i=n*n+r*r;i>0&&(i=1/Math.sqrt(i)),t[0]=e[0]*i,t[1]=e[1]*i}(s,s);var u=[i-t,o-e];return Math.abs(function(t,e){return t[0]*e[0]+t[1]*e[1]}(u,s))}function On(t,e,n,r,i){var o=1-i;return o*o*o*t+3*e*i*o*o+3*n*i*i*o+r*i*i*i}function Rn(t,e,n,r){var i,o,a,s=-3*t+9*e-9*n+3*r,u=6*t-12*e+6*n,c=3*e-3*t,h=[];if(Ut(s,0))Ut(u,0)||(i=-c/u)>=0&&i<=1&&h.push(i);else{var l=u*u-4*s*c;Ut(l,0)?h.push(-u/(2*s)):l>0&&(o=(-u-(a=Math.sqrt(l)))/(2*s),(i=(-u+a)/(2*s))>=0&&i<=1&&h.push(i),o>=0&&o<=1&&h.push(o))}return h}function Dn(t,e,n,r,i,o,a,s){for(var u=[t,a],c=[e,s],h=Rn(t,n,i,a),l=Rn(e,r,o,s),d=0;d<h.length;d++)u.push(On(t,n,i,a,h[d]));for(d=0;d<l.length;d++)c.push(On(e,r,o,s,l[d]));return wn(u,c)}function In(t,e,n,r,i,o,a,s,u,c,h){var l=function(t,e,n,r,i,o,a,s,u,c,h){return Pn([t,n,i,a],[e,r,o,s],u,c,On,h)}(t,e,n,r,i,o,a,s,u,c,h);return bn(l.x,l.y,u,c)}function Ln(t){return function(t){if(t.length<2)return 0;for(var e=0,n=0;n<t.length-1;n++){var r=t[n],i=t[n+1];e+=bn(r[0],r[1],i[0],i[1])}return e}(t)}function _n(t,e,n,r){var i=1-r;return i*i*t+2*r*i*e+r*r*n}function zn(t,e,n){var r=t+n-2*e;if(Ut(r,0))return[.5];var i=(t-e)/r;return i<=1&&i>=0?[i]:[]}function Fn(t,e,n,r,i,o){var a=zn(t,n,i)[0],s=zn(e,r,o)[0],u=[t,i],c=[e,o];return void 0!==a&&u.push(_n(t,n,i,a)),void 0!==s&&c.push(_n(e,r,o,s)),wn(u,c)}function Bn(t,e,n,r,i,o,a,s){var u=function(t,e,n,r,i,o,a,s){return Pn([t,n,i],[e,r,o],a,s,_n)}(t,e,n,r,i,o,a,s);return bn(u.x,u.y,a,s)}"undefined"!=typeof globalThis?globalThis:"undefined"!=typeof window?window:"undefined"!=typeof global?global:"undefined"!=typeof self&&self;var Gn={exports:{}};!function(t,e){t.exports=function(){function t(t,n,i,o,a){e(t,n,i||0,o||t.length-1,a||r)}function e(t,r,i,o,a){for(;o>i;){if(o-i>600){var s=o-i+1,u=r-i+1,c=Math.log(s),h=.5*Math.exp(2*c/3),l=.5*Math.sqrt(c*h*(s-h)/s)*(u-s/2<0?-1:1);e(t,r,Math.max(i,Math.floor(r-u*h/s+l)),Math.min(o,Math.floor(r+(s-u)*h/s+l)),a)}var d=t[r],f=i,p=o;for(n(t,i,r),a(t[o],d)>0&&n(t,i,o);f<p;){for(n(t,f,p),f++,p--;a(t[f],d)<0;)f++;for(;a(t[p],d)>0;)p--}0===a(t[i],d)?n(t,i,p):n(t,++p,o),p<=r&&(i=p+1),r<=p&&(o=p-1)}}function n(t,e,n){var r=t[e];t[e]=t[n],t[n]=r}function r(t,e){return t<e?-1:t>e?1:0}var i=function(t){void 0===t&&(t=9),this._maxEntries=Math.max(4,t),this._minEntries=Math.max(2,Math.ceil(.4*this._maxEntries)),this.clear()};function o(t,e,n){if(!n)return e.indexOf(t);for(var r=0;r<e.length;r++)if(n(t,e[r]))return r;return-1}function a(t,e){s(t,0,t.children.length,e,t)}function s(t,e,n,r,i){i||(i=v(null)),i.minX=1/0,i.minY=1/0,i.maxX=-1/0,i.maxY=-1/0;for(var o=e;o<n;o++){var a=t.children[o];u(i,t.leaf?r(a):a)}return i}function u(t,e){return t.minX=Math.min(t.minX,e.minX),t.minY=Math.min(t.minY,e.minY),t.maxX=Math.max(t.maxX,e.maxX),t.maxY=Math.max(t.maxY,e.maxY),t}function c(t,e){return t.minX-e.minX}function h(t,e){return t.minY-e.minY}function l(t){return(t.maxX-t.minX)*(t.maxY-t.minY)}function d(t){return t.maxX-t.minX+(t.maxY-t.minY)}function f(t,e){return(Math.max(e.maxX,t.maxX)-Math.min(e.minX,t.minX))*(Math.max(e.maxY,t.maxY)-Math.min(e.minY,t.minY))}function p(t,e){var n=Math.max(t.minX,e.minX),r=Math.max(t.minY,e.minY),i=Math.min(t.maxX,e.maxX),o=Math.min(t.maxY,e.maxY);return Math.max(0,i-n)*Math.max(0,o-r)}function g(t,e){return t.minX<=e.minX&&t.minY<=e.minY&&e.maxX<=t.maxX&&e.maxY<=t.maxY}function m(t,e){return e.minX<=t.maxX&&e.minY<=t.maxY&&e.maxX>=t.minX&&e.maxY>=t.minY}function v(t){return{children:t,height:1,leaf:!0,minX:1/0,minY:1/0,maxX:-1/0,maxY:-1/0}}function y(e,n,r,i,o){for(var a=[n,r];a.length;)if(!((r=a.pop())-(n=a.pop())<=i)){var s=n+Math.ceil((r-n)/i/2)*i;t(e,s,n,r,o),a.push(n,s,s,r)}}return i.prototype.all=function(){return this._all(this.data,[])},i.prototype.search=function(t){var e=this.data,n=[];if(!m(t,e))return n;for(var r=this.toBBox,i=[];e;){for(var o=0;o<e.children.length;o++){var a=e.children[o],s=e.leaf?r(a):a;m(t,s)&&(e.leaf?n.push(a):g(t,s)?this._all(a,n):i.push(a))}e=i.pop()}return n},i.prototype.collides=function(t){var e=this.data;if(!m(t,e))return!1;for(var n=[];e;){for(var r=0;r<e.children.length;r++){var i=e.children[r],o=e.leaf?this.toBBox(i):i;if(m(t,o)){if(e.leaf||g(t,o))return!0;n.push(i)}}e=n.pop()}return!1},i.prototype.load=function(t){if(!t||!t.length)return this;if(t.length<this._minEntries){for(var e=0;e<t.length;e++)this.insert(t[e]);return this}var n=this._build(t.slice(),0,t.length-1,0);if(this.data.children.length)if(this.data.height===n.height)this._splitRoot(this.data,n);else{if(this.data.height<n.height){var r=this.data;this.data=n,n=r}this._insert(n,this.data.height-n.height-1,!0)}else this.data=n;return this},i.prototype.insert=function(t){return t&&this._insert(t,this.data.height-1),this},i.prototype.clear=function(){return this.data=v([]),this},i.prototype.remove=function(t,e){if(!t)return this;for(var n,r,i,a=this.data,s=this.toBBox(t),u=[],c=[];a||u.length;){if(a||(a=u.pop(),r=u[u.length-1],n=c.pop(),i=!0),a.leaf){var h=o(t,a.children,e);if(-1!==h)return a.children.splice(h,1),u.push(a),this._condense(u),this}i||a.leaf||!g(a,s)?r?(n++,a=r.children[n],i=!1):a=null:(u.push(a),c.push(n),n=0,r=a,a=a.children[0])}return this},i.prototype.toBBox=function(t){return t},i.prototype.compareMinX=function(t,e){return t.minX-e.minX},i.prototype.compareMinY=function(t,e){return t.minY-e.minY},i.prototype.toJSON=function(){return this.data},i.prototype.fromJSON=function(t){return this.data=t,this},i.prototype._all=function(t,e){for(var n=[];t;)t.leaf?e.push.apply(e,t.children):n.push.apply(n,t.children),t=n.pop();return e},i.prototype._build=function(t,e,n,r){var i,o=n-e+1,s=this._maxEntries;if(o<=s)return a(i=v(t.slice(e,n+1)),this.toBBox),i;r||(r=Math.ceil(Math.log(o)/Math.log(s)),s=Math.ceil(o/Math.pow(s,r-1))),(i=v([])).leaf=!1,i.height=r;var u=Math.ceil(o/s),c=u*Math.ceil(Math.sqrt(s));y(t,e,n,c,this.compareMinX);for(var h=e;h<=n;h+=c){var l=Math.min(h+c-1,n);y(t,h,l,u,this.compareMinY);for(var d=h;d<=l;d+=u){var f=Math.min(d+u-1,l);i.children.push(this._build(t,d,f,r-1))}}return a(i,this.toBBox),i},i.prototype._chooseSubtree=function(t,e,n,r){for(;r.push(e),!e.leaf&&r.length-1!==n;){for(var i=1/0,o=1/0,a=void 0,s=0;s<e.children.length;s++){var u=e.children[s],c=l(u),h=f(t,u)-c;h<o?(o=h,i=c<i?c:i,a=u):h===o&&c<i&&(i=c,a=u)}e=a||e.children[0]}return e},i.prototype._insert=function(t,e,n){var r=n?t:this.toBBox(t),i=[],o=this._chooseSubtree(r,this.data,e,i);for(o.children.push(t),u(o,r);e>=0&&i[e].children.length>this._maxEntries;)this._split(i,e),e--;this._adjustParentBBoxes(r,i,e)},i.prototype._split=function(t,e){var n=t[e],r=n.children.length,i=this._minEntries;this._chooseSplitAxis(n,i,r);var o=this._chooseSplitIndex(n,i,r),s=v(n.children.splice(o,n.children.length-o));s.height=n.height,s.leaf=n.leaf,a(n,this.toBBox),a(s,this.toBBox),e?t[e-1].children.push(s):this._splitRoot(n,s)},i.prototype._splitRoot=function(t,e){this.data=v([t,e]),this.data.height=t.height+1,this.data.leaf=!1,a(this.data,this.toBBox)},i.prototype._chooseSplitIndex=function(t,e,n){for(var r,i=1/0,o=1/0,a=e;a<=n-e;a++){var u=s(t,0,a,this.toBBox),c=s(t,a,n,this.toBBox),h=p(u,c),d=l(u)+l(c);h<i?(i=h,r=a,o=d<o?d:o):h===i&&d<o&&(o=d,r=a)}return r||n-e},i.prototype._chooseSplitAxis=function(t,e,n){var r=t.leaf?this.compareMinX:c,i=t.leaf?this.compareMinY:h;this._allDistMargin(t,e,n,r)<this._allDistMargin(t,e,n,i)&&t.children.sort(r)},i.prototype._allDistMargin=function(t,e,n,r){t.children.sort(r);for(var i=this.toBBox,o=s(t,0,e,i),a=s(t,n-e,n,i),c=d(o)+d(a),h=e;h<n-e;h++){var l=t.children[h];u(o,t.leaf?i(l):l),c+=d(o)}for(var f=n-e-1;f>=e;f--){var p=t.children[f];u(a,t.leaf?i(p):p),c+=d(a)}return c},i.prototype._adjustParentBBoxes=function(t,e,n){for(var r=n;r>=0;r--)u(e[r],t)},i.prototype._condense=function(t){for(var e=t.length-1,n=void 0;e>=0;e--)0===t[e].children.length?e>0?(n=t[e-1].children).splice(n.indexOf(t[e]),1):this.clear():a(t[e],this.toBBox)},i}()}(Gn);var jn,Vn,Un=Gn.exports;!function(t){t.GROUP="g",t.CIRCLE="circle",t.ELLIPSE="ellipse",t.IMAGE="image",t.RECT="rect",t.LINE="line",t.POLYLINE="polyline",t.POLYGON="polygon",t.TEXT="text",t.PATH="path",t.HTML="html",t.MESH="mesh"}(jn||(jn={})),function(t){t[t.ZERO=0]="ZERO",t[t.NEGATIVE_ONE=1]="NEGATIVE_ONE"}(Vn||(Vn={}));var Wn=function(){function t(){this.plugins=[]}return t.prototype.addRenderingPlugin=function(t){this.plugins.push(t),this.context.renderingPlugins.push(t)},t.prototype.removeAllRenderingPlugins=function(){var t=this;this.plugins.forEach((function(e){var n=t.context.renderingPlugins.indexOf(e);n>=0&&t.context.renderingPlugins.splice(n,1)}))},t}(),Hn=function(){function t(t){this.clipSpaceNearZ=Vn.NEGATIVE_ONE,this.plugins=[],this.config=i({enableDirtyCheck:!0,enableCulling:!1,enableAutoRendering:!0,enableDirtyRectangleRendering:!0,enableDirtyRectangleRenderingDebug:!1,enableSizeAttenuation:!0},t)}return t.prototype.registerPlugin=function(t){-1===this.plugins.findIndex((function(e){return e===t}))&&this.plugins.push(t)},t.prototype.unregisterPlugin=function(t){var e=this.plugins.findIndex((function(e){return e===t}));e>-1&&this.plugins.splice(e,1)},t.prototype.getPlugins=function(){return this.plugins},t.prototype.getPlugin=function(t){return this.plugins.find((function(e){return e.name===t}))},t.prototype.getConfig=function(){return this.config},t.prototype.setConfig=function(t){Object.assign(this.config,t)},t}();function qn(t,e){return t[0]=e[0],t[1]=e[1],t[2]=e[2],t}function Yn(t,e,n){return t[0]=e[0]-n[0],t[1]=e[1]-n[1],t[2]=e[2]-n[2],t}function Xn(t,e,n){return t[0]=e[0]+n[0],t[1]=e[1]+n[1],t[2]=e[2]+n[2],t}function Kn(t,e,n){return t[0]=e[0]*n,t[1]=e[1]*n,t[2]=e[2]*n,t}function $n(t){return void 0===t?0:t>360||t<-360?t%360:t}function Zn(t,e,n){return void 0===e&&(e=0),void 0===n&&(n=0),Array.isArray(t)&&3===t.length?$(t):jt(t)?Q(t,e,n):Q(t[0],t[1]||e,t[2]||n)}function Qn(t){return t*(Math.PI/180)}function Jn(t){return t*(180/Math.PI)}function tr(t,e){return 16===e.length?function(t,e){var n,r,i=.5*Math.PI,o=c(L(K(),e),3),a=o[0],s=o[1],u=o[2],h=Math.asin(-e[2]/a);return h<i?h>-i?(n=Math.atan2(e[6]/s,e[10]/u),r=Math.atan2(e[1]/a,e[0]/a)):(r=0,n=-Math.atan2(e[4]/s,e[5]/s)):(r=0,n=Math.atan2(e[4]/s,e[5]/s)),t[0]=n,t[1]=h,t[2]=r,t}(t,e):function(t,e){var n=e[0],r=e[1],i=e[2],o=e[3],a=r*r,s=i*i,u=o*o,c=n*n+a+s+u,h=n*o-r*i;return h>.499995*c?(t[0]=Math.PI/2,t[1]=2*Math.atan2(r,n),t[2]=0):h<-.499995*c?(t[0]=-Math.PI/2,t[1]=2*Math.atan2(r,n),t[2]=0):(t[0]=Math.asin(2*(n*i-o*r)),t[1]=Math.atan2(2*(n*o+r*i),1-2*(s+u)),t[2]=Math.atan2(2*(n*r+i*o),1-2*(a+s))),t}(t,e)}function er(t,e,n,r,i){var o,a,s,u,c,h,l,d,f,p,g=Math.cos(t),v=Math.sin(t);return o=r*g,a=i*v,s=0,u=-r*v,c=i*g,h=0,l=e,d=n,f=1,(p=new m(9))[0]=o,p[1]=a,p[2]=s,p[3]=u,p[4]=c,p[5]=h,p[6]=l,p[7]=d,p[8]=f,p}function nr(t){var e=t[0],n=t[1],r=t[3],i=t[4],o=Math.sqrt(e*e+n*n),a=Math.sqrt(r*r+i*i);e*i-n*r<0&&(e<i?o=-o:a=-a),o&&(e*=1/o,n*=1/o),a&&(r*=1/a,i*=1/a);var s=Jn(Math.atan2(n,e));return[t[6],t[7],o,a,s]}var rr=y(),ir=y(),or=dt(),ar=[K(),K(),K()],sr=K();function ur(t,e,n,r,i){t[0]=e[0]*r+n[0]*i,t[1]=e[1]*r+n[1]*i,t[2]=e[2]*r+n[2]*i}var cr,hr=function(){function t(){this.center=[0,0,0],this.halfExtents=[0,0,0],this.min=[0,0,0],this.max=[0,0,0]}return t.isEmpty=function(t){return!t||0===t.halfExtents[0]&&0===t.halfExtents[1]&&0===t.halfExtents[2]},t.prototype.update=function(t,e){qn(this.center,t),qn(this.halfExtents,e),Yn(this.min,this.center,this.halfExtents),Xn(this.max,this.center,this.halfExtents)},t.prototype.setMinMax=function(t,e){Xn(this.center,e,t),Kn(this.center,this.center,.5),Yn(this.halfExtents,e,t),Kn(this.halfExtents,this.halfExtents,.5),qn(this.min,t),qn(this.max,e)},t.prototype.getMin=function(){return this.min},t.prototype.getMax=function(){return this.max},t.prototype.add=function(e){if(!t.isEmpty(e))if(t.isEmpty(this))this.setMinMax(e.getMin(),e.getMax());else{var n=this.center,r=n[0],i=n[1],o=n[2],a=this.halfExtents,s=a[0],u=a[1],c=a[2],h=r-s,l=r+s,d=i-u,f=i+u,p=o-c,g=o+c,m=e.center,v=m[0],y=m[1],E=m[2],x=e.halfExtents,b=x[0],w=x[1],M=x[2],N=v-b,S=v+b,T=y-w,P=y+w,C=E-M,k=E+M;N<h&&(h=N),S>l&&(l=S),T<d&&(d=T),P>f&&(f=P),C<p&&(p=C),k>g&&(g=k),n[0]=.5*(h+l),n[1]=.5*(d+f),n[2]=.5*(p+g),a[0]=.5*(l-h),a[1]=.5*(f-d),a[2]=.5*(g-p),this.min[0]=h,this.min[1]=d,this.min[2]=p,this.max[0]=l,this.max[1]=f,this.max[2]=g}},t.prototype.setFromTransformedAABB=function(t,e){var n=this.center,r=this.halfExtents,i=t.center,o=t.halfExtents,a=e[0],s=e[4],u=e[8],c=e[1],h=e[5],l=e[9],d=e[2],f=e[6],p=e[10],g=Math.abs(a),m=Math.abs(s),v=Math.abs(u),y=Math.abs(c),E=Math.abs(h),x=Math.abs(l),b=Math.abs(d),w=Math.abs(f),M=Math.abs(p);n[0]=e[12]+a*i[0]+s*i[1]+u*i[2],n[1]=e[13]+c*i[0]+h*i[1]+l*i[2],n[2]=e[14]+d*i[0]+f*i[1]+p*i[2],r[0]=g*o[0]+m*o[1]+v*o[2],r[1]=y*o[0]+E*o[1]+x*o[2],r[2]=b*o[0]+w*o[1]+M*o[2],Yn(this.min,n,r),Xn(this.max,n,r)},t.prototype.intersects=function(t){var e=this.getMax(),n=this.getMin(),r=t.getMax(),i=t.getMin();return n[0]<=r[0]&&e[0]>=i[0]&&n[1]<=r[1]&&e[1]>=i[1]&&n[2]<=r[2]&&e[2]>=i[2]},t.prototype.intersection=function(e){if(!this.intersects(e))return null;var n=new t,r=function(t,e,n){return t[0]=Math.max(e[0],n[0]),t[1]=Math.max(e[1],n[1]),t[2]=Math.max(e[2],n[2]),t}([0,0,0],this.getMin(),e.getMin()),i=function(t,e,n){return t[0]=Math.min(e[0],n[0]),t[1]=Math.min(e[1],n[1]),t[2]=Math.min(e[2],n[2]),t}([0,0,0],this.getMax(),e.getMax());return n.setMinMax(r,i),n},t.prototype.getNegativeFarPoint=function(t){return 273===t.pnVertexFlag?qn([0,0,0],this.min):272===t.pnVertexFlag?[this.min[0],this.min[1],this.max[2]]:257===t.pnVertexFlag?[this.min[0],this.max[1],this.min[2]]:256===t.pnVertexFlag?[this.min[0],this.max[1],this.max[2]]:17===t.pnVertexFlag?[this.max[0],this.min[1],this.min[2]]:16===t.pnVertexFlag?[this.max[0],this.min[1],this.max[2]]:1===t.pnVertexFlag?[this.max[0],this.max[1],this.min[2]]:[this.max[0],this.max[1],this.max[2]]},t.prototype.getPositiveFarPoint=function(t){return 273===t.pnVertexFlag?qn([0,0,0],this.max):272===t.pnVertexFlag?[this.max[0],this.max[1],this.min[2]]:257===t.pnVertexFlag?[this.max[0],this.min[1],this.max[2]]:256===t.pnVertexFlag?[this.max[0],this.min[1],this.min[2]]:17===t.pnVertexFlag?[this.min[0],this.max[1],this.max[2]]:16===t.pnVertexFlag?[this.min[0],this.max[1],this.min[2]]:1===t.pnVertexFlag?[this.min[0],this.min[1],this.max[2]]:[this.min[0],this.min[1],this.min[2]]},t}(),lr=function(){function t(t,e){this.distance=t||0,this.normal=e||Q(0,1,0),this.updatePNVertexFlag()}return t.prototype.updatePNVertexFlag=function(){this.pnVertexFlag=(Number(this.normal[0]>=0)<<8)+(Number(this.normal[1]>=0)<<4)+Number(this.normal[2]>=0)},t.prototype.distanceToPoint=function(t){return ot(t,this.normal)-this.distance},t.prototype.normalize=function(){var t=1/lt(this.normal);rt(this.normal,this.normal,t),this.distance*=t},t.prototype.intersectsLine=function(t,e,n){var r=this.distanceToPoint(t),i=r/(r-this.distanceToPoint(e)),o=i>=0&&i<=1;return o&&n&&st(n,t,e,i),o},t}();!function(t){t[t.OUTSIDE=4294967295]="OUTSIDE",t[t.INSIDE=0]="INSIDE",t[t.INDETERMINATE=2147483647]="INDETERMINATE"}(cr||(cr={}));var dr,fr,pr,gr=function(){function t(t){if(this.planes=[],t)this.planes=t;else for(var e=0;e<6;e++)this.planes.push(new lr)}return t.prototype.extractFromVPMatrix=function(t){var e=c(t,16),n=e[0],r=e[1],i=e[2],o=e[3],a=e[4],s=e[5],u=e[6],h=e[7],l=e[8],d=e[9],f=e[10],p=e[11],g=e[12],m=e[13],v=e[14],y=e[15];tt(this.planes[0].normal,o-n,h-a,p-l),this.planes[0].distance=y-g,tt(this.planes[1].normal,o+n,h+a,p+l),this.planes[1].distance=y+g,tt(this.planes[2].normal,o+r,h+s,p+d),this.planes[2].distance=y+m,tt(this.planes[3].normal,o-r,h-s,p-d),this.planes[3].distance=y-m,tt(this.planes[4].normal,o-i,h-u,p-f),this.planes[4].distance=y-v,tt(this.planes[5].normal,o+i,h+u,p+f),this.planes[5].distance=y+v,this.planes.forEach((function(t){t.normalize(),t.updatePNVertexFlag()}))},t}(),mr=function(){function t(t,e){void 0===t&&(t=0),void 0===e&&(e=0),this.x=0,this.y=0,this.x=t,this.y=e}return t.prototype.clone=function(){return new t(this.x,this.y)},t.prototype.copyFrom=function(t){this.x=t.x,this.y=t.y},t}(),vr=function(){function t(t,e,n,r){this.x=t,this.y=e,this.width=n,this.height=r,this.left=t,this.right=t+n,this.top=e,this.bottom=e+r}return t.prototype.toJSON=function(){},t}(),yr="Method not implemented.",Er="Use document.documentElement instead.";!function(t){t[t.ORBITING=0]="ORBITING",t[t.EXPLORING=1]="EXPLORING",t[t.TRACKING=2]="TRACKING"}(dr||(dr={})),function(t){t[t.DEFAULT=0]="DEFAULT",t[t.ROTATIONAL=1]="ROTATIONAL",t[t.TRANSLATIONAL=2]="TRANSLATIONAL",t[t.CINEMATIC=3]="CINEMATIC"}(fr||(fr={})),function(t){t[t.ORTHOGRAPHIC=0]="ORTHOGRAPHIC",t[t.PERSPECTIVE=1]="PERSPECTIVE"}(pr||(pr={}));var xr,br,wr,Mr,Nr,Sr="updated",Tr=2e-4,Pr=function(){function t(){this.clipSpaceNearZ=Vn.NEGATIVE_ONE,this.eventEmitter=new p,this.matrix=y(),this.right=Q(1,0,0),this.up=Q(0,1,0),this.forward=Q(0,0,1),this.position=Q(0,0,1),this.focalPoint=Q(0,0,0),this.distanceVector=Q(0,0,-1),this.distance=1,this.azimuth=0,this.elevation=0,this.roll=0,this.relAzimuth=0,this.relElevation=0,this.relRoll=0,this.dollyingStep=0,this.maxDistance=1/0,this.minDistance=-1/0,this.zoom=1,this.rotateWorld=!1,this.fov=30,this.near=.1,this.far=1e3,this.aspect=1,this.projectionMatrix=y(),this.projectionMatrixInverse=y(),this.jitteredProjectionMatrix=void 0,this.enableUpdate=!0,this.type=dr.EXPLORING,this.trackingMode=fr.DEFAULT,this.projectionMode=pr.PERSPECTIVE,this.frustum=new gr,this.orthoMatrix=y()}return t.prototype.isOrtho=function(){return this.projectionMode===pr.ORTHOGRAPHIC},t.prototype.getProjectionMode=function(){return this.projectionMode},t.prototype.getPerspective=function(){return this.jitteredProjectionMatrix||this.projectionMatrix},t.prototype.getPerspectiveInverse=function(){return this.projectionMatrixInverse},t.prototype.getFrustum=function(){return this.frustum},t.prototype.getPosition=function(){return this.position},t.prototype.getFocalPoint=function(){return this.focalPoint},t.prototype.getDollyingStep=function(){return this.dollyingStep},t.prototype.getNear=function(){return this.near},t.prototype.getFar=function(){return this.far},t.prototype.getZoom=function(){return this.zoom},t.prototype.getOrthoMatrix=function(){return this.orthoMatrix},t.prototype.getView=function(){return this.view},t.prototype.setEnableUpdate=function(t){this.enableUpdate=t},t.prototype.setType=function(t,e){return this.type=t,this.type===dr.EXPLORING?this.setWorldRotation(!0):this.setWorldRotation(!1),this._getAngles(),this.type===dr.TRACKING&&void 0!==e&&this.setTrackingMode(e),this},t.prototype.setProjectionMode=function(t){return this.projectionMode=t,this},t.prototype.setTrackingMode=function(t){if(this.type!==dr.TRACKING)throw new Error("Impossible to set a tracking mode if the camera is not of tracking type");return this.trackingMode=t,this},t.prototype.setWorldRotation=function(t){return this.rotateWorld=t,this._getAngles(),this},t.prototype.getViewTransform=function(){return N(y(),this.matrix)},t.prototype.getWorldTransform=function(){return this.matrix},t.prototype.jitterProjectionMatrix=function(t,e){var n=O(y(),[t,e,0]);this.jitteredProjectionMatrix=T(y(),n,this.projectionMatrix)},t.prototype.clearJitterProjectionMatrix=function(){this.jitteredProjectionMatrix=void 0},t.prototype.setMatrix=function(t){return this.matrix=t,this._update(),this},t.prototype.setFov=function(t){return this.setPerspective(this.near,this.far,t,this.aspect),this},t.prototype.setAspect=function(t){return this.setPerspective(this.near,this.far,this.fov,t),this},t.prototype.setNear=function(t){return this.projectionMode===pr.PERSPECTIVE?this.setPerspective(t,this.far,this.fov,this.aspect):this.setOrthographic(this.left,this.rright,this.top,this.bottom,t,this.far),this},t.prototype.setFar=function(t){return this.projectionMode===pr.PERSPECTIVE?this.setPerspective(this.near,t,this.fov,this.aspect):this.setOrthographic(this.left,this.rright,this.top,this.bottom,this.near,t),this},t.prototype.setViewOffset=function(t,e,n,r,i,o){return this.aspect=t/e,void 0===this.view&&(this.view={enabled:!0,fullWidth:1,fullHeight:1,offsetX:0,offsetY:0,width:1,height:1}),this.view.enabled=!0,this.view.fullWidth=t,this.view.fullHeight=e,this.view.offsetX=n,this.view.offsetY=r,this.view.width=i,this.view.height=o,this.projectionMode===pr.PERSPECTIVE?this.setPerspective(this.near,this.far,this.fov,this.aspect):this.setOrthographic(this.left,this.rright,this.top,this.bottom,this.near,this.far),this},t.prototype.clearViewOffset=function(){return void 0!==this.view&&(this.view.enabled=!1),this.projectionMode===pr.PERSPECTIVE?this.setPerspective(this.near,this.far,this.fov,this.aspect):this.setOrthographic(this.left,this.rright,this.top,this.bottom,this.near,this.far),this},t.prototype.setZoom=function(t){return this.zoom=t,this.projectionMode===pr.ORTHOGRAPHIC?this.setOrthographic(this.left,this.rright,this.top,this.bottom,this.near,this.far):this.projectionMode===pr.PERSPECTIVE&&this.setPerspective(this.near,this.far,this.fov,this.aspect),this},t.prototype.setZoomByViewportPoint=function(t,e){var n=this.canvas.viewport2Canvas({x:e[0],y:e[1]}),r=n.x,i=n.y,o=this.roll;this.rotate(0,0,-o),this.setPosition(r,i),this.setFocalPoint(r,i),this.setZoom(t),this.rotate(0,0,o);var a=this.canvas.viewport2Canvas({x:e[0],y:e[1]}),s=Q(a.x-r,a.y-i,0),u=ot(s,this.right)/Z(this.right),c=ot(s,this.up)/Z(this.up);return this.pan(-u,-c),this},t.prototype.setPerspective=function(t,e,n,r){var i;this.projectionMode=pr.PERSPECTIVE,this.fov=n,this.near=t,this.far=e,this.aspect=r;var o=this.near*Math.tan(Qn(.5*this.fov))/this.zoom,a=2*o,s=this.aspect*a,u=-.5*s;if(null===(i=this.view)||void 0===i?void 0:i.enabled){var c=this.view.fullWidth,h=this.view.fullHeight;u+=this.view.offsetX*s/c,o-=this.view.offsetY*a/h,s*=this.view.width/c,a*=this.view.height/h}return function(t,e,n,r,i,o,a,s){void 0===s&&(s=!1);var u,c,h=2*o/(n-e),l=2*o/(r-i),d=(n+e)/(n-e),f=(r+i)/(r-i);s?(u=-a/(a-o),c=-a*o/(a-o)):(u=-(a+o)/(a-o),c=-2*a*o/(a-o)),t[0]=h,t[1]=0,t[2]=0,t[3]=0,t[4]=0,t[5]=l,t[6]=0,t[7]=0,t[8]=d,t[9]=f,t[10]=u,t[11]=-1,t[12]=0,t[13]=0,t[14]=c,t[15]=0}(this.projectionMatrix,u,u+s,o,o-a,t,this.far,this.clipSpaceNearZ===Vn.ZERO),C(this.projectionMatrix,this.projectionMatrix,Q(1,-1,1)),N(this.projectionMatrixInverse,this.projectionMatrix),this.triggerUpdate(),this},t.prototype.setOrthographic=function(t,e,n,r,i,o){var a;this.projectionMode=pr.ORTHOGRAPHIC,this.rright=e,this.left=t,this.top=n,this.bottom=r,this.near=i,this.far=o;var s=(this.rright-this.left)/(2*this.zoom),u=(this.top-this.bottom)/(2*this.zoom),c=(this.rright+this.left)/2,h=(this.top+this.bottom)/2,l=c-s,d=c+s,f=h+u,p=h-u;if(null===(a=this.view)||void 0===a?void 0:a.enabled){var g=(this.rright-this.left)/this.view.fullWidth/this.zoom,m=(this.top-this.bottom)/this.view.fullHeight/this.zoom;d=(l+=g*this.view.offsetX)+g*this.view.width,p=(f-=m*this.view.offsetY)-m*this.view.height}return this.clipSpaceNearZ===Vn.NEGATIVE_ONE?V(this.projectionMatrix,l,d,p,f,i,o):U(this.projectionMatrix,l,d,p,f,i,o),C(this.projectionMatrix,this.projectionMatrix,Q(1,-1,1)),N(this.projectionMatrixInverse,this.projectionMatrix),this._getOrthoMatrix(),this.triggerUpdate(),this},t.prototype.setPosition=function(t,e,n){void 0===e&&(e=this.position[1]),void 0===n&&(n=this.position[2]);var r=Zn(t,e,n);return this._setPosition(r),this.setFocalPoint(this.focalPoint),this.triggerUpdate(),this},t.prototype.setFocalPoint=function(t,e,n){void 0===e&&(e=this.focalPoint[1]),void 0===n&&(n=this.focalPoint[2]);var r=Q(0,1,0);if(this.focalPoint=Zn(t,e,n),this.trackingMode===fr.CINEMATIC){var i=nt(K(),this.focalPoint,this.position);t=i[0],e=i[1],n=i[2];var o=Z(i),a=Jn(Math.asin(e/o)),s=90+Jn(Math.atan2(n,t)),u=y();A(u,u,Qn(s)),k(u,u,Qn(a)),r=ut(K(),[0,1,0],u)}return N(this.matrix,W(y(),this.position,this.focalPoint,r)),this._getAxes(),this._getDistance(),this._getAngles(),this.triggerUpdate(),this},t.prototype.getDistance=function(){return this.distance},t.prototype.getDistanceVector=function(){return this.distanceVector},t.prototype.setDistance=function(t){if(this.distance===t||t<0)return this;this.distance=t,this.distance<Tr&&(this.distance=Tr),this.dollyingStep=this.distance/100;var e=K();t=this.distance;var n=this.forward,r=this.focalPoint;return e[0]=t*n[0]+r[0],e[1]=t*n[1]+r[1],e[2]=t*n[2]+r[2],this._setPosition(e),this.triggerUpdate(),this},t.prototype.setMaxDistance=function(t){return this.maxDistance=t,this},t.prototype.setMinDistance=function(t){return this.minDistance=t,this},t.prototype.setAzimuth=function(t){return this.azimuth=$n(t),this.computeMatrix(),this._getAxes(),this.type===dr.ORBITING||this.type===dr.EXPLORING?this._getPosition():this.type===dr.TRACKING&&this._getFocalPoint(),this.triggerUpdate(),this},t.prototype.getAzimuth=function(){return this.azimuth},t.prototype.setElevation=function(t){return this.elevation=$n(t),this.computeMatrix(),this._getAxes(),this.type===dr.ORBITING||this.type===dr.EXPLORING?this._getPosition():this.type===dr.TRACKING&&this._getFocalPoint(),this.triggerUpdate(),this},t.prototype.getElevation=function(){return this.elevation},t.prototype.setRoll=function(t){return this.roll=$n(t),this.computeMatrix(),this._getAxes(),this.type===dr.ORBITING||this.type===dr.EXPLORING?this._getPosition():this.type===dr.TRACKING&&this._getFocalPoint(),this.triggerUpdate(),this},t.prototype.getRoll=function(){return this.roll},t.prototype._update=function(){this._getAxes(),this._getPosition(),this._getDistance(),this._getAngles(),this._getOrthoMatrix(),this.triggerUpdate()},t.prototype.computeMatrix=function(){var t=gt(pt(),[0,0,1],Qn(this.roll));w(this.matrix);var e=gt(pt(),[1,0,0],Qn((this.rotateWorld&&this.type!==dr.TRACKING||this.type===dr.TRACKING?1:-1)*this.elevation)),n=gt(pt(),[0,1,0],Qn((this.rotateWorld&&this.type!==dr.TRACKING||this.type===dr.TRACKING?1:-1)*this.azimuth)),r=mt(pt(),n,e);r=mt(pt(),r,t);var i=F(y(),r);this.type===dr.ORBITING||this.type===dr.EXPLORING?(P(this.matrix,this.matrix,this.focalPoint),T(this.matrix,this.matrix,i),P(this.matrix,this.matrix,[0,0,this.distance])):this.type===dr.TRACKING&&(P(this.matrix,this.matrix,this.position),T(this.matrix,this.matrix,i))},t.prototype._setPosition=function(t,e,n){this.position=Zn(t,e,n);var r=this.matrix;r[12]=this.position[0],r[13]=this.position[1],r[14]=this.position[2],r[15]=1,this._getOrthoMatrix()},t.prototype._getAxes=function(){J(this.right,Zn(ft(dt(),[1,0,0,0],this.matrix))),J(this.up,Zn(ft(dt(),[0,1,0,0],this.matrix))),J(this.forward,Zn(ft(dt(),[0,0,1,0],this.matrix))),it(this.right,this.right),it(this.up,this.up),it(this.forward,this.forward)},t.prototype._getAngles=function(){var t=this.distanceVector[0],e=this.distanceVector[1],n=this.distanceVector[2],r=Z(this.distanceVector);if(0===r)return this.elevation=0,void(this.azimuth=0);this.type===dr.TRACKING||this.rotateWorld?(this.elevation=Jn(Math.asin(e/r)),this.azimuth=Jn(Math.atan2(-t,-n))):(this.elevation=-Jn(Math.asin(e/r)),this.azimuth=-Jn(Math.atan2(-t,-n)))},t.prototype._getPosition=function(){J(this.position,Zn(ft(dt(),[0,0,0,1],this.matrix))),this._getDistance()},t.prototype._getFocalPoint=function(){!function(t,e,n){var r=e[0],i=e[1],o=e[2];t[0]=r*n[0]+i*n[3]+o*n[6],t[1]=r*n[1]+i*n[4]+o*n[7],t[2]=r*n[2]+i*n[5]+o*n[8]}(this.distanceVector,[0,0,-this.distance],function(t,e){return t[0]=e[0],t[1]=e[1],t[2]=e[2],t[3]=e[4],t[4]=e[5],t[5]=e[6],t[6]=e[8],t[7]=e[9],t[8]=e[10],t}(v(),this.matrix)),et(this.focalPoint,this.position,this.distanceVector),this._getDistance()},t.prototype._getDistance=function(){this.distanceVector=nt(K(),this.focalPoint,this.position),this.distance=Z(this.distanceVector),this.dollyingStep=this.distance/100},t.prototype._getOrthoMatrix=function(){if(this.projectionMode===pr.ORTHOGRAPHIC){var t=this.position,e=gt(pt(),[0,0,1],-this.roll*Math.PI/180);z(this.orthoMatrix,e,Q((this.rright-this.left)/2-t[0],(this.top-this.bottom)/2-t[1],0),Q(this.zoom,this.zoom,1),t)}},t.prototype.triggerUpdate=function(){if(this.enableUpdate){var t=this.getViewTransform(),e=T(y(),this.getPerspective(),t);this.getFrustum().extractFromVPMatrix(e),this.eventEmitter.emit(Sr)}},t.prototype.rotate=function(t,e,n){throw new Error(yr)},t.prototype.pan=function(t,e){throw new Error(yr)},t.prototype.dolly=function(t){throw new Error(yr)},t.prototype.createLandmark=function(t,e){throw new Error(yr)},t.prototype.gotoLandmark=function(t,e){throw new Error(yr)},t.prototype.cancelLandmarkAnimation=function(){throw new Error(yr)},t}();function Cr(t,e){if("function"!=typeof t||null!=e&&"function"!=typeof e)throw new TypeError("Expected a function");var n=function(){for(var r=[],i=0;i<arguments.length;i++)r[i]=arguments[i];var o=e?e.apply(this,r):r[0],a=n.cache;if(a.has(o))return a.get(o);var s=t.apply(this,r);return n.cache=a.set(o,s)||a,s};return n.cache=new(Cr.Cache||Map),n}Cr.Cache=Map,function(t){t[t.kUnknown=0]="kUnknown",t[t.kNumber=1]="kNumber",t[t.kPercentage=2]="kPercentage",t[t.kEms=3]="kEms",t[t.kPixels=4]="kPixels",t[t.kRems=5]="kRems",t[t.kDegrees=6]="kDegrees",t[t.kRadians=7]="kRadians",t[t.kGradians=8]="kGradians",t[t.kTurns=9]="kTurns",t[t.kMilliseconds=10]="kMilliseconds",t[t.kSeconds=11]="kSeconds",t[t.kInteger=12]="kInteger"}(xr||(xr={})),function(t){t[t.kUNumber=0]="kUNumber",t[t.kUPercent=1]="kUPercent",t[t.kULength=2]="kULength",t[t.kUAngle=3]="kUAngle",t[t.kUTime=4]="kUTime",t[t.kUOther=5]="kUOther"}(br||(br={})),function(t){t[t.kAll=0]="kAll",t[t.kNonNegative=1]="kNonNegative",t[t.kInteger=2]="kInteger",t[t.kNonNegativeInteger=3]="kNonNegativeInteger",t[t.kPositiveInteger=4]="kPositiveInteger"}(wr||(wr={})),function(t){t[t.kYes=0]="kYes",t[t.kNo=1]="kNo"}(Mr||(Mr={})),function(t){t[t.kYes=0]="kYes",t[t.kNo=1]="kNo"}(Nr||(Nr={}));var kr,Ar=[{name:"em",unit_type:xr.kEms},{name:"px",unit_type:xr.kPixels},{name:"deg",unit_type:xr.kDegrees},{name:"rad",unit_type:xr.kRadians},{name:"grad",unit_type:xr.kGradians},{name:"ms",unit_type:xr.kMilliseconds},{name:"s",unit_type:xr.kSeconds},{name:"rem",unit_type:xr.kRems},{name:"turn",unit_type:xr.kTurns}];!function(t){t[t.kUnknownType=0]="kUnknownType",t[t.kUnparsedType=1]="kUnparsedType",t[t.kKeywordType=2]="kKeywordType",t[t.kUnitType=3]="kUnitType",t[t.kSumType=4]="kSumType",t[t.kProductType=5]="kProductType",t[t.kNegateType=6]="kNegateType",t[t.kInvertType=7]="kInvertType",t[t.kMinType=8]="kMinType",t[t.kMaxType=9]="kMaxType",t[t.kClampType=10]="kClampType",t[t.kTransformType=11]="kTransformType",t[t.kPositionType=12]="kPositionType",t[t.kURLImageType=13]="kURLImageType",t[t.kColorType=14]="kColorType",t[t.kUnsupportedColorType=15]="kUnsupportedColorType"}(kr||(kr={}));var Or,Rr=function(t){return t?"number"===t?xr.kNumber:"percent"===t||"%"===t?xr.kPercentage:function(t){return Ar.find((function(e){return e.name===t})).unit_type}(t):xr.kUnknown},Dr=function(t){var e=1;switch(t){case xr.kPixels:case xr.kDegrees:case xr.kSeconds:break;case xr.kMilliseconds:e=.001;break;case xr.kRadians:e=180/Math.PI;break;case xr.kGradians:e=.9;break;case xr.kTurns:e=360}return e},Ir=function(t){switch(t){case xr.kNumber:case xr.kInteger:return"";case xr.kPercentage:return"%";case xr.kEms:return"em";case xr.kRems:return"rem";case xr.kPixels:return"px";case xr.kDegrees:return"deg";case xr.kRadians:return"rad";case xr.kGradians:return"grad";case xr.kMilliseconds:return"ms";case xr.kSeconds:return"s";case xr.kTurns:return"turn"}return""},Lr=function(){function t(){}return t.isAngle=function(t){return t===xr.kDegrees||t===xr.kRadians||t===xr.kGradians||t===xr.kTurns},t.isLength=function(t){return t>=xr.kEms&&t<xr.kDegrees},t.isRelativeUnit=function(t){return t===xr.kPercentage||t===xr.kEms||t===xr.kRems},t.isTime=function(t){return t===xr.kSeconds||t===xr.kMilliseconds},t.prototype.toString=function(){return this.buildCSSText(Mr.kNo,Nr.kNo,"")},t.prototype.isNumericValue=function(){return this.getType()>=kr.kUnitType&&this.getType()<=kr.kClampType},t}(),_r=function(t){function e(e){var n=t.call(this)||this;return n.colorSpace=e,n}return r(e,t),e.prototype.getType=function(){return kr.kColorType},e.prototype.to=function(t){return this},e}(Lr);!function(t){t[t.Constant=0]="Constant",t[t.LinearGradient=1]="LinearGradient",t[t.RadialGradient=2]="RadialGradient"}(Or||(Or={}));var zr=function(t){function e(e,n){var r=t.call(this)||this;return r.type=e,r.value=n,r}return r(e,t),e.prototype.clone=function(){return new e(this.type,this.value)},e.prototype.buildCSSText=function(t,e,n){return n},e.prototype.getType=function(){return kr.kColorType},e}(Lr),Fr=function(t){function e(e){var n=t.call(this)||this;return n.value=e,n}return r(e,t),e.prototype.clone=function(){return new e(this.value)},e.prototype.getType=function(){return kr.kKeywordType},e.prototype.buildCSSText=function(t,e,n){return n+this.value},e}(Lr),Br=Cr((function(t){return void 0===t&&(t=""),t.replace(/-([a-z])/g,(function(t){return t[1].toUpperCase()}))})),Gr=function(t){return t.split("").map((function(t,e){return t.toUpperCase()===t?"".concat(0!==e?"-":"").concat(t.toLowerCase()):t})).join("")};function jr(t){return"function"==typeof t}var Vr={d:{alias:"path"},strokeDasharray:{alias:"lineDash"},strokeWidth:{alias:"lineWidth"},textAnchor:{alias:"textAlign"},src:{alias:"img"}},Ur=Cr((function(t){var e=Br(t),n=Vr[e];return e=(null==n?void 0:n.alias)||e})),Wr=function(t,e){void 0===e&&(e="");var n="";return Number.isFinite(t)?(!function(t){if(!t)throw new Error}(Number.isNaN(t)),n="NaN"):n=t>0?"infinity":"-infinity",n+e},Hr=function(t){return function(t){switch(t){case br.kUNumber:return xr.kNumber;case br.kULength:return xr.kPixels;case br.kUPercent:return xr.kPercentage;case br.kUTime:return xr.kSeconds;case br.kUAngle:return xr.kDegrees;default:return xr.kUnknown}}(function(t){switch(t){case xr.kNumber:case xr.kInteger:return br.kUNumber;case xr.kPercentage:return br.kUPercent;case xr.kPixels:return br.kULength;case xr.kMilliseconds:case xr.kSeconds:return br.kUTime;case xr.kDegrees:case xr.kRadians:case xr.kGradians:case xr.kTurns:return br.kUAngle;default:return br.kUOther}}(t))},qr=function(t){function e(e,n){void 0===n&&(n=xr.kNumber);var r,i=t.call(this)||this;return r="string"==typeof n?Rr(n):n,i.unit=r,i.value=e,i}return r(e,t),e.prototype.clone=function(){return new e(this.value,this.unit)},e.prototype.equals=function(t){var e=t;return this.value===e.value&&this.unit===e.unit},e.prototype.getType=function(){return kr.kUnitType},e.prototype.convertTo=function(t){if(this.unit===t)return new e(this.value,this.unit);var n=Hr(this.unit);if(n!==Hr(t)||n===xr.kUnknown)return null;var r=Dr(this.unit)/Dr(t);return new e(this.value*r,t)},e.prototype.buildCSSText=function(t,e,n){var r;switch(this.unit){case xr.kUnknown:break;case xr.kInteger:r=Number(this.value).toFixed(0);break;case xr.kNumber:case xr.kPercentage:case xr.kEms:case xr.kRems:case xr.kPixels:case xr.kDegrees:case xr.kRadians:case xr.kGradians:case xr.kMilliseconds:case xr.kSeconds:case xr.kTurns:var i=this.value,o=Ir(this.unit);if(i<-999999||i>999999){var a=Ir(this.unit);r=!Number.isFinite(i)||Number.isNaN(i)?Wr(i,a):i+(a||"")}else r="".concat(i).concat(o)}return n+=r},e}(Lr),Yr=new qr(0,"px");new qr(1,"px");var Xr,Kr,$r=new qr(0,"deg"),Zr=function(t){function e(e,n,r,i,o){void 0===i&&(i=1),void 0===o&&(o=!1);var a=t.call(this,"rgb")||this;return a.r=e,a.g=n,a.b=r,a.alpha=i,a.isNone=o,a}return r(e,t),e.prototype.clone=function(){return new e(this.r,this.g,this.b,this.alpha)},e.prototype.buildCSSText=function(t,e,n){return n+"rgba(".concat(this.r,",").concat(this.g,",").concat(this.b,",").concat(this.alpha,")")},e}(_r),Qr=new Fr("unset"),Jr=new Fr("initial"),ti=new Fr("inherit"),ei={"":Qr,unset:Qr,initial:Jr,inherit:ti},ni=function(t){return ei[t]||(ei[t]=new Fr(t)),ei[t]},ri=new Zr(0,0,0,0,!0),ii=new Zr(0,0,0,0),oi=Cr((function(t,e,n,r){return new Zr(t,e,n,r)}),(function(t,e,n,r){return"rgba(".concat(t,",").concat(e,",").concat(n,",").concat(r,")")})),ai=function(t,e){return void 0===e&&(e=xr.kNumber),new qr(t,e)},si=new qr(50,"%");!function(t){t[t.Standard=0]="Standard"}(Xr||(Xr={})),function(t){t[t.ADDED=0]="ADDED",t[t.REMOVED=1]="REMOVED",t[t.Z_INDEX_CHANGED=2]="Z_INDEX_CHANGED"}(Kr||(Kr={}));var ui,ci={absolutePath:[],hasArc:!1,segments:[],polygons:[],polylines:[],curve:null,totalLength:0,rect:new vr(0,0,0,0)};function hi(t){var e=t.type,n=t.value;return"hex"===e?"#".concat(n):"literal"===e?n:"rgb"===e?"rgb(".concat(n.join(","),")"):"rgba(".concat(n.join(","),")")}!function(t){t.COORDINATE="<coordinate>",t.COLOR="<color>",t.PAINT="<paint>",t.NUMBER="<number>",t.ANGLE="<angle>",t.OPACITY_VALUE="<opacity-value>",t.SHADOW_BLUR="<shadow-blur>",t.LENGTH="<length>",t.PERCENTAGE="<percentage>",t.LENGTH_PERCENTAGE="<length> | <percentage>",t.LENGTH_PERCENTAGE_12="[<length> | <percentage>]{1,2}",t.LENGTH_PERCENTAGE_14="[<length> | <percentage>]{1,4}",t.LIST_OF_POINTS="<list-of-points>",t.PATH="<path>",t.FILTER="<filter>",t.Z_INDEX="<z-index>",t.OFFSET_DISTANCE="<offset-distance>",t.DEFINED_PATH="<defined-path>",t.MARKER="<marker>",t.TRANSFORM="<transform>",t.TRANSFORM_ORIGIN="<transform-origin>",t.TEXT="<text>",t.TEXT_TRANSFORM="<text-transform>"}(ui||(ui={}));var li=function(){var t={linearGradient:/^(linear\-gradient)/i,repeatingLinearGradient:/^(repeating\-linear\-gradient)/i,radialGradient:/^(radial\-gradient)/i,repeatingRadialGradient:/^(repeating\-radial\-gradient)/i,conicGradient:/^(conic\-gradient)/i,sideOrCorner:/^to (left (top|bottom)|right (top|bottom)|top (left|right)|bottom (left|right)|left|right|top|bottom)/i,extentKeywords:/^(closest\-side|closest\-corner|farthest\-side|farthest\-corner|contain|cover)/,positionKeywords:/^(left|center|right|top|bottom)/i,pixelValue:/^(-?(([0-9]*\.[0-9]+)|([0-9]+\.?)))px/,percentageValue:/^(-?(([0-9]*\.[0-9]+)|([0-9]+\.?)))\%/,emValue:/^(-?(([0-9]*\.[0-9]+)|([0-9]+\.?)))em/,angleValue:/^(-?(([0-9]*\.[0-9]+)|([0-9]+\.?)))deg/,startCall:/^\(/,endCall:/^\)/,comma:/^,/,hexColor:/^\#([0-9a-fA-F]+)/,literalColor:/^([a-zA-Z]+)/,rgbColor:/^rgb/i,rgbaColor:/^rgba/i,number:/^(([0-9]*\.[0-9]+)|([0-9]+\.?))/},e="";function n(t){throw new Error(e+": "+t)}function r(){var t=f(i);return e.length>0&&n("Invalid input not EOF"),t}function i(){return o("linear-gradient",t.linearGradient,s)||o("repeating-linear-gradient",t.repeatingLinearGradient,s)||o("radial-gradient",t.radialGradient,u)||o("repeating-radial-gradient",t.repeatingRadialGradient,u)||o("conic-gradient",t.conicGradient,u)}function o(e,r,i){return a(r,(function(r){var o=i();return o&&(E(t.comma)||n("Missing comma before color stops")),{type:e,orientation:o,colorStops:f(p)}}))}function a(e,r){var i=E(e);if(i){E(t.startCall)||n("Missing (");var o=r(i);return E(t.endCall)||n("Missing )"),o}}function s(){return y("directional",t.sideOrCorner,1)||y("angular",t.angleValue,1)}function u(){var n,r,i=c();return i&&((n=[]).push(i),r=e,E(t.comma)&&((i=c())?n.push(i):e=r)),n}function c(){var t=function(){var t=y("shape",/^(circle)/i,0);t&&(t.style=v()||h());return t}()||function(){var t=y("shape",/^(ellipse)/i,0);t&&(t.style=m()||h());return t}();if(t)t.at=l();else{var e=h();if(e){t=e;var n=l();n&&(t.at=n)}else{var r=d();r&&(t={type:"default-radial",at:r})}}return t}function h(){return y("extent-keyword",t.extentKeywords,1)}function l(){if(y("position",/^at/,0)){var t=d();return t||n("Missing positioning value"),t}}function d(){var t={x:m(),y:m()};if(t.x||t.y)return{type:"position",value:t}}function f(e){var r=e(),i=[];if(r)for(i.push(r);E(t.comma);)(r=e())?i.push(r):n("One extra comma");return i}function p(){var e=y("hex",t.hexColor,1)||a(t.rgbaColor,(function(){return{type:"rgba",value:f(g)}}))||a(t.rgbColor,(function(){return{type:"rgb",value:f(g)}}))||y("literal",t.literalColor,0);return e||n("Expected color definition"),e.length=m(),e}function g(){return E(t.number)[1]}function m(){return y("%",t.percentageValue,1)||y("position-keyword",t.positionKeywords,1)||v()}function v(){return y("px",t.pixelValue,1)||y("em",t.emValue,1)}function y(t,e,n){var r=E(e);if(r)return{type:t,value:r[n]}}function E(t){var n=/^[\n\r\t\s]+/.exec(e);n&&x(n[0].length);var r=t.exec(e);return r&&x(r[0].length),r}function x(t){e=e.substring(t)}return function(t){return e=t,r()}}();var di=/^l\s*\(\s*([\d.]+)\s*\)\s*(.*)/i,fi=/^r\s*\(\s*([\d.]+)\s*,\s*([\d.]+)\s*,\s*([\d.]+)\s*\)\s*(.*)/i,pi=/^p\s*\(\s*([axyn])\s*\)\s*(.*)/i,gi=/[\d.]+:(#[^\s]+|[^\)]+\))/gi;var mi={left:180,top:-90,bottom:90,right:0,"left top":225,"top left":225,"left bottom":135,"bottom left":135,"right top":-45,"top right":-45,"right bottom":45,"bottom right":45},vi=Cr((function(t){var e;return e="angular"===t.type?Number(t.value):mi[t.value]||0,ai(e,"deg")})),yi=Cr((function(t){var e=50,n=50,r="%",i="%";if("position"===(null==t?void 0:t.type)){var o=t.value,a=o.x,s=o.y;"position-keyword"===(null==a?void 0:a.type)&&("left"===a.value?e=0:"center"===a.value?e=50:"right"===a.value?e=100:"top"===a.value?n=0:"bottom"===a.value&&(n=100)),"position-keyword"===(null==s?void 0:s.type)&&("left"===s.value?e=0:"center"===s.value?n=50:"right"===s.value?e=100:"top"===s.value?n=0:"bottom"===s.value&&(n=100)),"px"!==(null==a?void 0:a.type)&&"%"!==(null==a?void 0:a.type)&&"em"!==(null==a?void 0:a.type)||(r=null==a?void 0:a.type,e=Number(a.value)),"px"!==(null==s?void 0:s.type)&&"%"!==(null==s?void 0:s.type)&&"em"!==(null==s?void 0:s.type)||(i=null==s?void 0:s.type,n=Number(s.value))}return{cx:ai(e,r),cy:ai(n,i)}})),Ei=Cr((function(t){var e;if(t.indexOf("linear")>-1||t.indexOf("radial")>-1)return li(t).map((function(t){var e=t.type,n=t.orientation,r=t.colorStops;!function(t){var e,n,r,i=t.length;t[i-1].length=null!==(e=t[i-1].length)&&void 0!==e?e:{type:"%",value:"100"},i>1&&(t[0].length=null!==(n=t[0].length)&&void 0!==n?n:{type:"%",value:"0"});for(var o=0,a=Number(t[0].length.value),s=1;s<i;s++){var u=null===(r=t[s].length)||void 0===r?void 0:r.value;if(!Pt(u)&&!Pt(a)){for(var c=1;c<s-o;c++)t[o+c].length={type:"%",value:"".concat(a+(Number(u)-a)*c/(s-o))};o=s,a=Number(u)}}}(r);var i=r.map((function(t){return{offset:ai(Number(t.length.value),"%"),color:hi(t)}}));if("linear-gradient"===e)return new zr(Or.LinearGradient,{angle:n?vi(n):$r,steps:i});if("radial-gradient"===e&&(n||(n=[{type:"shape",value:"circle"}]),"shape"===n[0].type&&"circle"===n[0].value)){var o=yi(n[0].at),a=o.cx,s=o.cy,u=void 0;if(n[0].style){var c=n[0].style,h=c.type,l=c.value;u="extent-keyword"===h?ni(l):ai(l,h)}return new zr(Or.RadialGradient,{cx:a,cy:s,size:u,steps:i})}}));var n=t[0];if("("===t[1]||"("===t[2])if("l"===n){var r=di.exec(t);if(r){var i=(null===(e=r[2].match(gi))||void 0===e?void 0:e.map((function(t){return t.split(":")})))||[];return[new zr(Or.LinearGradient,{angle:ai(parseFloat(r[1]),"deg"),steps:i.map((function(t){var e=c(t,2),n=e[0],r=e[1];return{offset:ai(100*Number(n),"%"),color:r}}))})]}}else if("r"===n){var o=function(t){var e,n=fi.exec(t);if(n){var r=(null===(e=n[4].match(gi))||void 0===e?void 0:e.map((function(t){return t.split(":")})))||[];return{cx:ai(50,"%"),cy:ai(50,"%"),steps:r.map((function(t){var e=c(t,2),n=e[0],r=e[1];return{offset:ai(100*Number(n),"%"),color:r}}))}}return null}(t);if(o){if(!zt(o))return[new zr(Or.RadialGradient,o)];t=o}}else if("p"===n)return function(t){var e=pi.exec(t);if(e){var n=e[1],r=e[2];switch(n){case"a":n="repeat";break;case"x":n="repeat-x";break;case"y":n="repeat-y";break;default:n="no-repeat"}return{image:r,repetition:n}}return null}(t)}));function xi(t){return t&&!!t.image}function bi(t){return t&&!Pt(t.r)&&!Pt(t.g)&&!Pt(t.b)}var wi=Cr((function(t){if(xi(t))return i({repetition:"repeat"},t);if(Pt(t)&&(t=""),"transparent"===t)return ii;"currentColor"===t&&(t="black");var e=Ei(t);if(e)return e;var n=hn(t),r=[0,0,0,0];return null!==n&&(r[0]=n.r||0,r[1]=n.g||0,r[2]=n.b||0,r[3]=n.opacity),oi.apply(void 0,h([],c(r),!1))}));function Mi(t,e){if(bi(t)&&bi(e))return[[Number(t.r),Number(t.g),Number(t.b),Number(t.alpha)],[Number(e.r),Number(e.g),Number(e.b),Number(e.alpha)],function(t){var e=t.slice();if(e[3])for(var n=0;n<3;n++)e[n]=Math.round(Gt(e[n],0,255));return e[3]=Gt(e[3],0,1),"rgba(".concat(e.join(","),")")}]}function Ni(t,e){if(Pt(e))return ai(0,"px");if(e="".concat(e).trim().toLowerCase(),isFinite(Number(e))){if("px".search(t)>=0)return ai(Number(e),"px");if("deg".search(t)>=0)return ai(Number(e),"deg")}var n=[];e=e.replace(t,(function(t){return n.push(t),"U"+t}));var r="U("+t.source+")";return n.map((function(t){return ai(Number(e.replace(new RegExp("U"+t,"g"),"").replace(new RegExp(r,"g"),"*0")),t)}))[0]}var Si=function(t){return Ni(new RegExp("px","g"),t)},Ti=Cr(Si);Cr((function(t){return Ni(new RegExp("%","g"),t)}));var Pi=function(t){return jt(t)||isFinite(Number(t))?ai(Number(t)||0,"px"):Ni(new RegExp("px|%|em|rem","g"),t)},Ci=Cr(Pi),ki=function(t){return Ni(new RegExp("deg|rad|grad|turn","g"),t)},Ai=Cr(ki);function Oi(t,e,n,r,i){void 0===i&&(i=0);var o="",a=t.value||0,s=e.value||0,u=Hr(t.unit),c=t.convertTo(u),h=e.convertTo(u);return c&&h?(a=c.value,s=h.value,o=Ir(t.unit)):(qr.isLength(t.unit)||qr.isLength(e.unit))&&(a=Li(t,i,n),s=Li(e,i,n),o="px"),[a,s,function(t){return r&&(t=Math.max(t,0)),t+o}]}function Ri(t){var e=0;return t.unit===xr.kDegrees?e=t.value:t.unit===xr.kRadians?e=Jn(Number(t.value)):t.unit===xr.kTurns&&(e=360*Number(t.value)),e}function Di(t,e){var n;return Array.isArray(t)?n=t.map((function(t){return Number(t)})):zt(t)?n=t.split(" ").map((function(t){return Number(t)})):jt(t)&&(n=[t]),2===e?1===n.length?[n[0],n[0]]:[n[0],n[1]]:1===n.length?[n[0],n[0],n[0],n[0]]:2===n.length?[n[0],n[1],n[0],n[1]]:3===n.length?[n[0],n[1],n[2],n[1]]:[n[0],n[1],n[2],n[3]]}function Ii(t){return zt(t)?t.split(" ").map((function(t){return Ci(t)})):t.map((function(t){return Ci(t.toString())}))}function Li(t,e,n){if(0===t.value)return 0;if(t.unit===xr.kPixels)return Number(t.value);if(t.unit===xr.kPercentage&&n){var r=n.nodeName===jn.GROUP?n.getLocalBounds():n.geometry.contentBounds;return t.value/100*r.halfExtents[e]*2}return 0}var _i=["blur","brightness","drop-shadow","contrast","grayscale","sepia","saturate","hue-rotate","invert"];function zi(t){if(void 0===t&&(t=""),"none"===(t=t.toLowerCase().trim()))return[];for(var e,n=/\s*([\w-]+)\(([^)]*)\)/g,r=[],i=0;e=n.exec(t);){if(e.index!==i)return[];if(i=e.index+e[0].length,_i.indexOf(e[1])>-1&&r.push({name:e[1],params:e[2].split(" ").map((function(t){return Ni(/deg|rad|grad|turn|px|%/g,t)||wi(t)}))}),n.lastIndex===t.length)return r}return[]}function Fi(t){return t.toString()}var Bi=function(t){return"number"==typeof t?ai(t):/^\s*[-+]?(\d*\.)?\d+\s*$/.test(t)?ai(Number(t)):ai(0)},Gi=Cr(Bi);function ji(t,e){return[t,e,Fi]}function Vi(t,e){return function(n,r){return[n,r,function(n){return Fi(Gt(n,t,e))}]}}function Ui(t,e){if(t.length===e.length)return[t,e,function(t){return t}]}function Wi(t){var e;return 0===t.parsedStyle.path.totalLength&&(t.parsedStyle.path.totalLength=Ge(t.parsedStyle.path.absolutePath,void 0,i(i({},e),{bbox:!1,length:!0})).length),t.parsedStyle.path.totalLength}function Hi(t,e){return t[0]===e[0]&&t[1]===e[1]}function qi(t,e){var n=t.prePoint,r=t.currentPoint,i=t.nextPoint,o=Math.pow(r[0]-n[0],2)+Math.pow(r[1]-n[1],2),a=Math.pow(r[0]-i[0],2)+Math.pow(r[1]-i[1],2),s=Math.pow(n[0]-i[0],2)+Math.pow(n[1]-i[1],2),u=Math.acos((o+a-s)/(2*Math.sqrt(o)*Math.sqrt(a)));if(!u||0===Math.sin(u)||Ut(u,0))return{xExtra:0,yExtra:0};var c=Math.abs(Math.atan2(i[1]-r[1],i[0]-r[0])),h=Math.abs(Math.atan2(i[0]-r[0],i[1]-r[1]));return c=c>Math.PI/2?Math.PI-c:c,h=h>Math.PI/2?Math.PI-h:h,{xExtra:Math.cos(u/2-c)*(e/2*(1/Math.sin(u/2)))-e/2||0,yExtra:Math.cos(h-u/2)*(e/2*(1/Math.sin(u/2)))-e/2||0}}function Yi(t,e){return[e[0]+(e[0]-t[0]),e[1]+(e[1]-t[1])]}Cr((function(t){return zt(t)?t.split(" ").map(Gi):t.map(Gi)}));var Xi=function(t,e){var n=t.x*e.x+t.y*e.y,r=Math.sqrt((Math.pow(t.x,2)+Math.pow(t.y,2))*(Math.pow(e.x,2)+Math.pow(e.y,2)));return(t.x*e.y-t.y*e.x<0?-1:1)*Math.acos(n/r)},Ki=function(t,e,n,r,i,o,a,s){e=Math.abs(e),n=Math.abs(n);var u=Qn(r=Wt(r,360));if(t.x===a.x&&t.y===a.y)return{x:t.x,y:t.y,ellipticalArcAngle:0};if(0===e||0===n)return{x:0,y:0,ellipticalArcAngle:0};var c=(t.x-a.x)/2,h=(t.y-a.y)/2,l={x:Math.cos(u)*c+Math.sin(u)*h,y:-Math.sin(u)*c+Math.cos(u)*h},d=Math.pow(l.x,2)/Math.pow(e,2)+Math.pow(l.y,2)/Math.pow(n,2);d>1&&(e=Math.sqrt(d)*e,n=Math.sqrt(d)*n);var f=(Math.pow(e,2)*Math.pow(n,2)-Math.pow(e,2)*Math.pow(l.y,2)-Math.pow(n,2)*Math.pow(l.x,2))/(Math.pow(e,2)*Math.pow(l.y,2)+Math.pow(n,2)*Math.pow(l.x,2));f=f<0?0:f;var p=(i!==o?1:-1)*Math.sqrt(f),g=p*(e*l.y/n),m=p*(-n*l.x/e),v={x:Math.cos(u)*g-Math.sin(u)*m+(t.x+a.x)/2,y:Math.sin(u)*g+Math.cos(u)*m+(t.y+a.y)/2},y={x:(l.x-g)/e,y:(l.y-m)/n},E=Xi({x:1,y:0},y),x=Xi(y,{x:(-l.x-g)/e,y:(-l.y-m)/n});!o&&x>0?x-=2*Math.PI:o&&x<0&&(x+=2*Math.PI);var b=E+(x%=2*Math.PI)*s,w=e*Math.cos(b),M=n*Math.sin(b);return{x:Math.cos(u)*w-Math.sin(u)*M+v.x,y:Math.sin(u)*w+Math.cos(u)*M+v.y,ellipticalArcStartAngle:E,ellipticalArcEndAngle:E+x,ellipticalArcAngle:b,ellipticalArcCenter:v,resultantRx:e,resultantRy:n}};function $i(t,e,n){void 0===n&&(n=!0);var r=t.arcParams,i=r.rx,o=void 0===i?0:i,a=r.ry,s=void 0===a?0:a,u=r.xRotation,c=r.arcFlag,h=r.sweepFlag,l=Ki({x:t.prePoint[0],y:t.prePoint[1]},o,s,u,!!c,!!h,{x:t.currentPoint[0],y:t.currentPoint[1]},e),d=Ki({x:t.prePoint[0],y:t.prePoint[1]},o,s,u,!!c,!!h,{x:t.currentPoint[0],y:t.currentPoint[1]},n?e+.005:e-.005),f=d.x-l.x,p=d.y-l.y,g=Math.sqrt(f*f+p*p);return{x:-f/g,y:-p/g}}function Zi(t){return Math.sqrt(t[0]*t[0]+t[1]*t[1])}function Qi(t,e){return Zi(t)*Zi(e)?(t[0]*e[0]+t[1]*e[1])/(Zi(t)*Zi(e)):1}function Ji(t,e){return(t[0]*e[1]<t[1]*e[0]?-1:1)*Math.acos(Qi(t,e))}function to(t,e){var n=e[1],r=e[2],i=Wt(Qn(e[3]),2*Math.PI),o=e[4],a=e[5],s=t[0],u=t[1],c=e[6],h=e[7],l=Math.cos(i)*(s-c)/2+Math.sin(i)*(u-h)/2,d=-1*Math.sin(i)*(s-c)/2+Math.cos(i)*(u-h)/2,f=l*l/(n*n)+d*d/(r*r);f>1&&(n*=Math.sqrt(f),r*=Math.sqrt(f));var p=n*n*(d*d)+r*r*(l*l),g=p?Math.sqrt((n*n*(r*r)-p)/p):1;o===a&&(g*=-1),isNaN(g)&&(g=0);var m=r?g*n*d/r:0,v=n?g*-r*l/n:0,y=(s+c)/2+Math.cos(i)*m-Math.sin(i)*v,E=(u+h)/2+Math.sin(i)*m+Math.cos(i)*v,x=[(l-m)/n,(d-v)/r],b=[(-1*l-m)/n,(-1*d-v)/r],w=Ji([1,0],x),M=Ji(x,b);return Qi(x,b)<=-1&&(M=Math.PI),Qi(x,b)>=1&&(M=0),0===a&&M>0&&(M-=2*Math.PI),1===a&&M<0&&(M+=2*Math.PI),{cx:y,cy:E,rx:Hi(t,[c,h])?0:n,ry:Hi(t,[c,h])?0:r,startAngle:w,endAngle:w+M,xRotation:i,arcFlag:o,sweepFlag:a}}var eo=function(t){if(""===t||Array.isArray(t)&&0===t.length)return{absolutePath:[],hasArc:!1,segments:[],polygons:[],polylines:[],curve:null,totalLength:0,rect:{x:0,y:0,width:0,height:0}};var e;try{e=Ne(t)}catch(n){e=Ne(""),console.error("[g]: Invalid SVG Path definition: ".concat(t))}!function(t){for(var e=0;e<t.length;e++){var n=t[e-1],r=t[e];if("M"===r[0]&&n){var i=n[0],o=[r[1],r[2]],a=void 0;"L"===i||"M"===i?a=[n[1],n[2]]:"C"!==i&&"A"!==i&&"Q"!==i||(a=[n[n.length-2],n[n.length-1]]),a&&Hi(o,a)&&(t.splice(e,1),e--)}}}(e);var n=function(t){for(var e=!1,n=t.length,r=0;r<n;r++){var i=t[r][0];if("C"===i||"A"===i||"Q"===i){e=!0;break}}return e}(e),r=function(t){for(var e=[],n=[],r=[],i=0;i<t.length;i++){var o=t[i],a=o[0];"M"===a?(r.length&&(n.push(r),r=[]),r.push([o[1],o[2]])):"Z"===a?r.length&&(e.push(r),r=[]):r.push([o[1],o[2]])}return r.length>0&&n.push(r),{polygons:e,polylines:n}}(e),i=r.polygons,o=r.polylines,a=function(t){for(var e=[],n=null,r=null,i=null,o=0,a=t.length,s=0;s<a;s++){var u=t[s];r=t[s+1];var c=u[0],h={command:c,prePoint:n,params:u,startTangent:null,endTangent:null,currentPoint:null,nextPoint:null,arcParams:null,box:null,cubicParams:null};switch(c){case"M":i=[u[1],u[2]],o=s;break;case"A":var l=to(n,u);h.arcParams=l}if("Z"===c)n=i,r=t[o+1];else{var d=u.length;n=[u[d-2],u[d-1]]}r&&"Z"===r[0]&&(r=t[o],e[o]&&(e[o].prePoint=n)),h.currentPoint=n,e[o]&&Hi(n,e[o].currentPoint)&&(e[o].prePoint=h.prePoint);var f=r?[r[r.length-2],r[r.length-1]]:null;h.nextPoint=f;var p=h.prePoint;if(["L","H","V"].includes(c))h.startTangent=[p[0]-n[0],p[1]-n[1]],h.endTangent=[n[0]-p[0],n[1]-p[1]];else if("Q"===c){var g=[u[1],u[2]];h.startTangent=[p[0]-g[0],p[1]-g[1]],h.endTangent=[n[0]-g[0],n[1]-g[1]]}else if("T"===c)g=Yi((y=e[s-1]).currentPoint,p),"Q"===y.command?(h.command="Q",h.startTangent=[p[0]-g[0],p[1]-g[1]],h.endTangent=[n[0]-g[0],n[1]-g[1]]):(h.command="TL",h.startTangent=[p[0]-n[0],p[1]-n[1]],h.endTangent=[n[0]-p[0],n[1]-p[1]]);else if("C"===c){var m=[u[1],u[2]],v=[u[3],u[4]];h.startTangent=[p[0]-m[0],p[1]-m[1]],h.endTangent=[n[0]-v[0],n[1]-v[1]],0===h.startTangent[0]&&0===h.startTangent[1]&&(h.startTangent=[m[0]-v[0],m[1]-v[1]]),0===h.endTangent[0]&&0===h.endTangent[1]&&(h.endTangent=[v[0]-m[0],v[1]-m[1]])}else if("S"===c){var y;m=Yi((y=e[s-1]).currentPoint,p),v=[u[1],u[2]],"C"===y.command?(h.command="C",h.startTangent=[p[0]-m[0],p[1]-m[1]],h.endTangent=[n[0]-v[0],n[1]-v[1]]):(h.command="SQ",h.startTangent=[p[0]-v[0],p[1]-v[1]],h.endTangent=[n[0]-v[0],n[1]-v[1]])}else if("A"===c){var E=$i(h,0),x=E.x,b=E.y,w=$i(h,1,!1),M=w.x,N=w.y;h.startTangent=[x,b],h.endTangent=[M,N]}e.push(h)}return e}(e),s=function(t,e){for(var n=[],r=[],i=[],o=0;o<t.length;o++){var a=(g=t[o]).currentPoint,s=g.params,u=g.prePoint,c=void 0;switch(g.command){case"Q":c=Fn(u[0],u[1],s[1],s[2],s[3],s[4]);break;case"C":c=Dn(u[0],u[1],s[1],s[2],s[3],s[4],s[5],s[6]);break;case"A":var h=g.arcParams;c=Sn(h.cx,h.cy,h.rx,h.ry,h.xRotation,h.startAngle,h.endAngle);break;default:n.push(a[0]),r.push(a[1])}c&&(g.box=c,n.push(c.x,c.x+c.width),r.push(c.y,c.y+c.height)),e&&("L"===g.command||"M"===g.command)&&g.prePoint&&g.nextPoint&&i.push(g)}n=n.filter((function(t){return!Number.isNaN(t)&&t!==1/0&&t!==-1/0})),r=r.filter((function(t){return!Number.isNaN(t)&&t!==1/0&&t!==-1/0}));var l=_t(n),d=_t(r),f=Lt(n),p=Lt(r);if(0===i.length)return{x:l,y:d,width:f-l,height:p-d};for(o=0;o<i.length;o++){var g;(a=(g=i[o]).currentPoint)[0]===l?l-=qi(g,e).xExtra:a[0]===f&&(f+=qi(g,e).xExtra),a[1]===d?d-=qi(g,e).yExtra:a[1]===p&&(p+=qi(g,e).yExtra)}return{x:l,y:d,width:f-l,height:p-d}}(a,0),u=s.x,c=s.y,h=s.width,l=s.height;return{absolutePath:e,hasArc:n,segments:a,polygons:i,polylines:o,totalLength:0,rect:{x:Number.isFinite(u)?u:0,y:Number.isFinite(c)?c:0,width:Number.isFinite(h)?h:0,height:Number.isFinite(l)?l:0}}},no=Cr(eo);function ro(t){return zt(t)?no(t):eo(t)}function io(t,e,n){var r=t.curve,i=e.curve;r&&0!==r.length||(r=Ae(t.absolutePath,!1),t.curve=r),i&&0!==i.length||(i=Ae(e.absolutePath,!1),e.curve=i);var o=[r,i];r.length!==i.length&&(o=We(r,i));var a,s,u=Ve(o[0])!==Ve(o[1])?(a=o[0],s=a.slice(1).map((function(t,e,n){return e?n[e-1].slice(-2).concat(t.slice(1)):a[0].slice(1).concat(t.slice(1))})).map((function(t){return t.map((function(e,n){return t[t.length-n-2*(1-n%2)]}))})).reverse(),[["M"].concat(s[0].slice(0,2))].concat(s.map((function(t){return["C"].concat(t.slice(2))})))):o[0].map((function(t){return Array.isArray(t)?[].concat(t):t}));return[u,je(o[1],u),function(t){return t}]}function oo(t,e){var n;n=zt(t)?t.split(" ").map((function(t){var e=c(t.split(","),2),n=e[0],r=e[1];return[Number(n),Number(r)]})):t;var r,i,o=[],a=0,s=Ln(n);n.forEach((function(t,e){n[e+1]&&((r=[0,0])[0]=a/s,i=Cn(t[0],t[1],n[e+1][0],n[e+1][1]),a+=i,r[1]=a/s,o.push(r))}));var u=Math.min.apply(Math,h([],c(n.map((function(t){return t[0]}))),!1)),l=Math.min.apply(Math,h([],c(n.map((function(t){return t[1]}))),!1));return e&&(e.parsedStyle.defX=u,e.parsedStyle.defY=l),{points:n,totalLength:s,segments:o}}function ao(t,e){return[t.points,e.points,function(t){return t}]}var so=null;function uo(t){return function(e){var n=0;return t.map((function(t){return t===so?e[n++]:t}))}}function co(t){return t}var ho={matrix:["NNNNNN",[so,so,0,0,so,so,0,0,0,0,1,0,so,so,0,1],co],matrix3d:["NNNNNNNNNNNNNNNN",co],rotate:["A"],rotatex:["A"],rotatey:["A"],rotatez:["A"],rotate3d:["NNNA"],perspective:["L"],scale:["Nn",uo([so,so,new qr(1)]),co],scalex:["N",uo([so,new qr(1),new qr(1)]),uo([so,new qr(1)])],scaley:["N",uo([new qr(1),so,new qr(1)]),uo([new qr(1),so])],scalez:["N",uo([new qr(1),new qr(1),so])],scale3d:["NNN",co],skew:["Aa",null,co],skewx:["A",null,uo([so,$r])],skewy:["A",null,uo([$r,so])],translate:["Tt",uo([so,so,Yr]),co],translatex:["T",uo([so,Yr,Yr]),uo([so,Yr])],translatey:["T",uo([Yr,so,Yr]),uo([Yr,so])],translatez:["L",uo([Yr,Yr,so])],translate3d:["TTL",co]};function lo(t){if("none"===(t=(t||"none").toLowerCase().trim()))return[];for(var e,n=/\s*(\w+)\(([^)]*)\)/g,r=[],i=0;e=n.exec(t);){if(e.index!==i)return[];i=e.index+e[0].length;var o=e[1],a=ho[o];if(!a)return[];var s=e[2].split(","),u=a[0];if(u.length<s.length)return[];for(var c=[],h=0;h<u.length;h++){var l=s[h],d=u[h],f=void 0;if(void 0===(f=l?{A:function(t){return"0"===t.trim()?$r:Ai(t)},N:Gi,T:Ci,L:Ti}[d.toUpperCase()](l):{a:$r,n:c[0],t:Yr}[d]))return[];c.push(f)}if(r.push({t:o,d:c}),n.lastIndex===t.length)return r}return[]}function fo(t){if("none"===(t=(t||"none").toLowerCase().trim()))return[];for(var e,n=/\s*(\w+)\(([^)]*)\)/g,r=[],i=0;e=n.exec(t);){if(e.index!==i)return[];i=e.index+e[0].length;var o=e[1],a=ho[o];if(!a)return[];var s=e[2].split(","),u=a[0];if(u.length<s.length)return[];for(var c=[],h=0;h<u.length;h++){var l=s[h],d=u[h],f=void 0;if(void 0===(f=l?{A:function(t){return"0"===t.trim()?$r:ki(t)},N:Bi,T:Pi,L:Si}[d.toUpperCase()](l):{a:$r,n:c[0],t:Yr}[d]))return[];c.push(f)}if(r.push({t:o,d:c}),n.lastIndex===t.length)return r}return[]}function po(t){var e,n,r,i;switch(t.t){case"rotatex":return i=Qn(Ri(t.d[0])),[1,0,0,0,0,Math.cos(i),Math.sin(i),0,0,-Math.sin(i),Math.cos(i),0,0,0,0,1];case"rotatey":return i=Qn(Ri(t.d[0])),[Math.cos(i),0,-Math.sin(i),0,0,1,0,0,Math.sin(i),0,Math.cos(i),0,0,0,0,1];case"rotate":case"rotatez":return i=Qn(Ri(t.d[0])),[Math.cos(i),Math.sin(i),0,0,-Math.sin(i),Math.cos(i),0,0,0,0,1,0,0,0,0,1];case"rotate3d":e=t.d[0].value,n=t.d[1].value,r=t.d[2].value,i=Qn(Ri(t.d[3]));var o=e*e+n*n+r*r;if(0===o)e=1,n=0,r=0;else if(1!==o){var a=Math.sqrt(o);e/=a,n/=a,r/=a}var s=Math.sin(i/2),u=s*Math.cos(i/2),c=s*s;return[1-2*(n*n+r*r)*c,2*(e*n*c+r*u),2*(e*r*c-n*u),0,2*(e*n*c-r*u),1-2*(e*e+r*r)*c,2*(n*r*c+e*u),0,2*(e*r*c+n*u),2*(n*r*c-e*u),1-2*(e*e+n*n)*c,0,0,0,0,1];case"scale":return[t.d[0].value,0,0,0,0,t.d[1].value,0,0,0,0,1,0,0,0,0,1];case"scalex":return[t.d[0].value,0,0,0,0,1,0,0,0,0,1,0,0,0,0,1];case"scaley":return[1,0,0,0,0,t.d[0].value,0,0,0,0,1,0,0,0,0,1];case"scalez":return[1,0,0,0,0,1,0,0,0,0,t.d[0].value,0,0,0,0,1];case"scale3d":return[t.d[0].value,0,0,0,0,t.d[1].value,0,0,0,0,t.d[2].value,0,0,0,0,1];case"skew":var h=Qn(Ri(t.d[0])),l=Qn(Ri(t.d[1]));return[1,Math.tan(l),0,0,Math.tan(h),1,0,0,0,0,1,0,0,0,0,1];case"skewx":return i=Qn(Ri(t.d[0])),[1,0,0,0,Math.tan(i),1,0,0,0,0,1,0,0,0,0,1];case"skewy":return i=Qn(Ri(t.d[0])),[1,Math.tan(i),0,0,0,1,0,0,0,0,1,0,0,0,0,1];case"translate":return[1,0,0,0,0,1,0,0,0,0,1,0,e=Li(t.d[0],0,null)||0,n=Li(t.d[1],0,null)||0,0,1];case"translatex":return[1,0,0,0,0,1,0,0,0,0,1,0,e=Li(t.d[0],0,null)||0,0,0,1];case"translatey":return[1,0,0,0,0,1,0,0,0,0,1,0,0,n=Li(t.d[0],0,null)||0,0,1];case"translatez":return[1,0,0,0,0,1,0,0,0,0,1,0,0,0,r=Li(t.d[0],0,null)||0,1];case"translate3d":return[1,0,0,0,0,1,0,0,0,0,1,0,e=Li(t.d[0],0,null)||0,n=Li(t.d[1],0,null)||0,r=Li(t.d[2],0,null)||0,1];case"perspective":var d=Li(t.d[0],0,null)||0;return[1,0,0,0,0,1,0,0,0,0,1,d?-1/d:0,0,0,0,1];case"matrix":return[t.d[0].value,t.d[1].value,0,0,t.d[2].value,t.d[3].value,0,0,0,0,1,0,t.d[4].value,t.d[5].value,0,1];case"matrix3d":return t.d.map((function(t){return t.value}))}}function go(t,e){return[t[0]*e[0]+t[4]*e[1]+t[8]*e[2]+t[12]*e[3],t[1]*e[0]+t[5]*e[1]+t[9]*e[2]+t[13]*e[3],t[2]*e[0]+t[6]*e[1]+t[10]*e[2]+t[14]*e[3],t[3]*e[0]+t[7]*e[1]+t[11]*e[2]+t[15]*e[3],t[0]*e[4]+t[4]*e[5]+t[8]*e[6]+t[12]*e[7],t[1]*e[4]+t[5]*e[5]+t[9]*e[6]+t[13]*e[7],t[2]*e[4]+t[6]*e[5]+t[10]*e[6]+t[14]*e[7],t[3]*e[4]+t[7]*e[5]+t[11]*e[6]+t[15]*e[7],t[0]*e[8]+t[4]*e[9]+t[8]*e[10]+t[12]*e[11],t[1]*e[8]+t[5]*e[9]+t[9]*e[10]+t[13]*e[11],t[2]*e[8]+t[6]*e[9]+t[10]*e[10]+t[14]*e[11],t[3]*e[8]+t[7]*e[9]+t[11]*e[10]+t[15]*e[11],t[0]*e[12]+t[4]*e[13]+t[8]*e[14]+t[12]*e[15],t[1]*e[12]+t[5]*e[13]+t[9]*e[14]+t[13]*e[15],t[2]*e[12]+t[6]*e[13]+t[10]*e[14]+t[14]*e[15],t[3]*e[12]+t[7]*e[13]+t[11]*e[14]+t[15]*e[15]]}function mo(t){var e=[0,0,0],n=[1,1,1],r=[0,0,0],i=[0,0,0,1],o=[0,0,0,1];return function(t,e,n,r,i,o){if(!function(t,e){var n=e[15];if(0===n)return!1;for(var r=1/n,i=0;i<16;i++)t[i]=e[i]*r;return!0}(rr,t))return!1;if(x(ir,rr),ir[3]=0,ir[7]=0,ir[11]=0,ir[15]=1,Math.abs(S(ir))<1e-8)return!1;var a,s,u=rr[3],c=rr[7],h=rr[11],l=rr[12],d=rr[13],f=rr[14],p=rr[15];if(0!==u||0!==c||0!==h){if(or[0]=u,or[1]=c,or[2]=h,or[3]=p,!N(ir,ir))return!1;M(ir,ir),ft(i,or,ir)}else i[0]=i[1]=i[2]=0,i[3]=1;if(e[0]=l,e[1]=d,e[2]=f,s=rr,(a=ar)[0][0]=s[0],a[0][1]=s[1],a[0][2]=s[2],a[1][0]=s[4],a[1][1]=s[5],a[1][2]=s[6],a[2][0]=s[8],a[2][1]=s[9],a[2][2]=s[10],n[0]=Z(ar[0]),it(ar[0],ar[0]),r[0]=ot(ar[0],ar[1]),ur(ar[1],ar[1],ar[0],1,-r[0]),n[1]=Z(ar[1]),it(ar[1],ar[1]),r[0]/=n[1],r[1]=ot(ar[0],ar[2]),ur(ar[2],ar[2],ar[0],1,-r[1]),r[2]=ot(ar[1],ar[2]),ur(ar[2],ar[2],ar[1],1,-r[2]),n[2]=Z(ar[2]),it(ar[2],ar[2]),r[1]/=n[2],r[2]/=n[2],at(sr,ar[1],ar[2]),ot(ar[0],sr)<0)for(var g=0;g<3;g++)n[g]*=-1,ar[g][0]*=-1,ar[g][1]*=-1,ar[g][2]*=-1;o[0]=.5*Math.sqrt(Math.max(1+ar[0][0]-ar[1][1]-ar[2][2],0)),o[1]=.5*Math.sqrt(Math.max(1-ar[0][0]+ar[1][1]-ar[2][2],0)),o[2]=.5*Math.sqrt(Math.max(1-ar[0][0]-ar[1][1]+ar[2][2],0)),o[3]=.5*Math.sqrt(Math.max(1+ar[0][0]+ar[1][1]+ar[2][2],0)),ar[2][1]>ar[1][2]&&(o[0]=-o[0]),ar[0][2]>ar[2][0]&&(o[1]=-o[1]),ar[1][0]>ar[0][1]&&(o[2]=-o[2])}(function(t){return 0===t.length?[1,0,0,0,0,1,0,0,0,0,1,0,0,0,0,1]:t.map(po).reduce(go)}(t),e,n,r,i,o),[[e,n,r,o,i]]}var vo=function(){function t(t,e){for(var n=[[0,0,0,0],[0,0,0,0],[0,0,0,0],[0,0,0,0]],r=0;r<4;r++)for(var i=0;i<4;i++)for(var o=0;o<4;o++)n[r][i]+=e[r][o]*t[o][i];return n}return function(e,n,r,i,o){for(var a=[[1,0,0,0],[0,1,0,0],[0,0,1,0],[0,0,0,1]],s=0;s<4;s++)a[s][3]=o[s];for(s=0;s<3;s++)for(var u=0;u<3;u++)a[3][s]+=e[u]*a[u][s];var c=i[0],h=i[1],l=i[2],d=i[3],f=[[1,0,0,0],[0,1,0,0],[0,0,1,0],[0,0,0,1]];f[0][0]=1-2*(h*h+l*l),f[0][1]=2*(c*h-l*d),f[0][2]=2*(c*l+h*d),f[1][0]=2*(c*h+l*d),f[1][1]=1-2*(c*c+l*l),f[1][2]=2*(h*l-c*d),f[2][0]=2*(c*l-h*d),f[2][1]=2*(h*l+c*d),f[2][2]=1-2*(c*c+h*h),a=t(a,f);var p=[[1,0,0,0],[0,1,0,0],[0,0,1,0],[0,0,0,1]];for(r[2]&&(p[2][1]=r[2],a=t(a,p)),r[1]&&(p[2][1]=0,p[2][0]=r[0],a=t(a,p)),r[0]&&(p[2][0]=0,p[1][0]=r[0],a=t(a,p)),s=0;s<3;s++)for(u=0;u<3;u++)a[s][u]*=n[s];return function(t){return 0==t[0][2]&&0==t[0][3]&&0==t[1][2]&&0==t[1][3]&&0==t[2][0]&&0==t[2][1]&&1==t[2][2]&&0==t[2][3]&&0==t[3][2]&&1==t[3][3]}(a)?[a[0][0],a[0][1],a[1][0],a[1][1],a[3][0],a[3][1]]:a[0].concat(a[1],a[2],a[3])}}();function yo(t){return t.toFixed(6).replace(".000000","")}function Eo(t,e){var n,r;return t.decompositionPair!==e&&(t.decompositionPair=e,n=mo(t)),e.decompositionPair!==t&&(e.decompositionPair=t,r=mo(e)),null===n[0]||null===r[0]?[[!1],[!0],function(n){return n?e[0].d:t[0].d}]:(n[0].push(0),r[0].push(1),[n,r,function(t){var e=function(t,e,n){var r=function(t,e){for(var n=0,r=0;r<t.length;r++)n+=t[r]*e[r];return n}(t,e);r=Gt(r,-1,1);var i=[];if(1===r)i=t;else for(var o=Math.acos(r),a=1*Math.sin(n*o)/Math.sqrt(1-r*r),s=0;s<4;s++)i.push(t[s]*(Math.cos(n*o)-r*a)+e[s]*a);return i}(n[0][3],r[0][3],t[5]);return vo(t[0],t[1],t[2],e,t[4]).map(yo).join(",")}])}function xo(t){return t.replace(/[xy]/,"")}function bo(t){return t.replace(/(x|y|z|3d)?$/,"3d")}function wo(t,e,n){var r=!1;if(!t.length||!e.length){t.length||(r=!0,t=e,e=[]);for(var i=function(n){var r=t[n],i=r.t,o=r.d,a="scale"===i.substring(0,5)?1:0;e.push({t:i,d:o.map((function(t){return"number"==typeof t?ai(a):ai(a,t.unit)}))})},o=0;o<t.length;o++)i(o)}var a,s,u=[],c=[],h=[];if(t.length!==e.length)u=[(y=Eo(t,e))[0]],c=[y[1]],h=[["matrix",[y[2]]]];else for(o=0;o<t.length;o++){var l=t[o].t,d=e[o].t,f=t[o].d,p=e[o].d,g=ho[l],m=ho[d],v=void 0;if(s=d,"perspective"===(a=l)&&"perspective"===s||!("matrix"!==a&&"matrix3d"!==a||"matrix"!==s&&"matrix3d"!==s)){var y=Eo([t[o]],[e[o]]);u.push(y[0]),c.push(y[1]),h.push(["matrix",[y[2]]])}else{if(l===d)v=l;else if(g[2]&&m[2]&&xo(l)===xo(d))v=xo(l),f=g[2](f),p=m[2](p);else{if(!g[1]||!m[1]||bo(l)!==bo(d)){u=[(y=Eo(t,e))[0]],c=[y[1]],h=[["matrix",[y[2]]]];break}v=bo(l),f=g[1](f),p=m[1](p)}for(var E=[],x=[],b=[],w=0;w<f.length;w++){y=Oi(f[w],p[w],n,!1,w);E[w]=y[0],x[w]=y[1],b.push(y[2])}u.push(E),c.push(x),h.push([v,b])}}if(r){var M=u;u=c,c=M}return[u,c,function(t){return t.map((function(t,e){var n=t.map((function(t,n){return h[e][1][n](t)})).join(",");return"matrix"===h[e][0]&&16===n.split(",").length&&(h[e][0]="matrix3d"),"matrix3d"===h[e][0]&&6===n.split(",").length&&(h[e][0]="matrix"),h[e][0]+"("+n+")"})).join(" ")}]}var Mo=Cr((function(t){if(zt(t)){if("text-anchor"===t)return[ai(0,"px"),ai(0,"px")];var e=t.split(" ");return 1===e.length&&("top"===e[0]||"bottom"===e[0]?(e[1]=e[0],e[0]="center"):e[1]="center"),2!==e.length?null:[Ci(So(e[0])),Ci(So(e[1]))]}return[ai(t[0]||0,"px"),ai(t[1]||0,"px")]})),No=function(t){if(zt(t)){if("text-anchor"===t)return[ai(0,"px"),ai(0,"px")];var e=t.split(" ");return 1===e.length&&("top"===e[0]||"bottom"===e[0]?(e[1]=e[0],e[0]="center"):e[1]="center"),2!==e.length?null:[Pi(So(e[0])),Pi(So(e[1]))]}return[ai(t[0]||0,"px"),ai(t[1]||0,"px")]};function So(t){return"center"===t?"50%":"left"===t||"top"===t?"0":"right"===t||"bottom"===t?"100%":t}var To=[{n:"display",k:["none"]},{n:"opacity",int:!0,inh:!0,d:"1",syntax:ui.OPACITY_VALUE},{n:"fillOpacity",int:!0,inh:!0,d:"1",syntax:ui.OPACITY_VALUE},{n:"strokeOpacity",int:!0,inh:!0,d:"1",syntax:ui.OPACITY_VALUE},{n:"fill",int:!0,k:["none"],d:"none",syntax:ui.PAINT},{n:"fillRule",k:["nonzero","evenodd"],d:"nonzero"},{n:"stroke",int:!0,k:["none"],d:"none",syntax:ui.PAINT,l:!0},{n:"shadowType",k:["inner","outer","both"],d:"outer",l:!0},{n:"shadowColor",int:!0,syntax:ui.COLOR},{n:"shadowOffsetX",int:!0,l:!0,d:"0",syntax:ui.LENGTH_PERCENTAGE},{n:"shadowOffsetY",int:!0,l:!0,d:"0",syntax:ui.LENGTH_PERCENTAGE},{n:"shadowBlur",int:!0,l:!0,d:"0",syntax:ui.SHADOW_BLUR},{n:"lineWidth",int:!0,inh:!0,d:"1",l:!0,a:["strokeWidth"],syntax:ui.LENGTH_PERCENTAGE},{n:"increasedLineWidthForHitTesting",inh:!0,d:"0",l:!0,syntax:ui.LENGTH_PERCENTAGE},{n:"lineJoin",inh:!0,l:!0,a:["strokeLinejoin"],k:["miter","bevel","round"],d:"miter"},{n:"lineCap",inh:!0,l:!0,a:["strokeLinecap"],k:["butt","round","square"],d:"butt"},{n:"lineDash",int:!0,inh:!0,k:["none"],a:["strokeDasharray"],syntax:ui.LENGTH_PERCENTAGE_12},{n:"lineDashOffset",int:!0,inh:!0,d:"0",a:["strokeDashoffset"],syntax:ui.LENGTH_PERCENTAGE},{n:"offsetPath",syntax:ui.DEFINED_PATH},{n:"offsetDistance",int:!0,syntax:ui.OFFSET_DISTANCE},{n:"dx",int:!0,l:!0,d:"0",syntax:ui.LENGTH_PERCENTAGE},{n:"dy",int:!0,l:!0,d:"0",syntax:ui.LENGTH_PERCENTAGE},{n:"zIndex",ind:!0,int:!0,d:"0",k:["auto"],syntax:ui.Z_INDEX},{n:"visibility",k:["visible","hidden"],ind:!0,inh:!0,int:!0,d:"visible"},{n:"pointerEvents",inh:!0,k:["none","auto","stroke","fill","painted","visible","visiblestroke","visiblefill","visiblepainted","all"],d:"auto"},{n:"filter",ind:!0,l:!0,k:["none"],d:"none",syntax:ui.FILTER},{n:"clipPath",syntax:ui.DEFINED_PATH},{n:"textPath",syntax:ui.DEFINED_PATH},{n:"textPathSide",k:["left","right"],d:"left"},{n:"textPathStartOffset",l:!0,d:"0",syntax:ui.LENGTH_PERCENTAGE},{n:"transform",p:100,int:!0,k:["none"],d:"none",syntax:ui.TRANSFORM},{n:"transformOrigin",p:100,d:function(t){return t===jn.CIRCLE||t===jn.ELLIPSE?"center":t===jn.TEXT?"text-anchor":"left top"},l:!0,syntax:ui.TRANSFORM_ORIGIN},{n:"anchor",p:99,d:function(t){return t===jn.CIRCLE||t===jn.ELLIPSE?"0.5 0.5":"0 0"},l:!0,syntax:ui.LENGTH_PERCENTAGE_12},{n:"cx",int:!0,d:"0",syntax:ui.COORDINATE},{n:"cy",int:!0,d:"0",syntax:ui.COORDINATE},{n:"cz",int:!0,d:"0",syntax:ui.COORDINATE},{n:"r",int:!0,l:!0,d:"0",syntax:ui.LENGTH_PERCENTAGE},{n:"rx",int:!0,l:!0,d:"0",syntax:ui.LENGTH_PERCENTAGE},{n:"ry",int:!0,l:!0,d:"0",syntax:ui.LENGTH_PERCENTAGE},{n:"x",int:!0,d:"0",syntax:ui.COORDINATE},{n:"y",int:!0,d:"0",syntax:ui.COORDINATE},{n:"z",int:!0,d:"0",syntax:ui.COORDINATE},{n:"width",int:!0,l:!0,k:["auto","fit-content","min-content","max-content"],d:"0",syntax:ui.LENGTH_PERCENTAGE},{n:"height",int:!0,l:!0,k:["auto","fit-content","min-content","max-content"],d:"0",syntax:ui.LENGTH_PERCENTAGE},{n:"radius",int:!0,l:!0,d:"0",syntax:ui.LENGTH_PERCENTAGE_14},{n:"x1",int:!0,l:!0,syntax:ui.COORDINATE},{n:"y1",int:!0,l:!0,syntax:ui.COORDINATE},{n:"z1",int:!0,l:!0,syntax:ui.COORDINATE},{n:"x2",int:!0,l:!0,syntax:ui.COORDINATE},{n:"y2",int:!0,l:!0,syntax:ui.COORDINATE},{n:"z2",int:!0,l:!0,syntax:ui.COORDINATE},{n:"path",int:!0,l:!0,d:"",a:["d"],syntax:ui.PATH,p:50},{n:"points",int:!0,l:!0,syntax:ui.LIST_OF_POINTS,p:50},{n:"text",l:!0,d:"",syntax:ui.TEXT,p:50},{n:"textTransform",l:!0,inh:!0,k:["capitalize","uppercase","lowercase","none"],d:"none",syntax:ui.TEXT_TRANSFORM,p:51},{n:"font",l:!0},{n:"fontSize",int:!0,inh:!0,d:"16px",l:!0,syntax:ui.LENGTH_PERCENTAGE},{n:"fontFamily",l:!0,inh:!0,d:"sans-serif"},{n:"fontStyle",l:!0,inh:!0,k:["normal","italic","oblique"],d:"normal"},{n:"fontWeight",l:!0,inh:!0,k:["normal","bold","bolder","lighter"],d:"normal"},{n:"fontVariant",l:!0,inh:!0,k:["normal","small-caps"],d:"normal"},{n:"lineHeight",l:!0,syntax:ui.LENGTH,int:!0,d:"0"},{n:"letterSpacing",l:!0,syntax:ui.LENGTH,int:!0,d:"0"},{n:"miterLimit",l:!0,syntax:ui.NUMBER,d:function(t){return t===jn.PATH||t===jn.POLYGON||t===jn.POLYLINE?"4":"10"}},{n:"wordWrap",l:!0},{n:"wordWrapWidth",l:!0},{n:"maxLines",l:!0},{n:"textOverflow",l:!0,d:"clip"},{n:"leading",l:!0},{n:"textBaseline",l:!0,inh:!0,k:["top","hanging","middle","alphabetic","ideographic","bottom"],d:"alphabetic"},{n:"textAlign",l:!0,inh:!0,k:["start","center","middle","end","left","right"],d:"start"},{n:"markerStart",syntax:ui.MARKER},{n:"markerEnd",syntax:ui.MARKER},{n:"markerMid",syntax:ui.MARKER},{n:"markerStartOffset",syntax:ui.LENGTH,l:!0,int:!0,d:"0"},{n:"markerEndOffset",syntax:ui.LENGTH,l:!0,int:!0,d:"0"}],Po=To.filter((function(t){return!!t.l})).map((function(t){return t.n})),Co={},ko=new WeakMap,Ao=function(){function t(t){var e=this;this.runtime=t,To.forEach((function(t){e.registerMetadata(t)}))}return t.prototype.registerMetadata=function(t){h([t.n],c(t.a||[]),!1).forEach((function(e){Co[e]=t}))},t.prototype.unregisterMetadata=function(t){delete Co[t]},t.prototype.getPropertySyntax=function(t){return this.runtime.CSSPropertySyntaxFactory[t]},t.prototype.processProperties=function(t,e,n){var r=this;if(void 0===n&&(n={skipUpdateAttribute:!1,skipParse:!1,forceUpdateGeometry:!1,usedAttributes:[],memoize:!0}),!this.runtime.enableCSSParsing){Object.assign(t.attributes,e);var o=Object.keys(e),a=t.parsedStyle.clipPath,s=t.parsedStyle.offsetPath;t.parsedStyle=Object.assign(t.parsedStyle,e);var u=!!n.forceUpdateGeometry;if(!u)for(var c=0;c<Po.length;c++)if(Po[c]in e){u=!0;break}return e.fill&&(t.parsedStyle.fill=wi(e.fill)),e.stroke&&(t.parsedStyle.stroke=wi(e.stroke)),e.shadowColor&&(t.parsedStyle.shadowColor=wi(e.shadowColor)),e.filter&&(t.parsedStyle.filter=zi(e.filter)),Pt(e.radius)||(t.parsedStyle.radius=Di(e.radius,4)),Pt(e.lineDash)||(t.parsedStyle.lineDash=Di(e.lineDash,2)),e.points&&(t.parsedStyle.points=oo(e.points,t)),""===e.path&&(t.parsedStyle.path=i({},ci)),e.path&&(t.parsedStyle.path=ro(e.path),t.parsedStyle.defX=t.parsedStyle.path.rect.x,t.parsedStyle.defY=t.parsedStyle.path.rect.y),e.textTransform&&this.runtime.CSSPropertySyntaxFactory["<text-transform>"].calculator(null,null,{value:e.textTransform},t,null),e.clipPath&&this.runtime.CSSPropertySyntaxFactory["<defined-path>"].calculator("clipPath",a,e.clipPath,t,this.runtime),e.offsetPath&&this.runtime.CSSPropertySyntaxFactory["<defined-path>"].calculator("offsetPath",s,e.offsetPath,t,this.runtime),e.anchor&&(t.parsedStyle.anchor=Di(e.anchor,2)),e.transform&&(t.parsedStyle.transform=lo(e.transform)),e.transformOrigin&&(t.parsedStyle.transformOrigin=Mo(e.transformOrigin)),e.markerStart&&(t.parsedStyle.markerStart=this.runtime.CSSPropertySyntaxFactory["<marker>"].calculator(null,e.markerStart,e.markerStart,null,null)),e.markerEnd&&(t.parsedStyle.markerEnd=this.runtime.CSSPropertySyntaxFactory["<marker>"].calculator(null,e.markerEnd,e.markerEnd,null,null)),e.markerMid&&(t.parsedStyle.markerMid=this.runtime.CSSPropertySyntaxFactory["<marker>"].calculator("",e.markerMid,e.markerMid,null,null)),(t.nodeName!==jn.CIRCLE&&t.nodeName!==jn.ELLIPSE||Pt(e.cx)&&Pt(e.cy))&&(t.nodeName!==jn.RECT&&t.nodeName!==jn.IMAGE&&t.nodeName!==jn.GROUP&&t.nodeName!==jn.HTML&&t.nodeName!==jn.TEXT&&t.nodeName!==jn.MESH||Pt(e.x)&&Pt(e.y)&&Pt(e.z))&&(t.nodeName!==jn.LINE||Pt(e.x1)&&Pt(e.y1)&&Pt(e.z1)&&Pt(e.x2)&&Pt(e.y2)&&Pt(e.z2))||this.runtime.CSSPropertySyntaxFactory["<coordinate>"].postProcessor(t,o),Pt(e.zIndex)||this.runtime.CSSPropertySyntaxFactory["<z-index>"].postProcessor(t,o),e.path&&this.runtime.CSSPropertySyntaxFactory["<path>"].postProcessor(t,o),e.points&&this.runtime.CSSPropertySyntaxFactory["<list-of-points>"].postProcessor(t,o),Pt(e.offsetDistance)||this.runtime.CSSPropertySyntaxFactory["<offset-distance>"].postProcessor(t,o),e.transform&&this.runtime.CSSPropertySyntaxFactory["<transform>"].postProcessor(t,o),void(u&&this.updateGeometry(t))}var h=n.skipUpdateAttribute,l=n.skipParse,d=n.forceUpdateGeometry,f=n.usedAttributes,p=n.memoize,g=d,m=Object.keys(e);m.forEach((function(n){var r;h||(t.attributes[n]=e[n]),!g&&(null===(r=Co[n])||void 0===r?void 0:r.l)&&(g=!0)})),l||m.forEach((function(e){t.computedStyle[e]=r.parseProperty(e,t.attributes[e],t,p)})),(null==f?void 0:f.length)&&(m=Array.from(new Set(m.concat(f)))),m.forEach((function(e){e in t.computedStyle&&(t.parsedStyle[e]=r.computeProperty(e,t.computedStyle[e],t,p))})),g&&this.updateGeometry(t),m.forEach((function(e){e in t.parsedStyle&&r.postProcessProperty(e,t,m)})),this.runtime.enableCSSParsing&&t.children.length&&m.forEach((function(e){e in t.parsedStyle&&r.isPropertyInheritable(e)&&t.children.forEach((function(t){t.internalSetAttribute(e,null,{skipUpdateAttribute:!0,skipParse:!0})}))}))},t.prototype.parseProperty=function(t,e,n,r){var i=Co[t],o=e;if((""===e||Pt(e))&&(e="unset"),"unset"===e||"initial"===e||"inherit"===e)o=ni(e);else if(i){var a=i.k,s=i.syntax,u=s&&this.getPropertySyntax(s);a&&a.indexOf(e)>-1?o=ni(e):u&&(!r&&u.parserUnmemoize?o=u.parserUnmemoize(e,n):u.parser&&(o=u.parser(e,n)))}return o},t.prototype.computeProperty=function(t,e,n,r){var i=Co[t],o="g-root"===n.id,a=e;if(i){var s=i.syntax,u=i.inh,c=i.d;if(e instanceof Fr){var h=e.value;if("unset"===h&&(h=u&&!o?"inherit":"initial"),"initial"===h)Pt(c)||(e=this.parseProperty(t,jr(c)?c(n.nodeName):c,n,r));else if("inherit"===h){var l=this.tryToResolveProperty(n,t,{inherited:!0});return Pt(l)?void this.addUnresolveProperty(n,t):l}}var d=s&&this.getPropertySyntax(s);if(d&&d.calculator){var f=n.parsedStyle[t];a=d.calculator(t,f,e,n,this.runtime)}else a=e instanceof Fr?e.value:e}return a},t.prototype.postProcessProperty=function(t,e,n){var r=Co[t];if(r&&r.syntax){var i=r.syntax&&this.getPropertySyntax(r.syntax);i&&i.postProcessor&&i.postProcessor(e,n)}},t.prototype.addUnresolveProperty=function(t,e){var n=ko.get(t);n||(ko.set(t,[]),n=ko.get(t)),-1===n.indexOf(e)&&n.push(e)},t.prototype.tryToResolveProperty=function(t,e,n){if(void 0===n&&(n={}),n.inherited&&t.parentElement&&function(t,e){var n=ko.get(t);return!n||0===n.length||n.includes(e)}(t.parentElement,e)){var r=t.parentElement.parsedStyle[e];if("unset"===r||"initial"===r||"inherit"===r)return;return r}},t.prototype.recalc=function(t){var e=ko.get(t);if(e&&e.length){var n={};e.forEach((function(e){n[e]=t.attributes[e]})),this.processProperties(t,n),ko.delete(t)}},t.prototype.updateGeometry=function(t){var e=t.nodeName,n=this.runtime.geometryUpdaterFactory[e];if(n){var r=t.geometry;r.contentBounds||(r.contentBounds=new hr),r.renderBounds||(r.renderBounds=new hr);var i=t.parsedStyle,o=n.update(i,t),a=o.width,s=o.height,u=o.depth,c=void 0===u?0:u,h=o.offsetX,l=void 0===h?0:h,d=o.offsetY,f=void 0===d?0:d,p=o.offsetZ,g=void 0===p?0:p,m=[Math.abs(a)/2,Math.abs(s)/2,c/2],v=i,y=v.stroke,E=v.lineWidth,x=v.increasedLineWidthForHitTesting,b=v.shadowType,w=v.shadowColor,M=v.filter,N=void 0===M?[]:M,S=v.transformOrigin,T=i.anchor;e===jn.TEXT?delete i.anchor:e===jn.MESH&&(i.anchor[2]=.5);var P=[(1-2*(T&&T[0]||0))*a/2+l,(1-2*(T&&T[1]||0))*s/2+f,(1-2*(T&&T[2]||0))*m[2]+g];r.contentBounds.update(P,m);var C=e===jn.POLYLINE||e===jn.POLYGON||e===jn.PATH?Math.SQRT2:.5;if(y&&!y.isNone){var k=((E||0)+(x||0))*C;m[0]+=k,m[1]+=k}if(r.renderBounds.update(P,m),w&&b&&"inner"!==b){var A=r.renderBounds,O=A.min,R=A.max,D=i,I=D.shadowBlur||0,L=D.shadowOffsetX||0,_=D.shadowOffsetY||0,z=O[0]-I+L,F=R[0]+I+L,B=O[1]-I+_,G=R[1]+I+_;O[0]=Math.min(O[0],z),R[0]=Math.max(R[0],F),O[1]=Math.min(O[1],B),R[1]=Math.max(R[1],G),r.renderBounds.setMinMax(O,R)}N.forEach((function(t){var e=t.name,n=t.params;if("blur"===e){var i=n[0].value;r.renderBounds.update(r.renderBounds.center,Xn(r.renderBounds.halfExtents,r.renderBounds.halfExtents,[i,i,0]))}else if("drop-shadow"===e){var o=n[0].value,a=n[1].value,s=n[2].value,u=r.renderBounds,c=u.min,h=u.max,l=c[0]-s+o,d=h[0]+s+o,f=c[1]-s+a,p=h[1]+s+a;c[0]=Math.min(c[0],l),h[0]=Math.max(h[0],d),c[1]=Math.min(c[1],f),h[1]=Math.max(h[1],p),r.renderBounds.setMinMax(c,h)}})),T=i.anchor;var j=a<0,V=s<0,U=(j?-1:1)*(S?Li(S[0],0,t):0),W=(V?-1:1)*(S?Li(S[1],1,t):0);U-=(j?-1:1)*(T&&T[0]||0)*r.contentBounds.halfExtents[0]*2,W-=(V?-1:1)*(T&&T[1]||0)*r.contentBounds.halfExtents[1]*2,t.setOrigin(U,W),this.runtime.sceneGraphService.dirtifyToRoot(t)}},t.prototype.updateSizeAttenuation=function(t,e){t.style.isSizeAttenuation?(t.style.rawLineWidth||(t.style.rawLineWidth=t.style.lineWidth),t.style.lineWidth=t.style.rawLineWidth/e,t.nodeName===jn.CIRCLE&&(t.style.rawR||(t.style.rawR=t.style.r),t.style.r=t.style.rawR/e)):(t.style.rawLineWidth&&(t.style.lineWidth=t.style.rawLineWidth,delete t.style.rawLineWidth),t.nodeName===jn.CIRCLE&&t.style.rawR&&(t.style.r=t.style.rawR,delete t.style.rawR))},t.prototype.isPropertyInheritable=function(t){var e=Co[t];return!!e&&e.inh},t}(),Oo=function(){function t(){this.parser=Ai,this.parserUnmemoize=ki,this.parserWithCSSDisabled=null,this.mixer=ji}return t.prototype.calculator=function(t,e,n,r){return Ri(n)},t}(),Ro=function(){function t(){}return t.prototype.calculator=function(t,e,n,r,i){return n instanceof Fr&&(n=null),i.sceneGraphService.updateDisplayObjectDependency(t,e,n,r),"clipPath"===t&&r.forEach((function(t){0===t.childNodes.length&&i.sceneGraphService.dirtifyToRoot(t)})),n},t}(),Do=function(){function t(){this.parser=wi,this.parserWithCSSDisabled=wi,this.mixer=Mi}return t.prototype.calculator=function(t,e,n,r){return n instanceof Fr?"none"===n.value?ri:ii:n},t}(),Io=function(){function t(){this.parser=zi}return t.prototype.calculator=function(t,e,n){return n instanceof Fr?[]:n},t}();function Lo(t){var e=t.parsedStyle.fontSize;return Pt(e)?null:e}var _o=function(){function t(){this.parser=Ci,this.parserUnmemoize=Pi,this.parserWithCSSDisabled=null,this.mixer=ji}return t.prototype.calculator=function(t,e,n,r,i){var o;if(jt(n))return n;if(!qr.isRelativeUnit(n.unit))return n.value;var a=i.styleValueRegistry;if(n.unit===xr.kPercentage)return 0;if(n.unit===xr.kEms){if(r.parentNode){if(s=Lo(r.parentNode))return s*=n.value;a.addUnresolveProperty(r,t)}else a.addUnresolveProperty(r,t);return 0}if(n.unit===xr.kRems){if(null===(o=null==r?void 0:r.ownerDocument)||void 0===o?void 0:o.documentElement){var s;if(s=Lo(r.ownerDocument.documentElement))return s*=n.value;a.addUnresolveProperty(r,t)}else a.addUnresolveProperty(r,t);return 0}},t}(),zo=function(){function t(){this.mixer=Ui}return t.prototype.parser=function(t){var e=Ii(jt(t)?[t]:t);return 1===e.length?[e[0],e[0]]:[e[0],e[1]]},t.prototype.calculator=function(t,e,n){return n.map((function(t){return t.value}))},t}(),Fo=function(){function t(){this.mixer=Ui}return t.prototype.parser=function(t){var e=Ii(jt(t)?[t]:t);return 1===e.length?[e[0],e[0],e[0],e[0]]:2===e.length?[e[0],e[1],e[0],e[1]]:3===e.length?[e[0],e[1],e[2],e[1]]:[e[0],e[1],e[2],e[3]]},t.prototype.calculator=function(t,e,n){return n.map((function(t){return t.value}))},t}(),Bo=y();function Go(t,e){var n=e.parsedStyle.defX||0,r=e.parsedStyle.defY||0;return e.resetLocalTransform(),e.setLocalPosition(n,r),t.forEach((function(t){var i=t.t,o=t.d;if("scale"===i){var a=(null==o?void 0:o.map((function(t){return t.value})))||[1,1];e.scaleLocal(a[0],a[1],1)}else if("scalex"===i){a=(null==o?void 0:o.map((function(t){return t.value})))||[1];e.scaleLocal(a[0],1,1)}else if("scaley"===i){a=(null==o?void 0:o.map((function(t){return t.value})))||[1];e.scaleLocal(1,a[0],1)}else if("scalez"===i){a=(null==o?void 0:o.map((function(t){return t.value})))||[1];e.scaleLocal(1,1,a[0])}else if("scale3d"===i){a=(null==o?void 0:o.map((function(t){return t.value})))||[1,1,1];e.scaleLocal(a[0],a[1],a[2])}else if("translate"===i){var s=o||[Yr,Yr];e.translateLocal(s[0].value,s[1].value,0)}else if("translatex"===i){s=o||[Yr];e.translateLocal(s[0].value,0,0)}else if("translatey"===i){s=o||[Yr];e.translateLocal(0,s[0].value,0)}else if("translatez"===i){s=o||[Yr];e.translateLocal(0,0,s[0].value)}else if("translate3d"===i){s=o||[Yr,Yr,Yr];e.translateLocal(s[0].value,s[1].value,s[2].value)}else if("rotate"===i){var u=o||[$r];e.rotateLocal(0,0,Ri(u[0]))}else if("rotatex"===i){u=o||[$r];e.rotateLocal(Ri(u[0]),0,0)}else if("rotatey"===i){u=o||[$r];e.rotateLocal(0,Ri(u[0]),0)}else if("rotatez"===i){u=o||[$r];e.rotateLocal(0,0,Ri(u[0]))}else if("rotate3d"===i);else if("skew"===i){var l=(null==o?void 0:o.map((function(t){return t.value})))||[0,0];e.setLocalSkew(Qn(l[0]),Qn(l[1]))}else if("skewx"===i){l=(null==o?void 0:o.map((function(t){return t.value})))||[0];e.setLocalSkew(Qn(l[0]),e.getLocalSkew()[1])}else if("skewy"===i){l=(null==o?void 0:o.map((function(t){return t.value})))||[0];e.setLocalSkew(e.getLocalSkew()[0],Qn(l[0]))}else if("matrix"===i){var d=c(o.map((function(t){return t.value})),6),f=d[0],p=d[1],g=d[2],m=d[3],v=d[4],y=d[5];e.setLocalTransform(b(Bo,f,p,0,0,g,m,0,0,0,0,1,0,v+n,y+r,0,1))}else"matrix3d"===i&&(b.apply(X,h([Bo],c(o.map((function(t){return t.value}))),!1)),Bo[12]+=n,Bo[13]+=r,e.setLocalTransform(Bo))})),e.getLocalTransform()}var jo=function(t){function e(){return null!==t&&t.apply(this,arguments)||this}return r(e,t),e.prototype.postProcessor=function(t,e){var n,r,i;switch(t.nodeName){case jn.CIRCLE:case jn.ELLIPSE:var o=t.parsedStyle,a=o.cx,s=o.cy,u=o.cz;Pt(a)||(n=a),Pt(s)||(r=s),Pt(u)||(i=u);break;case jn.LINE:var h=t.parsedStyle,l=h.x1,d=h.x2,f=h.y1,p=h.y2;n=Math.min(l,d),r=Math.min(f,p),i=0;break;case jn.RECT:case jn.IMAGE:case jn.GROUP:case jn.HTML:case jn.TEXT:case jn.MESH:Pt(t.parsedStyle.x)||(n=t.parsedStyle.x),Pt(t.parsedStyle.y)||(r=t.parsedStyle.y),Pt(t.parsedStyle.z)||(i=t.parsedStyle.z)}if(t.nodeName!==jn.PATH&&t.nodeName!==jn.POLYLINE&&t.nodeName!==jn.POLYGON&&(t.parsedStyle.defX=n||0,t.parsedStyle.defY=r||0),(!Pt(n)||!Pt(r)||!Pt(i))&&-1===e.indexOf("transform")){var g=t.parsedStyle.transform;if(g&&g.length)Go(g,t);else{var m=c(t.getLocalPosition(),3),v=m[0],y=m[1],E=m[2];t.setLocalPosition(Pt(n)?v:n,Pt(r)?y:r,Pt(i)?E:i)}}},e}(_o),Vo=function(){function t(){}return t.prototype.calculator=function(t,e,n,r){n instanceof Fr&&(n=null);var i=null==n?void 0:n.cloneNode(!0);return i&&(i.style.isMarker=!0),i},t}(),Uo=function(){function t(){this.mixer=ji,this.parser=Gi,this.parserUnmemoize=Bi,this.parserWithCSSDisabled=null}return t.prototype.calculator=function(t,e,n){return n.value},t}(),Wo=function(){function t(){this.parser=Gi,this.parserUnmemoize=Bi,this.parserWithCSSDisabled=null,this.mixer=Vi(0,1)}return t.prototype.calculator=function(t,e,n){return n.value},t.prototype.postProcessor=function(t){var e=t.parsedStyle,n=e.offsetPath,r=e.offsetDistance;if(n){var i=n.nodeName;if(i===jn.LINE||i===jn.PATH||i===jn.POLYLINE){var o=n.getPoint(r);o&&(t.parsedStyle.defX=o.x,t.parsedStyle.defY=o.y,t.setLocalPosition(o.x,o.y))}}},t}(),Ho=function(){function t(){this.parser=Gi,this.parserUnmemoize=Bi,this.parserWithCSSDisabled=null,this.mixer=Vi(0,1)}return t.prototype.calculator=function(t,e,n){return n.value},t}(),qo=function(){function t(){this.parser=ro,this.parserWithCSSDisabled=ro,this.mixer=io}return t.prototype.calculator=function(t,e,n){return n instanceof Fr&&"unset"===n.value?{absolutePath:[],hasArc:!1,segments:[],polygons:[],polylines:[],curve:null,totalLength:0,rect:new vr(0,0,0,0)}:n},t.prototype.postProcessor=function(t,e){if(t.parsedStyle.defX=t.parsedStyle.path.rect.x,t.parsedStyle.defY=t.parsedStyle.path.rect.y,t.nodeName===jn.PATH&&-1===e.indexOf("transform")){var n=t.parsedStyle,r=n.defX,i=void 0===r?0:r,o=n.defY,a=void 0===o?0:o;t.setLocalPosition(i,a)}},t}(),Yo=function(){function t(){this.parser=oo,this.mixer=ao}return t.prototype.postProcessor=function(t,e){if((t.nodeName===jn.POLYGON||t.nodeName===jn.POLYLINE)&&-1===e.indexOf("transform")){var n=t.parsedStyle,r=n.defX,i=n.defY;t.setLocalPosition(r,i)}},t}(),Xo=function(t){function e(){var e=t.apply(this,h([],c(arguments),!1))||this;return e.mixer=Vi(0,1/0),e}return r(e,t),e}(_o),Ko=function(){function t(){}return t.prototype.calculator=function(t,e,n,r){return n instanceof Fr?"unset"===n.value?"":n.value:"".concat(n)},t.prototype.postProcessor=function(t){t.nodeValue="".concat(t.parsedStyle.text)||""},t}(),$o=function(){function t(){}return t.prototype.calculator=function(t,e,n,r){var i=r.getAttribute("text");if(i){var o=i;"capitalize"===n.value?o=i.charAt(0).toUpperCase()+i.slice(1):"lowercase"===n.value?o=i.toLowerCase():"uppercase"===n.value&&(o=i.toUpperCase()),r.parsedStyle.text=o}return n.value},t}(),Zo={},Qo=0;var Jo="undefined"!=typeof window&&void 0!==window.document;function ta(t){return!!t.getAttribute}function ea(t,e){var n=Number(t.parsedStyle.zIndex),r=Number(e.parsedStyle.zIndex);if(n===r){var i=t.parentNode;if(i){var o=i.childNodes||[];return o.indexOf(t)-o.indexOf(e)}}return n-r}function na(t){var e,n=t;do{if(null===(e=n.parsedStyle)||void 0===e?void 0:e.clipPath)return n;n=n.parentElement}while(null!==n);return null}function ra(t,e){if(Jo)return document.defaultView.getComputedStyle(t,null).getPropertyValue(e)}var ia={touchstart:"pointerdown",touchend:"pointerup",touchendoutside:"pointerupoutside",touchmove:"pointermove",touchcancel:"pointercancel"},oa="object"==typeof performance&&performance.now?performance:Date;function aa(t,e,n){var r=!1,i=!1,o=!!e&&!e.isNone,a=!!n&&!n.isNone;return"visiblepainted"===t||"painted"===t||"auto"===t?(r=o,i=a):"visiblefill"===t||"fill"===t?r=!0:"visiblestroke"===t||"stroke"===t?i=!0:"visible"!==t&&"all"!==t||(r=!0,i=!0),[r,i]}var sa=1,ua="object"==typeof self&&self.self==self?self:"object"==typeof global&&global.global==global?global:{},ca=Date.now(),ha={},la=Date.now(),da=function(t){if("function"!=typeof t)throw new TypeError(t+" is not a function");var e=Date.now(),n=e-la,r=n>16?0:16-n,i=sa++;return ha[i]=t,Object.keys(ha).length>1||setTimeout((function(){la=e;var t=ha;ha={},Object.keys(t).forEach((function(e){return t[e](ua.performance&&"function"==typeof ua.performance.now?ua.performance.now():Date.now()-ca)}))}),r),i},fa=function(t){delete ha[t]},pa=function(t){return"string"!=typeof t?da:""===t?ua.requestAnimationFrame:ua[t+"RequestAnimationFrame"]},ga=function(t,e){for(var n=0;void 0!==t[n];){if(e(t[n]))return t[n];n+=1}}(["","webkit","moz","ms","o"],(function(t){return!!pa(t)})),ma=pa(ga),va=function(t){return"string"!=typeof t?fa:""===t?ua.cancelAnimationFrame:ua[t+"CancelAnimationFrame"]||ua[t+"CancelRequestAnimationFrame"]}(ga);ua.requestAnimationFrame=ma,ua.cancelAnimationFrame=va;var ya=function(){function t(){this.callbacks=[]}return t.prototype.getCallbacksNum=function(){return this.callbacks.length},t.prototype.tapPromise=function(t,e){this.callbacks.push(e)},t.prototype.promise=function(){for(var t=[],e=0;e<arguments.length;e++)t[e]=arguments[e];return Promise.all(this.callbacks.map((function(e){return e.apply(void 0,h([],c(t),!1))})))},t}(),Ea=function(){function t(){this.callbacks=[]}return t.prototype.tapPromise=function(t,e){this.callbacks.push(e)},t.prototype.promise=function(){for(var t=[],e=0;e<arguments.length;e++)t[e]=arguments[e];return a(this,void 0,void 0,(function(){var e,n,r;return s(this,(function(i){switch(i.label){case 0:return this.callbacks.length?[4,(r=this.callbacks)[0].apply(r,h([],c(t),!1))]:[3,6];case 1:e=i.sent(),n=0,i.label=2;case 2:return n<this.callbacks.length-1?[4,(0,this.callbacks[n])(e)]:[3,5];case 3:e=i.sent(),i.label=4;case 4:return n++,[3,2];case 5:return[2,e];case 6:return[2,null]}}))}))},t}(),xa=function(){function t(){this.callbacks=[]}return t.prototype.tap=function(t,e){this.callbacks.push(e)},t.prototype.call=function(){var t=arguments;this.callbacks.forEach((function(e){e.apply(void 0,t)}))},t}(),ba=function(){function t(){this.callbacks=[]}return t.prototype.tap=function(t,e){this.callbacks.push(e)},t.prototype.call=function(){if(this.callbacks.length){for(var t=arguments,e=this.callbacks[0].apply(void 0,t),n=0;n<this.callbacks.length-1;n++){e=(0,this.callbacks[n])(e)}return e}return null},t}(),wa=["serif","sans-serif","monospace","cursive","fantasy","system-ui"],Ma=/([\"\'])[^\'\"]+\1/;var Na=function(){function t(){this.parser=lo,this.parserUnmemoize=fo,this.parserWithCSSDisabled=fo,this.mixer=wo}return t.prototype.calculator=function(t,e,n,r){return n instanceof Fr?[]:n},t.prototype.postProcessor=function(t){Go(t.parsedStyle.transform,t)},t}(),Sa=function(){this.parser=Mo,this.parserUnmemoize=No},Ta=function(){function t(){this.parser=Gi,this.parserUnmemoize=Bi}return t.prototype.calculator=function(t,e,n,r){return n.value},t.prototype.postProcessor=function(t){if(t.parentNode){var e=t.parentNode,n=e.renderable,r=e.sortable;n&&(n.dirty=!0),r&&(r.dirty=!0,r.dirtyReason=Kr.Z_INDEX_CHANGED)}},t}(),Pa=function(){function t(){}return t.prototype.update=function(t,e){var n=t.r;return{width:2*n,height:2*n}},t}(),Ca=function(){function t(){}return t.prototype.update=function(t,e){return{width:2*t.rx,height:2*t.ry}},t}(),ka=function(){function t(){}return t.prototype.update=function(t){var e=t.x1,n=t.y1,r=t.x2,i=t.y2,o=Math.min(e,r),a=Math.max(e,r),s=Math.min(n,i);return{width:a-o,height:Math.max(n,i)-s}},t}(),Aa=function(){function t(){}return t.prototype.update=function(t){var e=t.path.rect;return{width:e.width,height:e.height}},t}(),Oa=function(){function t(){}return t.prototype.update=function(t){if(t.points&&At(t.points.points)){var e=t.points.points,n=Math.min.apply(Math,h([],c(e.map((function(t){return t[0]}))),!1)),r=Math.max.apply(Math,h([],c(e.map((function(t){return t[0]}))),!1)),i=Math.min.apply(Math,h([],c(e.map((function(t){return t[1]}))),!1));return{width:r-n,height:Math.max.apply(Math,h([],c(e.map((function(t){return t[1]}))),!1))-i}}return{width:0,height:0}},t}(),Ra=function(){function t(){}return t.prototype.update=function(t,e){var n=t.img,r=t.width,i=void 0===r?0:r,o=t.height,a=i,s=void 0===o?0:o;return n&&!zt(n)&&(a||(a=n.width,t.width=a),s||(s=n.height,t.height=s)),{width:a,height:s}},t}(),Da=function(){function t(t){this.globalRuntime=t}return t.prototype.isReadyToMeasure=function(t,e){var n=t.text,r=t.textAlign,i=t.textBaseline,o=t.fontSize,a=t.fontStyle,s=t.fontWeight,u=t.fontVariant,c=t.lineWidth;return n&&o&&a&&s&&u&&r&&i&&!Pt(c)},t.prototype.update=function(t,e){var n,r,i=t.text,o=t.textAlign,a=t.lineWidth,s=t.textBaseline,u=t.dx,c=t.dy;if(!this.isReadyToMeasure(t,e))return t.metrics={font:"",width:0,height:0,lines:[],lineWidths:[],lineHeight:0,maxLineWidth:0,fontProperties:{ascent:0,descent:0,fontSize:0},lineMetrics:[]},{width:0,height:0,x:0,y:0,offsetX:0,offsetY:0};var h=((null===(r=null===(n=null==e?void 0:e.ownerDocument)||void 0===n?void 0:n.defaultView)||void 0===r?void 0:r.getConfig())||{}).offscreenCanvas,l=this.globalRuntime.textService.measureText(i,t,h);t.metrics=l;var d=l.width,f=l.height,p=l.lineHeight,g=l.fontProperties,m=[d/2,f/2,0],v=[0,1],y=0;"center"===o||"middle"===o?(y=a/2,v=[.5,1]):"right"!==o&&"end"!==o||(y=a,v=[1,1]);var E=0;return"middle"===s?E=m[1]:"top"===s||"hanging"===s?E=2*m[1]:"alphabetic"===s?E=this.globalRuntime.enableCSSParsing?p-g.ascent:0:"bottom"!==s&&"ideographic"!==s||(E=0),u&&(y+=u),c&&(E+=c),t.anchor=[v[0],v[1],0],{width:2*m[0],height:2*m[1],offsetX:y,offsetY:E}},t}();var Ia,La=function(){function t(e){this.eventPhase=t.prototype.NONE,this.bubbles=!0,this.cancelBubble=!0,this.cancelable=!1,this.defaultPrevented=!1,this.propagationStopped=!1,this.propagationImmediatelyStopped=!1,this.layer=new mr,this.page=new mr,this.canvas=new mr,this.viewport=new mr,this.composed=!1,this.NONE=0,this.CAPTURING_PHASE=1,this.AT_TARGET=2,this.BUBBLING_PHASE=3,this.manager=e}return Object.defineProperty(t.prototype,"name",{get:function(){return this.type},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"layerX",{get:function(){return this.layer.x},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"layerY",{get:function(){return this.layer.y},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"pageX",{get:function(){return this.page.x},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"pageY",{get:function(){return this.page.y},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"x",{get:function(){return this.canvas.x},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"y",{get:function(){return this.canvas.y},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"canvasX",{get:function(){return this.canvas.x},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"canvasY",{get:function(){return this.canvas.y},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"viewportX",{get:function(){return this.viewport.x},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"viewportY",{get:function(){return this.viewport.y},enumerable:!1,configurable:!0}),t.prototype.composedPath=function(){return!this.manager||this.path&&this.path[0]===this.target||(this.path=this.target?this.manager.propagationPath(this.target):[]),this.path},Object.defineProperty(t.prototype,"propagationPath",{get:function(){return this.composedPath()},enumerable:!1,configurable:!0}),t.prototype.preventDefault=function(){this.nativeEvent instanceof Event&&this.nativeEvent.cancelable&&this.nativeEvent.preventDefault(),this.defaultPrevented=!0},t.prototype.stopImmediatePropagation=function(){this.propagationImmediatelyStopped=!0},t.prototype.stopPropagation=function(){this.propagationStopped=!0},t.prototype.initEvent=function(){},t.prototype.initUIEvent=function(){},t.prototype.clone=function(){throw new Error(yr)},t}(),_a=function(t){function e(){var e=t.apply(this,h([],c(arguments),!1))||this;return e.client=new mr,e.movement=new mr,e.offset=new mr,e.global=new mr,e.screen=new mr,e}return r(e,t),Object.defineProperty(e.prototype,"clientX",{get:function(){return this.client.x},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"clientY",{get:function(){return this.client.y},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"movementX",{get:function(){return this.movement.x},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"movementY",{get:function(){return this.movement.y},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"offsetX",{get:function(){return this.offset.x},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"offsetY",{get:function(){return this.offset.y},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"globalX",{get:function(){return this.global.x},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"globalY",{get:function(){return this.global.y},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"screenX",{get:function(){return this.screen.x},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"screenY",{get:function(){return this.screen.y},enumerable:!1,configurable:!0}),e.prototype.getModifierState=function(t){return"getModifierState"in this.nativeEvent&&this.nativeEvent.getModifierState(t)},e.prototype.initMouseEvent=function(){throw new Error(yr)},e}(La),za=function(t){function e(){var e=t.apply(this,h([],c(arguments),!1))||this;return e.width=0,e.height=0,e.isPrimary=!1,e}return r(e,t),e.prototype.getCoalescedEvents=function(){return"pointermove"===this.type||"mousemove"===this.type||"touchmove"===this.type?[this]:[]},e.prototype.getPredictedEvents=function(){throw new Error("getPredictedEvents is not supported!")},e.prototype.clone=function(){return this.manager.clonePointerEvent(this)},e}(_a),Fa=function(t){function e(){return null!==t&&t.apply(this,arguments)||this}return r(e,t),e.prototype.clone=function(){return this.manager.cloneWheelEvent(this)},e}(_a),Ba=function(t){function e(e,n){var r=t.call(this,null)||this;return r.type=e,r.detail=n,Object.assign(r,n),r}return r(e,t),e}(La),Ga=function(){function t(){this.emitter=new p}return t.prototype.on=function(t,e,n){return this.addEventListener(t,e,n),this},t.prototype.addEventListener=function(t,e,n){var r=Xt(n)&&n||Ot(n)&&n.capture,i=Ot(n)&&n.once,o=jr(e)?void 0:e,a=!1,s="";if(t.indexOf(":")>-1){var u=c(t.split(":"),2),l=u[0];t=u[1],s=l,a=!0}if(t=r?"".concat(t,"capture"):t,e=jr(e)?e:e.handleEvent,a){var d=e;e=function(){for(var t,e=[],n=0;n<arguments.length;n++)e[n]=arguments[n];(null===(t=e[0].target)||void 0===t?void 0:t.name)===s&&d.apply(void 0,h([],c(e),!1))}}return i?this.emitter.once(t,e,o):this.emitter.on(t,e,o),this},t.prototype.off=function(t,e,n){return t?this.removeEventListener(t,e,n):this.removeAllEventListeners(),this},t.prototype.removeAllEventListeners=function(){this.emitter.removeAllListeners()},t.prototype.removeEventListener=function(t,e,n){var r=Xt(n)&&n||Ot(n)&&n.capture,i=jr(e)?void 0:e;return t=r?"".concat(t,"capture"):t,e=jr(e)?e:null==e?void 0:e.handleEvent,this.emitter.off(t,e,i),this},t.prototype.emit=function(t,e){this.dispatchEvent(new Ba(t,e))},t.prototype.dispatchEvent=function(t,e){var n,r,i;if(void 0===e&&(e=!1),!t.type)throw new Error("DisplayObject cannot propagate events outside of the Federated Events API");if(i=this.document?this:this.defaultView?this.defaultView:null===(n=this.ownerDocument)||void 0===n?void 0:n.defaultView){if(t.manager=i.getEventService()||null,!t.manager)return!1;t.defaultPrevented=!1,t.path=[],e||(t.target=this),null===(r=t.manager)||void 0===r||r.dispatchEvent(t,t.type,e)}return!t.defaultPrevented},t}(),ja=function(t){function e(){var e=t.apply(this,h([],c(arguments),!1))||this;return e.shadow=!1,e.ownerDocument=null,e.isConnected=!1,e.baseURI="",e.childNodes=[],e.nodeType=0,e.nodeName="",e.nodeValue=null,e.parentNode=null,e}return r(e,t),e.isNode=function(t){return!!t.childNodes},Object.defineProperty(e.prototype,"textContent",{get:function(){var t,e,n="";this.nodeName===jn.TEXT&&(n+=this.style.text);try{for(var r=u(this.childNodes),i=r.next();!i.done;i=r.next()){var o=i.value;o.nodeName===jn.TEXT?n+=o.nodeValue:n+=o.textContent}}catch(e){t={error:e}}finally{try{i&&!i.done&&(e=r.return)&&e.call(r)}finally{if(t)throw t.error}}return n},set:function(t){var e=this;this.childNodes.slice().forEach((function(t){e.removeChild(t)})),this.nodeName===jn.TEXT&&(this.style.text="".concat(t))},enumerable:!1,configurable:!0}),e.prototype.getRootNode=function(t){return void 0===t&&(t={}),this.parentNode?this.parentNode.getRootNode(t):t.composed&&this.host?this.host.getRootNode(t):this},e.prototype.hasChildNodes=function(){return this.childNodes.length>0},e.prototype.isDefaultNamespace=function(t){throw new Error(yr)},e.prototype.lookupNamespaceURI=function(t){throw new Error(yr)},e.prototype.lookupPrefix=function(t){throw new Error(yr)},e.prototype.normalize=function(){throw new Error(yr)},e.prototype.isEqualNode=function(t){return this===t},e.prototype.isSameNode=function(t){return this.isEqualNode(t)},Object.defineProperty(e.prototype,"parent",{get:function(){return this.parentNode},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"parentElement",{get:function(){return null},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"nextSibling",{get:function(){return null},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"previousSibling",{get:function(){return null},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"firstChild",{get:function(){return this.childNodes.length>0?this.childNodes[0]:null},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"lastChild",{get:function(){return this.childNodes.length>0?this.childNodes[this.childNodes.length-1]:null},enumerable:!1,configurable:!0}),e.prototype.compareDocumentPosition=function(t){var n;if(t===this)return 0;for(var r=t,i=this,o=[r],a=[i];null!==(n=r.parentNode)&&void 0!==n?n:i.parentNode;)r=r.parentNode?(o.push(r.parentNode),r.parentNode):r,i=i.parentNode?(a.push(i.parentNode),i.parentNode):i;if(r!==i)return e.DOCUMENT_POSITION_DISCONNECTED|e.DOCUMENT_POSITION_IMPLEMENTATION_SPECIFIC|e.DOCUMENT_POSITION_PRECEDING;var s=o.length>a.length?o:a,u=s===o?a:o;if(s[s.length-u.length]===u[0])return s===o?e.DOCUMENT_POSITION_CONTAINED_BY|e.DOCUMENT_POSITION_FOLLOWING:e.DOCUMENT_POSITION_CONTAINS|e.DOCUMENT_POSITION_PRECEDING;for(var c=s.length-u.length,h=u.length-1;h>=0;h--){var l=u[h],d=s[c+h];if(d!==l){var f=l.parentNode.childNodes;return f.indexOf(l)<f.indexOf(d)?u===o?e.DOCUMENT_POSITION_PRECEDING:e.DOCUMENT_POSITION_FOLLOWING:s===o?e.DOCUMENT_POSITION_PRECEDING:e.DOCUMENT_POSITION_FOLLOWING}}return e.DOCUMENT_POSITION_FOLLOWING},e.prototype.contain=function(t){return this.contains(t)},e.prototype.contains=function(t){for(var e=t;e&&this!==e;)e=e.parentNode;return!!e},e.prototype.getAncestor=function(t){for(var e=this;t>0&&e;)e=e.parentNode,t--;return e},e.prototype.forEach=function(t,e){void 0===e&&(e=!1),t(this)||(e?this.childNodes.slice():this.childNodes).forEach((function(e){e.forEach(t)}))},e.DOCUMENT_POSITION_DISCONNECTED=1,e.DOCUMENT_POSITION_PRECEDING=2,e.DOCUMENT_POSITION_FOLLOWING=4,e.DOCUMENT_POSITION_CONTAINS=8,e.DOCUMENT_POSITION_CONTAINED_BY=16,e.DOCUMENT_POSITION_IMPLEMENTATION_SPECIFIC=32,e}(Ga),Va=function(){function t(t,e){var n=this;this.globalRuntime=t,this.context=e,this.emitter=new p,this.nativeHTMLMap=new WeakMap,this.cursor="default",this.mappingTable={},this.mappingState={trackingData:{}},this.eventPool=new Map,this.tmpMatrix=y(),this.tmpVec3=K(),this.onPointerDown=function(t){var e=n.createPointerEvent(t);if(n.dispatchEvent(e,"pointerdown"),"touch"===e.pointerType)n.dispatchEvent(e,"touchstart");else if("mouse"===e.pointerType||"pen"===e.pointerType){var r=2===e.button;n.dispatchEvent(e,r?"rightdown":"mousedown")}n.trackingData(t.pointerId).pressTargetsByButton[t.button]=e.composedPath(),n.freeEvent(e)},this.onPointerUp=function(t){var e,r=oa.now(),i=n.createPointerEvent(t,void 0,void 0,n.context.config.alwaysTriggerPointerEventOnCanvas?n.rootTarget:void 0);if(n.dispatchEvent(i,"pointerup"),"touch"===i.pointerType)n.dispatchEvent(i,"touchend");else if("mouse"===i.pointerType||"pen"===i.pointerType){var o=2===i.button;n.dispatchEvent(i,o?"rightup":"mouseup")}var a=n.trackingData(t.pointerId),s=n.findMountedTarget(a.pressTargetsByButton[t.button]),u=s;if(s&&!i.composedPath().includes(s)){for(var c=s;c&&!i.composedPath().includes(c);){if(i.currentTarget=c,n.notifyTarget(i,"pointerupoutside"),"touch"===i.pointerType)n.notifyTarget(i,"touchendoutside");else if("mouse"===i.pointerType||"pen"===i.pointerType){o=2===i.button;n.notifyTarget(i,o?"rightupoutside":"mouseupoutside")}ja.isNode(c)&&(c=c.parentNode)}delete a.pressTargetsByButton[t.button],u=c}if(u){var h=n.clonePointerEvent(i,"click");h.target=u,h.path=[],a.clicksByButton[t.button]||(a.clicksByButton[t.button]={clickCount:0,target:h.target,timeStamp:r});var l=a.clicksByButton[t.button];l.target===h.target&&r-l.timeStamp<200?++l.clickCount:l.clickCount=1,l.target=h.target,l.timeStamp=r,h.detail=l.clickCount,(null===(e=i.detail)||void 0===e?void 0:e.preventClick)||(n.context.config.useNativeClickEvent||"mouse"!==h.pointerType&&"touch"!==h.pointerType||n.dispatchEvent(h,"click"),n.dispatchEvent(h,"pointertap")),n.freeEvent(h)}n.freeEvent(i)},this.onPointerMove=function(t){var e=n.createPointerEvent(t,void 0,void 0,n.context.config.alwaysTriggerPointerEventOnCanvas?n.rootTarget:void 0),r="mouse"===e.pointerType||"pen"===e.pointerType,i=n.trackingData(t.pointerId),o=n.findMountedTarget(i.overTargets);if(i.overTargets&&o!==e.target){var a="mousemove"===t.type?"mouseout":"pointerout",s=n.createPointerEvent(t,a,o||void 0);if(n.dispatchEvent(s,"pointerout"),r&&n.dispatchEvent(s,"mouseout"),!e.composedPath().includes(o)){var u=n.createPointerEvent(t,"pointerleave",o||void 0);for(u.eventPhase=u.AT_TARGET;u.target&&!e.composedPath().includes(u.target);)u.currentTarget=u.target,n.notifyTarget(u),r&&n.notifyTarget(u,"mouseleave"),ja.isNode(u.target)&&(u.target=u.target.parentNode);n.freeEvent(u)}n.freeEvent(s)}if(o!==e.target){var c="mousemove"===t.type?"mouseover":"pointerover",h=n.clonePointerEvent(e,c);n.dispatchEvent(h,"pointerover"),r&&n.dispatchEvent(h,"mouseover");for(var l=o&&ja.isNode(o)&&o.parentNode;l&&l!==(ja.isNode(n.rootTarget)&&n.rootTarget.parentNode)&&l!==e.target;)l=l.parentNode;if(!l||l===(ja.isNode(n.rootTarget)&&n.rootTarget.parentNode)){var d=n.clonePointerEvent(e,"pointerenter");for(d.eventPhase=d.AT_TARGET;d.target&&d.target!==o&&d.target!==(ja.isNode(n.rootTarget)&&n.rootTarget.parentNode);)d.currentTarget=d.target,n.notifyTarget(d),r&&n.notifyTarget(d,"mouseenter"),ja.isNode(d.target)&&(d.target=d.target.parentNode);n.freeEvent(d)}n.freeEvent(h)}n.dispatchEvent(e,"pointermove"),"touch"===e.pointerType&&n.dispatchEvent(e,"touchmove"),r&&(n.dispatchEvent(e,"mousemove"),n.cursor=n.getCursor(e.target)),i.overTargets=e.composedPath(),n.freeEvent(e)},this.onPointerOut=function(t){var e=n.trackingData(t.pointerId);if(e.overTargets){var r="mouse"===t.pointerType||"pen"===t.pointerType,i=n.findMountedTarget(e.overTargets),o=n.createPointerEvent(t,"pointerout",i||void 0);n.dispatchEvent(o),r&&n.dispatchEvent(o,"mouseout");var a=n.createPointerEvent(t,"pointerleave",i||void 0);for(a.eventPhase=a.AT_TARGET;a.target&&a.target!==(ja.isNode(n.rootTarget)&&n.rootTarget.parentNode);)a.currentTarget=a.target,n.notifyTarget(a),r&&n.notifyTarget(a,"mouseleave"),ja.isNode(a.target)&&(a.target=a.target.parentNode);e.overTargets=null,n.freeEvent(o),n.freeEvent(a)}n.cursor=null},this.onPointerOver=function(t){var e=n.trackingData(t.pointerId),r=n.createPointerEvent(t),i="mouse"===r.pointerType||"pen"===r.pointerType;n.dispatchEvent(r,"pointerover"),i&&n.dispatchEvent(r,"mouseover"),"mouse"===r.pointerType&&(n.cursor=n.getCursor(r.target));var o=n.clonePointerEvent(r,"pointerenter");for(o.eventPhase=o.AT_TARGET;o.target&&o.target!==(ja.isNode(n.rootTarget)&&n.rootTarget.parentNode);)o.currentTarget=o.target,n.notifyTarget(o),i&&n.notifyTarget(o,"mouseenter"),ja.isNode(o.target)&&(o.target=o.target.parentNode);e.overTargets=r.composedPath(),n.freeEvent(r),n.freeEvent(o)},this.onPointerUpOutside=function(t){var e=n.trackingData(t.pointerId),r=n.findMountedTarget(e.pressTargetsByButton[t.button]),i=n.createPointerEvent(t);if(r){for(var o=r;o;)i.currentTarget=o,n.notifyTarget(i,"pointerupoutside"),"touch"===i.pointerType||"mouse"!==i.pointerType&&"pen"!==i.pointerType||n.notifyTarget(i,2===i.button?"rightupoutside":"mouseupoutside"),ja.isNode(o)&&(o=o.parentNode);delete e.pressTargetsByButton[t.button]}n.freeEvent(i)},this.onWheel=function(t){var e=n.createWheelEvent(t);n.dispatchEvent(e),n.freeEvent(e)},this.onClick=function(t){if(n.context.config.useNativeClickEvent){var e=n.createPointerEvent(t);n.dispatchEvent(e),n.freeEvent(e)}},this.onPointerCancel=function(t){var e=n.createPointerEvent(t,void 0,void 0,n.context.config.alwaysTriggerPointerEventOnCanvas?n.rootTarget:void 0);n.dispatchEvent(e),n.freeEvent(e)}}return t.prototype.init=function(){this.rootTarget=this.context.renderingContext.root.parentNode,this.addEventMapping("pointerdown",this.onPointerDown),this.addEventMapping("pointerup",this.onPointerUp),this.addEventMapping("pointermove",this.onPointerMove),this.addEventMapping("pointerout",this.onPointerOut),this.addEventMapping("pointerleave",this.onPointerOut),this.addEventMapping("pointercancel",this.onPointerCancel),this.addEventMapping("pointerover",this.onPointerOver),this.addEventMapping("pointerupoutside",this.onPointerUpOutside),this.addEventMapping("wheel",this.onWheel),this.addEventMapping("click",this.onClick)},t.prototype.destroy=function(){this.emitter.removeAllListeners(),this.mappingTable={},this.mappingState={},this.eventPool.clear()},t.prototype.client2Viewport=function(t){var e=this.context.contextService.getBoundingClientRect();return new mr(t.x-((null==e?void 0:e.left)||0),t.y-((null==e?void 0:e.top)||0))},t.prototype.viewport2Client=function(t){var e=this.context.contextService.getBoundingClientRect();return new mr(t.x+((null==e?void 0:e.left)||0),t.y+((null==e?void 0:e.top)||0))},t.prototype.viewport2Canvas=function(t){var e=t.x,n=t.y,r=this.rootTarget.defaultView.getCamera(),i=this.context.config,o=i.width,a=i.height,s=r.getPerspectiveInverse(),u=r.getWorldTransform(),c=T(this.tmpMatrix,u,s),h=tt(this.tmpVec3,e/o*2-1,2*(1-n/a)-1,0);return ut(h,h,c),new mr(h[0],h[1])},t.prototype.canvas2Viewport=function(t){var e=this.rootTarget.defaultView.getCamera(),n=e.getPerspective(),r=e.getViewTransform(),i=T(this.tmpMatrix,n,r),o=tt(this.tmpVec3,t.x,t.y,0);ut(this.tmpVec3,this.tmpVec3,i);var a=this.context.config,s=a.width,u=a.height;return new mr((o[0]+1)/2*s,(1-(o[1]+1)/2)*u)},t.prototype.setPickHandler=function(t){this.pickHandler=t},t.prototype.addEventMapping=function(t,e){this.mappingTable[t]||(this.mappingTable[t]=[]),this.mappingTable[t].push({fn:e,priority:0}),this.mappingTable[t].sort((function(t,e){return t.priority-e.priority}))},t.prototype.mapEvent=function(t){if(this.rootTarget){var e=this.mappingTable[t.type];if(e)for(var n=0,r=e.length;n<r;n++)e[n].fn(t);else console.warn("[EventService]: Event mapping not defined for ".concat(t.type))}},t.prototype.dispatchEvent=function(t,e,n){if(n){t.eventPhase=t.AT_TARGET;var r=this.rootTarget.defaultView||null;t.currentTarget=r,this.notifyListeners(t,e)}else t.propagationStopped=!1,t.propagationImmediatelyStopped=!1,this.propagate(t,e);this.emitter.emit(e||t.type,t)},t.prototype.propagate=function(t,e){if(t.target){var n=t.composedPath();t.eventPhase=t.CAPTURING_PHASE;for(var r=n.length-1;r>=1;r--)if(t.currentTarget=n[r],this.notifyTarget(t,e),t.propagationStopped||t.propagationImmediatelyStopped)return;if(t.eventPhase=t.AT_TARGET,t.currentTarget=t.target,this.notifyTarget(t,e),!t.propagationStopped&&!t.propagationImmediatelyStopped){var i=n.indexOf(t.currentTarget);t.eventPhase=t.BUBBLING_PHASE;for(r=i+1;r<n.length;r++)if(t.currentTarget=n[r],this.notifyTarget(t,e),t.propagationStopped||t.propagationImmediatelyStopped)return}}},t.prototype.propagationPath=function(t){var e=[t],n=this.rootTarget.defaultView||null;if(n&&n===t)return e.unshift(n.document),e;for(var r=0;r<2048&&t!==this.rootTarget;r++)ja.isNode(t)&&t.parentNode&&(e.push(t.parentNode),t=t.parentNode);return n&&e.push(n),e},t.prototype.hitTest=function(t){var e=t.viewportX,n=t.viewportY,r=this.context.config,i=r.width,o=r.height,a=r.disableHitTesting;return e<0||n<0||e>i||n>o?null:!a&&this.pickHandler(t)||this.rootTarget||null},t.prototype.isNativeEventFromCanvas=function(t){var e,n=this.context.contextService.getDomElement(),r=null===(e=t.nativeEvent)||void 0===e?void 0:e.target;if(r){if(r===n)return!0;if(n&&n.contains)return n.contains(r)}return!!t.nativeEvent.composedPath&&t.nativeEvent.composedPath().indexOf(n)>-1},t.prototype.getExistedHTML=function(t){var e,n;if(t.nativeEvent.composedPath)try{for(var r=u(t.nativeEvent.composedPath()),i=r.next();!i.done;i=r.next()){var o=i.value,a=this.nativeHTMLMap.get(o);if(a)return a}}catch(t){e={error:t}}finally{try{i&&!i.done&&(n=r.return)&&n.call(r)}finally{if(e)throw e.error}}return null},t.prototype.pickTarget=function(t){return this.hitTest({clientX:t.clientX,clientY:t.clientY,viewportX:t.viewportX,viewportY:t.viewportY,x:t.canvasX,y:t.canvasY})},t.prototype.createPointerEvent=function(t,e,n,r){var i=this.allocateEvent(za);this.copyPointerData(t,i),this.copyMouseData(t,i),this.copyData(t,i),i.nativeEvent=t.nativeEvent,i.originalEvent=t;var o=this.getExistedHTML(i);return i.target=null!=n?n:o||this.isNativeEventFromCanvas(i)&&this.pickTarget(i)||r,"string"==typeof e&&(i.type=e),i},t.prototype.createWheelEvent=function(t){var e=this.allocateEvent(Fa);this.copyWheelData(t,e),this.copyMouseData(t,e),this.copyData(t,e),e.nativeEvent=t.nativeEvent,e.originalEvent=t;var n=this.getExistedHTML(e);return e.target=n||this.isNativeEventFromCanvas(e)&&this.pickTarget(e),e},t.prototype.trackingData=function(t){return this.mappingState.trackingData[t]||(this.mappingState.trackingData[t]={pressTargetsByButton:{},clicksByButton:{},overTarget:null}),this.mappingState.trackingData[t]},t.prototype.cloneWheelEvent=function(t){var e=this.allocateEvent(Fa);return e.nativeEvent=t.nativeEvent,e.originalEvent=t.originalEvent,this.copyWheelData(t,e),this.copyMouseData(t,e),this.copyData(t,e),e.target=t.target,e.path=t.composedPath().slice(),e.type=t.type,e},t.prototype.clonePointerEvent=function(t,e){var n=this.allocateEvent(za);return n.nativeEvent=t.nativeEvent,n.originalEvent=t.originalEvent,this.copyPointerData(t,n),this.copyMouseData(t,n),this.copyData(t,n),n.target=t.target,n.path=t.composedPath().slice(),n.type=null!=e?e:n.type,n},t.prototype.copyPointerData=function(t,e){e.pointerId=t.pointerId,e.width=t.width,e.height=t.height,e.isPrimary=t.isPrimary,e.pointerType=t.pointerType,e.pressure=t.pressure,e.tangentialPressure=t.tangentialPressure,e.tiltX=t.tiltX,e.tiltY=t.tiltY,e.twist=t.twist},t.prototype.copyMouseData=function(t,e){e.altKey=t.altKey,e.button=t.button,e.buttons=t.buttons,e.ctrlKey=t.ctrlKey,e.metaKey=t.metaKey,e.shiftKey=t.shiftKey,e.client.copyFrom(t.client),e.movement.copyFrom(t.movement),e.canvas.copyFrom(t.canvas),e.screen.copyFrom(t.screen),e.global.copyFrom(t.global),e.offset.copyFrom(t.offset)},t.prototype.copyWheelData=function(t,e){e.deltaMode=t.deltaMode,e.deltaX=t.deltaX,e.deltaY=t.deltaY,e.deltaZ=t.deltaZ},t.prototype.copyData=function(t,e){e.isTrusted=t.isTrusted,e.timeStamp=oa.now(),e.type=t.type,e.detail=t.detail,e.view=t.view,e.page.copyFrom(t.page),e.viewport.copyFrom(t.viewport)},t.prototype.allocateEvent=function(t){this.eventPool.has(t)||this.eventPool.set(t,[]);var e=this.eventPool.get(t).pop()||new t(this);return e.eventPhase=e.NONE,e.currentTarget=null,e.path=[],e.target=null,e},t.prototype.freeEvent=function(t){if(t.manager!==this)throw new Error("It is illegal to free an event not managed by this EventBoundary!");var e=t.constructor;this.eventPool.has(e)||this.eventPool.set(e,[]),this.eventPool.get(e).push(t)},t.prototype.notifyTarget=function(t,e){e=null!=e?e:t.type;var n=t.eventPhase===t.CAPTURING_PHASE||t.eventPhase===t.AT_TARGET?"".concat(e,"capture"):e;this.notifyListeners(t,n),t.eventPhase===t.AT_TARGET&&this.notifyListeners(t,e)},t.prototype.notifyListeners=function(t,e){var n=t.currentTarget.emitter,r=n._events[e];if(r)if("fn"in r)r.once&&n.removeListener(e,r.fn,void 0,!0),r.fn.call(t.currentTarget||r.context,t);else for(var i=0;i<r.length&&!t.propagationImmediatelyStopped;i++)r[i].once&&n.removeListener(e,r[i].fn,void 0,!0),r[i].fn.call(t.currentTarget||r[i].context,t)},t.prototype.findMountedTarget=function(t){if(!t)return null;for(var e=t[t.length-1],n=t.length-2;n>=0;n--){var r=t[n];if(!(r===this.rootTarget||ja.isNode(r)&&r.parentNode===e))break;e=t[n]}return e},t.prototype.getCursor=function(t){for(var e=t;e;){var n=ta(e)&&e.getAttribute("cursor");if(n)return n;e=ja.isNode(e)&&e.parentNode}},t}(),Ua=function(){function t(){}return t.prototype.getOrCreateCanvas=function(t,e){if(this.canvas)return this.canvas;if(t||as.offscreenCanvas)this.canvas=t||as.offscreenCanvas,this.context=this.canvas.getContext("2d",i({willReadFrequently:!0},e));else try{this.canvas=new window.OffscreenCanvas(0,0),this.context=this.canvas.getContext("2d",i({willReadFrequently:!0},e)),this.context&&this.context.measureText||(this.canvas=document.createElement("canvas"),this.context=this.canvas.getContext("2d"))}catch(t){this.canvas=document.createElement("canvas"),this.context=this.canvas.getContext("2d",i({willReadFrequently:!0},e))}return this.canvas.width=10,this.canvas.height=10,this.canvas},t.prototype.getOrCreateContext=function(t,e){return this.context||this.getOrCreateCanvas(t,e),this.context},t}();!function(t){t[t.CAMERA_CHANGED=0]="CAMERA_CHANGED",t[t.DISPLAY_OBJECT_CHANGED=1]="DISPLAY_OBJECT_CHANGED",t[t.NONE=2]="NONE"}(Ia||(Ia={}));var Wa,Ha=function(){function t(t,e){this.globalRuntime=t,this.context=e,this.inited=!1,this.stats={total:0,rendered:0},this.zIndexCounter=0,this.hooks={init:new xa,initAsync:new ya,dirtycheck:new ba,cull:new ba,beginFrame:new xa,beforeRender:new xa,render:new xa,afterRender:new xa,endFrame:new xa,destroy:new xa,pick:new Ea,pickSync:new ba,pointerDown:new xa,pointerUp:new xa,pointerMove:new xa,pointerOut:new xa,pointerOver:new xa,pointerWheel:new xa,pointerCancel:new xa,click:new xa}}return t.prototype.init=function(t){var e=this,n=i(i({},this.globalRuntime),this.context);this.context.renderingPlugins.forEach((function(t){t.apply(n,e.globalRuntime)})),this.hooks.init.call(),0===this.hooks.initAsync.getCallbacksNum()?(this.inited=!0,t()):this.hooks.initAsync.promise().then((function(){e.inited=!0,t()}))},t.prototype.getStats=function(){return this.stats},t.prototype.disableDirtyRectangleRendering=function(){return!this.context.config.renderer.getConfig().enableDirtyRectangleRendering||this.context.renderingContext.renderReasons.has(Ia.CAMERA_CHANGED)},t.prototype.render=function(t,e){var n=this;this.stats.total=0,this.stats.rendered=0,this.zIndexCounter=0;var r=this.context.renderingContext;if(this.globalRuntime.sceneGraphService.syncHierarchy(r.root),this.globalRuntime.sceneGraphService.triggerPendingEvents(),r.renderReasons.size&&this.inited){r.dirtyRectangleRenderingDisabled=this.disableDirtyRectangleRendering();var i=1===r.renderReasons.size&&r.renderReasons.has(Ia.CAMERA_CHANGED),o=!t.disableRenderHooks||!(t.disableRenderHooks&&i);o&&this.renderDisplayObject(r.root,t,r),this.hooks.beginFrame.call(),o&&r.renderListCurrentFrame.forEach((function(t){n.hooks.beforeRender.call(t),n.hooks.render.call(t),n.hooks.afterRender.call(t)})),this.hooks.endFrame.call(),r.renderListCurrentFrame=[],r.renderReasons.clear(),e()}},t.prototype.renderDisplayObject=function(t,e,n){var r=this,i=e.renderer.getConfig(),o=i.enableDirtyCheck,a=i.enableCulling;this.globalRuntime.enableCSSParsing&&this.globalRuntime.styleValueRegistry.recalc(t);var s=t.renderable,u=o?s.dirty||n.dirtyRectangleRenderingDisabled?t:null:t;if(u){var c=a?this.hooks.cull.call(u,this.context.camera):u;c&&(this.stats.rendered++,n.renderListCurrentFrame.push(c))}t.renderable.dirty=!1,t.sortable.renderOrder=this.zIndexCounter++,this.stats.total++;var h=t.sortable;h.dirty&&(this.sort(t,h),h.dirty=!1,h.dirtyChildren=[],h.dirtyReason=void 0),(h.sorted||t.childNodes).forEach((function(t){r.renderDisplayObject(t,e,n)}))},t.prototype.sort=function(t,e){e.sorted&&e.dirtyReason!==Kr.Z_INDEX_CHANGED?e.dirtyChildren.forEach((function(n){if(-1===t.childNodes.indexOf(n)){var r=e.sorted.indexOf(n);r>=0&&e.sorted.splice(r,1)}else if(0===e.sorted.length)e.sorted.push(n);else{var i=function(t,e){for(var n=0,r=t.length;n<r;){var i=n+r>>>1;ea(t[i],e)<0?n=i+1:r=i}return n}(e.sorted,n);e.sorted.splice(i,0,n)}})):e.sorted=t.childNodes.slice().sort(ea)},t.prototype.destroy=function(){this.inited=!1,this.hooks.destroy.call(),this.globalRuntime.sceneGraphService.clearPendingEvents()},t.prototype.dirtify=function(){this.context.renderingContext.renderReasons.add(Ia.DISPLAY_OBJECT_CHANGED)},t}(),qa=/\[\s*(.*)=(.*)\s*\]/,Ya=function(){function t(){}return t.prototype.selectOne=function(t,e){var n=this;if(t.startsWith("."))return e.find((function(e){return((null==e?void 0:e.classList)||[]).indexOf(n.getIdOrClassname(t))>-1}));if(t.startsWith("#"))return e.find((function(e){return e.id===n.getIdOrClassname(t)}));if(t.startsWith("[")){var r=this.getAttribute(t),i=r.name,o=r.value;return i?e.find((function(t){return e!==t&&("name"===i?t.name===o:n.attributeToString(t,i)===o)})):null}return e.find((function(n){return e!==n&&n.nodeName===t}))},t.prototype.selectAll=function(t,e){var n=this;if(t.startsWith("."))return e.findAll((function(r){return e!==r&&((null==r?void 0:r.classList)||[]).indexOf(n.getIdOrClassname(t))>-1}));if(t.startsWith("#"))return e.findAll((function(r){return e!==r&&r.id===n.getIdOrClassname(t)}));if(t.startsWith("[")){var r=this.getAttribute(t),i=r.name,o=r.value;return i?e.findAll((function(t){return e!==t&&("name"===i?t.name===o:n.attributeToString(t,i)===o)})):[]}return e.findAll((function(n){return e!==n&&n.nodeName===t}))},t.prototype.is=function(t,e){if(t.startsWith("."))return e.className===this.getIdOrClassname(t);if(t.startsWith("#"))return e.id===this.getIdOrClassname(t);if(t.startsWith("[")){var n=this.getAttribute(t),r=n.name,i=n.value;return"name"===r?e.name===i:this.attributeToString(e,r)===i}return e.nodeName===t},t.prototype.getIdOrClassname=function(t){return t.substring(1)},t.prototype.getAttribute=function(t){var e=t.match(qa),n="",r="";return e&&e.length>2&&(n=e[1].replace(/"/g,""),r=e[2].replace(/"/g,"")),{name:n,value:r}},t.prototype.attributeToString=function(t,e){if(!t.getAttribute)return"";var n=t.getAttribute(e);return Pt(n)?"":n.toString?n.toString():""},t}(),Xa=function(t){function e(e,n,r,i,o,a,s,u){var c=t.call(this,null)||this;return c.relatedNode=n,c.prevValue=r,c.newValue=i,c.attrName=o,c.attrChange=a,c.prevParsedValue=s,c.newParsedValue=u,c.type=e,c}return r(e,t),e.ADDITION=2,e.MODIFICATION=1,e.REMOVAL=3,e}(La);function Ka(t){var e=t.renderable;e&&(e.renderBoundsDirty=!0,e.boundsDirty=!0)}!function(t){t.REPARENT="reparent",t.DESTROY="destroy",t.ATTR_MODIFIED="DOMAttrModified",t.INSERTED="DOMNodeInserted",t.REMOVED="removed",t.MOUNTED="DOMNodeInsertedIntoDocument",t.UNMOUNTED="DOMNodeRemovedFromDocument",t.BOUNDS_CHANGED="bounds-changed",t.CULLED="culled"}(Wa||(Wa={}));var $a,Za,Qa,Ja=new Xa(Wa.REPARENT,null,"","","",0,"",""),ts=function(){function t(t){var e,n,r,i,o,a,s,u,c=this;this.runtime=t,this.pendingEvents=[],this.boundsChangedEvent=new Ba(Wa.BOUNDS_CHANGED),this.rotate=(e=pt(),function(t,n,r,i){void 0===r&&(r=0),void 0===i&&(i=0),"number"==typeof n&&(n=Q(n,r,i));var o=t.transformable;if(null!==t.parentNode&&t.parentNode.transformable){var a=pt();yt(a,n[0],n[1],n[2]);var s=c.getRotation(t),u=c.getRotation(t.parentNode);xt(e,u),vt(e,e),mt(a,e,a),mt(o.localRotation,a,s),wt(o.localRotation,o.localRotation),c.dirtifyLocal(t,o)}else c.rotateLocal(t,n)}),this.rotateLocal=(n=pt(),function(t,e,r,i){void 0===r&&(r=0),void 0===i&&(i=0),"number"==typeof e&&(e=Q(e,r,i));var o=t.transformable;yt(n,e[0],e[1],e[2]),bt(o.localRotation,o.localRotation,n),c.dirtifyLocal(t,o)}),this.setEulerAngles=(r=pt(),function(t,e,n,i){void 0===n&&(n=0),void 0===i&&(i=0),"number"==typeof e&&(e=Q(e,n,i));var o=t.transformable;if(null!==t.parentNode&&t.parentNode.transformable){yt(o.localRotation,e[0],e[1],e[2]);var a=c.getRotation(t.parentNode);xt(r,vt(pt(),a)),bt(o.localRotation,o.localRotation,r),c.dirtifyLocal(t,o)}else c.setLocalEulerAngles(t,e)}),this.translateLocal=function(t,e,n,r){void 0===n&&(n=0),void 0===r&&(r=0),"number"==typeof e&&(e=Q(e,n,r));var i=t.transformable;ct(e,K())||(function(t,e,n){var r=n[0],i=n[1],o=n[2],a=n[3],s=e[0],u=e[1],c=e[2],h=i*c-o*u,l=o*s-r*c,d=r*u-i*s,f=i*d-o*l,p=o*h-r*d,g=r*l-i*h,m=2*a;h*=m,l*=m,d*=m,f*=2,p*=2,g*=2,t[0]=s+h+f,t[1]=u+l+p,t[2]=c+d+g}(e,e,i.localRotation),et(i.localPosition,i.localPosition,e),c.dirtifyLocal(t,i))},this.setPosition=(i=y(),o=K(),function(t,e){var n=t.transformable;if(o[0]=e[0],o[1]=e[1],o[2]=e[2]||0,!ct(c.getPosition(t),o)){if(J(n.position,o),null!==t.parentNode&&t.parentNode.transformable){var r=t.parentNode.transformable;x(i,r.worldTransform),N(i,i),ut(n.localPosition,o,i)}else J(n.localPosition,o);c.dirtifyLocal(t,n)}}),this.setLocalPosition=function(){var t=K();return function(e,n){var r=e.transformable;t[0]=n[0],t[1]=n[1],t[2]=n[2]||0,ct(r.localPosition,t)||(J(r.localPosition,t),c.dirtifyLocal(e,r))}}(),this.translate=(a=K(),s=K(),u=K(),function(t,e,n,r){void 0===n&&(n=0),void 0===r&&(r=0),"number"==typeof e&&(e=tt(s,e,n,r)),ct(e,a)||(et(u,c.getPosition(t),e),c.setPosition(t,u))}),this.setRotation=function(){var t=pt();return function(e,n,r,i,o){var a=e.transformable;if("number"==typeof n&&(n=Et(n,r,i,o)),null!==e.parentNode&&e.parentNode.transformable){var s=c.getRotation(e.parentNode);xt(t,s),vt(t,t),mt(a.localRotation,t,n),wt(a.localRotation,a.localRotation),c.dirtifyLocal(e,a)}else c.setLocalRotation(e,n)}},this.displayObjectDependencyMap=new WeakMap,this.calcLocalTransform=function(){var t=y(),e=K(),n=Et(0,0,0,1);return function(r){if(0!==r.localSkew[0]||0!==r.localSkew[1]){if(z(r.localTransform,r.localRotation,r.localPosition,Q(1,1,1),r.origin),0!==r.localSkew[0]||0!==r.localSkew[1]){var i=w(t);i[4]=Math.tan(r.localSkew[0]),i[1]=Math.tan(r.localSkew[1]),T(r.localTransform,r.localTransform,i)}var o=z(t,n,e,r.localScale,r.origin);T(r.localTransform,r.localTransform,o)}else z(r.localTransform,r.localRotation,r.localPosition,r.localScale,r.origin)}}()}return t.prototype.matches=function(t,e){return this.runtime.sceneGraphSelector.is(t,e)},t.prototype.querySelector=function(t,e){return this.runtime.sceneGraphSelector.selectOne(t,e)},t.prototype.querySelectorAll=function(t,e){return this.runtime.sceneGraphSelector.selectAll(t,e)},t.prototype.attach=function(t,e,n){var r,i,o=!1;t.parentNode&&(o=t.parentNode!==e,this.detach(t)),t.parentNode=e,Pt(n)?t.parentNode.childNodes.push(t):t.parentNode.childNodes.splice(n,0,t);var a=e.sortable;((null===(r=null==a?void 0:a.sorted)||void 0===r?void 0:r.length)||(null===(i=t.style)||void 0===i?void 0:i.zIndex))&&(-1===a.dirtyChildren.indexOf(t)&&a.dirtyChildren.push(t),a.dirty=!0,a.dirtyReason=Kr.ADDED);var s=t.transformable;s&&this.dirtifyWorld(t,s),s.frozen&&this.unfreezeParentToRoot(t),o&&t.dispatchEvent(Ja)},t.prototype.detach=function(t){var e,n;if(t.parentNode){var r=t.transformable,i=t.parentNode.sortable;((null===(e=null==i?void 0:i.sorted)||void 0===e?void 0:e.length)||(null===(n=t.style)||void 0===n?void 0:n.zIndex))&&(-1===i.dirtyChildren.indexOf(t)&&i.dirtyChildren.push(t),i.dirty=!0,i.dirtyReason=Kr.REMOVED);var o=t.parentNode.childNodes.indexOf(t);o>-1&&t.parentNode.childNodes.splice(o,1),r&&this.dirtifyWorld(t,r),t.parentNode=null}},t.prototype.getOrigin=function(t){return t.transformable.origin},t.prototype.setOrigin=function(t,e,n,r){void 0===n&&(n=0),void 0===r&&(r=0),"number"==typeof e&&(e=[e,n,r]);var i=t.transformable;if(e[0]!==i.origin[0]||e[1]!==i.origin[1]||e[2]!==i.origin[2]){var o=i.origin;o[0]=e[0],o[1]=e[1],o[2]=e[2]||0,this.dirtifyLocal(t,i)}},t.prototype.setLocalEulerAngles=function(t,e,n,r){void 0===n&&(n=0),void 0===r&&(r=0),"number"==typeof e&&(e=Q(e,n,r));var i=t.transformable;yt(i.localRotation,e[0],e[1],e[2]),this.dirtifyLocal(t,i)},t.prototype.scaleLocal=function(t,e){var n=t.transformable;!function(t,e,n){t[0]=e[0]*n[0],t[1]=e[1]*n[1],t[2]=e[2]*n[2]}(n.localScale,n.localScale,Q(e[0],e[1],e[2]||1)),this.dirtifyLocal(t,n)},t.prototype.setLocalScale=function(t,e){var n=t.transformable,r=Q(e[0],e[1],e[2]||n.localScale[2]);ct(r,n.localScale)||(J(n.localScale,r),this.dirtifyLocal(t,n))},t.prototype.setLocalRotation=function(t,e,n,r,i){"number"==typeof e&&(e=Et(e,n,r,i));var o=t.transformable;xt(o.localRotation,e),this.dirtifyLocal(t,o)},t.prototype.setLocalSkew=function(t,e,n){"number"==typeof e&&(e=function(t,e){var n=new m(2);return n[0]=t,n[1]=e,n}(e,n));var r=t.transformable;!function(t,e){t[0]=e[0],t[1]=e[1]}(r.localSkew,e),this.dirtifyLocal(t,r)},t.prototype.dirtifyLocal=function(t,e){e.localDirtyFlag||(e.localDirtyFlag=!0,e.dirtyFlag||this.dirtifyWorld(t,e))},t.prototype.dirtifyWorld=function(t,e){e.dirtyFlag||this.unfreezeParentToRoot(t),this.dirtifyWorldInternal(t,e),this.dirtifyToRoot(t,!0)},t.prototype.triggerPendingEvents=function(){var t=this,e=new Set,n=function(n,r){n.isConnected&&!e.has(n.entity)&&(t.boundsChangedEvent.detail=r,t.boundsChangedEvent.target=n,n.isMutationObserved?n.dispatchEvent(t.boundsChangedEvent):n.ownerDocument.defaultView.dispatchEvent(t.boundsChangedEvent,!0),e.add(n.entity))};this.pendingEvents.forEach((function(t){var e=c(t,2),r=e[0],i=e[1];i.affectChildren?r.forEach((function(t){n(t,i)})):n(r,i)})),this.clearPendingEvents(),e.clear()},t.prototype.clearPendingEvents=function(){this.pendingEvents=[]},t.prototype.dirtifyToRoot=function(t,e){void 0===e&&(e=!1);var n=t;for(n.renderable&&(n.renderable.dirty=!0);n;)Ka(n),n=n.parentNode;e&&t.forEach((function(t){Ka(t)})),this.informDependentDisplayObjects(t),this.pendingEvents.push([t,{affectChildren:e}])},t.prototype.updateDisplayObjectDependency=function(t,e,n,r){if(e&&e!==n){var i=this.displayObjectDependencyMap.get(e);if(i&&i[t]){var o=i[t].indexOf(r);i[t].splice(o,1)}}if(n){var a=this.displayObjectDependencyMap.get(n);a||(this.displayObjectDependencyMap.set(n,{}),a=this.displayObjectDependencyMap.get(n)),a[t]||(a[t]=[]),a[t].push(r)}},t.prototype.informDependentDisplayObjects=function(t){var e=this,n=this.displayObjectDependencyMap.get(t);n&&Object.keys(n).forEach((function(t){n[t].forEach((function(n){e.dirtifyToRoot(n,!0),n.dispatchEvent(new Xa(Wa.ATTR_MODIFIED,n,e,e,t,Xa.MODIFICATION,e,e)),n.isCustomElement&&n.isConnected&&n.attributeChangedCallback&&n.attributeChangedCallback(t,e,e)}))}))},t.prototype.getPosition=function(t){var e=t.transformable;return I(e.position,this.getWorldTransform(t,e))},t.prototype.getRotation=function(t){var e=t.transformable;return _(e.rotation,this.getWorldTransform(t,e))},t.prototype.getScale=function(t){var e=t.transformable;return L(e.scaling,this.getWorldTransform(t,e))},t.prototype.getWorldTransform=function(t,e){return void 0===e&&(e=t.transformable),e.localDirtyFlag||e.dirtyFlag?(t.parentNode&&t.parentNode.transformable&&this.getWorldTransform(t.parentNode),this.sync(t,e),e.worldTransform):e.worldTransform},t.prototype.getLocalPosition=function(t){return t.transformable.localPosition},t.prototype.getLocalRotation=function(t){return t.transformable.localRotation},t.prototype.getLocalScale=function(t){return t.transformable.localScale},t.prototype.getLocalSkew=function(t){return t.transformable.localSkew},t.prototype.getLocalTransform=function(t){var e=t.transformable;return e.localDirtyFlag&&(this.calcLocalTransform(e),e.localDirtyFlag=!1),e.localTransform},t.prototype.setLocalTransform=function(t,e){var n=I(K(),e),r=_(pt(),e),i=L(K(),e);this.setLocalScale(t,i),this.setLocalPosition(t,n),this.setLocalRotation(t,r)},t.prototype.resetLocalTransform=function(t){this.setLocalScale(t,[1,1,1]),this.setLocalPosition(t,[0,0,0]),this.setLocalEulerAngles(t,[0,0,0]),this.setLocalSkew(t,[0,0])},t.prototype.getTransformedGeometryBounds=function(t,e,n){void 0===e&&(e=!1);var r=this.getGeometryBounds(t,e);if(hr.isEmpty(r))return null;var i=n||new hr;return i.setFromTransformedAABB(r,this.getWorldTransform(t)),i},t.prototype.getGeometryBounds=function(t,e){void 0===e&&(e=!1);var n=t.geometry;return(e?n.renderBounds:n.contentBounds||null)||new hr},t.prototype.getBounds=function(t,e){var n=this;void 0===e&&(e=!1);var r=t.renderable;if(!r.boundsDirty&&!e&&r.bounds)return r.bounds;if(!r.renderBoundsDirty&&e&&r.renderBounds)return r.renderBounds;var i=e?r.renderBounds:r.bounds,o=this.getTransformedGeometryBounds(t,e,i);if(t.childNodes.forEach((function(t){var r=n.getBounds(t,e);r&&(o?o.add(r):(o=i||new hr).update(r.center,r.halfExtents))})),e){var a=na(t);if(a){var s=a.parsedStyle.clipPath.getBounds(e);o?s&&(o=s.intersection(o)):o=s}}return o||(o=new hr),o&&(e?r.renderBounds=o:r.bounds=o),e?r.renderBoundsDirty=!1:r.boundsDirty=!1,o},t.prototype.getLocalBounds=function(t){if(t.parentNode){var e=y();t.parentNode.transformable&&(e=N(y(),this.getWorldTransform(t.parentNode)));var n=this.getBounds(t);if(!hr.isEmpty(n)){var r=new hr;return r.setFromTransformedAABB(n,e),r}}return this.getBounds(t)},t.prototype.getBoundingClientRect=function(t){var e,n,r,i=this.getGeometryBounds(t);hr.isEmpty(i)||(r=new hr).setFromTransformedAABB(i,this.getWorldTransform(t));var o=null===(n=null===(e=t.ownerDocument)||void 0===e?void 0:e.defaultView)||void 0===n?void 0:n.getContextService().getBoundingClientRect();if(r){var a=c(r.getMin(),2),s=a[0],u=a[1],h=c(r.getMax(),2),l=h[0],d=h[1];return new vr(s+((null==o?void 0:o.left)||0),u+((null==o?void 0:o.top)||0),l-s,d-u)}return new vr((null==o?void 0:o.left)||0,(null==o?void 0:o.top)||0,0,0)},t.prototype.dirtifyWorldInternal=function(t,e){var n=this;if(!e.dirtyFlag){e.dirtyFlag=!0,e.frozen=!1,t.childNodes.forEach((function(t){var e=t.transformable;e.dirtyFlag||n.dirtifyWorldInternal(t,e)}));var r=t.renderable;r&&(r.renderBoundsDirty=!0,r.boundsDirty=!0,r.dirty=!0)}},t.prototype.syncHierarchy=function(t){var e=t.transformable;if(!e.frozen){e.frozen=!0,(e.localDirtyFlag||e.dirtyFlag)&&this.sync(t,e);for(var n=t.childNodes,r=0;r<n.length;r++)this.syncHierarchy(n[r])}},t.prototype.sync=function(t,e){if(e.localDirtyFlag&&(this.calcLocalTransform(e),e.localDirtyFlag=!1),e.dirtyFlag){var n=t.parentNode,r=n&&n.transformable;null!==n&&r?T(e.worldTransform,r.worldTransform,e.localTransform):x(e.worldTransform,e.localTransform),e.dirtyFlag=!1}},t.prototype.unfreezeParentToRoot=function(t){for(var e=t.parentNode;e;){var n=e.transformable;n&&(n.frozen=!1),e=e.parentNode}},t}(),es={MetricsString:"|ÉqÅ",BaselineSymbol:"M",BaselineMultiplier:1.4,HeightMultiplier:2,Newlines:[10,13],BreakingSpaces:[9,32,8192,8193,8194,8195,8196,8197,8198,8200,8201,8202,8287,12288]},ns=/[a-zA-Z0-9\u00C0-\u00D6\u00D8-\u00f6\u00f8-\u00ff!"#$%&'()*+,-./:;]/,rs=new RegExp("".concat(/[!%),.:;?\]}¢°·'""†‡›℃∶、。〃〆〕〗〞﹚﹜!"%'),.:;?!]}~]/.source,"|").concat(/[!),.:;?\]}¢·–—'"•"、。〆〞〕〉》」︰︱︲︳﹐﹑﹒﹓﹔﹕﹖﹘﹚﹜!),.:;?︶︸︺︼︾﹀﹂﹗]|}、]/.source,"|").concat(/[)\]}〕〉》」』】〙〗〟'"⦆»ヽヾーァィゥェォッャュョヮヵヶぁぃぅぇぉっゃゅょゎゕゖㇰㇱㇲㇳㇴㇵㇶㇷㇸㇹㇺㇻㇼㇽㇾㇿ々〻‐゠–〜?!‼⁇⁈⁉・、:;,。.]/.source,"|").concat(/[!%),.:;?\]}¢°'"†‡℃〆〈《「『〕!%),.:;?]}]/.source)),is=new RegExp("".concat(/[$(£¥·'"〈《「『【〔〖〝﹙﹛$(.[{£¥]/.source,"|").concat(/[([{£¥'"‵〈《「『〔〝︴﹙﹛({︵︷︹︻︽︿﹁﹃﹏]/.source,"|").concat(/[([{〔〈《「『【〘〖〝'"⦅«—...‥〳〴〵]/.source,"|").concat(/[$([{£¥'"々〇〉》」〔$([{⦆¥₩#]/.source)),os=function(){function t(t){var e=this;this.runtime=t,this.fontMetricsCache={},this.shouldBreakByKinsokuShorui=function(t,n){return!e.isBreakingSpace(n)&&!(!t||!is.exec(n)&&!rs.exec(t))},this.trimByKinsokuShorui=function(t){var e=h([],c(t),!1),n=e[e.length-2];if(!n)return t;var r=n[n.length-1];return e[e.length-2]=n.slice(0,-1),e[e.length-1]=r+e[e.length-1],e}}return t.prototype.measureFont=function(t,e){if(this.fontMetricsCache[t])return this.fontMetricsCache[t];var n={ascent:0,descent:0,fontSize:0},r=this.runtime.offscreenCanvasCreator.getOrCreateCanvas(e),i=this.runtime.offscreenCanvasCreator.getOrCreateContext(e,{willReadFrequently:!0});i.font=t;var o=es.MetricsString+es.BaselineSymbol,a=Math.ceil(i.measureText(o).width),s=Math.ceil(i.measureText(es.BaselineSymbol).width),u=es.HeightMultiplier*s;s=s*es.BaselineMultiplier|0,r.width=a,r.height=u,i.fillStyle="#f00",i.fillRect(0,0,a,u),i.font=t,i.textBaseline="alphabetic",i.fillStyle="#000",i.fillText(o,0,s);var c=i.getImageData(0,0,a||1,u||1).data,h=c.length,l=4*a,d=0,f=0,p=!1;for(d=0;d<s;++d){for(var g=0;g<l;g+=4)if(255!==c[f+g]){p=!0;break}if(p)break;f+=l}for(n.ascent=s-d,f=h-l,p=!1,d=u;d>s;--d){for(g=0;g<l;g+=4)if(255!==c[f+g]){p=!0;break}if(p)break;f-=l}return n.descent=d-s,n.fontSize=n.ascent+n.descent,this.fontMetricsCache[t]=n,n},t.prototype.measureText=function(t,e,n){var r=e.fontSize,i=e.wordWrap,o=e.lineHeight,a=e.lineWidth,s=e.textBaseline,u=e.textAlign,c=e.letterSpacing,h=e.textPath;e.textPathSide,e.textPathStartOffset;var l=e.leading,d=void 0===l?0:l,f=function(t){for(var e=t.fontSize,n=t.fontFamily,r=t.fontStyle,i=t.fontVariant,o=t.fontWeight,a=jt(e)&&"".concat(e,"px")||"16px",s=n.split(","),u=s.length-1;u>=0;u--){var c=s[u].trim();!Ma.test(c)&&wa.indexOf(c)<0&&(c='"'.concat(c,'"')),s[u]=c}return"".concat(r," ").concat(i," ").concat(o," ").concat(a," ").concat(s.join(","))}(e),p=this.measureFont(f,n);0===p.fontSize&&(p.fontSize=r,p.ascent=r);var g=this.runtime.offscreenCanvasCreator.getOrCreateContext(n);g.font=f,e.isOverflowing=!1;var m=(i?this.wordWrap(t,e,n):t).split(/(?:\r\n|\r|\n)/),v=new Array(m.length),y=0;if(!h){for(M=0;M<m.length;M++){var E=g.measureText(m[M]).width+(m[M].length-1)*c;v[M]=E,y=Math.max(y,E)}N=y+a;var x=o||p.fontSize+a,b=Math.max(x,p.fontSize+a)+(m.length-1)*(x+d),w=0;return"middle"===s?w=-b/2:"bottom"===s||"alphabetic"===s||"ideographic"===s?w=-b:"top"!==s&&"hanging"!==s||(w=0),{font:f,width:N,height:b,lines:m,lineWidths:v,lineHeight:x+=d,maxLineWidth:y,fontProperties:p,lineMetrics:v.map((function(t,e){var n=0;return"center"===u||"middle"===u?n-=t/2:"right"!==u&&"end"!==u||(n-=t),new vr(n-a/2,w+e*x,t+a,x)}))}}h.getTotalLength();for(var M=0;M<m.length;M++)var N=g.measureText(m[M]).width+(m[M].length-1)*c},t.prototype.setGraphemeOnPath=function(){},t.prototype.wordWrap=function(t,e,n){var r=this,i=e.wordWrapWidth,o=void 0===i?0:i,a=e.letterSpacing,s=e.maxLines,u=void 0===s?1/0:s,c=e.textOverflow,h=this.runtime.offscreenCanvasCreator.getOrCreateContext(n),l=o+a,d="";"ellipsis"===c?d="...":c&&"clip"!==c&&(d=c);for(var f=[],p=0,g=0,m={},v=function(t){return r.getFromCache(t,a,m,h)},y=Array.from(d).reduce((function(t,e){return t+v(e)}),0),E=Array.from(t),x=0;x<E.length;x++){var b=E[x],w=t[x-1],M=t[x+1],N=v(b);if(this.isNewline(b)){if(++p>=u){e.isOverflowing=!0;break}g=0,f[p]=""}else{if(g>0&&g+N>l){if(p+1>=u){if(e.isOverflowing=!0,y>0&&y<=l){for(var S=f[p].length,T=0,P=S,C=0;C<S;C++){var k=v(f[p][C]);if(T+k+y>l){P=C;break}T+=k}f[p]=(f[p]||"").slice(0,P)+d}break}if(g=0,f[++p]="",this.isBreakingSpace(b))continue;this.canBreakInLastChar(b)||(f=this.trimToBreakable(f),g=this.sumTextWidthByCache(f[p]||"",m)),this.shouldBreakByKinsokuShorui(b,M)&&(f=this.trimByKinsokuShorui(f),g+=v(w||""))}g+=N,f[p]=(f[p]||"")+b}}return f.join("\n")},t.prototype.isBreakingSpace=function(t){return"string"==typeof t&&es.BreakingSpaces.indexOf(t.charCodeAt(0))>=0},t.prototype.isNewline=function(t){return"string"==typeof t&&es.Newlines.indexOf(t.charCodeAt(0))>=0},t.prototype.trimToBreakable=function(t){var e=h([],c(t),!1),n=e[e.length-2],r=this.findBreakableIndex(n);if(-1===r||!n)return e;var i=n.slice(r,r+1),o=r+1,a=r+(this.isBreakingSpace(i)?0:1);return e[e.length-1]+=n.slice(o,n.length),e[e.length-2]=n.slice(0,a),e},t.prototype.canBreakInLastChar=function(t){return!t||!ns.test(t)},t.prototype.sumTextWidthByCache=function(t,e){return t.split("").reduce((function(t,n){if(!e[n])throw Error("cannot count the word without cache");return t+e[n]}),0)},t.prototype.findBreakableIndex=function(t){for(var e=t.length-1;e>=0;e--)if(!ns.test(t[e]))return e;return-1},t.prototype.getFromCache=function(t,e,n,r){var i=n[t];if("number"!=typeof i){var o=t.length*e;i=r.measureText(t).width+o,n[t]=i}return i},t}(),as={},ss=(Za=new Ra,Qa=new Oa,($a={})[jn.CIRCLE]=new Pa,$a[jn.ELLIPSE]=new Ca,$a[jn.RECT]=Za,$a[jn.IMAGE]=Za,$a[jn.GROUP]=Za,$a[jn.LINE]=new ka,$a[jn.TEXT]=new Da(as),$a[jn.POLYLINE]=Qa,$a[jn.POLYGON]=Qa,$a[jn.PATH]=new Aa,$a[jn.HTML]=null,$a[jn.MESH]=null,$a),us=function(){var t,e=new Do,n=new _o;return(t={})[ui.PERCENTAGE]=null,t[ui.NUMBER]=new Uo,t[ui.ANGLE]=new Oo,t[ui.DEFINED_PATH]=new Ro,t[ui.PAINT]=e,t[ui.COLOR]=e,t[ui.FILTER]=new Io,t[ui.LENGTH]=n,t[ui.LENGTH_PERCENTAGE]=n,t[ui.LENGTH_PERCENTAGE_12]=new zo,t[ui.LENGTH_PERCENTAGE_14]=new Fo,t[ui.COORDINATE]=new jo,t[ui.OFFSET_DISTANCE]=new Wo,t[ui.OPACITY_VALUE]=new Ho,t[ui.PATH]=new qo,t[ui.LIST_OF_POINTS]=new Yo,t[ui.SHADOW_BLUR]=new Xo,t[ui.TEXT]=new Ko,t[ui.TEXT_TRANSFORM]=new $o,t[ui.TRANSFORM]=new Na,t[ui.TRANSFORM_ORIGIN]=new Sa,t[ui.Z_INDEX]=new Ta,t[ui.MARKER]=new Vo,t}();as.CameraContribution=Pr,as.AnimationTimeline=null,as.EasingFunction=null,as.offscreenCanvasCreator=new Ua,as.sceneGraphSelector=new Ya,as.sceneGraphService=new ts(as),as.textService=new os(as),as.geometryUpdaterFactory=ss,as.CSSPropertySyntaxFactory=us,as.styleValueRegistry=new Ao(as),as.layoutRegistry=null,as.globalThis="undefined"!=typeof globalThis?globalThis:"undefined"!=typeof self?self:"undefined"!=typeof window?window:"undefined"!=typeof global?global:{},as.enableCSSParsing=!0,as.enableDataset=!1,as.enableStyleSyntax=!0,as.enableSizeAttenuation=!1;var cs=0,hs=new Xa(Wa.INSERTED,null,"","","",0,"",""),ls=new Xa(Wa.REMOVED,null,"","","",0,"",""),ds=new Ba(Wa.DESTROY),fs=function(t){function e(){var e=t.apply(this,h([],c(arguments),!1))||this;return e.entity=cs++,e.renderable={bounds:void 0,boundsDirty:!0,renderBounds:void 0,renderBoundsDirty:!0,dirtyRenderBounds:void 0,dirty:!1},e.cullable={strategy:Xr.Standard,visibilityPlaneMask:-1,visible:!0,enable:!0},e.transformable={dirtyFlag:!1,localDirtyFlag:!1,frozen:!1,localPosition:[0,0,0],localRotation:[0,0,0,1],localScale:[1,1,1],localTransform:[1,0,0,0,0,1,0,0,0,0,1,0,0,0,0,1],localSkew:[0,0],position:[0,0,0],rotation:[0,0,0,1],scaling:[1,1,1],worldTransform:[1,0,0,0,0,1,0,0,0,0,1,0,0,0,0,1],origin:[0,0,0]},e.sortable={dirty:!1,sorted:void 0,renderOrder:0,dirtyChildren:[],dirtyReason:void 0},e.geometry={contentBounds:void 0,renderBounds:void 0},e.rBushNode={aabb:void 0},e.namespaceURI="g",e.scrollLeft=0,e.scrollTop=0,e.clientTop=0,e.clientLeft=0,e.destroyed=!1,e.style={},e.computedStyle=as.enableCSSParsing?{anchor:Qr,opacity:Qr,fillOpacity:Qr,strokeOpacity:Qr,fill:Qr,stroke:Qr,transform:Qr,transformOrigin:Qr,visibility:Qr,pointerEvents:Qr,lineWidth:Qr,lineCap:Qr,lineJoin:Qr,increasedLineWidthForHitTesting:Qr,fontSize:Qr,fontFamily:Qr,fontStyle:Qr,fontWeight:Qr,fontVariant:Qr,textAlign:Qr,textBaseline:Qr,textTransform:Qr,zIndex:Qr,filter:Qr,shadowType:Qr}:null,e.parsedStyle={},e.attributes={},e}return r(e,t),Object.defineProperty(e.prototype,"className",{get:function(){return this.getAttribute("class")||""},set:function(t){this.setAttribute("class",t)},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"classList",{get:function(){return this.className.split(" ").filter((function(t){return""!==t}))},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"tagName",{get:function(){return this.nodeName},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"children",{get:function(){return this.childNodes},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"childElementCount",{get:function(){return this.childNodes.length},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"firstElementChild",{get:function(){return this.firstChild},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"lastElementChild",{get:function(){return this.lastChild},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"parentElement",{get:function(){return this.parentNode},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"nextSibling",{get:function(){if(this.parentNode){var t=this.parentNode.childNodes.indexOf(this);return this.parentNode.childNodes[t+1]||null}return null},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"previousSibling",{get:function(){if(this.parentNode){var t=this.parentNode.childNodes.indexOf(this);return this.parentNode.childNodes[t-1]||null}return null},enumerable:!1,configurable:!0}),e.prototype.cloneNode=function(t){throw new Error(yr)},e.prototype.appendChild=function(t,e){var n;if(t.destroyed)throw new Error("Cannot append a destroyed element.");return as.sceneGraphService.attach(t,this,e),(null===(n=this.ownerDocument)||void 0===n?void 0:n.defaultView)&&this.ownerDocument.defaultView.mountChildren(t),hs.relatedNode=this,t.dispatchEvent(hs),t},e.prototype.insertBefore=function(t,e){if(e){t.parentElement&&t.parentElement.removeChild(t);var n=this.childNodes.indexOf(e);-1===n?this.appendChild(t):this.appendChild(t,n)}else this.appendChild(t);return t},e.prototype.replaceChild=function(t,e){var n=this.childNodes.indexOf(e);return this.removeChild(e),this.appendChild(t,n),e},e.prototype.removeChild=function(t){var e;return ls.relatedNode=this,t.dispatchEvent(ls),(null===(e=t.ownerDocument)||void 0===e?void 0:e.defaultView)&&t.ownerDocument.defaultView.unmountChildren(t),as.sceneGraphService.detach(t),t},e.prototype.removeChildren=function(){for(var t=this.childNodes.length-1;t>=0;t--){var e=this.childNodes[t];this.removeChild(e)}},e.prototype.destroyChildren=function(){for(var t=this.childNodes.length-1;t>=0;t--){var e=this.childNodes[t];e.childNodes.length&&e.destroyChildren(),e.destroy()}},e.prototype.matches=function(t){return as.sceneGraphService.matches(t,this)},e.prototype.getElementById=function(t){return as.sceneGraphService.querySelector("#".concat(t),this)},e.prototype.getElementsByName=function(t){return as.sceneGraphService.querySelectorAll('[name="'.concat(t,'"]'),this)},e.prototype.getElementsByClassName=function(t){return as.sceneGraphService.querySelectorAll(".".concat(t),this)},e.prototype.getElementsByTagName=function(t){return as.sceneGraphService.querySelectorAll(t,this)},e.prototype.querySelector=function(t){return as.sceneGraphService.querySelector(t,this)},e.prototype.querySelectorAll=function(t){return as.sceneGraphService.querySelectorAll(t,this)},e.prototype.closest=function(t){var e=this;do{if(as.sceneGraphService.matches(t,e))return e;e=e.parentElement}while(null!==e);return null},e.prototype.find=function(t){var e=this,n=null;return this.forEach((function(r){return!(r===e||!t(r))&&(n=r,!0)})),n},e.prototype.findAll=function(t){var e=this,n=[];return this.forEach((function(r){r!==e&&t(r)&&n.push(r)})),n},e.prototype.after=function(){for(var t=this,e=[],n=0;n<arguments.length;n++)e[n]=arguments[n];if(this.parentNode){var r=this.parentNode.childNodes.indexOf(this);e.forEach((function(e,n){var i;return null===(i=t.parentNode)||void 0===i?void 0:i.appendChild(e,r+n+1)}))}},e.prototype.before=function(){for(var t,e=[],n=0;n<arguments.length;n++)e[n]=arguments[n];if(this.parentNode){var r=this.parentNode.childNodes.indexOf(this),i=c(e),o=i[0],a=i.slice(1);this.parentNode.appendChild(o,r),(t=o).after.apply(t,h([],c(a),!1))}},e.prototype.replaceWith=function(){for(var t=[],e=0;e<arguments.length;e++)t[e]=arguments[e];this.after.apply(this,h([],c(t),!1)),this.remove()},e.prototype.append=function(){for(var t=this,e=[],n=0;n<arguments.length;n++)e[n]=arguments[n];e.forEach((function(e){return t.appendChild(e)}))},e.prototype.prepend=function(){for(var t=this,e=[],n=0;n<arguments.length;n++)e[n]=arguments[n];e.forEach((function(e,n){return t.appendChild(e,n)}))},e.prototype.replaceChildren=function(){for(var t=[],e=0;e<arguments.length;e++)t[e]=arguments[e];for(;this.childNodes.length&&this.firstChild;)this.removeChild(this.firstChild);this.append.apply(this,h([],c(t),!1))},e.prototype.remove=function(){return this.parentNode?this.parentNode.removeChild(this):this},e.prototype.destroy=function(){this.dispatchEvent(ds),this.remove(),this.emitter.removeAllListeners(),this.destroyed=!0},e.prototype.getGeometryBounds=function(){return as.sceneGraphService.getGeometryBounds(this)},e.prototype.getRenderBounds=function(){return as.sceneGraphService.getBounds(this,!0)},e.prototype.getBounds=function(){return as.sceneGraphService.getBounds(this)},e.prototype.getLocalBounds=function(){return as.sceneGraphService.getLocalBounds(this)},e.prototype.getBoundingClientRect=function(){return as.sceneGraphService.getBoundingClientRect(this)},e.prototype.getClientRects=function(){return[this.getBoundingClientRect()]},e.prototype.computedStyleMap=function(){return new Map(Object.entries(this.computedStyle))},e.prototype.getAttributeNames=function(){return Object.keys(this.attributes)},e.prototype.getAttribute=function(t){if(function(t){return"symbol"==typeof t}(t))return as.enableCSSParsing?null:void 0;var e=this.attributes[t];if(void 0===e){var n=Ur(t);return e=this.attributes[n],as.enableCSSParsing&&Pt(e)?null:e}return e},e.prototype.hasAttribute=function(t){return this.getAttributeNames().includes(t)},e.prototype.hasAttributes=function(){return!!this.getAttributeNames().length},e.prototype.removeAttribute=function(t){this.setAttribute(t,null),delete this.attributes[t]},e.prototype.setAttribute=function(t,e,n){this.attributes[t]=e},e.prototype.getAttributeNS=function(t,e){throw new Error(yr)},e.prototype.getAttributeNode=function(t){throw new Error(yr)},e.prototype.getAttributeNodeNS=function(t,e){throw new Error(yr)},e.prototype.hasAttributeNS=function(t,e){throw new Error(yr)},e.prototype.removeAttributeNS=function(t,e){throw new Error(yr)},e.prototype.removeAttributeNode=function(t){throw new Error(yr)},e.prototype.setAttributeNS=function(t,e,n){throw new Error(yr)},e.prototype.setAttributeNode=function(t){throw new Error(yr)},e.prototype.setAttributeNodeNS=function(t){throw new Error(yr)},e.prototype.toggleAttribute=function(t,e){throw new Error(yr)},e}(ja);function ps(t){return!!(null==t?void 0:t.nodeName)}var gs,ms=new Xa(Wa.ATTR_MODIFIED,null,null,null,null,Xa.MODIFICATION,null,null),vs={anchor:"",opacity:"",fillOpacity:"",strokeOpacity:"",fill:"",stroke:"",transform:"",transformOrigin:"",visibility:"",pointerEvents:"",lineWidth:"",lineCap:"",lineJoin:"",increasedLineWidthForHitTesting:"",fontSize:"",fontFamily:"",fontStyle:"",fontWeight:"",fontVariant:"",textAlign:"",textBaseline:"",textTransform:"",zIndex:"",filter:"",shadowType:""},ys={anchor:[0,0],fill:ri,stroke:ri,transform:[],zIndex:0,filter:[],shadowType:"outer",miterLimit:10},Es=i(i({},ys),{opacity:1,fillOpacity:1,strokeOpacity:1,visibility:"visible",pointerEvents:"auto",lineWidth:1,lineCap:"butt",lineJoin:"miter",increasedLineWidthForHitTesting:0,fillRule:"nonzero"}),xs=h(h([],c(["opacity","fillOpacity","strokeOpacity","transformOrigin","visibility","pointerEvents","lineWidth","lineCap","lineJoin","increasedLineWidthForHitTesting"]),!1),["fontSize","fontFamily","fontStyle","fontWeight","fontVariant","textAlign","textBaseline","textTransform"],!1),bs="data-",ws=function(t){function e(e){var n,r=t.call(this)||this;r.isCustomElement=!1,r.isMutationObserved=!1,r.activeAnimations=[],r.getClip=function(){return this.style.clipPath||null},r.config=e,r.config.interactive=null!==(n=r.config.capture)&&void 0!==n?n:r.config.interactive,r.id=r.config.id||"",r.name=r.config.name||"",(r.config.className||r.config.class)&&(r.className=r.config.className||r.config.class),r.nodeName=r.config.type||jn.GROUP,r.config.style=r.config.style||r.config.attrs||{},Object.assign(r.config.style,r.config.attrs),null!=r.config.visible&&(r.config.style.visibility=!1===r.config.visible?"hidden":"visible"),null!=r.config.interactive&&(r.config.style.pointerEvents=!1===r.config.interactive?"none":"auto"),Object.assign(r.parsedStyle,as.enableCSSParsing?ys:Es,r.config.initialParsedStyle),as.enableCSSParsing&&Object.assign(r.attributes,vs),r.initAttributes(r.config.style);var i=as.globalThis.Proxy?as.globalThis.Proxy:function(){};return as.enableDataset&&(r.dataset=new i({},{get:function(t,e){var n="".concat(bs).concat(Gr(e));return void 0!==t[n]?t[n]:r.getAttribute(n)},set:function(t,e,n){return r.setAttribute("".concat(bs).concat(Gr(e)),n),!0}})),as.enableStyleSyntax&&(r.style=new i({setProperty:function(t,e){r.setAttribute(t,e)},getPropertyValue:function(t){return r.getAttribute(t)},removeProperty:function(t){r.removeAttribute(t)},item:function(){return""}},{get:function(t,e){return void 0!==t[e]?t[e]:r.getAttribute(e)},set:function(t,e,n){return r.setAttribute(e,n),!0}})),r}return r(e,t),e.prototype.destroy=function(){t.prototype.destroy.call(this),this.getAnimations().forEach((function(t){t.cancel()}))},e.prototype.cloneNode=function(t,e){var n=i({},this.attributes);for(var r in n){var o=n[r];ps(o)&&"clipPath"!==r&&"offsetPath"!==r&&"textPath"!==r&&(n[r]=o.cloneNode(t)),e&&(n[r]=e(r,o))}var a=new this.constructor({id:this.id,name:this.name,className:this.name,interactive:this.interactive,style:n});return a.setLocalTransform(this.getLocalTransform()),t&&this.children.forEach((function(e){if(!e.style.isMarker){var n=e.cloneNode(t);a.appendChild(n)}})),a},e.prototype.initAttributes=function(t){void 0===t&&(t={});var e=this.renderable,n={forceUpdateGeometry:!0};as.enableCSSParsing&&(n.usedAttributes=xs);var r={};for(var i in t){r[Ur(i)]=t[i]}as.styleValueRegistry.processProperties(this,r,n),e.dirty=!0},e.prototype.setAttribute=function(e,n,r,i){void 0===r&&(r=!1),void 0===i&&(i=!0);var o=Ur(e);$t(n)||(r||n!==this.attributes[o])&&(this.internalSetAttribute(o,n,{memoize:i}),t.prototype.setAttribute.call(this,o,n))},e.prototype.internalSetAttribute=function(t,e,n){var r;void 0===n&&(n={});var i=this.renderable,o=this.attributes[t],a=this.parsedStyle[t];as.styleValueRegistry.processProperties(this,((r={})[t]=e,r),n),i.dirty=!0;var s=this.parsedStyle[t];this.isConnected&&(ms.relatedNode=this,ms.prevValue=o,ms.newValue=e,ms.attrName=t,ms.prevParsedValue=a,ms.newParsedValue=s,this.isMutationObserved?this.dispatchEvent(ms):(ms.target=this,this.ownerDocument.defaultView.dispatchEvent(ms,!0))),(this.isCustomElement&&this.isConnected||!this.isCustomElement)&&this.attributeChangedCallback&&this.attributeChangedCallback(t,o,e,a,s)},e.prototype.getBBox=function(){var t=this.getBounds(),e=c(t.getMin(),2),n=e[0],r=e[1],i=c(t.getMax(),2),o=i[0],a=i[1];return new vr(n,r,o-n,a-r)},e.prototype.setOrigin=function(t,e,n){return void 0===e&&(e=0),void 0===n&&(n=0),as.sceneGraphService.setOrigin(this,Zn(t,e,n)),this},e.prototype.getOrigin=function(){return as.sceneGraphService.getOrigin(this)},e.prototype.setPosition=function(t,e,n){return void 0===e&&(e=0),void 0===n&&(n=0),as.sceneGraphService.setPosition(this,Zn(t,e,n)),this},e.prototype.setLocalPosition=function(t,e,n){return void 0===e&&(e=0),void 0===n&&(n=0),as.sceneGraphService.setLocalPosition(this,Zn(t,e,n)),this},e.prototype.translate=function(t,e,n){return void 0===e&&(e=0),void 0===n&&(n=0),as.sceneGraphService.translate(this,Zn(t,e,n)),this},e.prototype.translateLocal=function(t,e,n){return void 0===e&&(e=0),void 0===n&&(n=0),as.sceneGraphService.translateLocal(this,Zn(t,e,n)),this},e.prototype.getPosition=function(){return as.sceneGraphService.getPosition(this)},e.prototype.getLocalPosition=function(){return as.sceneGraphService.getLocalPosition(this)},e.prototype.scale=function(t,e,n){return this.scaleLocal(t,e,n)},e.prototype.scaleLocal=function(t,e,n){return"number"==typeof t&&(t=Zn(t,e=e||t,n=n||t)),as.sceneGraphService.scaleLocal(this,t),this},e.prototype.setLocalScale=function(t,e,n){return"number"==typeof t&&(t=Zn(t,e=e||t,n=n||t)),as.sceneGraphService.setLocalScale(this,t),this},e.prototype.getLocalScale=function(){return as.sceneGraphService.getLocalScale(this)},e.prototype.getScale=function(){return as.sceneGraphService.getScale(this)},e.prototype.getEulerAngles=function(){return Jn(c(tr(K(),as.sceneGraphService.getWorldTransform(this)),3)[2])},e.prototype.getLocalEulerAngles=function(){return Jn(c(tr(K(),as.sceneGraphService.getLocalRotation(this)),3)[2])},e.prototype.setEulerAngles=function(t){return as.sceneGraphService.setEulerAngles(this,0,0,t),this},e.prototype.setLocalEulerAngles=function(t){return as.sceneGraphService.setLocalEulerAngles(this,0,0,t),this},e.prototype.rotateLocal=function(t,e,n){return Pt(e)&&Pt(n)?as.sceneGraphService.rotateLocal(this,0,0,t):as.sceneGraphService.rotateLocal(this,t,e,n),this},e.prototype.rotate=function(t,e,n){return Pt(e)&&Pt(n)?as.sceneGraphService.rotate(this,0,0,t):as.sceneGraphService.rotate(this,t,e,n),this},e.prototype.setRotation=function(t,e,n,r){return as.sceneGraphService.setRotation(this,t,e,n,r),this},e.prototype.setLocalRotation=function(t,e,n,r){return as.sceneGraphService.setLocalRotation(this,t,e,n,r),this},e.prototype.setLocalSkew=function(t,e){return as.sceneGraphService.setLocalSkew(this,t,e),this},e.prototype.getRotation=function(){return as.sceneGraphService.getRotation(this)},e.prototype.getLocalRotation=function(){return as.sceneGraphService.getLocalRotation(this)},e.prototype.getLocalSkew=function(){return as.sceneGraphService.getLocalSkew(this)},e.prototype.getLocalTransform=function(){return as.sceneGraphService.getLocalTransform(this)},e.prototype.getWorldTransform=function(){return as.sceneGraphService.getWorldTransform(this)},e.prototype.setLocalTransform=function(t){return as.sceneGraphService.setLocalTransform(this,t),this},e.prototype.resetLocalTransform=function(){as.sceneGraphService.resetLocalTransform(this)},e.prototype.getAnimations=function(){return this.activeAnimations},e.prototype.animate=function(t,e){var n,r=null===(n=this.ownerDocument)||void 0===n?void 0:n.timeline;return r?r.play(this,t,e):null},e.prototype.isVisible=function(){var t;return"visible"===(null===(t=this.parsedStyle)||void 0===t?void 0:t.visibility)},Object.defineProperty(e.prototype,"interactive",{get:function(){return this.isInteractive()},set:function(t){this.style.pointerEvents=t?"auto":"none"},enumerable:!1,configurable:!0}),e.prototype.isInteractive=function(){var t;return"none"!==(null===(t=this.parsedStyle)||void 0===t?void 0:t.pointerEvents)},e.prototype.isCulled=function(){return!(!this.cullable||!this.cullable.enable||this.cullable.visible)},e.prototype.toFront=function(){return this.parentNode&&(this.style.zIndex=Math.max.apply(Math,h([],c(this.parentNode.children.map((function(t){return Number(t.style.zIndex)}))),!1))+1),this},e.prototype.toBack=function(){return this.parentNode&&(this.style.zIndex=Math.min.apply(Math,h([],c(this.parentNode.children.map((function(t){return Number(t.style.zIndex)}))),!1))-1),this},e.prototype.getConfig=function(){return this.config},e.prototype.attr=function(){for(var t=this,e=[],n=0;n<arguments.length;n++)e[n]=arguments[n];var r=c(e,2),i=r[0],o=r[1];return i?Ot(i)?(Object.keys(i).forEach((function(e){t.setAttribute(e,i[e])})),this):2===e.length?(this.setAttribute(i,o),this):this.attributes[i]:this.attributes},e.prototype.getMatrix=function(t){var e=t||this.getWorldTransform(),n=c(I(K(),e),2),r=n[0],i=n[1],o=c(L(K(),e),2),a=o[0],s=o[1],u=_(pt(),e),h=c(tr(K(),u),3),l=h[0],d=h[2];return er(l||d,r,i,a,s)},e.prototype.getLocalMatrix=function(){return this.getMatrix(this.getLocalTransform())},e.prototype.setMatrix=function(t){var e=c(nr(t),5),n=e[0],r=e[1],i=e[2],o=e[3],a=e[4];this.setEulerAngles(a).setPosition(n,r).setLocalScale(i,o)},e.prototype.setLocalMatrix=function(t){var e=c(nr(t),5),n=e[0],r=e[1],i=e[2],o=e[3],a=e[4];this.setLocalEulerAngles(a).setLocalPosition(n,r).setLocalScale(i,o)},e.prototype.show=function(){as.enableCSSParsing?this.style.visibility="visible":this.forEach((function(t){t.style.visibility="visible"}))},e.prototype.hide=function(){as.enableCSSParsing?this.style.visibility="hidden":this.forEach((function(t){t.style.visibility="hidden"}))},e.prototype.getCount=function(){return this.childElementCount},e.prototype.getParent=function(){return this.parentElement},e.prototype.getChildren=function(){return this.children},e.prototype.getFirst=function(){return this.firstElementChild},e.prototype.getLast=function(){return this.lastElementChild},e.prototype.getChildByIndex=function(t){return this.children[t]||null},e.prototype.add=function(t,e){return this.appendChild(t,e)},e.prototype.setClip=function(t){this.style.clipPath=t},e.prototype.set=function(t,e){this.config[t]=e},e.prototype.get=function(t){return this.config[t]},e.prototype.moveTo=function(t,e,n){return void 0===e&&(e=0),void 0===n&&(n=0),this.setPosition(t,e,n),this},e.prototype.move=function(t,e,n){return void 0===e&&(e=0),void 0===n&&(n=0),this.setPosition(t,e,n),this},e.prototype.setZIndex=function(t){return this.style.zIndex=t,this},e}(fs),Ms=function(t){function e(e){void 0===e&&(e={});var n=e.style,r=o(e,["style"]);return t.call(this,i({type:jn.CIRCLE,style:as.enableCSSParsing?i({cx:"",cy:"",r:""},n):i({},n),initialParsedStyle:{anchor:[.5,.5],transformOrigin:as.enableCSSParsing?null:[si,si]}},r))||this}return r(e,t),e}(ws),Ns=function(t){function e(e){void 0===e&&(e={});var n=this,r=e.style,a=o(e,["style"]);return(n=t.call(this,i({style:as.enableCSSParsing?i({x:"",y:""},r):i({},r)},a))||this).isCustomElement=!0,n}return r(e,t),e}(ws),Ss=function(t){function e(e){void 0===e&&(e={});var n=e.style,r=o(e,["style"]);return t.call(this,i({type:jn.ELLIPSE,style:as.enableCSSParsing?i({cx:"",cy:"",rx:"",ry:""},n):i({},n),initialParsedStyle:{anchor:[.5,.5],transformOrigin:as.enableCSSParsing?null:[si,si]}},r))||this}return r(e,t),e}(ws),Ts=function(t){function e(e){void 0===e&&(e={});var n=e.style,r=o(e,["style"]);return t.call(this,i({type:jn.GROUP,style:as.enableCSSParsing?i({x:"",y:"",width:"",height:""},n):i({},n)},r))||this}return r(e,t),e}(ws),Ps=function(t){function e(e){void 0===e&&(e={});var n=this,r=e.style,a=o(e,["style"]);return(n=t.call(this,i({type:jn.HTML,style:as.enableCSSParsing?i({x:"",y:"",width:"auto",height:"auto",innerHTML:""},r):i({},r)},a))||this).cullable.enable=!1,n}return r(e,t),e.prototype.getDomElement=function(){return this.parsedStyle.$el},e.prototype.getBoundingClientRect=function(){if(this.parsedStyle.$el)return this.parsedStyle.$el.getBoundingClientRect();var t=this.parsedStyle,e=t.x,n=t.y,r=t.width,i=t.height;return new vr(e,n,r,i)},e.prototype.getClientRects=function(){return[this.getBoundingClientRect()]},e.prototype.getBounds=function(){var t,e,n=this.getBoundingClientRect(),r=null===(e=null===(t=this.ownerDocument)||void 0===t?void 0:t.defaultView)||void 0===e?void 0:e.getContextService().getBoundingClientRect(),i=new hr,o=n.left-((null==r?void 0:r.left)||0),a=n.top-((null==r?void 0:r.top)||0);return i.setMinMax([o,a,0],[o+n.width,a+n.height,0]),i},e.prototype.getLocalBounds=function(){if(this.parentNode){var t=N(y(),this.parentNode.getWorldTransform()),e=this.getBounds();if(!hr.isEmpty(e)){var n=new hr;return n.setFromTransformedAABB(e,t),n}}return this.getBounds()},e}(ws),Cs=function(t){function e(e){void 0===e&&(e={});var n=e.style,r=o(e,["style"]);return t.call(this,i({type:jn.IMAGE,style:as.enableCSSParsing?i({x:"",y:"",img:"",width:"",height:""},n):i({},n)},r))||this}return r(e,t),e}(ws),ks=function(t){function e(e){void 0===e&&(e={});var n=this,r=e.style,a=o(e,["style"]);(n=t.call(this,i({type:jn.LINE,style:i({x1:0,y1:0,x2:0,y2:0,z1:0,z2:0},r)},a))||this).markerStartAngle=0,n.markerEndAngle=0;var s=n.parsedStyle,u=s.markerStart,c=s.markerEnd;return u&&ps(u)&&(n.markerStartAngle=u.getLocalEulerAngles(),n.appendChild(u)),c&&ps(c)&&(n.markerEndAngle=c.getLocalEulerAngles(),n.appendChild(c)),n.transformMarker(!0),n.transformMarker(!1),n}return r(e,t),e.prototype.attributeChangedCallback=function(t,e,n,r,i){"x1"===t||"y1"===t||"x2"===t||"y2"===t||"markerStartOffset"===t||"markerEndOffset"===t?(this.transformMarker(!0),this.transformMarker(!1)):"markerStart"===t?(r&&ps(r)&&(this.markerStartAngle=0,r.remove()),i&&ps(i)&&(this.markerStartAngle=i.getLocalEulerAngles(),this.appendChild(i),this.transformMarker(!0))):"markerEnd"===t&&(r&&ps(r)&&(this.markerEndAngle=0,r.remove()),i&&ps(i)&&(this.markerEndAngle=i.getLocalEulerAngles(),this.appendChild(i),this.transformMarker(!1)))},e.prototype.transformMarker=function(t){var e=this.parsedStyle,n=e.markerStart,r=e.markerEnd,i=e.markerStartOffset,o=e.markerEndOffset,a=e.x1,s=e.x2,u=e.y1,c=e.y2,h=e.defX,l=e.defY,d=t?n:r;if(d&&ps(d)){var f,p,g,m,v,y,E;t?(m=a-h,v=u-l,p=s-a,g=c-u,y=i||0,E=this.markerStartAngle):(m=s-h,v=c-l,p=a-s,g=u-c,y=o||0,E=this.markerEndAngle),f=Math.atan2(g,p),d.setLocalEulerAngles(180*f/Math.PI+E),d.setLocalPosition(m+Math.cos(f)*y,v+Math.sin(f)*y)}},e.prototype.getPoint=function(t,e){void 0===e&&(e=!1);var n=this.parsedStyle,r=n.x1,i=n.y1,o=n.x2,a=n.y2,s=n.defX,u=n.defY,c=kn(r,i,o,a,t),h=c.x,l=c.y,d=ut(K(),Q(h-s,l-u,0),e?this.getWorldTransform():this.getLocalTransform());return new mr(d[0],d[1])},e.prototype.getPointAtLength=function(t,e){return void 0===e&&(e=!1),this.getPoint(t/this.getTotalLength(),e)},e.prototype.getTotalLength=function(){var t=this.parsedStyle;return Cn(t.x1,t.y1,t.x2,t.y2)},e}(ws),As=function(t){function e(e){void 0===e&&(e={});var n=this,r=e.style,a=o(e,["style"]);(n=t.call(this,i({type:jn.PATH,style:as.enableCSSParsing?i({path:"",miterLimit:""},r):i({},r),initialParsedStyle:as.enableCSSParsing?null:{miterLimit:4,path:i({},ci)}},a))||this).markerStartAngle=0,n.markerEndAngle=0,n.markerMidList=[];var s=n.parsedStyle,u=s.markerStart,c=s.markerEnd,h=s.markerMid;return u&&ps(u)&&(n.markerStartAngle=u.getLocalEulerAngles(),n.appendChild(u)),h&&ps(h)&&n.placeMarkerMid(h),c&&ps(c)&&(n.markerEndAngle=c.getLocalEulerAngles(),n.appendChild(c)),n.transformMarker(!0),n.transformMarker(!1),n}return r(e,t),e.prototype.attributeChangedCallback=function(t,e,n,r,i){"path"===t?(this.transformMarker(!0),this.transformMarker(!1),this.placeMarkerMid(this.parsedStyle.markerMid)):"markerStartOffset"===t||"markerEndOffset"===t?(this.transformMarker(!0),this.transformMarker(!1)):"markerStart"===t?(r&&ps(r)&&(this.markerStartAngle=0,r.remove()),i&&ps(i)&&(this.markerStartAngle=i.getLocalEulerAngles(),this.appendChild(i),this.transformMarker(!0))):"markerEnd"===t?(r&&ps(r)&&(this.markerEndAngle=0,r.remove()),i&&ps(i)&&(this.markerEndAngle=i.getLocalEulerAngles(),this.appendChild(i),this.transformMarker(!1))):"markerMid"===t&&this.placeMarkerMid(i)},e.prototype.transformMarker=function(t){var e=this.parsedStyle,n=e.markerStart,r=e.markerEnd,i=e.markerStartOffset,o=e.markerEndOffset,a=e.defX,s=e.defY,u=t?n:r;if(u&&ps(u)){var h,l,d,f,p,g,m;if(t){var v=c(this.getStartTangent(),2),y=v[0];f=(E=v[1])[0]-a,p=E[1]-s,l=y[0]-E[0],d=y[1]-E[1],g=i||0,m=this.markerStartAngle}else{var E,x=c(this.getEndTangent(),2);y=x[0];f=(E=x[1])[0]-a,p=E[1]-s,l=y[0]-E[0],d=y[1]-E[1],g=o||0,m=this.markerEndAngle}h=Math.atan2(d,l),u.setLocalEulerAngles(180*h/Math.PI+m),u.setLocalPosition(f+Math.cos(h)*g,p+Math.sin(h)*g)}},e.prototype.placeMarkerMid=function(t){var e=this.parsedStyle,n=e.path.segments,r=e.defX,i=e.defY;if(this.markerMidList.forEach((function(t){t.remove()})),t&&ps(t))for(var o=1;o<n.length-1;o++){var a=c(n[o].currentPoint,2),s=a[0],u=a[1],h=1===o?t:t.cloneNode(!0);this.markerMidList.push(h),this.appendChild(h),h.setLocalPosition(s-r,u-i)}},e.prototype.getTotalLength=function(){return Wi(this)},e.prototype.getPointAtLength=function(t,e){void 0===e&&(e=!1);var n=this.parsedStyle,r=n.defX,o=n.defY,a=function(t,e,n){return Ge(t,e,i(i({},n),{bbox:!1,length:!0})).point}(n.path.absolutePath,t),s=a.x,u=a.y,c=ut(K(),Q(s-r,u-o,0),e?this.getWorldTransform():this.getLocalTransform());return new mr(c[0],c[1])},e.prototype.getPoint=function(t,e){return void 0===e&&(e=!1),this.getPointAtLength(t*Wi(this),e)},e.prototype.getStartTangent=function(){var t=this.parsedStyle.path.segments,e=[];if(t.length>1){var n=t[0].currentPoint,r=t[1].currentPoint,i=t[1].startTangent;e=[],i?(e.push([n[0]-i[0],n[1]-i[1]]),e.push([n[0],n[1]])):(e.push([r[0],r[1]]),e.push([n[0],n[1]]))}return e},e.prototype.getEndTangent=function(){var t=this.parsedStyle.path.segments,e=t.length,n=[];if(e>1){var r=t[e-2].currentPoint,i=t[e-1].currentPoint,o=t[e-1].endTangent;n=[],o?(n.push([i[0]-o[0],i[1]-o[1]]),n.push([i[0],i[1]])):(n.push([r[0],r[1]]),n.push([i[0],i[1]]))}return n},e}(ws),Os=function(t){function e(e){void 0===e&&(e={});var n=this,r=e.style,a=o(e,["style"]);(n=t.call(this,i({type:jn.POLYGON,style:as.enableCSSParsing?i({points:"",miterLimit:"",isClosed:!0},r):i({},r),initialParsedStyle:as.enableCSSParsing?null:{points:{points:[],totalLength:0,segments:[]},miterLimit:4,isClosed:!0}},a))||this).markerStartAngle=0,n.markerEndAngle=0,n.markerMidList=[];var s=n.parsedStyle,u=s.markerStart,c=s.markerEnd,h=s.markerMid;return u&&ps(u)&&(n.markerStartAngle=u.getLocalEulerAngles(),n.appendChild(u)),h&&ps(h)&&n.placeMarkerMid(h),c&&ps(c)&&(n.markerEndAngle=c.getLocalEulerAngles(),n.appendChild(c)),n.transformMarker(!0),n.transformMarker(!1),n}return r(e,t),e.prototype.attributeChangedCallback=function(t,e,n,r,i){"points"===t?(this.transformMarker(!0),this.transformMarker(!1),this.placeMarkerMid(this.parsedStyle.markerMid)):"markerStartOffset"===t||"markerEndOffset"===t?(this.transformMarker(!0),this.transformMarker(!1)):"markerStart"===t?(r&&ps(r)&&(this.markerStartAngle=0,r.remove()),i&&ps(i)&&(this.markerStartAngle=i.getLocalEulerAngles(),this.appendChild(i),this.transformMarker(!0))):"markerEnd"===t?(r&&ps(r)&&(this.markerEndAngle=0,r.remove()),i&&ps(i)&&(this.markerEndAngle=i.getLocalEulerAngles(),this.appendChild(i),this.transformMarker(!1))):"markerMid"===t&&this.placeMarkerMid(i)},e.prototype.transformMarker=function(t){var e=this.parsedStyle,n=e.markerStart,r=e.markerEnd,i=e.markerStartOffset,o=e.markerEndOffset,a=e.points,s=e.defX,u=e.defY,c=(a||{}).points,h=t?n:r;if(h&&ps(h)&&c){var l,d,f,p,g,m,v;if(p=c[0][0]-s,g=c[0][1]-u,t)d=c[1][0]-c[0][0],f=c[1][1]-c[0][1],m=i||0,v=this.markerStartAngle;else{var y=c.length;this.parsedStyle.isClosed?(d=c[y-1][0]-c[0][0],f=c[y-1][1]-c[0][1]):(p=c[y-1][0]-s,g=c[y-1][1]-u,d=c[y-2][0]-c[y-1][0],f=c[y-2][1]-c[y-1][1]),m=o||0,v=this.markerEndAngle}l=Math.atan2(f,d),h.setLocalEulerAngles(180*l/Math.PI+v),h.setLocalPosition(p+Math.cos(l)*m,g+Math.sin(l)*m)}},e.prototype.placeMarkerMid=function(t){var e=this.parsedStyle,n=e.points,r=e.defX,i=e.defY,o=(n||{}).points;if(this.markerMidList.forEach((function(t){t.remove()})),this.markerMidList=[],t&&ps(t)&&o)for(var a=1;a<(this.parsedStyle.isClosed?o.length:o.length-1);a++){var s=o[a][0]-r,u=o[a][1]-i,c=1===a?t:t.cloneNode(!0);this.markerMidList.push(c),this.appendChild(c),c.setLocalPosition(s,u)}},e}(ws),Rs=function(t){function e(e){void 0===e&&(e={});var n=e.style,r=o(e,["style"]);return t.call(this,i({type:jn.POLYLINE,style:as.enableCSSParsing?i({points:"",miterLimit:"",isClosed:!1},n):i({},n),initialParsedStyle:as.enableCSSParsing?null:{points:{points:[],totalLength:0,segments:[]},miterLimit:4,isClosed:!1}},r))||this}return r(e,t),e.prototype.getTotalLength=function(){return this.parsedStyle.points.totalLength},e.prototype.getPointAtLength=function(t,e){return void 0===e&&(e=!1),this.getPoint(t/this.getTotalLength(),e)},e.prototype.getPoint=function(t,e){void 0===e&&(e=!1);var n=this.parsedStyle,r=n.defX,i=n.defY,o=n.points,a=o.points,s=o.segments,u=0,c=0;s.forEach((function(e,n){t>=e[0]&&t<=e[1]&&(u=(t-e[0])/(e[1]-e[0]),c=n)}));var h=kn(a[c][0],a[c][1],a[c+1][0],a[c+1][1],u),l=h.x,d=h.y,f=ut(K(),Q(l-r,d-i,0),e?this.getWorldTransform():this.getLocalTransform());return new mr(f[0],f[1])},e.prototype.getStartTangent=function(){var t=this.parsedStyle.points.points,e=[];return e.push([t[1][0],t[1][1]]),e.push([t[0][0],t[0][1]]),e},e.prototype.getEndTangent=function(){var t=this.parsedStyle.points.points,e=t.length-1,n=[];return n.push([t[e-1][0],t[e-1][1]]),n.push([t[e][0],t[e][1]]),n},e}(Os),Ds=function(t){function e(e){void 0===e&&(e={});var n=e.style,r=o(e,["style"]);return t.call(this,i({type:jn.RECT,style:as.enableCSSParsing?i({x:"",y:"",width:"",height:"",radius:""},n):i({},n)},r))||this}return r(e,t),e}(ws),Is=function(t){function e(e){void 0===e&&(e={});var n=e.style,r=o(e,["style"]);return t.call(this,i({type:jn.TEXT,style:as.enableCSSParsing?i({x:"",y:"",text:"",fontSize:"",fontFamily:"",fontStyle:"",fontWeight:"",fontVariant:"",textAlign:"",textBaseline:"",textTransform:"",fill:"black",letterSpacing:"",lineHeight:"",miterLimit:"",wordWrap:!1,wordWrapWidth:0,leading:0,dx:"",dy:""},n):i({fill:"black"},n),initialParsedStyle:as.enableCSSParsing?{}:{x:0,y:0,fontSize:16,fontFamily:"sans-serif",fontStyle:"normal",fontWeight:"normal",fontVariant:"normal",lineHeight:0,letterSpacing:0,textBaseline:"alphabetic",textAlign:"start",wordWrap:!1,wordWrapWidth:0,leading:0,dx:0,dy:0}},r))||this}return r(e,t),e.prototype.getComputedTextLength=function(){var t;return(null===(t=this.parsedStyle.metrics)||void 0===t?void 0:t.maxLineWidth)||0},e.prototype.getLineBoundingRects=function(){var t;return(null===(t=this.parsedStyle.metrics)||void 0===t?void 0:t.lineMetrics)||[]},e.prototype.isOverflowing=function(){return!!this.parsedStyle.isOverflowing},e}(ws),Ls=function(){function t(){this.registry={},this.define(jn.CIRCLE,Ms),this.define(jn.ELLIPSE,Ss),this.define(jn.RECT,Ds),this.define(jn.IMAGE,Cs),this.define(jn.LINE,ks),this.define(jn.GROUP,Ts),this.define(jn.PATH,As),this.define(jn.POLYGON,Os),this.define(jn.POLYLINE,Rs),this.define(jn.TEXT,Is),this.define(jn.HTML,Ps)}return t.prototype.define=function(t,e){this.registry[t]=e},t.prototype.get=function(t){return this.registry[t]},t}(),_s=function(t){function e(){var e=t.call(this)||this;e.defaultView=null,e.ownerDocument=null,e.nodeName="document";try{e.timeline=new as.AnimationTimeline(e)}catch(t){}var n={};return To.forEach((function(t){var e=t.n,r=t.inh,i=t.d;r&&i&&(n[e]=jr(i)?i(jn.GROUP):i)})),e.documentElement=new Ts({id:"g-root",style:n}),e.documentElement.ownerDocument=e,e.documentElement.parentNode=e,e.childNodes=[e.documentElement],e}return r(e,t),Object.defineProperty(e.prototype,"children",{get:function(){return this.childNodes},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"childElementCount",{get:function(){return this.childNodes.length},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"firstElementChild",{get:function(){return this.firstChild},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"lastElementChild",{get:function(){return this.lastChild},enumerable:!1,configurable:!0}),e.prototype.createElement=function(t,e){if("svg"===t)return this.documentElement;var n=this.defaultView.customElements.get(t);n||(console.warn("Unsupported tagName: ",t),n="tspan"===t?Is:Ts);var r=new n(e);return r.ownerDocument=this,r},e.prototype.createElementNS=function(t,e,n){return this.createElement(e,n)},e.prototype.cloneNode=function(t){throw new Error(yr)},e.prototype.destroy=function(){try{this.documentElement.destroyChildren(),this.timeline.destroy()}catch(t){}},e.prototype.elementsFromBBox=function(t,e,n,r){var i=this.defaultView.context.rBushRoot.search({minX:t,minY:e,maxX:n,maxY:r}),o=[];return i.forEach((function(t){var e=t.displayObject,n=e.parsedStyle.pointerEvents,r=["auto","visiblepainted","visiblefill","visiblestroke","visible"].includes(n);(!r||r&&e.isVisible())&&!e.isCulled()&&e.isInteractive()&&o.push(e)})),o.sort((function(t,e){return e.sortable.renderOrder-t.sortable.renderOrder})),o},e.prototype.elementFromPointSync=function(t,e){var n=this.defaultView.canvas2Viewport({x:t,y:e}),r=n.x,i=n.y,o=this.defaultView.getConfig(),a=o.width,s=o.height;if(r<0||i<0||r>a||i>s)return null;var u=this.defaultView.viewport2Client({x:r,y:i}),c=u.x,h=u.y,l=this.defaultView.getRenderingService().hooks.pickSync.call({topmost:!0,position:{x:t,y:e,viewportX:r,viewportY:i,clientX:c,clientY:h},picked:[]}).picked;return l&&l[0]||this.documentElement},e.prototype.elementFromPoint=function(t,e){return a(this,void 0,void 0,(function(){var n,r,i,o,a,u,c,h,l,d;return s(this,(function(s){switch(s.label){case 0:return n=this.defaultView.canvas2Viewport({x:t,y:e}),r=n.x,i=n.y,o=this.defaultView.getConfig(),a=o.width,u=o.height,r<0||i<0||r>a||i>u?[2,null]:(c=this.defaultView.viewport2Client({x:r,y:i}),h=c.x,l=c.y,[4,this.defaultView.getRenderingService().hooks.pick.promise({topmost:!0,position:{x:t,y:e,viewportX:r,viewportY:i,clientX:h,clientY:l},picked:[]})]);case 1:return[2,(d=s.sent().picked)&&d[0]||this.documentElement]}}))}))},e.prototype.elementsFromPointSync=function(t,e){var n=this.defaultView.canvas2Viewport({x:t,y:e}),r=n.x,i=n.y,o=this.defaultView.getConfig(),a=o.width,s=o.height;if(r<0||i<0||r>a||i>s)return[];var u=this.defaultView.viewport2Client({x:r,y:i}),c=u.x,h=u.y,l=this.defaultView.getRenderingService().hooks.pickSync.call({topmost:!1,position:{x:t,y:e,viewportX:r,viewportY:i,clientX:c,clientY:h},picked:[]}).picked;return l[l.length-1]!==this.documentElement&&l.push(this.documentElement),l},e.prototype.elementsFromPoint=function(t,e){return a(this,void 0,void 0,(function(){var n,r,i,o,a,u,c,h,l,d;return s(this,(function(s){switch(s.label){case 0:return n=this.defaultView.canvas2Viewport({x:t,y:e}),r=n.x,i=n.y,o=this.defaultView.getConfig(),a=o.width,u=o.height,r<0||i<0||r>a||i>u?[2,[]]:(c=this.defaultView.viewport2Client({x:r,y:i}),h=c.x,l=c.y,[4,this.defaultView.getRenderingService().hooks.pick.promise({topmost:!1,position:{x:t,y:e,viewportX:r,viewportY:i,clientX:h,clientY:l},picked:[]})]);case 1:return(d=s.sent().picked)[d.length-1]!==this.documentElement&&d.push(this.documentElement),[2,d]}}))}))},e.prototype.appendChild=function(t,e){throw new Error(Er)},e.prototype.insertBefore=function(t,e){throw new Error(Er)},e.prototype.removeChild=function(t,e){throw new Error(Er)},e.prototype.replaceChild=function(t,e,n){throw new Error(Er)},e.prototype.append=function(){throw new Error(Er)},e.prototype.prepend=function(){throw new Error(Er)},e.prototype.getElementById=function(t){return this.documentElement.getElementById(t)},e.prototype.getElementsByName=function(t){return this.documentElement.getElementsByName(t)},e.prototype.getElementsByTagName=function(t){return this.documentElement.getElementsByTagName(t)},e.prototype.getElementsByClassName=function(t){return this.documentElement.getElementsByClassName(t)},e.prototype.querySelector=function(t){return this.documentElement.querySelector(t)},e.prototype.querySelectorAll=function(t){return this.documentElement.querySelectorAll(t)},e.prototype.find=function(t){return this.documentElement.find(t)},e.prototype.findAll=function(t){return this.documentElement.findAll(t)},e}(ja),zs=function(){function t(t){this.strategies=t}return t.prototype.apply=function(e){var n=e.camera,r=e.renderingService,i=e.renderingContext,o=this.strategies;r.hooks.cull.tap(t.tag,(function(t){if(t){var e=t.cullable;return 0===o.length?e.visible=i.unculledEntities.indexOf(t.entity)>-1:e.visible=o.every((function(e){return e.isVisible(n,t)})),!t.isCulled()&&t.isVisible()?t:(t.dispatchEvent(new Ba(Wa.CULLED)),null)}return t})),r.hooks.afterRender.tap(t.tag,(function(t){t.cullable.visibilityPlaneMask=-1}))},t.tag="Culling",t}(),Fs=function(){function t(){var t=this;this.autoPreventDefault=!1,this.rootPointerEvent=new za(null),this.rootWheelEvent=new Fa(null),this.onPointerMove=function(e){var n,r,i,o,a=null===(o=null===(i=t.context.renderingContext.root)||void 0===i?void 0:i.ownerDocument)||void 0===o?void 0:o.defaultView;if(!a.supportsTouchEvents||"touch"!==e.pointerType){var s=t.normalizeToPointerEvent(e,a);try{for(var c=u(s),h=c.next();!h.done;h=c.next()){var l=h.value,d=t.bootstrapEvent(t.rootPointerEvent,l,a,e);t.context.eventService.mapEvent(d)}}catch(t){n={error:t}}finally{try{h&&!h.done&&(r=c.return)&&r.call(c)}finally{if(n)throw n.error}}t.setCursor(t.context.eventService.cursor)}},this.onClick=function(e){var n,r,i,o,a=null===(o=null===(i=t.context.renderingContext.root)||void 0===i?void 0:i.ownerDocument)||void 0===o?void 0:o.defaultView,s=t.normalizeToPointerEvent(e,a);try{for(var c=u(s),h=c.next();!h.done;h=c.next()){var l=h.value,d=t.bootstrapEvent(t.rootPointerEvent,l,a,e);t.context.eventService.mapEvent(d)}}catch(t){n={error:t}}finally{try{h&&!h.done&&(r=c.return)&&r.call(c)}finally{if(n)throw n.error}}t.setCursor(t.context.eventService.cursor)}}return t.prototype.apply=function(e){var n=this;this.context=e;var r=e.renderingService,i=this.context.renderingContext.root.ownerDocument.defaultView;this.context.eventService.setPickHandler((function(t){return n.context.renderingService.hooks.pickSync.call({position:t,picked:[],topmost:!0}).picked[0]||null})),r.hooks.pointerWheel.tap(t.tag,(function(t){var e=n.normalizeWheelEvent(t);n.context.eventService.mapEvent(e)})),r.hooks.pointerDown.tap(t.tag,(function(t){var e,r;if(!i.supportsTouchEvents||"touch"!==t.pointerType){var o=n.normalizeToPointerEvent(t,i);if(n.autoPreventDefault&&o[0].isNormalized)(t.cancelable||!("cancelable"in t))&&t.preventDefault();try{for(var a=u(o),s=a.next();!s.done;s=a.next()){var c=s.value,h=n.bootstrapEvent(n.rootPointerEvent,c,i,t);n.context.eventService.mapEvent(h)}}catch(t){e={error:t}}finally{try{s&&!s.done&&(r=a.return)&&r.call(a)}finally{if(e)throw e.error}}n.setCursor(n.context.eventService.cursor)}})),r.hooks.pointerUp.tap(t.tag,(function(t){var e,r;if(!i.supportsTouchEvents||"touch"!==t.pointerType){var o=n.context.contextService.getDomElement(),a="outside";try{a=o&&t.target&&t.target!==o&&o.contains&&!o.contains(t.target)?"outside":""}catch(t){}var s=n.normalizeToPointerEvent(t,i);try{for(var c=u(s),h=c.next();!h.done;h=c.next()){var l=h.value,d=n.bootstrapEvent(n.rootPointerEvent,l,i,t);d.type+=a,n.context.eventService.mapEvent(d)}}catch(t){e={error:t}}finally{try{h&&!h.done&&(r=c.return)&&r.call(c)}finally{if(e)throw e.error}}n.setCursor(n.context.eventService.cursor)}})),r.hooks.pointerMove.tap(t.tag,this.onPointerMove),r.hooks.pointerOver.tap(t.tag,this.onPointerMove),r.hooks.pointerOut.tap(t.tag,this.onPointerMove),r.hooks.click.tap(t.tag,this.onClick),r.hooks.pointerCancel.tap(t.tag,(function(t){var e,r,o=n.normalizeToPointerEvent(t,i);try{for(var a=u(o),s=a.next();!s.done;s=a.next()){var c=s.value,h=n.bootstrapEvent(n.rootPointerEvent,c,i,t);n.context.eventService.mapEvent(h)}}catch(t){e={error:t}}finally{try{s&&!s.done&&(r=a.return)&&r.call(a)}finally{if(e)throw e.error}}n.setCursor(n.context.eventService.cursor)}))},t.prototype.getViewportXY=function(t){var e,n,r=t.offsetX,i=t.offsetY,o=t.clientX,a=t.clientY;if(!this.context.config.supportsCSSTransform||Pt(r)||Pt(i)){var s=this.context.eventService.client2Viewport(new mr(o,a));e=s.x,n=s.y}else e=r,n=i;return{x:e,y:n}},t.prototype.bootstrapEvent=function(t,e,n,r){t.view=n,t.originalEvent=null,t.nativeEvent=r,t.pointerId=e.pointerId,t.width=e.width,t.height=e.height,t.isPrimary=e.isPrimary,t.pointerType=e.pointerType,t.pressure=e.pressure,t.tangentialPressure=e.tangentialPressure,t.tiltX=e.tiltX,t.tiltY=e.tiltY,t.twist=e.twist,this.transferMouseData(t,e);var i=this.getViewportXY(e),o=i.x,a=i.y;t.viewport.x=o,t.viewport.y=a;var s=this.context.eventService.viewport2Canvas(t.viewport),u=s.x,c=s.y;return t.canvas.x=u,t.canvas.y=c,t.global.copyFrom(t.canvas),t.offset.copyFrom(t.canvas),t.isTrusted=r.isTrusted,"pointerleave"===t.type&&(t.type="pointerout"),t.type.startsWith("mouse")&&(t.type=t.type.replace("mouse","pointer")),t.type.startsWith("touch")&&(t.type=ia[t.type]||t.type),t},t.prototype.normalizeWheelEvent=function(t){var e=this.rootWheelEvent;this.transferMouseData(e,t),e.deltaMode=t.deltaMode,e.deltaX=t.deltaX,e.deltaY=t.deltaY,e.deltaZ=t.deltaZ;var n=this.getViewportXY(t),r=n.x,i=n.y;e.viewport.x=r,e.viewport.y=i;var o=this.context.eventService.viewport2Canvas(e.viewport),a=o.x,s=o.y;return e.canvas.x=a,e.canvas.y=s,e.global.copyFrom(e.canvas),e.offset.copyFrom(e.canvas),e.nativeEvent=t,e.type=t.type,e},t.prototype.transferMouseData=function(t,e){t.isTrusted=e.isTrusted,t.srcElement=e.srcElement,t.timeStamp=oa.now(),t.type=e.type,t.altKey=e.altKey,t.metaKey=e.metaKey,t.shiftKey=e.shiftKey,t.ctrlKey=e.ctrlKey,t.button=e.button,t.buttons=e.buttons,t.client.x=e.clientX,t.client.y=e.clientY,t.movement.x=e.movementX,t.movement.y=e.movementY,t.page.x=e.pageX,t.page.y=e.pageY,t.screen.x=e.screenX,t.screen.y=e.screenY,t.relatedTarget=null},t.prototype.setCursor=function(t){this.context.contextService.applyCursorStyle(t||this.context.config.cursor||"default")},t.prototype.normalizeToPointerEvent=function(t,e){var n=[];if(e.isTouchEvent(t))for(var r=0;r<t.changedTouches.length;r++){var i=t.changedTouches[r];$t(i.button)&&(i.button=0),$t(i.buttons)&&(i.buttons=1),$t(i.isPrimary)&&(i.isPrimary=1===t.touches.length&&"touchstart"===t.type),$t(i.width)&&(i.width=i.radiusX||1),$t(i.height)&&(i.height=i.radiusY||1),$t(i.tiltX)&&(i.tiltX=0),$t(i.tiltY)&&(i.tiltY=0),$t(i.pointerType)&&(i.pointerType="touch"),$t(i.pointerId)&&(i.pointerId=i.identifier||0),$t(i.pressure)&&(i.pressure=i.force||.5),$t(i.twist)&&(i.twist=0),$t(i.tangentialPressure)&&(i.tangentialPressure=0),i.isNormalized=!0,i.type=t.type,n.push(i)}else if(e.isMouseEvent(t)){var o=t;$t(o.isPrimary)&&(o.isPrimary=!0),$t(o.width)&&(o.width=1),$t(o.height)&&(o.height=1),$t(o.tiltX)&&(o.tiltX=0),$t(o.tiltY)&&(o.tiltY=0),$t(o.pointerType)&&(o.pointerType="mouse"),$t(o.pointerId)&&(o.pointerId=1),$t(o.pressure)&&(o.pressure=.5),$t(o.twist)&&(o.twist=0),$t(o.tangentialPressure)&&(o.tangentialPressure=0),o.isNormalized=!0,n.push(o)}else n.push(t);return n},t.tag="Event",t}(),Bs=[jn.CIRCLE,jn.ELLIPSE,jn.IMAGE,jn.RECT,jn.LINE,jn.POLYLINE,jn.POLYGON,jn.TEXT,jn.PATH,jn.HTML],Gs=function(){function t(){}return t.prototype.isVisible=function(t,e){var n,r,i=e.cullable;if(!i.enable)return!0;var o=e.getRenderBounds();if(hr.isEmpty(o))return!1;var a=t.getFrustum(),s=null===(r=null===(n=e.parentNode)||void 0===n?void 0:n.cullable)||void 0===r?void 0:r.visibilityPlaneMask;return i.visibilityPlaneMask=this.computeVisibilityWithPlaneMask(e,o,s||cr.INDETERMINATE,a.planes),i.visible=i.visibilityPlaneMask!==cr.OUTSIDE,i.visible},t.prototype.computeVisibilityWithPlaneMask=function(t,e,n,r){if(n===cr.OUTSIDE||n===cr.INSIDE)return n;for(var i=cr.INSIDE,o=Bs.indexOf(t.nodeName)>-1,a=0,s=r.length;a<s;++a){var u=1<<a;if(n&u&&(!o||4!==a&&5!==a)){var c=r[a],h=c.normal,l=c.distance;if(ot(h,e.getPositiveFarPoint(r[a]))+l<0)return cr.OUTSIDE;ot(h,e.getNegativeFarPoint(r[a]))+l<0&&(i|=u)}}return i},t}(),js=function(){function t(){this.toSync=new Set}return t.prototype.apply=function(e){var n=this,r=e.renderingService,i=e.renderingContext,o=e.rBushRoot,a=i.root.ownerDocument.defaultView;this.rBush=o;var s=function(t){t.target.renderable.dirty=!0,r.dirtify()},u=function(t){var e=t.detail.affectChildren,i=t.target;e&&i.forEach((function(t){n.toSync.add(t)}));for(var o=i;o;)o.renderable&&n.toSync.add(o),o=o.parentElement;r.dirtify()},c=function(t){var e=t.target;as.enableSizeAttenuation&&as.styleValueRegistry.updateSizeAttenuation(e,a.getCamera().getZoom()),as.enableCSSParsing&&as.styleValueRegistry.recalc(e),as.sceneGraphService.dirtifyToRoot(e),r.dirtify()},h=function(t){var e=t.target,i=e.rBushNode;i.aabb&&n.rBush.remove(i.aabb),n.toSync.delete(e),as.sceneGraphService.dirtifyToRoot(e),r.dirtify()};r.hooks.init.tap(t.tag,(function(){a.addEventListener(Wa.MOUNTED,c),a.addEventListener(Wa.UNMOUNTED,h),a.addEventListener(Wa.ATTR_MODIFIED,s),a.addEventListener(Wa.BOUNDS_CHANGED,u)})),r.hooks.destroy.tap(t.tag,(function(){a.removeEventListener(Wa.MOUNTED,c),a.removeEventListener(Wa.UNMOUNTED,h),a.removeEventListener(Wa.ATTR_MODIFIED,s),a.removeEventListener(Wa.BOUNDS_CHANGED,u),n.toSync.clear()})),r.hooks.endFrame.tap(t.tag,(function(){n.syncRTree()}))},t.prototype.syncRTree=function(){var t=this,e=[];Array.from(this.toSync).filter((function(t){return t.isConnected})).forEach((function(n){var r=n.rBushNode;r&&r.aabb&&t.rBush.remove(r.aabb);var i=n.getRenderBounds();if(i){var o=c(i.getMin(),2),a=o[0],s=o[1],u=c(i.getMax(),2),h=u[0],l=u[1];r.aabb||(r.aabb={}),r.aabb.displayObject=n,r.aabb.minX=a,r.aabb.minY=s,r.aabb.maxX=h,r.aabb.maxY=l}r.aabb&&(isNaN(r.aabb.maxX)||isNaN(r.aabb.maxX)||isNaN(r.aabb.minX)||isNaN(r.aabb.minY)||e.push(r.aabb))})),this.rBush.load(e),e.length=0,this.toSync.clear()},t.tag="Prepare",t}();!function(t){t.READY="ready",t.BEFORE_RENDER="beforerender",t.RERENDER="rerender",t.AFTER_RENDER="afterrender",t.BEFORE_DESTROY="beforedestroy",t.AFTER_DESTROY="afterdestroy",t.RESIZE="resize",t.DIRTY_RECTANGLE="dirtyrectangle",t.RENDERER_CHANGED="rendererchanged"}(gs||(gs={}));var Vs=new Ba(Wa.MOUNTED),Us=new Ba(Wa.UNMOUNTED),Ws=new Ba(gs.BEFORE_RENDER),Hs=new Ba(gs.RERENDER),qs=new Ba(gs.AFTER_RENDER),Ys=function(t){function e(e){var n=t.call(this)||this;n.Element=ws,n.inited=!1,n.context={},n.document=new _s,n.document.defaultView=n,n.customElements=new Ls;var r=e.container,i=e.canvas,o=e.offscreenCanvas,a=e.width,s=e.height,u=e.devicePixelRatio,c=e.renderer,h=e.background,l=e.cursor,d=e.document,f=e.requestAnimationFrame,p=e.cancelAnimationFrame,g=e.createImage,m=e.supportsPointerEvents,v=e.supportsTouchEvents,y=e.supportsCSSTransform,E=e.supportsMutipleCanvasesInOneContainer,x=e.useNativeClickEvent,b=e.alwaysTriggerPointerEventOnCanvas,w=e.isTouchEvent,M=e.isMouseEvent;E||function(t,e){if(t){var n="string"==typeof t?t:t.id||Qo++;Zo[n]&&Zo[n].destroy(),Zo[n]=e}}(r,n);var N=a,S=s,T=u;return i&&(T=(T=u||Jo&&window.devicePixelRatio||1)>=1?Math.ceil(T):1,N=a||function(t){var e=ra(t,"width");return"auto"===e?t.offsetWidth:parseFloat(e)}(i)||i.width/T,S=s||function(t){var e=ra(t,"height");return"auto"===e?t.offsetHeight:parseFloat(e)}(i)||i.height/T),o&&(as.offscreenCanvas=o),n.devicePixelRatio=T,n.requestAnimationFrame=null!=f?f:ma.bind(as.globalThis),n.cancelAnimationFrame=null!=p?p:va.bind(as.globalThis),n.supportsTouchEvents=null!=v?v:"ontouchstart"in as.globalThis,n.supportsPointerEvents=null!=m?m:!!as.globalThis.PointerEvent,n.isTouchEvent=null!=w?w:function(t){return n.supportsTouchEvents&&t instanceof as.globalThis.TouchEvent},n.isMouseEvent=null!=M?M:function(t){return!as.globalThis.MouseEvent||t instanceof as.globalThis.MouseEvent&&(!n.supportsPointerEvents||!(t instanceof as.globalThis.PointerEvent))},n.initRenderingContext({container:r,canvas:i,width:N,height:S,renderer:c,offscreenCanvas:o,devicePixelRatio:T,cursor:l||"default",background:h||"transparent",createImage:g,document:d,supportsCSSTransform:y,useNativeClickEvent:x,alwaysTriggerPointerEventOnCanvas:b}),n.initDefaultCamera(N,S,c.clipSpaceNearZ),n.initRenderer(c,!0),n}return r(e,t),e.prototype.initRenderingContext=function(t){this.context.config=t,this.context.renderingContext={root:this.document.documentElement,renderListCurrentFrame:[],unculledEntities:[],renderReasons:new Set,force:!1,dirty:!1}},e.prototype.initDefaultCamera=function(t,e,n){var r=this,i=new as.CameraContribution;i.clipSpaceNearZ=n,i.setType(dr.EXPLORING,fr.DEFAULT).setPosition(t/2,e/2,500).setFocalPoint(t/2,e/2,0).setOrthographic(t/-2,t/2,e/2,e/-2,.1,1e3),i.canvas=this,i.eventEmitter.on(Sr,(function(){r.context.renderingContext.renderReasons.add(Ia.CAMERA_CHANGED),as.enableSizeAttenuation&&r.getConfig().renderer.getConfig().enableSizeAttenuation&&r.updateSizeAttenuation()})),this.context.camera=i},e.prototype.updateSizeAttenuation=function(){var t=this.getCamera().getZoom();this.document.documentElement.forEach((function(e){as.styleValueRegistry.updateSizeAttenuation(e,t)}))},e.prototype.getConfig=function(){return this.context.config},e.prototype.getRoot=function(){return this.document.documentElement},e.prototype.getCamera=function(){return this.context.camera},e.prototype.getContextService=function(){return this.context.contextService},e.prototype.getEventService=function(){return this.context.eventService},e.prototype.getRenderingService=function(){return this.context.renderingService},e.prototype.getRenderingContext=function(){return this.context.renderingContext},e.prototype.getStats=function(){return this.getRenderingService().getStats()},Object.defineProperty(e.prototype,"ready",{get:function(){var t=this;return this.readyPromise||(this.readyPromise=new Promise((function(e){t.resolveReadyPromise=function(){e(t)}})),this.inited&&this.resolveReadyPromise()),this.readyPromise},enumerable:!1,configurable:!0}),e.prototype.destroy=function(t,e){(void 0===t&&(t=!0),void 0===e&&(e=!1),e||this.dispatchEvent(new Ba(gs.BEFORE_DESTROY)),this.frameId)&&(this.getConfig().cancelAnimationFrame||cancelAnimationFrame)(this.frameId);var n=this.getRoot();this.unmountChildren(n),t&&(this.document.destroy(),this.getEventService().destroy()),this.getRenderingService().destroy(),this.getContextService().destroy(),t&&this.context.rBushRoot&&(this.context.rBushRoot.clear(),this.context.rBushRoot=null,this.context.renderingContext.root=null),e||this.dispatchEvent(new Ba(gs.AFTER_DESTROY))},e.prototype.changeSize=function(t,e){this.resize(t,e)},e.prototype.resize=function(t,e){var n=this.context.config;n.width=t,n.height=e,this.getContextService().resize(t,e);var r=this.context.camera,i=r.getProjectionMode();r.setPosition(t/2,e/2,500).setFocalPoint(t/2,e/2,0),i===pr.ORTHOGRAPHIC?r.setOrthographic(t/-2,t/2,e/2,e/-2,r.getNear(),r.getFar()):r.setAspect(t/e),this.dispatchEvent(new Ba(gs.RESIZE,{width:t,height:e}))},e.prototype.appendChild=function(t,e){return this.document.documentElement.appendChild(t,e)},e.prototype.insertBefore=function(t,e){return this.document.documentElement.insertBefore(t,e)},e.prototype.removeChild=function(t){return this.document.documentElement.removeChild(t)},e.prototype.removeChildren=function(){this.document.documentElement.removeChildren()},e.prototype.destroyChildren=function(){this.document.documentElement.destroyChildren()},e.prototype.render=function(){var t=this;this.dispatchEvent(Ws),this.getRenderingService().render(this.getConfig(),(function(){t.dispatchEvent(Hs)})),this.dispatchEvent(qs)},e.prototype.run=function(){var t=this,e=function(){t.render(),t.frameId=t.requestAnimationFrame(e)};e()},e.prototype.initRenderer=function(t,e){var n=this;if(void 0===e&&(e=!1),!t)throw new Error("Renderer is required.");this.inited=!1,this.readyPromise=void 0,this.context.rBushRoot=new Un,this.context.renderingPlugins=[],this.context.renderingPlugins.push(new Fs,new js,new zs([new Gs])),this.loadRendererContainerModule(t),this.context.contextService=new this.context.ContextService(i(i({},as),this.context)),this.context.renderingService=new Ha(as,this.context),this.context.eventService=new Va(as,this.context),this.context.eventService.init(),this.context.contextService.init?(this.context.contextService.init(),this.initRenderingService(t,e,!0)):this.context.contextService.initAsync().then((function(){n.initRenderingService(t,e)}))},e.prototype.initRenderingService=function(t,e,n){var r=this;void 0===e&&(e=!1),void 0===n&&(n=!1),this.context.renderingService.init((function(){r.inited=!0,e?(n?r.requestAnimationFrame((function(){r.dispatchEvent(new Ba(gs.READY))})):r.dispatchEvent(new Ba(gs.READY)),r.readyPromise&&r.resolveReadyPromise()):r.dispatchEvent(new Ba(gs.RENDERER_CHANGED)),e||r.getRoot().forEach((function(t){var e=t.renderable;e&&(e.renderBoundsDirty=!0,e.boundsDirty=!0,e.dirty=!0)})),r.mountChildren(r.getRoot()),t.getConfig().enableAutoRendering&&r.run()}))},e.prototype.loadRendererContainerModule=function(t){var e=this;t.getPlugins().forEach((function(t){t.context=e.context,t.init(as)}))},e.prototype.setRenderer=function(t){var e=this.getConfig();if(e.renderer!==t){var n=e.renderer;e.renderer=t,this.destroy(!1,!0),h([],c(null==n?void 0:n.getPlugins()),!1).reverse().forEach((function(t){t.destroy(as)})),this.initRenderer(t)}},e.prototype.setCursor=function(t){this.getConfig().cursor=t,this.getContextService().applyCursorStyle(t)},e.prototype.unmountChildren=function(t){var e=this;t.childNodes.forEach((function(t){e.unmountChildren(t)})),this.inited&&(t.isMutationObserved?t.dispatchEvent(Us):(Us.target=t,this.dispatchEvent(Us,!0)),t!==this.document.documentElement&&(t.ownerDocument=null),t.isConnected=!1),t.isCustomElement&&t.disconnectedCallback&&t.disconnectedCallback()},e.prototype.mountChildren=function(t){var e=this;this.inited?t.isConnected||(t.ownerDocument=this.document,t.isConnected=!0,t.isMutationObserved?t.dispatchEvent(Vs):(Vs.target=t,this.dispatchEvent(Vs,!0))):console.warn("[g]: You are trying to call `canvas.appendChild` before canvas' initialization finished. You can either await `canvas.ready` or listen to `CanvasEvent.READY` manually.","appended child: ",t.nodeName),t.childNodes.forEach((function(t){e.mountChildren(t)})),t.isCustomElement&&t.connectedCallback&&t.connectedCallback()},e.prototype.client2Viewport=function(t){return this.getEventService().client2Viewport(t)},e.prototype.viewport2Client=function(t){return this.getEventService().viewport2Client(t)},e.prototype.viewport2Canvas=function(t){return this.getEventService().viewport2Canvas(t)},e.prototype.canvas2Viewport=function(t){return this.getEventService().canvas2Viewport(t)},e.prototype.getPointByClient=function(t,e){return this.client2Viewport({x:t,y:e})},e.prototype.getClientByPoint=function(t,e){return this.viewport2Client({x:t,y:e})},e}(Ga),Xs=function(t){function e(){var e=t.apply(this,h([],c(arguments),!1))||this;return e.landmarks=[],e}return r(e,t),e.prototype.rotate=function(t,e,n){if(this.relElevation=$n(e),this.relAzimuth=$n(t),this.relRoll=$n(n),this.elevation+=this.relElevation,this.azimuth+=this.relAzimuth,this.roll+=this.relRoll,this.type===dr.EXPLORING){var r=gt(pt(),[1,0,0],Qn((this.rotateWorld?1:-1)*this.relElevation)),i=gt(pt(),[0,1,0],Qn((this.rotateWorld?1:-1)*this.relAzimuth)),o=gt(pt(),[0,0,1],Qn(this.relRoll)),a=mt(pt(),i,r);a=mt(pt(),a,o);var s=F(y(),a);P(this.matrix,this.matrix,[0,0,-this.distance]),T(this.matrix,this.matrix,s),P(this.matrix,this.matrix,[0,0,this.distance])}else{if(Math.abs(this.elevation)>90)return this;this.computeMatrix()}return this._getAxes(),this.type===dr.ORBITING||this.type===dr.EXPLORING?this._getPosition():this.type===dr.TRACKING&&this._getFocalPoint(),this._update(),this},e.prototype.pan=function(t,e){var n=Zn(t,e,0),r=$(this.position);return et(r,r,rt(K(),this.right,n[0])),et(r,r,rt(K(),this.up,n[1])),this._setPosition(r),this.triggerUpdate(),this},e.prototype.dolly=function(t){var e=this.forward,n=$(this.position),r=this.dollyingStep,i=this.distance+t*this.dollyingStep;return r=Math.max(Math.min(i,this.maxDistance),this.minDistance)-this.distance,n[0]+=r*e[0],n[1]+=r*e[1],n[2]+=r*e[2],this._setPosition(n),this.type===dr.ORBITING||this.type===dr.EXPLORING?this._getDistance():this.type===dr.TRACKING&&et(this.focalPoint,n,this.distanceVector),this.triggerUpdate(),this},e.prototype.cancelLandmarkAnimation=function(){void 0!==this.landmarkAnimationID&&this.canvas.cancelAnimationFrame(this.landmarkAnimationID)},e.prototype.createLandmark=function(t,e){var n,r,i,o;void 0===e&&(e={});var a=e.position,s=void 0===a?this.position:a,u=e.focalPoint,c=void 0===u?this.focalPoint:u,h=e.roll,l=e.zoom,d=new as.CameraContribution;d.setType(this.type,void 0),d.setPosition(s[0],null!==(n=s[1])&&void 0!==n?n:this.position[1],null!==(r=s[2])&&void 0!==r?r:this.position[2]),d.setFocalPoint(c[0],null!==(i=c[1])&&void 0!==i?i:this.focalPoint[1],null!==(o=c[2])&&void 0!==o?o:this.focalPoint[2]),d.setRoll(null!=h?h:this.roll),d.setZoom(null!=l?l:this.zoom);var f={name:t,matrix:E(d.getWorldTransform()),right:$(d.right),up:$(d.up),forward:$(d.forward),position:$(d.getPosition()),focalPoint:$(d.getFocalPoint()),distanceVector:$(d.getDistanceVector()),distance:d.getDistance(),dollyingStep:d.getDollyingStep(),azimuth:d.getAzimuth(),elevation:d.getElevation(),roll:d.getRoll(),relAzimuth:d.relAzimuth,relElevation:d.relElevation,relRoll:d.relRoll,zoom:d.getZoom()};return this.landmarks.push(f),f},e.prototype.gotoLandmark=function(t,e){var n=this;void 0===e&&(e={});var r=zt(t)?this.landmarks.find((function(e){return e.name===t})):t;if(r){var i=jt(e)?{duration:e}:e,o=i.easing,a=void 0===o?"linear":o,s=i.duration,u=void 0===s?100:s,c=i.easingFunction,h=void 0===c?void 0:c,l=i.onfinish,d=void 0===l?void 0:l,f=i.onframe,p=void 0===f?void 0:f;if(0===u)return this.syncFromLandmark(r),void(d&&d());this.cancelLandmarkAnimation();var g,m=r.position,v=r.focalPoint,y=r.zoom,E=r.roll,x=h||as.EasingFunction(a),b=function(){n.setFocalPoint(v),n.setPosition(m),n.setRoll(E),n.setZoom(y),n.computeMatrix(),n.triggerUpdate(),d&&d()},w=function(t){void 0===g&&(g=t);var e=t-g;if(e>u)b();else{var r,i,o=x(e/u),a=K(),s=K();st(a,n.focalPoint,v,o),st(s,n.position,m,o),i=n.roll*(1-o)+E*o,r=n.zoom*(1-o)+y*o,n.setFocalPoint(a),n.setPosition(s),n.setRoll(i),n.setZoom(r),ht(a,v)+ht(s,m)<=.01&&null==y&&null==E?b():(n.computeMatrix(),n.triggerUpdate(),e<u&&(p&&p(o),n.landmarkAnimationID=n.canvas.requestAnimationFrame(w)))}};this.canvas.requestAnimationFrame(w)}},e.prototype.syncFromLandmark=function(t){this.matrix=x(this.matrix,t.matrix),this.right=J(this.right,t.right),this.up=J(this.up,t.up),this.forward=J(this.forward,t.forward),this.position=J(this.position,t.position),this.focalPoint=J(this.focalPoint,t.focalPoint),this.distanceVector=J(this.distanceVector,t.distanceVector),this.azimuth=t.azimuth,this.elevation=t.elevation,this.roll=t.roll,this.relAzimuth=t.relAzimuth,this.relElevation=t.relElevation,this.relRoll=t.relRoll,this.dollyingStep=t.dollyingStep,this.distance=t.distance,this.zoom=t.zoom},e}(Pr);as.CameraContribution=Xs;var Ks=function(t){function e(e,n,r,i){var o=t.call(this,e)||this;return o.currentTime=r,o.timelineTime=i,o.target=n,o.type="finish",o.bubbles=!1,o.currentTarget=n,o.defaultPrevented=!1,o.eventPhase=o.AT_TARGET,o.timeStamp=Date.now(),o.currentTime=r,o.timelineTime=i,o}return r(e,t),e}(La),$s=0,Zs=function(){function t(t,e){var n;this.currentTimePending=!1,this._idle=!0,this._paused=!1,this._finishedFlag=!0,this._currentTime=0,this._playbackRate=1,this._inTimeline=!0,this.effect=t,t.animation=this,this.timeline=e,this.id="".concat($s++),this._inEffect=!!this.effect.update(0),this._totalDuration=Number(null===(n=this.effect)||void 0===n?void 0:n.getComputedTiming().endTime),this._holdTime=0,this._paused=!1,this.oldPlayState="idle",this.updatePromises()}return Object.defineProperty(t.prototype,"pending",{get:function(){return null===this._startTime&&!this._paused&&0!==this.playbackRate||this.currentTimePending},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"playState",{get:function(){return this._idle?"idle":this._isFinished?"finished":this._paused?"paused":"running"},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"ready",{get:function(){var t=this;return this.readyPromise||(-1===this.timeline.animationsWithPromises.indexOf(this)&&this.timeline.animationsWithPromises.push(this),this.readyPromise=new Promise((function(e,n){t.resolveReadyPromise=function(){e(t)},t.rejectReadyPromise=function(){n(new Error)}})),this.pending||this.resolveReadyPromise()),this.readyPromise},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"finished",{get:function(){var t=this;return this.finishedPromise||(-1===this.timeline.animationsWithPromises.indexOf(this)&&this.timeline.animationsWithPromises.push(this),this.finishedPromise=new Promise((function(e,n){t.resolveFinishedPromise=function(){e(t)},t.rejectFinishedPromise=function(){n(new Error)}})),"finished"===this.playState&&this.resolveFinishedPromise()),this.finishedPromise},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"currentTime",{get:function(){return this.updatePromises(),this._idle||this.currentTimePending?null:this._currentTime},set:function(t){var e;t=Number(t),isNaN(t)||(this.timeline.restart(),this._paused||null===this._startTime||(this._startTime=Number(null===(e=this.timeline)||void 0===e?void 0:e.currentTime)-t/this.playbackRate),this.currentTimePending=!1,this._currentTime!==t&&(this._idle&&(this._idle=!1,this._paused=!0),this.tickCurrentTime(t,!0),this.timeline.applyDirtiedAnimation(this)))},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"startTime",{get:function(){return this._startTime},set:function(t){if(null!==t){if(this.updatePromises(),t=Number(t),isNaN(t))return;if(this._paused||this._idle)return;this._startTime=t,this.tickCurrentTime((Number(this.timeline.currentTime)-this._startTime)*this.playbackRate),this.timeline.applyDirtiedAnimation(this),this.updatePromises()}},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"playbackRate",{get:function(){return this._playbackRate},set:function(t){if(t!==this._playbackRate){this.updatePromises();var e=this.currentTime;this._playbackRate=t,this.startTime=null,"paused"!==this.playState&&"idle"!==this.playState&&(this._finishedFlag=!1,this._idle=!1,this.ensureAlive(),this.timeline.applyDirtiedAnimation(this)),null!==e&&(this.currentTime=e),this.updatePromises()}},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"_isFinished",{get:function(){return!this._idle&&(this._playbackRate>0&&Number(this._currentTime)>=this._totalDuration||this._playbackRate<0&&Number(this._currentTime)<=0)},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"totalDuration",{get:function(){return this._totalDuration},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"_needsTick",{get:function(){return this.pending||"running"===this.playState||!this._finishedFlag},enumerable:!1,configurable:!0}),t.prototype.updatePromises=function(){var t=this.oldPlayState,e=this.pending?"pending":this.playState;return this.readyPromise&&e!==t&&("idle"===e?(this.rejectReadyPromise(),this.readyPromise=void 0):"pending"===t?this.resolveReadyPromise():"pending"===e&&(this.readyPromise=void 0)),this.finishedPromise&&e!==t&&("idle"===e?(this.rejectFinishedPromise(),this.finishedPromise=void 0):"finished"===e?this.resolveFinishedPromise():"finished"===t&&(this.finishedPromise=void 0)),this.oldPlayState=e,this.readyPromise||this.finishedPromise},t.prototype.play=function(){this.updatePromises(),this._paused=!1,(this._isFinished||this._idle)&&(this.rewind(),this._startTime=null),this._finishedFlag=!1,this._idle=!1,this.ensureAlive(),this.timeline.applyDirtiedAnimation(this),-1===this.timeline.animations.indexOf(this)&&this.timeline.animations.push(this),this.updatePromises()},t.prototype.pause=function(){this.updatePromises(),this.currentTime&&(this._holdTime=this.currentTime),this._isFinished||this._paused||this._idle?this._idle&&(this.rewind(),this._idle=!1):this.currentTimePending=!0,this._startTime=null,this._paused=!0,this.updatePromises()},t.prototype.finish=function(){this.updatePromises(),this._idle||(this.currentTime=this._playbackRate>0?this._totalDuration:0,this._startTime=this._totalDuration-this.currentTime,this.currentTimePending=!1,this.timeline.applyDirtiedAnimation(this),this.updatePromises())},t.prototype.cancel=function(){var t=this;if(this.updatePromises(),this._inEffect&&(this._inEffect=!1,this._idle=!0,this._paused=!1,this._finishedFlag=!0,this._currentTime=0,this._startTime=null,this.effect.update(null),this.timeline.applyDirtiedAnimation(this),this.updatePromises(),this.oncancel)){var e=new Ks(null,this,this.currentTime,null);setTimeout((function(){t.oncancel(e)}))}},t.prototype.reverse=function(){this.updatePromises();var t=this.currentTime;this.playbackRate*=-1,this.play(),null!==t&&(this.currentTime=t),this.updatePromises()},t.prototype.updatePlaybackRate=function(t){this.playbackRate=t},t.prototype.targetAnimations=function(){var t;return(null===(t=this.effect)||void 0===t?void 0:t.target).getAnimations()},t.prototype.markTarget=function(){var t=this.targetAnimations();-1===t.indexOf(this)&&t.push(this)},t.prototype.unmarkTarget=function(){var t=this.targetAnimations(),e=t.indexOf(this);-1!==e&&t.splice(e,1)},t.prototype.tick=function(t,e){this._idle||this._paused||(null===this._startTime?e&&(this.startTime=t-this._currentTime/this.playbackRate):this._isFinished||this.tickCurrentTime((t-this._startTime)*this.playbackRate)),e&&(this.currentTimePending=!1,this.fireEvents(t))},t.prototype.rewind=function(){if(this.playbackRate>=0)this.currentTime=0;else{if(!(this._totalDuration<1/0))throw new Error("Unable to rewind negative playback rate animation with infinite duration");this.currentTime=this._totalDuration}},t.prototype.persist=function(){throw new Error(yr)},t.prototype.addEventListener=function(t,e,n){throw new Error(yr)},t.prototype.removeEventListener=function(t,e,n){throw new Error(yr)},t.prototype.dispatchEvent=function(t){throw new Error(yr)},t.prototype.commitStyles=function(){throw new Error(yr)},t.prototype.ensureAlive=function(){var t,e;this.playbackRate<0&&0===this.currentTime?this._inEffect=!!(null===(t=this.effect)||void 0===t?void 0:t.update(-1)):this._inEffect=!!(null===(e=this.effect)||void 0===e?void 0:e.update(this.currentTime)),this._inTimeline||!this._inEffect&&this._finishedFlag||(this._inTimeline=!0,this.timeline.animations.push(this))},t.prototype.tickCurrentTime=function(t,e){t!==this._currentTime&&(this._currentTime=t,this._isFinished&&!e&&(this._currentTime=this._playbackRate>0?this._totalDuration:0),this.ensureAlive())},t.prototype.fireEvents=function(t){var e=this;if(this._isFinished){if(!this._finishedFlag){if(this.onfinish){var n=new Ks(null,this,this.currentTime,t);setTimeout((function(){e.onfinish&&e.onfinish(n)}))}this._finishedFlag=!0}}else{if(this.onframe&&"running"===this.playState){var r=new Ks(null,this,this.currentTime,t);this.onframe(r)}this._finishedFlag=!1}},t}(),Qs=.1,Js="function"==typeof Float32Array,tu=function(t,e){return 1-3*e+3*t},eu=function(t,e){return 3*e-6*t},nu=function(t){return 3*t},ru=function(t,e,n){return((tu(e,n)*t+eu(e,n))*t+nu(e))*t},iu=function(t,e,n){return 3*tu(e,n)*t*t+2*eu(e,n)*t+nu(e)},ou=function(t,e,n,r){if(!(0<=t&&t<=1&&0<=n&&n<=1))throw new Error("bezier x values must be in [0, 1] range");if(t===e&&n===r)return function(t){return t};for(var i=Js?new Float32Array(11):new Array(11),o=0;o<11;++o)i[o]=ru(o*Qs,t,n);var a=function(e){for(var r=0,o=1;10!==o&&i[o]<=e;++o)r+=Qs;--o;var a=r+(e-i[o])/(i[o+1]-i[o])*Qs,s=iu(a,t,n);return s>=.001?function(t,e,n,r){for(var i=0;i<4;++i){var o=iu(e,n,r);if(0===o)return e;e-=(ru(e,n,r)-t)/o}return e}(e,a,t,n):0===s?a:function(t,e,n,r,i){var o,a,s=0;do{(o=ru(a=e+(n-e)/2,r,i)-t)>0?n=a:e=a}while(Math.abs(o)>1e-7&&++s<10);return a}(e,r,r+Qs,t,n)};return function(t){return 0===t||1===t?t:ru(a(t),e,r)}},au=function(t){return Math.pow(t,2)},su=function(t){return Math.pow(t,3)},uu=function(t){return Math.pow(t,4)},cu=function(t){return Math.pow(t,5)},hu=function(t){return Math.pow(t,6)},lu=function(t){return 1-Math.cos(t*Math.PI/2)},du=function(t){return 1-Math.sqrt(1-t*t)},fu=function(t){return t*t*(3*t-2)},pu=function(t){for(var e,n=4;t<((e=Math.pow(2,--n))-1)/11;);return 1/Math.pow(4,3-n)-7.5625*Math.pow((3*e-2)/22-t,2)},gu=function(t,e){void 0===e&&(e=[]);var n=c(e,2),r=n[0],i=void 0===r?1:r,o=n[1],a=void 0===o?.5:o,s=Gt(Number(i),1,10),u=Gt(Number(a),.1,2);return 0===t||1===t?t:-s*Math.pow(2,10*(t-1))*Math.sin((t-1-u/(2*Math.PI)*Math.asin(1/s))*(2*Math.PI)/u)},mu=function(t,e,n){void 0===e&&(e=[]);var r=c(e,4),i=r[0],o=void 0===i?1:i,a=r[1],s=void 0===a?100:a,u=r[2],h=void 0===u?10:u,l=r[3],d=void 0===l?0:l;o=Gt(o,.1,1e3),s=Gt(s,.1,1e3),h=Gt(h,.1,1e3),d=Gt(d,.1,1e3);var f=Math.sqrt(s/o),p=h/(2*Math.sqrt(s*o)),g=p<1?f*Math.sqrt(1-p*p):0,m=p<1?(p*f-d)/g:-d+f,v=n?n*t/1e3:t;return v=p<1?Math.exp(-v*p*f)*(1*Math.cos(g*v)+m*Math.sin(g*v)):(1+m*v)*Math.exp(-v*f),0===t||1===t?t:1-v},vu=function(t,e){void 0===e&&(e=[]);var n=c(e,2),r=n[0],i=void 0===r?10:r;return("start"==n[1]?Math.ceil:Math.floor)(Gt(t,0,1)*i)/i},yu=function(t,e){void 0===e&&(e=[]);var n=c(e,4),r=n[0],i=n[1],o=n[2],a=n[3];return ou(r,i,o,a)(t)},Eu=ou(.42,0,1,1),xu=function(t){return function(e,n,r){return void 0===n&&(n=[]),1-t(1-e,n,r)}},bu=function(t){return function(e,n,r){return void 0===n&&(n=[]),e<.5?t(2*e,n,r)/2:1-t(-2*e+2,n,r)/2}},wu=function(t){return function(e,n,r){return void 0===n&&(n=[]),e<.5?(1-t(1-2*e,n,r))/2:(t(2*e-1,n,r)+1)/2}},Mu={steps:vu,"step-start":function(t){return vu(t,[1,"start"])},"step-end":function(t){return vu(t,[1,"end"])},linear:function(t){return t},"cubic-bezier":yu,ease:function(t){return yu(t,[.25,.1,.25,1])},in:Eu,out:xu(Eu),"in-out":bu(Eu),"out-in":wu(Eu),"in-quad":au,"out-quad":xu(au),"in-out-quad":bu(au),"out-in-quad":wu(au),"in-cubic":su,"out-cubic":xu(su),"in-out-cubic":bu(su),"out-in-cubic":wu(su),"in-quart":uu,"out-quart":xu(uu),"in-out-quart":bu(uu),"out-in-quart":wu(uu),"in-quint":cu,"out-quint":xu(cu),"in-out-quint":bu(cu),"out-in-quint":wu(cu),"in-expo":hu,"out-expo":xu(hu),"in-out-expo":bu(hu),"out-in-expo":wu(hu),"in-sine":lu,"out-sine":xu(lu),"in-out-sine":bu(lu),"out-in-sine":wu(lu),"in-circ":du,"out-circ":xu(du),"in-out-circ":bu(du),"out-in-circ":wu(du),"in-back":fu,"out-back":xu(fu),"in-out-back":bu(fu),"out-in-back":wu(fu),"in-bounce":pu,"out-bounce":xu(pu),"in-out-bounce":bu(pu),"out-in-bounce":wu(pu),"in-elastic":gu,"out-elastic":xu(gu),"in-out-elastic":bu(gu),"out-in-elastic":wu(gu),spring:mu,"spring-in":mu,"spring-out":xu(mu),"spring-in-out":bu(mu),"spring-out-in":wu(mu)},Nu=function(t){return Mu[function(t){return function(t){return"-"===(t=t.replace(/([A-Z])/g,(function(t){return"-".concat(t.toLowerCase())}))).charAt(0)?t.substring(1):t}(t).replace(/^ease-/,"").replace(/(\(|\s).+/,"").toLowerCase().trim()}(t)]||Mu.linear},Su=function(t){return t},Tu=1,Pu=.5,Cu=0;function ku(t,e){return function(n){if(n>=1)return 1;var r=1/t;return(n+=e*r)-n%r}}var Au="\\s*(-?\\d+\\.?\\d*|-?\\.\\d+)\\s*",Ou=new RegExp("cubic-bezier\\("+Au+","+Au+","+Au+","+Au+"\\)"),Ru=/steps\(\s*(\d+)\s*\)/,Du=/steps\(\s*(\d+)\s*,\s*(start|middle|end)\s*\)/;function Iu(t){var e=Ou.exec(t);if(e)return ou.apply(void 0,h([],c(e.slice(1).map(Number)),!1));var n=Ru.exec(t);if(n)return ku(Number(n[1]),Cu);var r=Du.exec(t);return r?ku(Number(r[1]),{start:Tu,middle:Pu,end:Cu}[r[2]]):Nu(t)}function Lu(t){return Math.abs(function(t){var e;if(0===t.duration||0===t.iterations)return 0;return("auto"===t.duration?0:Number(t.duration))*(null!==(e=t.iterations)&&void 0!==e?e:1)}(t)/(t.playbackRate||1))}var _u=0,zu=1,Fu=2,Bu=3;function Gu(t,e,n){var r=function(t,e,n){if(null===e)return _u;var r=n.endTime;return e<Math.min(n.delay,r)?zu:e>=Math.min(n.delay+t+n.endDelay,r)?Fu:Bu}(t,e,n),i=function(t,e,n,r,i){switch(r){case zu:return"backwards"===e||"both"===e?0:null;case Bu:return n-i;case Fu:return"forwards"===e||"both"===e?t:null;case _u:return null}}(t,n.fill,e,r,n.delay);if(null===i)return null;var o="auto"===n.duration?0:n.duration,a=function(t,e,n,r,i){var o=i;return 0===t?e!==zu&&(o+=n):o+=r/t,o}(o,r,n.iterations,i,n.iterationStart),s=function(t,e,n,r,i,o){var a=t===1/0?e%1:t%1;return 0!==a||n!==Fu||0===r||0===i&&0!==o||(a=1),a}(a,n.iterationStart,r,n.iterations,i,o),u=function(t,e,n,r){return t===Fu&&e===1/0?1/0:1===n?Math.floor(r)-1:Math.floor(r)}(r,n.iterations,s,a),c=function(t,e,n){var r=t;if("normal"!==t&&"reverse"!==t){var i=e;"alternate-reverse"===t&&(i+=1),r="normal",i!==1/0&&i%2!=0&&(r="reverse")}return"normal"===r?n:1-n}(n.direction,u,s);return n.currentIteration=u,n.progress=c,n.easingFunction(c)}function ju(t,e,n){var r=function(t,e){for(var n={},r=0;r<t.length;r++)for(var i in t[r])if(Vu(i)){var o={offset:t[r].offset,computedOffset:t[r].computedOffset,easing:t[r].easing,easingFunction:Iu(t[r].easing)||e.easingFunction,value:t[r][i]};n[i]=n[i]||[],n[i].push(o)}return n}(t,e),i=function(t,e){var n=[];for(var r in t)for(var i=t[r],o=0;o<i.length-1;o++){var a=o,s=o+1,u=i[a].computedOffset,c=i[s].computedOffset,h=u,l=c;0===o&&(h=-1/0,0===c&&(s=a)),o===i.length-2&&(l=1/0,1===u&&(a=s)),n.push({applyFrom:h,applyTo:l,startOffset:i[a].computedOffset,endOffset:i[s].computedOffset,easingFunction:i[a].easingFunction,property:r,interpolation:Wu(r,i[a].value,i[s].value,e)})}return n.sort((function(t,e){return t.startOffset-e.startOffset})),n}(r,n);return function(t,e){if(null!==e)i.filter((function(t){return e>=t.applyFrom&&e<t.applyTo})).forEach((function(n){var r=e-n.startOffset,i=n.endOffset-n.startOffset,o=0===i?0:n.easingFunction(r/i);t.setAttribute(n.property,n.interpolation(o),!1,!1)}));else for(var n in r)Vu(n)&&t.setAttribute(n,null)}}function Vu(t){return"offset"!==t&&"easing"!==t&&"composite"!==t&&"computedOffset"!==t}var Uu=function(t,e,n){return function(r){var i=Hu(t,e,r);return!as.enableCSSParsing&&jt(i)?i:n(i)}};function Wu(t,e,n,r){var i=Co[t];if(i&&i.syntax&&i.int){var o=as.styleValueRegistry.getPropertySyntax(i.syntax);if(o){var a=void 0,s=void 0;if(as.enableCSSParsing){var u=as.styleValueRegistry.parseProperty(t,e,r,!1),l=as.styleValueRegistry.parseProperty(t,n,r,!1);a=as.styleValueRegistry.computeProperty(t,u,r,!1),s=as.styleValueRegistry.computeProperty(t,l,r,!1)}else{var d=o.parserWithCSSDisabled;a=d?d(e,r):e,s=d?d(n,r):n}var f=o.mixer(a,s,r);if(f){var p=Uu.apply(void 0,h([],c(f),!1));return function(t){return 0===t?e:1===t?n:p(t)}}}}return Uu(!1,!0,(function(t){return t?n:e}))}function Hu(t,e,n){if("number"==typeof t&&"number"==typeof e)return t*(1-n)+e*n;if("boolean"==typeof t&&"boolean"==typeof e||"string"==typeof t&&"string"==typeof e)return n<.5?t:e;if(Array.isArray(t)&&Array.isArray(e)){for(var r=t.length,i=e.length,o=Math.max(r,i),a=[],s=0;s<o;s++)a.push(Hu(t[s<r?s:r-1],e[s<i?s:i-1],n));return a}throw new Error("Mismatched interpolation arguments "+t+":"+e)}var qu=function(){function t(){this.delay=0,this.direction="normal",this.duration="auto",this._easing="linear",this.easingFunction=Su,this.endDelay=0,this.fill="auto",this.iterationStart=0,this.iterations=1,this.currentIteration=null,this.progress=null}return Object.defineProperty(t.prototype,"easing",{get:function(){return this._easing},set:function(t){this.easingFunction=Iu(t),this._easing=t},enumerable:!1,configurable:!0}),t}();function Yu(t,e){if(null===t)return[];Array.isArray(t)||(t=function(t){var e=[];for(var n in t)if(!(n in["easing","offset","composite"])){var r=t[n];Array.isArray(r)||(r=[r]);for(var i=r.length,o=0;o<i;o++){if(!e[o]){var a={};"offset"in t&&(a.offset=Number(t.offset)),"easing"in t&&(a.easing=t.easing),"composite"in t&&(a.composite=t.composite),e[o]=a}void 0!==r[o]&&null!==r[o]&&(e[o][n]=r[o])}}return e.sort((function(t,e){return(t.computedOffset||0)-(e.computedOffset||0)})),e}(t));for(var n=t.map((function(t){var n={};for(var r in(null==e?void 0:e.composite)&&(n.composite="auto"),t){var i=t[r];if("offset"===r){if(null!==i){if(i=Number(i),!isFinite(i))throw new Error("Keyframe offsets must be numbers.");if(i<0||i>1)throw new Error("Keyframe offsets must be between 0 and 1.");n.computedOffset=i}}else if("composite"===r&&-1===["replace","add","accumulate","auto"].indexOf(i))throw new Error("".concat(i," compositing is not supported"));n[r]=i}return void 0===n.offset&&(n.offset=null),void 0===n.easing&&(n.easing=(null==e?void 0:e.easing)||"linear"),void 0===n.composite&&(n.composite="auto"),n})),r=!0,i=-1/0,o=0;o<n.length;o++){var a=n[o].offset;if(Pt(a))r=!1;else{if(a<i)throw new TypeError("Keyframes are not loosely sorted by offset. Sort or specify offsets.");i=a}}return n=n.filter((function(t){return Number(t.offset)>=0&&Number(t.offset)<=1})),r||function(){var t,e,r=n.length;n[r-1].computedOffset=Number(null!==(t=n[r-1].offset)&&void 0!==t?t:1),r>1&&(n[0].computedOffset=Number(null!==(e=n[0].offset)&&void 0!==e?e:0));for(var i=0,o=Number(n[0].computedOffset),a=1;a<r;a++){var s=n[a].computedOffset;if(!Pt(s)&&!Pt(o)){for(var u=1;u<a-i;u++)n[i+u].computedOffset=o+(Number(s)-o)*u/(a-i);i=a,o=Number(s)}}}(),n}var Xu="backwards|forwards|both|none".split("|"),Ku="reverse|alternate|alternate-reverse".split("|");function $u(t,e){return function(t,e){var n=new qu;return e&&(n.fill="both",n.duration="auto"),"number"!=typeof t||isNaN(t)?void 0!==t&&Object.keys(t).forEach((function(e){if(void 0!==t[e]&&null!==t[e]&&"auto"!==t[e]){if(("number"==typeof n[e]||"duration"===e)&&("number"!=typeof t[e]||isNaN(t[e])))return;if("fill"===e&&-1===Xu.indexOf(t[e]))return;if("direction"===e&&-1===Ku.indexOf(t[e]))return;n[e]=t[e]}})):n.duration=t,n}(t=function(t){"number"==typeof t&&(t=isNaN(t)?{duration:"auto"}:{duration:t});return t}(null!=t?t:{duration:"auto"}),e)}var Zu=function(){function t(t,e,n){var r=this;this.composite="replace",this.iterationComposite="replace",this.target=t,this.timing=$u(n,!1),this.timing.effect=this,this.timing.activeDuration=Lu(this.timing),this.timing.endTime=Math.max(0,this.timing.delay+this.timing.activeDuration+this.timing.endDelay),this.normalizedKeyframes=Yu(e,this.timing),this.interpolations=ju(this.normalizedKeyframes,this.timing,this.target);var i=as.globalThis.Proxy;this.computedTiming=i?new i(this.timing,{get:function(t,e){return"duration"===e?"auto"===t.duration?0:t.duration:"fill"===e?"auto"===t.fill?"none":t.fill:"localTime"===e?r.animation&&r.animation.currentTime||null:"currentIteration"===e?r.animation&&"running"===r.animation.playState?t.currentIteration||0:null:"progress"===e?r.animation&&"running"===r.animation.playState?t.progress||0:null:t[e]},set:function(){return!0}}):this.timing}return t.prototype.applyInterpolations=function(){this.interpolations(this.target,Number(this.timeFraction))},t.prototype.update=function(t){return null!==t&&(this.timeFraction=Gu(this.timing.activeDuration,t,this.timing),null!==this.timeFraction)},t.prototype.getKeyframes=function(){return this.normalizedKeyframes},t.prototype.setKeyframes=function(t){this.normalizedKeyframes=Yu(t)},t.prototype.getComputedTiming=function(){return this.computedTiming},t.prototype.getTiming=function(){return this.timing},t.prototype.updateTiming=function(t){var e=this;Object.keys(t||{}).forEach((function(n){e.timing[n]=t[n]}))},t}();function Qu(t,e){return Number(t.id)-Number(e.id)}var Ju=function(){function t(t){var e=this;this.document=t,this.animations=[],this.ticking=!1,this.timelineTicking=!1,this.hasRestartedThisFrame=!1,this.animationsWithPromises=[],this.inTick=!1,this.pendingEffects=[],this.currentTime=null,this.rafId=0,this.rafCallbacks=[],this.webAnimationsNextTick=function(t){e.currentTime=t,e.discardAnimations(),0===e.animations.length?e.timelineTicking=!1:e.requestAnimationFrame(e.webAnimationsNextTick)},this.processRafCallbacks=function(t){var n=e.rafCallbacks;e.rafCallbacks=[],t<Number(e.currentTime)&&(t=Number(e.currentTime)),e.animations.sort(Qu),e.animations=e.tick(t,!0,e.animations)[0],n.forEach((function(e){e[1](t)})),e.applyPendingEffects()}}return t.prototype.getAnimations=function(){return this.discardAnimations(),this.animations.slice()},t.prototype.isTicking=function(){return this.inTick},t.prototype.play=function(t,e,n){var r=new Zu(t,e,n),i=new Zs(r,this);return this.animations.push(i),this.restartWebAnimationsNextTick(),i.updatePromises(),i.play(),i.updatePromises(),i},t.prototype.applyDirtiedAnimation=function(t){var e=this;if(!this.inTick){t.markTarget();var n=t.targetAnimations();n.sort(Qu),this.tick(Number(this.currentTime),!1,n.slice())[1].forEach((function(t){var n=e.animations.indexOf(t);-1!==n&&e.animations.splice(n,1)})),this.applyPendingEffects()}},t.prototype.restart=function(){return this.ticking||(this.ticking=!0,this.requestAnimationFrame((function(){})),this.hasRestartedThisFrame=!0),this.hasRestartedThisFrame},t.prototype.destroy=function(){this.document.defaultView.cancelAnimationFrame(this.frameId)},t.prototype.applyPendingEffects=function(){this.pendingEffects.forEach((function(t){null==t||t.applyInterpolations()})),this.pendingEffects=[]},t.prototype.updateAnimationsPromises=function(){this.animationsWithPromises=this.animationsWithPromises.filter((function(t){return t.updatePromises()}))},t.prototype.discardAnimations=function(){this.updateAnimationsPromises(),this.animations=this.animations.filter((function(t){return"finished"!==t.playState&&"idle"!==t.playState}))},t.prototype.restartWebAnimationsNextTick=function(){this.timelineTicking||(this.timelineTicking=!0,this.requestAnimationFrame(this.webAnimationsNextTick))},t.prototype.rAF=function(t){var e=this.rafId++;return 0===this.rafCallbacks.length&&(this.frameId=this.document.defaultView.requestAnimationFrame(this.processRafCallbacks)),this.rafCallbacks.push([e,t]),e},t.prototype.requestAnimationFrame=function(t){var e=this;return this.rAF((function(n){e.updateAnimationsPromises(),t(n),e.updateAnimationsPromises()}))},t.prototype.tick=function(t,e,n){var r,i,o=this;this.inTick=!0,this.hasRestartedThisFrame=!1,this.currentTime=t,this.ticking=!1;var a=[],s=[],u=[],l=[];return n.forEach((function(n){n.tick(t,e),n._inEffect?(s.push(n.effect),n.markTarget()):(a.push(n.effect),n.unmarkTarget()),n._needsTick&&(o.ticking=!0);var r=n._inEffect||n._needsTick;n._inTimeline=r,r?u.push(n):l.push(n)})),(r=this.pendingEffects).push.apply(r,h([],c(a),!1)),(i=this.pendingEffects).push.apply(i,h([],c(s),!1)),this.ticking&&this.requestAnimationFrame((function(){})),this.inTick=!1,[u,l]},t}();as.EasingFunction=Iu,as.AnimationTimeline=Ju;const tc={duration:500},ec={duration:1e3,easing:"cubic-bezier(0.250, 0.460, 0.450, 0.940)",iterations:1,fill:"both"};var nc,rc,ic,oc,ac,sc,uc,cc;!function(t){t.NodeAdded="NodeAdded",t.NodeUpdated="NodeUpdated",t.NodeRemoved="NodeRemoved",t.EdgeAdded="EdgeAdded",t.EdgeUpdated="EdgeUpdated",t.EdgeRemoved="EdgeRemoved",t.ComboAdded="ComboAdded",t.ComboUpdated="ComboUpdated",t.ComboRemoved="ComboRemoved"}(nc||(nc={})),function(t){t.DRAW="draw",t.TRANSFORM="transform",t.ELEMENT_VISIBILITY_CHANGE="elementvisibilitychange",t.ELEMENT_STATE_CHANGE="elementstatechange",t.ELEMENT_TRANSLATE="elementtranslate"}(rc||(rc={})),t.CanvasEvent=void 0,function(t){t.CLICK="click",t.DBLCLICK="dblclick",t.POINTER_OVER="pointerover",t.POINTER_LEAVE="pointerleave",t.POINTER_ENTER="pointerenter",t.POINTER_MOVE="pointermove",t.POINTER_OUT="pointerout",t.POINTER_DOWN="pointerdown",t.POINTER_UP="pointerup",t.CONTEXT_MENU="contextmenu",t.DRAG_START="dragstart",t.DRAG="drag",t.DRAG_END="dragend",t.DRAG_ENTER="dragenter",t.DRAG_OVER="dragover",t.DRAG_LEAVE="dragleave",t.DROP="drop",t.WHEEL="wheel"}(t.CanvasEvent||(t.CanvasEvent={})),t.NodeEvent=void 0,(ic=t.NodeEvent||(t.NodeEvent={})).CLICK="click",ic.DBLCLICK="dblclick",ic.POINTER_OVER="pointerover",ic.POINTER_LEAVE="pointerleave",ic.POINTER_ENTER="pointerenter",ic.POINTER_MOVE="pointermove",ic.POINTER_OUT="pointerout",ic.POINTER_DOWN="pointerdown",ic.POINTER_UP="pointerup",ic.CONTEXT_MENU="contextmenu",ic.DRAG_START="dragstart",ic.DRAG="drag",ic.DRAG_END="dragend",ic.DRAG_ENTER="dragenter",ic.DRAG_OVER="dragover",ic.DRAG_LEAVE="dragleave",ic.DROP="drop",t.CommonEvent=void 0,(oc=t.CommonEvent||(t.CommonEvent={})).CLICK="click",oc.DBLCLICK="dblclick",oc.POINTER_OVER="pointerover",oc.POINTER_LEAVE="pointerleave",oc.POINTER_ENTER="pointerenter",oc.POINTER_MOVE="pointermove",oc.POINTER_OUT="pointerout",oc.POINTER_DOWN="pointerdown",oc.POINTER_UP="pointerup",oc.CONTEXT_MENU="contextmenu",oc.DRAG_START="dragstart",oc.DRAG="drag",oc.DRAG_END="dragend",oc.DRAG_ENTER="dragenter",oc.DRAG_OVER="dragover",oc.DRAG_LEAVE="dragleave",oc.DROP="drop",oc.KEY_DOWN="keydown",oc.KEY_UP="keyup",oc.WHEEL="wheel",t.ContainerEvent=void 0,(ac=t.ContainerEvent||(t.ContainerEvent={})).KEY_DOWN="keydown",ac.KEY_UP="keyup",t.EdgeEvent=void 0,(sc=t.EdgeEvent||(t.EdgeEvent={})).CLICK="click",sc.DBLCLICK="dblclick",sc.POINTER_OVER="pointerover",sc.POINTER_LEAVE="pointerleave",sc.POINTER_ENTER="pointerenter",sc.POINTER_MOVE="pointermove",sc.POINTER_OUT="pointerout",sc.POINTER_DOWN="pointerdown",sc.POINTER_UP="pointerup",sc.CONTEXT_MENU="contextmenu",sc.DRAG_ENTER="dragenter",sc.DRAG_OVER="dragover",sc.DRAG_LEAVE="dragleave",sc.DROP="drop",t.GraphEvent=void 0,(uc=t.GraphEvent||(t.GraphEvent={})).BEFORE_SIZE_CHANGE="beforesizechange",uc.AFTER_SIZE_CHANGE="aftersizechange",uc.BEFORE_ELEMENT_CREATE="beforeelementcreate",uc.AFTER_ELEMENT_CREATE="afterelementcreate",uc.BEFORE_ELEMENT_UPDATE="beforeelementupdate",uc.AFTER_ELEMENT_UPDATE="afterelementupdate",uc.BEFORE_ELEMENT_DESTROY="beforeelementdestroy",uc.AFTER_ELEMENT_DESTROY="afterelementdestroy",uc.BEFORE_ELEMENT_TRANSLATE="beforeelementtranslate",uc.AFTER_ELEMENT_TRANSLATE="afterelementtranslate",uc.BEFORE_DRAW="beforedraw",uc.AFTER_DRAW="afterdraw",uc.BEFORE_RENDER="beforerender",uc.AFTER_RENDER="afterrender",uc.BEFORE_ANIMATE="beforeanimate",uc.AFTER_ANIMATE="afteranimate",uc.BEFORE_LAYOUT="beforelayout",uc.AFTER_LAYOUT="afterlayout",uc.BEFORE_TRANSFORM="beforetransform",uc.AFTER_TRANSFORM="aftertransform",uc.BEFORE_ELEMENT_VISIBILITY_CHANGE="beforeelementvisibilitychange",uc.AFTER_ELEMENT_VISIBILITY_CHANGE="afterelementvisibilitychange",uc.BEFORE_ELEMENT_Z_INDEX_CHANGE="beforeelementzindexchange",uc.AFTER_ELEMENT_Z_INDEX_CHANGE="afterelementzindexchange",uc.BEFORE_ELEMENT_STATE_CHANGE="beforeelementstatechange",uc.AFTER_ELEMENT_STATE_CHANGE="afterelementstatechange",function(t){t.DRAW="draw",t.ELEMENT_VISIBILITY_CHANGE="elementvisibilitychange",t.ELEMENT_STATE_CHANGE="elementstatechange",t.ELEMENT_TRANSLATE="elementtranslate"}(cc||(cc={}));const hc="combo",lc="tree";function dc(t){return"source"in t&&"target"in t}function fc(t){return t instanceof Float32Array||!(!Array.isArray(t)||2!==t.length&&3!==t.length)&&t.every((t=>"number"==typeof t))}function pc(t,e,n){return t>=e&&t<=n}function gc(t=0){if(Array.isArray(t)){const[e=0,n=e,r=e,i=n]=t;return[e,n,r,i]}return[t,t,t,t]}function mc(t){return t.max[0]-t.min[0]}function vc(t){return t.max[1]-t.min[1]}function yc(t){return[mc(t),vc(t)]}function Ec(t,e){const n=fc(t)?function(t){const[e,n,r=0]=t,i=new hr;return i.setMinMax([e,n,r],[e,n,r]),i}(t):t.getKey().getBounds();return e?xc(n,e):n}function xc(t,e){const[n,r,i,o]=gc(e),[a,s,u]=t.min,[c,h,l]=t.max,d=new hr;return d.setMinMax([a-o,s-n,u],[c+r,h+i,l]),d}function bc(t){if(0===t.length)return new hr;if(1===t.length)return t[0];const e=new hr;e.setMinMax(t[0].min,t[0].max);for(let n=1;n<t.length;n++){const r=t[n];e.setMinMax([Math.min(e.min[0],r.min[0]),Math.min(e.min[1],r.min[1]),Math.min(e.min[2],r.min[2])],[Math.max(e.max[0],r.max[0]),Math.max(e.max[1],r.max[1]),Math.max(e.max[2],r.max[2])])}return e}function wc(t,e){return pc(t[0],e.min[0],e.max[0])&&pc(t[1],e.min[1],e.max[1])}function Mc(t,e){const[n,r]=e,[i,o]=t.min,[a,s]=t.max,u=n-i,c=a-n,h=r-o,l=s-r,d=Math.min(u,c,h,l);return d===u?"left":d===c?"right":d===h?"top":d===l?"bottom":"left"}function Nc(t,e){const n=Zt(e);if(wc(e,t)){switch(Mc(t,e)){case"left":n[0]=t.min[0];break;case"right":n[0]=t.max[0];break;case"top":n[1]=t.min[1];break;case"bottom":n[1]=t.max[1]}}else{const[r,i]=e,[o,a]=t.min,[s,u]=t.max;n[0]=pc(r,o,s)?r:r<o?o:s,n[1]=pc(i,a,u)?i:i<a?a:u}return n}function Sc(t){const{x:e=0,y:n=0,z:r=0}=t.style||{};return[+e,+n,+r]}function Tc(t,e){const[n,r]=e,{min:i,max:o}=t;return[i[0]+n*(o[0]-i[0]),i[1]+r*(o[1]-i[1])]}function Pc(t,e="center"){const n=function(t){if(Array.isArray(t))return pc(t[0],0,1)&&pc(t[1],0,1)?t:[.5,.5];const e=t.split("-");return[e.includes("left")?0:e.includes("right")?1:.5,e.includes("top")?0:e.includes("bottom")?1:.5]}(e);return Tc(t,n)}function Cc(t,e){const n=function(t){const e="string"==typeof t?t.split(" ").map((t=>parseFloat(t))):t.slice(0,2);return pc(e[0],0,1)&&pc(e[1],0,1)?e:[.5,.5]}(e);return Tc(t,n)}function kc(t=0){if(jt(t))return Array(3).fill(t);const[e,n=e,r=e]=t;return[e,n,r]}function Ac(t,e,n){if(Array.isArray(t))return t;const[r,i]=kc(n),[o,a]=kc(e),s=o/2/r,u=a/2/i;switch(t){case"top":return[.5,u];case"bottom":return[.5,1-u];case"left":return[s,.5];case"right":return[1-s,.5];case"top-left":case"left-top":return[s,u];case"top-right":case"right-top":return[1-s,u];case"bottom-left":case"left-bottom":return[s,1-u];case"bottom-right":case"right-bottom":return[1-s,1-u];default:return[.5,.5]}}function Oc(t,e,n){if(Array.isArray(t))return t;const r=kc(n)[0],i=r/2,o=kc(e)[0]/2,a=o/r;switch(t){case"top":return[.5,a];case"bottom":return[.5,1-a];case"left":return[a,.5];case"right":return[1-a,.5]}const s=(i-o)*(Math.sqrt(2)/2)/r;switch(t){case"top-left":case"left-top":return[.5-s,.5-s];case"top-right":case"right-top":return[.5+s,.5-s];case"bottom-left":case"left-bottom":return[.5-s,.5+s];case"bottom-right":case"right-bottom":return[.5+s,.5+s];default:return[.5,.5]}}function Rc(t,e,n,r,i=Ac){const o=i(t,n,r),[a,s]=kc(r),u=new hr;return u.setMinMax([e[0]-a/2,e[1]-s/2,0],[e[0]+a/2,e[1]+s/2,0]),Cc(u,o)}function Dc(t){if(zt(t.id)||jt(t.id))return t.id;if(dc(t))return`${t.source}-${t.target}`;throw new Error("The data does not have available id.")}function Ic(t){return t.style?.parentId}function Lc(t,e){if(!t.startsWith(e))return!1;const n=t[e.length];return n>="A"&&n<="Z"}function _c(t,e){return Object.entries(t).reduce(((t,[n,r])=>("className"===n||"class"===n||Lc(n,e)&&(t[function(t,e,n=!0){if(!e)return t;if(!Lc(t,e))return t;const r=t.slice(e.length);return n?qt(r):r}(n,e)]=r),t)),{})}function zc(t,e){const n=e.length;return Object.keys(t).reduce(((r,i)=>{if(i.startsWith(e)){r[i.slice(n)]=t[i]}return r}),{})}function Fc(t,e){const n=zt(e)?[e]:e;return Object.entries(t).reduce(((t,[e,r])=>(n.find((t=>e.startsWith(t)))||(t[e]=r),t)),{})}const Bc=[0,0,0];function Gc(t,e){return t.map(((t,n)=>t+e[n]))}function jc(t,e){return t.map(((t,n)=>t-e[n]))}function Vc(t,e){return"number"==typeof e?t.map((t=>t*e)):t.map(((t,n)=>t*e[n]))}function Uc(t,e){return"number"==typeof e?t.map((t=>t/e)):t.map(((t,n)=>t/e[n]))}function Wc(t,e){return Math.sqrt(t.reduce(((t,n,r)=>t+(n-e[r]||0)**2),0))}function Hc(t,e){return t.reduce(((t,n,r)=>t+Math.abs(n-e[r])),0)}function qc(t){const e=t.reduce(((t,e)=>t+e**2),0);return t.map((t=>t/Math.sqrt(e)))}function Yc(t){return 2===t.length?[t[0],t[1],0]:t}function Xc(t){if(t)return"string"==typeof t||"function"==typeof t||Array.isArray(t)?{type:"group",field:t=>t.id,color:t,invert:!1}:t}function Kc(t){return[t.x,t.y]}function $c(t){return{x:t[0],y:t[1]}}function Zc(t,e=0){return t.map((t=>parseFloat(t.toFixed(e))))}function Qc(t,e,n,r=!1){const i=qc(r?jc(t,e):jc(e,t)),o=[i[0]*n,i[1]*n];return Gc(function(t){return[t[0],t[1]]}(t),o)}function Jc(t,e){return t[1]===e[1]}function th(t,e){const[n,r]=t,[i,o]=e;return function(t,e){const n=Yc(t),r=Yc(e);return[n[1]*r[2]-n[2]*r[1],n[2]*r[0]-n[0]*r[2],n[0]*r[1]-n[1]*r[0]]}(jc(n,r),jc(i,o)).every((t=>0===t))}function eh(t,e){if(th(t,e))return;const[n,r]=t,[i,o]=e,a=((n[0]-i[0])*(i[1]-o[1])-(n[1]-i[1])*(i[0]-o[0]))/((n[0]-r[0])*(i[1]-o[1])-(n[1]-r[1])*(i[0]-o[0])),s=o[0]-i[0]?(n[0]-i[0]+a*(r[0]-n[0]))/(o[0]-i[0]):(n[1]-i[1]+a*(r[1]-n[1]))/(o[1]-i[1]);return pc(a,0,1)&&pc(s,0,1)?[n[0]+a*(r[0]-n[0]),n[1]+a*(r[1]-n[1])]:void 0}function nh(t,e,n,r=!0){for(let i=0;i<n.length;i++){let o=n[i],a=n[(i+1)%n.length];r&&(o=Gc(e,o),a=Gc(e,a));const s=eh([e,t],[o,a]);if(s)return s}return e}function rh(t,e){const n=e.center,r=jc(t,e.center),i=Math.atan2(r[1],r[0]);if(isNaN(i))return n;const o=mc(e)/2,a=vc(e)/2;return[n[0]+o*Math.cos(i),n[1]+a*Math.sin(i)]}function ih(t,e){let n=2*t;return"string"==typeof e?n=t*Number(e.replace("%",""))/100:"number"==typeof e&&(n=e),isNaN(n)&&(n=2*t),n}function oh(t,e,n=1,r=!1){const i=r?n:1;return ih((t.max[0]-t.min[0])*i,e)}const ah="cachedStyle",sh=t=>`__${t}__`;function uh(t,e){const n=Array.isArray(e)?e:[e];ie(t,ah)||oe(t,ah,{}),n.forEach((e=>{oe(ie(t,ah),sh(e),t.attributes[e])}))}function ch(t,e){return ie(t,[ah,sh(e)])}function hh(t,e){return sh(e)in(ie(t,ah)||{})}function lh(t){const e=[],n=t=>{t.children&&t.children.length&&t.children.forEach((t=>{e.push(t),n(t)}))};return n(t),e}const dh="visibility";class fh extends Ns{constructor(t){super(t),this.render(this.attributes,this),this.setVisibility(),this.bindEvents()}get parsedAttributes(){return this.attributes}shapeMap={};animateMap={};upsert(t,e,n,r){const i=this.shapeMap[t];if(!1!==n){if(!i){const i=new e({style:n});return i.id=t,r.appendChild(i),this.shapeMap[t]=i,i}return gl(i,n),i}i&&(r.removeChild(i),delete this.shapeMap[t])}update(t={}){this.attr(te({},this.attributes,t)),this.render(this.attributes,this),this.setVisibility()}bindEvents(){}getGraphicStyle(t){const{x:e,y:n,className:r,transform:i,transformOrigin:o,context:a,zIndex:s,...u}=t;return u}animate(t,e){const n=[],r=super.animate(t,e);if(r&&n.push(r),Array.isArray(t)&&t.length>0){const r=["anchor","transform","transformOrigin","x","y","z","zIndex"];Object.keys(t[0]).some((t=>!r.includes(t)))&&Object.entries(this.shapeMap).forEach((([r,i])=>{const o=this[`get${r[0].toUpperCase()}${r.slice(1)}Style`];if("function"==typeof o){const r=t.map((t=>o.call(this,{...this.attributes,...t}))),a=i.animate(vl(r),e);a&&n.push(a)}}))}return ml(n)}setVisibility(){const{visibility:t}=this.attributes;!function(t,e){[t,...lh(t)].forEach((n=>{hh(n,dh)||uh(n,dh);const r=ch(n,dh);t!==n&&"hidden"===r||(n.style.visibility=e)}))}(this,t)}}class ph extends fh{static defaultStyleProps={padding:0,fontSize:12,wordWrap:!0,maxLines:1,wordWrapWidth:128,textOverflow:"...",textBaseline:"middle",backgroundOpacity:.75,backgroundZIndex:-1,backgroundLineWidth:0};constructor(t){super(te({},{style:ph.defaultStyleProps},t))}isTextStyle(t){return Lc(t,"label")}isBackgroundStyle(t){return Lc(t,"background")}getTextStyle(t){const{padding:e,...n}=this.getGraphicStyle(t);return Fc(n,"background")}getBackgroundStyle(t){if(!1===t.background)return!1;const e=this.getGraphicStyle(t),{wordWrap:n,wordWrapWidth:r,padding:i}=e,o=_c(e,"background"),{min:[a,s],halfExtents:[u,c]}=this.shapeMap.text.getGeometryBounds(),[h,l,d,f]=gc(i);Object.assign(o,{x:a-f,y:s-h,width:n?Math.min(2*u,r):2*u+f+l,height:2*c+h+d});const{radius:p}=o;if("string"==typeof p&&p.endsWith("%")){const t=Number(p.replace("%",""))/100;o.radius=Math.min(+o.width,+o.height)*t}return o}render(t=this.parsedAttributes,e=this){this.upsert("text",Is,this.getTextStyle(t),e),this.upsert("background",Ds,this.getBackgroundStyle(t),e)}}class gh extends fh{static defaultStyleProps={padding:[2,4,2,4],fontSize:10,wordWrap:!1,backgroundRadius:"50%",backgroundOpacity:1};constructor(t){super(te({},{style:gh.defaultStyleProps},t))}getBadgeStyle(t){return this.getGraphicStyle(t)}render(t=this.parsedAttributes,e=this){this.upsert("label",ph,this.getBadgeStyle(t),e)}connectedCallback(){this.upsert("label",ph,this.getBadgeStyle(this.parsedAttributes),this)}}class mh extends fh{constructor(t){super(t)}isGImage(){return!!this.getAttribute("src")}getIconStyle(t=this.attributes){const e=this.getGraphicStyle(t);return this.isGImage()?{anchor:[.5,.5],...e}:{textBaseline:"middle",textAlign:"center",...e}}render(t=this.attributes,e=this){this.upsert("icon",this.isGImage()?Cs:Is,this.getIconStyle(t),e)}connectedCallback(){this.upsert("icon",this.isGImage()?Cs:Is,this.getIconStyle(this.attributes),this)}}class vh extends fh{type="node";static defaultStyleProps={x:0,y:0,size:24,droppable:!0,draggable:!0,port:!0,ports:[],portZIndex:2,portLinkToCenter:!1,badge:!0,badges:[],badgeZIndex:3,halo:!1,haloDroppable:!1,haloLineDash:0,haloLineWidth:12,haloStrokeOpacity:.25,haloPointerEvents:"none",haloZIndex:-1,icon:!0,iconZIndex:1,label:!0,labelIsBillboard:!0,labelMaxWidth:"200%",labelPlacement:"bottom",labelWordWrap:!1,labelZIndex:0};constructor(t){super(te({},{style:vh.defaultStyleProps},t))}getSize(t=this.parsedAttributes){const{size:e}=t;return kc(e)}getKeyStyle(t){const{color:e,fill:n,...r}=this.getGraphicStyle(t);return Object.assign({fill:e||n},Fc(r,["label","halo","icon","badge","port"]))}getLabelStyle(t){if(!1===t.label||ne(t.labelText))return!1;const{placement:e,maxWidth:n,...r}=_c(this.getGraphicStyle(t),"label"),i=this.getKey().getLocalBounds();return Object.assign(pl(i,e),{wordWrapWidth:oh(i,n)},r)}getHaloStyle(t){if(!1===t.halo)return!1;const{fill:e,...n}=this.getKeyStyle(t);return{...n,stroke:e,..._c(this.getGraphicStyle(t),"halo")}}getIconStyle(t){if(!1===t.icon||ne(t.iconText||t.iconSrc))return!1;const e=_c(this.getGraphicStyle(t),"icon"),n=this.getKey(),[r,i]=Pc(n.getLocalBounds(),"center");return{x:r,y:i,...e}}getBadgesStyle(t){const e=zc(this.shapeMap,"badge-"),n={};if(Object.keys(e).forEach((t=>{n[t]=!1})),!1===t.badge||ne(t.badges))return n;const{badges:r=[],badgePalette:i,...o}=t,a=function(t){const e=zt(t)?RE("palette",t):t;if(!Tt(e))return e}(i),s=_c(this.getGraphicStyle(o),"badge");return r.forEach(((t,e)=>{n[e]={backgroundFill:a?a[e%a?.length]:void 0,...s,...this.getBadgeStyle(t)}})),n}getBadgeStyle(t){const e=this.getKey(),{placement:n="top",...r}=t;return{...pl(e.getLocalBounds(),n,!0),...r}}getPortsStyle(t){const e=this.getPorts(),n={};if(Object.keys(e).forEach((t=>{n[t]=!1})),!1===t.port||ne(t.ports))return n;const r=_c(this.getGraphicStyle(t),"port"),{ports:i=[]}=t;return i.forEach(((e,i)=>{const o=e.key||i,a={...r,...e};if(sl(a))n[o]=!1;else{const[r,i]=this.getPortXY(t,e);n[o]={cx:r,cy:i,...a}}})),n}getPortXY(t,e){const{placement:n="left"}=e;return ol(this.getKey().getLocalBounds(),n)}getKey(){return this.shapeMap.key}getPorts(){return zc(this.shapeMap,"port-")}getCenter(){return this.getKey().getBounds().center}getIntersectPoint(t){const e=this.getKey().getBounds();return nh(t,Pc(n=e,"center"),[Pc(n,"left-top"),Pc(n,"right-top"),Pc(n,"right-bottom"),Pc(n,"left-bottom")],!1);var n}drawHaloShape(t,e){const n=this.getKey();this.upsert("halo",n.constructor,this.getHaloStyle(t),e)}drawBadgeShapes(t,e){const n=this.getBadgesStyle(t);Object.keys(n).forEach((t=>{this.upsert(`badge-${t}`,gh,n[t],e)}))}drawPortShapes(t,e){const n=this.getPortsStyle(t);Object.keys(n).forEach((t=>{this.upsert(`port-${t}`,Ms,n[t],e)}))}render(t=this.parsedAttributes,e=this){this.drawKeyShape(t,e)&&(this.drawHaloShape(t,e),this.upsert("icon",mh,this.getIconStyle(t),e),this.drawBadgeShapes(t,e),this.upsert("label",ph,this.getLabelStyle(t),e),this.drawPortShapes(t,e))}animate(t,e){const n=super.animate(t,e);return n&&(n.onframe=()=>{this.drawBadgeShapes(this.parsedAttributes,this)}),n}}const yh=.8;class Eh extends vh{static defaultStyleProps={size:24};constructor(t){super(te({},{style:Eh.defaultStyleProps},t))}drawKeyShape(t,e){return this.upsert("key",Ms,this.getKeyStyle(t),e)}getKeyStyle(t){return{...super.getKeyStyle(t),r:Math.min(...this.getSize(t))/2}}getIconStyle(t){const e=super.getIconStyle(t),{r:n}=this.getKeyStyle(t),r=2*n*yh;return!!e&&{width:r,height:r,...e}}getIntersectPoint(t){return rh(t,this.getKey().getBounds())}}class xh extends vh{constructor(t){super(t)}drawKeyShape(t,e){return this.upsert("key",Os,this.getKeyStyle(t),e)}getKeyStyle(t){return{...super.getKeyStyle(t),points:this.getPoints(t)}}getIntersectPoint(t){const{points:e}=this.getKeyStyle(this.parsedAttributes);return nh(t,[+(this.attributes?.x||0),+(this.attributes?.y||0)],e)}}class bh extends vh{static defaultStyleProps={size:[80,40]};constructor(t){super(te({},{style:bh.defaultStyleProps},t))}drawKeyShape(t,e){return this.upsert("key",Ss,this.getKeyStyle(t),e)}getKeyStyle(t){const e=super.getKeyStyle(t),[n,r]=this.getSize(t);return{...e,rx:n/2,ry:r/2}}getIconStyle(t){const e=super.getIconStyle(t),{rx:n,ry:r}=this.getKeyStyle(t),i=2*Math.min(n,r)*yh;return!!e&&{width:i,height:i,...e}}getIntersectPoint(t){return rh(t,this.getKey().getBounds())}}class wh extends vh{static defaultStyleProps={size:50};constructor(t){super(te({},{style:wh.defaultStyleProps},t))}getKeyStyle(t){const[e,n]=this.getSize(t);return{...super.getKeyStyle(t),width:e,height:n,anchor:[.5,.5]}}getHaloStyle(t){if(!1===t.halo)return!1;const{fill:e,stroke:n,...r}=this.getKeyStyle(t),i=_c(this.getGraphicStyle(t),"halo"),o=Number(i.lineWidth),[a,s]=Gc(this.getSize(t),[o,o]);return{...r,...i,width:a,height:s,fill:"transparent"}}getIconStyle(t){const e=super.getIconStyle(t),[n,r]=this.getSize(t);return!!e&&{width:n*yh,height:r*yh,...e}}drawKeyShape(t,e){return this.upsert("key",Cs,this.getKeyStyle(t),e)}drawHaloShape(t,e){this.upsert("halo",Ds,this.getHaloStyle(t),e)}}class Mh extends vh{static defaultStyleProps={size:[48,24],anchor:[.5,.5]};constructor(t){super(te({},{style:Mh.defaultStyleProps},t))}getKeyStyle(t){const[e,n]=this.getSize(t);return{...super.getKeyStyle(t),width:e,height:n}}getIconStyle(t){const e=super.getIconStyle(t),{width:n,height:r}=this.getKeyStyle(t);return!!e&&{width:n*yh,height:r*yh,...e}}drawKeyShape(t,e){return this.upsert("key",Ds,this.getKeyStyle(t),e)}}class Nh extends xh{static defaultStyleProps={size:40,direction:"up"};constructor(t){super(te({},{style:Nh.defaultStyleProps},t))}getPoints(t){const{direction:e}=t,[n,r]=this.getSize(t);return function(t,e,n){const r=e/2,i=t/2,o={up:[[-i,r],[i,r],[0,-r]],left:[[-i,0],[i,r],[i,-r]],right:[[-i,r],[-i,-r],[i,0]],down:[[-i,-r],[i,-r],[0,r]]};return o[n]||o.up}(n,r,e)}getPortXY(t,e){const{direction:n}=t,{placement:r="top"}=e,i=this.getKey().getLocalBounds(),[o,a]=this.getSize(t),s=function(t,e,n){const r=e/2,i=t/2,o={};"down"===n?(o.bottom=o.default=[0,r],o.right=[i,-r],o.left=[-i,-r]):"left"===n?(o.top=[i,-r],o.bottom=[i,r],o.left=o.default=[-i,0]):"right"===n?(o.top=[-i,-r],o.bottom=[-i,r],o.right=o.default=[i,0]):(o.left=[-i,r],o.top=o.default=[0,-r],o.right=[i,r]);return o}(o,a,n);return ol(i,r,s,!1)}getIconStyle(t){const{icon:e,iconText:n,iconSrc:r,direction:i}=t;if(!1===e||ne(n||r))return!1;const o=_c(this.getGraphicStyle(t),"icon"),a=this.getKey().getLocalBounds(),[s,u]=function(t,e){const{center:n}=t,[r,i]=yc(t);return["up"===e||"down"===e?n[0]:"right"===e?n[0]-r/6:n[0]+r/6,"left"===e||"right"===e?n[1]:"down"===e?n[1]-i/6:n[1]+i/6]}(a,i),c=2*function(t,e){let[n,r]=yc(t);return[n,r]="up"===e||"down"===e?[n,r]:[r,n],(r**2-(Math.sqrt((n/2)**2+r**2)-n/2)**2)/(2*r)}(a,i)*yh;return{x:s,y:u,width:c,height:c,...o}}}class Sh extends vh{type="combo";static defaultStyleProps={childrenNode:[],droppable:!0,draggable:!0,collapsed:!1,collapsedSize:32,collapsedOrigin:[.5,.5],collapsedMarker:!0,collapsedMarkerZIndex:1,collapsedMarkerFontSize:12,collapsedMarkerTextAlign:"center",collapsedMarkerTextBaseline:"middle",collapsedMarkerType:"child-count"};constructor(t){super(te({},{style:Sh.defaultStyleProps},t))}calculatePosition(t){const{x:e=0,y:n=0,collapsed:r,childrenNode:i=[],childrenData:o=[]}=t;if(i.length<o.length){if(o.length>0&&r){return Uc(o.reduce(((t,e)=>Gc(t,Sc(e))),[0,0,0]),o.length)}return[+e,+n,0]}return o.length?r?this.getCollapsedOriginPosition(t):this.getContentBBox(t).center:[+e,+n,0]}getCollapsedOriginPosition(t){return Rc(t.collapsedOrigin,this.getContentBBox(t).center,this.getCollapsedKeySize(t),this.getExpandedKeySize(t))}getKeySize(t){const{collapsed:e,childrenNode:n=[]}=t;return 0===n.length?this.getEmptyKeySize(t):e?this.getCollapsedKeySize(t):this.getExpandedKeySize(t)}getEmptyKeySize(t){const{padding:e,collapsedSize:n}=t,[r,i,o,a]=gc(e);return Gc(kc(n),[a+i,r+o,0])}getCollapsedKeySize(t){return kc(t.collapsedSize)}getExpandedKeySize(t){if(!ne(t.size))return kc(t.size);const e=this.getContentBBox(t);return[mc(e),vc(e),0]}getContentBBox(t){const{childrenNode:e=[],padding:n}=t,r=bc(e.map((t=>t.getBounds())));return n?xc(r,n):r}drawCollapsedMarkerShape(t,e){this.upsert("collapsed-marker",mh,this.getCollapsedMarkerStyle(t),e)}getCollapsedMarkerStyle(t){if(!t.collapsed||!t.collapsedMarker)return!1;const{type:e,...n}=_c(this.getGraphicStyle(t),"collapsedMarker"),r=this.getKey(),[i,o]=Pc(r.getLocalBounds(),"center"),a={...n,x:i,y:o};if(e){const n=this.getCollapsedMarkerText(e,t);Object.assign(a,{text:n})}return a}getCollapsedMarkerText(t,e){const{context:n,childrenData:r=[]}=e;if(!n)return"";const{model:i}=n;return"descendant-count"===t?i.getDescendantsData(this.id).length.toString():"child-count"===t?r.length.toString():"node-count"===t?i.getDescendantsData(this.id).filter((t=>"node"===i.getElementType(Dc(t)))).length.toString():Tt(t)?t(r):""}getComboZIndex(t){return(t.context?.model.getAncestorsData(this.id,hc)||[]).length}getComboStyle(t){const{zIndex:e=this.getComboZIndex(t)}=t,[n,r]=this.calculatePosition(t);return{x:n,y:r,zIndex:e}}render(t,e=this){super.render(t,e);const n=this.getComboStyle(t);Object.assign(this.style,n),t.context?.model.syncComboDatum({id:this.id,style:n}),this.drawCollapsedMarkerShape(t,e)}}class Th extends Sh{static defaultStyleProps={anchor:[.5,.5]};constructor(t){super(te({},{style:Th.defaultStyleProps},t))}drawKeyShape(t,e){return this.upsert("key",Ds,this.getKeyStyle(t),e)}getKeyStyle(t){const e=super.getKeyStyle(t),n=_c(e,"collapsed"),[r,i]=this.getKeySize(t);return{...e,...t.collapsed&&n,width:r,height:i}}}const Ph={N:"S",S:"N",W:"E",E:"W"},Ch={N:-Math.PI/2,S:Math.PI/2,E:0,W:Math.PI};function kh(t,e){const[n,r]=t,[i,o]=e;return n===i?r>o?"N":"S":r===o?n>i?"W":"E":null}function Ah(t,e){return"N"===e||"S"===e?vc(t):mc(t)}function Oh(t,e,n){const r=[t[0],e[1]],i=[e[0],t[1]],o=kh(t,r),a=kh(t,i),s=n?Ph[n]:null,u=o===n||o!==s&&a!==n?r:i;return{points:[u],direction:kh(u,e)}}function Rh(t,e,n){const r=_h(t,e,n);return{points:[r],direction:kh(r,e)}}function Dh(t,e,n,r){const i=[[e[0],t[1]],[t[0],e[1]]],o=i.filter((t=>!wc(t,n))),a=o.filter((e=>kh(e,t)!==r));if(a.length>0){const n=a.find((e=>kh(t,e)===r))||a[0];return{points:[n],direction:kh(n,e)}}{const a=Qc(e,St(i,o)[0],Ah(n,r)/2);return{points:[_h(a,t,n),a],direction:kh(a,e)}}}function Ih(t,e,n,r){let i=Rh(t,e,n);const o=Yc(i.points[0]);if(wc(o,r)){i=Rh(e,t,r);const a=Yc(i.points[0]);if(wc(a,n)){const s=Qc(t,a,Ah(n,kh(t,a))/2),u=Qc(e,o,Ah(r,kh(e,o))/2),c=[(s[0]+u[0])/2,(s[1]+u[1])/2],h=Rh(t,c,n),l=Dh(c,e,r,h.direction);i.points=[h.points[0],l.points[0]],i.direction=l.direction}}return i}function Lh(t,e,n,r,i){const o=.01,a=bc([n,r]),s=Wc(e,a.center)>Wc(t,a.center),[u,c]=s?[e,t]:[t,e],h=vc(a)+mc(a);let l;if(i){const t=[u[0]+h*Math.cos(Ch[i]),u[1]+h*Math.sin(Ch[i])];l=Qc(Nc(a,t),t,o)}else l=Qc(Nc(a,u),u,-.01);let d=_h(l,c,a),f=[Zc(l,2),Zc(d,2)];if(re(Zc(l),Zc(d))){const t=function(t,e){return Math.acos(Vc(t,e).reduce(((t,e)=>t+e),0)/(Wc(t,Bc)*Wc(e,Bc)))}(jc(l,u),[1,0,0])+Math.PI/2;d=[c[0]+h*Math.cos(t),c[1]+h*Math.sin(t),0],d=Zc(Qc(Nc(a,d),c,-.01),2);f=[l,_h(l,d,a),d]}return{points:s?f.reverse():f,direction:kh(s?l:d,e)}}function _h(t,e,n){let r=[t[0],e[1]];return wc(r,n)&&(r=[e[0],t[1]]),r}function zh(t,e,n,r,i){const[o,a]=Kc(t.getPoint(e));let s=n,u=r;return i&&(s=n*Math.cos(i)-r*Math.sin(i),u=n*Math.sin(i)+r*Math.cos(i)),[o+s,a+u]}function Fh(t,e,n,r){if(re(t,e))return t;const i=jc(e,t),o=[t[0]+n*i[0],t[1]+n*i[1]],a=qc(function(t,e=!0){return e?[-t[1],t[0]]:[t[1],-t[0]]}(i,!1));return o[0]+=r*a[0],o[1]+=r*a[1],o}function Bh(t,e,n){return[["M",t[0],t[1]],["C",n[0][0],n[0][1],n[1][0],n[1][1],e[0],e[1]]]}function Gh(t,e=0,n=!1){const r=t[0],i=t[t.length-1],o=t.slice(1,t.length-1),a=[["M",r[0],r[1]]];return o.forEach(((t,n)=>{const s=o[n-1]||r,u=o[n+1]||i;if(!th([s,c=t],[c,u])&&e){const[n,r]=function(t,e,n,r){const i=Hc(t,e),o=Hc(n,e),a=Math.min(r,Math.min(i,o)/2),s=[e[0]-a/i*(e[0]-t[0]),e[1]-a/i*(e[1]-t[1])],u=[e[0]-a/o*(e[0]-n[0]),e[1]-a/o*(e[1]-n[1])];return[s,u]}(s,t,u,e);a.push(["L",n[0],n[1]],["Q",t[0],t[1],r[0],r[1]],["L",r[0],r[1]])}else a.push(["L",t[0],t[1]]);var c})),a.push(["L",i[0],i[1]]),n&&a.push(["Z"]),a}const jh=t=>{const e=Math.PI/2,n=vc(t)/2,r=mc(t)/2,i=Math.atan2(n,r)/2,o=Math.atan2(r,n)/2;return{top:[-e-o,-e+o],"top-right":[-e+o,-i],"right-top":[-e+o,-i],right:[-i,i],"bottom-right":[i,e-o],"right-bottom":[i,e-o],bottom:[e-o,e+o],"bottom-left":[e+o,Math.PI-i],"left-bottom":[e+o,Math.PI-i],left:[Math.PI-i,Math.PI+i],"top-left":[Math.PI+i,-e-o],"left-top":[Math.PI+i,-e-o]}};function Vh(t,e,n,r,i){const o=Ec(t),a=t.getCenter();let s=r&&ul(r),u=i&&ul(i);if(!s||!u){const r=jh(o),i=r[e][0],c=r[e][1],[h,l]=yc(o),d=Math.max(h,l),f=Gc(a,[d*Math.cos(i),d*Math.sin(i),0]),p=Gc(a,[d*Math.cos(c),d*Math.sin(c),0]);s=fl(t,f),u=fl(t,p),n||([s,u]=[u,s])}return[s,u]}function Uh(t,e,n,r,i,o){const a=t.getPorts()[i||o],s=t.getPorts()[o||i];let[u,c]=Vh(t,e,n,a,s);const h=function(t,e,n,r){const i=t.getCenter();if(re(e,n)){const t=jc(e,i),o=[r*Math.sign(t[0])||r/2,r*Math.sign(t[1])||-r/2,0];return[Gc(e,o),Gc(n,Vc(o,[1,-1,1]))]}return[Qc(i,e,Wc(i,e)+r),Qc(i,n,Wc(i,n)+r)]}(t,u,c,r);return a&&(u=dl(a,h[0])),s&&(c=dl(s,h[h.length-1])),Bh(u,c,h)}function Wh(t,e,n,r,i,o,a){const s=al(t),u=s[o||a],c=s[a||o];let[h,l]=Vh(t,n,r,u,c);const d=function(t,e,n,r){const i=[],o=Ec(t);if(re(e,n)){switch(Mc(o,e)){case"left":i.push([e[0]-r,e[1]]),i.push([e[0]-r,e[1]+r]),i.push([e[0],e[1]+r]);break;case"right":i.push([e[0]+r,e[1]]),i.push([e[0]+r,e[1]+r]),i.push([e[0],e[1]+r]);break;case"top":i.push([e[0],e[1]-r]),i.push([e[0]+r,e[1]-r]),i.push([e[0]+r,e[1]]);break;case"bottom":i.push([e[0],e[1]+r]),i.push([e[0]+r,e[1]+r]),i.push([e[0]+r,e[1]])}}else{const t=Mc(o,e),a=Mc(o,n);if(t===a){let o,a;switch(t){case"left":o=Math.min(e[0],n[0])-r,i.push([o,e[1]]),i.push([o,n[1]]);break;case"right":o=Math.max(e[0],n[0])+r,i.push([o,e[1]]),i.push([o,n[1]]);break;case"top":a=Math.min(e[1],n[1])-r,i.push([e[0],a]),i.push([n[0],a]);break;case"bottom":a=Math.max(e[1],n[1])+r,i.push([e[0],a]),i.push([n[0],a])}}else{const s=(t,e)=>({left:[e[0]-r,e[1]],right:[e[0]+r,e[1]],top:[e[0],e[1]-r],bottom:[e[0],e[1]+r]}[t]),u=s(t,e),c=s(a,n),h=_h(u,c,o);i.push(u,h,c)}}return i}(t,h,l,i);return u&&(h=dl(u,d[0])),c&&(l=dl(c,d[d.length-1])),Gh([h,...d,l],e)}function Hh(t,e){const n=new Set,r=new Set,i=new Set;return t.forEach((o=>{e(o).forEach((e=>{n.add(e),t.includes(e.source)&&t.includes(e.target)?r.add(e):i.add(e)}))})),{edges:Array.from(n),internal:Array.from(r),external:Array.from(i)}}const qh=(t,e)=>[["M",0,0],["L",t,-e/2],["L",t,e/2],["Z"]];var Yh=Object.freeze({__proto__:null,circle:(t,e)=>{const n=Math.max(t,e)/2;return[["M",0,0],["A",n,n,0,1,0,2*n,0],["A",n,n,0,1,0,0,0],["Z"]]},diamond:(t,e)=>[["M",0,0],["L",t/2,-e/2],["L",t,0],["L",t/2,e/2],["Z"]],rect:(t,e)=>[["M",0,-e/2],["L",t,-e/2],["L",t,e/2],["L",0,e/2],["Z"]],simple:(t,e)=>[["M",t,-e/2],["L",0,0],["L",t,e/2]],triangle:qh,triangleRect:(t,e)=>{const n=t/2,r=t/7,i=t-r;return[["M",0,0],["L",n,-e/2],["L",n,e/2],["Z"],["M",i,-e/2],["L",i+r,-e/2],["L",i+r,e/2],["L",i,e/2],["Z"]]},vee:(t,e)=>[["M",0,0],["L",t,-e/2],["L",2*t/3,0],["L",t,e/2],["Z"]]});class Xh extends fh{type="edge";static defaultStyleProps={isBillboard:!0,label:!0,labelAutoRotate:!0,labelIsBillboard:!0,labelMaxWidth:"80%",labelOffsetX:4,labelOffsetY:0,labelPlacement:"center",labelTextBaseline:"middle",labelWordWrap:!1,halo:!1,haloDroppable:!1,haloLineDash:0,haloLineWidth:12,haloPointerEvents:"none",haloStrokeOpacity:.25,haloZIndex:-1,startArrow:!1,startArrowAnchor:"0.5 0.5",startArrowSize:8,startArrowLineDash:0,startArrowLineWidth:1,startArrowTransformOrigin:"center",startArrowType:"triangle",endArrow:!1,endArrowAnchor:"0.5 0.5",endArrowSize:8,endArrowLineDash:0,endArrowLineWidth:1,endArrowTransformOrigin:"center",endArrowType:"triangle",loopPlacement:"top",loopClockwise:!0};constructor(t){super(te({},{style:Xh.defaultStyleProps},t))}getKeyStyle(t){const{sourceNode:e,targetNode:n,color:r,stroke:i,...o}=this.getGraphicStyle(t);var a,s;return{path:(s=n,(a=e)&&s&&a===s?this.getLoopPath(t):this.getKeyPath(t)),...Fc(o,["halo","label","startArrow","endArrow"]),stroke:r||i}}getLoopPath(t){const{sourceNode:e,sourcePort:n,targetPort:r}=t,i=Ec(e),o=Math.max(mc(i),vc(i)),{placement:a,clockwise:s,dist:u=o}=_c(this.getGraphicStyle(t),"loop");return Uh(e,a,s,u,n,r)}getEndpoints(t){const{sourceNode:e,targetNode:n,sourcePort:r,targetPort:i}=t,[o,a]=cl(e,n,r,i);return[ll(o||e,a||n),ll(a||n,o||e)]}getHaloStyle(t){if(!1===t.halo)return!1;return{...this.getKeyStyle(t),..._c(this.getGraphicStyle(t),"halo")}}getLabelStyle(t){if(!1===t.label||ne(t.labelText))return!1;const e=_c(this.getGraphicStyle(t),"label"),{placement:n,offsetX:r,offsetY:i,autoRotate:o,maxWidth:a,...s}=e,u=function(t,e,n,r,i){let o="number"==typeof e?e:.5;"start"===e&&(o=0),"end"===e&&(o=.99);const a=Kc(t.getPoint(o)),s=Kc(t.getPoint(o+.01));let u="start"===e?"left":"end"===e?"right":"center";if(Jc(a,s)||!n){const[e,n]=zh(t,o,r,i);return{x:e,y:n,textAlign:u}}let c=Math.atan2(s[1]-a[1],s[0]-a[0]);s[0]<a[0]&&(u="center"===u?u:"left"===u?"right":"left",r*=-1,c+=Math.PI);const[h,l]=zh(t,o,r,i,c);return{x:h,y:l,textAlign:u,transform:`rotate(${c/Math.PI*180}deg)`}}(this.shapeMap.key,n,o,r,i),c=this.shapeMap.key.getLocalBounds(),h=function(t,e,n=1){return ih(Wc(t[0],t[1])*n,e)}([c.min,c.max],a);return Object.assign({wordWrapWidth:h},u,s)}drawArrow(t,e){const n="start"===e,r=t["start"===e?"startArrow":"endArrow"],i=this.shapeMap.key;if(r){const e=this.getArrowStyle(t,n),r=ne(e.src)?As:Cs,[o,a,s]=n?["markerStart","markerStartOffset","startArrowOffset"]:["markerEnd","markerEndOffset","endArrowOffset"],u=i.style[o];u?u.attr(e):i.style[o]=new r({style:e}),i.style[a]=t[s]||e.width/2+ +e.lineWidth}else{const t=n?"markerStart":"markerEnd";i.style[t]?.destroy(),i.style[t]=null}}getArrowStyle(t,e){const n=this.getKeyStyle(t),r=e?"startArrow":"endArrow",{size:i,type:o,...a}=_c(this.getGraphicStyle(t),r),[s,u]=kc(i),c=(Tt(o)?o:Yh[o]||qh)(s,u);return{...n,width:s,height:u,...c&&{path:c,fill:"simple"===o?"":n.stroke},...a}}drawLabelShape(t,e){this.upsert("label",ph,this.getLabelStyle(t),e)}drawHaloShape(t,e){this.upsert("halo",As,this.getHaloStyle(t),e)}drawKeyShape(t,e){return this.upsert("key",As,this.getKeyStyle(t),e)}render(t=this.parsedAttributes,e=this){this.drawKeyShape(t,e)&&(this.drawArrow(t,"start"),this.drawArrow(t,"end"),this.drawLabelShape(t,e),this.drawHaloShape(t,e))}animate(t,e){const n=super.animate(t,e);return n&&(n.onframe=()=>{this.drawLabelShape(this.parsedAttributes,this)}),n}}class Kh extends Xh{static defaultStyleProps={curvePosition:.5,curveOffset:20};constructor(t){super(te({},{style:Kh.defaultStyleProps},t))}getKeyPath(t){const[e,n]=this.getEndpoints(t),{controlPoints:r,curvePosition:i,curveOffset:o}=t,a=this.getControlPoints(e,n,function(t){return jt(t)?[t,1-t]:t}(i),function(t){return jt(t)?[t,-t]:t}(o),r);return Bh(e,n,a)}getControlPoints(t,e,n,r,i){return 2===i?.length?i:[Fh(t,e,n[0],r[0]),Fh(t,e,n[1],r[1])]}}class $h extends Kh{static defaultStyleProps={curvePosition:[.5,.5],curveOffset:[0,0]};constructor(t){super(te({},{style:$h.defaultStyleProps},t))}getControlPoints(t,e,n,r){const i=e[0]-t[0];return[[t[0]+i*n[0]+r[0],t[1]],[e[0]-i*n[1]+r[1],e[1]]]}}class Zh extends Kh{static defaultStyleProps={curvePosition:[.5,.5],curveOffset:[0,0]};constructor(t){super(te({},{style:Zh.defaultStyleProps},t))}getControlPoints(t,e,n,r){const i=e[1]-t[1];return[[t[0],t[1]+i*n[0]+r[0]],[e[0],e[1]-i*n[1]+r[1]]]}}class Qh extends Xh{static defaultStyleProps={};constructor(t){super(te({},{style:Qh.defaultStyleProps},t))}getKeyPath(t){const[e,n]=this.getEndpoints(t);return[["M",e[0],e[1]],["L",n[0],n[1]]]}}class Jh extends Xh{static defaultStyleProps={radius:0,controlPoints:[],router:!1,routerName:"orth",routerPadding:10};constructor(t){super(te({},{style:Jh.defaultStyleProps},t))}getKeyPath(t){const{sourceNode:e,targetNode:n,radius:r}=t,{sourcePoint:i,targetPoint:o,sourcePort:a,targetPort:s}=this.getEndpointsAndPorts(t),u=this.getControlPoints(t,i,o),c=ll(a||e,u[0]||s||n),h=ll(s||n,u[u.length-1]||a||e);return Gh([c,...u,h],r)}getEndpointsAndPorts(t){const{sourceNode:e,targetNode:n,sourcePort:r,targetPort:i}=t,[o,a]=cl(e,n,r,i);return{sourcePoint:o?ul(o):e.getCenter(),targetPoint:a?ul(a):n.getCenter(),sourcePort:o,targetPort:a}}getControlPoints(t,e,n){const{controlPoints:r,sourceNode:i,targetNode:o,router:a,routerPadding:s}=t;if(!a)return[...r];return function(t,e,n,r,i,o){const a=[t,...i,e];let s=null;const u=[];for(let t=0,e=a.length;t<e-1;t++){const i=t+1,l=a[t],d=a[i],f=Jc(c=l,h=d)||function(t,e){return t[0]===e[0]}(c,h);let p=null;0===t?i===e-1?n.intersects(r)?p=Lh(l,d,n,r):f||(p=Ih(l,d,n,r)):wc(d,n)?p=Lh(l,d,n,Ec(d,o),s):f||(p=Rh(l,d,n)):i===e-1?wc(l,r)?p=Lh(l,d,Ec(l,o),r,s):f||(p=Dh(l,d,r,s)):f||(p=Oh(l,d,s)),p?(u.push(...p.points),s=p.direction):s=kh(l,d),i<e-1&&u.push(d)}var c,h;return u}(e,n,Ec(i,s),Ec(o,s),r,s)}getLoopPath(t){const{sourceNode:e,sourcePort:n,targetPort:r,radius:i}=t,o=Ec(e),a=Math.max(mc(o),vc(o))/4,{placement:s,clockwise:u,dist:c=a}=_c(this.getGraphicStyle(t),"loop");return Wh(e,i,s,u,c,n,r)}}class tl extends Xh{static defaultStyleProps={curvePosition:.5,curveOffset:30};constructor(t){super(te({},{style:tl.defaultStyleProps},t))}getKeyPath(t){const{curvePosition:e,curveOffset:n}=t,[r,i]=this.getEndpoints(t);return function(t,e,n){return[["M",t[0],t[1]],["Q",n[0],n[1],e[0],e[1]]]}(r,i,t.controlPoint||Fh(r,i,e,n))}}function el(t){return t instanceof vh&&"node"===t.type}function nl(t){return t instanceof Xh}function rl(t){return t instanceof Sh}const il={top:[.5,0],right:[1,.5],bottom:[.5,1],left:[0,.5],default:[.5,.5]};function ol(t,e,n=il,r=!0){const i=[.5,.5],o=zt(e)?ie(n,e.toLocaleLowerCase(),i):e;if(!r&&zt(e))return o;const[a,s]=o||i;return[t.min[0]+mc(t)*a,t.min[1]+vc(t)*s]}function al(t){const e=t.getPorts();return(t.attributes.ports||[]).forEach(((n,r)=>{const{key:i,placement:o}=n;sl(n)&&(e[i||r]||=Pc(t.getKey().getBounds(),o))})),e}function sl(t){const{r:e}=t;return!e||0===Number(e)}function ul(t){return fc(t)?t:t.getPosition()}function cl(t,e,n,r){return[hl(t,e,n,r),hl(e,t,r,n)]}function hl(t,e,n,r){const i=al(t);if(n)return i[n];const o=Object.values(i);if(0===o.length)return;const a=o.map((t=>ul(t))),s=function(t,e){const n=al(t);if(e)return[ul(n[e])];const r=Object.values(n);return r.length>0?r.map((t=>ul(t))):[t.getCenter()]}(e,r),[u]=function(t,e){let n=1/0,r=[t[0],e[0]];return t.forEach((t=>{e.forEach((e=>{const i=Wc(t,e);i<n&&(n=i,r=[t,e])}))})),r}(a,s);return o.find((t=>ul(t)===u))}function ll(t,e){return el(t)?fl(t,e):dl(t,e)}function dl(t,e){if(fc(t))return t;if(t.attributes.linkToCenter)return t.getPosition();return rh(fc(e)?e:el(e)?e.getCenter():e.getPosition(),t.getBounds())}function fl(t,e){const n=fc(e)?e:el(e)?e.getCenter():e.getPosition();return t.getIntersectPoint(n)||t.getCenter()}function pl(t,e="bottom",n=!1){const r=e.split("-"),[i,o]=Pc(t,e),a=r.includes("left")?"right":r.includes("right")?"left":"center";let s=r.includes("top")?"bottom":r.includes("bottom")?"top":"middle";return n&&(s="top"===s?"bottom":"bottom"===s?"top":s),{x:i,y:o,textBaseline:s,textAlign:a}}function gl(t,e){"update"in t?t.update(e):t.attr(e)}function ml(t,e){if(Array.isArray(t)&&0===t.length)return null;const n=Array.isArray(t)?t[0]:t,r=Array.isArray(t)?t.slice(1):e||[];return new Proxy(n,{get:(t,e)=>"function"!=typeof t[e]||["onframe","onfinish"].includes(e)?"finished"===e?Promise.all([n.finished,...r.map((t=>t.finished))]):Reflect.get(t,e):(...n)=>{t[e](...n),r.forEach((t=>t[e]?.(...n)))},set:(t,e,n)=>(["onframe","onfinish"].includes(e)||r.forEach((t=>{t[e]=n})),Reflect.set(t,e,n))})}function vl(t){const e=t.reduce(((t,e)=>(Object.entries(e).forEach((([e,n])=>{void 0===t[e]?t[e]=[n]:t[e].push(n)})),t)),{});return Object.entries(e).forEach((([n,r])=>{(r.length!==t.length||r.some((t=>Pt(t)))||r.every((t=>!el(t)&&re(t,r[0]))))&&delete e[n]})),Object.entries(e).reduce(((t,[e,n])=>(n.forEach(((n,r)=>{t[r]?t[r][e]=n:t[r]={[e]:n}})),t)),[])}function yl(t){switch(t){case"opacity":return 1;case"x":case"y":case"z":case"zIndex":return 0;default:return}}function El(t,e){return e.before?.(),t?(e.beforeAnimate?.(t),t.finished.then((()=>{e.afterAnimate?.(t),e.after?.()}))):e.after?.(),t}function xl(t,e){const{animation:n}=t;if(!n||!1===e)return!1;const r={...tc};return Ot(n)&&Object.assign(r,n),Ot(e)&&Object.assign(r,e),r}const bl=(t,e,n,r)=>{if(!e)return null;const{animationsFilter:i=(()=>!0)}=r,o=(zt(e)?RE("animation",e)||[]:e).filter(i);if(0===o.length)return null;const{originalStyle:a,modifiedStyle:s,states:u}=r,c=e=>{if(e){const n=t.getElementById(e),r=`get${function(t){var e=Ht(t);return e.charAt(0).toUpperCase()+e.substring(1)}(e)}Style`,i=t?.[r]?.bind(t)||(t=>t);return{shape:n,fromStyle:i?.({...t.attributes,...a})||{},toStyle:{...n.attributes}}}return{shape:t,fromStyle:a,toStyle:{...t.attributes,...s}}};let h;const l=o.map((({fields:t,shape:e,states:r,...i})=>{if(void 0===r||r?.some((t=>u.includes(t)))){const{shape:r,fromStyle:o,toStyle:a}=c(e);if(!r)return null;const s=[{},{}];t.forEach((t=>{Object.assign(s[0],{[t]:o[t]??yl(t)}),Object.assign(s[1],{[t]:a[t]??yl(t)})}));const u=function(t,e,n){if(0===e.length)return null;const r=["opacity"];if(!e.some((t=>Object.keys(t).some((t=>r.includes(t))))))return t.animate(e,n);const i=e.map((t=>{const e={};return Object.entries(t).forEach((([t,n])=>{r.includes(t)&&(e[t]=n)})),e})),o=lh(t);return ml(t.animate(e,n),o.map((t=>t.animate(i,n))))}(r,vl(s),{...ec,...n,...i});return void 0===e&&(h=u),u}return null})).filter(Boolean),d=h||l?.[0];return d?ml(d,l.filter((t=>t!==d))):null};function wl(t,e,n){const r=new Map(t.map((t=>[n(t),t]))),i=new Map(e.map((t=>[n(t),t]))),o=new Set(r.keys()),a=new Set(i.keys()),s=[],u=[],c=[],h=[];return a.forEach((t=>{o.has(t)?re(r.get(t),i.get(t))?h.push(i.get(t)):u.push(i.get(t)):s.push(i.get(t))})),o.forEach((t=>{a.has(t)||c.push(r.get(t))})),{enter:s,exit:c,keep:h,update:u}}class Ml{context;extensions=[];extensionMap={};constructor(t){this.context=t}setExtensions(t){const e=function(t,e){const n={},r=e=>(e in n||(n[e]=0),`${t}-${e}-${n[e]++}`);return e.map((t=>"string"==typeof t?{type:t,key:r(t)}:t.key?t:{...t,key:r(t.type)}))}(this.category,t),{enter:n,update:r,exit:i,keep:o}=wl(this.extensions,e,(t=>t.key));this.createExtensions(n),this.updateExtensions([...r,...o]),this.destroyExtensions(i),this.extensions=e}createExtension(t){const{category:e}=this,{key:n,type:r}=t,i=RE(e,r);if(!i)return;const o=new i(this.context,t);this.extensionMap[n]=o}createExtensions(t){t.forEach((t=>this.createExtension(t)))}updateExtension(t){const{key:e}=t,n=this.extensionMap[e];n&&n.update(t)}updateExtensions(t){t.forEach((t=>this.updateExtension(t)))}destroyExtension(t){const e=this.extensionMap[t];e&&(e.destroy(),delete this.extensionMap[t])}destroyExtensions(t){t.forEach((({key:t})=>this.destroyExtension(t)))}destroy(){Object.values(this.extensionMap).forEach((t=>t.destroy())),delete this.context,delete this.extensions,delete this.extensionMap}}class Nl{context;options;events=[];destroyed=!1;constructor(t,e){this.context=t,this.options=e}update(t){this.options=Object.assign(this.options,t)}destroy(){delete this.context,delete this.options,this.destroyed=!0}}class Sl extends Nl{}class Tl extends Sl{static defaultOptions={enable:!0,animation:!0};constructor(t,e){super(t,Object.assign({},Tl.defaultOptions,e)),this.bindEvents()}bindEvents(){const{graph:e}=this.context;this.unbindEvents(),e.on(`combo:${t.CommonEvent.DBLCLICK}`,this.onCollapseExpand)}unbindEvents(){const{graph:e}=this.context;e.off(`combo:${t.CommonEvent.DBLCLICK}`,this.onCollapseExpand)}onCollapseExpand=async t=>{if(!this.validate(t))return;const e=t?.target?.id,{model:n,graph:r}=this.context,i=n.getComboData([e])[0];if(!i)return!1;const{oncollapse:o,onexpand:a,animation:s}=this.options,u=i.style?.collapsed;u?(await r.expand(e,s),a?.(e)):(await r.collapse(e,s),o?.(e))};validate(t){if(this.destroyed)return!1;const{enable:e}=this.options;return Tt(e)?e(t):!!e}destroy(){this.unbindEvents(),super.destroy()}}class Pl{map=new Map;emitter;recordKey=new Set;constructor(t){this.emitter=t,this.bindEvents()}bind(t,e){0!==t.length&&this.map.set(t,e)}unbind(t,e){this.map.forEach(((n,r)=>{re(r,t)&&(e&&e!==n||this.map.delete(r))}))}unbindAll(){this.map.clear()}bindEvents(){const{emitter:e}=this;e.on(t.CommonEvent.KEY_DOWN,this.onKeyDown),e.on(t.CommonEvent.KEY_UP,this.onKeyUp),e.on(t.CommonEvent.WHEEL,this.onWheel)}onKeyDown=t=>{this.recordKey.add(t.key),this.trigger(t)};onKeyUp=t=>{this.recordKey.delete(t.key)};trigger(t){this.map.forEach(((e,n)=>{re(Array.from(this.recordKey),n)&&e(t)}))}onWheel=e=>{this.map.forEach(((n,r)=>{r.includes(t.CommonEvent.WHEEL)&&re(Array.from(this.recordKey),r.filter((e=>e!==t.CommonEvent.WHEEL)))&&n(e)}))}}class Cl extends Sl{static defaultOptions={enable:!0,sensitivity:10};shortcut;defaultCursor;constructor(t,e){super(t,Object.assign({},Cl.defaultOptions,e)),this.shortcut=new Pl(t.graph),this.bindEvents(),this.defaultCursor=this.context.canvas.getConfig().cursor||"default",t.canvas.setCursor("grab")}bindEvents(){const{trigger:e}=this.options;this.shortcut.unbindAll();const{graph:n}=this.context;if(Ot(e)){n.off(t.CanvasEvent.DRAG,this.onDrag);const{up:r=[],down:i=[],left:o=[],right:a=[]}=e;this.shortcut.bind(r,(t=>this.translate([0,1],t))),this.shortcut.bind(i,(t=>this.translate([0,-1],t))),this.shortcut.bind(o,(t=>this.translate([1,0],t))),this.shortcut.bind(a,(t=>this.translate([-1,0],t)))}else n.on(t.CanvasEvent.DRAG,this.onDrag)}onDrag=t=>{"canvas"===t.targetType&&this.context.graph.translateBy([t.movement.x,t.movement.y],!1)};translate(t,e){if(!this.validate(e))return;const{sensitivity:n}=this.options,r=-1*n;this.context.graph.translateBy(Vc(t,r),this.options.animation)}validate(t){if(this.destroyed)return!1;const{enable:e}=this.options;return Tt(e)?e(t):!!e}destroy(){this.context.canvas.setCursor(this.defaultCursor),super.destroy()}}class kl extends Sl{static defaultOptions={animation:!0,enable:!0,draggableElement:["node","combo"],dropEffect:"move",state:"selected",hideEdges:"none",shadowZIndex:100,shadowFill:"#F3F9FF",shadowFillOpacity:.5,shadowStroke:"#1890FF",shadowStrokeOpacity:.9,shadowLineDash:[5,5]};enable=!1;target=[];shadow;shadowOrigin=[0,0];hiddenEdges=[];get animation(){return!!this.options.shadow&&this.options.animation}get element(){return new Set(this.options.draggableElement)}constructor(t,e){super(t,Object.assign({},kl.defaultOptions,e)),this.bindEvents()}update(t){super.update(t),this.bindEvents()}bindEvents(){const{graph:e}=this.context;this.unbindEvents(),this.element.forEach((n=>{e.on(`${n}:${t.CommonEvent.DRAG_START}`,this.onDragStart),e.on(`${n}:${t.CommonEvent.DRAG}`,this.onDrag),e.on(`${n}:${t.CommonEvent.DRAG_END}`,this.onDragEnd)})),["link"].includes(this.options.dropEffect)&&(e.on(`combo:${t.CommonEvent.DROP}`,this.onDrop),e.on(`canvas:${t.CommonEvent.DROP}`,this.onDrop))}getSelectedNodeIDs(t){return Array.from(new Set(this.context.graph.getElementDataByState("node",this.options.state).map((t=>t.id)).concat(t)))}onDragStart=t=>{this.enable=this.validate(t),this.enable&&(this.target=this.getSelectedNodeIDs([t.target.id]),this.hideEdges(),this.context.graph.frontElement(this.target),this.options.shadow&&this.createShadow(this.target))};onDrag=t=>{if(!this.enable)return;const{dx:e,dy:n}=t;this.options.shadow?this.moveShadow([e,n]):this.moveElement(this.target,[e,n])};onDragEnd=()=>{if(this.enable=!1,this.options.shadow){if(!this.shadow)return;this.shadow.style.visibility="hidden";const{x:t=0,y:e=0}=this.shadow.attributes,[n,r]=jc([+t,+e],this.shadowOrigin);this.moveElement(this.target,[n,r])}this.showEdges(),this.options.onfinish?.(this.target),this.target=[]};onDrop=async t=>{if("link"!==this.options.dropEffect)return;const{model:e,element:n}=this.context,r=t.target.id;this.target.forEach((t=>{const n=e.getParentData(t,hc);n&&Dc(n)===r&&e.refreshComboData(r),e.setParent(t,r,hc)})),await(n?.draw({animation:!0}))};validate(t){if(this.destroyed)return!1;if(!this.element.has(t.targetType))return!1;const{enable:e}=this.options;return Tt(e)?e(t):!!e}async moveElement(t,e){const{model:n,element:r}=this.context,{dropEffect:i}=this.options;t.forEach((t=>{const r=n.getElementType(t);"node"===r?n.translateNodeBy(t,e):"combo"===r&&n.translateComboBy(t,e)})),"move"===i&&t.forEach((t=>n.refreshComboData(t))),await r.draw({animation:this.animation})}moveShadow(t){if(!this.shadow)return;const{x:e=0,y:n=0}=this.shadow.attributes,[r,i]=t;this.shadow.attr({x:+e+r,y:+n+i})}createShadow(t){const e=_c(this.options,"shadow"),n=bc(t.map((t=>this.context.element.getElement(t).getBounds()))),[r,i]=n.min;this.shadowOrigin=[r,i];const[o,a]=yc(n),s={width:o,height:a,x:r,y:i};this.shadow?this.shadow.attr({...e,...s,visibility:"visible"}):(this.shadow=new Ds({style:{...e,...s,pointerEvents:"none",$layer:"transient"}}),this.context.canvas.appendChild(this.shadow))}showEdges(){this.options.shadow||0===this.hiddenEdges.length||(this.context.graph.showElement(this.hiddenEdges),this.hiddenEdges=[])}hideEdges(){const{hideEdges:t,shadow:e}=this.options;if("none"===t||e)return;const{graph:n}=this.context;this.hiddenEdges="all"===t?n.getEdgeData().map(Dc):Array.from(new Set(this.target.map((e=>n.getRelatedEdgesData(e,t).map(Dc))).flat())),n.hideElement(this.hiddenEdges)}unbindEvents(){const{graph:e}=this.context;this.element.forEach((n=>{e.off(`${n}:${t.CommonEvent.DRAG_START}`,this.onDragStart),e.off(`${n}:${t.CommonEvent.DRAG}`,this.onDrag),e.off(`${n}:${t.CommonEvent.DRAG_END}`,this.onDragEnd)})),e.off(`combo:${t.CommonEvent.DROP}`,this.onDrop),e.off(`canvas:${t.CommonEvent.DROP}`,this.onDrop)}destroy(){this.unbindEvents(),this.shadow?.destroy(),super.destroy()}}class Al extends Sl{static defaultOptions={animation:{duration:200},enable:!0,sensitivity:1,trigger:[]};shortcut;constructor(t,e){super(t,Object.assign({},Al.defaultOptions,e)),this.shortcut=new Pl(t.graph),this.bindEvents()}update(t){super.update(t),this.bindEvents()}bindEvents(){const{trigger:e}=this.options;if(this.shortcut.unbindAll(),At(e)&&(this.preventDefault(t.CanvasEvent.WHEEL),this.shortcut.bind([...e,t.CanvasEvent.WHEEL],(t=>{const{deltaX:e,deltaY:n}=t;this.zoom(-(n??e),t)}))),Ot(e)){const{zoomIn:t=[],zoomOut:n=[],reset:r=[]}=e;this.shortcut.bind(t,(t=>this.zoom(1,t))),this.shortcut.bind(n,(t=>this.zoom(-1,t))),this.shortcut.bind(r,this.onReset)}}zoom=async(t,e)=>{if(!this.validate(e))return;const{graph:n}=this.context;let r;"viewport"in e&&(r=Kc(e.viewport));const{sensitivity:i,onfinish:o}=this.options,a=t*i/10,s=n.getZoom();await n.zoomTo(s+a,this.options.animation,r),o?.()};onReset=async()=>{await this.context.graph.zoomTo(1,this.options.animation)};validate(t){if(this.destroyed)return!1;const{enable:e}=this.options;return Tt(e)?e(t):!!e}preventDefault(t){const e=this.context.canvas.getContainer();e&&e.addEventListener(t,(t=>t.preventDefault()))}}var Ol=function(t){return null!==t&&"function"!=typeof t&&isFinite(t.length)},Rl=function(t,e){return!!Ol(t)&&t.indexOf(e)>-1},Dl=function(t,e){if(!Ol(t))return t;for(var n=[],r=0;r<t.length;r++){var i=t[r];e(i,r)&&n.push(i)}return n},Il={}.toString,Ll=function(t,e){return Il.call(t)==="[object "+e+"]"},_l=function(t){return Ll(t,"Function")},zl=function(t){return null==t},Fl=function(t){return Array.isArray?Array.isArray(t):Ll(t,"Array")},Bl=function(t){var e=typeof t;return null!==t&&"object"===e||"function"===e};function Gl(t,e){if(t)if(Fl(t))for(var n=0,r=t.length;n<r&&!1!==e(t[n],n);n++);else if(Bl(t))for(var i in t)if(t.hasOwnProperty(i)&&!1===e(t[i],i))break}var jl=Object.keys?function(t){return Object.keys(t)}:function(t){var e=[];return Gl(t,(function(n,r){_l(t)&&"prototype"===r||e.push(r)})),e};function Vl(t,e){var n=jl(e),r=n.length;if(zl(t))return!r;for(var i=0;i<r;i+=1){var o=n[i];if(e[o]!==t[o]||!(o in t))return!1}return!0}var Ul=function(t){return"object"==typeof t&&null!==t},Wl=function(t){if(!Ul(t)||!Ll(t,"Object"))return!1;if(null===Object.getPrototypeOf(t))return!0;for(var e=t;null!==Object.getPrototypeOf(e);)e=Object.getPrototypeOf(e);return Object.getPrototypeOf(t)===e};var Hl=function(t,e){if(void 0===e&&(e=[]),Fl(t))for(var n=0;n<t.length;n+=1)Hl(t[n],e);else e.push(t);return e},ql=function(t){if(Fl(t))return t.reduce((function(t,e){return Math.max(t,e)}),t[0])},Yl=function(t){if(Fl(t))return t.reduce((function(t,e){return Math.min(t,e)}),t[0])},Xl=Array.prototype,Kl=Xl.splice,$l=Xl.indexOf,Zl=Array.prototype.splice,Ql=function(t,e){if(!Ol(t))return[];for(var n=t?e.length:0,r=n-1;n--;){var i=void 0,o=e[n];n!==r&&o===i||(i=o,Zl.call(t,o,1))}return t},Jl=function(t,e,n){if(!Fl(t)&&!Wl(t))return t;var r=n;return Gl(t,(function(t,n){r=e(r,t,n)})),r},td=function(t){return Ll(t,"String")};function ed(t,e){void 0===e&&(e=new Map);var n=[];if(Array.isArray(t))for(var r=0,i=t.length;r<i;r++){var o=t[r];e.has(o)||(n.push(o),e.set(o,!0))}return n}var nd=Object.prototype.hasOwnProperty;function rd(t,e){if(!e||!Fl(t))return{};for(var n,r={},i=_l(e)?e:function(t){return t[e]},o=0;o<t.length;o++){var a=t[o];n=i(a),nd.call(r,n)?r[n].push(a):r[n]=[a]}return r}function id(t,e){if(!e)return{0:t};if(!_l(e)){var n=Fl(e)?e:e.replace(/\s+/g,"").split("*");e=function(t){for(var e="_",r=0,i=n.length;r<i;r++)e+=t[n[r]]&&t[n[r]].toString();return e}}return rd(t,e)}var od={};var ad=function(t){return Ll(t,"Number")},sd=Number.isInteger?Number.isInteger:function(t){return ad(t)&&t%1==0};var ud=180/Math.PI,cd=parseInt,hd=Math.PI/180,ld=function(t,e){return t.hasOwnProperty(e)},dd=Object.values?function(t){return Object.values(t)}:function(t){var e=[];return Gl(t,(function(n,r){_l(t)&&"prototype"===r||e.push(n)})),e},fd=function(t){return zl(t)?"":t.toString()};var pd={}.toString,gd=function(t){return pd.call(t).replace(/^\[object /,"").replace(/]$/,"")};var md=Object.prototype,vd=function(t){var e=t&&t.constructor;return t===("function"==typeof e&&e.prototype||md)};function yd(t,e){for(var n in e)e.hasOwnProperty(n)&&"constructor"!==n&&void 0!==e[n]&&(t[n]=e[n])}function Ed(t,e,n,r){return e&&yd(t,e),n&&yd(t,n),r&&yd(t,r),t}var xd=function(t){if("object"!=typeof t||null===t)return t;var e;if(Fl(t)){e=[];for(var n=0,r=t.length;n<r;n++)"object"==typeof t[n]&&null!=t[n]?e[n]=xd(t[n]):e[n]=t[n]}else for(var i in e={},t)"object"==typeof t[i]&&null!=t[i]?e[i]=xd(t[i]):e[i]=t[i];return e};var bd=function(t,e){if(!_l(t))throw new TypeError("Expected a function");var n=function(){for(var r=[],i=0;i<arguments.length;i++)r[i]=arguments[i];var o=e?e.apply(this,r):r[0],a=n.cache;if(a.has(o))return a.get(o);var s=t.apply(this,r);return a.set(o,s),s};return n.cache=new Map,n};function wd(t,e,n,r){for(var i in n=n||0,r=r||5,e)if(e.hasOwnProperty(i)){var o=e[i];null!==o&&Wl(o)?(Wl(t[i])||(t[i]={}),n<r?wd(t[i],o,n+1,r):t[i]=e[i]):Fl(o)?(t[i]=[],t[i]=t[i].concat(o)):void 0!==o&&(t[i]=o)}}var Md=Object.prototype.hasOwnProperty;var Nd,Sd=function(t,e){if(t===e)return!0;if(!t||!e)return!1;if(td(t)||td(e))return!1;if(Ol(t)||Ol(e)){if(t.length!==e.length)return!1;for(var n=!0,r=0;r<t.length&&(n=Sd(t[r],e[r]));r++);return n}if(Ul(t)||Ul(e)){var i=Object.keys(t),o=Object.keys(e);if(i.length!==o.length)return!1;for(n=!0,r=0;r<i.length&&(n=Sd(t[i[r]],e[i[r]]));r++);return n}return!1},Td=function(t){return t},Pd=Object.prototype.hasOwnProperty,Cd={};var kd=bd((function(t,e){void 0===e&&(e={});var n=e.fontSize,r=e.fontFamily,i=e.fontWeight,o=e.fontStyle,a=e.fontVariant;return Nd||(Nd=document.createElement("canvas").getContext("2d")),Nd.font=[o,a,i,n+"px",r].join(" "),Nd.measureText(td(t)?t:"").width}),(function(t,e){return void 0===e&&(e={}),function(){for(var t=0,e=0,n=arguments.length;e<n;e++)t+=arguments[e].length;var r=Array(t),i=0;for(e=0;e<n;e++)for(var o=arguments[e],a=0,s=o.length;a<s;a++,i++)r[i]=o[a];return r}([t],dd(e)).join("")})),Ad=function(){function t(){this.map={}}return t.prototype.has=function(t){return void 0!==this.map[t]},t.prototype.get=function(t,e){var n=this.map[t];return void 0===n?e:n},t.prototype.set=function(t,e){this.map[t]=e},t.prototype.clear=function(){this.map={}},t.prototype.delete=function(t){delete this.map[t]},t.prototype.size=function(){return Object.keys(this.map).length},t}(),Od=Object.freeze({__proto__:null,Cache:Ad,assign:Ed,augment:function(){for(var t=[],e=0;e<arguments.length;e++)t[e]=arguments[e];for(var n=t[0],r=1;r<t.length;r++){var i=t[r];_l(i)&&(i=i.prototype),Ed(n.prototype,i)}},clamp:function(t,e,n){return t<e?e:t>n?n:t},clearAnimationFrame:function(t){(window.cancelAnimationFrame||window.webkitCancelAnimationFrame||window.mozCancelAnimationFrame||window.msCancelAnimationFrame||clearTimeout)(t)},clone:xd,contains:Rl,debounce:function(t,e,n){var r;return function(){var i=this,o=arguments,a=n&&!r;clearTimeout(r),r=setTimeout((function(){r=null,n||t.apply(i,o)}),e),a&&t.apply(i,o)}},deepMix:function(t){for(var e=[],n=1;n<arguments.length;n++)e[n-1]=arguments[n];for(var r=0;r<e.length;r+=1)wd(t,e[r]);return t},difference:function(t,e){return void 0===e&&(e=[]),Dl(t,(function(t){return!Rl(e,t)}))},each:Gl,endsWith:function(t,e){return!(!Fl(t)&&!td(t))&&t[t.length-1]===e},every:function(t,e){for(var n=0;n<t.length;n++)if(!e(t[n],n))return!1;return!0},extend:function(t,e,n,r){_l(e)||(n=e,e=t,t=function(){});var i=Object.create?function(t,e){return Object.create(t,{constructor:{value:e}})}:function(t,e){function n(){}n.prototype=t;var r=new n;return r.constructor=e,r},o=i(e.prototype,t);return t.prototype=Ed(o,t.prototype),t.superclass=i(e.prototype,e),Ed(o,n),Ed(t,r),t},filter:Dl,find:function(t,e){if(!Fl(t))return null;var n;if(_l(e)&&(n=e),Wl(e)&&(n=function(t){return Vl(t,e)}),n)for(var r=0;r<t.length;r+=1)if(n(t[r]))return t[r];return null},findIndex:function(t,e,n){void 0===n&&(n=0);for(var r=n;r<t.length;r++)if(e(t[r],r))return r;return-1},firstValue:function(t,e){for(var n=null,r=0;r<t.length;r++){var i=t[r][e];if(!zl(i)){n=Fl(i)?i[0]:i;break}}return n},fixedBase:function(t,e){var n=e.toString(),r=n.indexOf(".");if(-1===r)return Math.round(t);var i=n.substr(r+1).length;return i>20&&(i=20),parseFloat(t.toFixed(i))},flatten:function(t){if(!Fl(t))return[];for(var e=[],n=0;n<t.length;n++)e=e.concat(t[n]);return e},flattenDeep:Hl,forIn:Gl,get:function(t,e,n){for(var r=0,i=td(e)?e.split("."):e;t&&r<i.length;)t=t[i[r++]];return void 0===t||r<i.length?n:t},getEllipsisText:function(t,e,n,r){void 0===r&&(r="...");var i,o,a=kd(r,n),s=td(t)?t:fd(t),u=e,c=[];if(kd(t,n)<=e)return t;for(;i=s.substr(0,16),!((o=kd(i,n))+a>u&&o>u);)if(c.push(i),u-=o,!(s=s.substr(16)))return c.join("");for(;i=s.substr(0,1),!((o=kd(i,n))+a>u);)if(c.push(i),u-=o,!(s=s.substr(1)))return c.join("");return""+c.join("")+r},getRange:function(t){var e=t.filter((function(t){return!isNaN(t)}));if(!e.length)return{min:0,max:0};if(Fl(t[0])){for(var n=[],r=0;r<t.length;r++)n=n.concat(t[r]);e=n}var i=ql(e);return{min:Yl(e),max:i}},getType:gd,getWrapBehavior:function(t,e){return t["_wrap_"+e]},group:function(t,e){if(!e)return[t];var n=id(t,e),r=[];for(var i in n)r.push(n[i]);return r},groupBy:rd,groupToMap:id,has:ld,hasKey:ld,hasValue:function(t,e){return Rl(dd(t),e)},head:function(t){if(Ol(t))return t[0]},identity:function(t){return t},includes:Rl,indexOf:function(t,e){if(!Ol(t))return-1;var n=Array.prototype.indexOf;if(n)return n.call(t,e);for(var r=-1,i=0;i<t.length;i++)if(t[i]===e){r=i;break}return r},isArguments:function(t){return Ll(t,"Arguments")},isArray:Fl,isArrayLike:Ol,isBoolean:function(t){return Ll(t,"Boolean")},isDate:function(t){return Ll(t,"Date")},isDecimal:function(t){return ad(t)&&t%1!=0},isElement:function(t){return t instanceof Element||t instanceof HTMLDocument},isEmpty:function(t){if(zl(t))return!0;if(Ol(t))return!t.length;var e=gd(t);if("Map"===e||"Set"===e)return!t.size;if(vd(t))return!Object.keys(t).length;for(var n in t)if(Md.call(t,n))return!1;return!0},isEqual:Sd,isEqualWith:function(t,e,n){return _l(n)?!!n(t,e):Sd(t,e)},isError:function(t){return Ll(t,"Error")},isEven:function(t){return ad(t)&&t%2==0},isFinite:function(t){return ad(t)&&isFinite(t)},isFunction:_l,isInteger:sd,isMatch:Vl,isNegative:function(t){return ad(t)&&t<0},isNil:zl,isNull:function(t){return null===t},isNumber:ad,isNumberEqual:function(t,e,n){return void 0===n&&(n=1e-5),Math.abs(t-e)<n},isObject:Bl,isObjectLike:Ul,isOdd:function(t){return ad(t)&&t%2!=0},isPlainObject:Wl,isPositive:function(t){return ad(t)&&t>0},isPrototype:vd,isRegExp:function(t){return Ll(t,"RegExp")},isString:td,isType:Ll,isUndefined:function(t){return void 0===t},keys:jl,last:function(t){if(Ol(t)){return t[t.length-1]}},lowerCase:function(t){return fd(t).toLowerCase()},lowerFirst:function(t){var e=fd(t);return e.charAt(0).toLowerCase()+e.substring(1)},map:function(t,e){if(!Ol(t))return t;for(var n=[],r=0;r<t.length;r++){var i=t[r];n.push(e(i,r))}return n},mapValues:function(t,e){void 0===e&&(e=Td);var n={};return Bl(t)&&!zl(t)&&Object.keys(t).forEach((function(r){n[r]=e(t[r],r)})),n},max:ql,maxBy:function(t,e){if(Fl(t)){for(var n,r=-1/0,i=0;i<t.length;i++){var o=t[i],a=_l(e)?e(o):o[e];a>r&&(n=o,r=a)}return n}},measureTextWidth:kd,memoize:bd,min:Yl,minBy:function(t,e){if(Fl(t)){for(var n,r=1/0,i=0;i<t.length;i++){var o=t[i],a=_l(e)?e(o):o[e];a<r&&(n=o,r=a)}return n}},mix:Ed,mod:function(t,e){return(t%e+e)%e},noop:function(){},number2color:function(t){var e=od[t];if(!e){for(var n=t.toString(16),r=n.length;r<6;r++)n="0"+n;e="#"+n,od[t]=e}return e},omit:function(t,e){return Jl(t,(function(t,n,r){return e.includes(r)||(t[r]=n),t}),{})},parseRadius:function(t){var e=0,n=0,r=0,i=0;return Fl(t)?1===t.length?e=n=r=i=t[0]:2===t.length?(e=r=t[0],n=i=t[1]):3===t.length?(e=t[0],n=i=t[1],r=t[2]):(e=t[0],n=t[1],r=t[2],i=t[3]):e=n=r=i=t,{r1:e,r2:n,r3:r,r4:i}},pick:function(t,e){if(null===t||!Wl(t))return{};var n={};return Gl(e,(function(e){Pd.call(t,e)&&(n[e]=t[e])})),n},pull:function(t){for(var e=[],n=1;n<arguments.length;n++)e[n-1]=arguments[n];for(var r=0;r<e.length;r++)for(var i=e[r],o=-1;(o=$l.call(t,i))>-1;)Kl.call(t,o,1);return t},pullAt:Ql,reduce:Jl,remove:function(t,e){var n=[];if(!Ol(t))return n;for(var r=-1,i=[],o=t.length;++r<o;){var a=t[r];e(a,r,t)&&(n.push(a),i.push(r))}return Ql(t,i),n},requestAnimationFrame:function(t){return(window.requestAnimationFrame||window.webkitRequestAnimationFrame||window.mozRequestAnimationFrame||window.msRequestAnimationFrame||function(t){return setTimeout(t,16)})(t)},set:function(t,e,n){var r=t,i=td(e)?e.split("."):e;return i.forEach((function(t,e){e<i.length-1?(Bl(r[t])||(r[t]=ad(i[e+1])?[]:{}),r=r[t]):r[t]=n})),t},size:function(t){return zl(t)?0:Ol(t)?t.length:Object.keys(t).length},some:function(t,e){for(var n=0;n<t.length;n++)if(e(t[n],n))return!0;return!1},sortBy:function(t,e){var n;if(_l(e))n=function(t,n){return e(t)-e(n)};else{var r=[];td(e)?r.push(e):Fl(e)&&(r=e),n=function(t,e){for(var n=0;n<r.length;n+=1){var i=r[n];if(t[i]>e[i])return 1;if(t[i]<e[i])return-1}return 0}}return t.sort(n),t},startsWith:function(t,e){return!(!Fl(t)&&!td(t))&&t[0]===e},substitute:function(t,e){return t&&e?t.replace(/\\?\{([^{}]+)\}/g,(function(t,n){return"\\"===t.charAt(0)?t.slice(1):void 0===e[n]?"":e[n]})):t},throttle:function(t,e,n){var r,i,o,a,s=0;n||(n={});var u=function(){s=!1===n.leading?0:Date.now(),r=null,a=t.apply(i,o),r||(i=o=null)},c=function(){var c=Date.now();s||!1!==n.leading||(s=c);var h=e-(c-s);return i=this,o=arguments,h<=0||h>e?(r&&(clearTimeout(r),r=null),s=c,a=t.apply(i,o),r||(i=o=null)):r||!1===n.trailing||(r=setTimeout(u,h)),a};return c.cancel=function(){clearTimeout(r),s=0,r=i=o=null},c},toArray:function(t){return Ol(t)?Array.prototype.slice.call(t):[]},toDegree:function(t){return ud*t},toInteger:cd,toRadian:function(t){return hd*t},toString:fd,union:function(){for(var t=[],e=0;e<arguments.length;e++)t[e]=arguments[e];return ed([].concat.apply([],t))},uniq:ed,uniqueId:function(t){return Cd[t=t||"g"]?Cd[t]+=1:Cd[t]=1,t+Cd[t]},upperCase:function(t){return fd(t).toUpperCase()},upperFirst:function(t){var e=fd(t);return e.charAt(0).toUpperCase()+e.substring(1)},values:dd,valuesOfKey:function(t,e){for(var n=[],r={},i=0;i<t.length;i++){var o=t[i][e];if(!zl(o)){Fl(o)||(o=[o]);for(var a=0;a<o.length;a++){var s=o[a];r[s]||(n.push(s),r[s]=!0)}}}return n},wrapBehavior:function(t,e){if(t["_wrap_"+e])return t["_wrap_"+e];var n=function(n){t[e](n)};return t["_wrap_"+e]=n,n}});var Rd={assign:d(Od).mix,getHeight:function(t,e,n,r){return void 0===r&&(r="height"),"center"===n?(t[r]+e[r])/2:t.height}},Dd=Rd,Id={getId:function(t){return t.id||t.name},getPreH:function(t){return t.preH||0},getPreV:function(t){return t.preV||0},getHGap:function(t){return t.hgap||18},getVGap:function(t){return t.vgap||18},getChildren:function(t){return t.children},getHeight:function(t){return t.height||36},getWidth:function(t){var e=t.label||" ";return t.width||18*e.split("").length}};function Ld(t,e){var n=this;if(n.vgap=n.hgap=0,t instanceof Ld)return t;n.data=t;var r=e.getHGap(t),i=e.getVGap(t);return n.preH=e.getPreH(t),n.preV=e.getPreV(t),n.width=e.getWidth(t),n.height=e.getHeight(t),n.width+=n.preH,n.height+=n.preV,n.id=e.getId(t),n.x=n.y=0,n.depth=0,n.children||(n.children=[]),n.addGap(r,i),n}Dd.assign(Ld.prototype,{isRoot:function(){return 0===this.depth},isLeaf:function(){return 0===this.children.length},addGap:function(t,e){var n=this;n.hgap+=t,n.vgap+=e,n.width+=2*t,n.height+=2*e},eachNode:function(t){for(var e,n=[this];e=n.shift();)t(e),n=e.children.concat(n)},DFTraverse:function(t){this.eachNode(t)},BFTraverse:function(t){for(var e,n=[this];e=n.shift();)t(e),n=n.concat(e.children)},getBoundingBox:function(){var t={left:Number.MAX_VALUE,top:Number.MAX_VALUE,width:0,height:0};return this.eachNode((function(e){t.left=Math.min(t.left,e.x),t.top=Math.min(t.top,e.y),t.width=Math.max(t.width,e.x+e.width),t.height=Math.max(t.height,e.y+e.height)})),t},translate:function(t,e){void 0===t&&(t=0),void 0===e&&(e=0),this.eachNode((function(n){n.x+=t,n.y+=e,n.x+=n.preH,n.y+=n.preV}))},right2left:function(){var t=this,e=t.getBoundingBox();t.eachNode((function(t){t.x=t.x-2*(t.x-e.left)-t.width})),t.translate(e.width,0)},bottom2top:function(){var t=this,e=t.getBoundingBox();t.eachNode((function(t){t.y=t.y-2*(t.y-e.top)-t.height})),t.translate(0,e.height)}});var _d=function(t,e,n){void 0===e&&(e={});var r,i=new Ld(t,e=Dd.assign({},Id,e)),o=[i];if(!n&&!t.collapsed)for(;r=o.shift();)if(!r.data.collapsed){var a=e.getChildren(r.data),s=a?a.length:0;if(r.children=new Array(s),a&&s)for(var u=0;u<s;u++){var c=new Ld(a[u],e);r.children[u]=c,o.push(c),c.parent=r,c.depth=r.depth+1}}return i},zd=_d,Fd=function(){function t(t,e){void 0===e&&(e={});this.options=e,this.rootNode=zd(t,e)}return t.prototype.execute=function(){throw new Error("please override this method")},t}(),Bd=Fd;function Gd(t,e,n,r){void 0===r&&(r=[]);var i=this;i.w=t||0,i.h=e||0,i.y=n||0,i.x=0,i.c=r||[],i.cs=r.length,i.prelim=0,i.mod=0,i.shift=0,i.change=0,i.tl=null,i.tr=null,i.el=null,i.er=null,i.msel=0,i.mser=0}function jd(t,e,n){n?t.y+=e:t.x+=e,t.children.forEach((function(t){jd(t,e,n)}))}function Vd(t,e){var n=e?t.y:t.x;return t.children.forEach((function(t){n=Math.min(Vd(t,e),n)})),n}function Ud(t,e){jd(t,-Vd(t,e),e)}function Wd(t,e,n){n?e.y=t.x:e.x=t.x,t.c.forEach((function(t,r){Wd(t,e.children[r],n)}))}function Hd(t,e,n){void 0===n&&(n=0),e?(t.x=n,n+=t.width):(t.y=n,n+=t.height),t.children.forEach((function(t){Hd(t,e,n)}))}Gd.fromNode=function(t,e){if(!t)return null;var n=[];return t.children.forEach((function(t){n.push(Gd.fromNode(t,e))})),e?new Gd(t.height,t.width,t.x,n):new Gd(t.width,t.height,t.y,n)};var qd=_d,Yd=function(t,e){for(var n=qd(t.data,e,!0),r=qd(t.data,e,!0),i=t.children.length,o=Math.round(i/2),a=e.getSide||function(t,e){return e<o?"right":"left"},s=0;s<i;s++){var u=t.children[s];"right"===a(u,s)?r.children.push(u):n.children.push(u)}return n.eachNode((function(t){t.isRoot()||(t.side="left")})),r.eachNode((function(t){t.isRoot()||(t.side="right")})),{left:n,right:r}},Xd=Yd,Kd=["LR","RL","TB","BT","H","V"],$d=["LR","RL","H"],Zd=Kd[0],Qd=function(t,e,n){var r=e.direction||Zd;if(e.isHorizontal=function(t){return $d.indexOf(t)>-1}(r),r&&-1===Kd.indexOf(r))throw new TypeError("Invalid direction: "+r);if(r===Kd[0])n(t,e);else if(r===Kd[1])n(t,e),t.right2left();else if(r===Kd[2])n(t,e);else if(r===Kd[3])n(t,e),t.bottom2top();else if(r===Kd[4]||r===Kd[5]){var i=Xd(t,e),o=i.left,a=i.right;n(o,e),n(a,e),e.isHorizontal?o.right2left():o.bottom2top(),a.translate(o.x-a.x,o.y-a.y),t.x=o.x,t.y=a.y;var s=t.getBoundingBox();e.isHorizontal?s.top<0&&t.translate(0,-s.top):s.left<0&&t.translate(-s.left,0)}var u=e.fixedRoot;return void 0===u&&(u=!0),u&&t.translate(-(t.x+t.width/2+t.hgap),-(t.y+t.height/2+t.vgap)),t};function Jd(t,e){return Jd=Object.setPrototypeOf?Object.setPrototypeOf.bind():function(t,e){return t.__proto__=e,t},Jd(t,e)}var tf=function(t,e){void 0===e&&(e={});var n=e.isHorizontal;function r(t){0===t.cs?(t.el=t,t.er=t,t.msel=t.mser=0):(t.el=t.c[0].el,t.msel=t.c[0].msel,t.er=t.c[t.cs-1].er,t.mser=t.c[t.cs-1].mser)}function i(t,e,n){for(var r=t.c[e-1],i=r.mod,c=t.c[e],h=c.mod;null!==r&&null!==c;){u(r)>n.low&&(n=n.nxt);var l=i+r.prelim+r.w-(h+c.prelim);l>0&&(h+=l,o(t,e,n.index,l));var d=u(r),f=u(c);d<=f&&null!==(r=s(r))&&(i+=r.mod),d>=f&&null!==(c=a(c))&&(h+=c.mod)}!r&&c?function(t,e,n,r){var i=t.c[0].el;i.tl=n;var o=r-n.mod-t.c[0].msel;i.mod+=o,i.prelim-=o,t.c[0].el=t.c[e].el,t.c[0].msel=t.c[e].msel}(t,e,c,h):r&&!c&&function(t,e,n,r){var i=t.c[e].er;i.tr=n;var o=r-n.mod-t.c[e].mser;i.mod+=o,i.prelim-=o,t.c[e].er=t.c[e-1].er,t.c[e].mser=t.c[e-1].mser}(t,e,r,i)}function o(t,e,n,r){t.c[e].mod+=r,t.c[e].msel+=r,t.c[e].mser+=r,function(t,e,n,r){if(n!==e-1){var i=e-n;t.c[n+1].shift+=r/i,t.c[e].shift-=r/i,t.c[e].change-=r-r/i}}(t,e,n,r)}function a(t){return 0===t.cs?t.tl:t.c[0]}function s(t){return 0===t.cs?t.tr:t.c[t.cs-1]}function u(t){return t.y+t.h}function c(t,e,n){for(;null!==n&&t>=n.low;)n=n.nxt;return{low:t,index:e,nxt:n}}Hd(t,n);var h=Gd.fromNode(t,n);return function t(e){if(0!==e.cs){t(e.c[0]);for(var n=c(u(e.c[0].el),0,null),o=1;o<e.cs;++o){t(e.c[o]);var a=u(e.c[o].er);i(e,o,n),n=c(a,o,n)}!function(t){t.prelim=(t.c[0].prelim+t.c[0].mod+t.c[t.cs-1].mod+t.c[t.cs-1].prelim+t.c[t.cs-1].w)/2-t.w/2}(e),r(e)}else r(e)}(h),function t(e,n){n+=e.mod,e.x=e.prelim+n,function(t){for(var e=0,n=0,r=0;r<t.cs;r++)n+=(e+=t.c[r].shift)+t.c[r].change,t.c[r].mod+=n}(e);for(var r=0;r<e.cs;r++)t(e.c[r],n)}(h,0),Wd(h,t,n),Ud(t,n),t},ef=Qd,nf=Rd,rf=function(t){var e,n;function r(){return t.apply(this,arguments)||this}return n=t,(e=r).prototype=Object.create(n.prototype),e.prototype.constructor=e,Jd(e,n),r.prototype.execute=function(){return ef(this.rootNode,this.options,tf)},r}(Bd),of={};var af=function(t,e){return e=nf.assign({},of,e),new rf(t,e).execute()},sf=Rd;function uf(t,e){void 0===e&&(e=[]);var n=this;n.x=n.y=0,n.leftChild=n.rightChild=null,n.height=0,n.children=e}var cf={isHorizontal:!0,nodeSep:20,nodeSize:20,rankSep:200,subTreeSep:10};function hf(t,e,n){n?(e.x=t.x,e.y=t.y):(e.x=t.y,e.y=t.x),t.children.forEach((function(t,r){hf(t,e.children[r],n)}))}function lf(t,e){return lf=Object.setPrototypeOf?Object.setPrototypeOf.bind():function(t,e){return t.__proto__=e,t},lf(t,e)}var df=function(t,e){void 0===e&&(e={}),e=sf.assign({},cf,e);var n,r=0;var i=function t(e){if(!e)return null;e.width=0,e.depth&&e.depth>r&&(r=e.depth);var n=e.children,i=n.length,o=new uf(e.height,[]);return n.forEach((function(e,n){var r=t(e);o.children.push(r),0===n&&(o.leftChild=r),n===i-1&&(o.rightChild=r)})),o.originNode=e,o.isLeaf=e.isLeaf(),o}(t);return function t(e){if(e.isLeaf||0===e.children.length)e.drawingDepth=r;else{var n=e.children.map((function(e){return t(e)})),i=Math.min.apply(null,n);e.drawingDepth=i-1}return e.drawingDepth}(i),function t(r){r.x=r.drawingDepth*e.rankSep,r.isLeaf?(r.y=0,n&&(r.y=n.y+n.height+e.nodeSep,r.originNode.parent!==n.originNode.parent&&(r.y+=e.subTreeSep)),n=r):(r.children.forEach((function(e){t(e)})),r.y=(r.leftChild.y+r.rightChild.y)/2)}(i),hf(i,t,e.isHorizontal),t},ff=Qd,pf=Rd,gf=function(t){var e,n;function r(){return t.apply(this,arguments)||this}return n=t,(e=r).prototype=Object.create(n.prototype),e.prototype.constructor=e,lf(e,n),r.prototype.execute=function(){var t=this;return t.rootNode.width=0,ff(t.rootNode,t.options,df)},r}(Bd),mf={};var vf=function(t,e){return e=pf.assign({},mf,e),new gf(t,e).execute()},yf=Rd;function Ef(t,e){return Ef=Object.setPrototypeOf?Object.setPrototypeOf.bind():function(t,e){return t.__proto__=e,t},Ef(t,e)}var xf=Bd,bf=function(t,e,n,r){var i=null;t.eachNode((function(t){!function(t,e,n,r,i){var o="function"==typeof n?n(t):n*t.depth;if(!r)try{if(t.id===t.parent.children[0].id)return t.x+=o,void(t.y=e?e.y:0)}catch(t){}if(t.x+=o,e){if(t.y=e.y+yf.getHeight(e,t,i),e.parent&&t.parent.id!==e.parent.id){var a=e.parent,s=a.y+yf.getHeight(a,t,i);t.y=s>t.y?s:t.y}}else t.y=0}(t,i,e,n,r),i=t}))},wf=Yd,Mf=Rd,Nf=["LR","RL","H"],Sf=Nf[0],Tf=function(t){var e,n;function r(){return t.apply(this,arguments)||this}return n=t,(e=r).prototype=Object.create(n.prototype),e.prototype.constructor=e,Ef(e,n),r.prototype.execute=function(){var t=this.options,e=this.rootNode;t.isHorizontal=!0;var n=t.indent,r=void 0===n?20:n,i=t.dropCap,o=void 0===i||i,a=t.direction,s=void 0===a?Sf:a,u=t.align;if(s&&-1===Nf.indexOf(s))throw new TypeError("Invalid direction: "+s);if(s===Nf[0])bf(e,r,o,u);else if(s===Nf[1])bf(e,r,o,u),e.right2left();else if(s===Nf[2]){var c=wf(e,t),h=c.left,l=c.right;bf(h,r,o,u),h.right2left(),bf(l,r,o,u);var d=h.getBoundingBox();l.translate(d.width,0),e.x=l.x-e.width/2}return e},r}(xf),Pf={};var Cf=function(t,e){return e=Mf.assign({},Pf,e),new Tf(t,e).execute()},kf=Rd;function Af(t,e){var n=0;return t.children.length?t.children.forEach((function(t){n+=Af(t,e)})):n=t.height,t._subTreeSep=e.getSubTreeSep(t.data),t.totalHeight=Math.max(t.height,n)+2*t._subTreeSep,t.totalHeight}function Of(t){var e=t.children,n=e.length;if(n){e.forEach((function(t){Of(t)}));var r=e[0],i=e[n-1],o=i.y-r.y+i.height,a=0;if(e.forEach((function(t){a+=t.totalHeight})),o>t.height)t.y=r.y+o/2-t.height/2;else if(1!==e.length||t.height>a){var s=t.y+(t.height-o)/2-r.y;e.forEach((function(t){t.translate(0,s)}))}else t.y=(r.y+r.height/2+i.y+i.height/2)/2-t.height/2}}var Rf={getSubTreeSep:function(){return 0}};function Df(t,e){return Df=Object.setPrototypeOf?Object.setPrototypeOf.bind():function(t,e){return t.__proto__=e,t},Df(t,e)}var If=function(t,e){void 0===e&&(e={}),e=kf.assign({},Rf,e),t.parent={x:0,width:0,height:0,y:0},t.BFTraverse((function(t){t.x=t.parent.x+t.parent.width})),t.parent=null,Af(t,e),t.startY=0,t.y=t.totalHeight/2-t.height/2,t.eachNode((function(t){var e=t.children,n=e.length;if(n){var r=e[0];if(r.startY=t.startY+t._subTreeSep,1===n)r.y=t.y+t.height/2-r.height/2;else{r.y=r.startY+r.totalHeight/2-r.height/2;for(var i=1;i<n;i++){var o=e[i];o.startY=e[i-1].startY+e[i-1].totalHeight,o.y=o.startY+o.totalHeight/2-o.height/2}}}})),Of(t)},Lf=Qd,_f=Rd,zf=function(t){var e,n;function r(){return t.apply(this,arguments)||this}return n=t,(e=r).prototype=Object.create(n.prototype),e.prototype.constructor=e,Df(e,n),r.prototype.execute=function(){return Lf(this.rootNode,this.options,If)},r}(Bd),Ff={};var Bf=function(t,e){return e=_f.assign({},Ff,e),new zf(t,e).execute()},Gf={compactBox:af,dendrogram:vf,indented:Cf,mindmap:Bf},jf=Array.isArray,Vf=function(t){for(var e=[],n=t.length,r=0;r<n;r+=1){e[r]=[];for(var i=0;i<n;i+=1)r===i?e[r][i]=0:0!==t[r][i]&&t[r][i]?e[r][i]=t[r][i]:e[r][i]=1/0}for(var o=0;o<n;o+=1)for(r=0;r<n;r+=1)for(i=0;i<n;i+=1)e[r][i]>e[r][o]+e[o][i]&&(e[r][i]=e[r][o]+e[o][i]);return e},Uf=function(t,e){var n=t.nodes,r=t.edges,i=[],o={};if(!n)throw new Error("invalid nodes data!");return n&&n.forEach((function(t,e){o[t.id]=e;i.push([])})),null==r||r.forEach((function(t){var n=t.source,r=t.target,a=o[n],s=o[r];void 0!==a&&void 0!==s&&(i[a][s]=1,e||(i[s][a]=1))})),i},Wf=function(t,e){return Math.sqrt((t.x-e.x)*(t.x-e.x)+(t.y-e.y)*(t.y-e.y))},Hf=function(t,e,n,r,i,o){if(void 0===r&&(r="TB"),void 0===o&&(o={}),null==e?void 0:e.length)for(var a=o.stopBranchFn,s=o.stopAllFn,u=0;u<e.length;u++){var c=e[u];if(t.hasNode(c.id)&&!(null==a?void 0:a(c))){if(null==s?void 0:s(c))return;"TB"===r&&n(c),Hf(t,t.getChildren(c.id,i),n,r,i,o),"TB"!==r&&n(c)}}},qf=function(t){if(null===t)return t;if(t instanceof Date)return new Date(t.getTime());if(t instanceof Array){var e=[];return t.forEach((function(t){e.push(t)})),e.map((function(t){return qf(t)}))}if("object"==typeof t){var n={};return Object.keys(t).forEach((function(e){n[e]=qf(t[e])})),n}return t},Yf=function(t,e){var n=qf(t);return n.data=n.data||{},e&&(jt(n.data.x)||(n.data.x=Math.random()*e[0]),jt(n.data.y)||(n.data.y=Math.random()*e[1])),n};function Xf(t,e){return Tt(e)?e:jt(e)?function(){return e}:function(){return t}}function Kf(t,e,n){return void 0===n&&(n=!0),e||0===e?Tt(e)?e:jt(e)?function(){return e}:Array.isArray(e)?function(){if(n){var r=Math.max.apply(Math,h([],c(e)));return isNaN(r)?t:r}return e}:Ot(e)?function(){if(n){var r=Math.max(e.width,e.height);return isNaN(r)?t:r}return[e.width,e.height]}:function(){return t}:function(e){var n=(e.data||{}).size;return n?Array.isArray(n)?n[0]>n[1]?n[0]:n[1]:Ot(n)?n.width>n.height?n.width:n.height:n:t}}var $f=function(t,e){var n,r;return r=jt(e)?function(){return e}:Tt(e)?e:function(){return 0},n=t?Array.isArray(t)?function(e){return(t[0]>t[1]?t[0]:t[1])+r(e)}:Tt(t)?t:function(e){return t+r(e)}:function(t){var e,n;if(null===(e=t.data)||void 0===e?void 0:e.bboxSize)return Math.max(t.data.bboxSize[0],t.data.bboxSize[1])+r(t);if(null===(n=t.data)||void 0===n?void 0:n.size){if(Array.isArray(t.data.size))return Math.max(t.data.size[0],t.data.size[1])+r(t);var i=t.data.size;return Ot(i)?(i.width>i.height?i.width:i.height)+r(t):i+r(t)}return 10+r(t)},n},Zf=function(t,e,n){var r=t.getAllNodes(),o=t.getAllEdges();return(null==r?void 0:r.length)?1===r.length?(e&&t.mergeNodeData(r[0].id,{x:n[0],y:n[1]}),{nodes:[i(i({},r[0]),{data:i(i({},r[0].data),{x:n[0],y:n[1]})})],edges:o}):void 0:{nodes:[],edges:o}},Qf={radius:null,startRadius:null,endRadius:null,startAngle:0,endAngle:2*Math.PI,clockwise:!0,divisions:1,ordering:null,angleRatio:1},Jf=function(){function t(t){void 0===t&&(t={}),this.options=t,this.id="circular",this.options=i(i({},Qf),t)}return t.prototype.execute=function(t,e){return a(this,void 0,void 0,(function(){return s(this,(function(n){return[2,this.genericCircularLayout(!1,t,e)]}))}))},t.prototype.assign=function(t,e){return a(this,void 0,void 0,(function(){return s(this,(function(n){switch(n.label){case 0:return[4,this.genericCircularLayout(!0,t,e)];case 1:return n.sent(),[2]}}))}))},t.prototype.genericCircularLayout=function(t,e,n){return a(this,void 0,void 0,(function(){var r,o,a,u,h,l,d,f,p,g,m,v,y,E,x,b,w,M,N,S,T,P,C,k,A,O,R,D,I,L,_,z,F,B,G;return s(this,(function(s){if(r=i(i({},this.options),n),o=r.width,a=r.height,u=r.center,h=r.divisions,l=r.startAngle,d=void 0===l?0:l,f=r.endAngle,p=void 0===f?2*Math.PI:f,g=r.angleRatio,m=r.ordering,v=r.clockwise,y=r.nodeSpacing,E=r.nodeSize,x=e.getAllNodes(),b=e.getAllEdges(),w=c(ep(o,a,u),3),M=w[0],N=w[1],S=w[2],!(T=null==x?void 0:x.length)||1===T)return[2,Zf(e,t,S)];for(P=(p-d)/T,C=r.radius,k=r.startRadius,A=r.endRadius,y?(O=Xf(10,y),R=Kf(10,E),D=-1/0,x.forEach((function(t){var e=R(t);D<e&&(D=e)})),I=0,x.forEach((function(t,e){I+=0===e?D||10:(O(t)||0)+(D||10)})),C=I/(2*Math.PI)):C||k||A?!k&&A?k=A:k&&!A&&(A=k):C=Math.min(N,M)/2,L=P*g,_=[],_="topology"===m?tp(e,x):"topology-directed"===m?tp(e,x,!0):"degree"===m?function(t,e){var n=[];return e.forEach((function(t,e){n.push(Yf(t))})),n.sort((function(e,n){return t.getDegree(e.id,"both")-t.getDegree(n.id,"both")})),n}(e,x):x.map((function(t){return Yf(t)})),z=Math.ceil(T/h),F=0;F<T;++F)(B=C)||null===k||null===A||(B=k+F*(A-k)/(T-1)),B||(B=10+100*F/(T-1)),G=d+F%z*L+2*Math.PI/h*Math.floor(F/z),v||(G=p-F%z*L-2*Math.PI/h*Math.floor(F/z)),_[F].data.x=S[0]+Math.cos(G)*B,_[F].data.y=S[1]+Math.sin(G)*B;return t&&_.forEach((function(t){e.mergeNodeData(t.id,{x:t.data.x,y:t.data.y})})),[2,{nodes:_,edges:b}]}))}))},t}(),tp=function(t,e,n){void 0===n&&(n=!1);var r=[Yf(e[0])],i={},o=e.length;i[e[0].id]=!0;var a=0;return e.forEach((function(s,u){if(0!==u)if(u!==o-1&&t.getDegree(s.id,"both")===t.getDegree(e[u+1].id,"both")&&!t.areNeighbors(r[a].id,s.id)||i[s.id]){for(var c=n?t.getSuccessors(r[a].id):t.getNeighbors(r[a].id),h=!1,l=0;l<c.length;l++){var d=c[l];if(t.getDegree(d.id)===t.getDegree(s.id)&&!i[d.id]){r.push(Yf(d)),i[d.id]=!0,h=!0;break}}for(var f=0;!h&&(i[e[f].id]||(r.push(Yf(e[f])),i[e[f].id]=!0,h=!0),++f!==o););}else r.push(Yf(s)),i[s.id]=!0,a++})),r};var ep=function(t,e,n){var r=t,i=e,o=n;return r||"undefined"==typeof window||(r=window.innerWidth),i||"undefined"==typeof window||(i=window.innerHeight),o||(o=[r/2,i/2]),[r,i,o]},np=function(){function t(){this._events={}}return t.prototype.on=function(t,e,n){return this._events[t]||(this._events[t]=[]),this._events[t].push({callback:e,once:!!n}),this},t.prototype.once=function(t,e){return this.on(t,e,!0)},t.prototype.emit=function(t){for(var e=this,n=[],r=1;r<arguments.length;r++)n[r-1]=arguments[r];var i=this._events[t]||[],o=this._events["*"]||[],a=function(r){for(var i=r.length,o=0;o<i;o++)if(r[o]){var a=r[o],s=a.callback;a.once&&(r.splice(o,1),0===r.length&&delete e._events[t],i--,o--),s.apply(e,n)}};a(i),a(o)},t.prototype.off=function(t,e){if(t)if(e){for(var n=this._events[t]||[],r=n.length,i=0;i<r;i++)n[i].callback===e&&(n.splice(i,1),r--,i--);0===n.length&&delete this._events[t]}else delete this._events[t];else this._events={};return this},t.prototype.getEvents=function(){return this._events},t}();
1
+ !function(t,e){"object"==typeof exports&&"undefined"!=typeof module?e(exports):"function"==typeof define&&define.amd?define(["exports"],e):e((t="undefined"!=typeof globalThis?globalThis:t||self).G6V5={})}(this,(function(t){"use strict";var e="undefined"!=typeof document?document.currentScript:null,n=function(t,e){return n=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(t,e){t.__proto__=e}||function(t,e){for(var n in e)Object.prototype.hasOwnProperty.call(e,n)&&(t[n]=e[n])},n(t,e)};function r(t,e){if("function"!=typeof e&&null!==e)throw new TypeError("Class extends value "+String(e)+" is not a constructor or null");function r(){this.constructor=t}n(t,e),t.prototype=null===e?Object.create(e):(r.prototype=e.prototype,new r)}var i=function(){return i=Object.assign||function(t){for(var e,n=1,r=arguments.length;n<r;n++)for(var i in e=arguments[n])Object.prototype.hasOwnProperty.call(e,i)&&(t[i]=e[i]);return t},i.apply(this,arguments)};function o(t,e){var n={};for(var r in t)Object.prototype.hasOwnProperty.call(t,r)&&e.indexOf(r)<0&&(n[r]=t[r]);if(null!=t&&"function"==typeof Object.getOwnPropertySymbols){var i=0;for(r=Object.getOwnPropertySymbols(t);i<r.length;i++)e.indexOf(r[i])<0&&Object.prototype.propertyIsEnumerable.call(t,r[i])&&(n[r[i]]=t[r[i]])}return n}function a(t,e,n,r){return new(n||(n=Promise))((function(i,o){function a(t){try{u(r.next(t))}catch(t){o(t)}}function s(t){try{u(r.throw(t))}catch(t){o(t)}}function u(t){var e;t.done?i(t.value):(e=t.value,e instanceof n?e:new n((function(t){t(e)}))).then(a,s)}u((r=r.apply(t,e||[])).next())}))}function s(t,e){var n,r,i,o,a={label:0,sent:function(){if(1&i[0])throw i[1];return i[1]},trys:[],ops:[]};return o={next:s(0),throw:s(1),return:s(2)},"function"==typeof Symbol&&(o[Symbol.iterator]=function(){return this}),o;function s(s){return function(u){return function(s){if(n)throw new TypeError("Generator is already executing.");for(;o&&(o=0,s[0]&&(a=0)),a;)try{if(n=1,r&&(i=2&s[0]?r.return:s[0]?r.throw||((i=r.return)&&i.call(r),0):r.next)&&!(i=i.call(r,s[1])).done)return i;switch(r=0,i&&(s=[2&s[0],i.value]),s[0]){case 0:case 1:i=s;break;case 4:return a.label++,{value:s[1],done:!1};case 5:a.label++,r=s[1],s=[0];continue;case 7:s=a.ops.pop(),a.trys.pop();continue;default:if(!(i=a.trys,(i=i.length>0&&i[i.length-1])||6!==s[0]&&2!==s[0])){a=0;continue}if(3===s[0]&&(!i||s[1]>i[0]&&s[1]<i[3])){a.label=s[1];break}if(6===s[0]&&a.label<i[1]){a.label=i[1],i=s;break}if(i&&a.label<i[2]){a.label=i[2],a.ops.push(s);break}i[2]&&a.ops.pop(),a.trys.pop();continue}s=e.call(t,a)}catch(t){s=[6,t],r=0}finally{n=i=0}if(5&s[0])throw s[1];return{value:s[0]?s[1]:void 0,done:!0}}([s,u])}}}function u(t){var e="function"==typeof Symbol&&Symbol.iterator,n=e&&t[e],r=0;if(n)return n.call(t);if(t&&"number"==typeof t.length)return{next:function(){return t&&r>=t.length&&(t=void 0),{value:t&&t[r++],done:!t}}};throw new TypeError(e?"Object is not iterable.":"Symbol.iterator is not defined.")}function c(t,e){var n="function"==typeof Symbol&&t[Symbol.iterator];if(!n)return t;var r,i,o=n.call(t),a=[];try{for(;(void 0===e||e-- >0)&&!(r=o.next()).done;)a.push(r.value)}catch(t){i={error:t}}finally{try{r&&!r.done&&(n=o.return)&&n.call(o)}finally{if(i)throw i.error}}return a}function h(t,e,n){if(n||2===arguments.length)for(var r,i=0,o=e.length;i<o;i++)!r&&i in e||(r||(r=Array.prototype.slice.call(e,0,i)),r[i]=e[i]);return t.concat(r||Array.prototype.slice.call(e))}"function"==typeof SuppressedError&&SuppressedError;var l="undefined"!=typeof globalThis?globalThis:"undefined"!=typeof window?window:"undefined"!=typeof global?global:"undefined"!=typeof self?self:{};function d(t){return t&&t.__esModule&&Object.prototype.hasOwnProperty.call(t,"default")?t.default:t}function f(t){if(t.__esModule)return t;var e=t.default;if("function"==typeof e){var n=function t(){return this instanceof t?Reflect.construct(e,arguments,this.constructor):e.apply(this,arguments)};n.prototype=e.prototype}else n={};return Object.defineProperty(n,"__esModule",{value:!0}),Object.keys(t).forEach((function(e){var r=Object.getOwnPropertyDescriptor(t,e);Object.defineProperty(n,e,r.get?r:{enumerable:!0,get:function(){return t[e]}})})),n}var p={exports:{}};!function(t){var e=Object.prototype.hasOwnProperty,n="~";function r(){}function i(t,e,n){this.fn=t,this.context=e,this.once=n||!1}function o(t,e,r,o,a){if("function"!=typeof r)throw new TypeError("The listener must be a function");var s=new i(r,o||t,a),u=n?n+e:e;return t._events[u]?t._events[u].fn?t._events[u]=[t._events[u],s]:t._events[u].push(s):(t._events[u]=s,t._eventsCount++),t}function a(t,e){0==--t._eventsCount?t._events=new r:delete t._events[e]}function s(){this._events=new r,this._eventsCount=0}Object.create&&(r.prototype=Object.create(null),(new r).__proto__||(n=!1)),s.prototype.eventNames=function(){var t,r,i=[];if(0===this._eventsCount)return i;for(r in t=this._events)e.call(t,r)&&i.push(n?r.slice(1):r);return Object.getOwnPropertySymbols?i.concat(Object.getOwnPropertySymbols(t)):i},s.prototype.listeners=function(t){var e=n?n+t:t,r=this._events[e];if(!r)return[];if(r.fn)return[r.fn];for(var i=0,o=r.length,a=new Array(o);i<o;i++)a[i]=r[i].fn;return a},s.prototype.listenerCount=function(t){var e=n?n+t:t,r=this._events[e];return r?r.fn?1:r.length:0},s.prototype.emit=function(t,e,r,i,o,a){var s=n?n+t:t;if(!this._events[s])return!1;var u,c,h=this._events[s],l=arguments.length;if(h.fn){switch(h.once&&this.removeListener(t,h.fn,void 0,!0),l){case 1:return h.fn.call(h.context),!0;case 2:return h.fn.call(h.context,e),!0;case 3:return h.fn.call(h.context,e,r),!0;case 4:return h.fn.call(h.context,e,r,i),!0;case 5:return h.fn.call(h.context,e,r,i,o),!0;case 6:return h.fn.call(h.context,e,r,i,o,a),!0}for(c=1,u=new Array(l-1);c<l;c++)u[c-1]=arguments[c];h.fn.apply(h.context,u)}else{var d,f=h.length;for(c=0;c<f;c++)switch(h[c].once&&this.removeListener(t,h[c].fn,void 0,!0),l){case 1:h[c].fn.call(h[c].context);break;case 2:h[c].fn.call(h[c].context,e);break;case 3:h[c].fn.call(h[c].context,e,r);break;case 4:h[c].fn.call(h[c].context,e,r,i);break;default:if(!u)for(d=1,u=new Array(l-1);d<l;d++)u[d-1]=arguments[d];h[c].fn.apply(h[c].context,u)}}return!0},s.prototype.on=function(t,e,n){return o(this,t,e,n,!1)},s.prototype.once=function(t,e,n){return o(this,t,e,n,!0)},s.prototype.removeListener=function(t,e,r,i){var o=n?n+t:t;if(!this._events[o])return this;if(!e)return a(this,o),this;var s=this._events[o];if(s.fn)s.fn!==e||i&&!s.once||r&&s.context!==r||a(this,o);else{for(var u=0,c=[],h=s.length;u<h;u++)(s[u].fn!==e||i&&!s[u].once||r&&s[u].context!==r)&&c.push(s[u]);c.length?this._events[o]=1===c.length?c[0]:c:a(this,o)}return this},s.prototype.removeAllListeners=function(t){var e;return t?(e=n?n+t:t,this._events[e]&&a(this,e)):(this._events=new r,this._eventsCount=0),this},s.prototype.off=s.prototype.removeListener,s.prototype.addListener=s.prototype.on,s.prefixed=n,s.EventEmitter=s,t.exports=s}(p);var g=d(p.exports),m=1e-6,v="undefined"!=typeof Float32Array?Float32Array:Array;function y(){var t=new v(9);return v!=Float32Array&&(t[1]=0,t[2]=0,t[3]=0,t[5]=0,t[6]=0,t[7]=0),t[0]=1,t[4]=1,t[8]=1,t}function b(){var t=new v(16);return v!=Float32Array&&(t[1]=0,t[2]=0,t[3]=0,t[4]=0,t[6]=0,t[7]=0,t[8]=0,t[9]=0,t[11]=0,t[12]=0,t[13]=0,t[14]=0),t[0]=1,t[5]=1,t[10]=1,t[15]=1,t}function E(t){var e=new v(16);return e[0]=t[0],e[1]=t[1],e[2]=t[2],e[3]=t[3],e[4]=t[4],e[5]=t[5],e[6]=t[6],e[7]=t[7],e[8]=t[8],e[9]=t[9],e[10]=t[10],e[11]=t[11],e[12]=t[12],e[13]=t[13],e[14]=t[14],e[15]=t[15],e}function w(t,e){return t[0]=e[0],t[1]=e[1],t[2]=e[2],t[3]=e[3],t[4]=e[4],t[5]=e[5],t[6]=e[6],t[7]=e[7],t[8]=e[8],t[9]=e[9],t[10]=e[10],t[11]=e[11],t[12]=e[12],t[13]=e[13],t[14]=e[14],t[15]=e[15],t}function x(t,e,n,r,i,o,a,s,u,c,h,l,d,f,p,g,m){return t[0]=e,t[1]=n,t[2]=r,t[3]=i,t[4]=o,t[5]=a,t[6]=s,t[7]=u,t[8]=c,t[9]=h,t[10]=l,t[11]=d,t[12]=f,t[13]=p,t[14]=g,t[15]=m,t}function M(t){return t[0]=1,t[1]=0,t[2]=0,t[3]=0,t[4]=0,t[5]=1,t[6]=0,t[7]=0,t[8]=0,t[9]=0,t[10]=1,t[11]=0,t[12]=0,t[13]=0,t[14]=0,t[15]=1,t}function N(t,e){if(t===e){var n=e[1],r=e[2],i=e[3],o=e[6],a=e[7],s=e[11];t[1]=e[4],t[2]=e[8],t[3]=e[12],t[4]=n,t[6]=e[9],t[7]=e[13],t[8]=r,t[9]=o,t[11]=e[14],t[12]=i,t[13]=a,t[14]=s}else t[0]=e[0],t[1]=e[4],t[2]=e[8],t[3]=e[12],t[4]=e[1],t[5]=e[5],t[6]=e[9],t[7]=e[13],t[8]=e[2],t[9]=e[6],t[10]=e[10],t[11]=e[14],t[12]=e[3],t[13]=e[7],t[14]=e[11],t[15]=e[15];return t}function S(t,e){var n=e[0],r=e[1],i=e[2],o=e[3],a=e[4],s=e[5],u=e[6],c=e[7],h=e[8],l=e[9],d=e[10],f=e[11],p=e[12],g=e[13],m=e[14],v=e[15],y=n*s-r*a,b=n*u-i*a,E=n*c-o*a,w=r*u-i*s,x=r*c-o*s,M=i*c-o*u,N=h*g-l*p,S=h*m-d*p,T=h*v-f*p,k=l*m-d*g,P=l*v-f*g,C=d*v-f*m,A=y*C-b*P+E*k+w*T-x*S+M*N;return A?(A=1/A,t[0]=(s*C-u*P+c*k)*A,t[1]=(i*P-r*C-o*k)*A,t[2]=(g*M-m*x+v*w)*A,t[3]=(d*x-l*M-f*w)*A,t[4]=(u*T-a*C-c*S)*A,t[5]=(n*C-i*T+o*S)*A,t[6]=(m*E-p*M-v*b)*A,t[7]=(h*M-d*E+f*b)*A,t[8]=(a*P-s*T+c*N)*A,t[9]=(r*T-n*P-o*N)*A,t[10]=(p*x-g*E+v*y)*A,t[11]=(l*E-h*x-f*y)*A,t[12]=(s*S-a*k-u*N)*A,t[13]=(n*k-r*S+i*N)*A,t[14]=(g*b-p*w-m*y)*A,t[15]=(h*w-l*b+d*y)*A,t):null}function T(t){var e=t[0],n=t[1],r=t[2],i=t[3],o=t[4],a=t[5],s=t[6],u=t[7],c=t[8],h=t[9],l=t[10],d=t[11],f=t[12],p=t[13],g=t[14],m=t[15];return(e*a-n*o)*(l*m-d*g)-(e*s-r*o)*(h*m-d*p)+(e*u-i*o)*(h*g-l*p)+(n*s-r*a)*(c*m-d*f)-(n*u-i*a)*(c*g-l*f)+(r*u-i*s)*(c*p-h*f)}function k(t,e,n){var r=e[0],i=e[1],o=e[2],a=e[3],s=e[4],u=e[5],c=e[6],h=e[7],l=e[8],d=e[9],f=e[10],p=e[11],g=e[12],m=e[13],v=e[14],y=e[15],b=n[0],E=n[1],w=n[2],x=n[3];return t[0]=b*r+E*s+w*l+x*g,t[1]=b*i+E*u+w*d+x*m,t[2]=b*o+E*c+w*f+x*v,t[3]=b*a+E*h+w*p+x*y,b=n[4],E=n[5],w=n[6],x=n[7],t[4]=b*r+E*s+w*l+x*g,t[5]=b*i+E*u+w*d+x*m,t[6]=b*o+E*c+w*f+x*v,t[7]=b*a+E*h+w*p+x*y,b=n[8],E=n[9],w=n[10],x=n[11],t[8]=b*r+E*s+w*l+x*g,t[9]=b*i+E*u+w*d+x*m,t[10]=b*o+E*c+w*f+x*v,t[11]=b*a+E*h+w*p+x*y,b=n[12],E=n[13],w=n[14],x=n[15],t[12]=b*r+E*s+w*l+x*g,t[13]=b*i+E*u+w*d+x*m,t[14]=b*o+E*c+w*f+x*v,t[15]=b*a+E*h+w*p+x*y,t}function P(t,e,n){var r,i,o,a,s,u,c,h,l,d,f,p,g=n[0],m=n[1],v=n[2];return e===t?(t[12]=e[0]*g+e[4]*m+e[8]*v+e[12],t[13]=e[1]*g+e[5]*m+e[9]*v+e[13],t[14]=e[2]*g+e[6]*m+e[10]*v+e[14],t[15]=e[3]*g+e[7]*m+e[11]*v+e[15]):(r=e[0],i=e[1],o=e[2],a=e[3],s=e[4],u=e[5],c=e[6],h=e[7],l=e[8],d=e[9],f=e[10],p=e[11],t[0]=r,t[1]=i,t[2]=o,t[3]=a,t[4]=s,t[5]=u,t[6]=c,t[7]=h,t[8]=l,t[9]=d,t[10]=f,t[11]=p,t[12]=r*g+s*m+l*v+e[12],t[13]=i*g+u*m+d*v+e[13],t[14]=o*g+c*m+f*v+e[14],t[15]=a*g+h*m+p*v+e[15]),t}function C(t,e,n){var r=n[0],i=n[1],o=n[2];return t[0]=e[0]*r,t[1]=e[1]*r,t[2]=e[2]*r,t[3]=e[3]*r,t[4]=e[4]*i,t[5]=e[5]*i,t[6]=e[6]*i,t[7]=e[7]*i,t[8]=e[8]*o,t[9]=e[9]*o,t[10]=e[10]*o,t[11]=e[11]*o,t[12]=e[12],t[13]=e[13],t[14]=e[14],t[15]=e[15],t}function A(t,e,n){var r=Math.sin(n),i=Math.cos(n),o=e[4],a=e[5],s=e[6],u=e[7],c=e[8],h=e[9],l=e[10],d=e[11];return e!==t&&(t[0]=e[0],t[1]=e[1],t[2]=e[2],t[3]=e[3],t[12]=e[12],t[13]=e[13],t[14]=e[14],t[15]=e[15]),t[4]=o*i+c*r,t[5]=a*i+h*r,t[6]=s*i+l*r,t[7]=u*i+d*r,t[8]=c*i-o*r,t[9]=h*i-a*r,t[10]=l*i-s*r,t[11]=d*i-u*r,t}function O(t,e,n){var r=Math.sin(n),i=Math.cos(n),o=e[0],a=e[1],s=e[2],u=e[3],c=e[8],h=e[9],l=e[10],d=e[11];return e!==t&&(t[4]=e[4],t[5]=e[5],t[6]=e[6],t[7]=e[7],t[12]=e[12],t[13]=e[13],t[14]=e[14],t[15]=e[15]),t[0]=o*i-c*r,t[1]=a*i-h*r,t[2]=s*i-l*r,t[3]=u*i-d*r,t[8]=o*r+c*i,t[9]=a*r+h*i,t[10]=s*r+l*i,t[11]=u*r+d*i,t}function R(t,e){return t[0]=1,t[1]=0,t[2]=0,t[3]=0,t[4]=0,t[5]=1,t[6]=0,t[7]=0,t[8]=0,t[9]=0,t[10]=1,t[11]=0,t[12]=e[0],t[13]=e[1],t[14]=e[2],t[15]=1,t}function _(t,e){return t[0]=e[0],t[1]=0,t[2]=0,t[3]=0,t[4]=0,t[5]=e[1],t[6]=0,t[7]=0,t[8]=0,t[9]=0,t[10]=e[2],t[11]=0,t[12]=0,t[13]=0,t[14]=0,t[15]=1,t}function D(t,e,n){var r=e[0],i=e[1],o=e[2],a=e[3],s=r+r,u=i+i,c=o+o,h=r*s,l=r*u,d=r*c,f=i*u,p=i*c,g=o*c,m=a*s,v=a*u,y=a*c;return t[0]=1-(f+g),t[1]=l+y,t[2]=d-v,t[3]=0,t[4]=l-y,t[5]=1-(h+g),t[6]=p+m,t[7]=0,t[8]=d+v,t[9]=p-m,t[10]=1-(h+f),t[11]=0,t[12]=n[0],t[13]=n[1],t[14]=n[2],t[15]=1,t}function I(t,e){return t[0]=e[12],t[1]=e[13],t[2]=e[14],t}function L(t,e){var n=e[0],r=e[1],i=e[2],o=e[4],a=e[5],s=e[6],u=e[8],c=e[9],h=e[10];return t[0]=Math.hypot(n,r,i),t[1]=Math.hypot(o,a,s),t[2]=Math.hypot(u,c,h),t}function j(t,e){var n=new v(3);L(n,e);var r=1/n[0],i=1/n[1],o=1/n[2],a=e[0]*r,s=e[1]*i,u=e[2]*o,c=e[4]*r,h=e[5]*i,l=e[6]*o,d=e[8]*r,f=e[9]*i,p=e[10]*o,g=a+h+p,m=0;return g>0?(m=2*Math.sqrt(g+1),t[3]=.25*m,t[0]=(l-f)/m,t[1]=(d-u)/m,t[2]=(s-c)/m):a>h&&a>p?(m=2*Math.sqrt(1+a-h-p),t[3]=(l-f)/m,t[0]=.25*m,t[1]=(s+c)/m,t[2]=(d+u)/m):h>p?(m=2*Math.sqrt(1+h-a-p),t[3]=(d-u)/m,t[0]=(s+c)/m,t[1]=.25*m,t[2]=(l+f)/m):(m=2*Math.sqrt(1+p-a-h),t[3]=(s-c)/m,t[0]=(d+u)/m,t[1]=(l+f)/m,t[2]=.25*m),t}function z(t,e,n,r,i){var o=e[0],a=e[1],s=e[2],u=e[3],c=o+o,h=a+a,l=s+s,d=o*c,f=o*h,p=o*l,g=a*h,m=a*l,v=s*l,y=u*c,b=u*h,E=u*l,w=r[0],x=r[1],M=r[2],N=i[0],S=i[1],T=i[2],k=(1-(g+v))*w,P=(f+E)*w,C=(p-b)*w,A=(f-E)*x,O=(1-(d+v))*x,R=(m+y)*x,_=(p+b)*M,D=(m-y)*M,I=(1-(d+g))*M;return t[0]=k,t[1]=P,t[2]=C,t[3]=0,t[4]=A,t[5]=O,t[6]=R,t[7]=0,t[8]=_,t[9]=D,t[10]=I,t[11]=0,t[12]=n[0]+N-(k*N+A*S+_*T),t[13]=n[1]+S-(P*N+O*S+D*T),t[14]=n[2]+T-(C*N+R*S+I*T),t[15]=1,t}function F(t,e){var n=e[0],r=e[1],i=e[2],o=e[3],a=n+n,s=r+r,u=i+i,c=n*a,h=r*a,l=r*s,d=i*a,f=i*s,p=i*u,g=o*a,m=o*s,v=o*u;return t[0]=1-l-p,t[1]=h+v,t[2]=d-m,t[3]=0,t[4]=h-v,t[5]=1-c-p,t[6]=f+g,t[7]=0,t[8]=d+m,t[9]=f-g,t[10]=1-c-l,t[11]=0,t[12]=0,t[13]=0,t[14]=0,t[15]=1,t}function B(t,e,n,r,i){var o,a=1/Math.tan(e/2);return t[0]=a/n,t[1]=0,t[2]=0,t[3]=0,t[4]=0,t[5]=a,t[6]=0,t[7]=0,t[8]=0,t[9]=0,t[11]=-1,t[12]=0,t[13]=0,t[15]=0,null!=i&&i!==1/0?(o=1/(r-i),t[10]=(i+r)*o,t[14]=2*i*r*o):(t[10]=-1,t[14]=-2*r),t}Math.hypot||(Math.hypot=function(){for(var t=0,e=arguments.length;e--;)t+=arguments[e]*arguments[e];return Math.sqrt(t)});var G=B;function V(t,e,n,r,i,o,a){var s=1/(e-n),u=1/(r-i),c=1/(o-a);return t[0]=-2*s,t[1]=0,t[2]=0,t[3]=0,t[4]=0,t[5]=-2*u,t[6]=0,t[7]=0,t[8]=0,t[9]=0,t[10]=2*c,t[11]=0,t[12]=(e+n)*s,t[13]=(i+r)*u,t[14]=(a+o)*c,t[15]=1,t}var U=V;function W(t,e,n,r,i,o,a){var s=1/(e-n),u=1/(r-i),c=1/(o-a);return t[0]=-2*s,t[1]=0,t[2]=0,t[3]=0,t[4]=0,t[5]=-2*u,t[6]=0,t[7]=0,t[8]=0,t[9]=0,t[10]=c,t[11]=0,t[12]=(e+n)*s,t[13]=(i+r)*u,t[14]=o*c,t[15]=1,t}function H(t,e,n,r){var i,o,a,s,u,c,h,l,d,f,p=e[0],g=e[1],v=e[2],y=r[0],b=r[1],E=r[2],w=n[0],x=n[1],N=n[2];return Math.abs(p-w)<m&&Math.abs(g-x)<m&&Math.abs(v-N)<m?M(t):(h=p-w,l=g-x,d=v-N,i=b*(d*=f=1/Math.hypot(h,l,d))-E*(l*=f),o=E*(h*=f)-y*d,a=y*l-b*h,(f=Math.hypot(i,o,a))?(i*=f=1/f,o*=f,a*=f):(i=0,o=0,a=0),s=l*a-d*o,u=d*i-h*a,c=h*o-l*i,(f=Math.hypot(s,u,c))?(s*=f=1/f,u*=f,c*=f):(s=0,u=0,c=0),t[0]=i,t[1]=s,t[2]=h,t[3]=0,t[4]=o,t[5]=u,t[6]=l,t[7]=0,t[8]=a,t[9]=c,t[10]=d,t[11]=0,t[12]=-(i*p+o*g+a*v),t[13]=-(s*p+u*g+c*v),t[14]=-(h*p+l*g+d*v),t[15]=1,t)}function q(t,e,n){return t[0]=e[0]-n[0],t[1]=e[1]-n[1],t[2]=e[2]-n[2],t[3]=e[3]-n[3],t[4]=e[4]-n[4],t[5]=e[5]-n[5],t[6]=e[6]-n[6],t[7]=e[7]-n[7],t[8]=e[8]-n[8],t[9]=e[9]-n[9],t[10]=e[10]-n[10],t[11]=e[11]-n[11],t[12]=e[12]-n[12],t[13]=e[13]-n[13],t[14]=e[14]-n[14],t[15]=e[15]-n[15],t}var Y=k,$=q,X=Object.freeze({__proto__:null,add:function(t,e,n){return t[0]=e[0]+n[0],t[1]=e[1]+n[1],t[2]=e[2]+n[2],t[3]=e[3]+n[3],t[4]=e[4]+n[4],t[5]=e[5]+n[5],t[6]=e[6]+n[6],t[7]=e[7]+n[7],t[8]=e[8]+n[8],t[9]=e[9]+n[9],t[10]=e[10]+n[10],t[11]=e[11]+n[11],t[12]=e[12]+n[12],t[13]=e[13]+n[13],t[14]=e[14]+n[14],t[15]=e[15]+n[15],t},adjoint:function(t,e){var n=e[0],r=e[1],i=e[2],o=e[3],a=e[4],s=e[5],u=e[6],c=e[7],h=e[8],l=e[9],d=e[10],f=e[11],p=e[12],g=e[13],m=e[14],v=e[15];return t[0]=s*(d*v-f*m)-l*(u*v-c*m)+g*(u*f-c*d),t[1]=-(r*(d*v-f*m)-l*(i*v-o*m)+g*(i*f-o*d)),t[2]=r*(u*v-c*m)-s*(i*v-o*m)+g*(i*c-o*u),t[3]=-(r*(u*f-c*d)-s*(i*f-o*d)+l*(i*c-o*u)),t[4]=-(a*(d*v-f*m)-h*(u*v-c*m)+p*(u*f-c*d)),t[5]=n*(d*v-f*m)-h*(i*v-o*m)+p*(i*f-o*d),t[6]=-(n*(u*v-c*m)-a*(i*v-o*m)+p*(i*c-o*u)),t[7]=n*(u*f-c*d)-a*(i*f-o*d)+h*(i*c-o*u),t[8]=a*(l*v-f*g)-h*(s*v-c*g)+p*(s*f-c*l),t[9]=-(n*(l*v-f*g)-h*(r*v-o*g)+p*(r*f-o*l)),t[10]=n*(s*v-c*g)-a*(r*v-o*g)+p*(r*c-o*s),t[11]=-(n*(s*f-c*l)-a*(r*f-o*l)+h*(r*c-o*s)),t[12]=-(a*(l*m-d*g)-h*(s*m-u*g)+p*(s*d-u*l)),t[13]=n*(l*m-d*g)-h*(r*m-i*g)+p*(r*d-i*l),t[14]=-(n*(s*m-u*g)-a*(r*m-i*g)+p*(r*u-i*s)),t[15]=n*(s*d-u*l)-a*(r*d-i*l)+h*(r*u-i*s),t},clone:E,copy:w,create:b,determinant:T,equals:function(t,e){var n=t[0],r=t[1],i=t[2],o=t[3],a=t[4],s=t[5],u=t[6],c=t[7],h=t[8],l=t[9],d=t[10],f=t[11],p=t[12],g=t[13],v=t[14],y=t[15],b=e[0],E=e[1],w=e[2],x=e[3],M=e[4],N=e[5],S=e[6],T=e[7],k=e[8],P=e[9],C=e[10],A=e[11],O=e[12],R=e[13],_=e[14],D=e[15];return Math.abs(n-b)<=m*Math.max(1,Math.abs(n),Math.abs(b))&&Math.abs(r-E)<=m*Math.max(1,Math.abs(r),Math.abs(E))&&Math.abs(i-w)<=m*Math.max(1,Math.abs(i),Math.abs(w))&&Math.abs(o-x)<=m*Math.max(1,Math.abs(o),Math.abs(x))&&Math.abs(a-M)<=m*Math.max(1,Math.abs(a),Math.abs(M))&&Math.abs(s-N)<=m*Math.max(1,Math.abs(s),Math.abs(N))&&Math.abs(u-S)<=m*Math.max(1,Math.abs(u),Math.abs(S))&&Math.abs(c-T)<=m*Math.max(1,Math.abs(c),Math.abs(T))&&Math.abs(h-k)<=m*Math.max(1,Math.abs(h),Math.abs(k))&&Math.abs(l-P)<=m*Math.max(1,Math.abs(l),Math.abs(P))&&Math.abs(d-C)<=m*Math.max(1,Math.abs(d),Math.abs(C))&&Math.abs(f-A)<=m*Math.max(1,Math.abs(f),Math.abs(A))&&Math.abs(p-O)<=m*Math.max(1,Math.abs(p),Math.abs(O))&&Math.abs(g-R)<=m*Math.max(1,Math.abs(g),Math.abs(R))&&Math.abs(v-_)<=m*Math.max(1,Math.abs(v),Math.abs(_))&&Math.abs(y-D)<=m*Math.max(1,Math.abs(y),Math.abs(D))},exactEquals:function(t,e){return t[0]===e[0]&&t[1]===e[1]&&t[2]===e[2]&&t[3]===e[3]&&t[4]===e[4]&&t[5]===e[5]&&t[6]===e[6]&&t[7]===e[7]&&t[8]===e[8]&&t[9]===e[9]&&t[10]===e[10]&&t[11]===e[11]&&t[12]===e[12]&&t[13]===e[13]&&t[14]===e[14]&&t[15]===e[15]},frob:function(t){return Math.hypot(t[0],t[1],t[2],t[3],t[4],t[5],t[6],t[7],t[8],t[9],t[10],t[11],t[12],t[13],t[14],t[15])},fromQuat:F,fromQuat2:function(t,e){var n=new v(3),r=-e[0],i=-e[1],o=-e[2],a=e[3],s=e[4],u=e[5],c=e[6],h=e[7],l=r*r+i*i+o*o+a*a;return l>0?(n[0]=2*(s*a+h*r+u*o-c*i)/l,n[1]=2*(u*a+h*i+c*r-s*o)/l,n[2]=2*(c*a+h*o+s*i-u*r)/l):(n[0]=2*(s*a+h*r+u*o-c*i),n[1]=2*(u*a+h*i+c*r-s*o),n[2]=2*(c*a+h*o+s*i-u*r)),D(t,e,n),t},fromRotation:function(t,e,n){var r,i,o,a=n[0],s=n[1],u=n[2],c=Math.hypot(a,s,u);return c<m?null:(a*=c=1/c,s*=c,u*=c,r=Math.sin(e),o=1-(i=Math.cos(e)),t[0]=a*a*o+i,t[1]=s*a*o+u*r,t[2]=u*a*o-s*r,t[3]=0,t[4]=a*s*o-u*r,t[5]=s*s*o+i,t[6]=u*s*o+a*r,t[7]=0,t[8]=a*u*o+s*r,t[9]=s*u*o-a*r,t[10]=u*u*o+i,t[11]=0,t[12]=0,t[13]=0,t[14]=0,t[15]=1,t)},fromRotationTranslation:D,fromRotationTranslationScale:function(t,e,n,r){var i=e[0],o=e[1],a=e[2],s=e[3],u=i+i,c=o+o,h=a+a,l=i*u,d=i*c,f=i*h,p=o*c,g=o*h,m=a*h,v=s*u,y=s*c,b=s*h,E=r[0],w=r[1],x=r[2];return t[0]=(1-(p+m))*E,t[1]=(d+b)*E,t[2]=(f-y)*E,t[3]=0,t[4]=(d-b)*w,t[5]=(1-(l+m))*w,t[6]=(g+v)*w,t[7]=0,t[8]=(f+y)*x,t[9]=(g-v)*x,t[10]=(1-(l+p))*x,t[11]=0,t[12]=n[0],t[13]=n[1],t[14]=n[2],t[15]=1,t},fromRotationTranslationScaleOrigin:z,fromScaling:_,fromTranslation:R,fromValues:function(t,e,n,r,i,o,a,s,u,c,h,l,d,f,p,g){var m=new v(16);return m[0]=t,m[1]=e,m[2]=n,m[3]=r,m[4]=i,m[5]=o,m[6]=a,m[7]=s,m[8]=u,m[9]=c,m[10]=h,m[11]=l,m[12]=d,m[13]=f,m[14]=p,m[15]=g,m},fromXRotation:function(t,e){var n=Math.sin(e),r=Math.cos(e);return t[0]=1,t[1]=0,t[2]=0,t[3]=0,t[4]=0,t[5]=r,t[6]=n,t[7]=0,t[8]=0,t[9]=-n,t[10]=r,t[11]=0,t[12]=0,t[13]=0,t[14]=0,t[15]=1,t},fromYRotation:function(t,e){var n=Math.sin(e),r=Math.cos(e);return t[0]=r,t[1]=0,t[2]=-n,t[3]=0,t[4]=0,t[5]=1,t[6]=0,t[7]=0,t[8]=n,t[9]=0,t[10]=r,t[11]=0,t[12]=0,t[13]=0,t[14]=0,t[15]=1,t},fromZRotation:function(t,e){var n=Math.sin(e),r=Math.cos(e);return t[0]=r,t[1]=n,t[2]=0,t[3]=0,t[4]=-n,t[5]=r,t[6]=0,t[7]=0,t[8]=0,t[9]=0,t[10]=1,t[11]=0,t[12]=0,t[13]=0,t[14]=0,t[15]=1,t},frustum:function(t,e,n,r,i,o,a){var s=1/(n-e),u=1/(i-r),c=1/(o-a);return t[0]=2*o*s,t[1]=0,t[2]=0,t[3]=0,t[4]=0,t[5]=2*o*u,t[6]=0,t[7]=0,t[8]=(n+e)*s,t[9]=(i+r)*u,t[10]=(a+o)*c,t[11]=-1,t[12]=0,t[13]=0,t[14]=a*o*2*c,t[15]=0,t},getRotation:j,getScaling:L,getTranslation:I,identity:M,invert:S,lookAt:H,mul:Y,multiply:k,multiplyScalar:function(t,e,n){return t[0]=e[0]*n,t[1]=e[1]*n,t[2]=e[2]*n,t[3]=e[3]*n,t[4]=e[4]*n,t[5]=e[5]*n,t[6]=e[6]*n,t[7]=e[7]*n,t[8]=e[8]*n,t[9]=e[9]*n,t[10]=e[10]*n,t[11]=e[11]*n,t[12]=e[12]*n,t[13]=e[13]*n,t[14]=e[14]*n,t[15]=e[15]*n,t},multiplyScalarAndAdd:function(t,e,n,r){return t[0]=e[0]+n[0]*r,t[1]=e[1]+n[1]*r,t[2]=e[2]+n[2]*r,t[3]=e[3]+n[3]*r,t[4]=e[4]+n[4]*r,t[5]=e[5]+n[5]*r,t[6]=e[6]+n[6]*r,t[7]=e[7]+n[7]*r,t[8]=e[8]+n[8]*r,t[9]=e[9]+n[9]*r,t[10]=e[10]+n[10]*r,t[11]=e[11]+n[11]*r,t[12]=e[12]+n[12]*r,t[13]=e[13]+n[13]*r,t[14]=e[14]+n[14]*r,t[15]=e[15]+n[15]*r,t},ortho:U,orthoNO:V,orthoZO:W,perspective:G,perspectiveFromFieldOfView:function(t,e,n,r){var i=Math.tan(e.upDegrees*Math.PI/180),o=Math.tan(e.downDegrees*Math.PI/180),a=Math.tan(e.leftDegrees*Math.PI/180),s=Math.tan(e.rightDegrees*Math.PI/180),u=2/(a+s),c=2/(i+o);return t[0]=u,t[1]=0,t[2]=0,t[3]=0,t[4]=0,t[5]=c,t[6]=0,t[7]=0,t[8]=-(a-s)*u*.5,t[9]=(i-o)*c*.5,t[10]=r/(n-r),t[11]=-1,t[12]=0,t[13]=0,t[14]=r*n/(n-r),t[15]=0,t},perspectiveNO:B,perspectiveZO:function(t,e,n,r,i){var o,a=1/Math.tan(e/2);return t[0]=a/n,t[1]=0,t[2]=0,t[3]=0,t[4]=0,t[5]=a,t[6]=0,t[7]=0,t[8]=0,t[9]=0,t[11]=-1,t[12]=0,t[13]=0,t[15]=0,null!=i&&i!==1/0?(o=1/(r-i),t[10]=i*o,t[14]=i*r*o):(t[10]=-1,t[14]=-r),t},rotate:function(t,e,n,r){var i,o,a,s,u,c,h,l,d,f,p,g,v,y,b,E,w,x,M,N,S,T,k,P,C=r[0],A=r[1],O=r[2],R=Math.hypot(C,A,O);return R<m?null:(C*=R=1/R,A*=R,O*=R,i=Math.sin(n),a=1-(o=Math.cos(n)),s=e[0],u=e[1],c=e[2],h=e[3],l=e[4],d=e[5],f=e[6],p=e[7],g=e[8],v=e[9],y=e[10],b=e[11],E=C*C*a+o,w=A*C*a+O*i,x=O*C*a-A*i,M=C*A*a-O*i,N=A*A*a+o,S=O*A*a+C*i,T=C*O*a+A*i,k=A*O*a-C*i,P=O*O*a+o,t[0]=s*E+l*w+g*x,t[1]=u*E+d*w+v*x,t[2]=c*E+f*w+y*x,t[3]=h*E+p*w+b*x,t[4]=s*M+l*N+g*S,t[5]=u*M+d*N+v*S,t[6]=c*M+f*N+y*S,t[7]=h*M+p*N+b*S,t[8]=s*T+l*k+g*P,t[9]=u*T+d*k+v*P,t[10]=c*T+f*k+y*P,t[11]=h*T+p*k+b*P,e!==t&&(t[12]=e[12],t[13]=e[13],t[14]=e[14],t[15]=e[15]),t)},rotateX:A,rotateY:O,rotateZ:function(t,e,n){var r=Math.sin(n),i=Math.cos(n),o=e[0],a=e[1],s=e[2],u=e[3],c=e[4],h=e[5],l=e[6],d=e[7];return e!==t&&(t[8]=e[8],t[9]=e[9],t[10]=e[10],t[11]=e[11],t[12]=e[12],t[13]=e[13],t[14]=e[14],t[15]=e[15]),t[0]=o*i+c*r,t[1]=a*i+h*r,t[2]=s*i+l*r,t[3]=u*i+d*r,t[4]=c*i-o*r,t[5]=h*i-a*r,t[6]=l*i-s*r,t[7]=d*i-u*r,t},scale:C,set:x,str:function(t){return"mat4("+t[0]+", "+t[1]+", "+t[2]+", "+t[3]+", "+t[4]+", "+t[5]+", "+t[6]+", "+t[7]+", "+t[8]+", "+t[9]+", "+t[10]+", "+t[11]+", "+t[12]+", "+t[13]+", "+t[14]+", "+t[15]+")"},sub:$,subtract:q,targetTo:function(t,e,n,r){var i=e[0],o=e[1],a=e[2],s=r[0],u=r[1],c=r[2],h=i-n[0],l=o-n[1],d=a-n[2],f=h*h+l*l+d*d;f>0&&(h*=f=1/Math.sqrt(f),l*=f,d*=f);var p=u*d-c*l,g=c*h-s*d,m=s*l-u*h;return(f=p*p+g*g+m*m)>0&&(p*=f=1/Math.sqrt(f),g*=f,m*=f),t[0]=p,t[1]=g,t[2]=m,t[3]=0,t[4]=l*m-d*g,t[5]=d*p-h*m,t[6]=h*g-l*p,t[7]=0,t[8]=h,t[9]=l,t[10]=d,t[11]=0,t[12]=i,t[13]=o,t[14]=a,t[15]=1,t},translate:P,transpose:N});function K(){var t=new v(3);return v!=Float32Array&&(t[0]=0,t[1]=0,t[2]=0),t}function Z(t){var e=new v(3);return e[0]=t[0],e[1]=t[1],e[2]=t[2],e}function Q(t){var e=t[0],n=t[1],r=t[2];return Math.hypot(e,n,r)}function J(t,e,n){var r=new v(3);return r[0]=t,r[1]=e,r[2]=n,r}function tt(t,e){return t[0]=e[0],t[1]=e[1],t[2]=e[2],t}function et(t,e,n,r){return t[0]=e,t[1]=n,t[2]=r,t}function nt(t,e,n){return t[0]=e[0]+n[0],t[1]=e[1]+n[1],t[2]=e[2]+n[2],t}function rt(t,e,n){return t[0]=e[0]-n[0],t[1]=e[1]-n[1],t[2]=e[2]-n[2],t}function it(t,e,n){return t[0]=e[0]*n,t[1]=e[1]*n,t[2]=e[2]*n,t}function ot(t,e){var n=e[0],r=e[1],i=e[2],o=n*n+r*r+i*i;return o>0&&(o=1/Math.sqrt(o)),t[0]=e[0]*o,t[1]=e[1]*o,t[2]=e[2]*o,t}function at(t,e){return t[0]*e[0]+t[1]*e[1]+t[2]*e[2]}function st(t,e,n){var r=e[0],i=e[1],o=e[2],a=n[0],s=n[1],u=n[2];return t[0]=i*u-o*s,t[1]=o*a-r*u,t[2]=r*s-i*a,t}function ut(t,e,n,r){var i=e[0],o=e[1],a=e[2];return t[0]=i+r*(n[0]-i),t[1]=o+r*(n[1]-o),t[2]=a+r*(n[2]-a),t}function ct(t,e,n){var r=e[0],i=e[1],o=e[2],a=n[3]*r+n[7]*i+n[11]*o+n[15];return a=a||1,t[0]=(n[0]*r+n[4]*i+n[8]*o+n[12])/a,t[1]=(n[1]*r+n[5]*i+n[9]*o+n[13])/a,t[2]=(n[2]*r+n[6]*i+n[10]*o+n[14])/a,t}function ht(t,e){var n=t[0],r=t[1],i=t[2],o=e[0],a=e[1],s=e[2];return Math.abs(n-o)<=m*Math.max(1,Math.abs(n),Math.abs(o))&&Math.abs(r-a)<=m*Math.max(1,Math.abs(r),Math.abs(a))&&Math.abs(i-s)<=m*Math.max(1,Math.abs(i),Math.abs(s))}var lt=function(t,e){var n=e[0]-t[0],r=e[1]-t[1],i=e[2]-t[2];return Math.hypot(n,r,i)},dt=Q;function ft(){var t=new v(4);return v!=Float32Array&&(t[0]=0,t[1]=0,t[2]=0,t[3]=0),t}function pt(t,e,n){var r=e[0],i=e[1],o=e[2],a=e[3];return t[0]=n[0]*r+n[4]*i+n[8]*o+n[12]*a,t[1]=n[1]*r+n[5]*i+n[9]*o+n[13]*a,t[2]=n[2]*r+n[6]*i+n[10]*o+n[14]*a,t[3]=n[3]*r+n[7]*i+n[11]*o+n[15]*a,t}function gt(){var t=new v(4);return v!=Float32Array&&(t[0]=0,t[1]=0,t[2]=0),t[3]=1,t}function mt(t,e,n){n*=.5;var r=Math.sin(n);return t[0]=r*e[0],t[1]=r*e[1],t[2]=r*e[2],t[3]=Math.cos(n),t}function vt(t,e,n){var r=e[0],i=e[1],o=e[2],a=e[3],s=n[0],u=n[1],c=n[2],h=n[3];return t[0]=r*h+a*s+i*c-o*u,t[1]=i*h+a*u+o*s-r*c,t[2]=o*h+a*c+r*u-i*s,t[3]=a*h-r*s-i*u-o*c,t}function yt(t,e){var n=e[0],r=e[1],i=e[2],o=e[3],a=n*n+r*r+i*i+o*o,s=a?1/a:0;return t[0]=-n*s,t[1]=-r*s,t[2]=-i*s,t[3]=o*s,t}function bt(t,e,n,r){var i=.5*Math.PI/180;e*=i,n*=i,r*=i;var o=Math.sin(e),a=Math.cos(e),s=Math.sin(n),u=Math.cos(n),c=Math.sin(r),h=Math.cos(r);return t[0]=o*u*h-a*s*c,t[1]=a*s*h+o*u*c,t[2]=a*u*c-o*s*h,t[3]=a*u*h+o*s*c,t}K(),function(){var t=ft()}();var Et=function(t,e,n,r){var i=new v(4);return i[0]=t,i[1]=e,i[2]=n,i[3]=r,i},wt=function(t,e){return t[0]=e[0],t[1]=e[1],t[2]=e[2],t[3]=e[3],t},xt=vt,Mt=function(t,e){var n=e[0],r=e[1],i=e[2],o=e[3],a=n*n+r*r+i*i+o*o;return a>0&&(a=1/Math.sqrt(a)),t[0]=n*a,t[1]=r*a,t[2]=i*a,t[3]=o*a,t};K(),J(1,0,0),J(0,1,0),gt(),gt(),y(),function(){var t,e=(t=new v(2),v!=Float32Array&&(t[0]=0,t[1]=0),t)}();var Nt=function(t){return null!==t&&"function"!=typeof t&&isFinite(t.length)},St=function(t,e){return!!Nt(t)&&t.indexOf(e)>-1},Tt=function(t,e){return void 0===e&&(e=[]),function(t,e){if(!Nt(t))return t;for(var n=[],r=0;r<t.length;r++){var i=t[r];e(i,r)&&n.push(i)}return n}(t,(function(t){return!St(e,t)}))},kt=function(t){return"function"==typeof t},Pt=function(t){return null==t},Ct={}.toString,At=function(t,e){return Ct.call(t)==="[object "+e+"]"},Ot=function(t){return Array.isArray?Array.isArray(t):At(t,"Array")},Rt=function(t){var e=typeof t;return null!==t&&"object"===e||"function"===e};function _t(t,e){if(t)if(Ot(t))for(var n=0,r=t.length;n<r&&!1!==e(t[n],n);n++);else if(Rt(t))for(var i in t)if(t.hasOwnProperty(i)&&!1===e(t[i],i))break}var Dt=function(t){return"object"==typeof t&&null!==t},It=function(t){if(!Dt(t)||!At(t,"Object"))return!1;if(null===Object.getPrototypeOf(t))return!0;for(var e=t;null!==Object.getPrototypeOf(e);)e=Object.getPrototypeOf(e);return Object.getPrototypeOf(t)===e},Lt=function(t){if(Ot(t))return t.reduce((function(t,e){return Math.max(t,e)}),t[0])},jt=function(t){if(Ot(t))return t.reduce((function(t,e){return Math.min(t,e)}),t[0])},zt=function(t){return At(t,"String")},Ft=Object.prototype.hasOwnProperty;function Bt(t,e){if(!e||!Ot(t))return{};for(var n,r={},i=kt(e)?e:function(t){return t[e]},o=0;o<t.length;o++){var a=t[o];n=i(a),Ft.call(r,n)?r[n].push(a):r[n]=[a]}return r}var Gt=function(t,e,n){return t<e?e:t>n?n:t},Vt=function(t){return At(t,"Number")},Ut=1e-5;function Wt(t,e,n){return void 0===n&&(n=Ut),Math.abs(t-e)<n}var Ht=function(t,e){return(t%e+e)%e},qt=function(t){return Pt(t)?"":t.toString()},Yt=function(t){var e=qt(t);return e.charAt(0).toLowerCase()+e.substring(1)};var $t={}.toString,Xt=function(t){return At(t,"Boolean")},Kt=Object.prototype,Zt=function(t){return void 0===t},Qt=function(t){if("object"!=typeof t||null===t)return t;var e;if(Ot(t)){e=[];for(var n=0,r=t.length;n<r;n++)"object"==typeof t[n]&&null!=t[n]?e[n]=Qt(t[n]):e[n]=t[n]}else for(var i in e={},t)"object"==typeof t[i]&&null!=t[i]?e[i]=Qt(t[i]):e[i]=t[i];return e};function Jt(t,e){if(Object.hasOwn)return Object.hasOwn(t,e);if(null==t)throw new TypeError("Cannot convert undefined or null to object");return Object.prototype.hasOwnProperty.call(Object(t),e)}function te(t,e,n,r){for(var i in n=n||0,r=r||5,e)if(Jt(e,i)){var o=e[i];null!==o&&It(o)?(It(t[i])||(t[i]={}),n<r?te(t[i],o,n+1,r):t[i]=e[i]):Ot(o)?(t[i]=[],t[i]=t[i].concat(o)):void 0!==o&&(t[i]=o)}}var ee=function(t){for(var e=[],n=1;n<arguments.length;n++)e[n-1]=arguments[n];for(var r=0;r<e.length;r+=1)te(t,e[r]);return t},ne=Object.prototype.hasOwnProperty;function re(t){if(Pt(t))return!0;if(Nt(t))return!t.length;var e=function(t){return $t.call(t).replace(/^\[object /,"").replace(/]$/,"")}(t);if("Map"===e||"Set"===e)return!t.size;if(function(t){var e=t&&t.constructor;return t===("function"==typeof e&&e.prototype||Kt)}(t))return!Object.keys(t).length;for(var n in t)if(ne.call(t,n))return!1;return!0}var ie=function(t,e){if(t===e)return!0;if(!t||!e)return!1;if(zt(t)||zt(e))return!1;if(Nt(t)||Nt(e)){if(t.length!==e.length)return!1;for(var n=!0,r=0;r<t.length&&(n=ie(t[r],e[r]));r++);return n}if(Dt(t)||Dt(e)){var i=Object.keys(t),o=Object.keys(e);if(i.length!==o.length)return!1;for(n=!0,r=0;r<i.length&&(n=ie(t[i[r]],e[i[r]]));r++);return n}return!1},oe=function(t,e,n){for(var r=0,i=zt(e)?e.split("."):e;t&&r<i.length;)t=t[i[r++]];return void 0===t||r<i.length?n:t},ae=function(t,e,n){var r=t,i=zt(e)?e.split("."):e;return i.forEach((function(t,e){e<i.length-1?(Rt(r[t])||(r[t]=Vt(i[e+1])?[]:{}),r=r[t]):r[t]=n})),t},se=Object.prototype.hasOwnProperty,ue=function(t,e){return function(t,e,n){if(!Ot(t)&&!It(t))return t;var r=n;return _t(t,(function(t,n){r=e(r,t,n)})),r}(t,(function(t,n,r){return e.includes(r)||(t[r]=n),t}),{})},ce={x1:0,y1:0,x2:0,y2:0,x:0,y:0,qx:null,qy:null};function he(t,e,n){if(t[n].length>7){t[n].shift();for(var r=t[n],i=n;r.length;)e[n]="A",t.splice(i+=1,0,["C"].concat(r.splice(0,6)));t.splice(n,1)}}var le={a:7,c:6,h:1,l:2,m:2,r:4,q:4,s:4,t:2,v:1,z:0};function de(t){return Array.isArray(t)&&t.every((function(t){var e=t[0].toLowerCase();return le[e]===t.length-1&&"achlmqstvz".includes(e)}))}function fe(t){return de(t)&&t.every((function(t){var e=t[0];return e===e.toUpperCase()}))}function pe(t){return fe(t)&&t.every((function(t){var e=t[0];return"ACLMQZ".includes(e)}))}function ge(t){for(var e=t.pathValue[t.segmentStart],n=e.toLowerCase(),r=t.data;r.length>=le[n]&&("m"===n&&r.length>2?(t.segments.push([e].concat(r.splice(0,2))),n="l",e="m"===e?"l":"L"):t.segments.push([e].concat(r.splice(0,le[n]))),le[n]););}function me(t){var e=t.index,n=t.pathValue,r=n.charCodeAt(e);return 48===r?(t.param=0,void(t.index+=1)):49===r?(t.param=1,void(t.index+=1)):void(t.err='[path-util]: invalid Arc flag "'+n[e]+'", expecting 0 or 1 at index '+e)}function ve(t){return t>=48&&t<=57||43===t||45===t||46===t}function ye(t){return t>=48&&t<=57}function be(t){var e,n=t.max,r=t.pathValue,i=t.index,o=i,a=!1,s=!1,u=!1,c=!1;if(o>=n)t.err="[path-util]: Invalid path value at index "+o+', "pathValue" is missing param';else if(43!==(e=r.charCodeAt(o))&&45!==e||(o+=1,e=r.charCodeAt(o)),ye(e)||46===e){if(46!==e){if(a=48===e,o+=1,e=r.charCodeAt(o),a&&o<n&&e&&ye(e))return void(t.err="[path-util]: Invalid path value at index "+i+', "'+r[i]+'" illegal number');for(;o<n&&ye(r.charCodeAt(o));)o+=1,s=!0;e=r.charCodeAt(o)}if(46===e){for(c=!0,o+=1;ye(r.charCodeAt(o));)o+=1,u=!0;e=r.charCodeAt(o)}if(101===e||69===e){if(c&&!s&&!u)return void(t.err="[path-util]: Invalid path value at index "+o+', "'+r[o]+'" invalid float exponent');if(o+=1,43!==(e=r.charCodeAt(o))&&45!==e||(o+=1),!(o<n&&ye(r.charCodeAt(o))))return void(t.err="[path-util]: Invalid path value at index "+o+', "'+r[o]+'" invalid integer exponent');for(;o<n&&ye(r.charCodeAt(o));)o+=1}t.index=o,t.param=+t.pathValue.slice(i,o)}else t.err="[path-util]: Invalid path value at index "+o+', "'+r[o]+'" is not a number'}function Ee(t){for(var e,n=t.pathValue,r=t.max;t.index<r&&(10===(e=n.charCodeAt(t.index))||13===e||8232===e||8233===e||32===e||9===e||11===e||12===e||160===e||e>=5760&&[5760,6158,8192,8193,8194,8195,8196,8197,8198,8199,8200,8201,8202,8239,8287,12288,65279].includes(e));)t.index+=1}function we(t){var e=t.max,n=t.pathValue,r=t.index,i=n.charCodeAt(r),o=le[n[r].toLowerCase()];if(t.segmentStart=r,function(t){switch(32|t){case 109:case 122:case 108:case 104:case 118:case 99:case 115:case 113:case 116:case 97:return!0;default:return!1}}(i))if(t.index+=1,Ee(t),t.data=[],o){for(;;){for(var a=o;a>0;a-=1){if(97!=(32|i)||3!==a&&4!==a?be(t):me(t),t.err.length)return;t.data.push(t.param),Ee(t),t.index<e&&44===n.charCodeAt(t.index)&&(t.index+=1,Ee(t))}if(t.index>=t.max)break;if(!ve(n.charCodeAt(t.index)))break}ge(t)}else ge(t);else t.err='[path-util]: Invalid path value "'+n[r]+'" is not a path command'}var xe=function(t){this.pathValue=t,this.segments=[],this.max=t.length,this.index=0,this.param=0,this.segmentStart=0,this.data=[],this.err=""};function Me(t){if(fe(t))return[].concat(t);var e=function(t){if(de(t))return[].concat(t);var e=new xe(t);for(Ee(e);e.index<e.max&&!e.err.length;)we(e);return e.err?e.err:e.segments}(t),n=0,r=0,i=0,o=0;return e.map((function(t){var e,a=t.slice(1).map(Number),s=t[0],u=s.toUpperCase();if("M"===s)return n=a[0],r=a[1],i=n,o=r,["M",n,r];if(s!==u)switch(u){case"A":e=[u,a[0],a[1],a[2],a[3],a[4],a[5]+n,a[6]+r];break;case"V":e=[u,a[0]+r];break;case"H":e=[u,a[0]+n];break;default:var c=a.map((function(t,e){return t+(e%2?r:n)}));e=[u].concat(c)}else e=[u].concat(a);var h=e.length;switch(u){case"Z":n=i,r=o;break;case"H":n=e[1];break;case"V":r=e[1];break;default:n=e[h-2],r=e[h-1],"M"===u&&(i=n,o=r)}return e}))}function Ne(t,e){var n=t[0],r=e.x1,i=e.y1,o=e.x2,a=e.y2,s=t.slice(1).map(Number),u=t;if("TQ".includes(n)||(e.qx=null,e.qy=null),"H"===n)u=["L",t[1],i];else if("V"===n)u=["L",r,t[1]];else if("S"===n){var c=2*r-o,h=2*i-a;e.x1=c,e.y1=h,u=["C",c,h].concat(s)}else if("T"===n){var l=2*r-e.qx,d=2*i-e.qy;e.qx=l,e.qy=d,u=["Q",l,d].concat(s)}else if("Q"===n){var f=s[0],p=s[1];e.qx=f,e.qy=p}return u}function Se(t){if(pe(t))return[].concat(t);for(var e=Me(t),n=i({},ce),r=0;r<e.length;r+=1){e[r]=Ne(e[r],n);var o=e[r],a=o.length;n.x1=+o[a-2],n.y1=+o[a-1],n.x2=+o[a-4]||n.x1,n.y2=+o[a-3]||n.y1}return e}function Te(t,e,n){return{x:t*Math.cos(n)-e*Math.sin(n),y:t*Math.sin(n)+e*Math.cos(n)}}function ke(t,e,n,r,i,o,a,s,u,c){var h,l,d,f,p,g=t,m=e,v=n,y=r,b=s,E=u,w=120*Math.PI/180,x=Math.PI/180*(+i||0),M=[];if(c)l=c[0],d=c[1],f=c[2],p=c[3];else{g=(h=Te(g,m,-x)).x,m=h.y;var N=(g-(b=(h=Te(b,E,-x)).x))/2,S=(m-(E=h.y))/2,T=N*N/(v*v)+S*S/(y*y);T>1&&(v*=T=Math.sqrt(T),y*=T);var k=v*v,P=y*y,C=(o===a?-1:1)*Math.sqrt(Math.abs((k*P-k*S*S-P*N*N)/(k*S*S+P*N*N)));f=C*v*S/y+(g+b)/2,p=C*-y*N/v+(m+E)/2,l=Math.asin(((m-p)/y*Math.pow(10,9)>>0)/Math.pow(10,9)),d=Math.asin(((E-p)/y*Math.pow(10,9)>>0)/Math.pow(10,9)),l=g<f?Math.PI-l:l,d=b<f?Math.PI-d:d,l<0&&(l=2*Math.PI+l),d<0&&(d=2*Math.PI+d),a&&l>d&&(l-=2*Math.PI),!a&&d>l&&(d-=2*Math.PI)}var A=d-l;if(Math.abs(A)>w){var O=d,R=b,_=E;d=l+w*(a&&d>l?1:-1),M=ke(b=f+v*Math.cos(d),E=p+y*Math.sin(d),v,y,i,0,a,R,_,[d,O,f,p])}A=d-l;var D=Math.cos(l),I=Math.sin(l),L=Math.cos(d),j=Math.sin(d),z=Math.tan(A/4),F=4/3*v*z,B=4/3*y*z,G=[g,m],V=[g+F*I,m-B*D],U=[b+F*j,E-B*L],W=[b,E];if(V[0]=2*G[0]-V[0],V[1]=2*G[1]-V[1],c)return V.concat(U,W,M);for(var H=[],q=0,Y=(M=V.concat(U,W,M)).length;q<Y;q+=1)H[q]=q%2?Te(M[q-1],M[q],x).y:Te(M[q],M[q+1],x).x;return H}function Pe(t,e,n){var r=t[0],i=t[1];return[r+(e[0]-r)*n,i+(e[1]-i)*n]}var Ce=function(t,e,n,r){return h(h([],Pe([t,e],[n,r],.5),!0),[n,r,n,r],!1)};function Ae(t,e){var n,r,i,o,a,s,u,c,h,l=t[0],d=t.slice(1).map(Number),f=d[0],p=d[1],g=e.x1,m=e.y1,v=e.x,y=e.y;switch("TQ".includes(l)||(e.qx=null,e.qy=null),l){case"M":return e.x=f,e.y=p,t;case"A":return n=[g,m].concat(d),["C"].concat(ke(n[0],n[1],n[2],n[3],n[4],n[5],n[6],n[7],n[8],n[9]));case"Q":return e.qx=f,e.qy=p,n=[g,m].concat(d),["C"].concat((r=n[0],i=n[1],o=n[2],a=n[3],s=n[4],u=n[5],[(c=1/3)*r+(h=2/3)*o,c*i+h*a,c*s+h*o,c*u+h*a,s,u]));case"L":return["C"].concat(Ce(g,m,f,p));case"Z":return g===v&&m===y?["C",g,m,v,y,v,y]:["C"].concat(Ce(g,m,v,y))}return t}function Oe(t,e){if(void 0===e&&(e=!1),function(t){return pe(t)&&t.every((function(t){var e=t[0];return"MC".includes(e)}))}(t)){var n=[].concat(t);return e?[n,[]]:n}for(var r,o,a=Se(t),s=i({},ce),u=[],c="",h=a.length,l=[],d=0;d<h;d+=1){a[d]&&(c=a[d][0]),u[d]=c;var f=Ae(a[d],s);a[d]=f,he(a,u,d),h=a.length,"Z"===c&&l.push(d),o=(r=a[d]).length,s.x1=+r[o-2],s.y1=+r[o-1],s.x2=+r[o-4]||s.x1,s.y2=+r[o-3]||s.y1}return e?[a,l]:a}function Re(t,e){return Math.sqrt((t[0]-e[0])*(t[0]-e[0])+(t[1]-e[1])*(t[1]-e[1]))}function _e(t,e,n,r,i){var o=Re([t,e],[n,r]),a={x:0,y:0};if("number"==typeof i)if(i<=0)a={x:t,y:e};else if(i>=o)a={x:n,y:r};else{var s=Pe([t,e],[n,r],i/o);a={x:s[0],y:s[1]}}return{length:o,point:a,min:{x:Math.min(t,n),y:Math.min(e,r)},max:{x:Math.max(t,n),y:Math.max(e,r)}}}function De(t,e){var n=t.x,r=t.y,i=e.x,o=e.y,a=n*i+r*o,s=Math.sqrt((Math.pow(n,2)+Math.pow(r,2))*(Math.pow(i,2)+Math.pow(o,2)));return(n*o-r*i<0?-1:1)*Math.acos(a/s)}function Ie(t,e,n,r,i,o,a,s,u,c){var h=Math.abs,l=Math.sin,d=Math.cos,f=Math.sqrt,p=Math.PI,g=h(n),m=h(r),v=(i%360+360)%360*(p/180);if(t===s&&e===u)return{x:t,y:e};if(0===g||0===m)return _e(t,e,s,u,c).point;var y=(t-s)/2,b=(e-u)/2,E={x:d(v)*y+l(v)*b,y:-l(v)*y+d(v)*b},w=Math.pow(E.x,2)/Math.pow(g,2)+Math.pow(E.y,2)/Math.pow(m,2);w>1&&(g*=f(w),m*=f(w));var x=(Math.pow(g,2)*Math.pow(m,2)-Math.pow(g,2)*Math.pow(E.y,2)-Math.pow(m,2)*Math.pow(E.x,2))/(Math.pow(g,2)*Math.pow(E.y,2)+Math.pow(m,2)*Math.pow(E.x,2)),M=(o!==a?1:-1)*f(x=x<0?0:x),N=M*(g*E.y/m),S=M*(-m*E.x/g),T=d(v)*N-l(v)*S+(t+s)/2,k=l(v)*N+d(v)*S+(e+u)/2,P={x:(E.x-N)/g,y:(E.y-S)/m},C=De({x:1,y:0},P),A=De(P,{x:(-E.x-N)/g,y:(-E.y-S)/m});!a&&A>0?A-=2*p:a&&A<0&&(A+=2*p);var O=C+(A%=2*p)*c,R=g*d(O),_=m*l(O);return{x:d(v)*R-l(v)*_+T,y:l(v)*R+d(v)*_+k}}function Le(t,e,n,r,i,o,a,s,u,c,h){var l,d=h.bbox,f=void 0===d||d,p=h.length,g=void 0===p||p,m=h.sampleSize,v=void 0===m?30:m,y="number"==typeof c,b=t,E=e,w=0,x=[b,E,w],M=[b,E],N={x:0,y:0},S=[{x:b,y:E}];y&&c<=0&&(N={x:b,y:E});for(var T=0;T<=v;T+=1){if(b=(l=Ie(t,e,n,r,i,o,a,s,u,T/v)).x,E=l.y,f&&S.push({x:b,y:E}),g&&(w+=Re(M,[b,E])),M=[b,E],y&&w>=c&&c>x[2]){var k=(w-c)/(w-x[2]);N={x:M[0]*(1-k)+x[0]*k,y:M[1]*(1-k)+x[1]*k}}x=[b,E,w]}return y&&c>=w&&(N={x:s,y:u}),{length:w,point:N,min:{x:Math.min.apply(null,S.map((function(t){return t.x}))),y:Math.min.apply(null,S.map((function(t){return t.y})))},max:{x:Math.max.apply(null,S.map((function(t){return t.x}))),y:Math.max.apply(null,S.map((function(t){return t.y})))}}}function je(t,e,n,r,i,o,a,s,u){var c=1-u;return{x:Math.pow(c,3)*t+3*Math.pow(c,2)*u*n+3*c*Math.pow(u,2)*i+Math.pow(u,3)*a,y:Math.pow(c,3)*e+3*Math.pow(c,2)*u*r+3*c*Math.pow(u,2)*o+Math.pow(u,3)*s}}function ze(t,e,n,r,i,o,a,s,u,c){var h,l=c.bbox,d=void 0===l||l,f=c.length,p=void 0===f||f,g=c.sampleSize,m=void 0===g?10:g,v="number"==typeof u,y=t,b=e,E=0,w=[y,b,E],x=[y,b],M={x:0,y:0},N=[{x:y,y:b}];v&&u<=0&&(M={x:y,y:b});for(var S=0;S<=m;S+=1){if(y=(h=je(t,e,n,r,i,o,a,s,S/m)).x,b=h.y,d&&N.push({x:y,y:b}),p&&(E+=Re(x,[y,b])),x=[y,b],v&&E>=u&&u>w[2]){var T=(E-u)/(E-w[2]);M={x:x[0]*(1-T)+w[0]*T,y:x[1]*(1-T)+w[1]*T}}w=[y,b,E]}return v&&u>=E&&(M={x:a,y:s}),{length:E,point:M,min:{x:Math.min.apply(null,N.map((function(t){return t.x}))),y:Math.min.apply(null,N.map((function(t){return t.y})))},max:{x:Math.max.apply(null,N.map((function(t){return t.x}))),y:Math.max.apply(null,N.map((function(t){return t.y})))}}}function Fe(t,e,n,r,i,o,a){var s=1-a;return{x:Math.pow(s,2)*t+2*s*a*n+Math.pow(a,2)*i,y:Math.pow(s,2)*e+2*s*a*r+Math.pow(a,2)*o}}function Be(t,e,n,r,i,o,a,s){var u,c=s.bbox,h=void 0===c||c,l=s.length,d=void 0===l||l,f=s.sampleSize,p=void 0===f?10:f,g="number"==typeof a,m=t,v=e,y=0,b=[m,v,y],E=[m,v],w={x:0,y:0},x=[{x:m,y:v}];g&&a<=0&&(w={x:m,y:v});for(var M=0;M<=p;M+=1){if(m=(u=Fe(t,e,n,r,i,o,M/p)).x,v=u.y,h&&x.push({x:m,y:v}),d&&(y+=Re(E,[m,v])),E=[m,v],g&&y>=a&&a>b[2]){var N=(y-a)/(y-b[2]);w={x:E[0]*(1-N)+b[0]*N,y:E[1]*(1-N)+b[1]*N}}b=[m,v,y]}return g&&a>=y&&(w={x:i,y:o}),{length:y,point:w,min:{x:Math.min.apply(null,x.map((function(t){return t.x}))),y:Math.min.apply(null,x.map((function(t){return t.y})))},max:{x:Math.max.apply(null,x.map((function(t){return t.x}))),y:Math.max.apply(null,x.map((function(t){return t.y})))}}}function Ge(t,e,n){for(var r,i,o,a,s,u,c,h,l,d=Se(t),f="number"==typeof e,p=[],g=0,m=0,v=0,y=0,b=[],E=[],w=0,x={x:0,y:0},M=x,N=x,S=x,T=0,k=0,P=d.length;k<P;k+=1)p=(c="M"===(h=(l=d[k])[0]))?p:[g,m].concat(l.slice(1)),c?(M=x={x:v=l[1],y:y=l[2]},w=0,f&&e<.001&&(S=x)):"L"===h?(w=(r=_e(p[0],p[1],p[2],p[3],(e||0)-T)).length,x=r.min,M=r.max,N=r.point):"A"===h?(w=(i=Le(p[0],p[1],p[2],p[3],p[4],p[5],p[6],p[7],p[8],(e||0)-T,n||{})).length,x=i.min,M=i.max,N=i.point):"C"===h?(w=(o=ze(p[0],p[1],p[2],p[3],p[4],p[5],p[6],p[7],(e||0)-T,n||{})).length,x=o.min,M=o.max,N=o.point):"Q"===h?(w=(a=Be(p[0],p[1],p[2],p[3],p[4],p[5],(e||0)-T,n||{})).length,x=a.min,M=a.max,N=a.point):"Z"===h&&(w=(s=_e((p=[g,m,v,y])[0],p[1],p[2],p[3],(e||0)-T)).length,x=s.min,M=s.max,N=s.point),f&&T<e&&T+w>=e&&(S=N),E.push(M),b.push(x),T+=w,g=(u="Z"!==h?l.slice(-2):[v,y])[0],m=u[1];return f&&e>=T&&(S={x:g,y:m}),{length:T,point:S,min:{x:Math.min.apply(null,b.map((function(t){return t.x}))),y:Math.min.apply(null,b.map((function(t){return t.y})))},max:{x:Math.max.apply(null,E.map((function(t){return t.x}))),y:Math.max.apply(null,E.map((function(t){return t.y})))}}}function Ve(t,e){var n=t.length-1,r=[],i=0,o=function(t){var e=t.length,n=e-1;return t.map((function(r,i){return t.map((function(r,o){var a,s=i+o;return 0===o||t[s]&&"M"===t[s][0]?(a=t[s],["M"].concat(a.slice(-2))):(s>=e&&(s-=n),t[s])}))}))}(t);return o.forEach((function(o,a){t.slice(1).forEach((function(r,o){i+=Re(t[(a+o)%n].slice(-2),e[o%n].slice(-2))})),r[a]=i,i=0})),o[r.indexOf(Math.min.apply(null,r))]}function Ue(t){return function(t){var e=0,n=0,r=0;return Oe(t).map((function(t){var i;if("M"===t[0])return e=t[1],n=t[2],0;var o=t.slice(1),a=o[0],s=o[1],u=o[2],c=o[3],h=o[4],l=o[5];return r=function(t,e,n,r,i,o,a,s){return 3*((s-e)*(n+i)-(a-t)*(r+o)+r*(t-i)-n*(e-o)+s*(i+t/3)-a*(o+e/3))/20}(e,n,a,s,u,c,h,l),i=t.slice(-2),e=i[0],n=i[1],r})).reduce((function(t,e){return t+e}),0)}(t)>=0}function We(t){return t.map((function(t,e,n){var r=e&&n[e-1].slice(-2).concat(t.slice(1)),i=e?ze(r[0],r[1],r[2],r[3],r[4],r[5],r[6],r[7],r[8],{bbox:!1}).length:0;return{s:t,ss:e?i?function(t,e){void 0===e&&(e=.5);var n=t.slice(0,2),r=t.slice(2,4),i=t.slice(4,6),o=t.slice(6,8),a=Pe(n,r,e),s=Pe(r,i,e),u=Pe(i,o,e),c=Pe(a,s,e),h=Pe(s,u,e),l=Pe(c,h,e);return[["C"].concat(a,c,l),["C"].concat(h,u,o)]}(r):[t,t]:[t],l:i}}))}function He(t,e,n){var r=We(t),i=We(e),o=r.length,a=i.length,s=r.filter((function(t){return t.l})).length,u=i.filter((function(t){return t.l})).length,c=r.filter((function(t){return t.l})).reduce((function(t,e){return t+e.l}),0)/s||0,h=i.filter((function(t){return t.l})).reduce((function(t,e){return t+e.l}),0)/u||0,l=n||Math.max(o,a),d=[c,h],f=[l-o,l-a],p=0,g=[r,i].map((function(t,e){return t.l===l?t.map((function(t){return t.s})):t.map((function(t,n){return p=n&&f[e]&&t.l>=d[e],f[e]-=p?1:0,p?t.ss:[t.s]})).flat()}));return g[0].length===g[1].length?g:He(g[0],g[1],l)}function qe(t){var e=document.createElement("div");e.innerHTML=t;var n=e.childNodes[0];return n&&e.contains(n)&&e.removeChild(n),n}function Ye(t,e,n){t.prototype=e.prototype=n,n.constructor=t}function $e(t,e){var n=Object.create(t.prototype);for(var r in e)n[r]=e[r];return n}function Xe(){}var Ke=.7,Ze=1/Ke,Qe="\\s*([+-]?\\d+)\\s*",Je="\\s*([+-]?\\d*\\.?\\d+(?:[eE][+-]?\\d+)?)\\s*",tn="\\s*([+-]?\\d*\\.?\\d+(?:[eE][+-]?\\d+)?)%\\s*",en=/^#([0-9a-f]{3,8})$/,nn=new RegExp("^rgb\\("+[Qe,Qe,Qe]+"\\)$"),rn=new RegExp("^rgb\\("+[tn,tn,tn]+"\\)$"),on=new RegExp("^rgba\\("+[Qe,Qe,Qe,Je]+"\\)$"),an=new RegExp("^rgba\\("+[tn,tn,tn,Je]+"\\)$"),sn=new RegExp("^hsl\\("+[Je,tn,tn]+"\\)$"),un=new RegExp("^hsla\\("+[Je,tn,tn,Je]+"\\)$"),cn={aliceblue:15792383,antiquewhite:16444375,aqua:65535,aquamarine:8388564,azure:15794175,beige:16119260,bisque:16770244,black:0,blanchedalmond:16772045,blue:255,blueviolet:9055202,brown:10824234,burlywood:14596231,cadetblue:6266528,chartreuse:8388352,chocolate:13789470,coral:16744272,cornflowerblue:6591981,cornsilk:16775388,crimson:14423100,cyan:65535,darkblue:139,darkcyan:35723,darkgoldenrod:12092939,darkgray:11119017,darkgreen:25600,darkgrey:11119017,darkkhaki:12433259,darkmagenta:9109643,darkolivegreen:5597999,darkorange:16747520,darkorchid:10040012,darkred:9109504,darksalmon:15308410,darkseagreen:9419919,darkslateblue:4734347,darkslategray:3100495,darkslategrey:3100495,darkturquoise:52945,darkviolet:9699539,deeppink:16716947,deepskyblue:49151,dimgray:6908265,dimgrey:6908265,dodgerblue:2003199,firebrick:11674146,floralwhite:16775920,forestgreen:2263842,fuchsia:16711935,gainsboro:14474460,ghostwhite:16316671,gold:16766720,goldenrod:14329120,gray:8421504,green:32768,greenyellow:11403055,grey:8421504,honeydew:15794160,hotpink:16738740,indianred:13458524,indigo:4915330,ivory:16777200,khaki:15787660,lavender:15132410,lavenderblush:16773365,lawngreen:8190976,lemonchiffon:16775885,lightblue:11393254,lightcoral:15761536,lightcyan:14745599,lightgoldenrodyellow:16448210,lightgray:13882323,lightgreen:9498256,lightgrey:13882323,lightpink:16758465,lightsalmon:16752762,lightseagreen:2142890,lightskyblue:8900346,lightslategray:7833753,lightslategrey:7833753,lightsteelblue:11584734,lightyellow:16777184,lime:65280,limegreen:3329330,linen:16445670,magenta:16711935,maroon:8388608,mediumaquamarine:6737322,mediumblue:205,mediumorchid:12211667,mediumpurple:9662683,mediumseagreen:3978097,mediumslateblue:8087790,mediumspringgreen:64154,mediumturquoise:4772300,mediumvioletred:13047173,midnightblue:1644912,mintcream:16121850,mistyrose:16770273,moccasin:16770229,navajowhite:16768685,navy:128,oldlace:16643558,olive:8421376,olivedrab:7048739,orange:16753920,orangered:16729344,orchid:14315734,palegoldenrod:15657130,palegreen:10025880,paleturquoise:11529966,palevioletred:14381203,papayawhip:16773077,peachpuff:16767673,peru:13468991,pink:16761035,plum:14524637,powderblue:11591910,purple:8388736,rebeccapurple:6697881,red:16711680,rosybrown:12357519,royalblue:4286945,saddlebrown:9127187,salmon:16416882,sandybrown:16032864,seagreen:3050327,seashell:16774638,sienna:10506797,silver:12632256,skyblue:8900331,slateblue:6970061,slategray:7372944,slategrey:7372944,snow:16775930,springgreen:65407,steelblue:4620980,tan:13808780,teal:32896,thistle:14204888,tomato:16737095,turquoise:4251856,violet:15631086,wheat:16113331,white:16777215,whitesmoke:16119285,yellow:16776960,yellowgreen:10145074};function hn(){return this.rgb().formatHex()}function ln(){return this.rgb().formatRgb()}function dn(t){var e,n;return t=(t+"").trim().toLowerCase(),(e=en.exec(t))?(n=e[1].length,e=parseInt(e[1],16),6===n?fn(e):3===n?new gn(e>>8&15|e>>4&240,e>>4&15|240&e,(15&e)<<4|15&e,1):8===n?pn(e>>24&255,e>>16&255,e>>8&255,(255&e)/255):4===n?pn(e>>12&15|e>>8&240,e>>8&15|e>>4&240,e>>4&15|240&e,((15&e)<<4|15&e)/255):null):(e=nn.exec(t))?new gn(e[1],e[2],e[3],1):(e=rn.exec(t))?new gn(255*e[1]/100,255*e[2]/100,255*e[3]/100,1):(e=on.exec(t))?pn(e[1],e[2],e[3],e[4]):(e=an.exec(t))?pn(255*e[1]/100,255*e[2]/100,255*e[3]/100,e[4]):(e=sn.exec(t))?bn(e[1],e[2]/100,e[3]/100,1):(e=un.exec(t))?bn(e[1],e[2]/100,e[3]/100,e[4]):cn.hasOwnProperty(t)?fn(cn[t]):"transparent"===t?new gn(NaN,NaN,NaN,0):null}function fn(t){return new gn(t>>16&255,t>>8&255,255&t,1)}function pn(t,e,n,r){return r<=0&&(t=e=n=NaN),new gn(t,e,n,r)}function gn(t,e,n,r){this.r=+t,this.g=+e,this.b=+n,this.opacity=+r}function mn(){return"#"+yn(this.r)+yn(this.g)+yn(this.b)}function vn(){var t=this.opacity;return(1===(t=isNaN(t)?1:Math.max(0,Math.min(1,t)))?"rgb(":"rgba(")+Math.max(0,Math.min(255,Math.round(this.r)||0))+", "+Math.max(0,Math.min(255,Math.round(this.g)||0))+", "+Math.max(0,Math.min(255,Math.round(this.b)||0))+(1===t?")":", "+t+")")}function yn(t){return((t=Math.max(0,Math.min(255,Math.round(t)||0)))<16?"0":"")+t.toString(16)}function bn(t,e,n,r){return r<=0?t=e=n=NaN:n<=0||n>=1?t=e=NaN:e<=0&&(t=NaN),new wn(t,e,n,r)}function En(t){if(t instanceof wn)return new wn(t.h,t.s,t.l,t.opacity);if(t instanceof Xe||(t=dn(t)),!t)return new wn;if(t instanceof wn)return t;var e=(t=t.rgb()).r/255,n=t.g/255,r=t.b/255,i=Math.min(e,n,r),o=Math.max(e,n,r),a=NaN,s=o-i,u=(o+i)/2;return s?(a=e===o?(n-r)/s+6*(n<r):n===o?(r-e)/s+2:(e-n)/s+4,s/=u<.5?o+i:2-o-i,a*=60):s=u>0&&u<1?0:a,new wn(a,s,u,t.opacity)}function wn(t,e,n,r){this.h=+t,this.s=+e,this.l=+n,this.opacity=+r}function xn(t,e,n){return 255*(t<60?e+(n-e)*t/60:t<180?n:t<240?e+(n-e)*(240-t)/60:e)}function Mn(t,e,n,r){var i=t-n,o=e-r;return Math.sqrt(i*i+o*o)}function Nn(t,e){var n=Math.min.apply(Math,h([],c(t),!1)),r=Math.min.apply(Math,h([],c(e),!1));return{x:n,y:r,width:Math.max.apply(Math,h([],c(t),!1))-n,height:Math.max.apply(Math,h([],c(e),!1))-r}}function Sn(t,e,n,r,i,o){return n*Math.cos(i)*Math.cos(o)-r*Math.sin(i)*Math.sin(o)+t}function Tn(t,e,n,r,i,o){return n*Math.sin(i)*Math.cos(o)+r*Math.cos(i)*Math.sin(o)+e}function kn(t,e,n,r,i,o,a){for(var s=function(t,e,n){return Math.atan(-e/t*Math.tan(n))}(n,r,i),u=1/0,c=-1/0,h=[o,a],l=2*-Math.PI;l<=2*Math.PI;l+=Math.PI){var d=s+l;o<a?o<d&&d<a&&h.push(d):a<d&&d<o&&h.push(d)}for(l=0;l<h.length;l++){var f=Sn(t,0,n,r,i,h[l]);f<u&&(u=f),f>c&&(c=f)}var p=function(t,e,n){return Math.atan(e/(t*Math.tan(n)))}(n,r,i),g=1/0,m=-1/0,v=[o,a];for(l=2*-Math.PI;l<=2*Math.PI;l+=Math.PI){var y=p+l;o<a?o<y&&y<a&&v.push(y):a<y&&y<o&&v.push(y)}for(l=0;l<v.length;l++){var b=Tn(0,e,n,r,i,v[l]);b<g&&(g=b),b>m&&(m=b)}return{x:u,y:g,width:c-u,height:m-g}}Ye(Xe,dn,{copy:function(t){return Object.assign(new this.constructor,this,t)},displayable:function(){return this.rgb().displayable()},hex:hn,formatHex:hn,formatHsl:function(){return En(this).formatHsl()},formatRgb:ln,toString:ln}),Ye(gn,(function(t,e,n,r){return 1===arguments.length?((i=t)instanceof Xe||(i=dn(i)),i?new gn((i=i.rgb()).r,i.g,i.b,i.opacity):new gn):new gn(t,e,n,null==r?1:r);var i}),$e(Xe,{brighter:function(t){return t=null==t?Ze:Math.pow(Ze,t),new gn(this.r*t,this.g*t,this.b*t,this.opacity)},darker:function(t){return t=null==t?Ke:Math.pow(Ke,t),new gn(this.r*t,this.g*t,this.b*t,this.opacity)},rgb:function(){return this},displayable:function(){return-.5<=this.r&&this.r<255.5&&-.5<=this.g&&this.g<255.5&&-.5<=this.b&&this.b<255.5&&0<=this.opacity&&this.opacity<=1},hex:mn,formatHex:mn,formatRgb:vn,toString:vn})),Ye(wn,(function(t,e,n,r){return 1===arguments.length?En(t):new wn(t,e,n,null==r?1:r)}),$e(Xe,{brighter:function(t){return t=null==t?Ze:Math.pow(Ze,t),new wn(this.h,this.s,this.l*t,this.opacity)},darker:function(t){return t=null==t?Ke:Math.pow(Ke,t),new wn(this.h,this.s,this.l*t,this.opacity)},rgb:function(){var t=this.h%360+360*(this.h<0),e=isNaN(t)||isNaN(this.s)?0:this.s,n=this.l,r=n+(n<.5?n:1-n)*e,i=2*n-r;return new gn(xn(t>=240?t-240:t+120,i,r),xn(t,i,r),xn(t<120?t+240:t-120,i,r),this.opacity)},displayable:function(){return(0<=this.s&&this.s<=1||isNaN(this.s))&&0<=this.l&&this.l<=1&&0<=this.opacity&&this.opacity<=1},formatHsl:function(){var t=this.opacity;return(1===(t=isNaN(t)?1:Math.max(0,Math.min(1,t)))?"hsl(":"hsla(")+(this.h||0)+", "+100*(this.s||0)+"%, "+100*(this.l||0)+"%"+(1===t?")":", "+t+")")}}));var Pn=1e-4;function Cn(t,e,n,r,i,o){var a=-1,s=1/0,u=[n,r],l=20;o&&o>200&&(l=o/10);for(var d=1/l,f=d/10,p=0;p<=l;p++){var g=p*d,m=[i.apply(void 0,h([],c(t.concat([g])),!1)),i.apply(void 0,h([],c(e.concat([g])),!1))];(E=Mn(u[0],u[1],m[0],m[1]))<s&&(a=g,s=E)}if(0===a)return{x:t[0],y:e[0]};if(1===a){var v=t.length;return{x:t[v-1],y:e[v-1]}}s=1/0;for(p=0;p<32&&!(f<Pn);p++){var y=a-f,b=a+f,E=(m=[i.apply(void 0,h([],c(t.concat([y])),!1)),i.apply(void 0,h([],c(e.concat([y])),!1))],Mn(u[0],u[1],m[0],m[1]));if(y>=0&&E<s)a=y,s=E;else{var w=[i.apply(void 0,h([],c(t.concat([b])),!1)),i.apply(void 0,h([],c(e.concat([b])),!1))],x=Mn(u[0],u[1],w[0],w[1]);b<=1&&x<s?(a=b,s=x):f*=.5}}return{x:i.apply(void 0,h([],c(t.concat([a])),!1)),y:i.apply(void 0,h([],c(e.concat([a])),!1))}}function An(t,e,n,r){return Mn(t,e,n,r)}function On(t,e,n,r,i){return{x:(1-i)*t+i*n,y:(1-i)*e+i*r}}function Rn(t,e,n,r,i,o){var a=[n-t,r-e];if(function(t,e){return t[0]===e[0]&&t[1]===e[1]}(a,[0,0]))return Math.sqrt((i-t)*(i-t)+(o-e)*(o-e));var s=[-a[1],a[0]];!function(t,e){var n=e[0],r=e[1],i=n*n+r*r;i>0&&(i=1/Math.sqrt(i)),t[0]=e[0]*i,t[1]=e[1]*i}(s,s);var u=[i-t,o-e];return Math.abs(function(t,e){return t[0]*e[0]+t[1]*e[1]}(u,s))}function _n(t,e,n,r,i){var o=1-i;return o*o*o*t+3*e*i*o*o+3*n*i*i*o+r*i*i*i}function Dn(t,e,n,r){var i,o,a,s=-3*t+9*e-9*n+3*r,u=6*t-12*e+6*n,c=3*e-3*t,h=[];if(Wt(s,0))Wt(u,0)||(i=-c/u)>=0&&i<=1&&h.push(i);else{var l=u*u-4*s*c;Wt(l,0)?h.push(-u/(2*s)):l>0&&(o=(-u-(a=Math.sqrt(l)))/(2*s),(i=(-u+a)/(2*s))>=0&&i<=1&&h.push(i),o>=0&&o<=1&&h.push(o))}return h}function In(t,e,n,r,i,o,a,s){for(var u=[t,a],c=[e,s],h=Dn(t,n,i,a),l=Dn(e,r,o,s),d=0;d<h.length;d++)u.push(_n(t,n,i,a,h[d]));for(d=0;d<l.length;d++)c.push(_n(e,r,o,s,l[d]));return Nn(u,c)}function Ln(t,e,n,r,i,o,a,s,u,c,h){var l=function(t,e,n,r,i,o,a,s,u,c,h){return Cn([t,n,i,a],[e,r,o,s],u,c,_n,h)}(t,e,n,r,i,o,a,s,u,c,h);return Mn(l.x,l.y,u,c)}function jn(t){return function(t){if(t.length<2)return 0;for(var e=0,n=0;n<t.length-1;n++){var r=t[n],i=t[n+1];e+=Mn(r[0],r[1],i[0],i[1])}return e}(t)}function zn(t,e,n,r){var i=1-r;return i*i*t+2*r*i*e+r*r*n}function Fn(t,e,n){var r=t+n-2*e;if(Wt(r,0))return[.5];var i=(t-e)/r;return i<=1&&i>=0?[i]:[]}function Bn(t,e,n,r,i,o){var a=Fn(t,n,i)[0],s=Fn(e,r,o)[0],u=[t,i],c=[e,o];return void 0!==a&&u.push(zn(t,n,i,a)),void 0!==s&&c.push(zn(e,r,o,s)),Nn(u,c)}function Gn(t,e,n,r,i,o,a,s){var u=function(t,e,n,r,i,o,a,s){return Cn([t,n,i],[e,r,o],a,s,zn)}(t,e,n,r,i,o,a,s);return Mn(u.x,u.y,a,s)}"undefined"!=typeof globalThis?globalThis:"undefined"!=typeof window?window:"undefined"!=typeof global?global:"undefined"!=typeof self&&self;var Vn={exports:{}};!function(t,e){t.exports=function(){function t(t,n,i,o,a){e(t,n,i||0,o||t.length-1,a||r)}function e(t,r,i,o,a){for(;o>i;){if(o-i>600){var s=o-i+1,u=r-i+1,c=Math.log(s),h=.5*Math.exp(2*c/3),l=.5*Math.sqrt(c*h*(s-h)/s)*(u-s/2<0?-1:1);e(t,r,Math.max(i,Math.floor(r-u*h/s+l)),Math.min(o,Math.floor(r+(s-u)*h/s+l)),a)}var d=t[r],f=i,p=o;for(n(t,i,r),a(t[o],d)>0&&n(t,i,o);f<p;){for(n(t,f,p),f++,p--;a(t[f],d)<0;)f++;for(;a(t[p],d)>0;)p--}0===a(t[i],d)?n(t,i,p):n(t,++p,o),p<=r&&(i=p+1),r<=p&&(o=p-1)}}function n(t,e,n){var r=t[e];t[e]=t[n],t[n]=r}function r(t,e){return t<e?-1:t>e?1:0}var i=function(t){void 0===t&&(t=9),this._maxEntries=Math.max(4,t),this._minEntries=Math.max(2,Math.ceil(.4*this._maxEntries)),this.clear()};function o(t,e,n){if(!n)return e.indexOf(t);for(var r=0;r<e.length;r++)if(n(t,e[r]))return r;return-1}function a(t,e){s(t,0,t.children.length,e,t)}function s(t,e,n,r,i){i||(i=v(null)),i.minX=1/0,i.minY=1/0,i.maxX=-1/0,i.maxY=-1/0;for(var o=e;o<n;o++){var a=t.children[o];u(i,t.leaf?r(a):a)}return i}function u(t,e){return t.minX=Math.min(t.minX,e.minX),t.minY=Math.min(t.minY,e.minY),t.maxX=Math.max(t.maxX,e.maxX),t.maxY=Math.max(t.maxY,e.maxY),t}function c(t,e){return t.minX-e.minX}function h(t,e){return t.minY-e.minY}function l(t){return(t.maxX-t.minX)*(t.maxY-t.minY)}function d(t){return t.maxX-t.minX+(t.maxY-t.minY)}function f(t,e){return(Math.max(e.maxX,t.maxX)-Math.min(e.minX,t.minX))*(Math.max(e.maxY,t.maxY)-Math.min(e.minY,t.minY))}function p(t,e){var n=Math.max(t.minX,e.minX),r=Math.max(t.minY,e.minY),i=Math.min(t.maxX,e.maxX),o=Math.min(t.maxY,e.maxY);return Math.max(0,i-n)*Math.max(0,o-r)}function g(t,e){return t.minX<=e.minX&&t.minY<=e.minY&&e.maxX<=t.maxX&&e.maxY<=t.maxY}function m(t,e){return e.minX<=t.maxX&&e.minY<=t.maxY&&e.maxX>=t.minX&&e.maxY>=t.minY}function v(t){return{children:t,height:1,leaf:!0,minX:1/0,minY:1/0,maxX:-1/0,maxY:-1/0}}function y(e,n,r,i,o){for(var a=[n,r];a.length;)if(!((r=a.pop())-(n=a.pop())<=i)){var s=n+Math.ceil((r-n)/i/2)*i;t(e,s,n,r,o),a.push(n,s,s,r)}}return i.prototype.all=function(){return this._all(this.data,[])},i.prototype.search=function(t){var e=this.data,n=[];if(!m(t,e))return n;for(var r=this.toBBox,i=[];e;){for(var o=0;o<e.children.length;o++){var a=e.children[o],s=e.leaf?r(a):a;m(t,s)&&(e.leaf?n.push(a):g(t,s)?this._all(a,n):i.push(a))}e=i.pop()}return n},i.prototype.collides=function(t){var e=this.data;if(!m(t,e))return!1;for(var n=[];e;){for(var r=0;r<e.children.length;r++){var i=e.children[r],o=e.leaf?this.toBBox(i):i;if(m(t,o)){if(e.leaf||g(t,o))return!0;n.push(i)}}e=n.pop()}return!1},i.prototype.load=function(t){if(!t||!t.length)return this;if(t.length<this._minEntries){for(var e=0;e<t.length;e++)this.insert(t[e]);return this}var n=this._build(t.slice(),0,t.length-1,0);if(this.data.children.length)if(this.data.height===n.height)this._splitRoot(this.data,n);else{if(this.data.height<n.height){var r=this.data;this.data=n,n=r}this._insert(n,this.data.height-n.height-1,!0)}else this.data=n;return this},i.prototype.insert=function(t){return t&&this._insert(t,this.data.height-1),this},i.prototype.clear=function(){return this.data=v([]),this},i.prototype.remove=function(t,e){if(!t)return this;for(var n,r,i,a=this.data,s=this.toBBox(t),u=[],c=[];a||u.length;){if(a||(a=u.pop(),r=u[u.length-1],n=c.pop(),i=!0),a.leaf){var h=o(t,a.children,e);if(-1!==h)return a.children.splice(h,1),u.push(a),this._condense(u),this}i||a.leaf||!g(a,s)?r?(n++,a=r.children[n],i=!1):a=null:(u.push(a),c.push(n),n=0,r=a,a=a.children[0])}return this},i.prototype.toBBox=function(t){return t},i.prototype.compareMinX=function(t,e){return t.minX-e.minX},i.prototype.compareMinY=function(t,e){return t.minY-e.minY},i.prototype.toJSON=function(){return this.data},i.prototype.fromJSON=function(t){return this.data=t,this},i.prototype._all=function(t,e){for(var n=[];t;)t.leaf?e.push.apply(e,t.children):n.push.apply(n,t.children),t=n.pop();return e},i.prototype._build=function(t,e,n,r){var i,o=n-e+1,s=this._maxEntries;if(o<=s)return a(i=v(t.slice(e,n+1)),this.toBBox),i;r||(r=Math.ceil(Math.log(o)/Math.log(s)),s=Math.ceil(o/Math.pow(s,r-1))),(i=v([])).leaf=!1,i.height=r;var u=Math.ceil(o/s),c=u*Math.ceil(Math.sqrt(s));y(t,e,n,c,this.compareMinX);for(var h=e;h<=n;h+=c){var l=Math.min(h+c-1,n);y(t,h,l,u,this.compareMinY);for(var d=h;d<=l;d+=u){var f=Math.min(d+u-1,l);i.children.push(this._build(t,d,f,r-1))}}return a(i,this.toBBox),i},i.prototype._chooseSubtree=function(t,e,n,r){for(;r.push(e),!e.leaf&&r.length-1!==n;){for(var i=1/0,o=1/0,a=void 0,s=0;s<e.children.length;s++){var u=e.children[s],c=l(u),h=f(t,u)-c;h<o?(o=h,i=c<i?c:i,a=u):h===o&&c<i&&(i=c,a=u)}e=a||e.children[0]}return e},i.prototype._insert=function(t,e,n){var r=n?t:this.toBBox(t),i=[],o=this._chooseSubtree(r,this.data,e,i);for(o.children.push(t),u(o,r);e>=0&&i[e].children.length>this._maxEntries;)this._split(i,e),e--;this._adjustParentBBoxes(r,i,e)},i.prototype._split=function(t,e){var n=t[e],r=n.children.length,i=this._minEntries;this._chooseSplitAxis(n,i,r);var o=this._chooseSplitIndex(n,i,r),s=v(n.children.splice(o,n.children.length-o));s.height=n.height,s.leaf=n.leaf,a(n,this.toBBox),a(s,this.toBBox),e?t[e-1].children.push(s):this._splitRoot(n,s)},i.prototype._splitRoot=function(t,e){this.data=v([t,e]),this.data.height=t.height+1,this.data.leaf=!1,a(this.data,this.toBBox)},i.prototype._chooseSplitIndex=function(t,e,n){for(var r,i=1/0,o=1/0,a=e;a<=n-e;a++){var u=s(t,0,a,this.toBBox),c=s(t,a,n,this.toBBox),h=p(u,c),d=l(u)+l(c);h<i?(i=h,r=a,o=d<o?d:o):h===i&&d<o&&(o=d,r=a)}return r||n-e},i.prototype._chooseSplitAxis=function(t,e,n){var r=t.leaf?this.compareMinX:c,i=t.leaf?this.compareMinY:h;this._allDistMargin(t,e,n,r)<this._allDistMargin(t,e,n,i)&&t.children.sort(r)},i.prototype._allDistMargin=function(t,e,n,r){t.children.sort(r);for(var i=this.toBBox,o=s(t,0,e,i),a=s(t,n-e,n,i),c=d(o)+d(a),h=e;h<n-e;h++){var l=t.children[h];u(o,t.leaf?i(l):l),c+=d(o)}for(var f=n-e-1;f>=e;f--){var p=t.children[f];u(a,t.leaf?i(p):p),c+=d(a)}return c},i.prototype._adjustParentBBoxes=function(t,e,n){for(var r=n;r>=0;r--)u(e[r],t)},i.prototype._condense=function(t){for(var e=t.length-1,n=void 0;e>=0;e--)0===t[e].children.length?e>0?(n=t[e-1].children).splice(n.indexOf(t[e]),1):this.clear():a(t[e],this.toBBox)},i}()}(Vn);var Un,Wn,Hn=Vn.exports;!function(t){t.GROUP="g",t.CIRCLE="circle",t.ELLIPSE="ellipse",t.IMAGE="image",t.RECT="rect",t.LINE="line",t.POLYLINE="polyline",t.POLYGON="polygon",t.TEXT="text",t.PATH="path",t.HTML="html",t.MESH="mesh"}(Un||(Un={})),function(t){t[t.ZERO=0]="ZERO",t[t.NEGATIVE_ONE=1]="NEGATIVE_ONE"}(Wn||(Wn={}));var qn=function(){function t(){this.plugins=[]}return t.prototype.addRenderingPlugin=function(t){this.plugins.push(t),this.context.renderingPlugins.push(t)},t.prototype.removeAllRenderingPlugins=function(){var t=this;this.plugins.forEach((function(e){var n=t.context.renderingPlugins.indexOf(e);n>=0&&t.context.renderingPlugins.splice(n,1)}))},t}(),Yn=function(){function t(t){this.clipSpaceNearZ=Wn.NEGATIVE_ONE,this.plugins=[],this.config=i({enableDirtyCheck:!0,enableCulling:!1,enableAutoRendering:!0,enableDirtyRectangleRendering:!0,enableDirtyRectangleRenderingDebug:!1,enableSizeAttenuation:!0},t)}return t.prototype.registerPlugin=function(t){-1===this.plugins.findIndex((function(e){return e===t}))&&this.plugins.push(t)},t.prototype.unregisterPlugin=function(t){var e=this.plugins.findIndex((function(e){return e===t}));e>-1&&this.plugins.splice(e,1)},t.prototype.getPlugins=function(){return this.plugins},t.prototype.getPlugin=function(t){return this.plugins.find((function(e){return e.name===t}))},t.prototype.getConfig=function(){return this.config},t.prototype.setConfig=function(t){Object.assign(this.config,t)},t}();function $n(t,e){return t[0]=e[0],t[1]=e[1],t[2]=e[2],t}function Xn(t,e,n){return t[0]=e[0]-n[0],t[1]=e[1]-n[1],t[2]=e[2]-n[2],t}function Kn(t,e,n){return t[0]=e[0]+n[0],t[1]=e[1]+n[1],t[2]=e[2]+n[2],t}function Zn(t,e,n){return t[0]=e[0]*n,t[1]=e[1]*n,t[2]=e[2]*n,t}function Qn(t){return void 0===t?0:t>360||t<-360?t%360:t}function Jn(t,e,n){return void 0===e&&(e=0),void 0===n&&(n=0),Array.isArray(t)&&3===t.length?Z(t):Vt(t)?J(t,e,n):J(t[0],t[1]||e,t[2]||n)}function tr(t){return t*(Math.PI/180)}function er(t){return t*(180/Math.PI)}function nr(t,e){return 16===e.length?function(t,e){var n,r,i=.5*Math.PI,o=c(L(K(),e),3),a=o[0],s=o[1],u=o[2],h=Math.asin(-e[2]/a);return h<i?h>-i?(n=Math.atan2(e[6]/s,e[10]/u),r=Math.atan2(e[1]/a,e[0]/a)):(r=0,n=-Math.atan2(e[4]/s,e[5]/s)):(r=0,n=Math.atan2(e[4]/s,e[5]/s)),t[0]=n,t[1]=h,t[2]=r,t}(t,e):function(t,e){var n=e[0],r=e[1],i=e[2],o=e[3],a=r*r,s=i*i,u=o*o,c=n*n+a+s+u,h=n*o-r*i;return h>.499995*c?(t[0]=Math.PI/2,t[1]=2*Math.atan2(r,n),t[2]=0):h<-.499995*c?(t[0]=-Math.PI/2,t[1]=2*Math.atan2(r,n),t[2]=0):(t[0]=Math.asin(2*(n*i-o*r)),t[1]=Math.atan2(2*(n*o+r*i),1-2*(s+u)),t[2]=Math.atan2(2*(n*r+i*o),1-2*(a+s))),t}(t,e)}function rr(t,e,n,r,i){var o,a,s,u,c,h,l,d,f,p,g=Math.cos(t),m=Math.sin(t);return o=r*g,a=i*m,s=0,u=-r*m,c=i*g,h=0,l=e,d=n,f=1,(p=new v(9))[0]=o,p[1]=a,p[2]=s,p[3]=u,p[4]=c,p[5]=h,p[6]=l,p[7]=d,p[8]=f,p}function ir(t){var e=t[0],n=t[1],r=t[3],i=t[4],o=Math.sqrt(e*e+n*n),a=Math.sqrt(r*r+i*i);e*i-n*r<0&&(e<i?o=-o:a=-a),o&&(e*=1/o,n*=1/o),a&&(r*=1/a,i*=1/a);var s=er(Math.atan2(n,e));return[t[6],t[7],o,a,s]}var or=b(),ar=b(),sr=ft(),ur=[K(),K(),K()],cr=K();function hr(t,e,n,r,i){t[0]=e[0]*r+n[0]*i,t[1]=e[1]*r+n[1]*i,t[2]=e[2]*r+n[2]*i}var lr,dr=function(){function t(){this.center=[0,0,0],this.halfExtents=[0,0,0],this.min=[0,0,0],this.max=[0,0,0]}return t.isEmpty=function(t){return!t||0===t.halfExtents[0]&&0===t.halfExtents[1]&&0===t.halfExtents[2]},t.prototype.update=function(t,e){$n(this.center,t),$n(this.halfExtents,e),Xn(this.min,this.center,this.halfExtents),Kn(this.max,this.center,this.halfExtents)},t.prototype.setMinMax=function(t,e){Kn(this.center,e,t),Zn(this.center,this.center,.5),Xn(this.halfExtents,e,t),Zn(this.halfExtents,this.halfExtents,.5),$n(this.min,t),$n(this.max,e)},t.prototype.getMin=function(){return this.min},t.prototype.getMax=function(){return this.max},t.prototype.add=function(e){if(!t.isEmpty(e))if(t.isEmpty(this))this.setMinMax(e.getMin(),e.getMax());else{var n=this.center,r=n[0],i=n[1],o=n[2],a=this.halfExtents,s=a[0],u=a[1],c=a[2],h=r-s,l=r+s,d=i-u,f=i+u,p=o-c,g=o+c,m=e.center,v=m[0],y=m[1],b=m[2],E=e.halfExtents,w=E[0],x=E[1],M=E[2],N=v-w,S=v+w,T=y-x,k=y+x,P=b-M,C=b+M;N<h&&(h=N),S>l&&(l=S),T<d&&(d=T),k>f&&(f=k),P<p&&(p=P),C>g&&(g=C),n[0]=.5*(h+l),n[1]=.5*(d+f),n[2]=.5*(p+g),a[0]=.5*(l-h),a[1]=.5*(f-d),a[2]=.5*(g-p),this.min[0]=h,this.min[1]=d,this.min[2]=p,this.max[0]=l,this.max[1]=f,this.max[2]=g}},t.prototype.setFromTransformedAABB=function(t,e){var n=this.center,r=this.halfExtents,i=t.center,o=t.halfExtents,a=e[0],s=e[4],u=e[8],c=e[1],h=e[5],l=e[9],d=e[2],f=e[6],p=e[10],g=Math.abs(a),m=Math.abs(s),v=Math.abs(u),y=Math.abs(c),b=Math.abs(h),E=Math.abs(l),w=Math.abs(d),x=Math.abs(f),M=Math.abs(p);n[0]=e[12]+a*i[0]+s*i[1]+u*i[2],n[1]=e[13]+c*i[0]+h*i[1]+l*i[2],n[2]=e[14]+d*i[0]+f*i[1]+p*i[2],r[0]=g*o[0]+m*o[1]+v*o[2],r[1]=y*o[0]+b*o[1]+E*o[2],r[2]=w*o[0]+x*o[1]+M*o[2],Xn(this.min,n,r),Kn(this.max,n,r)},t.prototype.intersects=function(t){var e=this.getMax(),n=this.getMin(),r=t.getMax(),i=t.getMin();return n[0]<=r[0]&&e[0]>=i[0]&&n[1]<=r[1]&&e[1]>=i[1]&&n[2]<=r[2]&&e[2]>=i[2]},t.prototype.intersection=function(e){if(!this.intersects(e))return null;var n=new t,r=function(t,e,n){return t[0]=Math.max(e[0],n[0]),t[1]=Math.max(e[1],n[1]),t[2]=Math.max(e[2],n[2]),t}([0,0,0],this.getMin(),e.getMin()),i=function(t,e,n){return t[0]=Math.min(e[0],n[0]),t[1]=Math.min(e[1],n[1]),t[2]=Math.min(e[2],n[2]),t}([0,0,0],this.getMax(),e.getMax());return n.setMinMax(r,i),n},t.prototype.getNegativeFarPoint=function(t){return 273===t.pnVertexFlag?$n([0,0,0],this.min):272===t.pnVertexFlag?[this.min[0],this.min[1],this.max[2]]:257===t.pnVertexFlag?[this.min[0],this.max[1],this.min[2]]:256===t.pnVertexFlag?[this.min[0],this.max[1],this.max[2]]:17===t.pnVertexFlag?[this.max[0],this.min[1],this.min[2]]:16===t.pnVertexFlag?[this.max[0],this.min[1],this.max[2]]:1===t.pnVertexFlag?[this.max[0],this.max[1],this.min[2]]:[this.max[0],this.max[1],this.max[2]]},t.prototype.getPositiveFarPoint=function(t){return 273===t.pnVertexFlag?$n([0,0,0],this.max):272===t.pnVertexFlag?[this.max[0],this.max[1],this.min[2]]:257===t.pnVertexFlag?[this.max[0],this.min[1],this.max[2]]:256===t.pnVertexFlag?[this.max[0],this.min[1],this.min[2]]:17===t.pnVertexFlag?[this.min[0],this.max[1],this.max[2]]:16===t.pnVertexFlag?[this.min[0],this.max[1],this.min[2]]:1===t.pnVertexFlag?[this.min[0],this.min[1],this.max[2]]:[this.min[0],this.min[1],this.min[2]]},t}(),fr=function(){function t(t,e){this.distance=t||0,this.normal=e||J(0,1,0),this.updatePNVertexFlag()}return t.prototype.updatePNVertexFlag=function(){this.pnVertexFlag=(Number(this.normal[0]>=0)<<8)+(Number(this.normal[1]>=0)<<4)+Number(this.normal[2]>=0)},t.prototype.distanceToPoint=function(t){return at(t,this.normal)-this.distance},t.prototype.normalize=function(){var t=1/dt(this.normal);it(this.normal,this.normal,t),this.distance*=t},t.prototype.intersectsLine=function(t,e,n){var r=this.distanceToPoint(t),i=r/(r-this.distanceToPoint(e)),o=i>=0&&i<=1;return o&&n&&ut(n,t,e,i),o},t}();!function(t){t[t.OUTSIDE=4294967295]="OUTSIDE",t[t.INSIDE=0]="INSIDE",t[t.INDETERMINATE=2147483647]="INDETERMINATE"}(lr||(lr={}));var pr,gr,mr,vr=function(){function t(t){if(this.planes=[],t)this.planes=t;else for(var e=0;e<6;e++)this.planes.push(new fr)}return t.prototype.extractFromVPMatrix=function(t){var e=c(t,16),n=e[0],r=e[1],i=e[2],o=e[3],a=e[4],s=e[5],u=e[6],h=e[7],l=e[8],d=e[9],f=e[10],p=e[11],g=e[12],m=e[13],v=e[14],y=e[15];et(this.planes[0].normal,o-n,h-a,p-l),this.planes[0].distance=y-g,et(this.planes[1].normal,o+n,h+a,p+l),this.planes[1].distance=y+g,et(this.planes[2].normal,o+r,h+s,p+d),this.planes[2].distance=y+m,et(this.planes[3].normal,o-r,h-s,p-d),this.planes[3].distance=y-m,et(this.planes[4].normal,o-i,h-u,p-f),this.planes[4].distance=y-v,et(this.planes[5].normal,o+i,h+u,p+f),this.planes[5].distance=y+v,this.planes.forEach((function(t){t.normalize(),t.updatePNVertexFlag()}))},t}(),yr=function(){function t(t,e){void 0===t&&(t=0),void 0===e&&(e=0),this.x=0,this.y=0,this.x=t,this.y=e}return t.prototype.clone=function(){return new t(this.x,this.y)},t.prototype.copyFrom=function(t){this.x=t.x,this.y=t.y},t}(),br=function(){function t(t,e,n,r){this.x=t,this.y=e,this.width=n,this.height=r,this.left=t,this.right=t+n,this.top=e,this.bottom=e+r}return t.prototype.toJSON=function(){},t}(),Er="Method not implemented.",wr="Use document.documentElement instead.";!function(t){t[t.ORBITING=0]="ORBITING",t[t.EXPLORING=1]="EXPLORING",t[t.TRACKING=2]="TRACKING"}(pr||(pr={})),function(t){t[t.DEFAULT=0]="DEFAULT",t[t.ROTATIONAL=1]="ROTATIONAL",t[t.TRANSLATIONAL=2]="TRANSLATIONAL",t[t.CINEMATIC=3]="CINEMATIC"}(gr||(gr={})),function(t){t[t.ORTHOGRAPHIC=0]="ORTHOGRAPHIC",t[t.PERSPECTIVE=1]="PERSPECTIVE"}(mr||(mr={}));var xr,Mr,Nr,Sr,Tr,kr="updated",Pr=2e-4,Cr=function(){function t(){this.clipSpaceNearZ=Wn.NEGATIVE_ONE,this.eventEmitter=new g,this.matrix=b(),this.right=J(1,0,0),this.up=J(0,1,0),this.forward=J(0,0,1),this.position=J(0,0,1),this.focalPoint=J(0,0,0),this.distanceVector=J(0,0,-1),this.distance=1,this.azimuth=0,this.elevation=0,this.roll=0,this.relAzimuth=0,this.relElevation=0,this.relRoll=0,this.dollyingStep=0,this.maxDistance=1/0,this.minDistance=-1/0,this.zoom=1,this.rotateWorld=!1,this.fov=30,this.near=.1,this.far=1e3,this.aspect=1,this.projectionMatrix=b(),this.projectionMatrixInverse=b(),this.jitteredProjectionMatrix=void 0,this.enableUpdate=!0,this.type=pr.EXPLORING,this.trackingMode=gr.DEFAULT,this.projectionMode=mr.PERSPECTIVE,this.frustum=new vr,this.orthoMatrix=b()}return t.prototype.isOrtho=function(){return this.projectionMode===mr.ORTHOGRAPHIC},t.prototype.getProjectionMode=function(){return this.projectionMode},t.prototype.getPerspective=function(){return this.jitteredProjectionMatrix||this.projectionMatrix},t.prototype.getPerspectiveInverse=function(){return this.projectionMatrixInverse},t.prototype.getFrustum=function(){return this.frustum},t.prototype.getPosition=function(){return this.position},t.prototype.getFocalPoint=function(){return this.focalPoint},t.prototype.getDollyingStep=function(){return this.dollyingStep},t.prototype.getNear=function(){return this.near},t.prototype.getFar=function(){return this.far},t.prototype.getZoom=function(){return this.zoom},t.prototype.getOrthoMatrix=function(){return this.orthoMatrix},t.prototype.getView=function(){return this.view},t.prototype.setEnableUpdate=function(t){this.enableUpdate=t},t.prototype.setType=function(t,e){return this.type=t,this.type===pr.EXPLORING?this.setWorldRotation(!0):this.setWorldRotation(!1),this._getAngles(),this.type===pr.TRACKING&&void 0!==e&&this.setTrackingMode(e),this},t.prototype.setProjectionMode=function(t){return this.projectionMode=t,this},t.prototype.setTrackingMode=function(t){if(this.type!==pr.TRACKING)throw new Error("Impossible to set a tracking mode if the camera is not of tracking type");return this.trackingMode=t,this},t.prototype.setWorldRotation=function(t){return this.rotateWorld=t,this._getAngles(),this},t.prototype.getViewTransform=function(){return S(b(),this.matrix)},t.prototype.getWorldTransform=function(){return this.matrix},t.prototype.jitterProjectionMatrix=function(t,e){var n=R(b(),[t,e,0]);this.jitteredProjectionMatrix=k(b(),n,this.projectionMatrix)},t.prototype.clearJitterProjectionMatrix=function(){this.jitteredProjectionMatrix=void 0},t.prototype.setMatrix=function(t){return this.matrix=t,this._update(),this},t.prototype.setFov=function(t){return this.setPerspective(this.near,this.far,t,this.aspect),this},t.prototype.setAspect=function(t){return this.setPerspective(this.near,this.far,this.fov,t),this},t.prototype.setNear=function(t){return this.projectionMode===mr.PERSPECTIVE?this.setPerspective(t,this.far,this.fov,this.aspect):this.setOrthographic(this.left,this.rright,this.top,this.bottom,t,this.far),this},t.prototype.setFar=function(t){return this.projectionMode===mr.PERSPECTIVE?this.setPerspective(this.near,t,this.fov,this.aspect):this.setOrthographic(this.left,this.rright,this.top,this.bottom,this.near,t),this},t.prototype.setViewOffset=function(t,e,n,r,i,o){return this.aspect=t/e,void 0===this.view&&(this.view={enabled:!0,fullWidth:1,fullHeight:1,offsetX:0,offsetY:0,width:1,height:1}),this.view.enabled=!0,this.view.fullWidth=t,this.view.fullHeight=e,this.view.offsetX=n,this.view.offsetY=r,this.view.width=i,this.view.height=o,this.projectionMode===mr.PERSPECTIVE?this.setPerspective(this.near,this.far,this.fov,this.aspect):this.setOrthographic(this.left,this.rright,this.top,this.bottom,this.near,this.far),this},t.prototype.clearViewOffset=function(){return void 0!==this.view&&(this.view.enabled=!1),this.projectionMode===mr.PERSPECTIVE?this.setPerspective(this.near,this.far,this.fov,this.aspect):this.setOrthographic(this.left,this.rright,this.top,this.bottom,this.near,this.far),this},t.prototype.setZoom=function(t){return this.zoom=t,this.projectionMode===mr.ORTHOGRAPHIC?this.setOrthographic(this.left,this.rright,this.top,this.bottom,this.near,this.far):this.projectionMode===mr.PERSPECTIVE&&this.setPerspective(this.near,this.far,this.fov,this.aspect),this},t.prototype.setZoomByViewportPoint=function(t,e){var n=this.canvas.viewport2Canvas({x:e[0],y:e[1]}),r=n.x,i=n.y,o=this.roll;this.rotate(0,0,-o),this.setPosition(r,i),this.setFocalPoint(r,i),this.setZoom(t),this.rotate(0,0,o);var a=this.canvas.viewport2Canvas({x:e[0],y:e[1]}),s=J(a.x-r,a.y-i,0),u=at(s,this.right)/Q(this.right),c=at(s,this.up)/Q(this.up);return this.pan(-u,-c),this},t.prototype.setPerspective=function(t,e,n,r){var i;this.projectionMode=mr.PERSPECTIVE,this.fov=n,this.near=t,this.far=e,this.aspect=r;var o=this.near*Math.tan(tr(.5*this.fov))/this.zoom,a=2*o,s=this.aspect*a,u=-.5*s;if(null===(i=this.view)||void 0===i?void 0:i.enabled){var c=this.view.fullWidth,h=this.view.fullHeight;u+=this.view.offsetX*s/c,o-=this.view.offsetY*a/h,s*=this.view.width/c,a*=this.view.height/h}return function(t,e,n,r,i,o,a,s){void 0===s&&(s=!1);var u,c,h=2*o/(n-e),l=2*o/(r-i),d=(n+e)/(n-e),f=(r+i)/(r-i);s?(u=-a/(a-o),c=-a*o/(a-o)):(u=-(a+o)/(a-o),c=-2*a*o/(a-o)),t[0]=h,t[1]=0,t[2]=0,t[3]=0,t[4]=0,t[5]=l,t[6]=0,t[7]=0,t[8]=d,t[9]=f,t[10]=u,t[11]=-1,t[12]=0,t[13]=0,t[14]=c,t[15]=0}(this.projectionMatrix,u,u+s,o,o-a,t,this.far,this.clipSpaceNearZ===Wn.ZERO),C(this.projectionMatrix,this.projectionMatrix,J(1,-1,1)),S(this.projectionMatrixInverse,this.projectionMatrix),this.triggerUpdate(),this},t.prototype.setOrthographic=function(t,e,n,r,i,o){var a;this.projectionMode=mr.ORTHOGRAPHIC,this.rright=e,this.left=t,this.top=n,this.bottom=r,this.near=i,this.far=o;var s=(this.rright-this.left)/(2*this.zoom),u=(this.top-this.bottom)/(2*this.zoom),c=(this.rright+this.left)/2,h=(this.top+this.bottom)/2,l=c-s,d=c+s,f=h+u,p=h-u;if(null===(a=this.view)||void 0===a?void 0:a.enabled){var g=(this.rright-this.left)/this.view.fullWidth/this.zoom,m=(this.top-this.bottom)/this.view.fullHeight/this.zoom;d=(l+=g*this.view.offsetX)+g*this.view.width,p=(f-=m*this.view.offsetY)-m*this.view.height}return this.clipSpaceNearZ===Wn.NEGATIVE_ONE?U(this.projectionMatrix,l,d,p,f,i,o):W(this.projectionMatrix,l,d,p,f,i,o),C(this.projectionMatrix,this.projectionMatrix,J(1,-1,1)),S(this.projectionMatrixInverse,this.projectionMatrix),this._getOrthoMatrix(),this.triggerUpdate(),this},t.prototype.setPosition=function(t,e,n){void 0===e&&(e=this.position[1]),void 0===n&&(n=this.position[2]);var r=Jn(t,e,n);return this._setPosition(r),this.setFocalPoint(this.focalPoint),this.triggerUpdate(),this},t.prototype.setFocalPoint=function(t,e,n){void 0===e&&(e=this.focalPoint[1]),void 0===n&&(n=this.focalPoint[2]);var r=J(0,1,0);if(this.focalPoint=Jn(t,e,n),this.trackingMode===gr.CINEMATIC){var i=rt(K(),this.focalPoint,this.position);t=i[0],e=i[1],n=i[2];var o=Q(i),a=er(Math.asin(e/o)),s=90+er(Math.atan2(n,t)),u=b();O(u,u,tr(s)),A(u,u,tr(a)),r=ct(K(),[0,1,0],u)}return S(this.matrix,H(b(),this.position,this.focalPoint,r)),this._getAxes(),this._getDistance(),this._getAngles(),this.triggerUpdate(),this},t.prototype.getDistance=function(){return this.distance},t.prototype.getDistanceVector=function(){return this.distanceVector},t.prototype.setDistance=function(t){if(this.distance===t||t<0)return this;this.distance=t,this.distance<Pr&&(this.distance=Pr),this.dollyingStep=this.distance/100;var e=K();t=this.distance;var n=this.forward,r=this.focalPoint;return e[0]=t*n[0]+r[0],e[1]=t*n[1]+r[1],e[2]=t*n[2]+r[2],this._setPosition(e),this.triggerUpdate(),this},t.prototype.setMaxDistance=function(t){return this.maxDistance=t,this},t.prototype.setMinDistance=function(t){return this.minDistance=t,this},t.prototype.setAzimuth=function(t){return this.azimuth=Qn(t),this.computeMatrix(),this._getAxes(),this.type===pr.ORBITING||this.type===pr.EXPLORING?this._getPosition():this.type===pr.TRACKING&&this._getFocalPoint(),this.triggerUpdate(),this},t.prototype.getAzimuth=function(){return this.azimuth},t.prototype.setElevation=function(t){return this.elevation=Qn(t),this.computeMatrix(),this._getAxes(),this.type===pr.ORBITING||this.type===pr.EXPLORING?this._getPosition():this.type===pr.TRACKING&&this._getFocalPoint(),this.triggerUpdate(),this},t.prototype.getElevation=function(){return this.elevation},t.prototype.setRoll=function(t){return this.roll=Qn(t),this.computeMatrix(),this._getAxes(),this.type===pr.ORBITING||this.type===pr.EXPLORING?this._getPosition():this.type===pr.TRACKING&&this._getFocalPoint(),this.triggerUpdate(),this},t.prototype.getRoll=function(){return this.roll},t.prototype._update=function(){this._getAxes(),this._getPosition(),this._getDistance(),this._getAngles(),this._getOrthoMatrix(),this.triggerUpdate()},t.prototype.computeMatrix=function(){var t=mt(gt(),[0,0,1],tr(this.roll));M(this.matrix);var e=mt(gt(),[1,0,0],tr((this.rotateWorld&&this.type!==pr.TRACKING||this.type===pr.TRACKING?1:-1)*this.elevation)),n=mt(gt(),[0,1,0],tr((this.rotateWorld&&this.type!==pr.TRACKING||this.type===pr.TRACKING?1:-1)*this.azimuth)),r=vt(gt(),n,e);r=vt(gt(),r,t);var i=F(b(),r);this.type===pr.ORBITING||this.type===pr.EXPLORING?(P(this.matrix,this.matrix,this.focalPoint),k(this.matrix,this.matrix,i),P(this.matrix,this.matrix,[0,0,this.distance])):this.type===pr.TRACKING&&(P(this.matrix,this.matrix,this.position),k(this.matrix,this.matrix,i))},t.prototype._setPosition=function(t,e,n){this.position=Jn(t,e,n);var r=this.matrix;r[12]=this.position[0],r[13]=this.position[1],r[14]=this.position[2],r[15]=1,this._getOrthoMatrix()},t.prototype._getAxes=function(){tt(this.right,Jn(pt(ft(),[1,0,0,0],this.matrix))),tt(this.up,Jn(pt(ft(),[0,1,0,0],this.matrix))),tt(this.forward,Jn(pt(ft(),[0,0,1,0],this.matrix))),ot(this.right,this.right),ot(this.up,this.up),ot(this.forward,this.forward)},t.prototype._getAngles=function(){var t=this.distanceVector[0],e=this.distanceVector[1],n=this.distanceVector[2],r=Q(this.distanceVector);if(0===r)return this.elevation=0,void(this.azimuth=0);this.type===pr.TRACKING||this.rotateWorld?(this.elevation=er(Math.asin(e/r)),this.azimuth=er(Math.atan2(-t,-n))):(this.elevation=-er(Math.asin(e/r)),this.azimuth=-er(Math.atan2(-t,-n)))},t.prototype._getPosition=function(){tt(this.position,Jn(pt(ft(),[0,0,0,1],this.matrix))),this._getDistance()},t.prototype._getFocalPoint=function(){!function(t,e,n){var r=e[0],i=e[1],o=e[2];t[0]=r*n[0]+i*n[3]+o*n[6],t[1]=r*n[1]+i*n[4]+o*n[7],t[2]=r*n[2]+i*n[5]+o*n[8]}(this.distanceVector,[0,0,-this.distance],function(t,e){return t[0]=e[0],t[1]=e[1],t[2]=e[2],t[3]=e[4],t[4]=e[5],t[5]=e[6],t[6]=e[8],t[7]=e[9],t[8]=e[10],t}(y(),this.matrix)),nt(this.focalPoint,this.position,this.distanceVector),this._getDistance()},t.prototype._getDistance=function(){this.distanceVector=rt(K(),this.focalPoint,this.position),this.distance=Q(this.distanceVector),this.dollyingStep=this.distance/100},t.prototype._getOrthoMatrix=function(){if(this.projectionMode===mr.ORTHOGRAPHIC){var t=this.position,e=mt(gt(),[0,0,1],-this.roll*Math.PI/180);z(this.orthoMatrix,e,J((this.rright-this.left)/2-t[0],(this.top-this.bottom)/2-t[1],0),J(this.zoom,this.zoom,1),t)}},t.prototype.triggerUpdate=function(){if(this.enableUpdate){var t=this.getViewTransform(),e=k(b(),this.getPerspective(),t);this.getFrustum().extractFromVPMatrix(e),this.eventEmitter.emit(kr)}},t.prototype.rotate=function(t,e,n){throw new Error(Er)},t.prototype.pan=function(t,e){throw new Error(Er)},t.prototype.dolly=function(t){throw new Error(Er)},t.prototype.createLandmark=function(t,e){throw new Error(Er)},t.prototype.gotoLandmark=function(t,e){throw new Error(Er)},t.prototype.cancelLandmarkAnimation=function(){throw new Error(Er)},t}();function Ar(t,e){if("function"!=typeof t||null!=e&&"function"!=typeof e)throw new TypeError("Expected a function");var n=function(){for(var r=[],i=0;i<arguments.length;i++)r[i]=arguments[i];var o=e?e.apply(this,r):r[0],a=n.cache;if(a.has(o))return a.get(o);var s=t.apply(this,r);return n.cache=a.set(o,s)||a,s};return n.cache=new(Ar.Cache||Map),n}Ar.Cache=Map,function(t){t[t.kUnknown=0]="kUnknown",t[t.kNumber=1]="kNumber",t[t.kPercentage=2]="kPercentage",t[t.kEms=3]="kEms",t[t.kPixels=4]="kPixels",t[t.kRems=5]="kRems",t[t.kDegrees=6]="kDegrees",t[t.kRadians=7]="kRadians",t[t.kGradians=8]="kGradians",t[t.kTurns=9]="kTurns",t[t.kMilliseconds=10]="kMilliseconds",t[t.kSeconds=11]="kSeconds",t[t.kInteger=12]="kInteger"}(xr||(xr={})),function(t){t[t.kUNumber=0]="kUNumber",t[t.kUPercent=1]="kUPercent",t[t.kULength=2]="kULength",t[t.kUAngle=3]="kUAngle",t[t.kUTime=4]="kUTime",t[t.kUOther=5]="kUOther"}(Mr||(Mr={})),function(t){t[t.kAll=0]="kAll",t[t.kNonNegative=1]="kNonNegative",t[t.kInteger=2]="kInteger",t[t.kNonNegativeInteger=3]="kNonNegativeInteger",t[t.kPositiveInteger=4]="kPositiveInteger"}(Nr||(Nr={})),function(t){t[t.kYes=0]="kYes",t[t.kNo=1]="kNo"}(Sr||(Sr={})),function(t){t[t.kYes=0]="kYes",t[t.kNo=1]="kNo"}(Tr||(Tr={}));var Or,Rr=[{name:"em",unit_type:xr.kEms},{name:"px",unit_type:xr.kPixels},{name:"deg",unit_type:xr.kDegrees},{name:"rad",unit_type:xr.kRadians},{name:"grad",unit_type:xr.kGradians},{name:"ms",unit_type:xr.kMilliseconds},{name:"s",unit_type:xr.kSeconds},{name:"rem",unit_type:xr.kRems},{name:"turn",unit_type:xr.kTurns}];!function(t){t[t.kUnknownType=0]="kUnknownType",t[t.kUnparsedType=1]="kUnparsedType",t[t.kKeywordType=2]="kKeywordType",t[t.kUnitType=3]="kUnitType",t[t.kSumType=4]="kSumType",t[t.kProductType=5]="kProductType",t[t.kNegateType=6]="kNegateType",t[t.kInvertType=7]="kInvertType",t[t.kMinType=8]="kMinType",t[t.kMaxType=9]="kMaxType",t[t.kClampType=10]="kClampType",t[t.kTransformType=11]="kTransformType",t[t.kPositionType=12]="kPositionType",t[t.kURLImageType=13]="kURLImageType",t[t.kColorType=14]="kColorType",t[t.kUnsupportedColorType=15]="kUnsupportedColorType"}(Or||(Or={}));var _r,Dr=function(t){return t?"number"===t?xr.kNumber:"percent"===t||"%"===t?xr.kPercentage:function(t){return Rr.find((function(e){return e.name===t})).unit_type}(t):xr.kUnknown},Ir=function(t){var e=1;switch(t){case xr.kPixels:case xr.kDegrees:case xr.kSeconds:break;case xr.kMilliseconds:e=.001;break;case xr.kRadians:e=180/Math.PI;break;case xr.kGradians:e=.9;break;case xr.kTurns:e=360}return e},Lr=function(t){switch(t){case xr.kNumber:case xr.kInteger:return"";case xr.kPercentage:return"%";case xr.kEms:return"em";case xr.kRems:return"rem";case xr.kPixels:return"px";case xr.kDegrees:return"deg";case xr.kRadians:return"rad";case xr.kGradians:return"grad";case xr.kMilliseconds:return"ms";case xr.kSeconds:return"s";case xr.kTurns:return"turn"}return""},jr=function(){function t(){}return t.isAngle=function(t){return t===xr.kDegrees||t===xr.kRadians||t===xr.kGradians||t===xr.kTurns},t.isLength=function(t){return t>=xr.kEms&&t<xr.kDegrees},t.isRelativeUnit=function(t){return t===xr.kPercentage||t===xr.kEms||t===xr.kRems},t.isTime=function(t){return t===xr.kSeconds||t===xr.kMilliseconds},t.prototype.toString=function(){return this.buildCSSText(Sr.kNo,Tr.kNo,"")},t.prototype.isNumericValue=function(){return this.getType()>=Or.kUnitType&&this.getType()<=Or.kClampType},t}(),zr=function(t){function e(e){var n=t.call(this)||this;return n.colorSpace=e,n}return r(e,t),e.prototype.getType=function(){return Or.kColorType},e.prototype.to=function(t){return this},e}(jr);!function(t){t[t.Constant=0]="Constant",t[t.LinearGradient=1]="LinearGradient",t[t.RadialGradient=2]="RadialGradient"}(_r||(_r={}));var Fr=function(t){function e(e,n){var r=t.call(this)||this;return r.type=e,r.value=n,r}return r(e,t),e.prototype.clone=function(){return new e(this.type,this.value)},e.prototype.buildCSSText=function(t,e,n){return n},e.prototype.getType=function(){return Or.kColorType},e}(jr),Br=function(t){function e(e){var n=t.call(this)||this;return n.value=e,n}return r(e,t),e.prototype.clone=function(){return new e(this.value)},e.prototype.getType=function(){return Or.kKeywordType},e.prototype.buildCSSText=function(t,e,n){return n+this.value},e}(jr),Gr=Ar((function(t){return void 0===t&&(t=""),t.replace(/-([a-z])/g,(function(t){return t[1].toUpperCase()}))})),Vr=function(t){return t.split("").map((function(t,e){return t.toUpperCase()===t?"".concat(0!==e?"-":"").concat(t.toLowerCase()):t})).join("")};function Ur(t){return"function"==typeof t}var Wr={d:{alias:"path"},strokeDasharray:{alias:"lineDash"},strokeWidth:{alias:"lineWidth"},textAnchor:{alias:"textAlign"},src:{alias:"img"}},Hr=Ar((function(t){var e=Gr(t),n=Wr[e];return e=(null==n?void 0:n.alias)||e})),qr=function(t,e){void 0===e&&(e="");var n="";return Number.isFinite(t)?(!function(t){if(!t)throw new Error}(Number.isNaN(t)),n="NaN"):n=t>0?"infinity":"-infinity",n+e},Yr=function(t){return function(t){switch(t){case Mr.kUNumber:return xr.kNumber;case Mr.kULength:return xr.kPixels;case Mr.kUPercent:return xr.kPercentage;case Mr.kUTime:return xr.kSeconds;case Mr.kUAngle:return xr.kDegrees;default:return xr.kUnknown}}(function(t){switch(t){case xr.kNumber:case xr.kInteger:return Mr.kUNumber;case xr.kPercentage:return Mr.kUPercent;case xr.kPixels:return Mr.kULength;case xr.kMilliseconds:case xr.kSeconds:return Mr.kUTime;case xr.kDegrees:case xr.kRadians:case xr.kGradians:case xr.kTurns:return Mr.kUAngle;default:return Mr.kUOther}}(t))},$r=function(t){function e(e,n){void 0===n&&(n=xr.kNumber);var r,i=t.call(this)||this;return r="string"==typeof n?Dr(n):n,i.unit=r,i.value=e,i}return r(e,t),e.prototype.clone=function(){return new e(this.value,this.unit)},e.prototype.equals=function(t){var e=t;return this.value===e.value&&this.unit===e.unit},e.prototype.getType=function(){return Or.kUnitType},e.prototype.convertTo=function(t){if(this.unit===t)return new e(this.value,this.unit);var n=Yr(this.unit);if(n!==Yr(t)||n===xr.kUnknown)return null;var r=Ir(this.unit)/Ir(t);return new e(this.value*r,t)},e.prototype.buildCSSText=function(t,e,n){var r;switch(this.unit){case xr.kUnknown:break;case xr.kInteger:r=Number(this.value).toFixed(0);break;case xr.kNumber:case xr.kPercentage:case xr.kEms:case xr.kRems:case xr.kPixels:case xr.kDegrees:case xr.kRadians:case xr.kGradians:case xr.kMilliseconds:case xr.kSeconds:case xr.kTurns:var i=this.value,o=Lr(this.unit);if(i<-999999||i>999999){var a=Lr(this.unit);r=!Number.isFinite(i)||Number.isNaN(i)?qr(i,a):i+(a||"")}else r="".concat(i).concat(o)}return n+=r},e}(jr),Xr=new $r(0,"px");new $r(1,"px");var Kr,Zr,Qr=new $r(0,"deg"),Jr=function(t){function e(e,n,r,i,o){void 0===i&&(i=1),void 0===o&&(o=!1);var a=t.call(this,"rgb")||this;return a.r=e,a.g=n,a.b=r,a.alpha=i,a.isNone=o,a}return r(e,t),e.prototype.clone=function(){return new e(this.r,this.g,this.b,this.alpha)},e.prototype.buildCSSText=function(t,e,n){return n+"rgba(".concat(this.r,",").concat(this.g,",").concat(this.b,",").concat(this.alpha,")")},e}(zr),ti=new Br("unset"),ei=new Br("initial"),ni=new Br("inherit"),ri={"":ti,unset:ti,initial:ei,inherit:ni},ii=function(t){return ri[t]||(ri[t]=new Br(t)),ri[t]},oi=new Jr(0,0,0,0,!0),ai=new Jr(0,0,0,0),si=Ar((function(t,e,n,r){return new Jr(t,e,n,r)}),(function(t,e,n,r){return"rgba(".concat(t,",").concat(e,",").concat(n,",").concat(r,")")})),ui=function(t,e){return void 0===e&&(e=xr.kNumber),new $r(t,e)},ci=new $r(50,"%");!function(t){t[t.Standard=0]="Standard"}(Kr||(Kr={})),function(t){t[t.ADDED=0]="ADDED",t[t.REMOVED=1]="REMOVED",t[t.Z_INDEX_CHANGED=2]="Z_INDEX_CHANGED"}(Zr||(Zr={}));var hi,li={absolutePath:[],hasArc:!1,segments:[],polygons:[],polylines:[],curve:null,totalLength:0,rect:new br(0,0,0,0)};function di(t){var e=t.type,n=t.value;return"hex"===e?"#".concat(n):"literal"===e?n:"rgb"===e?"rgb(".concat(n.join(","),")"):"rgba(".concat(n.join(","),")")}!function(t){t.COORDINATE="<coordinate>",t.COLOR="<color>",t.PAINT="<paint>",t.NUMBER="<number>",t.ANGLE="<angle>",t.OPACITY_VALUE="<opacity-value>",t.SHADOW_BLUR="<shadow-blur>",t.LENGTH="<length>",t.PERCENTAGE="<percentage>",t.LENGTH_PERCENTAGE="<length> | <percentage>",t.LENGTH_PERCENTAGE_12="[<length> | <percentage>]{1,2}",t.LENGTH_PERCENTAGE_14="[<length> | <percentage>]{1,4}",t.LIST_OF_POINTS="<list-of-points>",t.PATH="<path>",t.FILTER="<filter>",t.Z_INDEX="<z-index>",t.OFFSET_DISTANCE="<offset-distance>",t.DEFINED_PATH="<defined-path>",t.MARKER="<marker>",t.TRANSFORM="<transform>",t.TRANSFORM_ORIGIN="<transform-origin>",t.TEXT="<text>",t.TEXT_TRANSFORM="<text-transform>"}(hi||(hi={}));var fi=function(){var t={linearGradient:/^(linear\-gradient)/i,repeatingLinearGradient:/^(repeating\-linear\-gradient)/i,radialGradient:/^(radial\-gradient)/i,repeatingRadialGradient:/^(repeating\-radial\-gradient)/i,conicGradient:/^(conic\-gradient)/i,sideOrCorner:/^to (left (top|bottom)|right (top|bottom)|top (left|right)|bottom (left|right)|left|right|top|bottom)/i,extentKeywords:/^(closest\-side|closest\-corner|farthest\-side|farthest\-corner|contain|cover)/,positionKeywords:/^(left|center|right|top|bottom)/i,pixelValue:/^(-?(([0-9]*\.[0-9]+)|([0-9]+\.?)))px/,percentageValue:/^(-?(([0-9]*\.[0-9]+)|([0-9]+\.?)))\%/,emValue:/^(-?(([0-9]*\.[0-9]+)|([0-9]+\.?)))em/,angleValue:/^(-?(([0-9]*\.[0-9]+)|([0-9]+\.?)))deg/,startCall:/^\(/,endCall:/^\)/,comma:/^,/,hexColor:/^\#([0-9a-fA-F]+)/,literalColor:/^([a-zA-Z]+)/,rgbColor:/^rgb/i,rgbaColor:/^rgba/i,number:/^(([0-9]*\.[0-9]+)|([0-9]+\.?))/},e="";function n(t){throw new Error(e+": "+t)}function r(){var t=f(i);return e.length>0&&n("Invalid input not EOF"),t}function i(){return o("linear-gradient",t.linearGradient,s)||o("repeating-linear-gradient",t.repeatingLinearGradient,s)||o("radial-gradient",t.radialGradient,u)||o("repeating-radial-gradient",t.repeatingRadialGradient,u)||o("conic-gradient",t.conicGradient,u)}function o(e,r,i){return a(r,(function(r){var o=i();return o&&(b(t.comma)||n("Missing comma before color stops")),{type:e,orientation:o,colorStops:f(p)}}))}function a(e,r){var i=b(e);if(i){b(t.startCall)||n("Missing (");var o=r(i);return b(t.endCall)||n("Missing )"),o}}function s(){return y("directional",t.sideOrCorner,1)||y("angular",t.angleValue,1)}function u(){var n,r,i=c();return i&&((n=[]).push(i),r=e,b(t.comma)&&((i=c())?n.push(i):e=r)),n}function c(){var t=function(){var t=y("shape",/^(circle)/i,0);t&&(t.style=v()||h());return t}()||function(){var t=y("shape",/^(ellipse)/i,0);t&&(t.style=m()||h());return t}();if(t)t.at=l();else{var e=h();if(e){t=e;var n=l();n&&(t.at=n)}else{var r=d();r&&(t={type:"default-radial",at:r})}}return t}function h(){return y("extent-keyword",t.extentKeywords,1)}function l(){if(y("position",/^at/,0)){var t=d();return t||n("Missing positioning value"),t}}function d(){var t={x:m(),y:m()};if(t.x||t.y)return{type:"position",value:t}}function f(e){var r=e(),i=[];if(r)for(i.push(r);b(t.comma);)(r=e())?i.push(r):n("One extra comma");return i}function p(){var e=y("hex",t.hexColor,1)||a(t.rgbaColor,(function(){return{type:"rgba",value:f(g)}}))||a(t.rgbColor,(function(){return{type:"rgb",value:f(g)}}))||y("literal",t.literalColor,0);return e||n("Expected color definition"),e.length=m(),e}function g(){return b(t.number)[1]}function m(){return y("%",t.percentageValue,1)||y("position-keyword",t.positionKeywords,1)||v()}function v(){return y("px",t.pixelValue,1)||y("em",t.emValue,1)}function y(t,e,n){var r=b(e);if(r)return{type:t,value:r[n]}}function b(t){var n=/^[\n\r\t\s]+/.exec(e);n&&E(n[0].length);var r=t.exec(e);return r&&E(r[0].length),r}function E(t){e=e.substring(t)}return function(t){return e=t,r()}}();var pi=/^l\s*\(\s*([\d.]+)\s*\)\s*(.*)/i,gi=/^r\s*\(\s*([\d.]+)\s*,\s*([\d.]+)\s*,\s*([\d.]+)\s*\)\s*(.*)/i,mi=/^p\s*\(\s*([axyn])\s*\)\s*(.*)/i,vi=/[\d.]+:(#[^\s]+|[^\)]+\))/gi;var yi={left:180,top:-90,bottom:90,right:0,"left top":225,"top left":225,"left bottom":135,"bottom left":135,"right top":-45,"top right":-45,"right bottom":45,"bottom right":45},bi=Ar((function(t){var e;return e="angular"===t.type?Number(t.value):yi[t.value]||0,ui(e,"deg")})),Ei=Ar((function(t){var e=50,n=50,r="%",i="%";if("position"===(null==t?void 0:t.type)){var o=t.value,a=o.x,s=o.y;"position-keyword"===(null==a?void 0:a.type)&&("left"===a.value?e=0:"center"===a.value?e=50:"right"===a.value?e=100:"top"===a.value?n=0:"bottom"===a.value&&(n=100)),"position-keyword"===(null==s?void 0:s.type)&&("left"===s.value?e=0:"center"===s.value?n=50:"right"===s.value?e=100:"top"===s.value?n=0:"bottom"===s.value&&(n=100)),"px"!==(null==a?void 0:a.type)&&"%"!==(null==a?void 0:a.type)&&"em"!==(null==a?void 0:a.type)||(r=null==a?void 0:a.type,e=Number(a.value)),"px"!==(null==s?void 0:s.type)&&"%"!==(null==s?void 0:s.type)&&"em"!==(null==s?void 0:s.type)||(i=null==s?void 0:s.type,n=Number(s.value))}return{cx:ui(e,r),cy:ui(n,i)}})),wi=Ar((function(t){var e;if(t.indexOf("linear")>-1||t.indexOf("radial")>-1)return fi(t).map((function(t){var e=t.type,n=t.orientation,r=t.colorStops;!function(t){var e,n,r,i=t.length;t[i-1].length=null!==(e=t[i-1].length)&&void 0!==e?e:{type:"%",value:"100"},i>1&&(t[0].length=null!==(n=t[0].length)&&void 0!==n?n:{type:"%",value:"0"});for(var o=0,a=Number(t[0].length.value),s=1;s<i;s++){var u=null===(r=t[s].length)||void 0===r?void 0:r.value;if(!Pt(u)&&!Pt(a)){for(var c=1;c<s-o;c++)t[o+c].length={type:"%",value:"".concat(a+(Number(u)-a)*c/(s-o))};o=s,a=Number(u)}}}(r);var i=r.map((function(t){return{offset:ui(Number(t.length.value),"%"),color:di(t)}}));if("linear-gradient"===e)return new Fr(_r.LinearGradient,{angle:n?bi(n):Qr,steps:i});if("radial-gradient"===e&&(n||(n=[{type:"shape",value:"circle"}]),"shape"===n[0].type&&"circle"===n[0].value)){var o=Ei(n[0].at),a=o.cx,s=o.cy,u=void 0;if(n[0].style){var c=n[0].style,h=c.type,l=c.value;u="extent-keyword"===h?ii(l):ui(l,h)}return new Fr(_r.RadialGradient,{cx:a,cy:s,size:u,steps:i})}}));var n=t[0];if("("===t[1]||"("===t[2])if("l"===n){var r=pi.exec(t);if(r){var i=(null===(e=r[2].match(vi))||void 0===e?void 0:e.map((function(t){return t.split(":")})))||[];return[new Fr(_r.LinearGradient,{angle:ui(parseFloat(r[1]),"deg"),steps:i.map((function(t){var e=c(t,2),n=e[0],r=e[1];return{offset:ui(100*Number(n),"%"),color:r}}))})]}}else if("r"===n){var o=function(t){var e,n=gi.exec(t);if(n){var r=(null===(e=n[4].match(vi))||void 0===e?void 0:e.map((function(t){return t.split(":")})))||[];return{cx:ui(50,"%"),cy:ui(50,"%"),steps:r.map((function(t){var e=c(t,2),n=e[0],r=e[1];return{offset:ui(100*Number(n),"%"),color:r}}))}}return null}(t);if(o){if(!zt(o))return[new Fr(_r.RadialGradient,o)];t=o}}else if("p"===n)return function(t){var e=mi.exec(t);if(e){var n=e[1],r=e[2];switch(n){case"a":n="repeat";break;case"x":n="repeat-x";break;case"y":n="repeat-y";break;default:n="no-repeat"}return{image:r,repetition:n}}return null}(t)}));function xi(t){return t&&!!t.image}function Mi(t){return t&&!Pt(t.r)&&!Pt(t.g)&&!Pt(t.b)}var Ni=Ar((function(t){if(xi(t))return i({repetition:"repeat"},t);if(Pt(t)&&(t=""),"transparent"===t)return ai;"currentColor"===t&&(t="black");var e=wi(t);if(e)return e;var n=dn(t),r=[0,0,0,0];return null!==n&&(r[0]=n.r||0,r[1]=n.g||0,r[2]=n.b||0,r[3]=n.opacity),si.apply(void 0,h([],c(r),!1))}));function Si(t,e){if(Mi(t)&&Mi(e))return[[Number(t.r),Number(t.g),Number(t.b),Number(t.alpha)],[Number(e.r),Number(e.g),Number(e.b),Number(e.alpha)],function(t){var e=t.slice();if(e[3])for(var n=0;n<3;n++)e[n]=Math.round(Gt(e[n],0,255));return e[3]=Gt(e[3],0,1),"rgba(".concat(e.join(","),")")}]}function Ti(t,e){if(Pt(e))return ui(0,"px");if(e="".concat(e).trim().toLowerCase(),isFinite(Number(e))){if("px".search(t)>=0)return ui(Number(e),"px");if("deg".search(t)>=0)return ui(Number(e),"deg")}var n=[];e=e.replace(t,(function(t){return n.push(t),"U"+t}));var r="U("+t.source+")";return n.map((function(t){return ui(Number(e.replace(new RegExp("U"+t,"g"),"").replace(new RegExp(r,"g"),"*0")),t)}))[0]}var ki=function(t){return Ti(new RegExp("px","g"),t)},Pi=Ar(ki);Ar((function(t){return Ti(new RegExp("%","g"),t)}));var Ci=function(t){return Vt(t)||isFinite(Number(t))?ui(Number(t)||0,"px"):Ti(new RegExp("px|%|em|rem","g"),t)},Ai=Ar(Ci),Oi=function(t){return Ti(new RegExp("deg|rad|grad|turn","g"),t)},Ri=Ar(Oi);function _i(t,e,n,r,i){void 0===i&&(i=0);var o="",a=t.value||0,s=e.value||0,u=Yr(t.unit),c=t.convertTo(u),h=e.convertTo(u);return c&&h?(a=c.value,s=h.value,o=Lr(t.unit)):($r.isLength(t.unit)||$r.isLength(e.unit))&&(a=ji(t,i,n),s=ji(e,i,n),o="px"),[a,s,function(t){return r&&(t=Math.max(t,0)),t+o}]}function Di(t){var e=0;return t.unit===xr.kDegrees?e=t.value:t.unit===xr.kRadians?e=er(Number(t.value)):t.unit===xr.kTurns&&(e=360*Number(t.value)),e}function Ii(t,e){var n;return Array.isArray(t)?n=t.map((function(t){return Number(t)})):zt(t)?n=t.split(" ").map((function(t){return Number(t)})):Vt(t)&&(n=[t]),2===e?1===n.length?[n[0],n[0]]:[n[0],n[1]]:1===n.length?[n[0],n[0],n[0],n[0]]:2===n.length?[n[0],n[1],n[0],n[1]]:3===n.length?[n[0],n[1],n[2],n[1]]:[n[0],n[1],n[2],n[3]]}function Li(t){return zt(t)?t.split(" ").map((function(t){return Ai(t)})):t.map((function(t){return Ai(t.toString())}))}function ji(t,e,n){if(0===t.value)return 0;if(t.unit===xr.kPixels)return Number(t.value);if(t.unit===xr.kPercentage&&n){var r=n.nodeName===Un.GROUP?n.getLocalBounds():n.geometry.contentBounds;return t.value/100*r.halfExtents[e]*2}return 0}var zi=["blur","brightness","drop-shadow","contrast","grayscale","sepia","saturate","hue-rotate","invert"];function Fi(t){if(void 0===t&&(t=""),"none"===(t=t.toLowerCase().trim()))return[];for(var e,n=/\s*([\w-]+)\(([^)]*)\)/g,r=[],i=0;e=n.exec(t);){if(e.index!==i)return[];if(i=e.index+e[0].length,zi.indexOf(e[1])>-1&&r.push({name:e[1],params:e[2].split(" ").map((function(t){return Ti(/deg|rad|grad|turn|px|%/g,t)||Ni(t)}))}),n.lastIndex===t.length)return r}return[]}function Bi(t){return t.toString()}var Gi=function(t){return"number"==typeof t?ui(t):/^\s*[-+]?(\d*\.)?\d+\s*$/.test(t)?ui(Number(t)):ui(0)},Vi=Ar(Gi);function Ui(t,e){return[t,e,Bi]}function Wi(t,e){return function(n,r){return[n,r,function(n){return Bi(Gt(n,t,e))}]}}function Hi(t,e){if(t.length===e.length)return[t,e,function(t){return t}]}function qi(t){var e;return 0===t.parsedStyle.path.totalLength&&(t.parsedStyle.path.totalLength=Ge(t.parsedStyle.path.absolutePath,void 0,i(i({},e),{bbox:!1,length:!0})).length),t.parsedStyle.path.totalLength}function Yi(t,e){return t[0]===e[0]&&t[1]===e[1]}function $i(t,e){var n=t.prePoint,r=t.currentPoint,i=t.nextPoint,o=Math.pow(r[0]-n[0],2)+Math.pow(r[1]-n[1],2),a=Math.pow(r[0]-i[0],2)+Math.pow(r[1]-i[1],2),s=Math.pow(n[0]-i[0],2)+Math.pow(n[1]-i[1],2),u=Math.acos((o+a-s)/(2*Math.sqrt(o)*Math.sqrt(a)));if(!u||0===Math.sin(u)||Wt(u,0))return{xExtra:0,yExtra:0};var c=Math.abs(Math.atan2(i[1]-r[1],i[0]-r[0])),h=Math.abs(Math.atan2(i[0]-r[0],i[1]-r[1]));return c=c>Math.PI/2?Math.PI-c:c,h=h>Math.PI/2?Math.PI-h:h,{xExtra:Math.cos(u/2-c)*(e/2*(1/Math.sin(u/2)))-e/2||0,yExtra:Math.cos(h-u/2)*(e/2*(1/Math.sin(u/2)))-e/2||0}}function Xi(t,e){return[e[0]+(e[0]-t[0]),e[1]+(e[1]-t[1])]}Ar((function(t){return zt(t)?t.split(" ").map(Vi):t.map(Vi)}));var Ki=function(t,e){var n=t.x*e.x+t.y*e.y,r=Math.sqrt((Math.pow(t.x,2)+Math.pow(t.y,2))*(Math.pow(e.x,2)+Math.pow(e.y,2)));return(t.x*e.y-t.y*e.x<0?-1:1)*Math.acos(n/r)},Zi=function(t,e,n,r,i,o,a,s){e=Math.abs(e),n=Math.abs(n);var u=tr(r=Ht(r,360));if(t.x===a.x&&t.y===a.y)return{x:t.x,y:t.y,ellipticalArcAngle:0};if(0===e||0===n)return{x:0,y:0,ellipticalArcAngle:0};var c=(t.x-a.x)/2,h=(t.y-a.y)/2,l={x:Math.cos(u)*c+Math.sin(u)*h,y:-Math.sin(u)*c+Math.cos(u)*h},d=Math.pow(l.x,2)/Math.pow(e,2)+Math.pow(l.y,2)/Math.pow(n,2);d>1&&(e=Math.sqrt(d)*e,n=Math.sqrt(d)*n);var f=(Math.pow(e,2)*Math.pow(n,2)-Math.pow(e,2)*Math.pow(l.y,2)-Math.pow(n,2)*Math.pow(l.x,2))/(Math.pow(e,2)*Math.pow(l.y,2)+Math.pow(n,2)*Math.pow(l.x,2));f=f<0?0:f;var p=(i!==o?1:-1)*Math.sqrt(f),g=p*(e*l.y/n),m=p*(-n*l.x/e),v={x:Math.cos(u)*g-Math.sin(u)*m+(t.x+a.x)/2,y:Math.sin(u)*g+Math.cos(u)*m+(t.y+a.y)/2},y={x:(l.x-g)/e,y:(l.y-m)/n},b=Ki({x:1,y:0},y),E=Ki(y,{x:(-l.x-g)/e,y:(-l.y-m)/n});!o&&E>0?E-=2*Math.PI:o&&E<0&&(E+=2*Math.PI);var w=b+(E%=2*Math.PI)*s,x=e*Math.cos(w),M=n*Math.sin(w);return{x:Math.cos(u)*x-Math.sin(u)*M+v.x,y:Math.sin(u)*x+Math.cos(u)*M+v.y,ellipticalArcStartAngle:b,ellipticalArcEndAngle:b+E,ellipticalArcAngle:w,ellipticalArcCenter:v,resultantRx:e,resultantRy:n}};function Qi(t,e,n){void 0===n&&(n=!0);var r=t.arcParams,i=r.rx,o=void 0===i?0:i,a=r.ry,s=void 0===a?0:a,u=r.xRotation,c=r.arcFlag,h=r.sweepFlag,l=Zi({x:t.prePoint[0],y:t.prePoint[1]},o,s,u,!!c,!!h,{x:t.currentPoint[0],y:t.currentPoint[1]},e),d=Zi({x:t.prePoint[0],y:t.prePoint[1]},o,s,u,!!c,!!h,{x:t.currentPoint[0],y:t.currentPoint[1]},n?e+.005:e-.005),f=d.x-l.x,p=d.y-l.y,g=Math.sqrt(f*f+p*p);return{x:-f/g,y:-p/g}}function Ji(t){return Math.sqrt(t[0]*t[0]+t[1]*t[1])}function to(t,e){return Ji(t)*Ji(e)?(t[0]*e[0]+t[1]*e[1])/(Ji(t)*Ji(e)):1}function eo(t,e){return(t[0]*e[1]<t[1]*e[0]?-1:1)*Math.acos(to(t,e))}function no(t,e){var n=e[1],r=e[2],i=Ht(tr(e[3]),2*Math.PI),o=e[4],a=e[5],s=t[0],u=t[1],c=e[6],h=e[7],l=Math.cos(i)*(s-c)/2+Math.sin(i)*(u-h)/2,d=-1*Math.sin(i)*(s-c)/2+Math.cos(i)*(u-h)/2,f=l*l/(n*n)+d*d/(r*r);f>1&&(n*=Math.sqrt(f),r*=Math.sqrt(f));var p=n*n*(d*d)+r*r*(l*l),g=p?Math.sqrt((n*n*(r*r)-p)/p):1;o===a&&(g*=-1),isNaN(g)&&(g=0);var m=r?g*n*d/r:0,v=n?g*-r*l/n:0,y=(s+c)/2+Math.cos(i)*m-Math.sin(i)*v,b=(u+h)/2+Math.sin(i)*m+Math.cos(i)*v,E=[(l-m)/n,(d-v)/r],w=[(-1*l-m)/n,(-1*d-v)/r],x=eo([1,0],E),M=eo(E,w);return to(E,w)<=-1&&(M=Math.PI),to(E,w)>=1&&(M=0),0===a&&M>0&&(M-=2*Math.PI),1===a&&M<0&&(M+=2*Math.PI),{cx:y,cy:b,rx:Yi(t,[c,h])?0:n,ry:Yi(t,[c,h])?0:r,startAngle:x,endAngle:x+M,xRotation:i,arcFlag:o,sweepFlag:a}}var ro=function(t){if(""===t||Array.isArray(t)&&0===t.length)return{absolutePath:[],hasArc:!1,segments:[],polygons:[],polylines:[],curve:null,totalLength:0,rect:{x:0,y:0,width:0,height:0}};var e;try{e=Se(t)}catch(n){e=Se(""),console.error("[g]: Invalid SVG Path definition: ".concat(t))}!function(t){for(var e=0;e<t.length;e++){var n=t[e-1],r=t[e];if("M"===r[0]&&n){var i=n[0],o=[r[1],r[2]],a=void 0;"L"===i||"M"===i?a=[n[1],n[2]]:"C"!==i&&"A"!==i&&"Q"!==i||(a=[n[n.length-2],n[n.length-1]]),a&&Yi(o,a)&&(t.splice(e,1),e--)}}}(e);var n=function(t){for(var e=!1,n=t.length,r=0;r<n;r++){var i=t[r][0];if("C"===i||"A"===i||"Q"===i){e=!0;break}}return e}(e),r=function(t){for(var e=[],n=[],r=[],i=0;i<t.length;i++){var o=t[i],a=o[0];"M"===a?(r.length&&(n.push(r),r=[]),r.push([o[1],o[2]])):"Z"===a?r.length&&(e.push(r),r=[]):r.push([o[1],o[2]])}return r.length>0&&n.push(r),{polygons:e,polylines:n}}(e),i=r.polygons,o=r.polylines,a=function(t){for(var e=[],n=null,r=null,i=null,o=0,a=t.length,s=0;s<a;s++){var u=t[s];r=t[s+1];var c=u[0],h={command:c,prePoint:n,params:u,startTangent:null,endTangent:null,currentPoint:null,nextPoint:null,arcParams:null,box:null,cubicParams:null};switch(c){case"M":i=[u[1],u[2]],o=s;break;case"A":var l=no(n,u);h.arcParams=l}if("Z"===c)n=i,r=t[o+1];else{var d=u.length;n=[u[d-2],u[d-1]]}r&&"Z"===r[0]&&(r=t[o],e[o]&&(e[o].prePoint=n)),h.currentPoint=n,e[o]&&Yi(n,e[o].currentPoint)&&(e[o].prePoint=h.prePoint);var f=r?[r[r.length-2],r[r.length-1]]:null;h.nextPoint=f;var p=h.prePoint;if(["L","H","V"].includes(c))h.startTangent=[p[0]-n[0],p[1]-n[1]],h.endTangent=[n[0]-p[0],n[1]-p[1]];else if("Q"===c){var g=[u[1],u[2]];h.startTangent=[p[0]-g[0],p[1]-g[1]],h.endTangent=[n[0]-g[0],n[1]-g[1]]}else if("T"===c)g=Xi((y=e[s-1]).currentPoint,p),"Q"===y.command?(h.command="Q",h.startTangent=[p[0]-g[0],p[1]-g[1]],h.endTangent=[n[0]-g[0],n[1]-g[1]]):(h.command="TL",h.startTangent=[p[0]-n[0],p[1]-n[1]],h.endTangent=[n[0]-p[0],n[1]-p[1]]);else if("C"===c){var m=[u[1],u[2]],v=[u[3],u[4]];h.startTangent=[p[0]-m[0],p[1]-m[1]],h.endTangent=[n[0]-v[0],n[1]-v[1]],0===h.startTangent[0]&&0===h.startTangent[1]&&(h.startTangent=[m[0]-v[0],m[1]-v[1]]),0===h.endTangent[0]&&0===h.endTangent[1]&&(h.endTangent=[v[0]-m[0],v[1]-m[1]])}else if("S"===c){var y;m=Xi((y=e[s-1]).currentPoint,p),v=[u[1],u[2]],"C"===y.command?(h.command="C",h.startTangent=[p[0]-m[0],p[1]-m[1]],h.endTangent=[n[0]-v[0],n[1]-v[1]]):(h.command="SQ",h.startTangent=[p[0]-v[0],p[1]-v[1]],h.endTangent=[n[0]-v[0],n[1]-v[1]])}else if("A"===c){var b=Qi(h,0),E=b.x,w=b.y,x=Qi(h,1,!1),M=x.x,N=x.y;h.startTangent=[E,w],h.endTangent=[M,N]}e.push(h)}return e}(e),s=function(t,e){for(var n=[],r=[],i=[],o=0;o<t.length;o++){var a=(g=t[o]).currentPoint,s=g.params,u=g.prePoint,c=void 0;switch(g.command){case"Q":c=Bn(u[0],u[1],s[1],s[2],s[3],s[4]);break;case"C":c=In(u[0],u[1],s[1],s[2],s[3],s[4],s[5],s[6]);break;case"A":var h=g.arcParams;c=kn(h.cx,h.cy,h.rx,h.ry,h.xRotation,h.startAngle,h.endAngle);break;default:n.push(a[0]),r.push(a[1])}c&&(g.box=c,n.push(c.x,c.x+c.width),r.push(c.y,c.y+c.height)),e&&("L"===g.command||"M"===g.command)&&g.prePoint&&g.nextPoint&&i.push(g)}n=n.filter((function(t){return!Number.isNaN(t)&&t!==1/0&&t!==-1/0})),r=r.filter((function(t){return!Number.isNaN(t)&&t!==1/0&&t!==-1/0}));var l=jt(n),d=jt(r),f=Lt(n),p=Lt(r);if(0===i.length)return{x:l,y:d,width:f-l,height:p-d};for(o=0;o<i.length;o++){var g;(a=(g=i[o]).currentPoint)[0]===l?l-=$i(g,e).xExtra:a[0]===f&&(f+=$i(g,e).xExtra),a[1]===d?d-=$i(g,e).yExtra:a[1]===p&&(p+=$i(g,e).yExtra)}return{x:l,y:d,width:f-l,height:p-d}}(a,0),u=s.x,c=s.y,h=s.width,l=s.height;return{absolutePath:e,hasArc:n,segments:a,polygons:i,polylines:o,totalLength:0,rect:{x:Number.isFinite(u)?u:0,y:Number.isFinite(c)?c:0,width:Number.isFinite(h)?h:0,height:Number.isFinite(l)?l:0}}},io=Ar(ro);function oo(t){return zt(t)?io(t):ro(t)}function ao(t,e,n){var r=t.curve,i=e.curve;r&&0!==r.length||(r=Oe(t.absolutePath,!1),t.curve=r),i&&0!==i.length||(i=Oe(e.absolutePath,!1),e.curve=i);var o=[r,i];r.length!==i.length&&(o=He(r,i));var a,s,u=Ue(o[0])!==Ue(o[1])?(a=o[0],s=a.slice(1).map((function(t,e,n){return e?n[e-1].slice(-2).concat(t.slice(1)):a[0].slice(1).concat(t.slice(1))})).map((function(t){return t.map((function(e,n){return t[t.length-n-2*(1-n%2)]}))})).reverse(),[["M"].concat(s[0].slice(0,2))].concat(s.map((function(t){return["C"].concat(t.slice(2))})))):o[0].map((function(t){return Array.isArray(t)?[].concat(t):t}));return[u,Ve(o[1],u),function(t){return t}]}function so(t,e){var n;n=zt(t)?t.split(" ").map((function(t){var e=c(t.split(","),2),n=e[0],r=e[1];return[Number(n),Number(r)]})):t;var r,i,o=[],a=0,s=jn(n);n.forEach((function(t,e){n[e+1]&&((r=[0,0])[0]=a/s,i=An(t[0],t[1],n[e+1][0],n[e+1][1]),a+=i,r[1]=a/s,o.push(r))}));var u=Math.min.apply(Math,h([],c(n.map((function(t){return t[0]}))),!1)),l=Math.min.apply(Math,h([],c(n.map((function(t){return t[1]}))),!1));return e&&(e.parsedStyle.defX=u,e.parsedStyle.defY=l),{points:n,totalLength:s,segments:o}}function uo(t,e){return[t.points,e.points,function(t){return t}]}var co=null;function ho(t){return function(e){var n=0;return t.map((function(t){return t===co?e[n++]:t}))}}function lo(t){return t}var fo={matrix:["NNNNNN",[co,co,0,0,co,co,0,0,0,0,1,0,co,co,0,1],lo],matrix3d:["NNNNNNNNNNNNNNNN",lo],rotate:["A"],rotatex:["A"],rotatey:["A"],rotatez:["A"],rotate3d:["NNNA"],perspective:["L"],scale:["Nn",ho([co,co,new $r(1)]),lo],scalex:["N",ho([co,new $r(1),new $r(1)]),ho([co,new $r(1)])],scaley:["N",ho([new $r(1),co,new $r(1)]),ho([new $r(1),co])],scalez:["N",ho([new $r(1),new $r(1),co])],scale3d:["NNN",lo],skew:["Aa",null,lo],skewx:["A",null,ho([co,Qr])],skewy:["A",null,ho([Qr,co])],translate:["Tt",ho([co,co,Xr]),lo],translatex:["T",ho([co,Xr,Xr]),ho([co,Xr])],translatey:["T",ho([Xr,co,Xr]),ho([Xr,co])],translatez:["L",ho([Xr,Xr,co])],translate3d:["TTL",lo]};function po(t){if("none"===(t=(t||"none").toLowerCase().trim()))return[];for(var e,n=/\s*(\w+)\(([^)]*)\)/g,r=[],i=0;e=n.exec(t);){if(e.index!==i)return[];i=e.index+e[0].length;var o=e[1],a=fo[o];if(!a)return[];var s=e[2].split(","),u=a[0];if(u.length<s.length)return[];for(var c=[],h=0;h<u.length;h++){var l=s[h],d=u[h],f=void 0;if(void 0===(f=l?{A:function(t){return"0"===t.trim()?Qr:Ri(t)},N:Vi,T:Ai,L:Pi}[d.toUpperCase()](l):{a:Qr,n:c[0],t:Xr}[d]))return[];c.push(f)}if(r.push({t:o,d:c}),n.lastIndex===t.length)return r}return[]}function go(t){if("none"===(t=(t||"none").toLowerCase().trim()))return[];for(var e,n=/\s*(\w+)\(([^)]*)\)/g,r=[],i=0;e=n.exec(t);){if(e.index!==i)return[];i=e.index+e[0].length;var o=e[1],a=fo[o];if(!a)return[];var s=e[2].split(","),u=a[0];if(u.length<s.length)return[];for(var c=[],h=0;h<u.length;h++){var l=s[h],d=u[h],f=void 0;if(void 0===(f=l?{A:function(t){return"0"===t.trim()?Qr:Oi(t)},N:Gi,T:Ci,L:ki}[d.toUpperCase()](l):{a:Qr,n:c[0],t:Xr}[d]))return[];c.push(f)}if(r.push({t:o,d:c}),n.lastIndex===t.length)return r}return[]}function mo(t){var e,n,r,i;switch(t.t){case"rotatex":return i=tr(Di(t.d[0])),[1,0,0,0,0,Math.cos(i),Math.sin(i),0,0,-Math.sin(i),Math.cos(i),0,0,0,0,1];case"rotatey":return i=tr(Di(t.d[0])),[Math.cos(i),0,-Math.sin(i),0,0,1,0,0,Math.sin(i),0,Math.cos(i),0,0,0,0,1];case"rotate":case"rotatez":return i=tr(Di(t.d[0])),[Math.cos(i),Math.sin(i),0,0,-Math.sin(i),Math.cos(i),0,0,0,0,1,0,0,0,0,1];case"rotate3d":e=t.d[0].value,n=t.d[1].value,r=t.d[2].value,i=tr(Di(t.d[3]));var o=e*e+n*n+r*r;if(0===o)e=1,n=0,r=0;else if(1!==o){var a=Math.sqrt(o);e/=a,n/=a,r/=a}var s=Math.sin(i/2),u=s*Math.cos(i/2),c=s*s;return[1-2*(n*n+r*r)*c,2*(e*n*c+r*u),2*(e*r*c-n*u),0,2*(e*n*c-r*u),1-2*(e*e+r*r)*c,2*(n*r*c+e*u),0,2*(e*r*c+n*u),2*(n*r*c-e*u),1-2*(e*e+n*n)*c,0,0,0,0,1];case"scale":return[t.d[0].value,0,0,0,0,t.d[1].value,0,0,0,0,1,0,0,0,0,1];case"scalex":return[t.d[0].value,0,0,0,0,1,0,0,0,0,1,0,0,0,0,1];case"scaley":return[1,0,0,0,0,t.d[0].value,0,0,0,0,1,0,0,0,0,1];case"scalez":return[1,0,0,0,0,1,0,0,0,0,t.d[0].value,0,0,0,0,1];case"scale3d":return[t.d[0].value,0,0,0,0,t.d[1].value,0,0,0,0,t.d[2].value,0,0,0,0,1];case"skew":var h=tr(Di(t.d[0])),l=tr(Di(t.d[1]));return[1,Math.tan(l),0,0,Math.tan(h),1,0,0,0,0,1,0,0,0,0,1];case"skewx":return i=tr(Di(t.d[0])),[1,0,0,0,Math.tan(i),1,0,0,0,0,1,0,0,0,0,1];case"skewy":return i=tr(Di(t.d[0])),[1,Math.tan(i),0,0,0,1,0,0,0,0,1,0,0,0,0,1];case"translate":return[1,0,0,0,0,1,0,0,0,0,1,0,e=ji(t.d[0],0,null)||0,n=ji(t.d[1],0,null)||0,0,1];case"translatex":return[1,0,0,0,0,1,0,0,0,0,1,0,e=ji(t.d[0],0,null)||0,0,0,1];case"translatey":return[1,0,0,0,0,1,0,0,0,0,1,0,0,n=ji(t.d[0],0,null)||0,0,1];case"translatez":return[1,0,0,0,0,1,0,0,0,0,1,0,0,0,r=ji(t.d[0],0,null)||0,1];case"translate3d":return[1,0,0,0,0,1,0,0,0,0,1,0,e=ji(t.d[0],0,null)||0,n=ji(t.d[1],0,null)||0,r=ji(t.d[2],0,null)||0,1];case"perspective":var d=ji(t.d[0],0,null)||0;return[1,0,0,0,0,1,0,0,0,0,1,d?-1/d:0,0,0,0,1];case"matrix":return[t.d[0].value,t.d[1].value,0,0,t.d[2].value,t.d[3].value,0,0,0,0,1,0,t.d[4].value,t.d[5].value,0,1];case"matrix3d":return t.d.map((function(t){return t.value}))}}function vo(t,e){return[t[0]*e[0]+t[4]*e[1]+t[8]*e[2]+t[12]*e[3],t[1]*e[0]+t[5]*e[1]+t[9]*e[2]+t[13]*e[3],t[2]*e[0]+t[6]*e[1]+t[10]*e[2]+t[14]*e[3],t[3]*e[0]+t[7]*e[1]+t[11]*e[2]+t[15]*e[3],t[0]*e[4]+t[4]*e[5]+t[8]*e[6]+t[12]*e[7],t[1]*e[4]+t[5]*e[5]+t[9]*e[6]+t[13]*e[7],t[2]*e[4]+t[6]*e[5]+t[10]*e[6]+t[14]*e[7],t[3]*e[4]+t[7]*e[5]+t[11]*e[6]+t[15]*e[7],t[0]*e[8]+t[4]*e[9]+t[8]*e[10]+t[12]*e[11],t[1]*e[8]+t[5]*e[9]+t[9]*e[10]+t[13]*e[11],t[2]*e[8]+t[6]*e[9]+t[10]*e[10]+t[14]*e[11],t[3]*e[8]+t[7]*e[9]+t[11]*e[10]+t[15]*e[11],t[0]*e[12]+t[4]*e[13]+t[8]*e[14]+t[12]*e[15],t[1]*e[12]+t[5]*e[13]+t[9]*e[14]+t[13]*e[15],t[2]*e[12]+t[6]*e[13]+t[10]*e[14]+t[14]*e[15],t[3]*e[12]+t[7]*e[13]+t[11]*e[14]+t[15]*e[15]]}function yo(t){var e=[0,0,0],n=[1,1,1],r=[0,0,0],i=[0,0,0,1],o=[0,0,0,1];return function(t,e,n,r,i,o){if(!function(t,e){var n=e[15];if(0===n)return!1;for(var r=1/n,i=0;i<16;i++)t[i]=e[i]*r;return!0}(or,t))return!1;if(w(ar,or),ar[3]=0,ar[7]=0,ar[11]=0,ar[15]=1,Math.abs(T(ar))<1e-8)return!1;var a,s,u=or[3],c=or[7],h=or[11],l=or[12],d=or[13],f=or[14],p=or[15];if(0!==u||0!==c||0!==h){if(sr[0]=u,sr[1]=c,sr[2]=h,sr[3]=p,!S(ar,ar))return!1;N(ar,ar),pt(i,sr,ar)}else i[0]=i[1]=i[2]=0,i[3]=1;if(e[0]=l,e[1]=d,e[2]=f,s=or,(a=ur)[0][0]=s[0],a[0][1]=s[1],a[0][2]=s[2],a[1][0]=s[4],a[1][1]=s[5],a[1][2]=s[6],a[2][0]=s[8],a[2][1]=s[9],a[2][2]=s[10],n[0]=Q(ur[0]),ot(ur[0],ur[0]),r[0]=at(ur[0],ur[1]),hr(ur[1],ur[1],ur[0],1,-r[0]),n[1]=Q(ur[1]),ot(ur[1],ur[1]),r[0]/=n[1],r[1]=at(ur[0],ur[2]),hr(ur[2],ur[2],ur[0],1,-r[1]),r[2]=at(ur[1],ur[2]),hr(ur[2],ur[2],ur[1],1,-r[2]),n[2]=Q(ur[2]),ot(ur[2],ur[2]),r[1]/=n[2],r[2]/=n[2],st(cr,ur[1],ur[2]),at(ur[0],cr)<0)for(var g=0;g<3;g++)n[g]*=-1,ur[g][0]*=-1,ur[g][1]*=-1,ur[g][2]*=-1;o[0]=.5*Math.sqrt(Math.max(1+ur[0][0]-ur[1][1]-ur[2][2],0)),o[1]=.5*Math.sqrt(Math.max(1-ur[0][0]+ur[1][1]-ur[2][2],0)),o[2]=.5*Math.sqrt(Math.max(1-ur[0][0]-ur[1][1]+ur[2][2],0)),o[3]=.5*Math.sqrt(Math.max(1+ur[0][0]+ur[1][1]+ur[2][2],0)),ur[2][1]>ur[1][2]&&(o[0]=-o[0]),ur[0][2]>ur[2][0]&&(o[1]=-o[1]),ur[1][0]>ur[0][1]&&(o[2]=-o[2])}(function(t){return 0===t.length?[1,0,0,0,0,1,0,0,0,0,1,0,0,0,0,1]:t.map(mo).reduce(vo)}(t),e,n,r,i,o),[[e,n,r,o,i]]}var bo=function(){function t(t,e){for(var n=[[0,0,0,0],[0,0,0,0],[0,0,0,0],[0,0,0,0]],r=0;r<4;r++)for(var i=0;i<4;i++)for(var o=0;o<4;o++)n[r][i]+=e[r][o]*t[o][i];return n}return function(e,n,r,i,o){for(var a=[[1,0,0,0],[0,1,0,0],[0,0,1,0],[0,0,0,1]],s=0;s<4;s++)a[s][3]=o[s];for(s=0;s<3;s++)for(var u=0;u<3;u++)a[3][s]+=e[u]*a[u][s];var c=i[0],h=i[1],l=i[2],d=i[3],f=[[1,0,0,0],[0,1,0,0],[0,0,1,0],[0,0,0,1]];f[0][0]=1-2*(h*h+l*l),f[0][1]=2*(c*h-l*d),f[0][2]=2*(c*l+h*d),f[1][0]=2*(c*h+l*d),f[1][1]=1-2*(c*c+l*l),f[1][2]=2*(h*l-c*d),f[2][0]=2*(c*l-h*d),f[2][1]=2*(h*l+c*d),f[2][2]=1-2*(c*c+h*h),a=t(a,f);var p=[[1,0,0,0],[0,1,0,0],[0,0,1,0],[0,0,0,1]];for(r[2]&&(p[2][1]=r[2],a=t(a,p)),r[1]&&(p[2][1]=0,p[2][0]=r[0],a=t(a,p)),r[0]&&(p[2][0]=0,p[1][0]=r[0],a=t(a,p)),s=0;s<3;s++)for(u=0;u<3;u++)a[s][u]*=n[s];return function(t){return 0==t[0][2]&&0==t[0][3]&&0==t[1][2]&&0==t[1][3]&&0==t[2][0]&&0==t[2][1]&&1==t[2][2]&&0==t[2][3]&&0==t[3][2]&&1==t[3][3]}(a)?[a[0][0],a[0][1],a[1][0],a[1][1],a[3][0],a[3][1]]:a[0].concat(a[1],a[2],a[3])}}();function Eo(t){return t.toFixed(6).replace(".000000","")}function wo(t,e){var n,r;return t.decompositionPair!==e&&(t.decompositionPair=e,n=yo(t)),e.decompositionPair!==t&&(e.decompositionPair=t,r=yo(e)),null===n[0]||null===r[0]?[[!1],[!0],function(n){return n?e[0].d:t[0].d}]:(n[0].push(0),r[0].push(1),[n,r,function(t){var e=function(t,e,n){var r=function(t,e){for(var n=0,r=0;r<t.length;r++)n+=t[r]*e[r];return n}(t,e);r=Gt(r,-1,1);var i=[];if(1===r)i=t;else for(var o=Math.acos(r),a=1*Math.sin(n*o)/Math.sqrt(1-r*r),s=0;s<4;s++)i.push(t[s]*(Math.cos(n*o)-r*a)+e[s]*a);return i}(n[0][3],r[0][3],t[5]);return bo(t[0],t[1],t[2],e,t[4]).map(Eo).join(",")}])}function xo(t){return t.replace(/[xy]/,"")}function Mo(t){return t.replace(/(x|y|z|3d)?$/,"3d")}function No(t,e,n){var r=!1;if(!t.length||!e.length){t.length||(r=!0,t=e,e=[]);for(var i=function(n){var r=t[n],i=r.t,o=r.d,a="scale"===i.substring(0,5)?1:0;e.push({t:i,d:o.map((function(t){return"number"==typeof t?ui(a):ui(a,t.unit)}))})},o=0;o<t.length;o++)i(o)}var a,s,u=[],c=[],h=[];if(t.length!==e.length)u=[(y=wo(t,e))[0]],c=[y[1]],h=[["matrix",[y[2]]]];else for(o=0;o<t.length;o++){var l=t[o].t,d=e[o].t,f=t[o].d,p=e[o].d,g=fo[l],m=fo[d],v=void 0;if(s=d,"perspective"===(a=l)&&"perspective"===s||!("matrix"!==a&&"matrix3d"!==a||"matrix"!==s&&"matrix3d"!==s)){var y=wo([t[o]],[e[o]]);u.push(y[0]),c.push(y[1]),h.push(["matrix",[y[2]]])}else{if(l===d)v=l;else if(g[2]&&m[2]&&xo(l)===xo(d))v=xo(l),f=g[2](f),p=m[2](p);else{if(!g[1]||!m[1]||Mo(l)!==Mo(d)){u=[(y=wo(t,e))[0]],c=[y[1]],h=[["matrix",[y[2]]]];break}v=Mo(l),f=g[1](f),p=m[1](p)}for(var b=[],E=[],w=[],x=0;x<f.length;x++){y=_i(f[x],p[x],n,!1,x);b[x]=y[0],E[x]=y[1],w.push(y[2])}u.push(b),c.push(E),h.push([v,w])}}if(r){var M=u;u=c,c=M}return[u,c,function(t){return t.map((function(t,e){var n=t.map((function(t,n){return h[e][1][n](t)})).join(",");return"matrix"===h[e][0]&&16===n.split(",").length&&(h[e][0]="matrix3d"),"matrix3d"===h[e][0]&&6===n.split(",").length&&(h[e][0]="matrix"),h[e][0]+"("+n+")"})).join(" ")}]}var So=Ar((function(t){if(zt(t)){if("text-anchor"===t)return[ui(0,"px"),ui(0,"px")];var e=t.split(" ");return 1===e.length&&("top"===e[0]||"bottom"===e[0]?(e[1]=e[0],e[0]="center"):e[1]="center"),2!==e.length?null:[Ai(ko(e[0])),Ai(ko(e[1]))]}return[ui(t[0]||0,"px"),ui(t[1]||0,"px")]})),To=function(t){if(zt(t)){if("text-anchor"===t)return[ui(0,"px"),ui(0,"px")];var e=t.split(" ");return 1===e.length&&("top"===e[0]||"bottom"===e[0]?(e[1]=e[0],e[0]="center"):e[1]="center"),2!==e.length?null:[Ci(ko(e[0])),Ci(ko(e[1]))]}return[ui(t[0]||0,"px"),ui(t[1]||0,"px")]};function ko(t){return"center"===t?"50%":"left"===t||"top"===t?"0":"right"===t||"bottom"===t?"100%":t}var Po=[{n:"display",k:["none"]},{n:"opacity",int:!0,inh:!0,d:"1",syntax:hi.OPACITY_VALUE},{n:"fillOpacity",int:!0,inh:!0,d:"1",syntax:hi.OPACITY_VALUE},{n:"strokeOpacity",int:!0,inh:!0,d:"1",syntax:hi.OPACITY_VALUE},{n:"fill",int:!0,k:["none"],d:"none",syntax:hi.PAINT},{n:"fillRule",k:["nonzero","evenodd"],d:"nonzero"},{n:"stroke",int:!0,k:["none"],d:"none",syntax:hi.PAINT,l:!0},{n:"shadowType",k:["inner","outer","both"],d:"outer",l:!0},{n:"shadowColor",int:!0,syntax:hi.COLOR},{n:"shadowOffsetX",int:!0,l:!0,d:"0",syntax:hi.LENGTH_PERCENTAGE},{n:"shadowOffsetY",int:!0,l:!0,d:"0",syntax:hi.LENGTH_PERCENTAGE},{n:"shadowBlur",int:!0,l:!0,d:"0",syntax:hi.SHADOW_BLUR},{n:"lineWidth",int:!0,inh:!0,d:"1",l:!0,a:["strokeWidth"],syntax:hi.LENGTH_PERCENTAGE},{n:"increasedLineWidthForHitTesting",inh:!0,d:"0",l:!0,syntax:hi.LENGTH_PERCENTAGE},{n:"lineJoin",inh:!0,l:!0,a:["strokeLinejoin"],k:["miter","bevel","round"],d:"miter"},{n:"lineCap",inh:!0,l:!0,a:["strokeLinecap"],k:["butt","round","square"],d:"butt"},{n:"lineDash",int:!0,inh:!0,k:["none"],a:["strokeDasharray"],syntax:hi.LENGTH_PERCENTAGE_12},{n:"lineDashOffset",int:!0,inh:!0,d:"0",a:["strokeDashoffset"],syntax:hi.LENGTH_PERCENTAGE},{n:"offsetPath",syntax:hi.DEFINED_PATH},{n:"offsetDistance",int:!0,syntax:hi.OFFSET_DISTANCE},{n:"dx",int:!0,l:!0,d:"0",syntax:hi.LENGTH_PERCENTAGE},{n:"dy",int:!0,l:!0,d:"0",syntax:hi.LENGTH_PERCENTAGE},{n:"zIndex",ind:!0,int:!0,d:"0",k:["auto"],syntax:hi.Z_INDEX},{n:"visibility",k:["visible","hidden"],ind:!0,inh:!0,int:!0,d:"visible"},{n:"pointerEvents",inh:!0,k:["none","auto","stroke","fill","painted","visible","visiblestroke","visiblefill","visiblepainted","all"],d:"auto"},{n:"filter",ind:!0,l:!0,k:["none"],d:"none",syntax:hi.FILTER},{n:"clipPath",syntax:hi.DEFINED_PATH},{n:"textPath",syntax:hi.DEFINED_PATH},{n:"textPathSide",k:["left","right"],d:"left"},{n:"textPathStartOffset",l:!0,d:"0",syntax:hi.LENGTH_PERCENTAGE},{n:"transform",p:100,int:!0,k:["none"],d:"none",syntax:hi.TRANSFORM},{n:"transformOrigin",p:100,d:function(t){return t===Un.CIRCLE||t===Un.ELLIPSE?"center":t===Un.TEXT?"text-anchor":"left top"},l:!0,syntax:hi.TRANSFORM_ORIGIN},{n:"anchor",p:99,d:function(t){return t===Un.CIRCLE||t===Un.ELLIPSE?"0.5 0.5":"0 0"},l:!0,syntax:hi.LENGTH_PERCENTAGE_12},{n:"cx",int:!0,d:"0",syntax:hi.COORDINATE},{n:"cy",int:!0,d:"0",syntax:hi.COORDINATE},{n:"cz",int:!0,d:"0",syntax:hi.COORDINATE},{n:"r",int:!0,l:!0,d:"0",syntax:hi.LENGTH_PERCENTAGE},{n:"rx",int:!0,l:!0,d:"0",syntax:hi.LENGTH_PERCENTAGE},{n:"ry",int:!0,l:!0,d:"0",syntax:hi.LENGTH_PERCENTAGE},{n:"x",int:!0,d:"0",syntax:hi.COORDINATE},{n:"y",int:!0,d:"0",syntax:hi.COORDINATE},{n:"z",int:!0,d:"0",syntax:hi.COORDINATE},{n:"width",int:!0,l:!0,k:["auto","fit-content","min-content","max-content"],d:"0",syntax:hi.LENGTH_PERCENTAGE},{n:"height",int:!0,l:!0,k:["auto","fit-content","min-content","max-content"],d:"0",syntax:hi.LENGTH_PERCENTAGE},{n:"radius",int:!0,l:!0,d:"0",syntax:hi.LENGTH_PERCENTAGE_14},{n:"x1",int:!0,l:!0,syntax:hi.COORDINATE},{n:"y1",int:!0,l:!0,syntax:hi.COORDINATE},{n:"z1",int:!0,l:!0,syntax:hi.COORDINATE},{n:"x2",int:!0,l:!0,syntax:hi.COORDINATE},{n:"y2",int:!0,l:!0,syntax:hi.COORDINATE},{n:"z2",int:!0,l:!0,syntax:hi.COORDINATE},{n:"path",int:!0,l:!0,d:"",a:["d"],syntax:hi.PATH,p:50},{n:"points",int:!0,l:!0,syntax:hi.LIST_OF_POINTS,p:50},{n:"text",l:!0,d:"",syntax:hi.TEXT,p:50},{n:"textTransform",l:!0,inh:!0,k:["capitalize","uppercase","lowercase","none"],d:"none",syntax:hi.TEXT_TRANSFORM,p:51},{n:"font",l:!0},{n:"fontSize",int:!0,inh:!0,d:"16px",l:!0,syntax:hi.LENGTH_PERCENTAGE},{n:"fontFamily",l:!0,inh:!0,d:"sans-serif"},{n:"fontStyle",l:!0,inh:!0,k:["normal","italic","oblique"],d:"normal"},{n:"fontWeight",l:!0,inh:!0,k:["normal","bold","bolder","lighter"],d:"normal"},{n:"fontVariant",l:!0,inh:!0,k:["normal","small-caps"],d:"normal"},{n:"lineHeight",l:!0,syntax:hi.LENGTH,int:!0,d:"0"},{n:"letterSpacing",l:!0,syntax:hi.LENGTH,int:!0,d:"0"},{n:"miterLimit",l:!0,syntax:hi.NUMBER,d:function(t){return t===Un.PATH||t===Un.POLYGON||t===Un.POLYLINE?"4":"10"}},{n:"wordWrap",l:!0},{n:"wordWrapWidth",l:!0},{n:"maxLines",l:!0},{n:"textOverflow",l:!0,d:"clip"},{n:"leading",l:!0},{n:"textBaseline",l:!0,inh:!0,k:["top","hanging","middle","alphabetic","ideographic","bottom"],d:"alphabetic"},{n:"textAlign",l:!0,inh:!0,k:["start","center","middle","end","left","right"],d:"start"},{n:"markerStart",syntax:hi.MARKER},{n:"markerEnd",syntax:hi.MARKER},{n:"markerMid",syntax:hi.MARKER},{n:"markerStartOffset",syntax:hi.LENGTH,l:!0,int:!0,d:"0"},{n:"markerEndOffset",syntax:hi.LENGTH,l:!0,int:!0,d:"0"}],Co=Po.filter((function(t){return!!t.l})).map((function(t){return t.n})),Ao={},Oo=new WeakMap,Ro=function(){function t(t){var e=this;this.runtime=t,Po.forEach((function(t){e.registerMetadata(t)}))}return t.prototype.registerMetadata=function(t){h([t.n],c(t.a||[]),!1).forEach((function(e){Ao[e]=t}))},t.prototype.unregisterMetadata=function(t){delete Ao[t]},t.prototype.getPropertySyntax=function(t){return this.runtime.CSSPropertySyntaxFactory[t]},t.prototype.processProperties=function(t,e,n){var r=this;if(void 0===n&&(n={skipUpdateAttribute:!1,skipParse:!1,forceUpdateGeometry:!1,usedAttributes:[],memoize:!0}),!this.runtime.enableCSSParsing){Object.assign(t.attributes,e);var o=Object.keys(e),a=t.parsedStyle.clipPath,s=t.parsedStyle.offsetPath;t.parsedStyle=Object.assign(t.parsedStyle,e);var u=!!n.forceUpdateGeometry;if(!u)for(var c=0;c<Co.length;c++)if(Co[c]in e){u=!0;break}return e.fill&&(t.parsedStyle.fill=Ni(e.fill)),e.stroke&&(t.parsedStyle.stroke=Ni(e.stroke)),e.shadowColor&&(t.parsedStyle.shadowColor=Ni(e.shadowColor)),e.filter&&(t.parsedStyle.filter=Fi(e.filter)),Pt(e.radius)||(t.parsedStyle.radius=Ii(e.radius,4)),Pt(e.lineDash)||(t.parsedStyle.lineDash=Ii(e.lineDash,2)),e.points&&(t.parsedStyle.points=so(e.points,t)),""===e.path&&(t.parsedStyle.path=i({},li)),e.path&&(t.parsedStyle.path=oo(e.path),t.parsedStyle.defX=t.parsedStyle.path.rect.x,t.parsedStyle.defY=t.parsedStyle.path.rect.y),e.textTransform&&this.runtime.CSSPropertySyntaxFactory["<text-transform>"].calculator(null,null,{value:e.textTransform},t,null),e.clipPath&&this.runtime.CSSPropertySyntaxFactory["<defined-path>"].calculator("clipPath",a,e.clipPath,t,this.runtime),e.offsetPath&&this.runtime.CSSPropertySyntaxFactory["<defined-path>"].calculator("offsetPath",s,e.offsetPath,t,this.runtime),e.anchor&&(t.parsedStyle.anchor=Ii(e.anchor,2)),e.transform&&(t.parsedStyle.transform=po(e.transform)),e.transformOrigin&&(t.parsedStyle.transformOrigin=So(e.transformOrigin)),e.markerStart&&(t.parsedStyle.markerStart=this.runtime.CSSPropertySyntaxFactory["<marker>"].calculator(null,e.markerStart,e.markerStart,null,null)),e.markerEnd&&(t.parsedStyle.markerEnd=this.runtime.CSSPropertySyntaxFactory["<marker>"].calculator(null,e.markerEnd,e.markerEnd,null,null)),e.markerMid&&(t.parsedStyle.markerMid=this.runtime.CSSPropertySyntaxFactory["<marker>"].calculator("",e.markerMid,e.markerMid,null,null)),(t.nodeName!==Un.CIRCLE&&t.nodeName!==Un.ELLIPSE||Pt(e.cx)&&Pt(e.cy))&&(t.nodeName!==Un.RECT&&t.nodeName!==Un.IMAGE&&t.nodeName!==Un.GROUP&&t.nodeName!==Un.HTML&&t.nodeName!==Un.TEXT&&t.nodeName!==Un.MESH||Pt(e.x)&&Pt(e.y)&&Pt(e.z))&&(t.nodeName!==Un.LINE||Pt(e.x1)&&Pt(e.y1)&&Pt(e.z1)&&Pt(e.x2)&&Pt(e.y2)&&Pt(e.z2))||this.runtime.CSSPropertySyntaxFactory["<coordinate>"].postProcessor(t,o),Pt(e.zIndex)||this.runtime.CSSPropertySyntaxFactory["<z-index>"].postProcessor(t,o),e.path&&this.runtime.CSSPropertySyntaxFactory["<path>"].postProcessor(t,o),e.points&&this.runtime.CSSPropertySyntaxFactory["<list-of-points>"].postProcessor(t,o),Pt(e.offsetDistance)||this.runtime.CSSPropertySyntaxFactory["<offset-distance>"].postProcessor(t,o),e.transform&&this.runtime.CSSPropertySyntaxFactory["<transform>"].postProcessor(t,o),void(u&&this.updateGeometry(t))}var h=n.skipUpdateAttribute,l=n.skipParse,d=n.forceUpdateGeometry,f=n.usedAttributes,p=n.memoize,g=d,m=Object.keys(e);m.forEach((function(n){var r;h||(t.attributes[n]=e[n]),!g&&(null===(r=Ao[n])||void 0===r?void 0:r.l)&&(g=!0)})),l||m.forEach((function(e){t.computedStyle[e]=r.parseProperty(e,t.attributes[e],t,p)})),(null==f?void 0:f.length)&&(m=Array.from(new Set(m.concat(f)))),m.forEach((function(e){e in t.computedStyle&&(t.parsedStyle[e]=r.computeProperty(e,t.computedStyle[e],t,p))})),g&&this.updateGeometry(t),m.forEach((function(e){e in t.parsedStyle&&r.postProcessProperty(e,t,m)})),this.runtime.enableCSSParsing&&t.children.length&&m.forEach((function(e){e in t.parsedStyle&&r.isPropertyInheritable(e)&&t.children.forEach((function(t){t.internalSetAttribute(e,null,{skipUpdateAttribute:!0,skipParse:!0})}))}))},t.prototype.parseProperty=function(t,e,n,r){var i=Ao[t],o=e;if((""===e||Pt(e))&&(e="unset"),"unset"===e||"initial"===e||"inherit"===e)o=ii(e);else if(i){var a=i.k,s=i.syntax,u=s&&this.getPropertySyntax(s);a&&a.indexOf(e)>-1?o=ii(e):u&&(!r&&u.parserUnmemoize?o=u.parserUnmemoize(e,n):u.parser&&(o=u.parser(e,n)))}return o},t.prototype.computeProperty=function(t,e,n,r){var i=Ao[t],o="g-root"===n.id,a=e;if(i){var s=i.syntax,u=i.inh,c=i.d;if(e instanceof Br){var h=e.value;if("unset"===h&&(h=u&&!o?"inherit":"initial"),"initial"===h)Pt(c)||(e=this.parseProperty(t,Ur(c)?c(n.nodeName):c,n,r));else if("inherit"===h){var l=this.tryToResolveProperty(n,t,{inherited:!0});return Pt(l)?void this.addUnresolveProperty(n,t):l}}var d=s&&this.getPropertySyntax(s);if(d&&d.calculator){var f=n.parsedStyle[t];a=d.calculator(t,f,e,n,this.runtime)}else a=e instanceof Br?e.value:e}return a},t.prototype.postProcessProperty=function(t,e,n){var r=Ao[t];if(r&&r.syntax){var i=r.syntax&&this.getPropertySyntax(r.syntax);i&&i.postProcessor&&i.postProcessor(e,n)}},t.prototype.addUnresolveProperty=function(t,e){var n=Oo.get(t);n||(Oo.set(t,[]),n=Oo.get(t)),-1===n.indexOf(e)&&n.push(e)},t.prototype.tryToResolveProperty=function(t,e,n){if(void 0===n&&(n={}),n.inherited&&t.parentElement&&function(t,e){var n=Oo.get(t);return!n||0===n.length||n.includes(e)}(t.parentElement,e)){var r=t.parentElement.parsedStyle[e];if("unset"===r||"initial"===r||"inherit"===r)return;return r}},t.prototype.recalc=function(t){var e=Oo.get(t);if(e&&e.length){var n={};e.forEach((function(e){n[e]=t.attributes[e]})),this.processProperties(t,n),Oo.delete(t)}},t.prototype.updateGeometry=function(t){var e=t.nodeName,n=this.runtime.geometryUpdaterFactory[e];if(n){var r=t.geometry;r.contentBounds||(r.contentBounds=new dr),r.renderBounds||(r.renderBounds=new dr);var i=t.parsedStyle,o=n.update(i,t),a=o.width,s=o.height,u=o.depth,c=void 0===u?0:u,h=o.offsetX,l=void 0===h?0:h,d=o.offsetY,f=void 0===d?0:d,p=o.offsetZ,g=void 0===p?0:p,m=[Math.abs(a)/2,Math.abs(s)/2,c/2],v=i,y=v.stroke,b=v.lineWidth,E=v.increasedLineWidthForHitTesting,w=v.shadowType,x=v.shadowColor,M=v.filter,N=void 0===M?[]:M,S=v.transformOrigin,T=i.anchor;e===Un.TEXT?delete i.anchor:e===Un.MESH&&(i.anchor[2]=.5);var k=[(1-2*(T&&T[0]||0))*a/2+l,(1-2*(T&&T[1]||0))*s/2+f,(1-2*(T&&T[2]||0))*m[2]+g];r.contentBounds.update(k,m);var P=e===Un.POLYLINE||e===Un.POLYGON||e===Un.PATH?Math.SQRT2:.5;if(y&&!y.isNone){var C=((b||0)+(E||0))*P;m[0]+=C,m[1]+=C}if(r.renderBounds.update(k,m),x&&w&&"inner"!==w){var A=r.renderBounds,O=A.min,R=A.max,_=i,D=_.shadowBlur||0,I=_.shadowOffsetX||0,L=_.shadowOffsetY||0,j=O[0]-D+I,z=R[0]+D+I,F=O[1]-D+L,B=R[1]+D+L;O[0]=Math.min(O[0],j),R[0]=Math.max(R[0],z),O[1]=Math.min(O[1],F),R[1]=Math.max(R[1],B),r.renderBounds.setMinMax(O,R)}N.forEach((function(t){var e=t.name,n=t.params;if("blur"===e){var i=n[0].value;r.renderBounds.update(r.renderBounds.center,Kn(r.renderBounds.halfExtents,r.renderBounds.halfExtents,[i,i,0]))}else if("drop-shadow"===e){var o=n[0].value,a=n[1].value,s=n[2].value,u=r.renderBounds,c=u.min,h=u.max,l=c[0]-s+o,d=h[0]+s+o,f=c[1]-s+a,p=h[1]+s+a;c[0]=Math.min(c[0],l),h[0]=Math.max(h[0],d),c[1]=Math.min(c[1],f),h[1]=Math.max(h[1],p),r.renderBounds.setMinMax(c,h)}})),T=i.anchor;var G=a<0,V=s<0,U=(G?-1:1)*(S?ji(S[0],0,t):0),W=(V?-1:1)*(S?ji(S[1],1,t):0);U-=(G?-1:1)*(T&&T[0]||0)*r.contentBounds.halfExtents[0]*2,W-=(V?-1:1)*(T&&T[1]||0)*r.contentBounds.halfExtents[1]*2,t.setOrigin(U,W),this.runtime.sceneGraphService.dirtifyToRoot(t)}},t.prototype.updateSizeAttenuation=function(t,e){t.style.isSizeAttenuation?(t.style.rawLineWidth||(t.style.rawLineWidth=t.style.lineWidth),t.style.lineWidth=t.style.rawLineWidth/e,t.nodeName===Un.CIRCLE&&(t.style.rawR||(t.style.rawR=t.style.r),t.style.r=t.style.rawR/e)):(t.style.rawLineWidth&&(t.style.lineWidth=t.style.rawLineWidth,delete t.style.rawLineWidth),t.nodeName===Un.CIRCLE&&t.style.rawR&&(t.style.r=t.style.rawR,delete t.style.rawR))},t.prototype.isPropertyInheritable=function(t){var e=Ao[t];return!!e&&e.inh},t}(),_o=function(){function t(){this.parser=Ri,this.parserUnmemoize=Oi,this.parserWithCSSDisabled=null,this.mixer=Ui}return t.prototype.calculator=function(t,e,n,r){return Di(n)},t}(),Do=function(){function t(){}return t.prototype.calculator=function(t,e,n,r,i){return n instanceof Br&&(n=null),i.sceneGraphService.updateDisplayObjectDependency(t,e,n,r),"clipPath"===t&&r.forEach((function(t){0===t.childNodes.length&&i.sceneGraphService.dirtifyToRoot(t)})),n},t}(),Io=function(){function t(){this.parser=Ni,this.parserWithCSSDisabled=Ni,this.mixer=Si}return t.prototype.calculator=function(t,e,n,r){return n instanceof Br?"none"===n.value?oi:ai:n},t}(),Lo=function(){function t(){this.parser=Fi}return t.prototype.calculator=function(t,e,n){return n instanceof Br?[]:n},t}();function jo(t){var e=t.parsedStyle.fontSize;return Pt(e)?null:e}var zo=function(){function t(){this.parser=Ai,this.parserUnmemoize=Ci,this.parserWithCSSDisabled=null,this.mixer=Ui}return t.prototype.calculator=function(t,e,n,r,i){var o;if(Vt(n))return n;if(!$r.isRelativeUnit(n.unit))return n.value;var a=i.styleValueRegistry;if(n.unit===xr.kPercentage)return 0;if(n.unit===xr.kEms){if(r.parentNode){if(s=jo(r.parentNode))return s*=n.value;a.addUnresolveProperty(r,t)}else a.addUnresolveProperty(r,t);return 0}if(n.unit===xr.kRems){if(null===(o=null==r?void 0:r.ownerDocument)||void 0===o?void 0:o.documentElement){var s;if(s=jo(r.ownerDocument.documentElement))return s*=n.value;a.addUnresolveProperty(r,t)}else a.addUnresolveProperty(r,t);return 0}},t}(),Fo=function(){function t(){this.mixer=Hi}return t.prototype.parser=function(t){var e=Li(Vt(t)?[t]:t);return 1===e.length?[e[0],e[0]]:[e[0],e[1]]},t.prototype.calculator=function(t,e,n){return n.map((function(t){return t.value}))},t}(),Bo=function(){function t(){this.mixer=Hi}return t.prototype.parser=function(t){var e=Li(Vt(t)?[t]:t);return 1===e.length?[e[0],e[0],e[0],e[0]]:2===e.length?[e[0],e[1],e[0],e[1]]:3===e.length?[e[0],e[1],e[2],e[1]]:[e[0],e[1],e[2],e[3]]},t.prototype.calculator=function(t,e,n){return n.map((function(t){return t.value}))},t}(),Go=b();function Vo(t,e){var n=e.parsedStyle.defX||0,r=e.parsedStyle.defY||0;return e.resetLocalTransform(),e.setLocalPosition(n,r),t.forEach((function(t){var i=t.t,o=t.d;if("scale"===i){var a=(null==o?void 0:o.map((function(t){return t.value})))||[1,1];e.scaleLocal(a[0],a[1],1)}else if("scalex"===i){a=(null==o?void 0:o.map((function(t){return t.value})))||[1];e.scaleLocal(a[0],1,1)}else if("scaley"===i){a=(null==o?void 0:o.map((function(t){return t.value})))||[1];e.scaleLocal(1,a[0],1)}else if("scalez"===i){a=(null==o?void 0:o.map((function(t){return t.value})))||[1];e.scaleLocal(1,1,a[0])}else if("scale3d"===i){a=(null==o?void 0:o.map((function(t){return t.value})))||[1,1,1];e.scaleLocal(a[0],a[1],a[2])}else if("translate"===i){var s=o||[Xr,Xr];e.translateLocal(s[0].value,s[1].value,0)}else if("translatex"===i){s=o||[Xr];e.translateLocal(s[0].value,0,0)}else if("translatey"===i){s=o||[Xr];e.translateLocal(0,s[0].value,0)}else if("translatez"===i){s=o||[Xr];e.translateLocal(0,0,s[0].value)}else if("translate3d"===i){s=o||[Xr,Xr,Xr];e.translateLocal(s[0].value,s[1].value,s[2].value)}else if("rotate"===i){var u=o||[Qr];e.rotateLocal(0,0,Di(u[0]))}else if("rotatex"===i){u=o||[Qr];e.rotateLocal(Di(u[0]),0,0)}else if("rotatey"===i){u=o||[Qr];e.rotateLocal(0,Di(u[0]),0)}else if("rotatez"===i){u=o||[Qr];e.rotateLocal(0,0,Di(u[0]))}else if("rotate3d"===i);else if("skew"===i){var l=(null==o?void 0:o.map((function(t){return t.value})))||[0,0];e.setLocalSkew(tr(l[0]),tr(l[1]))}else if("skewx"===i){l=(null==o?void 0:o.map((function(t){return t.value})))||[0];e.setLocalSkew(tr(l[0]),e.getLocalSkew()[1])}else if("skewy"===i){l=(null==o?void 0:o.map((function(t){return t.value})))||[0];e.setLocalSkew(e.getLocalSkew()[0],tr(l[0]))}else if("matrix"===i){var d=c(o.map((function(t){return t.value})),6),f=d[0],p=d[1],g=d[2],m=d[3],v=d[4],y=d[5];e.setLocalTransform(x(Go,f,p,0,0,g,m,0,0,0,0,1,0,v+n,y+r,0,1))}else"matrix3d"===i&&(x.apply(X,h([Go],c(o.map((function(t){return t.value}))),!1)),Go[12]+=n,Go[13]+=r,e.setLocalTransform(Go))})),e.getLocalTransform()}var Uo=function(t){function e(){return null!==t&&t.apply(this,arguments)||this}return r(e,t),e.prototype.postProcessor=function(t,e){var n,r,i;switch(t.nodeName){case Un.CIRCLE:case Un.ELLIPSE:var o=t.parsedStyle,a=o.cx,s=o.cy,u=o.cz;Pt(a)||(n=a),Pt(s)||(r=s),Pt(u)||(i=u);break;case Un.LINE:var h=t.parsedStyle,l=h.x1,d=h.x2,f=h.y1,p=h.y2;n=Math.min(l,d),r=Math.min(f,p),i=0;break;case Un.RECT:case Un.IMAGE:case Un.GROUP:case Un.HTML:case Un.TEXT:case Un.MESH:Pt(t.parsedStyle.x)||(n=t.parsedStyle.x),Pt(t.parsedStyle.y)||(r=t.parsedStyle.y),Pt(t.parsedStyle.z)||(i=t.parsedStyle.z)}if(t.nodeName!==Un.PATH&&t.nodeName!==Un.POLYLINE&&t.nodeName!==Un.POLYGON&&(t.parsedStyle.defX=n||0,t.parsedStyle.defY=r||0),(!Pt(n)||!Pt(r)||!Pt(i))&&-1===e.indexOf("transform")){var g=t.parsedStyle.transform;if(g&&g.length)Vo(g,t);else{var m=c(t.getLocalPosition(),3),v=m[0],y=m[1],b=m[2];t.setLocalPosition(Pt(n)?v:n,Pt(r)?y:r,Pt(i)?b:i)}}},e}(zo),Wo=function(){function t(){}return t.prototype.calculator=function(t,e,n,r){n instanceof Br&&(n=null);var i=null==n?void 0:n.cloneNode(!0);return i&&(i.style.isMarker=!0),i},t}(),Ho=function(){function t(){this.mixer=Ui,this.parser=Vi,this.parserUnmemoize=Gi,this.parserWithCSSDisabled=null}return t.prototype.calculator=function(t,e,n){return n.value},t}(),qo=function(){function t(){this.parser=Vi,this.parserUnmemoize=Gi,this.parserWithCSSDisabled=null,this.mixer=Wi(0,1)}return t.prototype.calculator=function(t,e,n){return n.value},t.prototype.postProcessor=function(t){var e=t.parsedStyle,n=e.offsetPath,r=e.offsetDistance;if(n){var i=n.nodeName;if(i===Un.LINE||i===Un.PATH||i===Un.POLYLINE){var o=n.getPoint(r);o&&(t.parsedStyle.defX=o.x,t.parsedStyle.defY=o.y,t.setLocalPosition(o.x,o.y))}}},t}(),Yo=function(){function t(){this.parser=Vi,this.parserUnmemoize=Gi,this.parserWithCSSDisabled=null,this.mixer=Wi(0,1)}return t.prototype.calculator=function(t,e,n){return n.value},t}(),$o=function(){function t(){this.parser=oo,this.parserWithCSSDisabled=oo,this.mixer=ao}return t.prototype.calculator=function(t,e,n){return n instanceof Br&&"unset"===n.value?{absolutePath:[],hasArc:!1,segments:[],polygons:[],polylines:[],curve:null,totalLength:0,rect:new br(0,0,0,0)}:n},t.prototype.postProcessor=function(t,e){if(t.parsedStyle.defX=t.parsedStyle.path.rect.x,t.parsedStyle.defY=t.parsedStyle.path.rect.y,t.nodeName===Un.PATH&&-1===e.indexOf("transform")){var n=t.parsedStyle,r=n.defX,i=void 0===r?0:r,o=n.defY,a=void 0===o?0:o;t.setLocalPosition(i,a)}},t}(),Xo=function(){function t(){this.parser=so,this.mixer=uo}return t.prototype.postProcessor=function(t,e){if((t.nodeName===Un.POLYGON||t.nodeName===Un.POLYLINE)&&-1===e.indexOf("transform")){var n=t.parsedStyle,r=n.defX,i=n.defY;t.setLocalPosition(r,i)}},t}(),Ko=function(t){function e(){var e=t.apply(this,h([],c(arguments),!1))||this;return e.mixer=Wi(0,1/0),e}return r(e,t),e}(zo),Zo=function(){function t(){}return t.prototype.calculator=function(t,e,n,r){return n instanceof Br?"unset"===n.value?"":n.value:"".concat(n)},t.prototype.postProcessor=function(t){t.nodeValue="".concat(t.parsedStyle.text)||""},t}(),Qo=function(){function t(){}return t.prototype.calculator=function(t,e,n,r){var i=r.getAttribute("text");if(i){var o=i;"capitalize"===n.value?o=i.charAt(0).toUpperCase()+i.slice(1):"lowercase"===n.value?o=i.toLowerCase():"uppercase"===n.value&&(o=i.toUpperCase()),r.parsedStyle.text=o}return n.value},t}(),Jo={},ta=0;var ea="undefined"!=typeof window&&void 0!==window.document;function na(t){return!!t.getAttribute}function ra(t,e){var n=Number(t.parsedStyle.zIndex),r=Number(e.parsedStyle.zIndex);if(n===r){var i=t.parentNode;if(i){var o=i.childNodes||[];return o.indexOf(t)-o.indexOf(e)}}return n-r}function ia(t){var e,n=t;do{if(null===(e=n.parsedStyle)||void 0===e?void 0:e.clipPath)return n;n=n.parentElement}while(null!==n);return null}function oa(t,e){if(ea)return document.defaultView.getComputedStyle(t,null).getPropertyValue(e)}var aa={touchstart:"pointerdown",touchend:"pointerup",touchendoutside:"pointerupoutside",touchmove:"pointermove",touchcancel:"pointercancel"},sa="object"==typeof performance&&performance.now?performance:Date;function ua(t,e,n){var r=!1,i=!1,o=!!e&&!e.isNone,a=!!n&&!n.isNone;return"visiblepainted"===t||"painted"===t||"auto"===t?(r=o,i=a):"visiblefill"===t||"fill"===t?r=!0:"visiblestroke"===t||"stroke"===t?i=!0:"visible"!==t&&"all"!==t||(r=!0,i=!0),[r,i]}var ca=1,ha="object"==typeof self&&self.self==self?self:"object"==typeof global&&global.global==global?global:{},la=Date.now(),da={},fa=Date.now(),pa=function(t){if("function"!=typeof t)throw new TypeError(t+" is not a function");var e=Date.now(),n=e-fa,r=n>16?0:16-n,i=ca++;return da[i]=t,Object.keys(da).length>1||setTimeout((function(){fa=e;var t=da;da={},Object.keys(t).forEach((function(e){return t[e](ha.performance&&"function"==typeof ha.performance.now?ha.performance.now():Date.now()-la)}))}),r),i},ga=function(t){delete da[t]},ma=function(t){return"string"!=typeof t?pa:""===t?ha.requestAnimationFrame:ha[t+"RequestAnimationFrame"]},va=function(t,e){for(var n=0;void 0!==t[n];){if(e(t[n]))return t[n];n+=1}}(["","webkit","moz","ms","o"],(function(t){return!!ma(t)})),ya=ma(va),ba=function(t){return"string"!=typeof t?ga:""===t?ha.cancelAnimationFrame:ha[t+"CancelAnimationFrame"]||ha[t+"CancelRequestAnimationFrame"]}(va);ha.requestAnimationFrame=ya,ha.cancelAnimationFrame=ba;var Ea=function(){function t(){this.callbacks=[]}return t.prototype.getCallbacksNum=function(){return this.callbacks.length},t.prototype.tapPromise=function(t,e){this.callbacks.push(e)},t.prototype.promise=function(){for(var t=[],e=0;e<arguments.length;e++)t[e]=arguments[e];return Promise.all(this.callbacks.map((function(e){return e.apply(void 0,h([],c(t),!1))})))},t}(),wa=function(){function t(){this.callbacks=[]}return t.prototype.tapPromise=function(t,e){this.callbacks.push(e)},t.prototype.promise=function(){for(var t=[],e=0;e<arguments.length;e++)t[e]=arguments[e];return a(this,void 0,void 0,(function(){var e,n,r;return s(this,(function(i){switch(i.label){case 0:return this.callbacks.length?[4,(r=this.callbacks)[0].apply(r,h([],c(t),!1))]:[3,6];case 1:e=i.sent(),n=0,i.label=2;case 2:return n<this.callbacks.length-1?[4,(0,this.callbacks[n])(e)]:[3,5];case 3:e=i.sent(),i.label=4;case 4:return n++,[3,2];case 5:return[2,e];case 6:return[2,null]}}))}))},t}(),xa=function(){function t(){this.callbacks=[]}return t.prototype.tap=function(t,e){this.callbacks.push(e)},t.prototype.call=function(){var t=arguments;this.callbacks.forEach((function(e){e.apply(void 0,t)}))},t}(),Ma=function(){function t(){this.callbacks=[]}return t.prototype.tap=function(t,e){this.callbacks.push(e)},t.prototype.call=function(){if(this.callbacks.length){for(var t=arguments,e=this.callbacks[0].apply(void 0,t),n=0;n<this.callbacks.length-1;n++){e=(0,this.callbacks[n])(e)}return e}return null},t}(),Na=["serif","sans-serif","monospace","cursive","fantasy","system-ui"],Sa=/([\"\'])[^\'\"]+\1/;var Ta=function(){function t(){this.parser=po,this.parserUnmemoize=go,this.parserWithCSSDisabled=go,this.mixer=No}return t.prototype.calculator=function(t,e,n,r){return n instanceof Br?[]:n},t.prototype.postProcessor=function(t){Vo(t.parsedStyle.transform,t)},t}(),ka=function(){this.parser=So,this.parserUnmemoize=To},Pa=function(){function t(){this.parser=Vi,this.parserUnmemoize=Gi}return t.prototype.calculator=function(t,e,n,r){return n.value},t.prototype.postProcessor=function(t){if(t.parentNode){var e=t.parentNode,n=e.renderable,r=e.sortable;n&&(n.dirty=!0),r&&(r.dirty=!0,r.dirtyReason=Zr.Z_INDEX_CHANGED)}},t}(),Ca=function(){function t(){}return t.prototype.update=function(t,e){var n=t.r;return{width:2*n,height:2*n}},t}(),Aa=function(){function t(){}return t.prototype.update=function(t,e){return{width:2*t.rx,height:2*t.ry}},t}(),Oa=function(){function t(){}return t.prototype.update=function(t){var e=t.x1,n=t.y1,r=t.x2,i=t.y2,o=Math.min(e,r),a=Math.max(e,r),s=Math.min(n,i);return{width:a-o,height:Math.max(n,i)-s}},t}(),Ra=function(){function t(){}return t.prototype.update=function(t){var e=t.path.rect;return{width:e.width,height:e.height}},t}(),_a=function(){function t(){}return t.prototype.update=function(t){if(t.points&&Ot(t.points.points)){var e=t.points.points,n=Math.min.apply(Math,h([],c(e.map((function(t){return t[0]}))),!1)),r=Math.max.apply(Math,h([],c(e.map((function(t){return t[0]}))),!1)),i=Math.min.apply(Math,h([],c(e.map((function(t){return t[1]}))),!1));return{width:r-n,height:Math.max.apply(Math,h([],c(e.map((function(t){return t[1]}))),!1))-i}}return{width:0,height:0}},t}(),Da=function(){function t(){}return t.prototype.update=function(t,e){var n=t.img,r=t.width,i=void 0===r?0:r,o=t.height,a=i,s=void 0===o?0:o;return n&&!zt(n)&&(a||(a=n.width,t.width=a),s||(s=n.height,t.height=s)),{width:a,height:s}},t}(),Ia=function(){function t(t){this.globalRuntime=t}return t.prototype.isReadyToMeasure=function(t,e){var n=t.text,r=t.textAlign,i=t.textBaseline,o=t.fontSize,a=t.fontStyle,s=t.fontWeight,u=t.fontVariant,c=t.lineWidth;return n&&o&&a&&s&&u&&r&&i&&!Pt(c)},t.prototype.update=function(t,e){var n,r,i=t.text,o=t.textAlign,a=t.lineWidth,s=t.textBaseline,u=t.dx,c=t.dy;if(!this.isReadyToMeasure(t,e))return t.metrics={font:"",width:0,height:0,lines:[],lineWidths:[],lineHeight:0,maxLineWidth:0,fontProperties:{ascent:0,descent:0,fontSize:0},lineMetrics:[]},{width:0,height:0,x:0,y:0,offsetX:0,offsetY:0};var h=((null===(r=null===(n=null==e?void 0:e.ownerDocument)||void 0===n?void 0:n.defaultView)||void 0===r?void 0:r.getConfig())||{}).offscreenCanvas,l=this.globalRuntime.textService.measureText(i,t,h);t.metrics=l;var d=l.width,f=l.height,p=l.lineHeight,g=l.fontProperties,m=[d/2,f/2,0],v=[0,1],y=0;"center"===o||"middle"===o?(y=a/2,v=[.5,1]):"right"!==o&&"end"!==o||(y=a,v=[1,1]);var b=0;return"middle"===s?b=m[1]:"top"===s||"hanging"===s?b=2*m[1]:"alphabetic"===s?b=this.globalRuntime.enableCSSParsing?p-g.ascent:0:"bottom"!==s&&"ideographic"!==s||(b=0),u&&(y+=u),c&&(b+=c),t.anchor=[v[0],v[1],0],{width:2*m[0],height:2*m[1],offsetX:y,offsetY:b}},t}();var La,ja=function(){function t(e){this.eventPhase=t.prototype.NONE,this.bubbles=!0,this.cancelBubble=!0,this.cancelable=!1,this.defaultPrevented=!1,this.propagationStopped=!1,this.propagationImmediatelyStopped=!1,this.layer=new yr,this.page=new yr,this.canvas=new yr,this.viewport=new yr,this.composed=!1,this.NONE=0,this.CAPTURING_PHASE=1,this.AT_TARGET=2,this.BUBBLING_PHASE=3,this.manager=e}return Object.defineProperty(t.prototype,"name",{get:function(){return this.type},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"layerX",{get:function(){return this.layer.x},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"layerY",{get:function(){return this.layer.y},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"pageX",{get:function(){return this.page.x},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"pageY",{get:function(){return this.page.y},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"x",{get:function(){return this.canvas.x},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"y",{get:function(){return this.canvas.y},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"canvasX",{get:function(){return this.canvas.x},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"canvasY",{get:function(){return this.canvas.y},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"viewportX",{get:function(){return this.viewport.x},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"viewportY",{get:function(){return this.viewport.y},enumerable:!1,configurable:!0}),t.prototype.composedPath=function(){return!this.manager||this.path&&this.path[0]===this.target||(this.path=this.target?this.manager.propagationPath(this.target):[]),this.path},Object.defineProperty(t.prototype,"propagationPath",{get:function(){return this.composedPath()},enumerable:!1,configurable:!0}),t.prototype.preventDefault=function(){this.nativeEvent instanceof Event&&this.nativeEvent.cancelable&&this.nativeEvent.preventDefault(),this.defaultPrevented=!0},t.prototype.stopImmediatePropagation=function(){this.propagationImmediatelyStopped=!0},t.prototype.stopPropagation=function(){this.propagationStopped=!0},t.prototype.initEvent=function(){},t.prototype.initUIEvent=function(){},t.prototype.clone=function(){throw new Error(Er)},t}(),za=function(t){function e(){var e=t.apply(this,h([],c(arguments),!1))||this;return e.client=new yr,e.movement=new yr,e.offset=new yr,e.global=new yr,e.screen=new yr,e}return r(e,t),Object.defineProperty(e.prototype,"clientX",{get:function(){return this.client.x},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"clientY",{get:function(){return this.client.y},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"movementX",{get:function(){return this.movement.x},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"movementY",{get:function(){return this.movement.y},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"offsetX",{get:function(){return this.offset.x},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"offsetY",{get:function(){return this.offset.y},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"globalX",{get:function(){return this.global.x},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"globalY",{get:function(){return this.global.y},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"screenX",{get:function(){return this.screen.x},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"screenY",{get:function(){return this.screen.y},enumerable:!1,configurable:!0}),e.prototype.getModifierState=function(t){return"getModifierState"in this.nativeEvent&&this.nativeEvent.getModifierState(t)},e.prototype.initMouseEvent=function(){throw new Error(Er)},e}(ja),Fa=function(t){function e(){var e=t.apply(this,h([],c(arguments),!1))||this;return e.width=0,e.height=0,e.isPrimary=!1,e}return r(e,t),e.prototype.getCoalescedEvents=function(){return"pointermove"===this.type||"mousemove"===this.type||"touchmove"===this.type?[this]:[]},e.prototype.getPredictedEvents=function(){throw new Error("getPredictedEvents is not supported!")},e.prototype.clone=function(){return this.manager.clonePointerEvent(this)},e}(za),Ba=function(t){function e(){return null!==t&&t.apply(this,arguments)||this}return r(e,t),e.prototype.clone=function(){return this.manager.cloneWheelEvent(this)},e}(za),Ga=function(t){function e(e,n){var r=t.call(this,null)||this;return r.type=e,r.detail=n,Object.assign(r,n),r}return r(e,t),e}(ja),Va=function(){function t(){this.emitter=new g}return t.prototype.on=function(t,e,n){return this.addEventListener(t,e,n),this},t.prototype.addEventListener=function(t,e,n){var r=Xt(n)&&n||Rt(n)&&n.capture,i=Rt(n)&&n.once,o=Ur(e)?void 0:e,a=!1,s="";if(t.indexOf(":")>-1){var u=c(t.split(":"),2),l=u[0];t=u[1],s=l,a=!0}if(t=r?"".concat(t,"capture"):t,e=Ur(e)?e:e.handleEvent,a){var d=e;e=function(){for(var t,e=[],n=0;n<arguments.length;n++)e[n]=arguments[n];(null===(t=e[0].target)||void 0===t?void 0:t.name)===s&&d.apply(void 0,h([],c(e),!1))}}return i?this.emitter.once(t,e,o):this.emitter.on(t,e,o),this},t.prototype.off=function(t,e,n){return t?this.removeEventListener(t,e,n):this.removeAllEventListeners(),this},t.prototype.removeAllEventListeners=function(){this.emitter.removeAllListeners()},t.prototype.removeEventListener=function(t,e,n){var r=Xt(n)&&n||Rt(n)&&n.capture,i=Ur(e)?void 0:e;return t=r?"".concat(t,"capture"):t,e=Ur(e)?e:null==e?void 0:e.handleEvent,this.emitter.off(t,e,i),this},t.prototype.emit=function(t,e){this.dispatchEvent(new Ga(t,e))},t.prototype.dispatchEvent=function(t,e){var n,r,i;if(void 0===e&&(e=!1),!t.type)throw new Error("DisplayObject cannot propagate events outside of the Federated Events API");if(i=this.document?this:this.defaultView?this.defaultView:null===(n=this.ownerDocument)||void 0===n?void 0:n.defaultView){if(t.manager=i.getEventService()||null,!t.manager)return!1;t.defaultPrevented=!1,t.path=[],e||(t.target=this),null===(r=t.manager)||void 0===r||r.dispatchEvent(t,t.type,e)}return!t.defaultPrevented},t}(),Ua=function(t){function e(){var e=t.apply(this,h([],c(arguments),!1))||this;return e.shadow=!1,e.ownerDocument=null,e.isConnected=!1,e.baseURI="",e.childNodes=[],e.nodeType=0,e.nodeName="",e.nodeValue=null,e.parentNode=null,e}return r(e,t),e.isNode=function(t){return!!t.childNodes},Object.defineProperty(e.prototype,"textContent",{get:function(){var t,e,n="";this.nodeName===Un.TEXT&&(n+=this.style.text);try{for(var r=u(this.childNodes),i=r.next();!i.done;i=r.next()){var o=i.value;o.nodeName===Un.TEXT?n+=o.nodeValue:n+=o.textContent}}catch(e){t={error:e}}finally{try{i&&!i.done&&(e=r.return)&&e.call(r)}finally{if(t)throw t.error}}return n},set:function(t){var e=this;this.childNodes.slice().forEach((function(t){e.removeChild(t)})),this.nodeName===Un.TEXT&&(this.style.text="".concat(t))},enumerable:!1,configurable:!0}),e.prototype.getRootNode=function(t){return void 0===t&&(t={}),this.parentNode?this.parentNode.getRootNode(t):t.composed&&this.host?this.host.getRootNode(t):this},e.prototype.hasChildNodes=function(){return this.childNodes.length>0},e.prototype.isDefaultNamespace=function(t){throw new Error(Er)},e.prototype.lookupNamespaceURI=function(t){throw new Error(Er)},e.prototype.lookupPrefix=function(t){throw new Error(Er)},e.prototype.normalize=function(){throw new Error(Er)},e.prototype.isEqualNode=function(t){return this===t},e.prototype.isSameNode=function(t){return this.isEqualNode(t)},Object.defineProperty(e.prototype,"parent",{get:function(){return this.parentNode},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"parentElement",{get:function(){return null},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"nextSibling",{get:function(){return null},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"previousSibling",{get:function(){return null},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"firstChild",{get:function(){return this.childNodes.length>0?this.childNodes[0]:null},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"lastChild",{get:function(){return this.childNodes.length>0?this.childNodes[this.childNodes.length-1]:null},enumerable:!1,configurable:!0}),e.prototype.compareDocumentPosition=function(t){var n;if(t===this)return 0;for(var r=t,i=this,o=[r],a=[i];null!==(n=r.parentNode)&&void 0!==n?n:i.parentNode;)r=r.parentNode?(o.push(r.parentNode),r.parentNode):r,i=i.parentNode?(a.push(i.parentNode),i.parentNode):i;if(r!==i)return e.DOCUMENT_POSITION_DISCONNECTED|e.DOCUMENT_POSITION_IMPLEMENTATION_SPECIFIC|e.DOCUMENT_POSITION_PRECEDING;var s=o.length>a.length?o:a,u=s===o?a:o;if(s[s.length-u.length]===u[0])return s===o?e.DOCUMENT_POSITION_CONTAINED_BY|e.DOCUMENT_POSITION_FOLLOWING:e.DOCUMENT_POSITION_CONTAINS|e.DOCUMENT_POSITION_PRECEDING;for(var c=s.length-u.length,h=u.length-1;h>=0;h--){var l=u[h],d=s[c+h];if(d!==l){var f=l.parentNode.childNodes;return f.indexOf(l)<f.indexOf(d)?u===o?e.DOCUMENT_POSITION_PRECEDING:e.DOCUMENT_POSITION_FOLLOWING:s===o?e.DOCUMENT_POSITION_PRECEDING:e.DOCUMENT_POSITION_FOLLOWING}}return e.DOCUMENT_POSITION_FOLLOWING},e.prototype.contain=function(t){return this.contains(t)},e.prototype.contains=function(t){for(var e=t;e&&this!==e;)e=e.parentNode;return!!e},e.prototype.getAncestor=function(t){for(var e=this;t>0&&e;)e=e.parentNode,t--;return e},e.prototype.forEach=function(t,e){void 0===e&&(e=!1),t(this)||(e?this.childNodes.slice():this.childNodes).forEach((function(e){e.forEach(t)}))},e.DOCUMENT_POSITION_DISCONNECTED=1,e.DOCUMENT_POSITION_PRECEDING=2,e.DOCUMENT_POSITION_FOLLOWING=4,e.DOCUMENT_POSITION_CONTAINS=8,e.DOCUMENT_POSITION_CONTAINED_BY=16,e.DOCUMENT_POSITION_IMPLEMENTATION_SPECIFIC=32,e}(Va),Wa=function(){function t(t,e){var n=this;this.globalRuntime=t,this.context=e,this.emitter=new g,this.nativeHTMLMap=new WeakMap,this.cursor="default",this.mappingTable={},this.mappingState={trackingData:{}},this.eventPool=new Map,this.tmpMatrix=b(),this.tmpVec3=K(),this.onPointerDown=function(t){var e=n.createPointerEvent(t);if(n.dispatchEvent(e,"pointerdown"),"touch"===e.pointerType)n.dispatchEvent(e,"touchstart");else if("mouse"===e.pointerType||"pen"===e.pointerType){var r=2===e.button;n.dispatchEvent(e,r?"rightdown":"mousedown")}n.trackingData(t.pointerId).pressTargetsByButton[t.button]=e.composedPath(),n.freeEvent(e)},this.onPointerUp=function(t){var e,r=sa.now(),i=n.createPointerEvent(t,void 0,void 0,n.context.config.alwaysTriggerPointerEventOnCanvas?n.rootTarget:void 0);if(n.dispatchEvent(i,"pointerup"),"touch"===i.pointerType)n.dispatchEvent(i,"touchend");else if("mouse"===i.pointerType||"pen"===i.pointerType){var o=2===i.button;n.dispatchEvent(i,o?"rightup":"mouseup")}var a=n.trackingData(t.pointerId),s=n.findMountedTarget(a.pressTargetsByButton[t.button]),u=s;if(s&&!i.composedPath().includes(s)){for(var c=s;c&&!i.composedPath().includes(c);){if(i.currentTarget=c,n.notifyTarget(i,"pointerupoutside"),"touch"===i.pointerType)n.notifyTarget(i,"touchendoutside");else if("mouse"===i.pointerType||"pen"===i.pointerType){o=2===i.button;n.notifyTarget(i,o?"rightupoutside":"mouseupoutside")}Ua.isNode(c)&&(c=c.parentNode)}delete a.pressTargetsByButton[t.button],u=c}if(u){var h=n.clonePointerEvent(i,"click");h.target=u,h.path=[],a.clicksByButton[t.button]||(a.clicksByButton[t.button]={clickCount:0,target:h.target,timeStamp:r});var l=a.clicksByButton[t.button];l.target===h.target&&r-l.timeStamp<200?++l.clickCount:l.clickCount=1,l.target=h.target,l.timeStamp=r,h.detail=l.clickCount,(null===(e=i.detail)||void 0===e?void 0:e.preventClick)||(n.context.config.useNativeClickEvent||"mouse"!==h.pointerType&&"touch"!==h.pointerType||n.dispatchEvent(h,"click"),n.dispatchEvent(h,"pointertap")),n.freeEvent(h)}n.freeEvent(i)},this.onPointerMove=function(t){var e=n.createPointerEvent(t,void 0,void 0,n.context.config.alwaysTriggerPointerEventOnCanvas?n.rootTarget:void 0),r="mouse"===e.pointerType||"pen"===e.pointerType,i=n.trackingData(t.pointerId),o=n.findMountedTarget(i.overTargets);if(i.overTargets&&o!==e.target){var a="mousemove"===t.type?"mouseout":"pointerout",s=n.createPointerEvent(t,a,o||void 0);if(n.dispatchEvent(s,"pointerout"),r&&n.dispatchEvent(s,"mouseout"),!e.composedPath().includes(o)){var u=n.createPointerEvent(t,"pointerleave",o||void 0);for(u.eventPhase=u.AT_TARGET;u.target&&!e.composedPath().includes(u.target);)u.currentTarget=u.target,n.notifyTarget(u),r&&n.notifyTarget(u,"mouseleave"),Ua.isNode(u.target)&&(u.target=u.target.parentNode);n.freeEvent(u)}n.freeEvent(s)}if(o!==e.target){var c="mousemove"===t.type?"mouseover":"pointerover",h=n.clonePointerEvent(e,c);n.dispatchEvent(h,"pointerover"),r&&n.dispatchEvent(h,"mouseover");for(var l=o&&Ua.isNode(o)&&o.parentNode;l&&l!==(Ua.isNode(n.rootTarget)&&n.rootTarget.parentNode)&&l!==e.target;)l=l.parentNode;if(!l||l===(Ua.isNode(n.rootTarget)&&n.rootTarget.parentNode)){var d=n.clonePointerEvent(e,"pointerenter");for(d.eventPhase=d.AT_TARGET;d.target&&d.target!==o&&d.target!==(Ua.isNode(n.rootTarget)&&n.rootTarget.parentNode);)d.currentTarget=d.target,n.notifyTarget(d),r&&n.notifyTarget(d,"mouseenter"),Ua.isNode(d.target)&&(d.target=d.target.parentNode);n.freeEvent(d)}n.freeEvent(h)}n.dispatchEvent(e,"pointermove"),"touch"===e.pointerType&&n.dispatchEvent(e,"touchmove"),r&&(n.dispatchEvent(e,"mousemove"),n.cursor=n.getCursor(e.target)),i.overTargets=e.composedPath(),n.freeEvent(e)},this.onPointerOut=function(t){var e=n.trackingData(t.pointerId);if(e.overTargets){var r="mouse"===t.pointerType||"pen"===t.pointerType,i=n.findMountedTarget(e.overTargets),o=n.createPointerEvent(t,"pointerout",i||void 0);n.dispatchEvent(o),r&&n.dispatchEvent(o,"mouseout");var a=n.createPointerEvent(t,"pointerleave",i||void 0);for(a.eventPhase=a.AT_TARGET;a.target&&a.target!==(Ua.isNode(n.rootTarget)&&n.rootTarget.parentNode);)a.currentTarget=a.target,n.notifyTarget(a),r&&n.notifyTarget(a,"mouseleave"),Ua.isNode(a.target)&&(a.target=a.target.parentNode);e.overTargets=null,n.freeEvent(o),n.freeEvent(a)}n.cursor=null},this.onPointerOver=function(t){var e=n.trackingData(t.pointerId),r=n.createPointerEvent(t),i="mouse"===r.pointerType||"pen"===r.pointerType;n.dispatchEvent(r,"pointerover"),i&&n.dispatchEvent(r,"mouseover"),"mouse"===r.pointerType&&(n.cursor=n.getCursor(r.target));var o=n.clonePointerEvent(r,"pointerenter");for(o.eventPhase=o.AT_TARGET;o.target&&o.target!==(Ua.isNode(n.rootTarget)&&n.rootTarget.parentNode);)o.currentTarget=o.target,n.notifyTarget(o),i&&n.notifyTarget(o,"mouseenter"),Ua.isNode(o.target)&&(o.target=o.target.parentNode);e.overTargets=r.composedPath(),n.freeEvent(r),n.freeEvent(o)},this.onPointerUpOutside=function(t){var e=n.trackingData(t.pointerId),r=n.findMountedTarget(e.pressTargetsByButton[t.button]),i=n.createPointerEvent(t);if(r){for(var o=r;o;)i.currentTarget=o,n.notifyTarget(i,"pointerupoutside"),"touch"===i.pointerType||"mouse"!==i.pointerType&&"pen"!==i.pointerType||n.notifyTarget(i,2===i.button?"rightupoutside":"mouseupoutside"),Ua.isNode(o)&&(o=o.parentNode);delete e.pressTargetsByButton[t.button]}n.freeEvent(i)},this.onWheel=function(t){var e=n.createWheelEvent(t);n.dispatchEvent(e),n.freeEvent(e)},this.onClick=function(t){if(n.context.config.useNativeClickEvent){var e=n.createPointerEvent(t);n.dispatchEvent(e),n.freeEvent(e)}},this.onPointerCancel=function(t){var e=n.createPointerEvent(t,void 0,void 0,n.context.config.alwaysTriggerPointerEventOnCanvas?n.rootTarget:void 0);n.dispatchEvent(e),n.freeEvent(e)}}return t.prototype.init=function(){this.rootTarget=this.context.renderingContext.root.parentNode,this.addEventMapping("pointerdown",this.onPointerDown),this.addEventMapping("pointerup",this.onPointerUp),this.addEventMapping("pointermove",this.onPointerMove),this.addEventMapping("pointerout",this.onPointerOut),this.addEventMapping("pointerleave",this.onPointerOut),this.addEventMapping("pointercancel",this.onPointerCancel),this.addEventMapping("pointerover",this.onPointerOver),this.addEventMapping("pointerupoutside",this.onPointerUpOutside),this.addEventMapping("wheel",this.onWheel),this.addEventMapping("click",this.onClick)},t.prototype.destroy=function(){this.emitter.removeAllListeners(),this.mappingTable={},this.mappingState={},this.eventPool.clear()},t.prototype.client2Viewport=function(t){var e=this.context.contextService.getBoundingClientRect();return new yr(t.x-((null==e?void 0:e.left)||0),t.y-((null==e?void 0:e.top)||0))},t.prototype.viewport2Client=function(t){var e=this.context.contextService.getBoundingClientRect();return new yr(t.x+((null==e?void 0:e.left)||0),t.y+((null==e?void 0:e.top)||0))},t.prototype.viewport2Canvas=function(t){var e=t.x,n=t.y,r=this.rootTarget.defaultView.getCamera(),i=this.context.config,o=i.width,a=i.height,s=r.getPerspectiveInverse(),u=r.getWorldTransform(),c=k(this.tmpMatrix,u,s),h=et(this.tmpVec3,e/o*2-1,2*(1-n/a)-1,0);return ct(h,h,c),new yr(h[0],h[1])},t.prototype.canvas2Viewport=function(t){var e=this.rootTarget.defaultView.getCamera(),n=e.getPerspective(),r=e.getViewTransform(),i=k(this.tmpMatrix,n,r),o=et(this.tmpVec3,t.x,t.y,0);ct(this.tmpVec3,this.tmpVec3,i);var a=this.context.config,s=a.width,u=a.height;return new yr((o[0]+1)/2*s,(1-(o[1]+1)/2)*u)},t.prototype.setPickHandler=function(t){this.pickHandler=t},t.prototype.addEventMapping=function(t,e){this.mappingTable[t]||(this.mappingTable[t]=[]),this.mappingTable[t].push({fn:e,priority:0}),this.mappingTable[t].sort((function(t,e){return t.priority-e.priority}))},t.prototype.mapEvent=function(t){if(this.rootTarget){var e=this.mappingTable[t.type];if(e)for(var n=0,r=e.length;n<r;n++)e[n].fn(t);else console.warn("[EventService]: Event mapping not defined for ".concat(t.type))}},t.prototype.dispatchEvent=function(t,e,n){if(n){t.eventPhase=t.AT_TARGET;var r=this.rootTarget.defaultView||null;t.currentTarget=r,this.notifyListeners(t,e)}else t.propagationStopped=!1,t.propagationImmediatelyStopped=!1,this.propagate(t,e);this.emitter.emit(e||t.type,t)},t.prototype.propagate=function(t,e){if(t.target){var n=t.composedPath();t.eventPhase=t.CAPTURING_PHASE;for(var r=n.length-1;r>=1;r--)if(t.currentTarget=n[r],this.notifyTarget(t,e),t.propagationStopped||t.propagationImmediatelyStopped)return;if(t.eventPhase=t.AT_TARGET,t.currentTarget=t.target,this.notifyTarget(t,e),!t.propagationStopped&&!t.propagationImmediatelyStopped){var i=n.indexOf(t.currentTarget);t.eventPhase=t.BUBBLING_PHASE;for(r=i+1;r<n.length;r++)if(t.currentTarget=n[r],this.notifyTarget(t,e),t.propagationStopped||t.propagationImmediatelyStopped)return}}},t.prototype.propagationPath=function(t){var e=[t],n=this.rootTarget.defaultView||null;if(n&&n===t)return e.unshift(n.document),e;for(var r=0;r<2048&&t!==this.rootTarget;r++)Ua.isNode(t)&&t.parentNode&&(e.push(t.parentNode),t=t.parentNode);return n&&e.push(n),e},t.prototype.hitTest=function(t){var e=t.viewportX,n=t.viewportY,r=this.context.config,i=r.width,o=r.height,a=r.disableHitTesting;return e<0||n<0||e>i||n>o?null:!a&&this.pickHandler(t)||this.rootTarget||null},t.prototype.isNativeEventFromCanvas=function(t){var e,n=this.context.contextService.getDomElement(),r=null===(e=t.nativeEvent)||void 0===e?void 0:e.target;if(r){if(r===n)return!0;if(n&&n.contains)return n.contains(r)}return!!t.nativeEvent.composedPath&&t.nativeEvent.composedPath().indexOf(n)>-1},t.prototype.getExistedHTML=function(t){var e,n;if(t.nativeEvent.composedPath)try{for(var r=u(t.nativeEvent.composedPath()),i=r.next();!i.done;i=r.next()){var o=i.value,a=this.nativeHTMLMap.get(o);if(a)return a}}catch(t){e={error:t}}finally{try{i&&!i.done&&(n=r.return)&&n.call(r)}finally{if(e)throw e.error}}return null},t.prototype.pickTarget=function(t){return this.hitTest({clientX:t.clientX,clientY:t.clientY,viewportX:t.viewportX,viewportY:t.viewportY,x:t.canvasX,y:t.canvasY})},t.prototype.createPointerEvent=function(t,e,n,r){var i=this.allocateEvent(Fa);this.copyPointerData(t,i),this.copyMouseData(t,i),this.copyData(t,i),i.nativeEvent=t.nativeEvent,i.originalEvent=t;var o=this.getExistedHTML(i);return i.target=null!=n?n:o||this.isNativeEventFromCanvas(i)&&this.pickTarget(i)||r,"string"==typeof e&&(i.type=e),i},t.prototype.createWheelEvent=function(t){var e=this.allocateEvent(Ba);this.copyWheelData(t,e),this.copyMouseData(t,e),this.copyData(t,e),e.nativeEvent=t.nativeEvent,e.originalEvent=t;var n=this.getExistedHTML(e);return e.target=n||this.isNativeEventFromCanvas(e)&&this.pickTarget(e),e},t.prototype.trackingData=function(t){return this.mappingState.trackingData[t]||(this.mappingState.trackingData[t]={pressTargetsByButton:{},clicksByButton:{},overTarget:null}),this.mappingState.trackingData[t]},t.prototype.cloneWheelEvent=function(t){var e=this.allocateEvent(Ba);return e.nativeEvent=t.nativeEvent,e.originalEvent=t.originalEvent,this.copyWheelData(t,e),this.copyMouseData(t,e),this.copyData(t,e),e.target=t.target,e.path=t.composedPath().slice(),e.type=t.type,e},t.prototype.clonePointerEvent=function(t,e){var n=this.allocateEvent(Fa);return n.nativeEvent=t.nativeEvent,n.originalEvent=t.originalEvent,this.copyPointerData(t,n),this.copyMouseData(t,n),this.copyData(t,n),n.target=t.target,n.path=t.composedPath().slice(),n.type=null!=e?e:n.type,n},t.prototype.copyPointerData=function(t,e){e.pointerId=t.pointerId,e.width=t.width,e.height=t.height,e.isPrimary=t.isPrimary,e.pointerType=t.pointerType,e.pressure=t.pressure,e.tangentialPressure=t.tangentialPressure,e.tiltX=t.tiltX,e.tiltY=t.tiltY,e.twist=t.twist},t.prototype.copyMouseData=function(t,e){e.altKey=t.altKey,e.button=t.button,e.buttons=t.buttons,e.ctrlKey=t.ctrlKey,e.metaKey=t.metaKey,e.shiftKey=t.shiftKey,e.client.copyFrom(t.client),e.movement.copyFrom(t.movement),e.canvas.copyFrom(t.canvas),e.screen.copyFrom(t.screen),e.global.copyFrom(t.global),e.offset.copyFrom(t.offset)},t.prototype.copyWheelData=function(t,e){e.deltaMode=t.deltaMode,e.deltaX=t.deltaX,e.deltaY=t.deltaY,e.deltaZ=t.deltaZ},t.prototype.copyData=function(t,e){e.isTrusted=t.isTrusted,e.timeStamp=sa.now(),e.type=t.type,e.detail=t.detail,e.view=t.view,e.page.copyFrom(t.page),e.viewport.copyFrom(t.viewport)},t.prototype.allocateEvent=function(t){this.eventPool.has(t)||this.eventPool.set(t,[]);var e=this.eventPool.get(t).pop()||new t(this);return e.eventPhase=e.NONE,e.currentTarget=null,e.path=[],e.target=null,e},t.prototype.freeEvent=function(t){if(t.manager!==this)throw new Error("It is illegal to free an event not managed by this EventBoundary!");var e=t.constructor;this.eventPool.has(e)||this.eventPool.set(e,[]),this.eventPool.get(e).push(t)},t.prototype.notifyTarget=function(t,e){e=null!=e?e:t.type;var n=t.eventPhase===t.CAPTURING_PHASE||t.eventPhase===t.AT_TARGET?"".concat(e,"capture"):e;this.notifyListeners(t,n),t.eventPhase===t.AT_TARGET&&this.notifyListeners(t,e)},t.prototype.notifyListeners=function(t,e){var n=t.currentTarget.emitter,r=n._events[e];if(r)if("fn"in r)r.once&&n.removeListener(e,r.fn,void 0,!0),r.fn.call(t.currentTarget||r.context,t);else for(var i=0;i<r.length&&!t.propagationImmediatelyStopped;i++)r[i].once&&n.removeListener(e,r[i].fn,void 0,!0),r[i].fn.call(t.currentTarget||r[i].context,t)},t.prototype.findMountedTarget=function(t){if(!t)return null;for(var e=t[t.length-1],n=t.length-2;n>=0;n--){var r=t[n];if(!(r===this.rootTarget||Ua.isNode(r)&&r.parentNode===e))break;e=t[n]}return e},t.prototype.getCursor=function(t){for(var e=t;e;){var n=na(e)&&e.getAttribute("cursor");if(n)return n;e=Ua.isNode(e)&&e.parentNode}},t}(),Ha=function(){function t(){}return t.prototype.getOrCreateCanvas=function(t,e){if(this.canvas)return this.canvas;if(t||us.offscreenCanvas)this.canvas=t||us.offscreenCanvas,this.context=this.canvas.getContext("2d",i({willReadFrequently:!0},e));else try{this.canvas=new window.OffscreenCanvas(0,0),this.context=this.canvas.getContext("2d",i({willReadFrequently:!0},e)),this.context&&this.context.measureText||(this.canvas=document.createElement("canvas"),this.context=this.canvas.getContext("2d"))}catch(t){this.canvas=document.createElement("canvas"),this.context=this.canvas.getContext("2d",i({willReadFrequently:!0},e))}return this.canvas.width=10,this.canvas.height=10,this.canvas},t.prototype.getOrCreateContext=function(t,e){return this.context||this.getOrCreateCanvas(t,e),this.context},t}();!function(t){t[t.CAMERA_CHANGED=0]="CAMERA_CHANGED",t[t.DISPLAY_OBJECT_CHANGED=1]="DISPLAY_OBJECT_CHANGED",t[t.NONE=2]="NONE"}(La||(La={}));var qa,Ya=function(){function t(t,e){this.globalRuntime=t,this.context=e,this.inited=!1,this.stats={total:0,rendered:0},this.zIndexCounter=0,this.hooks={init:new xa,initAsync:new Ea,dirtycheck:new Ma,cull:new Ma,beginFrame:new xa,beforeRender:new xa,render:new xa,afterRender:new xa,endFrame:new xa,destroy:new xa,pick:new wa,pickSync:new Ma,pointerDown:new xa,pointerUp:new xa,pointerMove:new xa,pointerOut:new xa,pointerOver:new xa,pointerWheel:new xa,pointerCancel:new xa,click:new xa}}return t.prototype.init=function(t){var e=this,n=i(i({},this.globalRuntime),this.context);this.context.renderingPlugins.forEach((function(t){t.apply(n,e.globalRuntime)})),this.hooks.init.call(),0===this.hooks.initAsync.getCallbacksNum()?(this.inited=!0,t()):this.hooks.initAsync.promise().then((function(){e.inited=!0,t()}))},t.prototype.getStats=function(){return this.stats},t.prototype.disableDirtyRectangleRendering=function(){return!this.context.config.renderer.getConfig().enableDirtyRectangleRendering||this.context.renderingContext.renderReasons.has(La.CAMERA_CHANGED)},t.prototype.render=function(t,e){var n=this;this.stats.total=0,this.stats.rendered=0,this.zIndexCounter=0;var r=this.context.renderingContext;if(this.globalRuntime.sceneGraphService.syncHierarchy(r.root),this.globalRuntime.sceneGraphService.triggerPendingEvents(),r.renderReasons.size&&this.inited){r.dirtyRectangleRenderingDisabled=this.disableDirtyRectangleRendering();var i=1===r.renderReasons.size&&r.renderReasons.has(La.CAMERA_CHANGED),o=!t.disableRenderHooks||!(t.disableRenderHooks&&i);o&&this.renderDisplayObject(r.root,t,r),this.hooks.beginFrame.call(),o&&r.renderListCurrentFrame.forEach((function(t){n.hooks.beforeRender.call(t),n.hooks.render.call(t),n.hooks.afterRender.call(t)})),this.hooks.endFrame.call(),r.renderListCurrentFrame=[],r.renderReasons.clear(),e()}},t.prototype.renderDisplayObject=function(t,e,n){var r=this,i=e.renderer.getConfig(),o=i.enableDirtyCheck,a=i.enableCulling;this.globalRuntime.enableCSSParsing&&this.globalRuntime.styleValueRegistry.recalc(t);var s=t.renderable,u=o?s.dirty||n.dirtyRectangleRenderingDisabled?t:null:t;if(u){var c=a?this.hooks.cull.call(u,this.context.camera):u;c&&(this.stats.rendered++,n.renderListCurrentFrame.push(c))}t.renderable.dirty=!1,t.sortable.renderOrder=this.zIndexCounter++,this.stats.total++;var h=t.sortable;h.dirty&&(this.sort(t,h),h.dirty=!1,h.dirtyChildren=[],h.dirtyReason=void 0),(h.sorted||t.childNodes).forEach((function(t){r.renderDisplayObject(t,e,n)}))},t.prototype.sort=function(t,e){e.sorted&&e.dirtyReason!==Zr.Z_INDEX_CHANGED?e.dirtyChildren.forEach((function(n){if(-1===t.childNodes.indexOf(n)){var r=e.sorted.indexOf(n);r>=0&&e.sorted.splice(r,1)}else if(0===e.sorted.length)e.sorted.push(n);else{var i=function(t,e){for(var n=0,r=t.length;n<r;){var i=n+r>>>1;ra(t[i],e)<0?n=i+1:r=i}return n}(e.sorted,n);e.sorted.splice(i,0,n)}})):e.sorted=t.childNodes.slice().sort(ra)},t.prototype.destroy=function(){this.inited=!1,this.hooks.destroy.call(),this.globalRuntime.sceneGraphService.clearPendingEvents()},t.prototype.dirtify=function(){this.context.renderingContext.renderReasons.add(La.DISPLAY_OBJECT_CHANGED)},t}(),$a=/\[\s*(.*)=(.*)\s*\]/,Xa=function(){function t(){}return t.prototype.selectOne=function(t,e){var n=this;if(t.startsWith("."))return e.find((function(e){return((null==e?void 0:e.classList)||[]).indexOf(n.getIdOrClassname(t))>-1}));if(t.startsWith("#"))return e.find((function(e){return e.id===n.getIdOrClassname(t)}));if(t.startsWith("[")){var r=this.getAttribute(t),i=r.name,o=r.value;return i?e.find((function(t){return e!==t&&("name"===i?t.name===o:n.attributeToString(t,i)===o)})):null}return e.find((function(n){return e!==n&&n.nodeName===t}))},t.prototype.selectAll=function(t,e){var n=this;if(t.startsWith("."))return e.findAll((function(r){return e!==r&&((null==r?void 0:r.classList)||[]).indexOf(n.getIdOrClassname(t))>-1}));if(t.startsWith("#"))return e.findAll((function(r){return e!==r&&r.id===n.getIdOrClassname(t)}));if(t.startsWith("[")){var r=this.getAttribute(t),i=r.name,o=r.value;return i?e.findAll((function(t){return e!==t&&("name"===i?t.name===o:n.attributeToString(t,i)===o)})):[]}return e.findAll((function(n){return e!==n&&n.nodeName===t}))},t.prototype.is=function(t,e){if(t.startsWith("."))return e.className===this.getIdOrClassname(t);if(t.startsWith("#"))return e.id===this.getIdOrClassname(t);if(t.startsWith("[")){var n=this.getAttribute(t),r=n.name,i=n.value;return"name"===r?e.name===i:this.attributeToString(e,r)===i}return e.nodeName===t},t.prototype.getIdOrClassname=function(t){return t.substring(1)},t.prototype.getAttribute=function(t){var e=t.match($a),n="",r="";return e&&e.length>2&&(n=e[1].replace(/"/g,""),r=e[2].replace(/"/g,"")),{name:n,value:r}},t.prototype.attributeToString=function(t,e){if(!t.getAttribute)return"";var n=t.getAttribute(e);return Pt(n)?"":n.toString?n.toString():""},t}(),Ka=function(t){function e(e,n,r,i,o,a,s,u){var c=t.call(this,null)||this;return c.relatedNode=n,c.prevValue=r,c.newValue=i,c.attrName=o,c.attrChange=a,c.prevParsedValue=s,c.newParsedValue=u,c.type=e,c}return r(e,t),e.ADDITION=2,e.MODIFICATION=1,e.REMOVAL=3,e}(ja);function Za(t){var e=t.renderable;e&&(e.renderBoundsDirty=!0,e.boundsDirty=!0)}!function(t){t.REPARENT="reparent",t.DESTROY="destroy",t.ATTR_MODIFIED="DOMAttrModified",t.INSERTED="DOMNodeInserted",t.REMOVED="removed",t.MOUNTED="DOMNodeInsertedIntoDocument",t.UNMOUNTED="DOMNodeRemovedFromDocument",t.BOUNDS_CHANGED="bounds-changed",t.CULLED="culled"}(qa||(qa={}));var Qa,Ja,ts,es=new Ka(qa.REPARENT,null,"","","",0,"",""),ns=function(){function t(t){var e,n,r,i,o,a,s,u,c=this;this.runtime=t,this.pendingEvents=[],this.boundsChangedEvent=new Ga(qa.BOUNDS_CHANGED),this.rotate=(e=gt(),function(t,n,r,i){void 0===r&&(r=0),void 0===i&&(i=0),"number"==typeof n&&(n=J(n,r,i));var o=t.transformable;if(null!==t.parentNode&&t.parentNode.transformable){var a=gt();bt(a,n[0],n[1],n[2]);var s=c.getRotation(t),u=c.getRotation(t.parentNode);wt(e,u),yt(e,e),vt(a,e,a),vt(o.localRotation,a,s),Mt(o.localRotation,o.localRotation),c.dirtifyLocal(t,o)}else c.rotateLocal(t,n)}),this.rotateLocal=(n=gt(),function(t,e,r,i){void 0===r&&(r=0),void 0===i&&(i=0),"number"==typeof e&&(e=J(e,r,i));var o=t.transformable;bt(n,e[0],e[1],e[2]),xt(o.localRotation,o.localRotation,n),c.dirtifyLocal(t,o)}),this.setEulerAngles=(r=gt(),function(t,e,n,i){void 0===n&&(n=0),void 0===i&&(i=0),"number"==typeof e&&(e=J(e,n,i));var o=t.transformable;if(null!==t.parentNode&&t.parentNode.transformable){bt(o.localRotation,e[0],e[1],e[2]);var a=c.getRotation(t.parentNode);wt(r,yt(gt(),a)),xt(o.localRotation,o.localRotation,r),c.dirtifyLocal(t,o)}else c.setLocalEulerAngles(t,e)}),this.translateLocal=function(t,e,n,r){void 0===n&&(n=0),void 0===r&&(r=0),"number"==typeof e&&(e=J(e,n,r));var i=t.transformable;ht(e,K())||(function(t,e,n){var r=n[0],i=n[1],o=n[2],a=n[3],s=e[0],u=e[1],c=e[2],h=i*c-o*u,l=o*s-r*c,d=r*u-i*s,f=i*d-o*l,p=o*h-r*d,g=r*l-i*h,m=2*a;h*=m,l*=m,d*=m,f*=2,p*=2,g*=2,t[0]=s+h+f,t[1]=u+l+p,t[2]=c+d+g}(e,e,i.localRotation),nt(i.localPosition,i.localPosition,e),c.dirtifyLocal(t,i))},this.setPosition=(i=b(),o=K(),function(t,e){var n=t.transformable;if(o[0]=e[0],o[1]=e[1],o[2]=e[2]||0,!ht(c.getPosition(t),o)){if(tt(n.position,o),null!==t.parentNode&&t.parentNode.transformable){var r=t.parentNode.transformable;w(i,r.worldTransform),S(i,i),ct(n.localPosition,o,i)}else tt(n.localPosition,o);c.dirtifyLocal(t,n)}}),this.setLocalPosition=function(){var t=K();return function(e,n){var r=e.transformable;t[0]=n[0],t[1]=n[1],t[2]=n[2]||0,ht(r.localPosition,t)||(tt(r.localPosition,t),c.dirtifyLocal(e,r))}}(),this.translate=(a=K(),s=K(),u=K(),function(t,e,n,r){void 0===n&&(n=0),void 0===r&&(r=0),"number"==typeof e&&(e=et(s,e,n,r)),ht(e,a)||(nt(u,c.getPosition(t),e),c.setPosition(t,u))}),this.setRotation=function(){var t=gt();return function(e,n,r,i,o){var a=e.transformable;if("number"==typeof n&&(n=Et(n,r,i,o)),null!==e.parentNode&&e.parentNode.transformable){var s=c.getRotation(e.parentNode);wt(t,s),yt(t,t),vt(a.localRotation,t,n),Mt(a.localRotation,a.localRotation),c.dirtifyLocal(e,a)}else c.setLocalRotation(e,n)}},this.displayObjectDependencyMap=new WeakMap,this.calcLocalTransform=function(){var t=b(),e=K(),n=Et(0,0,0,1);return function(r){if(0!==r.localSkew[0]||0!==r.localSkew[1]){if(z(r.localTransform,r.localRotation,r.localPosition,J(1,1,1),r.origin),0!==r.localSkew[0]||0!==r.localSkew[1]){var i=M(t);i[4]=Math.tan(r.localSkew[0]),i[1]=Math.tan(r.localSkew[1]),k(r.localTransform,r.localTransform,i)}var o=z(t,n,e,r.localScale,r.origin);k(r.localTransform,r.localTransform,o)}else z(r.localTransform,r.localRotation,r.localPosition,r.localScale,r.origin)}}()}return t.prototype.matches=function(t,e){return this.runtime.sceneGraphSelector.is(t,e)},t.prototype.querySelector=function(t,e){return this.runtime.sceneGraphSelector.selectOne(t,e)},t.prototype.querySelectorAll=function(t,e){return this.runtime.sceneGraphSelector.selectAll(t,e)},t.prototype.attach=function(t,e,n){var r,i,o=!1;t.parentNode&&(o=t.parentNode!==e,this.detach(t)),t.parentNode=e,Pt(n)?t.parentNode.childNodes.push(t):t.parentNode.childNodes.splice(n,0,t);var a=e.sortable;((null===(r=null==a?void 0:a.sorted)||void 0===r?void 0:r.length)||(null===(i=t.style)||void 0===i?void 0:i.zIndex))&&(-1===a.dirtyChildren.indexOf(t)&&a.dirtyChildren.push(t),a.dirty=!0,a.dirtyReason=Zr.ADDED);var s=t.transformable;s&&this.dirtifyWorld(t,s),s.frozen&&this.unfreezeParentToRoot(t),o&&t.dispatchEvent(es)},t.prototype.detach=function(t){var e,n;if(t.parentNode){var r=t.transformable,i=t.parentNode.sortable;((null===(e=null==i?void 0:i.sorted)||void 0===e?void 0:e.length)||(null===(n=t.style)||void 0===n?void 0:n.zIndex))&&(-1===i.dirtyChildren.indexOf(t)&&i.dirtyChildren.push(t),i.dirty=!0,i.dirtyReason=Zr.REMOVED);var o=t.parentNode.childNodes.indexOf(t);o>-1&&t.parentNode.childNodes.splice(o,1),r&&this.dirtifyWorld(t,r),t.parentNode=null}},t.prototype.getOrigin=function(t){return t.transformable.origin},t.prototype.setOrigin=function(t,e,n,r){void 0===n&&(n=0),void 0===r&&(r=0),"number"==typeof e&&(e=[e,n,r]);var i=t.transformable;if(e[0]!==i.origin[0]||e[1]!==i.origin[1]||e[2]!==i.origin[2]){var o=i.origin;o[0]=e[0],o[1]=e[1],o[2]=e[2]||0,this.dirtifyLocal(t,i)}},t.prototype.setLocalEulerAngles=function(t,e,n,r){void 0===n&&(n=0),void 0===r&&(r=0),"number"==typeof e&&(e=J(e,n,r));var i=t.transformable;bt(i.localRotation,e[0],e[1],e[2]),this.dirtifyLocal(t,i)},t.prototype.scaleLocal=function(t,e){var n=t.transformable;!function(t,e,n){t[0]=e[0]*n[0],t[1]=e[1]*n[1],t[2]=e[2]*n[2]}(n.localScale,n.localScale,J(e[0],e[1],e[2]||1)),this.dirtifyLocal(t,n)},t.prototype.setLocalScale=function(t,e){var n=t.transformable,r=J(e[0],e[1],e[2]||n.localScale[2]);ht(r,n.localScale)||(tt(n.localScale,r),this.dirtifyLocal(t,n))},t.prototype.setLocalRotation=function(t,e,n,r,i){"number"==typeof e&&(e=Et(e,n,r,i));var o=t.transformable;wt(o.localRotation,e),this.dirtifyLocal(t,o)},t.prototype.setLocalSkew=function(t,e,n){"number"==typeof e&&(e=function(t,e){var n=new v(2);return n[0]=t,n[1]=e,n}(e,n));var r=t.transformable;!function(t,e){t[0]=e[0],t[1]=e[1]}(r.localSkew,e),this.dirtifyLocal(t,r)},t.prototype.dirtifyLocal=function(t,e){e.localDirtyFlag||(e.localDirtyFlag=!0,e.dirtyFlag||this.dirtifyWorld(t,e))},t.prototype.dirtifyWorld=function(t,e){e.dirtyFlag||this.unfreezeParentToRoot(t),this.dirtifyWorldInternal(t,e),this.dirtifyToRoot(t,!0)},t.prototype.triggerPendingEvents=function(){var t=this,e=new Set,n=function(n,r){n.isConnected&&!e.has(n.entity)&&(t.boundsChangedEvent.detail=r,t.boundsChangedEvent.target=n,n.isMutationObserved?n.dispatchEvent(t.boundsChangedEvent):n.ownerDocument.defaultView.dispatchEvent(t.boundsChangedEvent,!0),e.add(n.entity))};this.pendingEvents.forEach((function(t){var e=c(t,2),r=e[0],i=e[1];i.affectChildren?r.forEach((function(t){n(t,i)})):n(r,i)})),this.clearPendingEvents(),e.clear()},t.prototype.clearPendingEvents=function(){this.pendingEvents=[]},t.prototype.dirtifyToRoot=function(t,e){void 0===e&&(e=!1);var n=t;for(n.renderable&&(n.renderable.dirty=!0);n;)Za(n),n=n.parentNode;e&&t.forEach((function(t){Za(t)})),this.informDependentDisplayObjects(t),this.pendingEvents.push([t,{affectChildren:e}])},t.prototype.updateDisplayObjectDependency=function(t,e,n,r){if(e&&e!==n){var i=this.displayObjectDependencyMap.get(e);if(i&&i[t]){var o=i[t].indexOf(r);i[t].splice(o,1)}}if(n){var a=this.displayObjectDependencyMap.get(n);a||(this.displayObjectDependencyMap.set(n,{}),a=this.displayObjectDependencyMap.get(n)),a[t]||(a[t]=[]),a[t].push(r)}},t.prototype.informDependentDisplayObjects=function(t){var e=this,n=this.displayObjectDependencyMap.get(t);n&&Object.keys(n).forEach((function(t){n[t].forEach((function(n){e.dirtifyToRoot(n,!0),n.dispatchEvent(new Ka(qa.ATTR_MODIFIED,n,e,e,t,Ka.MODIFICATION,e,e)),n.isCustomElement&&n.isConnected&&n.attributeChangedCallback&&n.attributeChangedCallback(t,e,e)}))}))},t.prototype.getPosition=function(t){var e=t.transformable;return I(e.position,this.getWorldTransform(t,e))},t.prototype.getRotation=function(t){var e=t.transformable;return j(e.rotation,this.getWorldTransform(t,e))},t.prototype.getScale=function(t){var e=t.transformable;return L(e.scaling,this.getWorldTransform(t,e))},t.prototype.getWorldTransform=function(t,e){return void 0===e&&(e=t.transformable),e.localDirtyFlag||e.dirtyFlag?(t.parentNode&&t.parentNode.transformable&&this.getWorldTransform(t.parentNode),this.sync(t,e),e.worldTransform):e.worldTransform},t.prototype.getLocalPosition=function(t){return t.transformable.localPosition},t.prototype.getLocalRotation=function(t){return t.transformable.localRotation},t.prototype.getLocalScale=function(t){return t.transformable.localScale},t.prototype.getLocalSkew=function(t){return t.transformable.localSkew},t.prototype.getLocalTransform=function(t){var e=t.transformable;return e.localDirtyFlag&&(this.calcLocalTransform(e),e.localDirtyFlag=!1),e.localTransform},t.prototype.setLocalTransform=function(t,e){var n=I(K(),e),r=j(gt(),e),i=L(K(),e);this.setLocalScale(t,i),this.setLocalPosition(t,n),this.setLocalRotation(t,r)},t.prototype.resetLocalTransform=function(t){this.setLocalScale(t,[1,1,1]),this.setLocalPosition(t,[0,0,0]),this.setLocalEulerAngles(t,[0,0,0]),this.setLocalSkew(t,[0,0])},t.prototype.getTransformedGeometryBounds=function(t,e,n){void 0===e&&(e=!1);var r=this.getGeometryBounds(t,e);if(dr.isEmpty(r))return null;var i=n||new dr;return i.setFromTransformedAABB(r,this.getWorldTransform(t)),i},t.prototype.getGeometryBounds=function(t,e){void 0===e&&(e=!1);var n=t.geometry;return(e?n.renderBounds:n.contentBounds||null)||new dr},t.prototype.getBounds=function(t,e){var n=this;void 0===e&&(e=!1);var r=t.renderable;if(!r.boundsDirty&&!e&&r.bounds)return r.bounds;if(!r.renderBoundsDirty&&e&&r.renderBounds)return r.renderBounds;var i=e?r.renderBounds:r.bounds,o=this.getTransformedGeometryBounds(t,e,i);if(t.childNodes.forEach((function(t){var r=n.getBounds(t,e);r&&(o?o.add(r):(o=i||new dr).update(r.center,r.halfExtents))})),e){var a=ia(t);if(a){var s=a.parsedStyle.clipPath.getBounds(e);o?s&&(o=s.intersection(o)):o=s}}return o||(o=new dr),o&&(e?r.renderBounds=o:r.bounds=o),e?r.renderBoundsDirty=!1:r.boundsDirty=!1,o},t.prototype.getLocalBounds=function(t){if(t.parentNode){var e=b();t.parentNode.transformable&&(e=S(b(),this.getWorldTransform(t.parentNode)));var n=this.getBounds(t);if(!dr.isEmpty(n)){var r=new dr;return r.setFromTransformedAABB(n,e),r}}return this.getBounds(t)},t.prototype.getBoundingClientRect=function(t){var e,n,r,i=this.getGeometryBounds(t);dr.isEmpty(i)||(r=new dr).setFromTransformedAABB(i,this.getWorldTransform(t));var o=null===(n=null===(e=t.ownerDocument)||void 0===e?void 0:e.defaultView)||void 0===n?void 0:n.getContextService().getBoundingClientRect();if(r){var a=c(r.getMin(),2),s=a[0],u=a[1],h=c(r.getMax(),2),l=h[0],d=h[1];return new br(s+((null==o?void 0:o.left)||0),u+((null==o?void 0:o.top)||0),l-s,d-u)}return new br((null==o?void 0:o.left)||0,(null==o?void 0:o.top)||0,0,0)},t.prototype.dirtifyWorldInternal=function(t,e){var n=this;if(!e.dirtyFlag){e.dirtyFlag=!0,e.frozen=!1,t.childNodes.forEach((function(t){var e=t.transformable;e.dirtyFlag||n.dirtifyWorldInternal(t,e)}));var r=t.renderable;r&&(r.renderBoundsDirty=!0,r.boundsDirty=!0,r.dirty=!0)}},t.prototype.syncHierarchy=function(t){var e=t.transformable;if(!e.frozen){e.frozen=!0,(e.localDirtyFlag||e.dirtyFlag)&&this.sync(t,e);for(var n=t.childNodes,r=0;r<n.length;r++)this.syncHierarchy(n[r])}},t.prototype.sync=function(t,e){if(e.localDirtyFlag&&(this.calcLocalTransform(e),e.localDirtyFlag=!1),e.dirtyFlag){var n=t.parentNode,r=n&&n.transformable;null!==n&&r?k(e.worldTransform,r.worldTransform,e.localTransform):w(e.worldTransform,e.localTransform),e.dirtyFlag=!1}},t.prototype.unfreezeParentToRoot=function(t){for(var e=t.parentNode;e;){var n=e.transformable;n&&(n.frozen=!1),e=e.parentNode}},t}(),rs={MetricsString:"|ÉqÅ",BaselineSymbol:"M",BaselineMultiplier:1.4,HeightMultiplier:2,Newlines:[10,13],BreakingSpaces:[9,32,8192,8193,8194,8195,8196,8197,8198,8200,8201,8202,8287,12288]},is=/[a-zA-Z0-9\u00C0-\u00D6\u00D8-\u00f6\u00f8-\u00ff!"#$%&'()*+,-./:;]/,os=new RegExp("".concat(/[!%),.:;?\]}¢°·'""†‡›℃∶、。〃〆〕〗〞﹚﹜!"%'),.:;?!]}~]/.source,"|").concat(/[!),.:;?\]}¢·–—'"•"、。〆〞〕〉》」︰︱︲︳﹐﹑﹒﹓﹔﹕﹖﹘﹚﹜!),.:;?︶︸︺︼︾﹀﹂﹗]|}、]/.source,"|").concat(/[)\]}〕〉》」』】〙〗〟'"⦆»ヽヾーァィゥェォッャュョヮヵヶぁぃぅぇぉっゃゅょゎゕゖㇰㇱㇲㇳㇴㇵㇶㇷㇸㇹㇺㇻㇼㇽㇾㇿ々〻‐゠–〜?!‼⁇⁈⁉・、:;,。.]/.source,"|").concat(/[!%),.:;?\]}¢°'"†‡℃〆〈《「『〕!%),.:;?]}]/.source)),as=new RegExp("".concat(/[$(£¥·'"〈《「『【〔〖〝﹙﹛$(.[{£¥]/.source,"|").concat(/[([{£¥'"‵〈《「『〔〝︴﹙﹛({︵︷︹︻︽︿﹁﹃﹏]/.source,"|").concat(/[([{〔〈《「『【〘〖〝'"⦅«—...‥〳〴〵]/.source,"|").concat(/[$([{£¥'"々〇〉》」〔$([{⦆¥₩#]/.source)),ss=function(){function t(t){var e=this;this.runtime=t,this.fontMetricsCache={},this.shouldBreakByKinsokuShorui=function(t,n){return!e.isBreakingSpace(n)&&!(!t||!as.exec(n)&&!os.exec(t))},this.trimByKinsokuShorui=function(t){var e=h([],c(t),!1),n=e[e.length-2];if(!n)return t;var r=n[n.length-1];return e[e.length-2]=n.slice(0,-1),e[e.length-1]=r+e[e.length-1],e}}return t.prototype.measureFont=function(t,e){if(this.fontMetricsCache[t])return this.fontMetricsCache[t];var n={ascent:0,descent:0,fontSize:0},r=this.runtime.offscreenCanvasCreator.getOrCreateCanvas(e),i=this.runtime.offscreenCanvasCreator.getOrCreateContext(e,{willReadFrequently:!0});i.font=t;var o=rs.MetricsString+rs.BaselineSymbol,a=Math.ceil(i.measureText(o).width),s=Math.ceil(i.measureText(rs.BaselineSymbol).width),u=rs.HeightMultiplier*s;s=s*rs.BaselineMultiplier|0,r.width=a,r.height=u,i.fillStyle="#f00",i.fillRect(0,0,a,u),i.font=t,i.textBaseline="alphabetic",i.fillStyle="#000",i.fillText(o,0,s);var c=i.getImageData(0,0,a||1,u||1).data,h=c.length,l=4*a,d=0,f=0,p=!1;for(d=0;d<s;++d){for(var g=0;g<l;g+=4)if(255!==c[f+g]){p=!0;break}if(p)break;f+=l}for(n.ascent=s-d,f=h-l,p=!1,d=u;d>s;--d){for(g=0;g<l;g+=4)if(255!==c[f+g]){p=!0;break}if(p)break;f-=l}return n.descent=d-s,n.fontSize=n.ascent+n.descent,this.fontMetricsCache[t]=n,n},t.prototype.measureText=function(t,e,n){var r=e.fontSize,i=e.wordWrap,o=e.lineHeight,a=e.lineWidth,s=e.textBaseline,u=e.textAlign,c=e.letterSpacing,h=e.textPath;e.textPathSide,e.textPathStartOffset;var l=e.leading,d=void 0===l?0:l,f=function(t){for(var e=t.fontSize,n=t.fontFamily,r=t.fontStyle,i=t.fontVariant,o=t.fontWeight,a=Vt(e)&&"".concat(e,"px")||"16px",s=n.split(","),u=s.length-1;u>=0;u--){var c=s[u].trim();!Sa.test(c)&&Na.indexOf(c)<0&&(c='"'.concat(c,'"')),s[u]=c}return"".concat(r," ").concat(i," ").concat(o," ").concat(a," ").concat(s.join(","))}(e),p=this.measureFont(f,n);0===p.fontSize&&(p.fontSize=r,p.ascent=r);var g=this.runtime.offscreenCanvasCreator.getOrCreateContext(n);g.font=f,e.isOverflowing=!1;var m=(i?this.wordWrap(t,e,n):t).split(/(?:\r\n|\r|\n)/),v=new Array(m.length),y=0;if(!h){for(M=0;M<m.length;M++){var b=g.measureText(m[M]).width+(m[M].length-1)*c;v[M]=b,y=Math.max(y,b)}N=y+a;var E=o||p.fontSize+a,w=Math.max(E,p.fontSize+a)+(m.length-1)*(E+d),x=0;return"middle"===s?x=-w/2:"bottom"===s||"alphabetic"===s||"ideographic"===s?x=-w:"top"!==s&&"hanging"!==s||(x=0),{font:f,width:N,height:w,lines:m,lineWidths:v,lineHeight:E+=d,maxLineWidth:y,fontProperties:p,lineMetrics:v.map((function(t,e){var n=0;return"center"===u||"middle"===u?n-=t/2:"right"!==u&&"end"!==u||(n-=t),new br(n-a/2,x+e*E,t+a,E)}))}}h.getTotalLength();for(var M=0;M<m.length;M++)var N=g.measureText(m[M]).width+(m[M].length-1)*c},t.prototype.setGraphemeOnPath=function(){},t.prototype.wordWrap=function(t,e,n){var r=this,i=e.wordWrapWidth,o=void 0===i?0:i,a=e.letterSpacing,s=e.maxLines,u=void 0===s?1/0:s,c=e.textOverflow,h=this.runtime.offscreenCanvasCreator.getOrCreateContext(n),l=o+a,d="";"ellipsis"===c?d="...":c&&"clip"!==c&&(d=c);for(var f=[],p=0,g=0,m={},v=function(t){return r.getFromCache(t,a,m,h)},y=Array.from(d).reduce((function(t,e){return t+v(e)}),0),b=Array.from(t),E=0;E<b.length;E++){var w=b[E],x=t[E-1],M=t[E+1],N=v(w);if(this.isNewline(w)){if(++p>=u){e.isOverflowing=!0;break}g=0,f[p]=""}else{if(g>0&&g+N>l){if(p+1>=u){if(e.isOverflowing=!0,y>0&&y<=l){for(var S=f[p].length,T=0,k=S,P=0;P<S;P++){var C=v(f[p][P]);if(T+C+y>l){k=P;break}T+=C}f[p]=(f[p]||"").slice(0,k)+d}break}if(g=0,f[++p]="",this.isBreakingSpace(w))continue;this.canBreakInLastChar(w)||(f=this.trimToBreakable(f),g=this.sumTextWidthByCache(f[p]||"",m)),this.shouldBreakByKinsokuShorui(w,M)&&(f=this.trimByKinsokuShorui(f),g+=v(x||""))}g+=N,f[p]=(f[p]||"")+w}}return f.join("\n")},t.prototype.isBreakingSpace=function(t){return"string"==typeof t&&rs.BreakingSpaces.indexOf(t.charCodeAt(0))>=0},t.prototype.isNewline=function(t){return"string"==typeof t&&rs.Newlines.indexOf(t.charCodeAt(0))>=0},t.prototype.trimToBreakable=function(t){var e=h([],c(t),!1),n=e[e.length-2],r=this.findBreakableIndex(n);if(-1===r||!n)return e;var i=n.slice(r,r+1),o=r+1,a=r+(this.isBreakingSpace(i)?0:1);return e[e.length-1]+=n.slice(o,n.length),e[e.length-2]=n.slice(0,a),e},t.prototype.canBreakInLastChar=function(t){return!t||!is.test(t)},t.prototype.sumTextWidthByCache=function(t,e){return t.split("").reduce((function(t,n){if(!e[n])throw Error("cannot count the word without cache");return t+e[n]}),0)},t.prototype.findBreakableIndex=function(t){for(var e=t.length-1;e>=0;e--)if(!is.test(t[e]))return e;return-1},t.prototype.getFromCache=function(t,e,n,r){var i=n[t];if("number"!=typeof i){var o=t.length*e;i=r.measureText(t).width+o,n[t]=i}return i},t}(),us={},cs=(Ja=new Da,ts=new _a,(Qa={})[Un.CIRCLE]=new Ca,Qa[Un.ELLIPSE]=new Aa,Qa[Un.RECT]=Ja,Qa[Un.IMAGE]=Ja,Qa[Un.GROUP]=Ja,Qa[Un.LINE]=new Oa,Qa[Un.TEXT]=new Ia(us),Qa[Un.POLYLINE]=ts,Qa[Un.POLYGON]=ts,Qa[Un.PATH]=new Ra,Qa[Un.HTML]=null,Qa[Un.MESH]=null,Qa),hs=function(){var t,e=new Io,n=new zo;return(t={})[hi.PERCENTAGE]=null,t[hi.NUMBER]=new Ho,t[hi.ANGLE]=new _o,t[hi.DEFINED_PATH]=new Do,t[hi.PAINT]=e,t[hi.COLOR]=e,t[hi.FILTER]=new Lo,t[hi.LENGTH]=n,t[hi.LENGTH_PERCENTAGE]=n,t[hi.LENGTH_PERCENTAGE_12]=new Fo,t[hi.LENGTH_PERCENTAGE_14]=new Bo,t[hi.COORDINATE]=new Uo,t[hi.OFFSET_DISTANCE]=new qo,t[hi.OPACITY_VALUE]=new Yo,t[hi.PATH]=new $o,t[hi.LIST_OF_POINTS]=new Xo,t[hi.SHADOW_BLUR]=new Ko,t[hi.TEXT]=new Zo,t[hi.TEXT_TRANSFORM]=new Qo,t[hi.TRANSFORM]=new Ta,t[hi.TRANSFORM_ORIGIN]=new ka,t[hi.Z_INDEX]=new Pa,t[hi.MARKER]=new Wo,t}();us.CameraContribution=Cr,us.AnimationTimeline=null,us.EasingFunction=null,us.offscreenCanvasCreator=new Ha,us.sceneGraphSelector=new Xa,us.sceneGraphService=new ns(us),us.textService=new ss(us),us.geometryUpdaterFactory=cs,us.CSSPropertySyntaxFactory=hs,us.styleValueRegistry=new Ro(us),us.layoutRegistry=null,us.globalThis="undefined"!=typeof globalThis?globalThis:"undefined"!=typeof self?self:"undefined"!=typeof window?window:"undefined"!=typeof global?global:{},us.enableCSSParsing=!0,us.enableDataset=!1,us.enableStyleSyntax=!0,us.enableSizeAttenuation=!1;var ls=0,ds=new Ka(qa.INSERTED,null,"","","",0,"",""),fs=new Ka(qa.REMOVED,null,"","","",0,"",""),ps=new Ga(qa.DESTROY),gs=function(t){function e(){var e=t.apply(this,h([],c(arguments),!1))||this;return e.entity=ls++,e.renderable={bounds:void 0,boundsDirty:!0,renderBounds:void 0,renderBoundsDirty:!0,dirtyRenderBounds:void 0,dirty:!1},e.cullable={strategy:Kr.Standard,visibilityPlaneMask:-1,visible:!0,enable:!0},e.transformable={dirtyFlag:!1,localDirtyFlag:!1,frozen:!1,localPosition:[0,0,0],localRotation:[0,0,0,1],localScale:[1,1,1],localTransform:[1,0,0,0,0,1,0,0,0,0,1,0,0,0,0,1],localSkew:[0,0],position:[0,0,0],rotation:[0,0,0,1],scaling:[1,1,1],worldTransform:[1,0,0,0,0,1,0,0,0,0,1,0,0,0,0,1],origin:[0,0,0]},e.sortable={dirty:!1,sorted:void 0,renderOrder:0,dirtyChildren:[],dirtyReason:void 0},e.geometry={contentBounds:void 0,renderBounds:void 0},e.rBushNode={aabb:void 0},e.namespaceURI="g",e.scrollLeft=0,e.scrollTop=0,e.clientTop=0,e.clientLeft=0,e.destroyed=!1,e.style={},e.computedStyle=us.enableCSSParsing?{anchor:ti,opacity:ti,fillOpacity:ti,strokeOpacity:ti,fill:ti,stroke:ti,transform:ti,transformOrigin:ti,visibility:ti,pointerEvents:ti,lineWidth:ti,lineCap:ti,lineJoin:ti,increasedLineWidthForHitTesting:ti,fontSize:ti,fontFamily:ti,fontStyle:ti,fontWeight:ti,fontVariant:ti,textAlign:ti,textBaseline:ti,textTransform:ti,zIndex:ti,filter:ti,shadowType:ti}:null,e.parsedStyle={},e.attributes={},e}return r(e,t),Object.defineProperty(e.prototype,"className",{get:function(){return this.getAttribute("class")||""},set:function(t){this.setAttribute("class",t)},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"classList",{get:function(){return this.className.split(" ").filter((function(t){return""!==t}))},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"tagName",{get:function(){return this.nodeName},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"children",{get:function(){return this.childNodes},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"childElementCount",{get:function(){return this.childNodes.length},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"firstElementChild",{get:function(){return this.firstChild},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"lastElementChild",{get:function(){return this.lastChild},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"parentElement",{get:function(){return this.parentNode},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"nextSibling",{get:function(){if(this.parentNode){var t=this.parentNode.childNodes.indexOf(this);return this.parentNode.childNodes[t+1]||null}return null},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"previousSibling",{get:function(){if(this.parentNode){var t=this.parentNode.childNodes.indexOf(this);return this.parentNode.childNodes[t-1]||null}return null},enumerable:!1,configurable:!0}),e.prototype.cloneNode=function(t){throw new Error(Er)},e.prototype.appendChild=function(t,e){var n;if(t.destroyed)throw new Error("Cannot append a destroyed element.");return us.sceneGraphService.attach(t,this,e),(null===(n=this.ownerDocument)||void 0===n?void 0:n.defaultView)&&this.ownerDocument.defaultView.mountChildren(t),ds.relatedNode=this,t.dispatchEvent(ds),t},e.prototype.insertBefore=function(t,e){if(e){t.parentElement&&t.parentElement.removeChild(t);var n=this.childNodes.indexOf(e);-1===n?this.appendChild(t):this.appendChild(t,n)}else this.appendChild(t);return t},e.prototype.replaceChild=function(t,e){var n=this.childNodes.indexOf(e);return this.removeChild(e),this.appendChild(t,n),e},e.prototype.removeChild=function(t){var e;return fs.relatedNode=this,t.dispatchEvent(fs),(null===(e=t.ownerDocument)||void 0===e?void 0:e.defaultView)&&t.ownerDocument.defaultView.unmountChildren(t),us.sceneGraphService.detach(t),t},e.prototype.removeChildren=function(){for(var t=this.childNodes.length-1;t>=0;t--){var e=this.childNodes[t];this.removeChild(e)}},e.prototype.destroyChildren=function(){for(var t=this.childNodes.length-1;t>=0;t--){var e=this.childNodes[t];e.childNodes.length&&e.destroyChildren(),e.destroy()}},e.prototype.matches=function(t){return us.sceneGraphService.matches(t,this)},e.prototype.getElementById=function(t){return us.sceneGraphService.querySelector("#".concat(t),this)},e.prototype.getElementsByName=function(t){return us.sceneGraphService.querySelectorAll('[name="'.concat(t,'"]'),this)},e.prototype.getElementsByClassName=function(t){return us.sceneGraphService.querySelectorAll(".".concat(t),this)},e.prototype.getElementsByTagName=function(t){return us.sceneGraphService.querySelectorAll(t,this)},e.prototype.querySelector=function(t){return us.sceneGraphService.querySelector(t,this)},e.prototype.querySelectorAll=function(t){return us.sceneGraphService.querySelectorAll(t,this)},e.prototype.closest=function(t){var e=this;do{if(us.sceneGraphService.matches(t,e))return e;e=e.parentElement}while(null!==e);return null},e.prototype.find=function(t){var e=this,n=null;return this.forEach((function(r){return!(r===e||!t(r))&&(n=r,!0)})),n},e.prototype.findAll=function(t){var e=this,n=[];return this.forEach((function(r){r!==e&&t(r)&&n.push(r)})),n},e.prototype.after=function(){for(var t=this,e=[],n=0;n<arguments.length;n++)e[n]=arguments[n];if(this.parentNode){var r=this.parentNode.childNodes.indexOf(this);e.forEach((function(e,n){var i;return null===(i=t.parentNode)||void 0===i?void 0:i.appendChild(e,r+n+1)}))}},e.prototype.before=function(){for(var t,e=[],n=0;n<arguments.length;n++)e[n]=arguments[n];if(this.parentNode){var r=this.parentNode.childNodes.indexOf(this),i=c(e),o=i[0],a=i.slice(1);this.parentNode.appendChild(o,r),(t=o).after.apply(t,h([],c(a),!1))}},e.prototype.replaceWith=function(){for(var t=[],e=0;e<arguments.length;e++)t[e]=arguments[e];this.after.apply(this,h([],c(t),!1)),this.remove()},e.prototype.append=function(){for(var t=this,e=[],n=0;n<arguments.length;n++)e[n]=arguments[n];e.forEach((function(e){return t.appendChild(e)}))},e.prototype.prepend=function(){for(var t=this,e=[],n=0;n<arguments.length;n++)e[n]=arguments[n];e.forEach((function(e,n){return t.appendChild(e,n)}))},e.prototype.replaceChildren=function(){for(var t=[],e=0;e<arguments.length;e++)t[e]=arguments[e];for(;this.childNodes.length&&this.firstChild;)this.removeChild(this.firstChild);this.append.apply(this,h([],c(t),!1))},e.prototype.remove=function(){return this.parentNode?this.parentNode.removeChild(this):this},e.prototype.destroy=function(){this.dispatchEvent(ps),this.remove(),this.emitter.removeAllListeners(),this.destroyed=!0},e.prototype.getGeometryBounds=function(){return us.sceneGraphService.getGeometryBounds(this)},e.prototype.getRenderBounds=function(){return us.sceneGraphService.getBounds(this,!0)},e.prototype.getBounds=function(){return us.sceneGraphService.getBounds(this)},e.prototype.getLocalBounds=function(){return us.sceneGraphService.getLocalBounds(this)},e.prototype.getBoundingClientRect=function(){return us.sceneGraphService.getBoundingClientRect(this)},e.prototype.getClientRects=function(){return[this.getBoundingClientRect()]},e.prototype.computedStyleMap=function(){return new Map(Object.entries(this.computedStyle))},e.prototype.getAttributeNames=function(){return Object.keys(this.attributes)},e.prototype.getAttribute=function(t){if(function(t){return"symbol"==typeof t}(t))return us.enableCSSParsing?null:void 0;var e=this.attributes[t];if(void 0===e){var n=Hr(t);return e=this.attributes[n],us.enableCSSParsing&&Pt(e)?null:e}return e},e.prototype.hasAttribute=function(t){return this.getAttributeNames().includes(t)},e.prototype.hasAttributes=function(){return!!this.getAttributeNames().length},e.prototype.removeAttribute=function(t){this.setAttribute(t,null),delete this.attributes[t]},e.prototype.setAttribute=function(t,e,n){this.attributes[t]=e},e.prototype.getAttributeNS=function(t,e){throw new Error(Er)},e.prototype.getAttributeNode=function(t){throw new Error(Er)},e.prototype.getAttributeNodeNS=function(t,e){throw new Error(Er)},e.prototype.hasAttributeNS=function(t,e){throw new Error(Er)},e.prototype.removeAttributeNS=function(t,e){throw new Error(Er)},e.prototype.removeAttributeNode=function(t){throw new Error(Er)},e.prototype.setAttributeNS=function(t,e,n){throw new Error(Er)},e.prototype.setAttributeNode=function(t){throw new Error(Er)},e.prototype.setAttributeNodeNS=function(t){throw new Error(Er)},e.prototype.toggleAttribute=function(t,e){throw new Error(Er)},e}(Ua);function ms(t){return!!(null==t?void 0:t.nodeName)}var vs,ys=new Ka(qa.ATTR_MODIFIED,null,null,null,null,Ka.MODIFICATION,null,null),bs={anchor:"",opacity:"",fillOpacity:"",strokeOpacity:"",fill:"",stroke:"",transform:"",transformOrigin:"",visibility:"",pointerEvents:"",lineWidth:"",lineCap:"",lineJoin:"",increasedLineWidthForHitTesting:"",fontSize:"",fontFamily:"",fontStyle:"",fontWeight:"",fontVariant:"",textAlign:"",textBaseline:"",textTransform:"",zIndex:"",filter:"",shadowType:""},Es={anchor:[0,0],fill:oi,stroke:oi,transform:[],zIndex:0,filter:[],shadowType:"outer",miterLimit:10},ws=i(i({},Es),{opacity:1,fillOpacity:1,strokeOpacity:1,visibility:"visible",pointerEvents:"auto",lineWidth:1,lineCap:"butt",lineJoin:"miter",increasedLineWidthForHitTesting:0,fillRule:"nonzero"}),xs=h(h([],c(["opacity","fillOpacity","strokeOpacity","transformOrigin","visibility","pointerEvents","lineWidth","lineCap","lineJoin","increasedLineWidthForHitTesting"]),!1),["fontSize","fontFamily","fontStyle","fontWeight","fontVariant","textAlign","textBaseline","textTransform"],!1),Ms="data-",Ns=function(t){function e(e){var n,r=t.call(this)||this;r.isCustomElement=!1,r.isMutationObserved=!1,r.activeAnimations=[],r.getClip=function(){return this.style.clipPath||null},r.config=e,r.config.interactive=null!==(n=r.config.capture)&&void 0!==n?n:r.config.interactive,r.id=r.config.id||"",r.name=r.config.name||"",(r.config.className||r.config.class)&&(r.className=r.config.className||r.config.class),r.nodeName=r.config.type||Un.GROUP,r.config.style=r.config.style||r.config.attrs||{},Object.assign(r.config.style,r.config.attrs),null!=r.config.visible&&(r.config.style.visibility=!1===r.config.visible?"hidden":"visible"),null!=r.config.interactive&&(r.config.style.pointerEvents=!1===r.config.interactive?"none":"auto"),Object.assign(r.parsedStyle,us.enableCSSParsing?Es:ws,r.config.initialParsedStyle),us.enableCSSParsing&&Object.assign(r.attributes,bs),r.initAttributes(r.config.style);var i=us.globalThis.Proxy?us.globalThis.Proxy:function(){};return us.enableDataset&&(r.dataset=new i({},{get:function(t,e){var n="".concat(Ms).concat(Vr(e));return void 0!==t[n]?t[n]:r.getAttribute(n)},set:function(t,e,n){return r.setAttribute("".concat(Ms).concat(Vr(e)),n),!0}})),us.enableStyleSyntax&&(r.style=new i({setProperty:function(t,e){r.setAttribute(t,e)},getPropertyValue:function(t){return r.getAttribute(t)},removeProperty:function(t){r.removeAttribute(t)},item:function(){return""}},{get:function(t,e){return void 0!==t[e]?t[e]:r.getAttribute(e)},set:function(t,e,n){return r.setAttribute(e,n),!0}})),r}return r(e,t),e.prototype.destroy=function(){t.prototype.destroy.call(this),this.getAnimations().forEach((function(t){t.cancel()}))},e.prototype.cloneNode=function(t,e){var n=i({},this.attributes);for(var r in n){var o=n[r];ms(o)&&"clipPath"!==r&&"offsetPath"!==r&&"textPath"!==r&&(n[r]=o.cloneNode(t)),e&&(n[r]=e(r,o))}var a=new this.constructor({id:this.id,name:this.name,className:this.name,interactive:this.interactive,style:n});return a.setLocalTransform(this.getLocalTransform()),t&&this.children.forEach((function(e){if(!e.style.isMarker){var n=e.cloneNode(t);a.appendChild(n)}})),a},e.prototype.initAttributes=function(t){void 0===t&&(t={});var e=this.renderable,n={forceUpdateGeometry:!0};us.enableCSSParsing&&(n.usedAttributes=xs);var r={};for(var i in t){r[Hr(i)]=t[i]}us.styleValueRegistry.processProperties(this,r,n),e.dirty=!0},e.prototype.setAttribute=function(e,n,r,i){void 0===r&&(r=!1),void 0===i&&(i=!0);var o=Hr(e);Zt(n)||(r||n!==this.attributes[o])&&(this.internalSetAttribute(o,n,{memoize:i}),t.prototype.setAttribute.call(this,o,n))},e.prototype.internalSetAttribute=function(t,e,n){var r;void 0===n&&(n={});var i=this.renderable,o=this.attributes[t],a=this.parsedStyle[t];us.styleValueRegistry.processProperties(this,((r={})[t]=e,r),n),i.dirty=!0;var s=this.parsedStyle[t];this.isConnected&&(ys.relatedNode=this,ys.prevValue=o,ys.newValue=e,ys.attrName=t,ys.prevParsedValue=a,ys.newParsedValue=s,this.isMutationObserved?this.dispatchEvent(ys):(ys.target=this,this.ownerDocument.defaultView.dispatchEvent(ys,!0))),(this.isCustomElement&&this.isConnected||!this.isCustomElement)&&this.attributeChangedCallback&&this.attributeChangedCallback(t,o,e,a,s)},e.prototype.getBBox=function(){var t=this.getBounds(),e=c(t.getMin(),2),n=e[0],r=e[1],i=c(t.getMax(),2),o=i[0],a=i[1];return new br(n,r,o-n,a-r)},e.prototype.setOrigin=function(t,e,n){return void 0===e&&(e=0),void 0===n&&(n=0),us.sceneGraphService.setOrigin(this,Jn(t,e,n)),this},e.prototype.getOrigin=function(){return us.sceneGraphService.getOrigin(this)},e.prototype.setPosition=function(t,e,n){return void 0===e&&(e=0),void 0===n&&(n=0),us.sceneGraphService.setPosition(this,Jn(t,e,n)),this},e.prototype.setLocalPosition=function(t,e,n){return void 0===e&&(e=0),void 0===n&&(n=0),us.sceneGraphService.setLocalPosition(this,Jn(t,e,n)),this},e.prototype.translate=function(t,e,n){return void 0===e&&(e=0),void 0===n&&(n=0),us.sceneGraphService.translate(this,Jn(t,e,n)),this},e.prototype.translateLocal=function(t,e,n){return void 0===e&&(e=0),void 0===n&&(n=0),us.sceneGraphService.translateLocal(this,Jn(t,e,n)),this},e.prototype.getPosition=function(){return us.sceneGraphService.getPosition(this)},e.prototype.getLocalPosition=function(){return us.sceneGraphService.getLocalPosition(this)},e.prototype.scale=function(t,e,n){return this.scaleLocal(t,e,n)},e.prototype.scaleLocal=function(t,e,n){return"number"==typeof t&&(t=Jn(t,e=e||t,n=n||t)),us.sceneGraphService.scaleLocal(this,t),this},e.prototype.setLocalScale=function(t,e,n){return"number"==typeof t&&(t=Jn(t,e=e||t,n=n||t)),us.sceneGraphService.setLocalScale(this,t),this},e.prototype.getLocalScale=function(){return us.sceneGraphService.getLocalScale(this)},e.prototype.getScale=function(){return us.sceneGraphService.getScale(this)},e.prototype.getEulerAngles=function(){return er(c(nr(K(),us.sceneGraphService.getWorldTransform(this)),3)[2])},e.prototype.getLocalEulerAngles=function(){return er(c(nr(K(),us.sceneGraphService.getLocalRotation(this)),3)[2])},e.prototype.setEulerAngles=function(t){return us.sceneGraphService.setEulerAngles(this,0,0,t),this},e.prototype.setLocalEulerAngles=function(t){return us.sceneGraphService.setLocalEulerAngles(this,0,0,t),this},e.prototype.rotateLocal=function(t,e,n){return Pt(e)&&Pt(n)?us.sceneGraphService.rotateLocal(this,0,0,t):us.sceneGraphService.rotateLocal(this,t,e,n),this},e.prototype.rotate=function(t,e,n){return Pt(e)&&Pt(n)?us.sceneGraphService.rotate(this,0,0,t):us.sceneGraphService.rotate(this,t,e,n),this},e.prototype.setRotation=function(t,e,n,r){return us.sceneGraphService.setRotation(this,t,e,n,r),this},e.prototype.setLocalRotation=function(t,e,n,r){return us.sceneGraphService.setLocalRotation(this,t,e,n,r),this},e.prototype.setLocalSkew=function(t,e){return us.sceneGraphService.setLocalSkew(this,t,e),this},e.prototype.getRotation=function(){return us.sceneGraphService.getRotation(this)},e.prototype.getLocalRotation=function(){return us.sceneGraphService.getLocalRotation(this)},e.prototype.getLocalSkew=function(){return us.sceneGraphService.getLocalSkew(this)},e.prototype.getLocalTransform=function(){return us.sceneGraphService.getLocalTransform(this)},e.prototype.getWorldTransform=function(){return us.sceneGraphService.getWorldTransform(this)},e.prototype.setLocalTransform=function(t){return us.sceneGraphService.setLocalTransform(this,t),this},e.prototype.resetLocalTransform=function(){us.sceneGraphService.resetLocalTransform(this)},e.prototype.getAnimations=function(){return this.activeAnimations},e.prototype.animate=function(t,e){var n,r=null===(n=this.ownerDocument)||void 0===n?void 0:n.timeline;return r?r.play(this,t,e):null},e.prototype.isVisible=function(){var t;return"visible"===(null===(t=this.parsedStyle)||void 0===t?void 0:t.visibility)},Object.defineProperty(e.prototype,"interactive",{get:function(){return this.isInteractive()},set:function(t){this.style.pointerEvents=t?"auto":"none"},enumerable:!1,configurable:!0}),e.prototype.isInteractive=function(){var t;return"none"!==(null===(t=this.parsedStyle)||void 0===t?void 0:t.pointerEvents)},e.prototype.isCulled=function(){return!(!this.cullable||!this.cullable.enable||this.cullable.visible)},e.prototype.toFront=function(){return this.parentNode&&(this.style.zIndex=Math.max.apply(Math,h([],c(this.parentNode.children.map((function(t){return Number(t.style.zIndex)}))),!1))+1),this},e.prototype.toBack=function(){return this.parentNode&&(this.style.zIndex=Math.min.apply(Math,h([],c(this.parentNode.children.map((function(t){return Number(t.style.zIndex)}))),!1))-1),this},e.prototype.getConfig=function(){return this.config},e.prototype.attr=function(){for(var t=this,e=[],n=0;n<arguments.length;n++)e[n]=arguments[n];var r=c(e,2),i=r[0],o=r[1];return i?Rt(i)?(Object.keys(i).forEach((function(e){t.setAttribute(e,i[e])})),this):2===e.length?(this.setAttribute(i,o),this):this.attributes[i]:this.attributes},e.prototype.getMatrix=function(t){var e=t||this.getWorldTransform(),n=c(I(K(),e),2),r=n[0],i=n[1],o=c(L(K(),e),2),a=o[0],s=o[1],u=j(gt(),e),h=c(nr(K(),u),3),l=h[0],d=h[2];return rr(l||d,r,i,a,s)},e.prototype.getLocalMatrix=function(){return this.getMatrix(this.getLocalTransform())},e.prototype.setMatrix=function(t){var e=c(ir(t),5),n=e[0],r=e[1],i=e[2],o=e[3],a=e[4];this.setEulerAngles(a).setPosition(n,r).setLocalScale(i,o)},e.prototype.setLocalMatrix=function(t){var e=c(ir(t),5),n=e[0],r=e[1],i=e[2],o=e[3],a=e[4];this.setLocalEulerAngles(a).setLocalPosition(n,r).setLocalScale(i,o)},e.prototype.show=function(){us.enableCSSParsing?this.style.visibility="visible":this.forEach((function(t){t.style.visibility="visible"}))},e.prototype.hide=function(){us.enableCSSParsing?this.style.visibility="hidden":this.forEach((function(t){t.style.visibility="hidden"}))},e.prototype.getCount=function(){return this.childElementCount},e.prototype.getParent=function(){return this.parentElement},e.prototype.getChildren=function(){return this.children},e.prototype.getFirst=function(){return this.firstElementChild},e.prototype.getLast=function(){return this.lastElementChild},e.prototype.getChildByIndex=function(t){return this.children[t]||null},e.prototype.add=function(t,e){return this.appendChild(t,e)},e.prototype.setClip=function(t){this.style.clipPath=t},e.prototype.set=function(t,e){this.config[t]=e},e.prototype.get=function(t){return this.config[t]},e.prototype.moveTo=function(t,e,n){return void 0===e&&(e=0),void 0===n&&(n=0),this.setPosition(t,e,n),this},e.prototype.move=function(t,e,n){return void 0===e&&(e=0),void 0===n&&(n=0),this.setPosition(t,e,n),this},e.prototype.setZIndex=function(t){return this.style.zIndex=t,this},e}(gs),Ss=function(t){function e(e){void 0===e&&(e={});var n=e.style,r=o(e,["style"]);return t.call(this,i({type:Un.CIRCLE,style:us.enableCSSParsing?i({cx:"",cy:"",r:""},n):i({},n),initialParsedStyle:{anchor:[.5,.5],transformOrigin:us.enableCSSParsing?null:[ci,ci]}},r))||this}return r(e,t),e}(Ns),Ts=function(t){function e(e){void 0===e&&(e={});var n=this,r=e.style,a=o(e,["style"]);return(n=t.call(this,i({style:us.enableCSSParsing?i({x:"",y:""},r):i({},r)},a))||this).isCustomElement=!0,n}return r(e,t),e}(Ns),ks=function(t){function e(e){void 0===e&&(e={});var n=e.style,r=o(e,["style"]);return t.call(this,i({type:Un.ELLIPSE,style:us.enableCSSParsing?i({cx:"",cy:"",rx:"",ry:""},n):i({},n),initialParsedStyle:{anchor:[.5,.5],transformOrigin:us.enableCSSParsing?null:[ci,ci]}},r))||this}return r(e,t),e}(Ns),Ps=function(t){function e(e){void 0===e&&(e={});var n=e.style,r=o(e,["style"]);return t.call(this,i({type:Un.GROUP,style:us.enableCSSParsing?i({x:"",y:"",width:"",height:""},n):i({},n)},r))||this}return r(e,t),e}(Ns),Cs=function(t){function e(e){void 0===e&&(e={});var n=this,r=e.style,a=o(e,["style"]);return(n=t.call(this,i({type:Un.HTML,style:us.enableCSSParsing?i({x:"",y:"",width:"auto",height:"auto",innerHTML:""},r):i({},r)},a))||this).cullable.enable=!1,n}return r(e,t),e.prototype.getDomElement=function(){return this.parsedStyle.$el},e.prototype.getBoundingClientRect=function(){if(this.parsedStyle.$el)return this.parsedStyle.$el.getBoundingClientRect();var t=this.parsedStyle,e=t.x,n=t.y,r=t.width,i=t.height;return new br(e,n,r,i)},e.prototype.getClientRects=function(){return[this.getBoundingClientRect()]},e.prototype.getBounds=function(){var t,e,n=this.getBoundingClientRect(),r=null===(e=null===(t=this.ownerDocument)||void 0===t?void 0:t.defaultView)||void 0===e?void 0:e.getContextService().getBoundingClientRect(),i=new dr,o=n.left-((null==r?void 0:r.left)||0),a=n.top-((null==r?void 0:r.top)||0);return i.setMinMax([o,a,0],[o+n.width,a+n.height,0]),i},e.prototype.getLocalBounds=function(){if(this.parentNode){var t=S(b(),this.parentNode.getWorldTransform()),e=this.getBounds();if(!dr.isEmpty(e)){var n=new dr;return n.setFromTransformedAABB(e,t),n}}return this.getBounds()},e}(Ns),As=function(t){function e(e){void 0===e&&(e={});var n=e.style,r=o(e,["style"]);return t.call(this,i({type:Un.IMAGE,style:us.enableCSSParsing?i({x:"",y:"",img:"",width:"",height:""},n):i({},n)},r))||this}return r(e,t),e}(Ns),Os=function(t){function e(e){void 0===e&&(e={});var n=this,r=e.style,a=o(e,["style"]);(n=t.call(this,i({type:Un.LINE,style:i({x1:0,y1:0,x2:0,y2:0,z1:0,z2:0},r)},a))||this).markerStartAngle=0,n.markerEndAngle=0;var s=n.parsedStyle,u=s.markerStart,c=s.markerEnd;return u&&ms(u)&&(n.markerStartAngle=u.getLocalEulerAngles(),n.appendChild(u)),c&&ms(c)&&(n.markerEndAngle=c.getLocalEulerAngles(),n.appendChild(c)),n.transformMarker(!0),n.transformMarker(!1),n}return r(e,t),e.prototype.attributeChangedCallback=function(t,e,n,r,i){"x1"===t||"y1"===t||"x2"===t||"y2"===t||"markerStartOffset"===t||"markerEndOffset"===t?(this.transformMarker(!0),this.transformMarker(!1)):"markerStart"===t?(r&&ms(r)&&(this.markerStartAngle=0,r.remove()),i&&ms(i)&&(this.markerStartAngle=i.getLocalEulerAngles(),this.appendChild(i),this.transformMarker(!0))):"markerEnd"===t&&(r&&ms(r)&&(this.markerEndAngle=0,r.remove()),i&&ms(i)&&(this.markerEndAngle=i.getLocalEulerAngles(),this.appendChild(i),this.transformMarker(!1)))},e.prototype.transformMarker=function(t){var e=this.parsedStyle,n=e.markerStart,r=e.markerEnd,i=e.markerStartOffset,o=e.markerEndOffset,a=e.x1,s=e.x2,u=e.y1,c=e.y2,h=e.defX,l=e.defY,d=t?n:r;if(d&&ms(d)){var f,p,g,m,v,y,b;t?(m=a-h,v=u-l,p=s-a,g=c-u,y=i||0,b=this.markerStartAngle):(m=s-h,v=c-l,p=a-s,g=u-c,y=o||0,b=this.markerEndAngle),f=Math.atan2(g,p),d.setLocalEulerAngles(180*f/Math.PI+b),d.setLocalPosition(m+Math.cos(f)*y,v+Math.sin(f)*y)}},e.prototype.getPoint=function(t,e){void 0===e&&(e=!1);var n=this.parsedStyle,r=n.x1,i=n.y1,o=n.x2,a=n.y2,s=n.defX,u=n.defY,c=On(r,i,o,a,t),h=c.x,l=c.y,d=ct(K(),J(h-s,l-u,0),e?this.getWorldTransform():this.getLocalTransform());return new yr(d[0],d[1])},e.prototype.getPointAtLength=function(t,e){return void 0===e&&(e=!1),this.getPoint(t/this.getTotalLength(),e)},e.prototype.getTotalLength=function(){var t=this.parsedStyle;return An(t.x1,t.y1,t.x2,t.y2)},e}(Ns),Rs=function(t){function e(e){void 0===e&&(e={});var n=this,r=e.style,a=o(e,["style"]);(n=t.call(this,i({type:Un.PATH,style:us.enableCSSParsing?i({path:"",miterLimit:""},r):i({},r),initialParsedStyle:us.enableCSSParsing?null:{miterLimit:4,path:i({},li)}},a))||this).markerStartAngle=0,n.markerEndAngle=0,n.markerMidList=[];var s=n.parsedStyle,u=s.markerStart,c=s.markerEnd,h=s.markerMid;return u&&ms(u)&&(n.markerStartAngle=u.getLocalEulerAngles(),n.appendChild(u)),h&&ms(h)&&n.placeMarkerMid(h),c&&ms(c)&&(n.markerEndAngle=c.getLocalEulerAngles(),n.appendChild(c)),n.transformMarker(!0),n.transformMarker(!1),n}return r(e,t),e.prototype.attributeChangedCallback=function(t,e,n,r,i){"path"===t?(this.transformMarker(!0),this.transformMarker(!1),this.placeMarkerMid(this.parsedStyle.markerMid)):"markerStartOffset"===t||"markerEndOffset"===t?(this.transformMarker(!0),this.transformMarker(!1)):"markerStart"===t?(r&&ms(r)&&(this.markerStartAngle=0,r.remove()),i&&ms(i)&&(this.markerStartAngle=i.getLocalEulerAngles(),this.appendChild(i),this.transformMarker(!0))):"markerEnd"===t?(r&&ms(r)&&(this.markerEndAngle=0,r.remove()),i&&ms(i)&&(this.markerEndAngle=i.getLocalEulerAngles(),this.appendChild(i),this.transformMarker(!1))):"markerMid"===t&&this.placeMarkerMid(i)},e.prototype.transformMarker=function(t){var e=this.parsedStyle,n=e.markerStart,r=e.markerEnd,i=e.markerStartOffset,o=e.markerEndOffset,a=e.defX,s=e.defY,u=t?n:r;if(u&&ms(u)){var h,l,d,f,p,g,m;if(t){var v=c(this.getStartTangent(),2),y=v[0];f=(b=v[1])[0]-a,p=b[1]-s,l=y[0]-b[0],d=y[1]-b[1],g=i||0,m=this.markerStartAngle}else{var b,E=c(this.getEndTangent(),2);y=E[0];f=(b=E[1])[0]-a,p=b[1]-s,l=y[0]-b[0],d=y[1]-b[1],g=o||0,m=this.markerEndAngle}h=Math.atan2(d,l),u.setLocalEulerAngles(180*h/Math.PI+m),u.setLocalPosition(f+Math.cos(h)*g,p+Math.sin(h)*g)}},e.prototype.placeMarkerMid=function(t){var e=this.parsedStyle,n=e.path.segments,r=e.defX,i=e.defY;if(this.markerMidList.forEach((function(t){t.remove()})),t&&ms(t))for(var o=1;o<n.length-1;o++){var a=c(n[o].currentPoint,2),s=a[0],u=a[1],h=1===o?t:t.cloneNode(!0);this.markerMidList.push(h),this.appendChild(h),h.setLocalPosition(s-r,u-i)}},e.prototype.getTotalLength=function(){return qi(this)},e.prototype.getPointAtLength=function(t,e){void 0===e&&(e=!1);var n=this.parsedStyle,r=n.defX,o=n.defY,a=function(t,e,n){return Ge(t,e,i(i({},n),{bbox:!1,length:!0})).point}(n.path.absolutePath,t),s=a.x,u=a.y,c=ct(K(),J(s-r,u-o,0),e?this.getWorldTransform():this.getLocalTransform());return new yr(c[0],c[1])},e.prototype.getPoint=function(t,e){return void 0===e&&(e=!1),this.getPointAtLength(t*qi(this),e)},e.prototype.getStartTangent=function(){var t=this.parsedStyle.path.segments,e=[];if(t.length>1){var n=t[0].currentPoint,r=t[1].currentPoint,i=t[1].startTangent;e=[],i?(e.push([n[0]-i[0],n[1]-i[1]]),e.push([n[0],n[1]])):(e.push([r[0],r[1]]),e.push([n[0],n[1]]))}return e},e.prototype.getEndTangent=function(){var t=this.parsedStyle.path.segments,e=t.length,n=[];if(e>1){var r=t[e-2].currentPoint,i=t[e-1].currentPoint,o=t[e-1].endTangent;n=[],o?(n.push([i[0]-o[0],i[1]-o[1]]),n.push([i[0],i[1]])):(n.push([r[0],r[1]]),n.push([i[0],i[1]]))}return n},e}(Ns),_s=function(t){function e(e){void 0===e&&(e={});var n=this,r=e.style,a=o(e,["style"]);(n=t.call(this,i({type:Un.POLYGON,style:us.enableCSSParsing?i({points:"",miterLimit:"",isClosed:!0},r):i({},r),initialParsedStyle:us.enableCSSParsing?null:{points:{points:[],totalLength:0,segments:[]},miterLimit:4,isClosed:!0}},a))||this).markerStartAngle=0,n.markerEndAngle=0,n.markerMidList=[];var s=n.parsedStyle,u=s.markerStart,c=s.markerEnd,h=s.markerMid;return u&&ms(u)&&(n.markerStartAngle=u.getLocalEulerAngles(),n.appendChild(u)),h&&ms(h)&&n.placeMarkerMid(h),c&&ms(c)&&(n.markerEndAngle=c.getLocalEulerAngles(),n.appendChild(c)),n.transformMarker(!0),n.transformMarker(!1),n}return r(e,t),e.prototype.attributeChangedCallback=function(t,e,n,r,i){"points"===t?(this.transformMarker(!0),this.transformMarker(!1),this.placeMarkerMid(this.parsedStyle.markerMid)):"markerStartOffset"===t||"markerEndOffset"===t?(this.transformMarker(!0),this.transformMarker(!1)):"markerStart"===t?(r&&ms(r)&&(this.markerStartAngle=0,r.remove()),i&&ms(i)&&(this.markerStartAngle=i.getLocalEulerAngles(),this.appendChild(i),this.transformMarker(!0))):"markerEnd"===t?(r&&ms(r)&&(this.markerEndAngle=0,r.remove()),i&&ms(i)&&(this.markerEndAngle=i.getLocalEulerAngles(),this.appendChild(i),this.transformMarker(!1))):"markerMid"===t&&this.placeMarkerMid(i)},e.prototype.transformMarker=function(t){var e=this.parsedStyle,n=e.markerStart,r=e.markerEnd,i=e.markerStartOffset,o=e.markerEndOffset,a=e.points,s=e.defX,u=e.defY,c=(a||{}).points,h=t?n:r;if(h&&ms(h)&&c){var l,d,f,p,g,m,v;if(p=c[0][0]-s,g=c[0][1]-u,t)d=c[1][0]-c[0][0],f=c[1][1]-c[0][1],m=i||0,v=this.markerStartAngle;else{var y=c.length;this.parsedStyle.isClosed?(d=c[y-1][0]-c[0][0],f=c[y-1][1]-c[0][1]):(p=c[y-1][0]-s,g=c[y-1][1]-u,d=c[y-2][0]-c[y-1][0],f=c[y-2][1]-c[y-1][1]),m=o||0,v=this.markerEndAngle}l=Math.atan2(f,d),h.setLocalEulerAngles(180*l/Math.PI+v),h.setLocalPosition(p+Math.cos(l)*m,g+Math.sin(l)*m)}},e.prototype.placeMarkerMid=function(t){var e=this.parsedStyle,n=e.points,r=e.defX,i=e.defY,o=(n||{}).points;if(this.markerMidList.forEach((function(t){t.remove()})),this.markerMidList=[],t&&ms(t)&&o)for(var a=1;a<(this.parsedStyle.isClosed?o.length:o.length-1);a++){var s=o[a][0]-r,u=o[a][1]-i,c=1===a?t:t.cloneNode(!0);this.markerMidList.push(c),this.appendChild(c),c.setLocalPosition(s,u)}},e}(Ns),Ds=function(t){function e(e){void 0===e&&(e={});var n=e.style,r=o(e,["style"]);return t.call(this,i({type:Un.POLYLINE,style:us.enableCSSParsing?i({points:"",miterLimit:"",isClosed:!1},n):i({},n),initialParsedStyle:us.enableCSSParsing?null:{points:{points:[],totalLength:0,segments:[]},miterLimit:4,isClosed:!1}},r))||this}return r(e,t),e.prototype.getTotalLength=function(){return this.parsedStyle.points.totalLength},e.prototype.getPointAtLength=function(t,e){return void 0===e&&(e=!1),this.getPoint(t/this.getTotalLength(),e)},e.prototype.getPoint=function(t,e){void 0===e&&(e=!1);var n=this.parsedStyle,r=n.defX,i=n.defY,o=n.points,a=o.points,s=o.segments,u=0,c=0;s.forEach((function(e,n){t>=e[0]&&t<=e[1]&&(u=(t-e[0])/(e[1]-e[0]),c=n)}));var h=On(a[c][0],a[c][1],a[c+1][0],a[c+1][1],u),l=h.x,d=h.y,f=ct(K(),J(l-r,d-i,0),e?this.getWorldTransform():this.getLocalTransform());return new yr(f[0],f[1])},e.prototype.getStartTangent=function(){var t=this.parsedStyle.points.points,e=[];return e.push([t[1][0],t[1][1]]),e.push([t[0][0],t[0][1]]),e},e.prototype.getEndTangent=function(){var t=this.parsedStyle.points.points,e=t.length-1,n=[];return n.push([t[e-1][0],t[e-1][1]]),n.push([t[e][0],t[e][1]]),n},e}(_s),Is=function(t){function e(e){void 0===e&&(e={});var n=e.style,r=o(e,["style"]);return t.call(this,i({type:Un.RECT,style:us.enableCSSParsing?i({x:"",y:"",width:"",height:"",radius:""},n):i({},n)},r))||this}return r(e,t),e}(Ns),Ls=function(t){function e(e){void 0===e&&(e={});var n=e.style,r=o(e,["style"]);return t.call(this,i({type:Un.TEXT,style:us.enableCSSParsing?i({x:"",y:"",text:"",fontSize:"",fontFamily:"",fontStyle:"",fontWeight:"",fontVariant:"",textAlign:"",textBaseline:"",textTransform:"",fill:"black",letterSpacing:"",lineHeight:"",miterLimit:"",wordWrap:!1,wordWrapWidth:0,leading:0,dx:"",dy:""},n):i({fill:"black"},n),initialParsedStyle:us.enableCSSParsing?{}:{x:0,y:0,fontSize:16,fontFamily:"sans-serif",fontStyle:"normal",fontWeight:"normal",fontVariant:"normal",lineHeight:0,letterSpacing:0,textBaseline:"alphabetic",textAlign:"start",wordWrap:!1,wordWrapWidth:0,leading:0,dx:0,dy:0}},r))||this}return r(e,t),e.prototype.getComputedTextLength=function(){var t;return(null===(t=this.parsedStyle.metrics)||void 0===t?void 0:t.maxLineWidth)||0},e.prototype.getLineBoundingRects=function(){var t;return(null===(t=this.parsedStyle.metrics)||void 0===t?void 0:t.lineMetrics)||[]},e.prototype.isOverflowing=function(){return!!this.parsedStyle.isOverflowing},e}(Ns),js=function(){function t(){this.registry={},this.define(Un.CIRCLE,Ss),this.define(Un.ELLIPSE,ks),this.define(Un.RECT,Is),this.define(Un.IMAGE,As),this.define(Un.LINE,Os),this.define(Un.GROUP,Ps),this.define(Un.PATH,Rs),this.define(Un.POLYGON,_s),this.define(Un.POLYLINE,Ds),this.define(Un.TEXT,Ls),this.define(Un.HTML,Cs)}return t.prototype.define=function(t,e){this.registry[t]=e},t.prototype.get=function(t){return this.registry[t]},t}(),zs=function(t){function e(){var e=t.call(this)||this;e.defaultView=null,e.ownerDocument=null,e.nodeName="document";try{e.timeline=new us.AnimationTimeline(e)}catch(t){}var n={};return Po.forEach((function(t){var e=t.n,r=t.inh,i=t.d;r&&i&&(n[e]=Ur(i)?i(Un.GROUP):i)})),e.documentElement=new Ps({id:"g-root",style:n}),e.documentElement.ownerDocument=e,e.documentElement.parentNode=e,e.childNodes=[e.documentElement],e}return r(e,t),Object.defineProperty(e.prototype,"children",{get:function(){return this.childNodes},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"childElementCount",{get:function(){return this.childNodes.length},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"firstElementChild",{get:function(){return this.firstChild},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"lastElementChild",{get:function(){return this.lastChild},enumerable:!1,configurable:!0}),e.prototype.createElement=function(t,e){if("svg"===t)return this.documentElement;var n=this.defaultView.customElements.get(t);n||(console.warn("Unsupported tagName: ",t),n="tspan"===t?Ls:Ps);var r=new n(e);return r.ownerDocument=this,r},e.prototype.createElementNS=function(t,e,n){return this.createElement(e,n)},e.prototype.cloneNode=function(t){throw new Error(Er)},e.prototype.destroy=function(){try{this.documentElement.destroyChildren(),this.timeline.destroy()}catch(t){}},e.prototype.elementsFromBBox=function(t,e,n,r){var i=this.defaultView.context.rBushRoot.search({minX:t,minY:e,maxX:n,maxY:r}),o=[];return i.forEach((function(t){var e=t.displayObject,n=e.parsedStyle.pointerEvents,r=["auto","visiblepainted","visiblefill","visiblestroke","visible"].includes(n);(!r||r&&e.isVisible())&&!e.isCulled()&&e.isInteractive()&&o.push(e)})),o.sort((function(t,e){return e.sortable.renderOrder-t.sortable.renderOrder})),o},e.prototype.elementFromPointSync=function(t,e){var n=this.defaultView.canvas2Viewport({x:t,y:e}),r=n.x,i=n.y,o=this.defaultView.getConfig(),a=o.width,s=o.height;if(r<0||i<0||r>a||i>s)return null;var u=this.defaultView.viewport2Client({x:r,y:i}),c=u.x,h=u.y,l=this.defaultView.getRenderingService().hooks.pickSync.call({topmost:!0,position:{x:t,y:e,viewportX:r,viewportY:i,clientX:c,clientY:h},picked:[]}).picked;return l&&l[0]||this.documentElement},e.prototype.elementFromPoint=function(t,e){return a(this,void 0,void 0,(function(){var n,r,i,o,a,u,c,h,l,d;return s(this,(function(s){switch(s.label){case 0:return n=this.defaultView.canvas2Viewport({x:t,y:e}),r=n.x,i=n.y,o=this.defaultView.getConfig(),a=o.width,u=o.height,r<0||i<0||r>a||i>u?[2,null]:(c=this.defaultView.viewport2Client({x:r,y:i}),h=c.x,l=c.y,[4,this.defaultView.getRenderingService().hooks.pick.promise({topmost:!0,position:{x:t,y:e,viewportX:r,viewportY:i,clientX:h,clientY:l},picked:[]})]);case 1:return[2,(d=s.sent().picked)&&d[0]||this.documentElement]}}))}))},e.prototype.elementsFromPointSync=function(t,e){var n=this.defaultView.canvas2Viewport({x:t,y:e}),r=n.x,i=n.y,o=this.defaultView.getConfig(),a=o.width,s=o.height;if(r<0||i<0||r>a||i>s)return[];var u=this.defaultView.viewport2Client({x:r,y:i}),c=u.x,h=u.y,l=this.defaultView.getRenderingService().hooks.pickSync.call({topmost:!1,position:{x:t,y:e,viewportX:r,viewportY:i,clientX:c,clientY:h},picked:[]}).picked;return l[l.length-1]!==this.documentElement&&l.push(this.documentElement),l},e.prototype.elementsFromPoint=function(t,e){return a(this,void 0,void 0,(function(){var n,r,i,o,a,u,c,h,l,d;return s(this,(function(s){switch(s.label){case 0:return n=this.defaultView.canvas2Viewport({x:t,y:e}),r=n.x,i=n.y,o=this.defaultView.getConfig(),a=o.width,u=o.height,r<0||i<0||r>a||i>u?[2,[]]:(c=this.defaultView.viewport2Client({x:r,y:i}),h=c.x,l=c.y,[4,this.defaultView.getRenderingService().hooks.pick.promise({topmost:!1,position:{x:t,y:e,viewportX:r,viewportY:i,clientX:h,clientY:l},picked:[]})]);case 1:return(d=s.sent().picked)[d.length-1]!==this.documentElement&&d.push(this.documentElement),[2,d]}}))}))},e.prototype.appendChild=function(t,e){throw new Error(wr)},e.prototype.insertBefore=function(t,e){throw new Error(wr)},e.prototype.removeChild=function(t,e){throw new Error(wr)},e.prototype.replaceChild=function(t,e,n){throw new Error(wr)},e.prototype.append=function(){throw new Error(wr)},e.prototype.prepend=function(){throw new Error(wr)},e.prototype.getElementById=function(t){return this.documentElement.getElementById(t)},e.prototype.getElementsByName=function(t){return this.documentElement.getElementsByName(t)},e.prototype.getElementsByTagName=function(t){return this.documentElement.getElementsByTagName(t)},e.prototype.getElementsByClassName=function(t){return this.documentElement.getElementsByClassName(t)},e.prototype.querySelector=function(t){return this.documentElement.querySelector(t)},e.prototype.querySelectorAll=function(t){return this.documentElement.querySelectorAll(t)},e.prototype.find=function(t){return this.documentElement.find(t)},e.prototype.findAll=function(t){return this.documentElement.findAll(t)},e}(Ua),Fs=function(){function t(t){this.strategies=t}return t.prototype.apply=function(e){var n=e.camera,r=e.renderingService,i=e.renderingContext,o=this.strategies;r.hooks.cull.tap(t.tag,(function(t){if(t){var e=t.cullable;return 0===o.length?e.visible=i.unculledEntities.indexOf(t.entity)>-1:e.visible=o.every((function(e){return e.isVisible(n,t)})),!t.isCulled()&&t.isVisible()?t:(t.dispatchEvent(new Ga(qa.CULLED)),null)}return t})),r.hooks.afterRender.tap(t.tag,(function(t){t.cullable.visibilityPlaneMask=-1}))},t.tag="Culling",t}(),Bs=function(){function t(){var t=this;this.autoPreventDefault=!1,this.rootPointerEvent=new Fa(null),this.rootWheelEvent=new Ba(null),this.onPointerMove=function(e){var n,r,i,o,a=null===(o=null===(i=t.context.renderingContext.root)||void 0===i?void 0:i.ownerDocument)||void 0===o?void 0:o.defaultView;if(!a.supportsTouchEvents||"touch"!==e.pointerType){var s=t.normalizeToPointerEvent(e,a);try{for(var c=u(s),h=c.next();!h.done;h=c.next()){var l=h.value,d=t.bootstrapEvent(t.rootPointerEvent,l,a,e);t.context.eventService.mapEvent(d)}}catch(t){n={error:t}}finally{try{h&&!h.done&&(r=c.return)&&r.call(c)}finally{if(n)throw n.error}}t.setCursor(t.context.eventService.cursor)}},this.onClick=function(e){var n,r,i,o,a=null===(o=null===(i=t.context.renderingContext.root)||void 0===i?void 0:i.ownerDocument)||void 0===o?void 0:o.defaultView,s=t.normalizeToPointerEvent(e,a);try{for(var c=u(s),h=c.next();!h.done;h=c.next()){var l=h.value,d=t.bootstrapEvent(t.rootPointerEvent,l,a,e);t.context.eventService.mapEvent(d)}}catch(t){n={error:t}}finally{try{h&&!h.done&&(r=c.return)&&r.call(c)}finally{if(n)throw n.error}}t.setCursor(t.context.eventService.cursor)}}return t.prototype.apply=function(e){var n=this;this.context=e;var r=e.renderingService,i=this.context.renderingContext.root.ownerDocument.defaultView;this.context.eventService.setPickHandler((function(t){return n.context.renderingService.hooks.pickSync.call({position:t,picked:[],topmost:!0}).picked[0]||null})),r.hooks.pointerWheel.tap(t.tag,(function(t){var e=n.normalizeWheelEvent(t);n.context.eventService.mapEvent(e)})),r.hooks.pointerDown.tap(t.tag,(function(t){var e,r;if(!i.supportsTouchEvents||"touch"!==t.pointerType){var o=n.normalizeToPointerEvent(t,i);if(n.autoPreventDefault&&o[0].isNormalized)(t.cancelable||!("cancelable"in t))&&t.preventDefault();try{for(var a=u(o),s=a.next();!s.done;s=a.next()){var c=s.value,h=n.bootstrapEvent(n.rootPointerEvent,c,i,t);n.context.eventService.mapEvent(h)}}catch(t){e={error:t}}finally{try{s&&!s.done&&(r=a.return)&&r.call(a)}finally{if(e)throw e.error}}n.setCursor(n.context.eventService.cursor)}})),r.hooks.pointerUp.tap(t.tag,(function(t){var e,r;if(!i.supportsTouchEvents||"touch"!==t.pointerType){var o=n.context.contextService.getDomElement(),a="outside";try{a=o&&t.target&&t.target!==o&&o.contains&&!o.contains(t.target)?"outside":""}catch(t){}var s=n.normalizeToPointerEvent(t,i);try{for(var c=u(s),h=c.next();!h.done;h=c.next()){var l=h.value,d=n.bootstrapEvent(n.rootPointerEvent,l,i,t);d.type+=a,n.context.eventService.mapEvent(d)}}catch(t){e={error:t}}finally{try{h&&!h.done&&(r=c.return)&&r.call(c)}finally{if(e)throw e.error}}n.setCursor(n.context.eventService.cursor)}})),r.hooks.pointerMove.tap(t.tag,this.onPointerMove),r.hooks.pointerOver.tap(t.tag,this.onPointerMove),r.hooks.pointerOut.tap(t.tag,this.onPointerMove),r.hooks.click.tap(t.tag,this.onClick),r.hooks.pointerCancel.tap(t.tag,(function(t){var e,r,o=n.normalizeToPointerEvent(t,i);try{for(var a=u(o),s=a.next();!s.done;s=a.next()){var c=s.value,h=n.bootstrapEvent(n.rootPointerEvent,c,i,t);n.context.eventService.mapEvent(h)}}catch(t){e={error:t}}finally{try{s&&!s.done&&(r=a.return)&&r.call(a)}finally{if(e)throw e.error}}n.setCursor(n.context.eventService.cursor)}))},t.prototype.getViewportXY=function(t){var e,n,r=t.offsetX,i=t.offsetY,o=t.clientX,a=t.clientY;if(!this.context.config.supportsCSSTransform||Pt(r)||Pt(i)){var s=this.context.eventService.client2Viewport(new yr(o,a));e=s.x,n=s.y}else e=r,n=i;return{x:e,y:n}},t.prototype.bootstrapEvent=function(t,e,n,r){t.view=n,t.originalEvent=null,t.nativeEvent=r,t.pointerId=e.pointerId,t.width=e.width,t.height=e.height,t.isPrimary=e.isPrimary,t.pointerType=e.pointerType,t.pressure=e.pressure,t.tangentialPressure=e.tangentialPressure,t.tiltX=e.tiltX,t.tiltY=e.tiltY,t.twist=e.twist,this.transferMouseData(t,e);var i=this.getViewportXY(e),o=i.x,a=i.y;t.viewport.x=o,t.viewport.y=a;var s=this.context.eventService.viewport2Canvas(t.viewport),u=s.x,c=s.y;return t.canvas.x=u,t.canvas.y=c,t.global.copyFrom(t.canvas),t.offset.copyFrom(t.canvas),t.isTrusted=r.isTrusted,"pointerleave"===t.type&&(t.type="pointerout"),t.type.startsWith("mouse")&&(t.type=t.type.replace("mouse","pointer")),t.type.startsWith("touch")&&(t.type=aa[t.type]||t.type),t},t.prototype.normalizeWheelEvent=function(t){var e=this.rootWheelEvent;this.transferMouseData(e,t),e.deltaMode=t.deltaMode,e.deltaX=t.deltaX,e.deltaY=t.deltaY,e.deltaZ=t.deltaZ;var n=this.getViewportXY(t),r=n.x,i=n.y;e.viewport.x=r,e.viewport.y=i;var o=this.context.eventService.viewport2Canvas(e.viewport),a=o.x,s=o.y;return e.canvas.x=a,e.canvas.y=s,e.global.copyFrom(e.canvas),e.offset.copyFrom(e.canvas),e.nativeEvent=t,e.type=t.type,e},t.prototype.transferMouseData=function(t,e){t.isTrusted=e.isTrusted,t.srcElement=e.srcElement,t.timeStamp=sa.now(),t.type=e.type,t.altKey=e.altKey,t.metaKey=e.metaKey,t.shiftKey=e.shiftKey,t.ctrlKey=e.ctrlKey,t.button=e.button,t.buttons=e.buttons,t.client.x=e.clientX,t.client.y=e.clientY,t.movement.x=e.movementX,t.movement.y=e.movementY,t.page.x=e.pageX,t.page.y=e.pageY,t.screen.x=e.screenX,t.screen.y=e.screenY,t.relatedTarget=null},t.prototype.setCursor=function(t){this.context.contextService.applyCursorStyle(t||this.context.config.cursor||"default")},t.prototype.normalizeToPointerEvent=function(t,e){var n=[];if(e.isTouchEvent(t))for(var r=0;r<t.changedTouches.length;r++){var i=t.changedTouches[r];Zt(i.button)&&(i.button=0),Zt(i.buttons)&&(i.buttons=1),Zt(i.isPrimary)&&(i.isPrimary=1===t.touches.length&&"touchstart"===t.type),Zt(i.width)&&(i.width=i.radiusX||1),Zt(i.height)&&(i.height=i.radiusY||1),Zt(i.tiltX)&&(i.tiltX=0),Zt(i.tiltY)&&(i.tiltY=0),Zt(i.pointerType)&&(i.pointerType="touch"),Zt(i.pointerId)&&(i.pointerId=i.identifier||0),Zt(i.pressure)&&(i.pressure=i.force||.5),Zt(i.twist)&&(i.twist=0),Zt(i.tangentialPressure)&&(i.tangentialPressure=0),i.isNormalized=!0,i.type=t.type,n.push(i)}else if(e.isMouseEvent(t)){var o=t;Zt(o.isPrimary)&&(o.isPrimary=!0),Zt(o.width)&&(o.width=1),Zt(o.height)&&(o.height=1),Zt(o.tiltX)&&(o.tiltX=0),Zt(o.tiltY)&&(o.tiltY=0),Zt(o.pointerType)&&(o.pointerType="mouse"),Zt(o.pointerId)&&(o.pointerId=1),Zt(o.pressure)&&(o.pressure=.5),Zt(o.twist)&&(o.twist=0),Zt(o.tangentialPressure)&&(o.tangentialPressure=0),o.isNormalized=!0,n.push(o)}else n.push(t);return n},t.tag="Event",t}(),Gs=[Un.CIRCLE,Un.ELLIPSE,Un.IMAGE,Un.RECT,Un.LINE,Un.POLYLINE,Un.POLYGON,Un.TEXT,Un.PATH,Un.HTML],Vs=function(){function t(){}return t.prototype.isVisible=function(t,e){var n,r,i=e.cullable;if(!i.enable)return!0;var o=e.getRenderBounds();if(dr.isEmpty(o))return!1;var a=t.getFrustum(),s=null===(r=null===(n=e.parentNode)||void 0===n?void 0:n.cullable)||void 0===r?void 0:r.visibilityPlaneMask;return i.visibilityPlaneMask=this.computeVisibilityWithPlaneMask(e,o,s||lr.INDETERMINATE,a.planes),i.visible=i.visibilityPlaneMask!==lr.OUTSIDE,i.visible},t.prototype.computeVisibilityWithPlaneMask=function(t,e,n,r){if(n===lr.OUTSIDE||n===lr.INSIDE)return n;for(var i=lr.INSIDE,o=Gs.indexOf(t.nodeName)>-1,a=0,s=r.length;a<s;++a){var u=1<<a;if(0!=(n&u)&&(!o||4!==a&&5!==a)){var c=r[a],h=c.normal,l=c.distance;if(at(h,e.getPositiveFarPoint(r[a]))+l<0)return lr.OUTSIDE;at(h,e.getNegativeFarPoint(r[a]))+l<0&&(i|=u)}}return i},t}(),Us=function(){function t(){this.toSync=new Set}return t.prototype.apply=function(e){var n=this,r=e.renderingService,i=e.renderingContext,o=e.rBushRoot,a=i.root.ownerDocument.defaultView;this.rBush=o;var s=function(t){t.target.renderable.dirty=!0,r.dirtify()},u=function(t){var e=t.detail.affectChildren,i=t.target;e&&i.forEach((function(t){n.toSync.add(t)}));for(var o=i;o;)o.renderable&&n.toSync.add(o),o=o.parentElement;r.dirtify()},c=function(t){var e=t.target;us.enableSizeAttenuation&&us.styleValueRegistry.updateSizeAttenuation(e,a.getCamera().getZoom()),us.enableCSSParsing&&us.styleValueRegistry.recalc(e),us.sceneGraphService.dirtifyToRoot(e),r.dirtify()},h=function(t){var e=t.target,i=e.rBushNode;i.aabb&&n.rBush.remove(i.aabb),n.toSync.delete(e),us.sceneGraphService.dirtifyToRoot(e),r.dirtify()};r.hooks.init.tap(t.tag,(function(){a.addEventListener(qa.MOUNTED,c),a.addEventListener(qa.UNMOUNTED,h),a.addEventListener(qa.ATTR_MODIFIED,s),a.addEventListener(qa.BOUNDS_CHANGED,u)})),r.hooks.destroy.tap(t.tag,(function(){a.removeEventListener(qa.MOUNTED,c),a.removeEventListener(qa.UNMOUNTED,h),a.removeEventListener(qa.ATTR_MODIFIED,s),a.removeEventListener(qa.BOUNDS_CHANGED,u),n.toSync.clear()})),r.hooks.endFrame.tap(t.tag,(function(){n.syncRTree()}))},t.prototype.syncRTree=function(){var t=this,e=[];Array.from(this.toSync).filter((function(t){return t.isConnected})).forEach((function(n){var r=n.rBushNode;r&&r.aabb&&t.rBush.remove(r.aabb);var i=n.getRenderBounds();if(i){var o=c(i.getMin(),2),a=o[0],s=o[1],u=c(i.getMax(),2),h=u[0],l=u[1];r.aabb||(r.aabb={}),r.aabb.displayObject=n,r.aabb.minX=a,r.aabb.minY=s,r.aabb.maxX=h,r.aabb.maxY=l}r.aabb&&(isNaN(r.aabb.maxX)||isNaN(r.aabb.maxX)||isNaN(r.aabb.minX)||isNaN(r.aabb.minY)||e.push(r.aabb))})),this.rBush.load(e),e.length=0,this.toSync.clear()},t.tag="Prepare",t}();!function(t){t.READY="ready",t.BEFORE_RENDER="beforerender",t.RERENDER="rerender",t.AFTER_RENDER="afterrender",t.BEFORE_DESTROY="beforedestroy",t.AFTER_DESTROY="afterdestroy",t.RESIZE="resize",t.DIRTY_RECTANGLE="dirtyrectangle",t.RENDERER_CHANGED="rendererchanged"}(vs||(vs={}));var Ws=new Ga(qa.MOUNTED),Hs=new Ga(qa.UNMOUNTED),qs=new Ga(vs.BEFORE_RENDER),Ys=new Ga(vs.RERENDER),$s=new Ga(vs.AFTER_RENDER),Xs=function(t){function e(e){var n=t.call(this)||this;n.Element=Ns,n.inited=!1,n.context={},n.document=new zs,n.document.defaultView=n,n.customElements=new js;var r=e.container,i=e.canvas,o=e.offscreenCanvas,a=e.width,s=e.height,u=e.devicePixelRatio,c=e.renderer,h=e.background,l=e.cursor,d=e.document,f=e.requestAnimationFrame,p=e.cancelAnimationFrame,g=e.createImage,m=e.supportsPointerEvents,v=e.supportsTouchEvents,y=e.supportsCSSTransform,b=e.supportsMutipleCanvasesInOneContainer,E=e.useNativeClickEvent,w=e.alwaysTriggerPointerEventOnCanvas,x=e.isTouchEvent,M=e.isMouseEvent;b||function(t,e){if(t){var n="string"==typeof t?t:t.id||ta++;Jo[n]&&Jo[n].destroy(),Jo[n]=e}}(r,n);var N=a,S=s,T=u;return i&&(T=(T=u||ea&&window.devicePixelRatio||1)>=1?Math.ceil(T):1,N=a||function(t){var e=oa(t,"width");return"auto"===e?t.offsetWidth:parseFloat(e)}(i)||i.width/T,S=s||function(t){var e=oa(t,"height");return"auto"===e?t.offsetHeight:parseFloat(e)}(i)||i.height/T),o&&(us.offscreenCanvas=o),n.devicePixelRatio=T,n.requestAnimationFrame=null!=f?f:ya.bind(us.globalThis),n.cancelAnimationFrame=null!=p?p:ba.bind(us.globalThis),n.supportsTouchEvents=null!=v?v:"ontouchstart"in us.globalThis,n.supportsPointerEvents=null!=m?m:!!us.globalThis.PointerEvent,n.isTouchEvent=null!=x?x:function(t){return n.supportsTouchEvents&&t instanceof us.globalThis.TouchEvent},n.isMouseEvent=null!=M?M:function(t){return!us.globalThis.MouseEvent||t instanceof us.globalThis.MouseEvent&&(!n.supportsPointerEvents||!(t instanceof us.globalThis.PointerEvent))},n.initRenderingContext({container:r,canvas:i,width:N,height:S,renderer:c,offscreenCanvas:o,devicePixelRatio:T,cursor:l||"default",background:h||"transparent",createImage:g,document:d,supportsCSSTransform:y,useNativeClickEvent:E,alwaysTriggerPointerEventOnCanvas:w}),n.initDefaultCamera(N,S,c.clipSpaceNearZ),n.initRenderer(c,!0),n}return r(e,t),e.prototype.initRenderingContext=function(t){this.context.config=t,this.context.renderingContext={root:this.document.documentElement,renderListCurrentFrame:[],unculledEntities:[],renderReasons:new Set,force:!1,dirty:!1}},e.prototype.initDefaultCamera=function(t,e,n){var r=this,i=new us.CameraContribution;i.clipSpaceNearZ=n,i.setType(pr.EXPLORING,gr.DEFAULT).setPosition(t/2,e/2,500).setFocalPoint(t/2,e/2,0).setOrthographic(t/-2,t/2,e/2,e/-2,.1,1e3),i.canvas=this,i.eventEmitter.on(kr,(function(){r.context.renderingContext.renderReasons.add(La.CAMERA_CHANGED),us.enableSizeAttenuation&&r.getConfig().renderer.getConfig().enableSizeAttenuation&&r.updateSizeAttenuation()})),this.context.camera=i},e.prototype.updateSizeAttenuation=function(){var t=this.getCamera().getZoom();this.document.documentElement.forEach((function(e){us.styleValueRegistry.updateSizeAttenuation(e,t)}))},e.prototype.getConfig=function(){return this.context.config},e.prototype.getRoot=function(){return this.document.documentElement},e.prototype.getCamera=function(){return this.context.camera},e.prototype.getContextService=function(){return this.context.contextService},e.prototype.getEventService=function(){return this.context.eventService},e.prototype.getRenderingService=function(){return this.context.renderingService},e.prototype.getRenderingContext=function(){return this.context.renderingContext},e.prototype.getStats=function(){return this.getRenderingService().getStats()},Object.defineProperty(e.prototype,"ready",{get:function(){var t=this;return this.readyPromise||(this.readyPromise=new Promise((function(e){t.resolveReadyPromise=function(){e(t)}})),this.inited&&this.resolveReadyPromise()),this.readyPromise},enumerable:!1,configurable:!0}),e.prototype.destroy=function(t,e){(void 0===t&&(t=!0),void 0===e&&(e=!1),e||this.dispatchEvent(new Ga(vs.BEFORE_DESTROY)),this.frameId)&&(this.getConfig().cancelAnimationFrame||cancelAnimationFrame)(this.frameId);var n=this.getRoot();this.unmountChildren(n),t&&(this.document.destroy(),this.getEventService().destroy()),this.getRenderingService().destroy(),this.getContextService().destroy(),t&&this.context.rBushRoot&&(this.context.rBushRoot.clear(),this.context.rBushRoot=null,this.context.renderingContext.root=null),e||this.dispatchEvent(new Ga(vs.AFTER_DESTROY))},e.prototype.changeSize=function(t,e){this.resize(t,e)},e.prototype.resize=function(t,e){var n=this.context.config;n.width=t,n.height=e,this.getContextService().resize(t,e);var r=this.context.camera,i=r.getProjectionMode();r.setPosition(t/2,e/2,500).setFocalPoint(t/2,e/2,0),i===mr.ORTHOGRAPHIC?r.setOrthographic(t/-2,t/2,e/2,e/-2,r.getNear(),r.getFar()):r.setAspect(t/e),this.dispatchEvent(new Ga(vs.RESIZE,{width:t,height:e}))},e.prototype.appendChild=function(t,e){return this.document.documentElement.appendChild(t,e)},e.prototype.insertBefore=function(t,e){return this.document.documentElement.insertBefore(t,e)},e.prototype.removeChild=function(t){return this.document.documentElement.removeChild(t)},e.prototype.removeChildren=function(){this.document.documentElement.removeChildren()},e.prototype.destroyChildren=function(){this.document.documentElement.destroyChildren()},e.prototype.render=function(){var t=this;this.dispatchEvent(qs),this.getRenderingService().render(this.getConfig(),(function(){t.dispatchEvent(Ys)})),this.dispatchEvent($s)},e.prototype.run=function(){var t=this,e=function(){t.render(),t.frameId=t.requestAnimationFrame(e)};e()},e.prototype.initRenderer=function(t,e){var n=this;if(void 0===e&&(e=!1),!t)throw new Error("Renderer is required.");this.inited=!1,this.readyPromise=void 0,this.context.rBushRoot=new Hn,this.context.renderingPlugins=[],this.context.renderingPlugins.push(new Bs,new Us,new Fs([new Vs])),this.loadRendererContainerModule(t),this.context.contextService=new this.context.ContextService(i(i({},us),this.context)),this.context.renderingService=new Ya(us,this.context),this.context.eventService=new Wa(us,this.context),this.context.eventService.init(),this.context.contextService.init?(this.context.contextService.init(),this.initRenderingService(t,e,!0)):this.context.contextService.initAsync().then((function(){n.initRenderingService(t,e)}))},e.prototype.initRenderingService=function(t,e,n){var r=this;void 0===e&&(e=!1),void 0===n&&(n=!1),this.context.renderingService.init((function(){r.inited=!0,e?(n?r.requestAnimationFrame((function(){r.dispatchEvent(new Ga(vs.READY))})):r.dispatchEvent(new Ga(vs.READY)),r.readyPromise&&r.resolveReadyPromise()):r.dispatchEvent(new Ga(vs.RENDERER_CHANGED)),e||r.getRoot().forEach((function(t){var e=t.renderable;e&&(e.renderBoundsDirty=!0,e.boundsDirty=!0,e.dirty=!0)})),r.mountChildren(r.getRoot()),t.getConfig().enableAutoRendering&&r.run()}))},e.prototype.loadRendererContainerModule=function(t){var e=this;t.getPlugins().forEach((function(t){t.context=e.context,t.init(us)}))},e.prototype.setRenderer=function(t){var e=this.getConfig();if(e.renderer!==t){var n=e.renderer;e.renderer=t,this.destroy(!1,!0),h([],c(null==n?void 0:n.getPlugins()),!1).reverse().forEach((function(t){t.destroy(us)})),this.initRenderer(t)}},e.prototype.setCursor=function(t){this.getConfig().cursor=t,this.getContextService().applyCursorStyle(t)},e.prototype.unmountChildren=function(t){var e=this;t.childNodes.forEach((function(t){e.unmountChildren(t)})),this.inited&&(t.isMutationObserved?t.dispatchEvent(Hs):(Hs.target=t,this.dispatchEvent(Hs,!0)),t!==this.document.documentElement&&(t.ownerDocument=null),t.isConnected=!1),t.isCustomElement&&t.disconnectedCallback&&t.disconnectedCallback()},e.prototype.mountChildren=function(t){var e=this;this.inited?t.isConnected||(t.ownerDocument=this.document,t.isConnected=!0,t.isMutationObserved?t.dispatchEvent(Ws):(Ws.target=t,this.dispatchEvent(Ws,!0))):console.warn("[g]: You are trying to call `canvas.appendChild` before canvas' initialization finished. You can either await `canvas.ready` or listen to `CanvasEvent.READY` manually.","appended child: ",t.nodeName),t.childNodes.forEach((function(t){e.mountChildren(t)})),t.isCustomElement&&t.connectedCallback&&t.connectedCallback()},e.prototype.client2Viewport=function(t){return this.getEventService().client2Viewport(t)},e.prototype.viewport2Client=function(t){return this.getEventService().viewport2Client(t)},e.prototype.viewport2Canvas=function(t){return this.getEventService().viewport2Canvas(t)},e.prototype.canvas2Viewport=function(t){return this.getEventService().canvas2Viewport(t)},e.prototype.getPointByClient=function(t,e){return this.client2Viewport({x:t,y:e})},e.prototype.getClientByPoint=function(t,e){return this.viewport2Client({x:t,y:e})},e}(Va),Ks=function(t){function e(){var e=t.apply(this,h([],c(arguments),!1))||this;return e.landmarks=[],e}return r(e,t),e.prototype.rotate=function(t,e,n){if(this.relElevation=Qn(e),this.relAzimuth=Qn(t),this.relRoll=Qn(n),this.elevation+=this.relElevation,this.azimuth+=this.relAzimuth,this.roll+=this.relRoll,this.type===pr.EXPLORING){var r=mt(gt(),[1,0,0],tr((this.rotateWorld?1:-1)*this.relElevation)),i=mt(gt(),[0,1,0],tr((this.rotateWorld?1:-1)*this.relAzimuth)),o=mt(gt(),[0,0,1],tr(this.relRoll)),a=vt(gt(),i,r);a=vt(gt(),a,o);var s=F(b(),a);P(this.matrix,this.matrix,[0,0,-this.distance]),k(this.matrix,this.matrix,s),P(this.matrix,this.matrix,[0,0,this.distance])}else{if(Math.abs(this.elevation)>90)return this;this.computeMatrix()}return this._getAxes(),this.type===pr.ORBITING||this.type===pr.EXPLORING?this._getPosition():this.type===pr.TRACKING&&this._getFocalPoint(),this._update(),this},e.prototype.pan=function(t,e){var n=Jn(t,e,0),r=Z(this.position);return nt(r,r,it(K(),this.right,n[0])),nt(r,r,it(K(),this.up,n[1])),this._setPosition(r),this.triggerUpdate(),this},e.prototype.dolly=function(t){var e=this.forward,n=Z(this.position),r=this.dollyingStep,i=this.distance+t*this.dollyingStep;return r=Math.max(Math.min(i,this.maxDistance),this.minDistance)-this.distance,n[0]+=r*e[0],n[1]+=r*e[1],n[2]+=r*e[2],this._setPosition(n),this.type===pr.ORBITING||this.type===pr.EXPLORING?this._getDistance():this.type===pr.TRACKING&&nt(this.focalPoint,n,this.distanceVector),this.triggerUpdate(),this},e.prototype.cancelLandmarkAnimation=function(){void 0!==this.landmarkAnimationID&&this.canvas.cancelAnimationFrame(this.landmarkAnimationID)},e.prototype.createLandmark=function(t,e){var n,r,i,o;void 0===e&&(e={});var a=e.position,s=void 0===a?this.position:a,u=e.focalPoint,c=void 0===u?this.focalPoint:u,h=e.roll,l=e.zoom,d=new us.CameraContribution;d.setType(this.type,void 0),d.setPosition(s[0],null!==(n=s[1])&&void 0!==n?n:this.position[1],null!==(r=s[2])&&void 0!==r?r:this.position[2]),d.setFocalPoint(c[0],null!==(i=c[1])&&void 0!==i?i:this.focalPoint[1],null!==(o=c[2])&&void 0!==o?o:this.focalPoint[2]),d.setRoll(null!=h?h:this.roll),d.setZoom(null!=l?l:this.zoom);var f={name:t,matrix:E(d.getWorldTransform()),right:Z(d.right),up:Z(d.up),forward:Z(d.forward),position:Z(d.getPosition()),focalPoint:Z(d.getFocalPoint()),distanceVector:Z(d.getDistanceVector()),distance:d.getDistance(),dollyingStep:d.getDollyingStep(),azimuth:d.getAzimuth(),elevation:d.getElevation(),roll:d.getRoll(),relAzimuth:d.relAzimuth,relElevation:d.relElevation,relRoll:d.relRoll,zoom:d.getZoom()};return this.landmarks.push(f),f},e.prototype.gotoLandmark=function(t,e){var n=this;void 0===e&&(e={});var r=zt(t)?this.landmarks.find((function(e){return e.name===t})):t;if(r){var i=Vt(e)?{duration:e}:e,o=i.easing,a=void 0===o?"linear":o,s=i.duration,u=void 0===s?100:s,c=i.easingFunction,h=void 0===c?void 0:c,l=i.onfinish,d=void 0===l?void 0:l,f=i.onframe,p=void 0===f?void 0:f;if(0===u)return this.syncFromLandmark(r),void(d&&d());this.cancelLandmarkAnimation();var g,m=r.position,v=r.focalPoint,y=r.zoom,b=r.roll,E=h||us.EasingFunction(a),w=function(){n.setFocalPoint(v),n.setPosition(m),n.setRoll(b),n.setZoom(y),n.computeMatrix(),n.triggerUpdate(),d&&d()},x=function(t){void 0===g&&(g=t);var e=t-g;if(e>u)w();else{var r,i,o=E(e/u),a=K(),s=K();ut(a,n.focalPoint,v,o),ut(s,n.position,m,o),i=n.roll*(1-o)+b*o,r=n.zoom*(1-o)+y*o,n.setFocalPoint(a),n.setPosition(s),n.setRoll(i),n.setZoom(r),lt(a,v)+lt(s,m)<=.01&&null==y&&null==b?w():(n.computeMatrix(),n.triggerUpdate(),e<u&&(p&&p(o),n.landmarkAnimationID=n.canvas.requestAnimationFrame(x)))}};this.canvas.requestAnimationFrame(x)}},e.prototype.syncFromLandmark=function(t){this.matrix=w(this.matrix,t.matrix),this.right=tt(this.right,t.right),this.up=tt(this.up,t.up),this.forward=tt(this.forward,t.forward),this.position=tt(this.position,t.position),this.focalPoint=tt(this.focalPoint,t.focalPoint),this.distanceVector=tt(this.distanceVector,t.distanceVector),this.azimuth=t.azimuth,this.elevation=t.elevation,this.roll=t.roll,this.relAzimuth=t.relAzimuth,this.relElevation=t.relElevation,this.relRoll=t.relRoll,this.dollyingStep=t.dollyingStep,this.distance=t.distance,this.zoom=t.zoom},e}(Cr);us.CameraContribution=Ks;var Zs=function(t){function e(e,n,r,i){var o=t.call(this,e)||this;return o.currentTime=r,o.timelineTime=i,o.target=n,o.type="finish",o.bubbles=!1,o.currentTarget=n,o.defaultPrevented=!1,o.eventPhase=o.AT_TARGET,o.timeStamp=Date.now(),o.currentTime=r,o.timelineTime=i,o}return r(e,t),e}(ja),Qs=0,Js=function(){function t(t,e){var n;this.currentTimePending=!1,this._idle=!0,this._paused=!1,this._finishedFlag=!0,this._currentTime=0,this._playbackRate=1,this._inTimeline=!0,this.effect=t,t.animation=this,this.timeline=e,this.id="".concat(Qs++),this._inEffect=!!this.effect.update(0),this._totalDuration=Number(null===(n=this.effect)||void 0===n?void 0:n.getComputedTiming().endTime),this._holdTime=0,this._paused=!1,this.oldPlayState="idle",this.updatePromises()}return Object.defineProperty(t.prototype,"pending",{get:function(){return null===this._startTime&&!this._paused&&0!==this.playbackRate||this.currentTimePending},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"playState",{get:function(){return this._idle?"idle":this._isFinished?"finished":this._paused?"paused":"running"},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"ready",{get:function(){var t=this;return this.readyPromise||(-1===this.timeline.animationsWithPromises.indexOf(this)&&this.timeline.animationsWithPromises.push(this),this.readyPromise=new Promise((function(e,n){t.resolveReadyPromise=function(){e(t)},t.rejectReadyPromise=function(){n(new Error)}})),this.pending||this.resolveReadyPromise()),this.readyPromise},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"finished",{get:function(){var t=this;return this.finishedPromise||(-1===this.timeline.animationsWithPromises.indexOf(this)&&this.timeline.animationsWithPromises.push(this),this.finishedPromise=new Promise((function(e,n){t.resolveFinishedPromise=function(){e(t)},t.rejectFinishedPromise=function(){n(new Error)}})),"finished"===this.playState&&this.resolveFinishedPromise()),this.finishedPromise},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"currentTime",{get:function(){return this.updatePromises(),this._idle||this.currentTimePending?null:this._currentTime},set:function(t){var e;t=Number(t),isNaN(t)||(this.timeline.restart(),this._paused||null===this._startTime||(this._startTime=Number(null===(e=this.timeline)||void 0===e?void 0:e.currentTime)-t/this.playbackRate),this.currentTimePending=!1,this._currentTime!==t&&(this._idle&&(this._idle=!1,this._paused=!0),this.tickCurrentTime(t,!0),this.timeline.applyDirtiedAnimation(this)))},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"startTime",{get:function(){return this._startTime},set:function(t){if(null!==t){if(this.updatePromises(),t=Number(t),isNaN(t))return;if(this._paused||this._idle)return;this._startTime=t,this.tickCurrentTime((Number(this.timeline.currentTime)-this._startTime)*this.playbackRate),this.timeline.applyDirtiedAnimation(this),this.updatePromises()}},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"playbackRate",{get:function(){return this._playbackRate},set:function(t){if(t!==this._playbackRate){this.updatePromises();var e=this.currentTime;this._playbackRate=t,this.startTime=null,"paused"!==this.playState&&"idle"!==this.playState&&(this._finishedFlag=!1,this._idle=!1,this.ensureAlive(),this.timeline.applyDirtiedAnimation(this)),null!==e&&(this.currentTime=e),this.updatePromises()}},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"_isFinished",{get:function(){return!this._idle&&(this._playbackRate>0&&Number(this._currentTime)>=this._totalDuration||this._playbackRate<0&&Number(this._currentTime)<=0)},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"totalDuration",{get:function(){return this._totalDuration},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"_needsTick",{get:function(){return this.pending||"running"===this.playState||!this._finishedFlag},enumerable:!1,configurable:!0}),t.prototype.updatePromises=function(){var t=this.oldPlayState,e=this.pending?"pending":this.playState;return this.readyPromise&&e!==t&&("idle"===e?(this.rejectReadyPromise(),this.readyPromise=void 0):"pending"===t?this.resolveReadyPromise():"pending"===e&&(this.readyPromise=void 0)),this.finishedPromise&&e!==t&&("idle"===e?(this.rejectFinishedPromise(),this.finishedPromise=void 0):"finished"===e?this.resolveFinishedPromise():"finished"===t&&(this.finishedPromise=void 0)),this.oldPlayState=e,this.readyPromise||this.finishedPromise},t.prototype.play=function(){this.updatePromises(),this._paused=!1,(this._isFinished||this._idle)&&(this.rewind(),this._startTime=null),this._finishedFlag=!1,this._idle=!1,this.ensureAlive(),this.timeline.applyDirtiedAnimation(this),-1===this.timeline.animations.indexOf(this)&&this.timeline.animations.push(this),this.updatePromises()},t.prototype.pause=function(){this.updatePromises(),this.currentTime&&(this._holdTime=this.currentTime),this._isFinished||this._paused||this._idle?this._idle&&(this.rewind(),this._idle=!1):this.currentTimePending=!0,this._startTime=null,this._paused=!0,this.updatePromises()},t.prototype.finish=function(){this.updatePromises(),this._idle||(this.currentTime=this._playbackRate>0?this._totalDuration:0,this._startTime=this._totalDuration-this.currentTime,this.currentTimePending=!1,this.timeline.applyDirtiedAnimation(this),this.updatePromises())},t.prototype.cancel=function(){var t=this;if(this.updatePromises(),this._inEffect&&(this._inEffect=!1,this._idle=!0,this._paused=!1,this._finishedFlag=!0,this._currentTime=0,this._startTime=null,this.effect.update(null),this.timeline.applyDirtiedAnimation(this),this.updatePromises(),this.oncancel)){var e=new Zs(null,this,this.currentTime,null);setTimeout((function(){t.oncancel(e)}))}},t.prototype.reverse=function(){this.updatePromises();var t=this.currentTime;this.playbackRate*=-1,this.play(),null!==t&&(this.currentTime=t),this.updatePromises()},t.prototype.updatePlaybackRate=function(t){this.playbackRate=t},t.prototype.targetAnimations=function(){var t;return(null===(t=this.effect)||void 0===t?void 0:t.target).getAnimations()},t.prototype.markTarget=function(){var t=this.targetAnimations();-1===t.indexOf(this)&&t.push(this)},t.prototype.unmarkTarget=function(){var t=this.targetAnimations(),e=t.indexOf(this);-1!==e&&t.splice(e,1)},t.prototype.tick=function(t,e){this._idle||this._paused||(null===this._startTime?e&&(this.startTime=t-this._currentTime/this.playbackRate):this._isFinished||this.tickCurrentTime((t-this._startTime)*this.playbackRate)),e&&(this.currentTimePending=!1,this.fireEvents(t))},t.prototype.rewind=function(){if(this.playbackRate>=0)this.currentTime=0;else{if(!(this._totalDuration<1/0))throw new Error("Unable to rewind negative playback rate animation with infinite duration");this.currentTime=this._totalDuration}},t.prototype.persist=function(){throw new Error(Er)},t.prototype.addEventListener=function(t,e,n){throw new Error(Er)},t.prototype.removeEventListener=function(t,e,n){throw new Error(Er)},t.prototype.dispatchEvent=function(t){throw new Error(Er)},t.prototype.commitStyles=function(){throw new Error(Er)},t.prototype.ensureAlive=function(){var t,e;this.playbackRate<0&&0===this.currentTime?this._inEffect=!!(null===(t=this.effect)||void 0===t?void 0:t.update(-1)):this._inEffect=!!(null===(e=this.effect)||void 0===e?void 0:e.update(this.currentTime)),this._inTimeline||!this._inEffect&&this._finishedFlag||(this._inTimeline=!0,this.timeline.animations.push(this))},t.prototype.tickCurrentTime=function(t,e){t!==this._currentTime&&(this._currentTime=t,this._isFinished&&!e&&(this._currentTime=this._playbackRate>0?this._totalDuration:0),this.ensureAlive())},t.prototype.fireEvents=function(t){var e=this;if(this._isFinished){if(!this._finishedFlag){if(this.onfinish){var n=new Zs(null,this,this.currentTime,t);setTimeout((function(){e.onfinish&&e.onfinish(n)}))}this._finishedFlag=!0}}else{if(this.onframe&&"running"===this.playState){var r=new Zs(null,this,this.currentTime,t);this.onframe(r)}this._finishedFlag=!1}},t}(),tu=.1,eu="function"==typeof Float32Array,nu=function(t,e){return 1-3*e+3*t},ru=function(t,e){return 3*e-6*t},iu=function(t){return 3*t},ou=function(t,e,n){return((nu(e,n)*t+ru(e,n))*t+iu(e))*t},au=function(t,e,n){return 3*nu(e,n)*t*t+2*ru(e,n)*t+iu(e)},su=function(t,e,n,r){if(!(0<=t&&t<=1&&0<=n&&n<=1))throw new Error("bezier x values must be in [0, 1] range");if(t===e&&n===r)return function(t){return t};for(var i=eu?new Float32Array(11):new Array(11),o=0;o<11;++o)i[o]=ou(o*tu,t,n);var a=function(e){for(var r=0,o=1;10!==o&&i[o]<=e;++o)r+=tu;--o;var a=r+(e-i[o])/(i[o+1]-i[o])*tu,s=au(a,t,n);return s>=.001?function(t,e,n,r){for(var i=0;i<4;++i){var o=au(e,n,r);if(0===o)return e;e-=(ou(e,n,r)-t)/o}return e}(e,a,t,n):0===s?a:function(t,e,n,r,i){var o,a,s=0;do{(o=ou(a=e+(n-e)/2,r,i)-t)>0?n=a:e=a}while(Math.abs(o)>1e-7&&++s<10);return a}(e,r,r+tu,t,n)};return function(t){return 0===t||1===t?t:ou(a(t),e,r)}},uu=function(t){return Math.pow(t,2)},cu=function(t){return Math.pow(t,3)},hu=function(t){return Math.pow(t,4)},lu=function(t){return Math.pow(t,5)},du=function(t){return Math.pow(t,6)},fu=function(t){return 1-Math.cos(t*Math.PI/2)},pu=function(t){return 1-Math.sqrt(1-t*t)},gu=function(t){return t*t*(3*t-2)},mu=function(t){for(var e,n=4;t<((e=Math.pow(2,--n))-1)/11;);return 1/Math.pow(4,3-n)-7.5625*Math.pow((3*e-2)/22-t,2)},vu=function(t,e){void 0===e&&(e=[]);var n=c(e,2),r=n[0],i=void 0===r?1:r,o=n[1],a=void 0===o?.5:o,s=Gt(Number(i),1,10),u=Gt(Number(a),.1,2);return 0===t||1===t?t:-s*Math.pow(2,10*(t-1))*Math.sin((t-1-u/(2*Math.PI)*Math.asin(1/s))*(2*Math.PI)/u)},yu=function(t,e,n){void 0===e&&(e=[]);var r=c(e,4),i=r[0],o=void 0===i?1:i,a=r[1],s=void 0===a?100:a,u=r[2],h=void 0===u?10:u,l=r[3],d=void 0===l?0:l;o=Gt(o,.1,1e3),s=Gt(s,.1,1e3),h=Gt(h,.1,1e3),d=Gt(d,.1,1e3);var f=Math.sqrt(s/o),p=h/(2*Math.sqrt(s*o)),g=p<1?f*Math.sqrt(1-p*p):0,m=p<1?(p*f-d)/g:-d+f,v=n?n*t/1e3:t;return v=p<1?Math.exp(-v*p*f)*(1*Math.cos(g*v)+m*Math.sin(g*v)):(1+m*v)*Math.exp(-v*f),0===t||1===t?t:1-v},bu=function(t,e){void 0===e&&(e=[]);var n=c(e,2),r=n[0],i=void 0===r?10:r;return("start"==n[1]?Math.ceil:Math.floor)(Gt(t,0,1)*i)/i},Eu=function(t,e){void 0===e&&(e=[]);var n=c(e,4),r=n[0],i=n[1],o=n[2],a=n[3];return su(r,i,o,a)(t)},wu=su(.42,0,1,1),xu=function(t){return function(e,n,r){return void 0===n&&(n=[]),1-t(1-e,n,r)}},Mu=function(t){return function(e,n,r){return void 0===n&&(n=[]),e<.5?t(2*e,n,r)/2:1-t(-2*e+2,n,r)/2}},Nu=function(t){return function(e,n,r){return void 0===n&&(n=[]),e<.5?(1-t(1-2*e,n,r))/2:(t(2*e-1,n,r)+1)/2}},Su={steps:bu,"step-start":function(t){return bu(t,[1,"start"])},"step-end":function(t){return bu(t,[1,"end"])},linear:function(t){return t},"cubic-bezier":Eu,ease:function(t){return Eu(t,[.25,.1,.25,1])},in:wu,out:xu(wu),"in-out":Mu(wu),"out-in":Nu(wu),"in-quad":uu,"out-quad":xu(uu),"in-out-quad":Mu(uu),"out-in-quad":Nu(uu),"in-cubic":cu,"out-cubic":xu(cu),"in-out-cubic":Mu(cu),"out-in-cubic":Nu(cu),"in-quart":hu,"out-quart":xu(hu),"in-out-quart":Mu(hu),"out-in-quart":Nu(hu),"in-quint":lu,"out-quint":xu(lu),"in-out-quint":Mu(lu),"out-in-quint":Nu(lu),"in-expo":du,"out-expo":xu(du),"in-out-expo":Mu(du),"out-in-expo":Nu(du),"in-sine":fu,"out-sine":xu(fu),"in-out-sine":Mu(fu),"out-in-sine":Nu(fu),"in-circ":pu,"out-circ":xu(pu),"in-out-circ":Mu(pu),"out-in-circ":Nu(pu),"in-back":gu,"out-back":xu(gu),"in-out-back":Mu(gu),"out-in-back":Nu(gu),"in-bounce":mu,"out-bounce":xu(mu),"in-out-bounce":Mu(mu),"out-in-bounce":Nu(mu),"in-elastic":vu,"out-elastic":xu(vu),"in-out-elastic":Mu(vu),"out-in-elastic":Nu(vu),spring:yu,"spring-in":yu,"spring-out":xu(yu),"spring-in-out":Mu(yu),"spring-out-in":Nu(yu)},Tu=function(t){return Su[function(t){return function(t){return"-"===(t=t.replace(/([A-Z])/g,(function(t){return"-".concat(t.toLowerCase())}))).charAt(0)?t.substring(1):t}(t).replace(/^ease-/,"").replace(/(\(|\s).+/,"").toLowerCase().trim()}(t)]||Su.linear},ku=function(t){return t},Pu=1,Cu=.5,Au=0;function Ou(t,e){return function(n){if(n>=1)return 1;var r=1/t;return(n+=e*r)-n%r}}var Ru="\\s*(-?\\d+\\.?\\d*|-?\\.\\d+)\\s*",_u=new RegExp("cubic-bezier\\("+Ru+","+Ru+","+Ru+","+Ru+"\\)"),Du=/steps\(\s*(\d+)\s*\)/,Iu=/steps\(\s*(\d+)\s*,\s*(start|middle|end)\s*\)/;function Lu(t){var e=_u.exec(t);if(e)return su.apply(void 0,h([],c(e.slice(1).map(Number)),!1));var n=Du.exec(t);if(n)return Ou(Number(n[1]),Au);var r=Iu.exec(t);return r?Ou(Number(r[1]),{start:Pu,middle:Cu,end:Au}[r[2]]):Tu(t)}function ju(t){return Math.abs(function(t){var e;if(0===t.duration||0===t.iterations)return 0;return("auto"===t.duration?0:Number(t.duration))*(null!==(e=t.iterations)&&void 0!==e?e:1)}(t)/(t.playbackRate||1))}var zu=0,Fu=1,Bu=2,Gu=3;function Vu(t,e,n){var r=function(t,e,n){if(null===e)return zu;var r=n.endTime;return e<Math.min(n.delay,r)?Fu:e>=Math.min(n.delay+t+n.endDelay,r)?Bu:Gu}(t,e,n),i=function(t,e,n,r,i){switch(r){case Fu:return"backwards"===e||"both"===e?0:null;case Gu:return n-i;case Bu:return"forwards"===e||"both"===e?t:null;case zu:return null}}(t,n.fill,e,r,n.delay);if(null===i)return null;var o="auto"===n.duration?0:n.duration,a=function(t,e,n,r,i){var o=i;return 0===t?e!==Fu&&(o+=n):o+=r/t,o}(o,r,n.iterations,i,n.iterationStart),s=function(t,e,n,r,i,o){var a=t===1/0?e%1:t%1;return 0!==a||n!==Bu||0===r||0===i&&0!==o||(a=1),a}(a,n.iterationStart,r,n.iterations,i,o),u=function(t,e,n,r){return t===Bu&&e===1/0?1/0:1===n?Math.floor(r)-1:Math.floor(r)}(r,n.iterations,s,a),c=function(t,e,n){var r=t;if("normal"!==t&&"reverse"!==t){var i=e;"alternate-reverse"===t&&(i+=1),r="normal",i!==1/0&&i%2!=0&&(r="reverse")}return"normal"===r?n:1-n}(n.direction,u,s);return n.currentIteration=u,n.progress=c,n.easingFunction(c)}function Uu(t,e,n){var r=function(t,e){for(var n={},r=0;r<t.length;r++)for(var i in t[r])if(Wu(i)){var o={offset:t[r].offset,computedOffset:t[r].computedOffset,easing:t[r].easing,easingFunction:Lu(t[r].easing)||e.easingFunction,value:t[r][i]};n[i]=n[i]||[],n[i].push(o)}return n}(t,e),i=function(t,e){var n=[];for(var r in t)for(var i=t[r],o=0;o<i.length-1;o++){var a=o,s=o+1,u=i[a].computedOffset,c=i[s].computedOffset,h=u,l=c;0===o&&(h=-1/0,0===c&&(s=a)),o===i.length-2&&(l=1/0,1===u&&(a=s)),n.push({applyFrom:h,applyTo:l,startOffset:i[a].computedOffset,endOffset:i[s].computedOffset,easingFunction:i[a].easingFunction,property:r,interpolation:qu(r,i[a].value,i[s].value,e)})}return n.sort((function(t,e){return t.startOffset-e.startOffset})),n}(r,n);return function(t,e){if(null!==e)i.filter((function(t){return e>=t.applyFrom&&e<t.applyTo})).forEach((function(n){var r=e-n.startOffset,i=n.endOffset-n.startOffset,o=0===i?0:n.easingFunction(r/i);t.setAttribute(n.property,n.interpolation(o),!1,!1)}));else for(var n in r)Wu(n)&&t.setAttribute(n,null)}}function Wu(t){return"offset"!==t&&"easing"!==t&&"composite"!==t&&"computedOffset"!==t}var Hu=function(t,e,n){return function(r){var i=Yu(t,e,r);return!us.enableCSSParsing&&Vt(i)?i:n(i)}};function qu(t,e,n,r){var i=Ao[t];if(i&&i.syntax&&i.int){var o=us.styleValueRegistry.getPropertySyntax(i.syntax);if(o){var a=void 0,s=void 0;if(us.enableCSSParsing){var u=us.styleValueRegistry.parseProperty(t,e,r,!1),l=us.styleValueRegistry.parseProperty(t,n,r,!1);a=us.styleValueRegistry.computeProperty(t,u,r,!1),s=us.styleValueRegistry.computeProperty(t,l,r,!1)}else{var d=o.parserWithCSSDisabled;a=d?d(e,r):e,s=d?d(n,r):n}var f=o.mixer(a,s,r);if(f){var p=Hu.apply(void 0,h([],c(f),!1));return function(t){return 0===t?e:1===t?n:p(t)}}}}return Hu(!1,!0,(function(t){return t?n:e}))}function Yu(t,e,n){if("number"==typeof t&&"number"==typeof e)return t*(1-n)+e*n;if("boolean"==typeof t&&"boolean"==typeof e||"string"==typeof t&&"string"==typeof e)return n<.5?t:e;if(Array.isArray(t)&&Array.isArray(e)){for(var r=t.length,i=e.length,o=Math.max(r,i),a=[],s=0;s<o;s++)a.push(Yu(t[s<r?s:r-1],e[s<i?s:i-1],n));return a}throw new Error("Mismatched interpolation arguments "+t+":"+e)}var $u=function(){function t(){this.delay=0,this.direction="normal",this.duration="auto",this._easing="linear",this.easingFunction=ku,this.endDelay=0,this.fill="auto",this.iterationStart=0,this.iterations=1,this.currentIteration=null,this.progress=null}return Object.defineProperty(t.prototype,"easing",{get:function(){return this._easing},set:function(t){this.easingFunction=Lu(t),this._easing=t},enumerable:!1,configurable:!0}),t}();function Xu(t,e){if(null===t)return[];Array.isArray(t)||(t=function(t){var e=[];for(var n in t)if(!(n in["easing","offset","composite"])){var r=t[n];Array.isArray(r)||(r=[r]);for(var i=r.length,o=0;o<i;o++){if(!e[o]){var a={};"offset"in t&&(a.offset=Number(t.offset)),"easing"in t&&(a.easing=t.easing),"composite"in t&&(a.composite=t.composite),e[o]=a}void 0!==r[o]&&null!==r[o]&&(e[o][n]=r[o])}}return e.sort((function(t,e){return(t.computedOffset||0)-(e.computedOffset||0)})),e}(t));for(var n=t.map((function(t){var n={};for(var r in(null==e?void 0:e.composite)&&(n.composite="auto"),t){var i=t[r];if("offset"===r){if(null!==i){if(i=Number(i),!isFinite(i))throw new Error("Keyframe offsets must be numbers.");if(i<0||i>1)throw new Error("Keyframe offsets must be between 0 and 1.");n.computedOffset=i}}else if("composite"===r&&-1===["replace","add","accumulate","auto"].indexOf(i))throw new Error("".concat(i," compositing is not supported"));n[r]=i}return void 0===n.offset&&(n.offset=null),void 0===n.easing&&(n.easing=(null==e?void 0:e.easing)||"linear"),void 0===n.composite&&(n.composite="auto"),n})),r=!0,i=-1/0,o=0;o<n.length;o++){var a=n[o].offset;if(Pt(a))r=!1;else{if(a<i)throw new TypeError("Keyframes are not loosely sorted by offset. Sort or specify offsets.");i=a}}return n=n.filter((function(t){return Number(t.offset)>=0&&Number(t.offset)<=1})),r||function(){var t,e,r=n.length;n[r-1].computedOffset=Number(null!==(t=n[r-1].offset)&&void 0!==t?t:1),r>1&&(n[0].computedOffset=Number(null!==(e=n[0].offset)&&void 0!==e?e:0));for(var i=0,o=Number(n[0].computedOffset),a=1;a<r;a++){var s=n[a].computedOffset;if(!Pt(s)&&!Pt(o)){for(var u=1;u<a-i;u++)n[i+u].computedOffset=o+(Number(s)-o)*u/(a-i);i=a,o=Number(s)}}}(),n}var Ku="backwards|forwards|both|none".split("|"),Zu="reverse|alternate|alternate-reverse".split("|");function Qu(t,e){return function(t,e){var n=new $u;return e&&(n.fill="both",n.duration="auto"),"number"!=typeof t||isNaN(t)?void 0!==t&&Object.keys(t).forEach((function(e){if(void 0!==t[e]&&null!==t[e]&&"auto"!==t[e]){if(("number"==typeof n[e]||"duration"===e)&&("number"!=typeof t[e]||isNaN(t[e])))return;if("fill"===e&&-1===Ku.indexOf(t[e]))return;if("direction"===e&&-1===Zu.indexOf(t[e]))return;n[e]=t[e]}})):n.duration=t,n}(t=function(t){"number"==typeof t&&(t=isNaN(t)?{duration:"auto"}:{duration:t});return t}(null!=t?t:{duration:"auto"}),e)}var Ju=function(){function t(t,e,n){var r=this;this.composite="replace",this.iterationComposite="replace",this.target=t,this.timing=Qu(n,!1),this.timing.effect=this,this.timing.activeDuration=ju(this.timing),this.timing.endTime=Math.max(0,this.timing.delay+this.timing.activeDuration+this.timing.endDelay),this.normalizedKeyframes=Xu(e,this.timing),this.interpolations=Uu(this.normalizedKeyframes,this.timing,this.target);var i=us.globalThis.Proxy;this.computedTiming=i?new i(this.timing,{get:function(t,e){return"duration"===e?"auto"===t.duration?0:t.duration:"fill"===e?"auto"===t.fill?"none":t.fill:"localTime"===e?r.animation&&r.animation.currentTime||null:"currentIteration"===e?r.animation&&"running"===r.animation.playState?t.currentIteration||0:null:"progress"===e?r.animation&&"running"===r.animation.playState?t.progress||0:null:t[e]},set:function(){return!0}}):this.timing}return t.prototype.applyInterpolations=function(){this.interpolations(this.target,Number(this.timeFraction))},t.prototype.update=function(t){return null!==t&&(this.timeFraction=Vu(this.timing.activeDuration,t,this.timing),null!==this.timeFraction)},t.prototype.getKeyframes=function(){return this.normalizedKeyframes},t.prototype.setKeyframes=function(t){this.normalizedKeyframes=Xu(t)},t.prototype.getComputedTiming=function(){return this.computedTiming},t.prototype.getTiming=function(){return this.timing},t.prototype.updateTiming=function(t){var e=this;Object.keys(t||{}).forEach((function(n){e.timing[n]=t[n]}))},t}();function tc(t,e){return Number(t.id)-Number(e.id)}var ec=function(){function t(t){var e=this;this.document=t,this.animations=[],this.ticking=!1,this.timelineTicking=!1,this.hasRestartedThisFrame=!1,this.animationsWithPromises=[],this.inTick=!1,this.pendingEffects=[],this.currentTime=null,this.rafId=0,this.rafCallbacks=[],this.webAnimationsNextTick=function(t){e.currentTime=t,e.discardAnimations(),0===e.animations.length?e.timelineTicking=!1:e.requestAnimationFrame(e.webAnimationsNextTick)},this.processRafCallbacks=function(t){var n=e.rafCallbacks;e.rafCallbacks=[],t<Number(e.currentTime)&&(t=Number(e.currentTime)),e.animations.sort(tc),e.animations=e.tick(t,!0,e.animations)[0],n.forEach((function(e){e[1](t)})),e.applyPendingEffects()}}return t.prototype.getAnimations=function(){return this.discardAnimations(),this.animations.slice()},t.prototype.isTicking=function(){return this.inTick},t.prototype.play=function(t,e,n){var r=new Ju(t,e,n),i=new Js(r,this);return this.animations.push(i),this.restartWebAnimationsNextTick(),i.updatePromises(),i.play(),i.updatePromises(),i},t.prototype.applyDirtiedAnimation=function(t){var e=this;if(!this.inTick){t.markTarget();var n=t.targetAnimations();n.sort(tc),this.tick(Number(this.currentTime),!1,n.slice())[1].forEach((function(t){var n=e.animations.indexOf(t);-1!==n&&e.animations.splice(n,1)})),this.applyPendingEffects()}},t.prototype.restart=function(){return this.ticking||(this.ticking=!0,this.requestAnimationFrame((function(){})),this.hasRestartedThisFrame=!0),this.hasRestartedThisFrame},t.prototype.destroy=function(){this.document.defaultView.cancelAnimationFrame(this.frameId)},t.prototype.applyPendingEffects=function(){this.pendingEffects.forEach((function(t){null==t||t.applyInterpolations()})),this.pendingEffects=[]},t.prototype.updateAnimationsPromises=function(){this.animationsWithPromises=this.animationsWithPromises.filter((function(t){return t.updatePromises()}))},t.prototype.discardAnimations=function(){this.updateAnimationsPromises(),this.animations=this.animations.filter((function(t){return"finished"!==t.playState&&"idle"!==t.playState}))},t.prototype.restartWebAnimationsNextTick=function(){this.timelineTicking||(this.timelineTicking=!0,this.requestAnimationFrame(this.webAnimationsNextTick))},t.prototype.rAF=function(t){var e=this.rafId++;return 0===this.rafCallbacks.length&&(this.frameId=this.document.defaultView.requestAnimationFrame(this.processRafCallbacks)),this.rafCallbacks.push([e,t]),e},t.prototype.requestAnimationFrame=function(t){var e=this;return this.rAF((function(n){e.updateAnimationsPromises(),t(n),e.updateAnimationsPromises()}))},t.prototype.tick=function(t,e,n){var r,i,o=this;this.inTick=!0,this.hasRestartedThisFrame=!1,this.currentTime=t,this.ticking=!1;var a=[],s=[],u=[],l=[];return n.forEach((function(n){n.tick(t,e),n._inEffect?(s.push(n.effect),n.markTarget()):(a.push(n.effect),n.unmarkTarget()),n._needsTick&&(o.ticking=!0);var r=n._inEffect||n._needsTick;n._inTimeline=r,r?u.push(n):l.push(n)})),(r=this.pendingEffects).push.apply(r,h([],c(a),!1)),(i=this.pendingEffects).push.apply(i,h([],c(s),!1)),this.ticking&&this.requestAnimationFrame((function(){})),this.inTick=!1,[u,l]},t}();us.EasingFunction=Lu,us.AnimationTimeline=ec;const nc={duration:500},rc={duration:1e3,easing:"cubic-bezier(0.250, 0.460, 0.450, 0.940)",iterations:1,fill:"both"};var ic,oc,ac,sc,uc,cc,hc,lc;!function(t){t.NodeAdded="NodeAdded",t.NodeUpdated="NodeUpdated",t.NodeRemoved="NodeRemoved",t.EdgeAdded="EdgeAdded",t.EdgeUpdated="EdgeUpdated",t.EdgeRemoved="EdgeRemoved",t.ComboAdded="ComboAdded",t.ComboUpdated="ComboUpdated",t.ComboRemoved="ComboRemoved"}(ic||(ic={})),function(t){t.DRAW="draw",t.TRANSFORM="transform",t.ELEMENT_VISIBILITY_CHANGE="elementvisibilitychange",t.ELEMENT_STATE_CHANGE="elementstatechange",t.ELEMENT_TRANSLATE="elementtranslate"}(oc||(oc={})),t.CanvasEvent=void 0,function(t){t.CLICK="click",t.DBLCLICK="dblclick",t.POINTER_OVER="pointerover",t.POINTER_LEAVE="pointerleave",t.POINTER_ENTER="pointerenter",t.POINTER_MOVE="pointermove",t.POINTER_OUT="pointerout",t.POINTER_DOWN="pointerdown",t.POINTER_UP="pointerup",t.CONTEXT_MENU="contextmenu",t.DRAG_START="dragstart",t.DRAG="drag",t.DRAG_END="dragend",t.DRAG_ENTER="dragenter",t.DRAG_OVER="dragover",t.DRAG_LEAVE="dragleave",t.DROP="drop",t.WHEEL="wheel"}(t.CanvasEvent||(t.CanvasEvent={})),t.NodeEvent=void 0,(ac=t.NodeEvent||(t.NodeEvent={})).CLICK="click",ac.DBLCLICK="dblclick",ac.POINTER_OVER="pointerover",ac.POINTER_LEAVE="pointerleave",ac.POINTER_ENTER="pointerenter",ac.POINTER_MOVE="pointermove",ac.POINTER_OUT="pointerout",ac.POINTER_DOWN="pointerdown",ac.POINTER_UP="pointerup",ac.CONTEXT_MENU="contextmenu",ac.DRAG_START="dragstart",ac.DRAG="drag",ac.DRAG_END="dragend",ac.DRAG_ENTER="dragenter",ac.DRAG_OVER="dragover",ac.DRAG_LEAVE="dragleave",ac.DROP="drop",t.CommonEvent=void 0,(sc=t.CommonEvent||(t.CommonEvent={})).CLICK="click",sc.DBLCLICK="dblclick",sc.POINTER_OVER="pointerover",sc.POINTER_LEAVE="pointerleave",sc.POINTER_ENTER="pointerenter",sc.POINTER_MOVE="pointermove",sc.POINTER_OUT="pointerout",sc.POINTER_DOWN="pointerdown",sc.POINTER_UP="pointerup",sc.CONTEXT_MENU="contextmenu",sc.DRAG_START="dragstart",sc.DRAG="drag",sc.DRAG_END="dragend",sc.DRAG_ENTER="dragenter",sc.DRAG_OVER="dragover",sc.DRAG_LEAVE="dragleave",sc.DROP="drop",sc.KEY_DOWN="keydown",sc.KEY_UP="keyup",sc.WHEEL="wheel",t.ContainerEvent=void 0,(uc=t.ContainerEvent||(t.ContainerEvent={})).KEY_DOWN="keydown",uc.KEY_UP="keyup",t.EdgeEvent=void 0,(cc=t.EdgeEvent||(t.EdgeEvent={})).CLICK="click",cc.DBLCLICK="dblclick",cc.POINTER_OVER="pointerover",cc.POINTER_LEAVE="pointerleave",cc.POINTER_ENTER="pointerenter",cc.POINTER_MOVE="pointermove",cc.POINTER_OUT="pointerout",cc.POINTER_DOWN="pointerdown",cc.POINTER_UP="pointerup",cc.CONTEXT_MENU="contextmenu",cc.DRAG_ENTER="dragenter",cc.DRAG_OVER="dragover",cc.DRAG_LEAVE="dragleave",cc.DROP="drop",t.GraphEvent=void 0,(hc=t.GraphEvent||(t.GraphEvent={})).BEFORE_SIZE_CHANGE="beforesizechange",hc.AFTER_SIZE_CHANGE="aftersizechange",hc.BEFORE_ELEMENT_CREATE="beforeelementcreate",hc.AFTER_ELEMENT_CREATE="afterelementcreate",hc.BEFORE_ELEMENT_UPDATE="beforeelementupdate",hc.AFTER_ELEMENT_UPDATE="afterelementupdate",hc.BEFORE_ELEMENT_DESTROY="beforeelementdestroy",hc.AFTER_ELEMENT_DESTROY="afterelementdestroy",hc.BEFORE_ELEMENT_TRANSLATE="beforeelementtranslate",hc.AFTER_ELEMENT_TRANSLATE="afterelementtranslate",hc.BEFORE_DRAW="beforedraw",hc.AFTER_DRAW="afterdraw",hc.BEFORE_RENDER="beforerender",hc.AFTER_RENDER="afterrender",hc.BEFORE_ANIMATE="beforeanimate",hc.AFTER_ANIMATE="afteranimate",hc.BEFORE_LAYOUT="beforelayout",hc.AFTER_LAYOUT="afterlayout",hc.BEFORE_TRANSFORM="beforetransform",hc.AFTER_TRANSFORM="aftertransform",hc.BEFORE_ELEMENT_VISIBILITY_CHANGE="beforeelementvisibilitychange",hc.AFTER_ELEMENT_VISIBILITY_CHANGE="afterelementvisibilitychange",hc.BEFORE_ELEMENT_Z_INDEX_CHANGE="beforeelementzindexchange",hc.AFTER_ELEMENT_Z_INDEX_CHANGE="afterelementzindexchange",hc.BEFORE_ELEMENT_STATE_CHANGE="beforeelementstatechange",hc.AFTER_ELEMENT_STATE_CHANGE="afterelementstatechange",function(t){t.DRAW="draw",t.ELEMENT_VISIBILITY_CHANGE="elementvisibilitychange",t.ELEMENT_STATE_CHANGE="elementstatechange",t.ELEMENT_TRANSLATE="elementtranslate"}(lc||(lc={}));const dc="combo",fc="tree";function pc(t){return"source"in t&&"target"in t}function gc(t){return t instanceof Float32Array||!(!Array.isArray(t)||2!==t.length&&3!==t.length)&&t.every((t=>"number"==typeof t))}function mc(t,e,n){return t>=e&&t<=n}function vc(t=0){if(Array.isArray(t)){const[e=0,n=e,r=e,i=n]=t;return[e,n,r,i]}return[t,t,t,t]}function yc(t){return t.max[0]-t.min[0]}function bc(t){return t.max[1]-t.min[1]}function Ec(t){return[yc(t),bc(t)]}function wc(t,e){const n=gc(t)?function(t){const[e,n,r=0]=t,i=new dr;return i.setMinMax([e,n,r],[e,n,r]),i}(t):t.getKey().getBounds();return e?xc(n,e):n}function xc(t,e){const[n,r,i,o]=vc(e),[a,s,u]=t.min,[c,h,l]=t.max,d=new dr;return d.setMinMax([a-o,s-n,u],[c+r,h+i,l]),d}function Mc(t){if(0===t.length)return new dr;if(1===t.length)return t[0];const e=new dr;e.setMinMax(t[0].min,t[0].max);for(let n=1;n<t.length;n++){const r=t[n];e.setMinMax([Math.min(e.min[0],r.min[0]),Math.min(e.min[1],r.min[1]),Math.min(e.min[2],r.min[2])],[Math.max(e.max[0],r.max[0]),Math.max(e.max[1],r.max[1]),Math.max(e.max[2],r.max[2])])}return e}function Nc(t,e){return mc(t[0],e.min[0],e.max[0])&&mc(t[1],e.min[1],e.max[1])}function Sc(t,e){const[n,r]=e,[i,o]=t.min,[a,s]=t.max,u=n-i,c=a-n,h=r-o,l=s-r,d=Math.min(u,c,h,l);return d===u?"left":d===c?"right":d===h?"top":d===l?"bottom":"left"}function Tc(t,e){const n=Qt(e);if(Nc(e,t)){switch(Sc(t,e)){case"left":n[0]=t.min[0];break;case"right":n[0]=t.max[0];break;case"top":n[1]=t.min[1];break;case"bottom":n[1]=t.max[1]}}else{const[r,i]=e,[o,a]=t.min,[s,u]=t.max;n[0]=mc(r,o,s)?r:r<o?o:s,n[1]=mc(i,a,u)?i:i<a?a:u}return n}function kc(t){const{x:e=0,y:n=0,z:r=0}=t.style||{};return[+e,+n,+r]}function Pc(t,e){const[n,r]=e,{min:i,max:o}=t;return[i[0]+n*(o[0]-i[0]),i[1]+r*(o[1]-i[1])]}function Cc(t,e="center"){const n=function(t){if(Array.isArray(t))return mc(t[0],0,1)&&mc(t[1],0,1)?t:[.5,.5];const e=t.split("-");return[e.includes("left")?0:e.includes("right")?1:.5,e.includes("top")?0:e.includes("bottom")?1:.5]}(e);return Pc(t,n)}function Ac(t,e){const n=function(t){const e="string"==typeof t?t.split(" ").map((t=>parseFloat(t))):t.slice(0,2);return mc(e[0],0,1)&&mc(e[1],0,1)?e:[.5,.5]}(e);return Pc(t,n)}function Oc(t=0){if(Vt(t))return Array(3).fill(t);const[e,n=e,r=e]=t;return[e,n,r]}function Rc(t,e,n){if(Array.isArray(t))return t;const[r,i]=Oc(n),[o,a]=Oc(e),s=o/2/r,u=a/2/i;switch(t){case"top":return[.5,u];case"bottom":return[.5,1-u];case"left":return[s,.5];case"right":return[1-s,.5];case"top-left":case"left-top":return[s,u];case"top-right":case"right-top":return[1-s,u];case"bottom-left":case"left-bottom":return[s,1-u];case"bottom-right":case"right-bottom":return[1-s,1-u];default:return[.5,.5]}}function _c(t,e,n){if(Array.isArray(t))return t;const r=Oc(n)[0],i=r/2,o=Oc(e)[0]/2,a=o/r;switch(t){case"top":return[.5,a];case"bottom":return[.5,1-a];case"left":return[a,.5];case"right":return[1-a,.5]}const s=(i-o)*(Math.sqrt(2)/2)/r;switch(t){case"top-left":case"left-top":return[.5-s,.5-s];case"top-right":case"right-top":return[.5+s,.5-s];case"bottom-left":case"left-bottom":return[.5-s,.5+s];case"bottom-right":case"right-bottom":return[.5+s,.5+s];default:return[.5,.5]}}function Dc(t,e,n,r,i=Rc){const o=i(t,n,r),[a,s]=Oc(r),u=new dr;return u.setMinMax([e[0]-a/2,e[1]-s/2,0],[e[0]+a/2,e[1]+s/2,0]),Ac(u,o)}function Ic(t){if(zt(t.id)||Vt(t.id))return t.id;if(pc(t))return`${t.source}-${t.target}`;throw new Error("The data does not have available id.")}function Lc(t){return t.style?.parentId}function jc(t,e){if(!t.startsWith(e))return!1;const n=t[e.length];return n>="A"&&n<="Z"}function zc(t,e){return Object.entries(t).reduce(((t,[n,r])=>("className"===n||"class"===n||jc(n,e)&&(t[function(t,e,n=!0){if(!e)return t;if(!jc(t,e))return t;const r=t.slice(e.length);return n?Yt(r):r}(n,e)]=r),t)),{})}function Fc(t,e){const n=e.length;return Object.keys(t).reduce(((r,i)=>{if(i.startsWith(e)){r[i.slice(n)]=t[i]}return r}),{})}function Bc(t,e){const n=zt(e)?[e]:e;return Object.entries(t).reduce(((t,[e,r])=>(n.find((t=>e.startsWith(t)))||(t[e]=r),t)),{})}const Gc=[0,0,0];function Vc(t,e){return t.map(((t,n)=>t+e[n]))}function Uc(t,e){return t.map(((t,n)=>t-e[n]))}function Wc(t,e){return"number"==typeof e?t.map((t=>t*e)):t.map(((t,n)=>t*e[n]))}function Hc(t,e){return"number"==typeof e?t.map((t=>t/e)):t.map(((t,n)=>t/e[n]))}function qc(t,e){return Math.sqrt(t.reduce(((t,n,r)=>t+(n-e[r]||0)**2),0))}function Yc(t,e){return t.reduce(((t,n,r)=>t+Math.abs(n-e[r])),0)}function $c(t){const e=t.reduce(((t,e)=>t+e**2),0);return t.map((t=>t/Math.sqrt(e)))}function Xc(t){return 2===t.length?[t[0],t[1],0]:t}function Kc(t){if(t)return"string"==typeof t||"function"==typeof t||Array.isArray(t)?{type:"group",field:t=>t.id,color:t,invert:!1}:t}function Zc(t){return[t.x,t.y]}function Qc(t){return{x:t[0],y:t[1]}}function Jc(t,e=0){return t.map((t=>parseFloat(t.toFixed(e))))}function th(t,e,n,r=!1){const i=$c(r?Uc(t,e):Uc(e,t)),o=[i[0]*n,i[1]*n];return Vc(function(t){return[t[0],t[1]]}(t),o)}function eh(t,e){return t[1]===e[1]}function nh(t,e){const[n,r]=t,[i,o]=e;return function(t,e){const n=Xc(t),r=Xc(e);return[n[1]*r[2]-n[2]*r[1],n[2]*r[0]-n[0]*r[2],n[0]*r[1]-n[1]*r[0]]}(Uc(n,r),Uc(i,o)).every((t=>0===t))}function rh(t,e){if(nh(t,e))return;const[n,r]=t,[i,o]=e,a=((n[0]-i[0])*(i[1]-o[1])-(n[1]-i[1])*(i[0]-o[0]))/((n[0]-r[0])*(i[1]-o[1])-(n[1]-r[1])*(i[0]-o[0])),s=o[0]-i[0]?(n[0]-i[0]+a*(r[0]-n[0]))/(o[0]-i[0]):(n[1]-i[1]+a*(r[1]-n[1]))/(o[1]-i[1]);return mc(a,0,1)&&mc(s,0,1)?[n[0]+a*(r[0]-n[0]),n[1]+a*(r[1]-n[1])]:void 0}function ih(t,e,n,r=!0){for(let i=0;i<n.length;i++){let o=n[i],a=n[(i+1)%n.length];r&&(o=Vc(e,o),a=Vc(e,a));const s=rh([e,t],[o,a]);if(s)return s}return e}function oh(t,e){const n=e.center,r=Uc(t,e.center),i=Math.atan2(r[1],r[0]);if(isNaN(i))return n;const o=yc(e)/2,a=bc(e)/2;return[n[0]+o*Math.cos(i),n[1]+a*Math.sin(i)]}function ah(t,e){let n=2*t;return"string"==typeof e?n=t*Number(e.replace("%",""))/100:"number"==typeof e&&(n=e),isNaN(n)&&(n=2*t),n}function sh(t,e,n=1,r=!1){const i=r?n:1;return ah((t.max[0]-t.min[0])*i,e)}const uh="cachedStyle",ch=t=>`__${t}__`;function hh(t,e){const n=Array.isArray(e)?e:[e];oe(t,uh)||ae(t,uh,{}),n.forEach((e=>{ae(oe(t,uh),ch(e),t.attributes[e])}))}function lh(t,e){return oe(t,[uh,ch(e)])}function dh(t,e){return ch(e)in(oe(t,uh)||{})}function fh(t){const e=[],n=t=>{t.children&&t.children.length&&t.children.forEach((t=>{e.push(t),n(t)}))};return n(t),e}const ph="visibility";class gh extends Ts{constructor(t){super(t),this.render(this.attributes,this),this.setVisibility(),this.bindEvents()}get parsedAttributes(){return this.attributes}shapeMap={};animateMap={};upsert(t,e,n,r){const i=this.shapeMap[t];if(!1!==n){if(!i){const i=new e({style:n});return i.id=t,r.appendChild(i),this.shapeMap[t]=i,i}return ml(i,n),i}i&&(r.removeChild(i),delete this.shapeMap[t])}update(t={}){this.attr(ee({},this.attributes,t)),this.render(this.attributes,this),this.setVisibility()}bindEvents(){}getGraphicStyle(t){const{x:e,y:n,className:r,transform:i,transformOrigin:o,context:a,zIndex:s,...u}=t;return u}animate(t,e){const n=[],r=super.animate(t,e);if(r&&n.push(r),Array.isArray(t)&&t.length>0){const r=["anchor","transform","transformOrigin","x","y","z","zIndex"];Object.keys(t[0]).some((t=>!r.includes(t)))&&Object.entries(this.shapeMap).forEach((([r,i])=>{const o=this[`get${r[0].toUpperCase()}${r.slice(1)}Style`];if("function"==typeof o){const r=t.map((t=>o.call(this,{...this.attributes,...t}))),a=i.animate(yl(r),e);a&&n.push(a)}}))}return vl(n)}setVisibility(){const{visibility:t}=this.attributes;!function(t,e){[t,...fh(t)].forEach((n=>{dh(n,ph)||hh(n,ph);const r=lh(n,ph);t!==n&&"hidden"===r||(n.style.visibility=e)}))}(this,t)}}class mh extends gh{static defaultStyleProps={padding:0,fontSize:12,wordWrap:!0,maxLines:1,wordWrapWidth:128,textOverflow:"...",textBaseline:"middle",backgroundOpacity:.75,backgroundZIndex:-1,backgroundLineWidth:0};constructor(t){super(ee({},{style:mh.defaultStyleProps},t))}isTextStyle(t){return jc(t,"label")}isBackgroundStyle(t){return jc(t,"background")}getTextStyle(t){const{padding:e,...n}=this.getGraphicStyle(t);return Bc(n,"background")}getBackgroundStyle(t){if(!1===t.background)return!1;const e=this.getGraphicStyle(t),{wordWrap:n,wordWrapWidth:r,padding:i}=e,o=zc(e,"background"),{min:[a,s],halfExtents:[u,c]}=this.shapeMap.text.getGeometryBounds(),[h,l,d,f]=vc(i);Object.assign(o,{x:a-f,y:s-h,width:n?Math.min(2*u,r):2*u+f+l,height:2*c+h+d});const{radius:p}=o;if("string"==typeof p&&p.endsWith("%")){const t=Number(p.replace("%",""))/100;o.radius=Math.min(+o.width,+o.height)*t}return o}render(t=this.parsedAttributes,e=this){this.upsert("text",Ls,this.getTextStyle(t),e),this.upsert("background",Is,this.getBackgroundStyle(t),e)}}class vh extends gh{static defaultStyleProps={padding:[2,4,2,4],fontSize:10,wordWrap:!1,backgroundRadius:"50%",backgroundOpacity:1};constructor(t){super(ee({},{style:vh.defaultStyleProps},t))}getBadgeStyle(t){return this.getGraphicStyle(t)}render(t=this.parsedAttributes,e=this){this.upsert("label",mh,this.getBadgeStyle(t),e)}connectedCallback(){this.upsert("label",mh,this.getBadgeStyle(this.parsedAttributes),this)}}class yh extends gh{constructor(t){super(t)}isGImage(){return!!this.getAttribute("src")}getIconStyle(t=this.attributes){const e=this.getGraphicStyle(t);return this.isGImage()?{anchor:[.5,.5],...e}:{textBaseline:"middle",textAlign:"center",...e}}render(t=this.attributes,e=this){this.upsert("icon",this.isGImage()?As:Ls,this.getIconStyle(t),e)}connectedCallback(){this.upsert("icon",this.isGImage()?As:Ls,this.getIconStyle(this.attributes),this)}}class bh extends gh{type="node";static defaultStyleProps={x:0,y:0,size:24,droppable:!0,draggable:!0,port:!0,ports:[],portZIndex:2,portLinkToCenter:!1,badge:!0,badges:[],badgeZIndex:3,halo:!1,haloDroppable:!1,haloLineDash:0,haloLineWidth:12,haloStrokeOpacity:.25,haloPointerEvents:"none",haloZIndex:-1,icon:!0,iconZIndex:1,label:!0,labelIsBillboard:!0,labelMaxWidth:"200%",labelPlacement:"bottom",labelWordWrap:!1,labelZIndex:0};constructor(t){super(ee({},{style:bh.defaultStyleProps},t))}getSize(t=this.parsedAttributes){const{size:e}=t;return Oc(e)}getKeyStyle(t){const{color:e,fill:n,...r}=this.getGraphicStyle(t);return Object.assign({fill:e||n},Bc(r,["label","halo","icon","badge","port"]))}getLabelStyle(t){if(!1===t.label||re(t.labelText))return!1;const{placement:e,maxWidth:n,...r}=zc(this.getGraphicStyle(t),"label"),i=this.getKey().getLocalBounds();return Object.assign(gl(i,e),{wordWrapWidth:sh(i,n)},r)}getHaloStyle(t){if(!1===t.halo)return!1;const{fill:e,...n}=this.getKeyStyle(t);return{...n,stroke:e,...zc(this.getGraphicStyle(t),"halo")}}getIconStyle(t){if(!1===t.icon||re(t.iconText||t.iconSrc))return!1;const e=zc(this.getGraphicStyle(t),"icon"),n=this.getKey(),[r,i]=Cc(n.getLocalBounds(),"center");return{x:r,y:i,...e}}getBadgesStyle(t){const e=Fc(this.shapeMap,"badge-"),n={};if(Object.keys(e).forEach((t=>{n[t]=!1})),!1===t.badge||re(t.badges))return n;const{badges:r=[],badgePalette:i,...o}=t,a=function(t){const e=zt(t)?sI("palette",t):t;if(!kt(e))return e}(i),s=zc(this.getGraphicStyle(o),"badge");return r.forEach(((t,e)=>{n[e]={backgroundFill:a?a[e%a?.length]:void 0,...s,...this.getBadgeStyle(t)}})),n}getBadgeStyle(t){const e=this.getKey(),{placement:n="top",...r}=t;return{...gl(e.getLocalBounds(),n,!0),...r}}getPortsStyle(t){const e=this.getPorts(),n={};if(Object.keys(e).forEach((t=>{n[t]=!1})),!1===t.port||re(t.ports))return n;const r=zc(this.getGraphicStyle(t),"port"),{ports:i=[]}=t;return i.forEach(((e,i)=>{const o=e.key||i,a={...r,...e};if(ul(a))n[o]=!1;else{const[r,i]=this.getPortXY(t,e);n[o]={cx:r,cy:i,...a}}})),n}getPortXY(t,e){const{placement:n="left"}=e;return al(this.getKey().getLocalBounds(),n)}getKey(){return this.shapeMap.key}getPorts(){return Fc(this.shapeMap,"port-")}getCenter(){return this.getKey().getBounds().center}getIntersectPoint(t){const e=this.getKey().getBounds();return ih(t,Cc(n=e,"center"),[Cc(n,"left-top"),Cc(n,"right-top"),Cc(n,"right-bottom"),Cc(n,"left-bottom")],!1);var n}drawHaloShape(t,e){const n=this.getKey();this.upsert("halo",n.constructor,this.getHaloStyle(t),e)}drawBadgeShapes(t,e){const n=this.getBadgesStyle(t);Object.keys(n).forEach((t=>{this.upsert(`badge-${t}`,vh,n[t],e)}))}drawPortShapes(t,e){const n=this.getPortsStyle(t);Object.keys(n).forEach((t=>{this.upsert(`port-${t}`,Ss,n[t],e)}))}render(t=this.parsedAttributes,e=this){this.drawKeyShape(t,e)&&(this.drawHaloShape(t,e),this.upsert("icon",yh,this.getIconStyle(t),e),this.drawBadgeShapes(t,e),this.upsert("label",mh,this.getLabelStyle(t),e),this.drawPortShapes(t,e))}animate(t,e){const n=super.animate(t,e);return n&&(n.onframe=()=>{this.drawBadgeShapes(this.parsedAttributes,this)}),n}}const Eh=.8;class wh extends bh{static defaultStyleProps={size:24};constructor(t){super(ee({},{style:wh.defaultStyleProps},t))}drawKeyShape(t,e){return this.upsert("key",Ss,this.getKeyStyle(t),e)}getKeyStyle(t){return{...super.getKeyStyle(t),r:Math.min(...this.getSize(t))/2}}getIconStyle(t){const e=super.getIconStyle(t),{r:n}=this.getKeyStyle(t),r=2*n*Eh;return!!e&&{width:r,height:r,...e}}getIntersectPoint(t){return oh(t,this.getKey().getBounds())}}class xh extends bh{constructor(t){super(t)}drawKeyShape(t,e){return this.upsert("key",_s,this.getKeyStyle(t),e)}getKeyStyle(t){return{...super.getKeyStyle(t),points:this.getPoints(t)}}getIntersectPoint(t){const{points:e}=this.getKeyStyle(this.parsedAttributes);return ih(t,[+(this.attributes?.x||0),+(this.attributes?.y||0)],e)}}class Mh extends bh{static defaultStyleProps={size:[80,40]};constructor(t){super(ee({},{style:Mh.defaultStyleProps},t))}drawKeyShape(t,e){return this.upsert("key",ks,this.getKeyStyle(t),e)}getKeyStyle(t){const e=super.getKeyStyle(t),[n,r]=this.getSize(t);return{...e,rx:n/2,ry:r/2}}getIconStyle(t){const e=super.getIconStyle(t),{rx:n,ry:r}=this.getKeyStyle(t),i=2*Math.min(n,r)*Eh;return!!e&&{width:i,height:i,...e}}getIntersectPoint(t){return oh(t,this.getKey().getBounds())}}class Nh extends bh{static defaultStyleProps={size:[48,24],anchor:[.5,.5]};constructor(t){super(ee({},{style:Nh.defaultStyleProps},t))}getKeyStyle(t){const[e,n]=this.getSize(t);return{...super.getKeyStyle(t),width:e,height:n}}getIconStyle(t){const e=super.getIconStyle(t),{width:n,height:r}=this.getKeyStyle(t);return!!e&&{width:n*Eh,height:r*Eh,...e}}drawKeyShape(t,e){return this.upsert("key",Is,this.getKeyStyle(t),e)}}class Sh extends xh{static defaultStyleProps={size:40,direction:"up"};constructor(t){super(ee({},{style:Sh.defaultStyleProps},t))}getPoints(t){const{direction:e}=t,[n,r]=this.getSize(t);return function(t,e,n){const r=e/2,i=t/2,o={up:[[-i,r],[i,r],[0,-r]],left:[[-i,0],[i,r],[i,-r]],right:[[-i,r],[-i,-r],[i,0]],down:[[-i,-r],[i,-r],[0,r]]};return o[n]||o.up}(n,r,e)}getPortXY(t,e){const{direction:n}=t,{placement:r="top"}=e,i=this.getKey().getLocalBounds(),[o,a]=this.getSize(t),s=function(t,e,n){const r=e/2,i=t/2,o={};"down"===n?(o.bottom=o.default=[0,r],o.right=[i,-r],o.left=[-i,-r]):"left"===n?(o.top=[i,-r],o.bottom=[i,r],o.left=o.default=[-i,0]):"right"===n?(o.top=[-i,-r],o.bottom=[-i,r],o.right=o.default=[i,0]):(o.left=[-i,r],o.top=o.default=[0,-r],o.right=[i,r]);return o}(o,a,n);return al(i,r,s,!1)}getIconStyle(t){const{icon:e,iconText:n,iconSrc:r,direction:i}=t;if(!1===e||re(n||r))return!1;const o=zc(this.getGraphicStyle(t),"icon"),a=this.getKey().getLocalBounds(),[s,u]=function(t,e){const{center:n}=t,[r,i]=Ec(t);return["up"===e||"down"===e?n[0]:"right"===e?n[0]-r/6:n[0]+r/6,"left"===e||"right"===e?n[1]:"down"===e?n[1]-i/6:n[1]+i/6]}(a,i),c=2*function(t,e){let[n,r]=Ec(t);return[n,r]="up"===e||"down"===e?[n,r]:[r,n],(r**2-(Math.sqrt((n/2)**2+r**2)-n/2)**2)/(2*r)}(a,i)*Eh;return{x:s,y:u,width:c,height:c,...o}}}class Th extends bh{type="combo";static defaultStyleProps={childrenNode:[],droppable:!0,draggable:!0,collapsed:!1,collapsedSize:32,collapsedOrigin:[.5,.5],collapsedMarker:!0,collapsedMarkerZIndex:1,collapsedMarkerFontSize:12,collapsedMarkerTextAlign:"center",collapsedMarkerTextBaseline:"middle",collapsedMarkerType:"child-count"};constructor(t){super(ee({},{style:Th.defaultStyleProps},t))}calculatePosition(t){const{x:e=0,y:n=0,collapsed:r,childrenNode:i=[],childrenData:o=[]}=t;if(i.length<o.length){if(o.length>0&&r){return Hc(o.reduce(((t,e)=>Vc(t,kc(e))),[0,0,0]),o.length)}return[+e,+n,0]}return o.length?r?this.getCollapsedOriginPosition(t):this.getContentBBox(t).center:[+e,+n,0]}getCollapsedOriginPosition(t){return Dc(t.collapsedOrigin,this.getContentBBox(t).center,this.getCollapsedKeySize(t),this.getExpandedKeySize(t))}getKeySize(t){const{collapsed:e,childrenNode:n=[]}=t;return 0===n.length?this.getEmptyKeySize(t):e?this.getCollapsedKeySize(t):this.getExpandedKeySize(t)}getEmptyKeySize(t){const{padding:e,collapsedSize:n}=t,[r,i,o,a]=vc(e);return Vc(Oc(n),[a+i,r+o,0])}getCollapsedKeySize(t){return Oc(t.collapsedSize)}getExpandedKeySize(t){if(!re(t.size))return Oc(t.size);const e=this.getContentBBox(t);return[yc(e),bc(e),0]}getContentBBox(t){const{childrenNode:e=[],padding:n}=t,r=Mc(e.map((t=>t.getBounds())));return n?xc(r,n):r}drawCollapsedMarkerShape(t,e){this.upsert("collapsed-marker",yh,this.getCollapsedMarkerStyle(t),e)}getCollapsedMarkerStyle(t){if(!t.collapsed||!t.collapsedMarker)return!1;const{type:e,...n}=zc(this.getGraphicStyle(t),"collapsedMarker"),r=this.getKey(),[i,o]=Cc(r.getLocalBounds(),"center"),a={...n,x:i,y:o};if(e){const n=this.getCollapsedMarkerText(e,t);Object.assign(a,{text:n})}return a}getCollapsedMarkerText(t,e){const{context:n,childrenData:r=[]}=e;if(!n)return"";const{model:i}=n;return"descendant-count"===t?i.getDescendantsData(this.id).length.toString():"child-count"===t?r.length.toString():"node-count"===t?i.getDescendantsData(this.id).filter((t=>"node"===i.getElementType(Ic(t)))).length.toString():kt(t)?t(r):""}getComboZIndex(t){return(t.context?.model.getAncestorsData(this.id,dc)||[]).length}getComboStyle(t){const{zIndex:e=this.getComboZIndex(t)}=t,[n,r]=this.calculatePosition(t);return{x:n,y:r,zIndex:e}}render(t,e=this){super.render(t,e);const n=this.getComboStyle(t);Object.assign(this.style,n),t.context?.model.syncComboDatum({id:this.id,style:n}),this.drawCollapsedMarkerShape(t,e)}}class kh extends Th{static defaultStyleProps={anchor:[.5,.5]};constructor(t){super(ee({},{style:kh.defaultStyleProps},t))}drawKeyShape(t,e){return this.upsert("key",Is,this.getKeyStyle(t),e)}getKeyStyle(t){const e=super.getKeyStyle(t),n=zc(e,"collapsed"),[r,i]=this.getKeySize(t);return{...e,...t.collapsed&&n,width:r,height:i}}}const Ph={N:"S",S:"N",W:"E",E:"W"},Ch={N:-Math.PI/2,S:Math.PI/2,E:0,W:Math.PI};function Ah(t,e){const[n,r]=t,[i,o]=e;return n===i?r>o?"N":"S":r===o?n>i?"W":"E":null}function Oh(t,e){return"N"===e||"S"===e?bc(t):yc(t)}function Rh(t,e,n){const r=[t[0],e[1]],i=[e[0],t[1]],o=Ah(t,r),a=Ah(t,i),s=n?Ph[n]:null,u=o===n||o!==s&&a!==n?r:i;return{points:[u],direction:Ah(u,e)}}function _h(t,e,n){const r=jh(t,e,n);return{points:[r],direction:Ah(r,e)}}function Dh(t,e,n,r){const i=[[e[0],t[1]],[t[0],e[1]]],o=i.filter((t=>!Nc(t,n))),a=o.filter((e=>Ah(e,t)!==r));if(a.length>0){const n=a.find((e=>Ah(t,e)===r))||a[0];return{points:[n],direction:Ah(n,e)}}{const a=th(e,Tt(i,o)[0],Oh(n,r)/2);return{points:[jh(a,t,n),a],direction:Ah(a,e)}}}function Ih(t,e,n,r){let i=_h(t,e,n);const o=Xc(i.points[0]);if(Nc(o,r)){i=_h(e,t,r);const a=Xc(i.points[0]);if(Nc(a,n)){const s=th(t,a,Oh(n,Ah(t,a))/2),u=th(e,o,Oh(r,Ah(e,o))/2),c=[(s[0]+u[0])/2,(s[1]+u[1])/2],h=_h(t,c,n),l=Dh(c,e,r,h.direction);i.points=[h.points[0],l.points[0]],i.direction=l.direction}}return i}function Lh(t,e,n,r,i){const o=.01,a=Mc([n,r]),s=qc(e,a.center)>qc(t,a.center),[u,c]=s?[e,t]:[t,e],h=bc(a)+yc(a);let l;if(i){const t=[u[0]+h*Math.cos(Ch[i]),u[1]+h*Math.sin(Ch[i])];l=th(Tc(a,t),t,o)}else l=th(Tc(a,u),u,-.01);let d=jh(l,c,a),f=[Jc(l,2),Jc(d,2)];if(ie(Jc(l),Jc(d))){const t=function(t,e){return Math.acos(Wc(t,e).reduce(((t,e)=>t+e),0)/(qc(t,Gc)*qc(e,Gc)))}(Uc(l,u),[1,0,0])+Math.PI/2;d=[c[0]+h*Math.cos(t),c[1]+h*Math.sin(t),0],d=Jc(th(Tc(a,d),c,-.01),2);f=[l,jh(l,d,a),d]}return{points:s?f.reverse():f,direction:Ah(s?l:d,e)}}function jh(t,e,n){let r=[t[0],e[1]];return Nc(r,n)&&(r=[e[0],t[1]]),r}function zh(t,e,n,r,i){const[o,a]=Zc(t.getPoint(e));let s=n,u=r;return i&&(s=n*Math.cos(i)-r*Math.sin(i),u=n*Math.sin(i)+r*Math.cos(i)),[o+s,a+u]}function Fh(t,e,n,r){if(ie(t,e))return t;const i=Uc(e,t),o=[t[0]+n*i[0],t[1]+n*i[1]],a=$c(function(t,e=!0){return e?[-t[1],t[0]]:[t[1],-t[0]]}(i,!1));return o[0]+=r*a[0],o[1]+=r*a[1],o}function Bh(t,e,n){return[["M",t[0],t[1]],["C",n[0][0],n[0][1],n[1][0],n[1][1],e[0],e[1]]]}function Gh(t,e=0,n=!1){const r=t[0],i=t[t.length-1],o=t.slice(1,t.length-1),a=[["M",r[0],r[1]]];return o.forEach(((t,n)=>{const s=o[n-1]||r,u=o[n+1]||i;if(!nh([s,c=t],[c,u])&&e){const[n,r]=function(t,e,n,r){const i=Yc(t,e),o=Yc(n,e),a=Math.min(r,Math.min(i,o)/2),s=[e[0]-a/i*(e[0]-t[0]),e[1]-a/i*(e[1]-t[1])],u=[e[0]-a/o*(e[0]-n[0]),e[1]-a/o*(e[1]-n[1])];return[s,u]}(s,t,u,e);a.push(["L",n[0],n[1]],["Q",t[0],t[1],r[0],r[1]],["L",r[0],r[1]])}else a.push(["L",t[0],t[1]]);var c})),a.push(["L",i[0],i[1]]),n&&a.push(["Z"]),a}const Vh=t=>{const e=Math.PI/2,n=bc(t)/2,r=yc(t)/2,i=Math.atan2(n,r)/2,o=Math.atan2(r,n)/2;return{top:[-e-o,-e+o],"top-right":[-e+o,-i],"right-top":[-e+o,-i],right:[-i,i],"bottom-right":[i,e-o],"right-bottom":[i,e-o],bottom:[e-o,e+o],"bottom-left":[e+o,Math.PI-i],"left-bottom":[e+o,Math.PI-i],left:[Math.PI-i,Math.PI+i],"top-left":[Math.PI+i,-e-o],"left-top":[Math.PI+i,-e-o]}};function Uh(t,e,n,r,i){const o=wc(t),a=t.getCenter();let s=r&&cl(r),u=i&&cl(i);if(!s||!u){const r=Vh(o),i=r[e][0],c=r[e][1],[h,l]=Ec(o),d=Math.max(h,l),f=Vc(a,[d*Math.cos(i),d*Math.sin(i),0]),p=Vc(a,[d*Math.cos(c),d*Math.sin(c),0]);s=pl(t,f),u=pl(t,p),n||([s,u]=[u,s])}return[s,u]}function Wh(t,e,n,r,i,o){const a=t.getPorts()[i||o],s=t.getPorts()[o||i];let[u,c]=Uh(t,e,n,a,s);const h=function(t,e,n,r){const i=t.getCenter();if(ie(e,n)){const t=Uc(e,i),o=[r*Math.sign(t[0])||r/2,r*Math.sign(t[1])||-r/2,0];return[Vc(e,o),Vc(n,Wc(o,[1,-1,1]))]}return[th(i,e,qc(i,e)+r),th(i,n,qc(i,n)+r)]}(t,u,c,r);return a&&(u=fl(a,h[0])),s&&(c=fl(s,h[h.length-1])),Bh(u,c,h)}function Hh(t,e,n,r,i,o,a){const s=sl(t),u=s[o||a],c=s[a||o];let[h,l]=Uh(t,n,r,u,c);const d=function(t,e,n,r){const i=[],o=wc(t);if(ie(e,n)){switch(Sc(o,e)){case"left":i.push([e[0]-r,e[1]]),i.push([e[0]-r,e[1]+r]),i.push([e[0],e[1]+r]);break;case"right":i.push([e[0]+r,e[1]]),i.push([e[0]+r,e[1]+r]),i.push([e[0],e[1]+r]);break;case"top":i.push([e[0],e[1]-r]),i.push([e[0]+r,e[1]-r]),i.push([e[0]+r,e[1]]);break;case"bottom":i.push([e[0],e[1]+r]),i.push([e[0]+r,e[1]+r]),i.push([e[0]+r,e[1]])}}else{const t=Sc(o,e),a=Sc(o,n);if(t===a){let o,a;switch(t){case"left":o=Math.min(e[0],n[0])-r,i.push([o,e[1]]),i.push([o,n[1]]);break;case"right":o=Math.max(e[0],n[0])+r,i.push([o,e[1]]),i.push([o,n[1]]);break;case"top":a=Math.min(e[1],n[1])-r,i.push([e[0],a]),i.push([n[0],a]);break;case"bottom":a=Math.max(e[1],n[1])+r,i.push([e[0],a]),i.push([n[0],a])}}else{const s=(t,e)=>({left:[e[0]-r,e[1]],right:[e[0]+r,e[1]],top:[e[0],e[1]-r],bottom:[e[0],e[1]+r]}[t]),u=s(t,e),c=s(a,n),h=jh(u,c,o);i.push(u,h,c)}}return i}(t,h,l,i);return u&&(h=fl(u,d[0])),c&&(l=fl(c,d[d.length-1])),Gh([h,...d,l],e)}function qh(t,e){const n=new Set,r=new Set,i=new Set;return t.forEach((o=>{e(o).forEach((e=>{n.add(e),t.includes(e.source)&&t.includes(e.target)?r.add(e):i.add(e)}))})),{edges:Array.from(n),internal:Array.from(r),external:Array.from(i)}}const Yh=(t,e)=>[["M",0,0],["L",t,-e/2],["L",t,e/2],["Z"]];var $h=Object.freeze({__proto__:null,circle:(t,e)=>{const n=Math.max(t,e)/2;return[["M",0,0],["A",n,n,0,1,0,2*n,0],["A",n,n,0,1,0,0,0],["Z"]]},diamond:(t,e)=>[["M",0,0],["L",t/2,-e/2],["L",t,0],["L",t/2,e/2],["Z"]],rect:(t,e)=>[["M",0,-e/2],["L",t,-e/2],["L",t,e/2],["L",0,e/2],["Z"]],simple:(t,e)=>[["M",t,-e/2],["L",0,0],["L",t,e/2]],triangle:Yh,triangleRect:(t,e)=>{const n=t/2,r=t/7,i=t-r;return[["M",0,0],["L",n,-e/2],["L",n,e/2],["Z"],["M",i,-e/2],["L",i+r,-e/2],["L",i+r,e/2],["L",i,e/2],["Z"]]},vee:(t,e)=>[["M",0,0],["L",t,-e/2],["L",2*t/3,0],["L",t,e/2],["Z"]]});class Xh extends gh{type="edge";static defaultStyleProps={isBillboard:!0,label:!0,labelAutoRotate:!0,labelIsBillboard:!0,labelMaxWidth:"80%",labelOffsetX:4,labelOffsetY:0,labelPlacement:"center",labelTextBaseline:"middle",labelWordWrap:!1,halo:!1,haloDroppable:!1,haloLineDash:0,haloLineWidth:12,haloPointerEvents:"none",haloStrokeOpacity:.25,haloZIndex:-1,startArrow:!1,startArrowAnchor:"0.5 0.5",startArrowSize:8,startArrowLineDash:0,startArrowLineWidth:1,startArrowTransformOrigin:"center",startArrowType:"triangle",endArrow:!1,endArrowAnchor:"0.5 0.5",endArrowSize:8,endArrowLineDash:0,endArrowLineWidth:1,endArrowTransformOrigin:"center",endArrowType:"triangle",loopPlacement:"top",loopClockwise:!0};constructor(t){super(ee({},{style:Xh.defaultStyleProps},t))}getKeyStyle(t){const{sourceNode:e,targetNode:n,color:r,stroke:i,...o}=this.getGraphicStyle(t);var a,s;return{path:(s=n,(a=e)&&s&&a===s?this.getLoopPath(t):this.getKeyPath(t)),...Bc(o,["halo","label","startArrow","endArrow"]),stroke:r||i}}getLoopPath(t){const{sourceNode:e,sourcePort:n,targetPort:r}=t,i=wc(e),o=Math.max(yc(i),bc(i)),{placement:a,clockwise:s,dist:u=o}=zc(this.getGraphicStyle(t),"loop");return Wh(e,a,s,u,n,r)}getEndpoints(t){const{sourceNode:e,targetNode:n,sourcePort:r,targetPort:i}=t,[o,a]=hl(e,n,r,i);return[dl(o||e,a||n),dl(a||n,o||e)]}getHaloStyle(t){if(!1===t.halo)return!1;return{...this.getKeyStyle(t),...zc(this.getGraphicStyle(t),"halo")}}getLabelStyle(t){if(!1===t.label||re(t.labelText))return!1;const e=zc(this.getGraphicStyle(t),"label"),{placement:n,offsetX:r,offsetY:i,autoRotate:o,maxWidth:a,...s}=e,u=function(t,e,n,r,i){let o="number"==typeof e?e:.5;"start"===e&&(o=0),"end"===e&&(o=.99);const a=Zc(t.getPoint(o)),s=Zc(t.getPoint(o+.01));let u="start"===e?"left":"end"===e?"right":"center";if(eh(a,s)||!n){const[e,n]=zh(t,o,r,i);return{x:e,y:n,textAlign:u}}let c=Math.atan2(s[1]-a[1],s[0]-a[0]);s[0]<a[0]&&(u="center"===u?u:"left"===u?"right":"left",r*=-1,c+=Math.PI);const[h,l]=zh(t,o,r,i,c);return{x:h,y:l,textAlign:u,transform:`rotate(${c/Math.PI*180}deg)`}}(this.shapeMap.key,n,o,r,i),c=this.shapeMap.key.getLocalBounds(),h=function(t,e,n=1){return ah(qc(t[0],t[1])*n,e)}([c.min,c.max],a);return Object.assign({wordWrapWidth:h},u,s)}drawArrow(t,e){const n="start"===e,r=t["start"===e?"startArrow":"endArrow"],i=this.shapeMap.key;if(r){const e=this.getArrowStyle(t,n),r=re(e.src)?Rs:As,[o,a,s]=n?["markerStart","markerStartOffset","startArrowOffset"]:["markerEnd","markerEndOffset","endArrowOffset"],u=i.style[o];u?u.attr(e):i.style[o]=new r({style:e}),i.style[a]=t[s]||e.width/2+ +e.lineWidth}else{const t=n?"markerStart":"markerEnd";i.style[t]?.destroy(),i.style[t]=null}}getArrowStyle(t,e){const n=this.getKeyStyle(t),r=e?"startArrow":"endArrow",{size:i,type:o,...a}=zc(this.getGraphicStyle(t),r),[s,u]=Oc(i),c=(kt(o)?o:$h[o]||Yh)(s,u);return{...n,width:s,height:u,...c&&{path:c,fill:"simple"===o?"":n.stroke},...a}}drawLabelShape(t,e){this.upsert("label",mh,this.getLabelStyle(t),e)}drawHaloShape(t,e){this.upsert("halo",Rs,this.getHaloStyle(t),e)}drawKeyShape(t,e){return this.upsert("key",Rs,this.getKeyStyle(t),e)}render(t=this.parsedAttributes,e=this){this.drawKeyShape(t,e)&&(this.drawArrow(t,"start"),this.drawArrow(t,"end"),this.drawLabelShape(t,e),this.drawHaloShape(t,e))}animate(t,e){const n=super.animate(t,e);return n&&(n.onframe=()=>{this.drawLabelShape(this.parsedAttributes,this)}),n}}class Kh extends Xh{static defaultStyleProps={curvePosition:.5,curveOffset:20};constructor(t){super(ee({},{style:Kh.defaultStyleProps},t))}getKeyPath(t){const[e,n]=this.getEndpoints(t),{controlPoints:r,curvePosition:i,curveOffset:o}=t,a=this.getControlPoints(e,n,function(t){return Vt(t)?[t,1-t]:t}(i),function(t){return Vt(t)?[t,-t]:t}(o),r);return Bh(e,n,a)}getControlPoints(t,e,n,r,i){return 2===i?.length?i:[Fh(t,e,n[0],r[0]),Fh(t,e,n[1],r[1])]}}class Zh extends Kh{static defaultStyleProps={curvePosition:[.5,.5],curveOffset:[0,0]};constructor(t){super(ee({},{style:Zh.defaultStyleProps},t))}getControlPoints(t,e,n,r){const i=e[0]-t[0];return[[t[0]+i*n[0]+r[0],t[1]],[e[0]-i*n[1]+r[1],e[1]]]}}class Qh extends Kh{static defaultStyleProps={curvePosition:[.5,.5],curveOffset:[0,0]};constructor(t){super(ee({},{style:Qh.defaultStyleProps},t))}getControlPoints(t,e,n,r){const i=e[1]-t[1];return[[t[0],t[1]+i*n[0]+r[0]],[e[0],e[1]-i*n[1]+r[1]]]}}class Jh extends Xh{static defaultStyleProps={};constructor(t){super(ee({},{style:Jh.defaultStyleProps},t))}getKeyPath(t){const[e,n]=this.getEndpoints(t);return[["M",e[0],e[1]],["L",n[0],n[1]]]}}class tl extends Xh{static defaultStyleProps={radius:0,controlPoints:[],router:!1,routerName:"orth",routerPadding:10};constructor(t){super(ee({},{style:tl.defaultStyleProps},t))}getKeyPath(t){const{sourceNode:e,targetNode:n,radius:r}=t,{sourcePoint:i,targetPoint:o,sourcePort:a,targetPort:s}=this.getEndpointsAndPorts(t),u=this.getControlPoints(t,i,o),c=dl(a||e,u[0]||s||n),h=dl(s||n,u[u.length-1]||a||e);return Gh([c,...u,h],r)}getEndpointsAndPorts(t){const{sourceNode:e,targetNode:n,sourcePort:r,targetPort:i}=t,[o,a]=hl(e,n,r,i);return{sourcePoint:o?cl(o):e.getCenter(),targetPoint:a?cl(a):n.getCenter(),sourcePort:o,targetPort:a}}getControlPoints(t,e,n){const{controlPoints:r,sourceNode:i,targetNode:o,router:a,routerPadding:s}=t;if(!a)return[...r];return function(t,e,n,r,i,o){const a=[t,...i,e];let s=null;const u=[];for(let t=0,e=a.length;t<e-1;t++){const i=t+1,l=a[t],d=a[i],f=eh(c=l,h=d)||function(t,e){return t[0]===e[0]}(c,h);let p=null;0===t?i===e-1?n.intersects(r)?p=Lh(l,d,n,r):f||(p=Ih(l,d,n,r)):Nc(d,n)?p=Lh(l,d,n,wc(d,o),s):f||(p=_h(l,d,n)):i===e-1?Nc(l,r)?p=Lh(l,d,wc(l,o),r,s):f||(p=Dh(l,d,r,s)):f||(p=Rh(l,d,s)),p?(u.push(...p.points),s=p.direction):s=Ah(l,d),i<e-1&&u.push(d)}var c,h;return u}(e,n,wc(i,s),wc(o,s),r,s)}getLoopPath(t){const{sourceNode:e,sourcePort:n,targetPort:r,radius:i}=t,o=wc(e),a=Math.max(yc(o),bc(o))/4,{placement:s,clockwise:u,dist:c=a}=zc(this.getGraphicStyle(t),"loop");return Hh(e,i,s,u,c,n,r)}}class el extends Xh{static defaultStyleProps={curvePosition:.5,curveOffset:30};constructor(t){super(ee({},{style:el.defaultStyleProps},t))}getKeyPath(t){const{curvePosition:e,curveOffset:n}=t,[r,i]=this.getEndpoints(t);return function(t,e,n){return[["M",t[0],t[1]],["Q",n[0],n[1],e[0],e[1]]]}(r,i,t.controlPoint||Fh(r,i,e,n))}}function nl(t){return t instanceof bh&&"node"===t.type}function rl(t){return t instanceof Xh}function il(t){return t instanceof Th}const ol={top:[.5,0],right:[1,.5],bottom:[.5,1],left:[0,.5],default:[.5,.5]};function al(t,e,n=ol,r=!0){const i=[.5,.5],o=zt(e)?oe(n,e.toLocaleLowerCase(),i):e;if(!r&&zt(e))return o;const[a,s]=o||i;return[t.min[0]+yc(t)*a,t.min[1]+bc(t)*s]}function sl(t){const e=t.getPorts();return(t.attributes.ports||[]).forEach(((n,r)=>{const{key:i,placement:o}=n;ul(n)&&(e[i||r]||=Cc(t.getKey().getBounds(),o))})),e}function ul(t){const{r:e}=t;return!e||0===Number(e)}function cl(t){return gc(t)?t:t.getPosition()}function hl(t,e,n,r){return[ll(t,e,n,r),ll(e,t,r,n)]}function ll(t,e,n,r){const i=sl(t);if(n)return i[n];const o=Object.values(i);if(0===o.length)return;const a=o.map((t=>cl(t))),s=function(t,e){const n=sl(t);if(e)return[cl(n[e])];const r=Object.values(n);return r.length>0?r.map((t=>cl(t))):[t.getCenter()]}(e,r),[u]=function(t,e){let n=1/0,r=[t[0],e[0]];return t.forEach((t=>{e.forEach((e=>{const i=qc(t,e);i<n&&(n=i,r=[t,e])}))})),r}(a,s);return o.find((t=>cl(t)===u))}function dl(t,e){return nl(t)?pl(t,e):fl(t,e)}function fl(t,e){if(gc(t))return t;if(t.attributes.linkToCenter)return t.getPosition();return oh(gc(e)?e:nl(e)?e.getCenter():e.getPosition(),t.getBounds())}function pl(t,e){const n=gc(e)?e:nl(e)?e.getCenter():e.getPosition();return t.getIntersectPoint(n)||t.getCenter()}function gl(t,e="bottom",n=!1){const r=e.split("-"),[i,o]=Cc(t,e),a=r.includes("left")?"right":r.includes("right")?"left":"center";let s=r.includes("top")?"bottom":r.includes("bottom")?"top":"middle";return n&&(s="top"===s?"bottom":"bottom"===s?"top":s),{x:i,y:o,textBaseline:s,textAlign:a}}function ml(t,e){"update"in t?t.update(e):t.attr(e)}function vl(t,e){if(Array.isArray(t)&&0===t.length)return null;const n=Array.isArray(t)?t[0]:t,r=Array.isArray(t)?t.slice(1):e||[];return new Proxy(n,{get:(t,e)=>"function"!=typeof t[e]||["onframe","onfinish"].includes(e)?"finished"===e?Promise.all([n.finished,...r.map((t=>t.finished))]):Reflect.get(t,e):(...n)=>{t[e](...n),r.forEach((t=>t[e]?.(...n)))},set:(t,e,n)=>(["onframe","onfinish"].includes(e)||r.forEach((t=>{t[e]=n})),Reflect.set(t,e,n))})}function yl(t){const e=t.reduce(((t,e)=>(Object.entries(e).forEach((([e,n])=>{void 0===t[e]?t[e]=[n]:t[e].push(n)})),t)),{});return Object.entries(e).forEach((([n,r])=>{(r.length!==t.length||r.some((t=>Pt(t)))||r.every((t=>!nl(t)&&ie(t,r[0]))))&&delete e[n]})),Object.entries(e).reduce(((t,[e,n])=>(n.forEach(((n,r)=>{t[r]?t[r][e]=n:t[r]={[e]:n}})),t)),[])}function bl(t){switch(t){case"opacity":return 1;case"x":case"y":case"z":case"zIndex":return 0;default:return}}function El(t,e){return e.before?.(),t?(e.beforeAnimate?.(t),t.finished.then((()=>{e.afterAnimate?.(t),e.after?.()}))):e.after?.(),t}function wl(t,e){const{animation:n}=t;if(!n||!1===e)return!1;const r={...nc};return Rt(n)&&Object.assign(r,n),Rt(e)&&Object.assign(r,e),r}const xl=(t,e,n,r)=>{if(!e)return null;const{animationsFilter:i=(()=>!0)}=r,o=(zt(e)?sI("animation",e)||[]:e).filter(i);if(0===o.length)return null;const{originalStyle:a,modifiedStyle:s,states:u}=r,c=e=>{if(e){const n=t.getElementById(e),r=`get${function(t){var e=qt(t);return e.charAt(0).toUpperCase()+e.substring(1)}(e)}Style`,i=t?.[r]?.bind(t)||(t=>t);return{shape:n,fromStyle:i?.({...t.attributes,...a})||{},toStyle:{...n.attributes}}}return{shape:t,fromStyle:a,toStyle:{...t.attributes,...s}}};let h;const l=o.map((({fields:t,shape:e,states:r,...i})=>{if(void 0===r||r?.some((t=>u.includes(t)))){const{shape:r,fromStyle:o,toStyle:a}=c(e);if(!r)return null;const s=[{},{}];t.forEach((t=>{Object.assign(s[0],{[t]:o[t]??bl(t)}),Object.assign(s[1],{[t]:a[t]??bl(t)})}));const u=function(t,e,n){if(0===e.length)return null;const r=["opacity"];if(!e.some((t=>Object.keys(t).some((t=>r.includes(t))))))return t.animate(e,n);const i=e.map((t=>{const e={};return Object.entries(t).forEach((([t,n])=>{r.includes(t)&&(e[t]=n)})),e})),o=fh(t);return vl(t.animate(e,n),o.map((t=>t.animate(i,n))))}(r,yl(s),{...rc,...n,...i});return void 0===e&&(h=u),u}return null})).filter(Boolean),d=h||l?.[0];return d?vl(d,l.filter((t=>t!==d))):null};function Ml(t,e,n){const r=new Map(t.map((t=>[n(t),t]))),i=new Map(e.map((t=>[n(t),t]))),o=new Set(r.keys()),a=new Set(i.keys()),s=[],u=[],c=[],h=[];return a.forEach((t=>{o.has(t)?ie(r.get(t),i.get(t))?h.push(i.get(t)):u.push(i.get(t)):s.push(i.get(t))})),o.forEach((t=>{a.has(t)||c.push(r.get(t))})),{enter:s,exit:c,keep:h,update:u}}class Nl{context;extensions=[];extensionMap={};constructor(t){this.context=t}setExtensions(t){const e=function(t,e){const n={},r=e=>(e in n||(n[e]=0),`${t}-${e}-${n[e]++}`);return e.map((t=>"string"==typeof t?{type:t,key:r(t)}:t.key?t:{...t,key:r(t.type)}))}(this.category,t),{enter:n,update:r,exit:i,keep:o}=Ml(this.extensions,e,(t=>t.key));this.createExtensions(n),this.updateExtensions([...r,...o]),this.destroyExtensions(i),this.extensions=e}createExtension(t){const{category:e}=this,{key:n,type:r}=t,i=sI(e,r);if(!i)return;const o=new i(this.context,t);this.extensionMap[n]=o}createExtensions(t){t.forEach((t=>this.createExtension(t)))}updateExtension(t){const{key:e}=t,n=this.extensionMap[e];n&&n.update(t)}updateExtensions(t){t.forEach((t=>this.updateExtension(t)))}destroyExtension(t){const e=this.extensionMap[t];e&&(e.destroy(),delete this.extensionMap[t])}destroyExtensions(t){t.forEach((({key:t})=>this.destroyExtension(t)))}destroy(){Object.values(this.extensionMap).forEach((t=>t.destroy())),delete this.context,delete this.extensions,delete this.extensionMap}}class Sl{context;options;events=[];destroyed=!1;constructor(t,e){this.context=t,this.options=e}update(t){this.options=Object.assign(this.options,t)}destroy(){delete this.context,delete this.options,this.destroyed=!0}}class Tl extends Sl{}class kl extends Tl{static defaultOptions={enable:!0,animation:!0};constructor(t,e){super(t,Object.assign({},kl.defaultOptions,e)),this.bindEvents()}bindEvents(){const{graph:e}=this.context;this.unbindEvents(),e.on(`combo:${t.CommonEvent.DBLCLICK}`,this.onCollapseExpand)}unbindEvents(){const{graph:e}=this.context;e.off(`combo:${t.CommonEvent.DBLCLICK}`,this.onCollapseExpand)}onCollapseExpand=async t=>{if(!this.validate(t))return;const e=t?.target?.id,{model:n,graph:r}=this.context,i=n.getComboData([e])[0];if(!i)return!1;const{oncollapse:o,onexpand:a,animation:s}=this.options,u=i.style?.collapsed;u?(await r.expand(e,s),a?.(e)):(await r.collapse(e,s),o?.(e))};validate(t){if(this.destroyed)return!1;const{enable:e}=this.options;return kt(e)?e(t):!!e}destroy(){this.unbindEvents(),super.destroy()}}class Pl{map=new Map;emitter;recordKey=new Set;constructor(t){this.emitter=t,this.bindEvents()}bind(t,e){0!==t.length&&this.map.set(t,e)}unbind(t,e){this.map.forEach(((n,r)=>{ie(r,t)&&(e&&e!==n||this.map.delete(r))}))}unbindAll(){this.map.clear()}bindEvents(){const{emitter:e}=this;e.on(t.CommonEvent.KEY_DOWN,this.onKeyDown),e.on(t.CommonEvent.KEY_UP,this.onKeyUp),e.on(t.CommonEvent.WHEEL,this.onWheel)}onKeyDown=t=>{this.recordKey.add(t.key),this.trigger(t)};onKeyUp=t=>{this.recordKey.delete(t.key)};trigger(t){this.map.forEach(((e,n)=>{ie(Array.from(this.recordKey),n)&&e(t)}))}onWheel=e=>{this.map.forEach(((n,r)=>{r.includes(t.CommonEvent.WHEEL)&&ie(Array.from(this.recordKey),r.filter((e=>e!==t.CommonEvent.WHEEL)))&&n(e)}))}}class Cl extends Tl{static defaultOptions={enable:!0,sensitivity:10};shortcut;defaultCursor;constructor(t,e){super(t,Object.assign({},Cl.defaultOptions,e)),this.shortcut=new Pl(t.graph),this.bindEvents(),this.defaultCursor=this.context.canvas.getConfig().cursor||"default",t.canvas.setCursor("grab")}bindEvents(){const{trigger:e}=this.options;this.shortcut.unbindAll();const{graph:n}=this.context;if(Rt(e)){n.off(t.CanvasEvent.DRAG,this.onDrag);const{up:r=[],down:i=[],left:o=[],right:a=[]}=e;this.shortcut.bind(r,(t=>this.translate([0,1],t))),this.shortcut.bind(i,(t=>this.translate([0,-1],t))),this.shortcut.bind(o,(t=>this.translate([1,0],t))),this.shortcut.bind(a,(t=>this.translate([-1,0],t)))}else n.on(t.CanvasEvent.DRAG,this.onDrag)}onDrag=t=>{"canvas"===t.targetType&&this.context.graph.translateBy([t.movement.x,t.movement.y],!1)};translate(t,e){if(!this.validate(e))return;const{sensitivity:n}=this.options,r=-1*n;this.context.graph.translateBy(Wc(t,r),this.options.animation)}validate(t){if(this.destroyed)return!1;const{enable:e}=this.options;return kt(e)?e(t):!!e}destroy(){this.context.canvas.setCursor(this.defaultCursor),super.destroy()}}class Al extends Tl{static defaultOptions={animation:!0,enable:t=>["node","combo"].includes(t.targetType),dropEffect:"move",state:"selected",hideEdge:"none",shadowZIndex:100,shadowFill:"#F3F9FF",shadowFillOpacity:.5,shadowStroke:"#1890FF",shadowStrokeOpacity:.9,shadowLineDash:[5,5]};enable=!1;enableElements=["node","combo"];target=[];shadow;shadowOrigin=[0,0];hiddenEdges=[];get animation(){return!!this.options.shadow&&this.options.animation}constructor(t,e){super(t,Object.assign({},Al.defaultOptions,e)),this.bindEvents()}update(t){super.update(t),this.bindEvents()}bindEvents(){const{graph:e}=this.context;this.unbindEvents(),this.enableElements.forEach((n=>{e.on(`${n}:${t.CommonEvent.DRAG_START}`,this.onDragStart),e.on(`${n}:${t.CommonEvent.DRAG}`,this.onDrag),e.on(`${n}:${t.CommonEvent.DRAG_END}`,this.onDragEnd)})),["link"].includes(this.options.dropEffect)&&(e.on(`combo:${t.CommonEvent.DROP}`,this.onDrop),e.on(`canvas:${t.CommonEvent.DROP}`,this.onDrop))}getSelectedNodeIDs(t){return Array.from(new Set(this.context.graph.getElementDataByState("node",this.options.state).map((t=>t.id)).concat(t)))}onDragStart=t=>{this.enable=this.validate(t),this.enable&&(this.target=this.getSelectedNodeIDs([t.target.id]),this.hideEdge(),this.context.graph.frontElement(this.target),this.options.shadow&&this.createShadow(this.target))};onDrag=t=>{if(!this.enable)return;const e=this.context.graph.getZoom(),{dx:n,dy:r}=t,i=Hc([n,r],e);this.options.shadow?this.moveShadow(i):this.moveElement(this.target,i)};onDragEnd=()=>{if(this.enable=!1,this.options.shadow){if(!this.shadow)return;this.shadow.style.visibility="hidden";const{x:t=0,y:e=0}=this.shadow.attributes,[n,r]=Uc([+t,+e],this.shadowOrigin);this.moveElement(this.target,[n,r])}this.showEdges(),this.options.onFinish?.(this.target),this.target=[]};onDrop=async t=>{if("link"!==this.options.dropEffect)return;const{model:e,element:n}=this.context,r=t.target.id;this.target.forEach((t=>{const n=e.getParentData(t,dc);n&&Ic(n)===r&&e.refreshComboData(r),e.setParent(t,r,dc)})),await(n?.draw({animation:!0}))};validate(t){if(this.destroyed)return!1;const{enable:e}=this.options;return kt(e)?e(t):!!e}async moveElement(t,e){const{model:n,element:r}=this.context,{dropEffect:i}=this.options;t.forEach((t=>{const r=n.getElementType(t);"node"===r?n.translateNodeBy(t,e):"combo"===r&&n.translateComboBy(t,e)})),"move"===i&&t.forEach((t=>n.refreshComboData(t))),await r.draw({animation:this.animation})}moveShadow(t){if(!this.shadow)return;const{x:e=0,y:n=0}=this.shadow.attributes,[r,i]=t;this.shadow.attr({x:+e+r,y:+n+i})}createShadow(t){const e=zc(this.options,"shadow"),n=Mc(t.map((t=>this.context.element.getElement(t).getBounds()))),[r,i]=n.min;this.shadowOrigin=[r,i];const[o,a]=Ec(n),s={width:o,height:a,x:r,y:i};this.shadow?this.shadow.attr({...e,...s,visibility:"visible"}):(this.shadow=new Is({style:{...e,...s,pointerEvents:"none",$layer:"transient"}}),this.context.canvas.appendChild(this.shadow))}showEdges(){this.options.shadow||0===this.hiddenEdges.length||(this.context.graph.showElement(this.hiddenEdges),this.hiddenEdges=[])}hideEdge(){const{hideEdge:t,shadow:e}=this.options;if("none"===t||e)return;const{graph:n}=this.context;this.hiddenEdges="all"===t?n.getEdgeData().map(Ic):Array.from(new Set(this.target.map((e=>n.getRelatedEdgesData(e,t).map(Ic))).flat())),n.hideElement(this.hiddenEdges)}unbindEvents(){const{graph:e}=this.context;this.enableElements.forEach((n=>{e.off(`${n}:${t.CommonEvent.DRAG_START}`,this.onDragStart),e.off(`${n}:${t.CommonEvent.DRAG}`,this.onDrag),e.off(`${n}:${t.CommonEvent.DRAG_END}`,this.onDragEnd)})),e.off(`combo:${t.CommonEvent.DROP}`,this.onDrop),e.off(`canvas:${t.CommonEvent.DROP}`,this.onDrop)}destroy(){this.unbindEvents(),this.shadow?.destroy(),super.destroy()}}class Ol extends Tl{static defaultOptions={animation:{duration:200},enable:!0,sensitivity:1,trigger:[]};shortcut;constructor(t,e){super(t,Object.assign({},Ol.defaultOptions,e)),this.shortcut=new Pl(t.graph),this.bindEvents()}update(t){super.update(t),this.bindEvents()}bindEvents(){const{trigger:e}=this.options;if(this.shortcut.unbindAll(),Ot(e)&&(this.preventDefault(t.CanvasEvent.WHEEL),this.shortcut.bind([...e,t.CanvasEvent.WHEEL],(t=>{const{deltaX:e,deltaY:n}=t;this.zoom(-(n??e),t,!1)}))),Rt(e)){const{zoomIn:t=[],zoomOut:n=[],reset:r=[]}=e;this.shortcut.bind(t,(t=>this.zoom(10,t,this.options.animation))),this.shortcut.bind(n,(t=>this.zoom(-10,t,this.options.animation))),this.shortcut.bind(r,this.onReset)}}zoom=async(t,e,n)=>{if(!this.validate(e))return;const{graph:r}=this.context;let i;"viewport"in e&&(i=Zc(e.viewport));const{sensitivity:o,onfinish:a}=this.options,s=1+Gt(t,-50,50)*o/100,u=r.getZoom();await r.zoomTo(u*s,n,i),a?.()};onReset=async()=>{await this.context.graph.zoomTo(1,this.options.animation)};validate(t){if(this.destroyed)return!1;const{enable:e}=this.options;return kt(e)?e(t):!!e}preventDefault(t){const e=this.context.canvas.getContainer();e&&e.addEventListener(t,(t=>t.preventDefault()))}}var Rl=function(t){return null!==t&&"function"!=typeof t&&isFinite(t.length)},_l=function(t,e){return!!Rl(t)&&t.indexOf(e)>-1},Dl=function(t,e){if(!Rl(t))return t;for(var n=[],r=0;r<t.length;r++){var i=t[r];e(i,r)&&n.push(i)}return n},Il={}.toString,Ll=function(t,e){return Il.call(t)==="[object "+e+"]"},jl=function(t){return Ll(t,"Function")},zl=function(t){return null==t},Fl=function(t){return Array.isArray?Array.isArray(t):Ll(t,"Array")},Bl=function(t){var e=typeof t;return null!==t&&"object"===e||"function"===e};function Gl(t,e){if(t)if(Fl(t))for(var n=0,r=t.length;n<r&&!1!==e(t[n],n);n++);else if(Bl(t))for(var i in t)if(t.hasOwnProperty(i)&&!1===e(t[i],i))break}var Vl=Object.keys?function(t){return Object.keys(t)}:function(t){var e=[];return Gl(t,(function(n,r){jl(t)&&"prototype"===r||e.push(r)})),e};function Ul(t,e){var n=Vl(e),r=n.length;if(zl(t))return!r;for(var i=0;i<r;i+=1){var o=n[i];if(e[o]!==t[o]||!(o in t))return!1}return!0}var Wl=function(t){return"object"==typeof t&&null!==t},Hl=function(t){if(!Wl(t)||!Ll(t,"Object"))return!1;if(null===Object.getPrototypeOf(t))return!0;for(var e=t;null!==Object.getPrototypeOf(e);)e=Object.getPrototypeOf(e);return Object.getPrototypeOf(t)===e};var ql=function(t,e){if(void 0===e&&(e=[]),Fl(t))for(var n=0;n<t.length;n+=1)ql(t[n],e);else e.push(t);return e},Yl=function(t){if(Fl(t))return t.reduce((function(t,e){return Math.max(t,e)}),t[0])},$l=function(t){if(Fl(t))return t.reduce((function(t,e){return Math.min(t,e)}),t[0])},Xl=Array.prototype,Kl=Xl.splice,Zl=Xl.indexOf,Ql=Array.prototype.splice,Jl=function(t,e){if(!Rl(t))return[];for(var n=t?e.length:0,r=n-1;n--;){var i=void 0,o=e[n];n!==r&&o===i||(i=o,Ql.call(t,o,1))}return t},td=function(t,e,n){if(!Fl(t)&&!Hl(t))return t;var r=n;return Gl(t,(function(t,n){r=e(r,t,n)})),r},ed=function(t){return Ll(t,"String")};function nd(t,e){void 0===e&&(e=new Map);var n=[];if(Array.isArray(t))for(var r=0,i=t.length;r<i;r++){var o=t[r];e.has(o)||(n.push(o),e.set(o,!0))}return n}var rd=Object.prototype.hasOwnProperty;function id(t,e){if(!e||!Fl(t))return{};for(var n,r={},i=jl(e)?e:function(t){return t[e]},o=0;o<t.length;o++){var a=t[o];n=i(a),rd.call(r,n)?r[n].push(a):r[n]=[a]}return r}function od(t,e){if(!e)return{0:t};if(!jl(e)){var n=Fl(e)?e:e.replace(/\s+/g,"").split("*");e=function(t){for(var e="_",r=0,i=n.length;r<i;r++)e+=t[n[r]]&&t[n[r]].toString();return e}}return id(t,e)}var ad={};var sd=function(t){return Ll(t,"Number")},ud=Number.isInteger?Number.isInteger:function(t){return sd(t)&&t%1==0};var cd=180/Math.PI,hd=parseInt,ld=Math.PI/180,dd=function(t,e){return t.hasOwnProperty(e)},fd=Object.values?function(t){return Object.values(t)}:function(t){var e=[];return Gl(t,(function(n,r){jl(t)&&"prototype"===r||e.push(n)})),e},pd=function(t){return zl(t)?"":t.toString()};var gd={}.toString,md=function(t){return gd.call(t).replace(/^\[object /,"").replace(/]$/,"")};var vd=Object.prototype,yd=function(t){var e=t&&t.constructor;return t===("function"==typeof e&&e.prototype||vd)};function bd(t,e){for(var n in e)e.hasOwnProperty(n)&&"constructor"!==n&&void 0!==e[n]&&(t[n]=e[n])}function Ed(t,e,n,r){return e&&bd(t,e),n&&bd(t,n),r&&bd(t,r),t}var wd=function(t){if("object"!=typeof t||null===t)return t;var e;if(Fl(t)){e=[];for(var n=0,r=t.length;n<r;n++)"object"==typeof t[n]&&null!=t[n]?e[n]=wd(t[n]):e[n]=t[n]}else for(var i in e={},t)"object"==typeof t[i]&&null!=t[i]?e[i]=wd(t[i]):e[i]=t[i];return e};var xd=function(t,e){if(!jl(t))throw new TypeError("Expected a function");var n=function(){for(var r=[],i=0;i<arguments.length;i++)r[i]=arguments[i];var o=e?e.apply(this,r):r[0],a=n.cache;if(a.has(o))return a.get(o);var s=t.apply(this,r);return a.set(o,s),s};return n.cache=new Map,n};function Md(t,e,n,r){for(var i in n=n||0,r=r||5,e)if(e.hasOwnProperty(i)){var o=e[i];null!==o&&Hl(o)?(Hl(t[i])||(t[i]={}),n<r?Md(t[i],o,n+1,r):t[i]=e[i]):Fl(o)?(t[i]=[],t[i]=t[i].concat(o)):void 0!==o&&(t[i]=o)}}var Nd=Object.prototype.hasOwnProperty;var Sd,Td=function(t,e){if(t===e)return!0;if(!t||!e)return!1;if(ed(t)||ed(e))return!1;if(Rl(t)||Rl(e)){if(t.length!==e.length)return!1;for(var n=!0,r=0;r<t.length&&(n=Td(t[r],e[r]));r++);return n}if(Wl(t)||Wl(e)){var i=Object.keys(t),o=Object.keys(e);if(i.length!==o.length)return!1;for(n=!0,r=0;r<i.length&&(n=Td(t[i[r]],e[i[r]]));r++);return n}return!1},kd=function(t){return t},Pd=Object.prototype.hasOwnProperty,Cd={};var Ad=xd((function(t,e){void 0===e&&(e={});var n=e.fontSize,r=e.fontFamily,i=e.fontWeight,o=e.fontStyle,a=e.fontVariant;return Sd||(Sd=document.createElement("canvas").getContext("2d")),Sd.font=[o,a,i,n+"px",r].join(" "),Sd.measureText(ed(t)?t:"").width}),(function(t,e){return void 0===e&&(e={}),function(){for(var t=0,e=0,n=arguments.length;e<n;e++)t+=arguments[e].length;var r=Array(t),i=0;for(e=0;e<n;e++)for(var o=arguments[e],a=0,s=o.length;a<s;a++,i++)r[i]=o[a];return r}([t],fd(e)).join("")})),Od=function(){function t(){this.map={}}return t.prototype.has=function(t){return void 0!==this.map[t]},t.prototype.get=function(t,e){var n=this.map[t];return void 0===n?e:n},t.prototype.set=function(t,e){this.map[t]=e},t.prototype.clear=function(){this.map={}},t.prototype.delete=function(t){delete this.map[t]},t.prototype.size=function(){return Object.keys(this.map).length},t}(),Rd=Object.freeze({__proto__:null,Cache:Od,assign:Ed,augment:function(){for(var t=[],e=0;e<arguments.length;e++)t[e]=arguments[e];for(var n=t[0],r=1;r<t.length;r++){var i=t[r];jl(i)&&(i=i.prototype),Ed(n.prototype,i)}},clamp:function(t,e,n){return t<e?e:t>n?n:t},clearAnimationFrame:function(t){(window.cancelAnimationFrame||window.webkitCancelAnimationFrame||window.mozCancelAnimationFrame||window.msCancelAnimationFrame||clearTimeout)(t)},clone:wd,contains:_l,debounce:function(t,e,n){var r;return function(){var i=this,o=arguments,a=n&&!r;clearTimeout(r),r=setTimeout((function(){r=null,n||t.apply(i,o)}),e),a&&t.apply(i,o)}},deepMix:function(t){for(var e=[],n=1;n<arguments.length;n++)e[n-1]=arguments[n];for(var r=0;r<e.length;r+=1)Md(t,e[r]);return t},difference:function(t,e){return void 0===e&&(e=[]),Dl(t,(function(t){return!_l(e,t)}))},each:Gl,endsWith:function(t,e){return!(!Fl(t)&&!ed(t))&&t[t.length-1]===e},every:function(t,e){for(var n=0;n<t.length;n++)if(!e(t[n],n))return!1;return!0},extend:function(t,e,n,r){jl(e)||(n=e,e=t,t=function(){});var i=Object.create?function(t,e){return Object.create(t,{constructor:{value:e}})}:function(t,e){function n(){}n.prototype=t;var r=new n;return r.constructor=e,r},o=i(e.prototype,t);return t.prototype=Ed(o,t.prototype),t.superclass=i(e.prototype,e),Ed(o,n),Ed(t,r),t},filter:Dl,find:function(t,e){if(!Fl(t))return null;var n;if(jl(e)&&(n=e),Hl(e)&&(n=function(t){return Ul(t,e)}),n)for(var r=0;r<t.length;r+=1)if(n(t[r]))return t[r];return null},findIndex:function(t,e,n){void 0===n&&(n=0);for(var r=n;r<t.length;r++)if(e(t[r],r))return r;return-1},firstValue:function(t,e){for(var n=null,r=0;r<t.length;r++){var i=t[r][e];if(!zl(i)){n=Fl(i)?i[0]:i;break}}return n},fixedBase:function(t,e){var n=e.toString(),r=n.indexOf(".");if(-1===r)return Math.round(t);var i=n.substr(r+1).length;return i>20&&(i=20),parseFloat(t.toFixed(i))},flatten:function(t){if(!Fl(t))return[];for(var e=[],n=0;n<t.length;n++)e=e.concat(t[n]);return e},flattenDeep:ql,forIn:Gl,get:function(t,e,n){for(var r=0,i=ed(e)?e.split("."):e;t&&r<i.length;)t=t[i[r++]];return void 0===t||r<i.length?n:t},getEllipsisText:function(t,e,n,r){void 0===r&&(r="...");var i,o,a=Ad(r,n),s=ed(t)?t:pd(t),u=e,c=[];if(Ad(t,n)<=e)return t;for(;i=s.substr(0,16),!((o=Ad(i,n))+a>u&&o>u);)if(c.push(i),u-=o,!(s=s.substr(16)))return c.join("");for(;i=s.substr(0,1),!((o=Ad(i,n))+a>u);)if(c.push(i),u-=o,!(s=s.substr(1)))return c.join("");return""+c.join("")+r},getRange:function(t){var e=t.filter((function(t){return!isNaN(t)}));if(!e.length)return{min:0,max:0};if(Fl(t[0])){for(var n=[],r=0;r<t.length;r++)n=n.concat(t[r]);e=n}var i=Yl(e);return{min:$l(e),max:i}},getType:md,getWrapBehavior:function(t,e){return t["_wrap_"+e]},group:function(t,e){if(!e)return[t];var n=od(t,e),r=[];for(var i in n)r.push(n[i]);return r},groupBy:id,groupToMap:od,has:dd,hasKey:dd,hasValue:function(t,e){return _l(fd(t),e)},head:function(t){if(Rl(t))return t[0]},identity:function(t){return t},includes:_l,indexOf:function(t,e){if(!Rl(t))return-1;var n=Array.prototype.indexOf;if(n)return n.call(t,e);for(var r=-1,i=0;i<t.length;i++)if(t[i]===e){r=i;break}return r},isArguments:function(t){return Ll(t,"Arguments")},isArray:Fl,isArrayLike:Rl,isBoolean:function(t){return Ll(t,"Boolean")},isDate:function(t){return Ll(t,"Date")},isDecimal:function(t){return sd(t)&&t%1!=0},isElement:function(t){return t instanceof Element||t instanceof HTMLDocument},isEmpty:function(t){if(zl(t))return!0;if(Rl(t))return!t.length;var e=md(t);if("Map"===e||"Set"===e)return!t.size;if(yd(t))return!Object.keys(t).length;for(var n in t)if(Nd.call(t,n))return!1;return!0},isEqual:Td,isEqualWith:function(t,e,n){return jl(n)?!!n(t,e):Td(t,e)},isError:function(t){return Ll(t,"Error")},isEven:function(t){return sd(t)&&t%2==0},isFinite:function(t){return sd(t)&&isFinite(t)},isFunction:jl,isInteger:ud,isMatch:Ul,isNegative:function(t){return sd(t)&&t<0},isNil:zl,isNull:function(t){return null===t},isNumber:sd,isNumberEqual:function(t,e,n){return void 0===n&&(n=1e-5),Math.abs(t-e)<n},isObject:Bl,isObjectLike:Wl,isOdd:function(t){return sd(t)&&t%2!=0},isPlainObject:Hl,isPositive:function(t){return sd(t)&&t>0},isPrototype:yd,isRegExp:function(t){return Ll(t,"RegExp")},isString:ed,isType:Ll,isUndefined:function(t){return void 0===t},keys:Vl,last:function(t){if(Rl(t)){return t[t.length-1]}},lowerCase:function(t){return pd(t).toLowerCase()},lowerFirst:function(t){var e=pd(t);return e.charAt(0).toLowerCase()+e.substring(1)},map:function(t,e){if(!Rl(t))return t;for(var n=[],r=0;r<t.length;r++){var i=t[r];n.push(e(i,r))}return n},mapValues:function(t,e){void 0===e&&(e=kd);var n={};return Bl(t)&&!zl(t)&&Object.keys(t).forEach((function(r){n[r]=e(t[r],r)})),n},max:Yl,maxBy:function(t,e){if(Fl(t)){for(var n,r=-1/0,i=0;i<t.length;i++){var o=t[i],a=jl(e)?e(o):o[e];a>r&&(n=o,r=a)}return n}},measureTextWidth:Ad,memoize:xd,min:$l,minBy:function(t,e){if(Fl(t)){for(var n,r=1/0,i=0;i<t.length;i++){var o=t[i],a=jl(e)?e(o):o[e];a<r&&(n=o,r=a)}return n}},mix:Ed,mod:function(t,e){return(t%e+e)%e},noop:function(){},number2color:function(t){var e=ad[t];if(!e){for(var n=t.toString(16),r=n.length;r<6;r++)n="0"+n;e="#"+n,ad[t]=e}return e},omit:function(t,e){return td(t,(function(t,n,r){return e.includes(r)||(t[r]=n),t}),{})},parseRadius:function(t){var e=0,n=0,r=0,i=0;return Fl(t)?1===t.length?e=n=r=i=t[0]:2===t.length?(e=r=t[0],n=i=t[1]):3===t.length?(e=t[0],n=i=t[1],r=t[2]):(e=t[0],n=t[1],r=t[2],i=t[3]):e=n=r=i=t,{r1:e,r2:n,r3:r,r4:i}},pick:function(t,e){if(null===t||!Hl(t))return{};var n={};return Gl(e,(function(e){Pd.call(t,e)&&(n[e]=t[e])})),n},pull:function(t){for(var e=[],n=1;n<arguments.length;n++)e[n-1]=arguments[n];for(var r=0;r<e.length;r++)for(var i=e[r],o=-1;(o=Zl.call(t,i))>-1;)Kl.call(t,o,1);return t},pullAt:Jl,reduce:td,remove:function(t,e){var n=[];if(!Rl(t))return n;for(var r=-1,i=[],o=t.length;++r<o;){var a=t[r];e(a,r,t)&&(n.push(a),i.push(r))}return Jl(t,i),n},requestAnimationFrame:function(t){return(window.requestAnimationFrame||window.webkitRequestAnimationFrame||window.mozRequestAnimationFrame||window.msRequestAnimationFrame||function(t){return setTimeout(t,16)})(t)},set:function(t,e,n){var r=t,i=ed(e)?e.split("."):e;return i.forEach((function(t,e){e<i.length-1?(Bl(r[t])||(r[t]=sd(i[e+1])?[]:{}),r=r[t]):r[t]=n})),t},size:function(t){return zl(t)?0:Rl(t)?t.length:Object.keys(t).length},some:function(t,e){for(var n=0;n<t.length;n++)if(e(t[n],n))return!0;return!1},sortBy:function(t,e){var n;if(jl(e))n=function(t,n){return e(t)-e(n)};else{var r=[];ed(e)?r.push(e):Fl(e)&&(r=e),n=function(t,e){for(var n=0;n<r.length;n+=1){var i=r[n];if(t[i]>e[i])return 1;if(t[i]<e[i])return-1}return 0}}return t.sort(n),t},startsWith:function(t,e){return!(!Fl(t)&&!ed(t))&&t[0]===e},substitute:function(t,e){return t&&e?t.replace(/\\?\{([^{}]+)\}/g,(function(t,n){return"\\"===t.charAt(0)?t.slice(1):void 0===e[n]?"":e[n]})):t},throttle:function(t,e,n){var r,i,o,a,s=0;n||(n={});var u=function(){s=!1===n.leading?0:Date.now(),r=null,a=t.apply(i,o),r||(i=o=null)},c=function(){var c=Date.now();s||!1!==n.leading||(s=c);var h=e-(c-s);return i=this,o=arguments,h<=0||h>e?(r&&(clearTimeout(r),r=null),s=c,a=t.apply(i,o),r||(i=o=null)):r||!1===n.trailing||(r=setTimeout(u,h)),a};return c.cancel=function(){clearTimeout(r),s=0,r=i=o=null},c},toArray:function(t){return Rl(t)?Array.prototype.slice.call(t):[]},toDegree:function(t){return cd*t},toInteger:hd,toRadian:function(t){return ld*t},toString:pd,union:function(){for(var t=[],e=0;e<arguments.length;e++)t[e]=arguments[e];return nd([].concat.apply([],t))},uniq:nd,uniqueId:function(t){return Cd[t=t||"g"]?Cd[t]+=1:Cd[t]=1,t+Cd[t]},upperCase:function(t){return pd(t).toUpperCase()},upperFirst:function(t){var e=pd(t);return e.charAt(0).toUpperCase()+e.substring(1)},values:fd,valuesOfKey:function(t,e){for(var n=[],r={},i=0;i<t.length;i++){var o=t[i][e];if(!zl(o)){Fl(o)||(o=[o]);for(var a=0;a<o.length;a++){var s=o[a];r[s]||(n.push(s),r[s]=!0)}}}return n},wrapBehavior:function(t,e){if(t["_wrap_"+e])return t["_wrap_"+e];var n=function(n){t[e](n)};return t["_wrap_"+e]=n,n}});var _d={assign:f(Rd).mix,getHeight:function(t,e,n,r){return void 0===r&&(r="height"),"center"===n?(t[r]+e[r])/2:t.height}},Dd=_d,Id={getId:function(t){return t.id||t.name},getPreH:function(t){return t.preH||0},getPreV:function(t){return t.preV||0},getHGap:function(t){return t.hgap||18},getVGap:function(t){return t.vgap||18},getChildren:function(t){return t.children},getHeight:function(t){return t.height||36},getWidth:function(t){var e=t.label||" ";return t.width||18*e.split("").length}};function Ld(t,e){var n=this;if(n.vgap=n.hgap=0,t instanceof Ld)return t;n.data=t;var r=e.getHGap(t),i=e.getVGap(t);return n.preH=e.getPreH(t),n.preV=e.getPreV(t),n.width=e.getWidth(t),n.height=e.getHeight(t),n.width+=n.preH,n.height+=n.preV,n.id=e.getId(t),n.x=n.y=0,n.depth=0,n.children||(n.children=[]),n.addGap(r,i),n}Dd.assign(Ld.prototype,{isRoot:function(){return 0===this.depth},isLeaf:function(){return 0===this.children.length},addGap:function(t,e){var n=this;n.hgap+=t,n.vgap+=e,n.width+=2*t,n.height+=2*e},eachNode:function(t){for(var e,n=[this];e=n.shift();)t(e),n=e.children.concat(n)},DFTraverse:function(t){this.eachNode(t)},BFTraverse:function(t){for(var e,n=[this];e=n.shift();)t(e),n=n.concat(e.children)},getBoundingBox:function(){var t={left:Number.MAX_VALUE,top:Number.MAX_VALUE,width:0,height:0};return this.eachNode((function(e){t.left=Math.min(t.left,e.x),t.top=Math.min(t.top,e.y),t.width=Math.max(t.width,e.x+e.width),t.height=Math.max(t.height,e.y+e.height)})),t},translate:function(t,e){void 0===t&&(t=0),void 0===e&&(e=0),this.eachNode((function(n){n.x+=t,n.y+=e,n.x+=n.preH,n.y+=n.preV}))},right2left:function(){var t=this,e=t.getBoundingBox();t.eachNode((function(t){t.x=t.x-2*(t.x-e.left)-t.width})),t.translate(e.width,0)},bottom2top:function(){var t=this,e=t.getBoundingBox();t.eachNode((function(t){t.y=t.y-2*(t.y-e.top)-t.height})),t.translate(0,e.height)}});var jd=function(t,e,n){void 0===e&&(e={});var r,i=new Ld(t,e=Dd.assign({},Id,e)),o=[i];if(!n&&!t.collapsed)for(;r=o.shift();)if(!r.data.collapsed){var a=e.getChildren(r.data),s=a?a.length:0;if(r.children=new Array(s),a&&s)for(var u=0;u<s;u++){var c=new Ld(a[u],e);r.children[u]=c,o.push(c),c.parent=r,c.depth=r.depth+1}}return i},zd=jd,Fd=function(){function t(t,e){void 0===e&&(e={});this.options=e,this.rootNode=zd(t,e)}return t.prototype.execute=function(){throw new Error("please override this method")},t}(),Bd=Fd;function Gd(t,e,n,r){void 0===r&&(r=[]);var i=this;i.w=t||0,i.h=e||0,i.y=n||0,i.x=0,i.c=r||[],i.cs=r.length,i.prelim=0,i.mod=0,i.shift=0,i.change=0,i.tl=null,i.tr=null,i.el=null,i.er=null,i.msel=0,i.mser=0}function Vd(t,e,n){n?t.y+=e:t.x+=e,t.children.forEach((function(t){Vd(t,e,n)}))}function Ud(t,e){var n=e?t.y:t.x;return t.children.forEach((function(t){n=Math.min(Ud(t,e),n)})),n}function Wd(t,e){Vd(t,-Ud(t,e),e)}function Hd(t,e,n){n?e.y=t.x:e.x=t.x,t.c.forEach((function(t,r){Hd(t,e.children[r],n)}))}function qd(t,e,n){void 0===n&&(n=0),e?(t.x=n,n+=t.width):(t.y=n,n+=t.height),t.children.forEach((function(t){qd(t,e,n)}))}Gd.fromNode=function(t,e){if(!t)return null;var n=[];return t.children.forEach((function(t){n.push(Gd.fromNode(t,e))})),e?new Gd(t.height,t.width,t.x,n):new Gd(t.width,t.height,t.y,n)};var Yd=jd,$d=function(t,e){for(var n=Yd(t.data,e,!0),r=Yd(t.data,e,!0),i=t.children.length,o=Math.round(i/2),a=e.getSide||function(t,e){return e<o?"right":"left"},s=0;s<i;s++){var u=t.children[s];"right"===a(u,s)?r.children.push(u):n.children.push(u)}return n.eachNode((function(t){t.isRoot()||(t.side="left")})),r.eachNode((function(t){t.isRoot()||(t.side="right")})),{left:n,right:r}},Xd=$d,Kd=["LR","RL","TB","BT","H","V"],Zd=["LR","RL","H"],Qd=Kd[0],Jd=function(t,e,n){var r=e.direction||Qd;if(e.isHorizontal=function(t){return Zd.indexOf(t)>-1}(r),r&&-1===Kd.indexOf(r))throw new TypeError("Invalid direction: "+r);if(r===Kd[0])n(t,e);else if(r===Kd[1])n(t,e),t.right2left();else if(r===Kd[2])n(t,e);else if(r===Kd[3])n(t,e),t.bottom2top();else if(r===Kd[4]||r===Kd[5]){var i=Xd(t,e),o=i.left,a=i.right;n(o,e),n(a,e),e.isHorizontal?o.right2left():o.bottom2top(),a.translate(o.x-a.x,o.y-a.y),t.x=o.x,t.y=a.y;var s=t.getBoundingBox();e.isHorizontal?s.top<0&&t.translate(0,-s.top):s.left<0&&t.translate(-s.left,0)}var u=e.fixedRoot;return void 0===u&&(u=!0),u&&t.translate(-(t.x+t.width/2+t.hgap),-(t.y+t.height/2+t.vgap)),t};function tf(t,e){return tf=Object.setPrototypeOf?Object.setPrototypeOf.bind():function(t,e){return t.__proto__=e,t},tf(t,e)}var ef=function(t,e){void 0===e&&(e={});var n=e.isHorizontal;function r(t){0===t.cs?(t.el=t,t.er=t,t.msel=t.mser=0):(t.el=t.c[0].el,t.msel=t.c[0].msel,t.er=t.c[t.cs-1].er,t.mser=t.c[t.cs-1].mser)}function i(t,e,n){for(var r=t.c[e-1],i=r.mod,c=t.c[e],h=c.mod;null!==r&&null!==c;){u(r)>n.low&&(n=n.nxt);var l=i+r.prelim+r.w-(h+c.prelim);l>0&&(h+=l,o(t,e,n.index,l));var d=u(r),f=u(c);d<=f&&null!==(r=s(r))&&(i+=r.mod),d>=f&&null!==(c=a(c))&&(h+=c.mod)}!r&&c?function(t,e,n,r){var i=t.c[0].el;i.tl=n;var o=r-n.mod-t.c[0].msel;i.mod+=o,i.prelim-=o,t.c[0].el=t.c[e].el,t.c[0].msel=t.c[e].msel}(t,e,c,h):r&&!c&&function(t,e,n,r){var i=t.c[e].er;i.tr=n;var o=r-n.mod-t.c[e].mser;i.mod+=o,i.prelim-=o,t.c[e].er=t.c[e-1].er,t.c[e].mser=t.c[e-1].mser}(t,e,r,i)}function o(t,e,n,r){t.c[e].mod+=r,t.c[e].msel+=r,t.c[e].mser+=r,function(t,e,n,r){if(n!==e-1){var i=e-n;t.c[n+1].shift+=r/i,t.c[e].shift-=r/i,t.c[e].change-=r-r/i}}(t,e,n,r)}function a(t){return 0===t.cs?t.tl:t.c[0]}function s(t){return 0===t.cs?t.tr:t.c[t.cs-1]}function u(t){return t.y+t.h}function c(t,e,n){for(;null!==n&&t>=n.low;)n=n.nxt;return{low:t,index:e,nxt:n}}qd(t,n);var h=Gd.fromNode(t,n);return function t(e){if(0!==e.cs){t(e.c[0]);for(var n=c(u(e.c[0].el),0,null),o=1;o<e.cs;++o){t(e.c[o]);var a=u(e.c[o].er);i(e,o,n),n=c(a,o,n)}!function(t){t.prelim=(t.c[0].prelim+t.c[0].mod+t.c[t.cs-1].mod+t.c[t.cs-1].prelim+t.c[t.cs-1].w)/2-t.w/2}(e),r(e)}else r(e)}(h),function t(e,n){n+=e.mod,e.x=e.prelim+n,function(t){for(var e=0,n=0,r=0;r<t.cs;r++)n+=(e+=t.c[r].shift)+t.c[r].change,t.c[r].mod+=n}(e);for(var r=0;r<e.cs;r++)t(e.c[r],n)}(h,0),Hd(h,t,n),Wd(t,n),t},nf=Jd,rf=_d,of=function(t){var e,n;function r(){return t.apply(this,arguments)||this}return n=t,(e=r).prototype=Object.create(n.prototype),e.prototype.constructor=e,tf(e,n),r.prototype.execute=function(){return nf(this.rootNode,this.options,ef)},r}(Bd),af={};var sf=function(t,e){return e=rf.assign({},af,e),new of(t,e).execute()},uf=_d;function cf(t,e){void 0===e&&(e=[]);var n=this;n.x=n.y=0,n.leftChild=n.rightChild=null,n.height=0,n.children=e}var hf={isHorizontal:!0,nodeSep:20,nodeSize:20,rankSep:200,subTreeSep:10};function lf(t,e,n){n?(e.x=t.x,e.y=t.y):(e.x=t.y,e.y=t.x),t.children.forEach((function(t,r){lf(t,e.children[r],n)}))}function df(t,e){return df=Object.setPrototypeOf?Object.setPrototypeOf.bind():function(t,e){return t.__proto__=e,t},df(t,e)}var ff=function(t,e){void 0===e&&(e={}),e=uf.assign({},hf,e);var n,r=0;var i=function t(e){if(!e)return null;e.width=0,e.depth&&e.depth>r&&(r=e.depth);var n=e.children,i=n.length,o=new cf(e.height,[]);return n.forEach((function(e,n){var r=t(e);o.children.push(r),0===n&&(o.leftChild=r),n===i-1&&(o.rightChild=r)})),o.originNode=e,o.isLeaf=e.isLeaf(),o}(t);return function t(e){if(e.isLeaf||0===e.children.length)e.drawingDepth=r;else{var n=e.children.map((function(e){return t(e)})),i=Math.min.apply(null,n);e.drawingDepth=i-1}return e.drawingDepth}(i),function t(r){r.x=r.drawingDepth*e.rankSep,r.isLeaf?(r.y=0,n&&(r.y=n.y+n.height+e.nodeSep,r.originNode.parent!==n.originNode.parent&&(r.y+=e.subTreeSep)),n=r):(r.children.forEach((function(e){t(e)})),r.y=(r.leftChild.y+r.rightChild.y)/2)}(i),lf(i,t,e.isHorizontal),t},pf=Jd,gf=_d,mf=function(t){var e,n;function r(){return t.apply(this,arguments)||this}return n=t,(e=r).prototype=Object.create(n.prototype),e.prototype.constructor=e,df(e,n),r.prototype.execute=function(){var t=this;return t.rootNode.width=0,pf(t.rootNode,t.options,ff)},r}(Bd),vf={};var yf=function(t,e){return e=gf.assign({},vf,e),new mf(t,e).execute()},bf=_d;function Ef(t,e){return Ef=Object.setPrototypeOf?Object.setPrototypeOf.bind():function(t,e){return t.__proto__=e,t},Ef(t,e)}var wf=Bd,xf=function(t,e,n,r){var i=null;t.eachNode((function(t){!function(t,e,n,r,i){var o="function"==typeof n?n(t):n*t.depth;if(!r)try{if(t.id===t.parent.children[0].id)return t.x+=o,void(t.y=e?e.y:0)}catch(t){}if(t.x+=o,e){if(t.y=e.y+bf.getHeight(e,t,i),e.parent&&t.parent.id!==e.parent.id){var a=e.parent,s=a.y+bf.getHeight(a,t,i);t.y=s>t.y?s:t.y}}else t.y=0}(t,i,e,n,r),i=t}))},Mf=$d,Nf=_d,Sf=["LR","RL","H"],Tf=Sf[0],kf=function(t){var e,n;function r(){return t.apply(this,arguments)||this}return n=t,(e=r).prototype=Object.create(n.prototype),e.prototype.constructor=e,Ef(e,n),r.prototype.execute=function(){var t=this.options,e=this.rootNode;t.isHorizontal=!0;var n=t.indent,r=void 0===n?20:n,i=t.dropCap,o=void 0===i||i,a=t.direction,s=void 0===a?Tf:a,u=t.align;if(s&&-1===Sf.indexOf(s))throw new TypeError("Invalid direction: "+s);if(s===Sf[0])xf(e,r,o,u);else if(s===Sf[1])xf(e,r,o,u),e.right2left();else if(s===Sf[2]){var c=Mf(e,t),h=c.left,l=c.right;xf(h,r,o,u),h.right2left(),xf(l,r,o,u);var d=h.getBoundingBox();l.translate(d.width,0),e.x=l.x-e.width/2}return e},r}(wf),Pf={};var Cf=function(t,e){return e=Nf.assign({},Pf,e),new kf(t,e).execute()},Af=_d;function Of(t,e){var n=0;return t.children.length?t.children.forEach((function(t){n+=Of(t,e)})):n=t.height,t._subTreeSep=e.getSubTreeSep(t.data),t.totalHeight=Math.max(t.height,n)+2*t._subTreeSep,t.totalHeight}function Rf(t){var e=t.children,n=e.length;if(n){e.forEach((function(t){Rf(t)}));var r=e[0],i=e[n-1],o=i.y-r.y+i.height,a=0;if(e.forEach((function(t){a+=t.totalHeight})),o>t.height)t.y=r.y+o/2-t.height/2;else if(1!==e.length||t.height>a){var s=t.y+(t.height-o)/2-r.y;e.forEach((function(t){t.translate(0,s)}))}else t.y=(r.y+r.height/2+i.y+i.height/2)/2-t.height/2}}var _f={getSubTreeSep:function(){return 0}};function Df(t,e){return Df=Object.setPrototypeOf?Object.setPrototypeOf.bind():function(t,e){return t.__proto__=e,t},Df(t,e)}var If=function(t,e){void 0===e&&(e={}),e=Af.assign({},_f,e),t.parent={x:0,width:0,height:0,y:0},t.BFTraverse((function(t){t.x=t.parent.x+t.parent.width})),t.parent=null,Of(t,e),t.startY=0,t.y=t.totalHeight/2-t.height/2,t.eachNode((function(t){var e=t.children,n=e.length;if(n){var r=e[0];if(r.startY=t.startY+t._subTreeSep,1===n)r.y=t.y+t.height/2-r.height/2;else{r.y=r.startY+r.totalHeight/2-r.height/2;for(var i=1;i<n;i++){var o=e[i];o.startY=e[i-1].startY+e[i-1].totalHeight,o.y=o.startY+o.totalHeight/2-o.height/2}}}})),Rf(t)},Lf=Jd,jf=_d,zf=function(t){var e,n;function r(){return t.apply(this,arguments)||this}return n=t,(e=r).prototype=Object.create(n.prototype),e.prototype.constructor=e,Df(e,n),r.prototype.execute=function(){return Lf(this.rootNode,this.options,If)},r}(Bd),Ff={};var Bf=function(t,e){return e=jf.assign({},Ff,e),new zf(t,e).execute()},Gf={compactBox:sf,dendrogram:yf,indented:Cf,mindmap:Bf},Vf=function(){function t(){this._events={}}return t.prototype.on=function(t,e,n){return this._events[t]||(this._events[t]=[]),this._events[t].push({callback:e,once:!!n}),this},t.prototype.once=function(t,e){return this.on(t,e,!0)},t.prototype.emit=function(t){for(var e=this,n=[],r=1;r<arguments.length;r++)n[r-1]=arguments[r];var i=this._events[t]||[],o=this._events["*"]||[],a=function(r){for(var i=r.length,o=0;o<i;o++)if(r[o]){var a=r[o],s=a.callback;a.once&&(r.splice(o,1),0===r.length&&delete e._events[t],i--,o--),s.apply(e,n)}};a(i),a(o)},t.prototype.off=function(t,e){if(t)if(e){for(var n=this._events[t]||[],r=n.length,i=0;i<r;i++)n[i].callback===e&&(n.splice(i,1),r--,i--);0===n.length&&delete this._events[t]}else delete this._events[t];else this._events={};return this},t.prototype.getEvents=function(){return this._events},t}();function Uf(t,e,n,r){for(;t.length;){const i=t.shift();if(n(i))return!0;e.add(i.id),r(i.id).forEach((n=>{e.has(n.id)||(e.add(n.id),t.push(n))}))}return!1}function Wf(t,e,n,r){if(n(t))return!0;e.add(t.id);for(const i of r(t.id))if(!e.has(i.id)&&Wf(i,e,n,r))return!0;return!1}const Hf=()=>!0;class qf{graph;nodeFilter;edgeFilter;cacheEnabled;inEdgesMap=new Map;outEdgesMap=new Map;bothEdgesMap=new Map;allNodesMap=new Map;allEdgesMap=new Map;constructor(t){this.graph=t.graph;const e=t.nodeFilter||Hf,n=t.edgeFilter||Hf;this.nodeFilter=e,this.edgeFilter=t=>{const{source:r,target:i}=this.graph.getEdgeDetail(t.id);return!(!e(r)||!e(i))&&n(t,r,i)},"auto"===t.cache?(this.cacheEnabled=!0,this.startAutoCache()):"manual"===t.cache?this.cacheEnabled=!0:this.cacheEnabled=!1}clearCache=()=>{this.inEdgesMap.clear(),this.outEdgesMap.clear(),this.bothEdgesMap.clear(),this.allNodesMap.clear(),this.allEdgesMap.clear()};refreshCache=()=>{this.clearCache(),this.updateCache(this.graph.getAllNodes().map((t=>t.id)))};updateCache=t=>{const e=new Set;t.forEach((t=>{const n=this.bothEdgesMap.get(t);if(n&&n.forEach((t=>e.add(t.id))),this.hasNode(t)){const n=this.graph.getRelatedEdges(t,"in").filter(this.edgeFilter),r=this.graph.getRelatedEdges(t,"out").filter(this.edgeFilter),i=Array.from(new Set([...n,...r]));i.forEach((t=>e.add(t.id))),this.inEdgesMap.set(t,n),this.outEdgesMap.set(t,r),this.bothEdgesMap.set(t,i),this.allNodesMap.set(t,this.graph.getNode(t))}else this.inEdgesMap.delete(t),this.outEdgesMap.delete(t),this.bothEdgesMap.delete(t),this.allNodesMap.delete(t)})),e.forEach((t=>{this.hasEdge(t)?this.allEdgesMap.set(t,this.graph.getEdge(t)):this.allEdgesMap.delete(t)}))};startAutoCache(){this.refreshCache(),this.graph.on("changed",this.handleGraphChanged)}stopAutoCache(){this.graph.off("changed",this.handleGraphChanged)}handleGraphChanged=t=>{const e=new Set;t.changes.forEach((n=>{switch(n.type){case"NodeAdded":case"NodeRemoved":e.add(n.value.id);break;case"NodeDataUpdated":e.add(n.id);break;case"EdgeAdded":case"EdgeRemoved":e.add(n.value.source),e.add(n.value.target);break;case"EdgeUpdated":"source"!==n.propertyName&&"target"!==n.propertyName||(e.add(n.oldValue),e.add(n.newValue));break;case"EdgeDataUpdated":if(t.graph.hasEdge(n.id)){const r=t.graph.getEdge(n.id);e.add(r.source),e.add(r.target)}}})),this.updateCache(e)};checkNodeExistence(t){this.getNode(t)}hasNode(t){if(!this.graph.hasNode(t))return!1;const e=this.graph.getNode(t);return this.nodeFilter(e)}areNeighbors(t,e){return this.checkNodeExistence(t),this.getNeighbors(e).some((e=>e.id===t))}getNode(t){const e=this.graph.getNode(t);if(!this.nodeFilter(e))throw new Error("Node not found for id: "+t);return e}getRelatedEdges(t,e){if(this.checkNodeExistence(t),this.cacheEnabled)return"in"===e?this.inEdgesMap.get(t):"out"===e?this.outEdgesMap.get(t):this.bothEdgesMap.get(t);return this.graph.getRelatedEdges(t,e).filter(this.edgeFilter)}getDegree(t,e){return this.getRelatedEdges(t,e).length}getSuccessors(t){const e=this.getRelatedEdges(t,"out").map((t=>this.getNode(t.target)));return Array.from(new Set(e))}getPredecessors(t){const e=this.getRelatedEdges(t,"in").map((t=>this.getNode(t.source)));return Array.from(new Set(e))}getNeighbors(t){const e=this.getPredecessors(t),n=this.getSuccessors(t);return Array.from(new Set([...e,...n]))}hasEdge(t){if(!this.graph.hasEdge(t))return!1;const e=this.graph.getEdge(t);return this.edgeFilter(e)}getEdge(t){const e=this.graph.getEdge(t);if(!this.edgeFilter(e))throw new Error("Edge not found for id: "+t);return e}getEdgeDetail(t){const e=this.getEdge(t);return{edge:e,source:this.getNode(e.source),target:this.getNode(e.target)}}hasTreeStructure(t){return this.graph.hasTreeStructure(t)}getRoots(t){return this.graph.getRoots(t).filter(this.nodeFilter)}getChildren(t,e){return this.checkNodeExistence(t),this.graph.getChildren(t,e).filter(this.nodeFilter)}getParent(t,e){this.checkNodeExistence(t);const n=this.graph.getParent(t,e);return n&&this.nodeFilter(n)?n:null}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(t,e,n="out"){const r={in:this.getPredecessors.bind(this),out:this.getSuccessors.bind(this),both:this.getNeighbors.bind(this)}[n];Uf([this.getNode(t)],new Set,e,r)}dfs(t,e,n="out"){const r={in:this.getPredecessors.bind(this),out:this.getSuccessors.bind(this),both:this.getNeighbors.bind(this)}[n];Wf(this.getNode(t),new Set,e,r)}}let Yf=class t extends Vf{nodeMap=new Map;edgeMap=new Map;inEdgesMap=new Map;outEdgesMap=new Map;bothEdgesMap=new Map;treeIndices=new Map;changes=[];batchCount=0;onChanged=()=>{};constructor(t){super(),t&&(t.nodes&&this.addNodes(t.nodes),t.edges&&this.addEdges(t.edges),t.tree&&this.addTree(t.tree),t.onChanged&&(this.onChanged=t.onChanged))}batch=t=>{this.batchCount+=1,t(),this.batchCount-=1,this.batchCount||this.commit()};commit(){const t=this.changes;this.changes=[];const e={graph:this,changes:t};this.emit("changed",e),this.onChanged(e)}reduceChanges(t){let e=[];return t.forEach((t=>{switch(t.type){case"NodeRemoved":{let n=!1;e=e.filter((e=>{if("NodeAdded"===e.type){const r=e.value.id===t.value.id;return r&&(n=!0),!r}return"NodeDataUpdated"===e.type?e.id!==t.value.id:"TreeStructureChanged"!==e.type||e.nodeId!==t.value.id})),n||e.push(t);break}case"EdgeRemoved":{let n=!1;e=e.filter((e=>{if("EdgeAdded"===e.type){const r=e.value.id===t.value.id;return r&&(n=!0),!r}return"EdgeDataUpdated"!==e.type&&"EdgeUpdated"!==e.type||e.id!==t.value.id})),n||e.push(t);break}case"NodeDataUpdated":case"EdgeDataUpdated":case"EdgeUpdated":{const n=e.findIndex((e=>e.type===t.type&&e.id===t.id&&(void 0===t.propertyName||e.propertyName===t.propertyName))),r=e[n];r?void 0!==t.propertyName?r.newValue=t.newValue:(e.splice(n,1),e.push(t)):e.push(t);break}case"TreeStructureDetached":e=e.filter((e=>"TreeStructureAttached"===e.type?e.treeKey!==t.treeKey:"TreeStructureChanged"!==e.type||e.treeKey!==t.treeKey)),e.push(t);break;case"TreeStructureChanged":{const n=e.find((e=>"TreeStructureChanged"===e.type&&e.treeKey===t.treeKey&&e.nodeId===t.nodeId));n?n.newParentId=t.newParentId:e.push(t);break}default:e.push(t)}})),e}checkNodeExistence(t){this.getNode(t)}hasNode(t){return this.nodeMap.has(t)}areNeighbors(t,e){return this.getNeighbors(e).some((e=>e.id===t))}getNode(t){const e=this.nodeMap.get(t);if(!e)throw new Error("Node not found for id: "+t);return e}getRelatedEdges(t,e){if(this.checkNodeExistence(t),"in"===e){const e=this.inEdgesMap.get(t);return Array.from(e)}if("out"===e){const e=this.outEdgesMap.get(t);return Array.from(e)}{const e=this.bothEdgesMap.get(t);return Array.from(e)}}getDegree(t,e){return this.getRelatedEdges(t,e).length}getSuccessors(t){const e=this.getRelatedEdges(t,"out").map((t=>this.getNode(t.target)));return Array.from(new Set(e))}getPredecessors(t){const e=this.getRelatedEdges(t,"in").map((t=>this.getNode(t.source)));return Array.from(new Set(e))}getNeighbors(t){const e=this.getPredecessors(t),n=this.getSuccessors(t);return Array.from(new Set([...e,...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((e=>{e.childrenMap.set(t.id,new Set)})),this.changes.push({type:"NodeAdded",value:t})}addNodes(t){this.batch((()=>{for(const e of t)this.doAddNode(e)}))}addNode(t){this.addNodes([t])}doRemoveNode(t){const e=this.getNode(t),n=this.bothEdgesMap.get(t);n?.forEach((t=>this.doRemoveEdge(t.id))),this.nodeMap.delete(t),this.treeIndices.forEach((e=>{e.childrenMap.get(t)?.forEach((t=>{e.parentMap.delete(t.id)})),e.parentMap.delete(t),e.childrenMap.delete(t)})),this.changes.push({type:"NodeRemoved",value:e})}removeNodes(t){this.batch((()=>{t.forEach((t=>this.doRemoveNode(t)))}))}removeNode(t){this.removeNodes([t])}updateNodeDataProperty(t,e,n){const r=this.getNode(t);this.batch((()=>{const i=r.data[e],o=n;r.data[e]=o,this.changes.push({type:"NodeDataUpdated",id:t,propertyName:e,oldValue:i,newValue:o})}))}mergeNodeData(t,e){this.batch((()=>{Object.entries(e).forEach((([e,n])=>{this.updateNodeDataProperty(t,e,n)}))}))}updateNodeData(...t){const e=t[0],n=this.getNode(e);if("string"==typeof t[1])return void this.updateNodeDataProperty(e,t[1],t[2]);let r;if("function"==typeof t[1]){const e=t[1];r=e(n.data)}else"object"==typeof t[1]&&(r=t[1]);this.batch((()=>{const t=n.data,i=r;n.data=r,this.changes.push({type:"NodeDataUpdated",id:e,oldValue:t,newValue:i})}))}checkEdgeExistence(t){if(!this.hasEdge(t))throw new Error("Edge not found for id: "+t)}hasEdge(t){return this.edgeMap.has(t)}getEdge(t){return this.checkEdgeExistence(t),this.edgeMap.get(t)}getEdgeDetail(t){const e=this.getEdge(t);return{edge:e,source:this.getNode(e.source),target:this.getNode(e.target)}}doAddEdge(t){if(this.hasEdge(t.id))throw new Error("Edge already exists: "+t.id);this.checkNodeExistence(t.source),this.checkNodeExistence(t.target),this.edgeMap.set(t.id,t);const e=this.inEdgesMap.get(t.target),n=this.outEdgesMap.get(t.source),r=this.bothEdgesMap.get(t.source),i=this.bothEdgesMap.get(t.target);e.add(t),n.add(t),r.add(t),i.add(t),this.changes.push({type:"EdgeAdded",value:t})}addEdges(t){this.batch((()=>{for(const e of t)this.doAddEdge(e)}))}addEdge(t){this.addEdges([t])}doRemoveEdge(t){const e=this.getEdge(t),n=this.outEdgesMap.get(e.source),r=this.inEdgesMap.get(e.target),i=this.bothEdgesMap.get(e.source),o=this.bothEdgesMap.get(e.target);n.delete(e),r.delete(e),i.delete(e),o.delete(e),this.edgeMap.delete(t),this.changes.push({type:"EdgeRemoved",value:e})}removeEdges(t){this.batch((()=>{t.forEach((t=>this.doRemoveEdge(t)))}))}removeEdge(t){this.removeEdges([t])}updateEdgeSource(t,e){const n=this.getEdge(t);this.checkNodeExistence(e);const r=n.source,i=e;this.outEdgesMap.get(r).delete(n),this.bothEdgesMap.get(r).delete(n),this.outEdgesMap.get(i).add(n),this.bothEdgesMap.get(i).add(n),n.source=e,this.batch((()=>{this.changes.push({type:"EdgeUpdated",id:t,propertyName:"source",oldValue:r,newValue:i})}))}updateEdgeTarget(t,e){const n=this.getEdge(t);this.checkNodeExistence(e);const r=n.target,i=e;this.inEdgesMap.get(r).delete(n),this.bothEdgesMap.get(r).delete(n),this.inEdgesMap.get(i).add(n),this.bothEdgesMap.get(i).add(n),n.target=e,this.batch((()=>{this.changes.push({type:"EdgeUpdated",id:t,propertyName:"target",oldValue:r,newValue:i})}))}updateEdgeDataProperty(t,e,n){const r=this.getEdge(t);this.batch((()=>{const i=r.data[e],o=n;r.data[e]=o,this.changes.push({type:"EdgeDataUpdated",id:t,propertyName:e,oldValue:i,newValue:o})}))}updateEdgeData(...t){const e=t[0],n=this.getEdge(e);if("string"==typeof t[1])return void this.updateEdgeDataProperty(e,t[1],t[2]);let r;if("function"==typeof t[1]){const e=t[1];r=e(n.data)}else"object"==typeof t[1]&&(r=t[1]);this.batch((()=>{const t=n.data,i=r;n.data=r,this.changes.push({type:"EdgeDataUpdated",id:e,oldValue:t,newValue:i})}))}mergeEdgeData(t,e){this.batch((()=>{Object.entries(e).forEach((([e,n])=>{this.updateEdgeDataProperty(t,e,n)}))}))}checkTreeExistence(t){if(!this.hasTreeStructure(t))throw new Error("Tree structure not found for treeKey: "+t)}hasTreeStructure(t){return this.treeIndices.has(t)}attachTreeStructure(t){this.treeIndices.has(t)||(this.treeIndices.set(t,{parentMap:new Map,childrenMap:new Map}),this.batch((()=>{this.changes.push({type:"TreeStructureAttached",treeKey:t})})))}detachTreeStructure(t){this.checkTreeExistence(t),this.treeIndices.delete(t),this.batch((()=>{this.changes.push({type:"TreeStructureDetached",treeKey:t})}))}addTree(t,e){this.batch((()=>{this.attachTreeStructure(e);const n=[],r=Array.isArray(t)?t:[t];for(;r.length;){const t=r.shift();n.push(t),t.children&&r.push(...t.children)}this.addNodes(n),n.forEach((t=>{t.children?.forEach((n=>{this.setParent(n.id,t.id,e)}))}))}))}getRoots(t){return this.checkTreeExistence(t),this.getAllNodes().filter((e=>!this.getParent(e.id,t)))}getChildren(t,e){this.checkNodeExistence(t),this.checkTreeExistence(e);const n=this.treeIndices.get(e).childrenMap.get(t);return Array.from(n||[])}getParent(t,e){this.checkNodeExistence(t),this.checkTreeExistence(e);return this.treeIndices.get(e).parentMap.get(t)||null}getAncestors(t,e){const n=[];let r,i=this.getNode(t);for(;r=this.getParent(i.id,e);)n.push(r),i=r;return n}setParent(t,e,n){this.checkTreeExistence(n);const r=this.treeIndices.get(n),i=this.getNode(t),o=r.parentMap.get(t);if(o?.id===e)return;if(void 0===e)return o&&r.childrenMap.get(o.id)?.delete(i),void r.parentMap.delete(t);const a=this.getNode(e);r.parentMap.set(t,a),o&&r.childrenMap.get(o.id)?.delete(i);let s=r.childrenMap.get(a.id);s||(s=new Set,r.childrenMap.set(a.id,s)),s.add(i),this.batch((()=>{this.changes.push({type:"TreeStructureChanged",treeKey:n,nodeId:t,oldParentId:o?.id,newParentId:a.id})}))}dfsTree(t,e,n){return Wf(this.getNode(t),new Set,e,(t=>this.getChildren(t,n)))}bfsTree(t,e,n){return Uf([this.getNode(t)],new Set,e,(t=>this.getChildren(t,n)))}getAllNodes(){return Array.from(this.nodeMap.values())}getAllEdges(){return Array.from(this.edgeMap.values())}bfs(t,e,n="out"){const r={in:this.getPredecessors.bind(this),out:this.getSuccessors.bind(this),both:this.getNeighbors.bind(this)}[n];return Uf([this.getNode(t)],new Set,e,r)}dfs(t,e,n="out"){const r={in:this.getPredecessors.bind(this),out:this.getSuccessors.bind(this),both:this.getNeighbors.bind(this)}[n];return Wf(this.getNode(t),new Set,e,r)}clone(){const e=this.getAllNodes().map((t=>({...t,data:{...t.data}}))),n=this.getAllEdges().map((t=>({...t,data:{...t.data}}))),r=new t({nodes:e,edges:n});return this.treeIndices.forEach((({parentMap:t,childrenMap:e},n)=>{const i=new Map;t.forEach(((t,e)=>{i.set(e,r.getNode(t.id))}));const o=new Map;e.forEach(((t,e)=>{o.set(e,new Set(Array.from(t).map((t=>r.getNode(t.id)))))})),r.treeIndices.set(n,{parentMap:i,childrenMap:o})})),r}toJSON(){return JSON.stringify({nodes:this.getAllNodes(),edges:this.getAllEdges()})}createView(t){return new qf({graph:this,...t})}};const $f=(t,e)=>{if("next"!==t&&"prev"!==t)return e},Xf=t=>{t.prev.next=t.next,t.next.prev=t.prev,delete t.next,delete t.prev};let Kf=class{constructor(){const t={};t.prev=t,t.next=t.prev,this.shortcut=t}dequeue(){const t=this.shortcut,e=t.prev;if(e&&e!==t)return Xf(e),e}enqueue(t){const e=this.shortcut;t.prev&&t.next&&Xf(t),t.next=e.next,e.next.prev=t,e.next=t,t.prev=e}toString(){const t=[],e=this.shortcut;let n=e.prev;for(;n!==e;)t.push(JSON.stringify(n,$f)),n=null==n?void 0:n.prev;return`[${t.join(", ")}]`}},Zf=class extends Kf{};const Qf=()=>1,Jf=(t,e,n)=>{let r=[];const i=e[e.length-1],o=e[0];let a;for(;t.getAllNodes().length;){for(;a=o.dequeue();)tp(t,e,n,a);for(;a=i.dequeue();)tp(t,e,n,a);if(t.getAllNodes().length)for(let i=e.length-2;i>0;--i)if(a=e[i].dequeue(),a){r=r.concat(tp(t,e,n,a,!0));break}}return r},tp=(t,e,n,r,i)=>{var o,a;const s=[];return t.hasNode(r.v)&&(null===(o=t.getRelatedEdges(r.v,"in"))||void 0===o||o.forEach((r=>{const o=r.data.weight,a=t.getNode(r.source);i&&s.push({v:r.source,w:r.target,in:0,out:0}),void 0===a.data.out&&(a.data.out=0),a.data.out-=o,np(e,n,Object.assign({v:a.id},a.data))})),null===(a=t.getRelatedEdges(r.v,"out"))||void 0===a||a.forEach((r=>{const i=r.data.weight,o=r.target,a=t.getNode(o);void 0===a.data.in&&(a.data.in=0),a.data.in-=i,np(e,n,Object.assign({v:a.id},a.data))})),t.removeNode(r.v)),i?s:void 0},ep=(t,e)=>{const n=new Yf;let r=0,i=0;t.getAllNodes().forEach((t=>{n.addNode({id:t.id,data:{v:t.id,in:0,out:0}})})),t.getAllEdges().forEach((t=>{const o=n.getRelatedEdges(t.source,"out").find((e=>e.target===t.target)),a=(null==e?void 0:e(t))||1;o?n.updateEdgeData(null==o?void 0:o.id,Object.assign(Object.assign({},o.data),{weight:o.data.weight+a})):n.addEdge({id:t.id,source:t.source,target:t.target,data:{weight:a}}),i=Math.max(i,n.getNode(t.source).data.out+=a),r=Math.max(r,n.getNode(t.target).data.in+=a)}));const o=[],a=i+r+3;for(let t=0;t<a;t++)o.push(new Zf);const s=r+1;return n.getAllNodes().forEach((t=>{np(o,s,Object.assign({v:t.id},n.getNode(t.id).data))})),{buckets:o,zeroIdx:s,graph:n}},np=(t,e,n)=>{n.out?n.in?t[n.out-n.in+e].enqueue(n):t[t.length-1].enqueue(n):t[0].enqueue(n)},rp=(t,e)=>{const n="greedy"===e?((t,e)=>{var n;if(t.getAllNodes().length<=1)return[];const r=ep(t,e||Qf);return null===(n=Jf(r.graph,r.buckets,r.zeroIdx).map((e=>t.getRelatedEdges(e.v,"out").filter((({target:t})=>t===e.w)))))||void 0===n?void 0:n.flat()})(t,(t=>t.data.weight||1)):ip(t);null==n||n.forEach((e=>{const n=e.data;t.removeEdge(e.id),n.forwardName=e.data.name,n.reversed=!0,t.addEdge({id:e.id,source:e.target,target:e.source,data:Object.assign({},n)})}))},ip=t=>{const e=[],n={},r={},i=o=>{r[o]||(r[o]=!0,n[o]=!0,t.getRelatedEdges(o,"out").forEach((t=>{n[t.target]?e.push(t):i(t.target)})),delete n[o])};return t.getAllNodes().forEach((t=>i(t.id))),e},op=(t,e,n,r)=>{let i;do{i=`${r}${Math.random()}`}while(t.hasNode(i));return n.dummy=e,t.addNode({id:i,data:n}),i},ap=t=>{const e=new Yf;return t.getAllNodes().forEach((n=>{t.getChildren(n.id).length||e.addNode(Object.assign({},n))})),t.getAllEdges().forEach((t=>{e.addEdge(t)})),e},sp=(t,e)=>{const n=Number(t.x),r=Number(t.y),i=Number(e.x)-n,o=Number(e.y)-r;let a,s,u=Number(t.width)/2,c=Number(t.height)/2;return i||o?(Math.abs(o)*u>Math.abs(i)*c?(o<0&&(c=-c),a=c*i/o,s=c):(i<0&&(u=-u),a=u,s=u*o/i),{x:n+a,y:r+s}):{x:0,y:0}},up=t=>{const e=[],n=hp(t)+1;for(let t=0;t<n;t++)e.push([]);t.getAllNodes().forEach((t=>{const n=t.data.rank;void 0!==n&&e[n]&&e[n].push(t.id)}));for(let r=0;r<n;r++)e[r]=e[r].sort(((e,n)=>{return r=t.getNode(e).data.order,i=t.getNode(n).data.order,Number(r)-Number(i);var r,i}));return e},cp=(t,e,n,r)=>{const i={width:0,height:0};return Vt(n)&&Vt(r)&&(i.rank=n,i.order=r),op(t,"border",i,e)},hp=t=>{let e;return t.getAllNodes().forEach((t=>{const n=t.data.rank;void 0!==n&&(void 0===e||n>e)&&(e=n)})),e||(e=0),e},lp=(t,e)=>t.reduce(((t,n)=>e(t)>e(n)?n:t)),dp=(t,e,n,r,i,o)=>{r.includes(e.id)||(r.push(e.id),n||o.push(e.id),i(e.id).forEach((e=>dp(t,e,n,r,i,o))),n&&o.push(e.id))},fp=(t,e,n,r)=>{const i=Array.isArray(e)?e:[e],o=e=>r?t.getSuccessors(e):t.getNeighbors(e),a=[],s=[];return i.forEach((e=>{if(!t.hasNode(e.id))throw new Error(`Graph does not have node: ${e}`);dp(t,e,"post"===n,s,o,a)})),a},pp=(t,e,n,r,i,o)=>{const a={rank:o,borderType:e,width:0,height:0},s=i.data[e][o-1],u=op(t,"border",a,n);i.data[e][o]=u,t.setParent(u,r),s&&t.addEdge({id:`e${Math.random()}`,source:s,target:u,data:{weight:1}})},gp=t=>{t.getAllNodes().forEach((t=>{mp(t)})),t.getAllEdges().forEach((t=>{mp(t)}))},mp=t=>{const e=t.data.width;t.data.width=t.data.height,t.data.height=e},vp=t=>{t.getAllNodes().forEach((t=>{yp(t.data)})),t.getAllEdges().forEach((t=>{var e;null===(e=t.data.points)||void 0===e||e.forEach((t=>yp(t))),t.data.hasOwnProperty("y")&&yp(t.data)}))},yp=t=>{(null==t?void 0:t.y)&&(t.y=-t.y)},bp=t=>{t.getAllNodes().forEach((t=>{Ep(t.data)})),t.getAllEdges().forEach((t=>{var e;null===(e=t.data.points)||void 0===e||e.forEach((t=>Ep(t))),t.data.hasOwnProperty("x")&&Ep(t.data)}))},Ep=t=>{const e=t.x;t.x=t.y,t.y=e},wp=(t,e,n,r,i,o,a)=>{const s=t.getChildren(a);if(!(null==s?void 0:s.length))return void(a!==e&&t.addEdge({id:`e${Math.random()}`,source:e,target:a,data:{weight:0,minlen:n}}));const u=cp(t,"_bt"),c=cp(t,"_bb"),h=t.getNode(a);t.setParent(u,a),h.data.borderTop=u,t.setParent(c,a),h.data.borderBottom=c,null==s||s.forEach((s=>{wp(t,e,n,r,i,o,s.id);const h=s.data.borderTop?s.data.borderTop:s.id,l=s.data.borderBottom?s.data.borderBottom:s.id,d=s.data.borderTop?r:2*r,f=h!==l?1:i-o[a]+1;t.addEdge({id:`e${Math.random()}`,source:u,target:h,data:{minlen:f,weight:d,nestingEdge:!0}}),t.addEdge({id:`e${Math.random()}`,source:l,target:c,data:{minlen:f,weight:d,nestingEdge:!0}})})),t.getParent(a)||t.addEdge({id:`e${Math.random()}`,source:e,target:u,data:{weight:0,minlen:i+o[a]}})},xp=t=>{const e={},n=(r,i)=>{const o=t.getChildren(r);null==o||o.forEach((t=>n(t.id,i+1))),e[r]=i};return t.getRoots().forEach((t=>n(t.id,1))),e},Mp=t=>{let e=0;return t.getAllEdges().forEach((t=>{e+=t.data.weight})),e},Np="edge-label",Sp=(t,e,n)=>{let r=e.source,i=t.getNode(r).data.rank;const o=e.target,a=t.getNode(o).data.rank,s=e.data.labelRank;if(a===i+1)return;let u,c,h;for(t.removeEdge(e.id),h=0,++i;i<a;++h,++i)e.data.points=[],c={originalEdge:e,width:0,height:0,rank:i},u=op(t,"edge",c,"_d"),i===s&&(c.width=e.data.width,c.height=e.data.height,c.dummy=Np,c.labelpos=e.data.labelpos),t.addEdge({id:`e${Math.random()}`,source:r,target:u,data:{weight:e.data.weight}}),0===h&&n.push(u),r=u;t.addEdge({id:`e${Math.random()}`,source:r,target:o,data:{weight:e.data.weight}})},Tp=t=>{let e;for(;t.hasNode(e=`_root${Math.random()}`););return e},kp=(t,e,n)=>{const r=((t,e)=>null==t?void 0:t.reduce(((t,n,r)=>(t[n]=e[r],t)),{}))(n,n.map(((t,e)=>e))),i=e.map((e=>{const n=t.getRelatedEdges(e,"out").map((t=>({pos:r[t.target]||0,weight:t.data.weight})));return null==n?void 0:n.sort(((t,e)=>t.pos-e.pos))})),o=i.flat().filter((t=>void 0!==t));let a=1;for(;a<n.length;)a<<=1;const s=2*a-1;a-=1;const u=Array(s).fill(0,0,s);let c=0;return null==o||o.forEach((t=>{if(t){let e=t.pos+a;u[e]+=t.weight;let n=0;for(;e>0;)e%2&&(n+=u[e+1]),e=e-1>>1,u[e]+=t.weight;c+=t.weight*n}})),c},Pp=(t,e)=>{let n=0;for(let r=1;r<(null==e?void 0:e.length);r+=1)n+=kp(t,e[r-1],e[r]);return n},Cp=t=>{const e={},n=t.getAllNodes(),r=n.map((t=>{var e;return null!==(e=t.data.rank)&&void 0!==e?e:-1/0})),i=Math.max(...r),o=[];for(let t=0;t<i+1;t++)o.push([]);const a=n.sort(((e,n)=>t.getNode(e.id).data.rank-t.getNode(n.id).data.rank)),s=a.filter((e=>void 0!==t.getNode(e.id).data.fixorder)).sort(((e,n)=>t.getNode(e.id).data.fixorder-t.getNode(n.id).data.fixorder));return null==s||s.forEach((n=>{isNaN(t.getNode(n.id).data.rank)||o[t.getNode(n.id).data.rank].push(n.id),e[n.id]=!0})),null==a||a.forEach((n=>t.dfsTree(n.id,(t=>{if(e.hasOwnProperty(t.id))return!0;e[t.id]=!0,isNaN(t.data.rank)||o[t.data.rank].push(t.id)})))),o},Ap=t=>{var e,n;const r=[];for(;null==t?void 0:t.length;){const i=t.pop();r.push(i),null===(e=i.in.reverse())||void 0===e||e.forEach((t=>{return(e=i,t=>{t.merged||(void 0===t.barycenter||void 0===e.barycenter||t.barycenter>=e.barycenter)&&Op(e,t)})(t);var e})),null===(n=i.out)||void 0===n||n.forEach((e=>{return(n=i,e=>{e.in.push(n),0==--e.indegree&&t.push(e)})(e);var n}))}const i=r.filter((t=>!t.merged)),o=["vs","i","barycenter","weight"];return i.map((t=>{const e={};return null==o||o.forEach((n=>{void 0!==t[n]&&(e[n]=t[n])})),e}))},Op=(t,e)=>{var n;let r=0,i=0;t.weight&&(r+=t.barycenter*t.weight,i+=t.weight),e.weight&&(r+=e.barycenter*e.weight,i+=e.weight),t.vs=null===(n=e.vs)||void 0===n?void 0:n.concat(t.vs),t.barycenter=r/i,t.weight=i,t.i=Math.min(e.i,t.i),e.merged=!0},Rp=(t,e,n)=>{let r,i=n;for(;e.length&&(r=e[e.length-1]).i<=i;)e.pop(),null==t||t.push(r.vs),i++;return i},_p=(t,e)=>(n,r)=>{if(void 0!==n.fixorder&&void 0!==r.fixorder)return n.fixorder-r.fixorder;if(n.barycenter<r.barycenter)return-1;if(n.barycenter>r.barycenter)return 1;if(e&&void 0!==n.order&&void 0!==r.order){if(n.order<r.order)return-1;if(n.order>r.order)return 1}return t?r.i-n.i:n.i-r.i},Dp=(t,e,n,r,i,o)=>{var a,s,u,c;let h=t.getChildren(e).map((t=>t.id));const l=t.getNode(e),d=l?l.data.borderLeft:void 0,f=l?l.data.borderRight:void 0,p={};d&&(h=null==h?void 0:h.filter((t=>t!==d&&t!==f)));const g=((t,e)=>e.map((e=>{const n=t.getRelatedEdges(e,"in");if(!(null==n?void 0:n.length))return{v:e};const r={sum:0,weight:0};return null==n||n.forEach((e=>{const n=t.getNode(e.source);r.sum+=e.data.weight*n.data.order,r.weight+=e.data.weight})),{v:e,barycenter:r.sum/r.weight,weight:r.weight}})))(t,h||[]);null==g||g.forEach((e=>{var i;if(null===(i=t.getChildren(e.v))||void 0===i?void 0:i.length){const i=Dp(t,e.v,n,r,o);p[e.v]=i,i.hasOwnProperty("barycenter")&&Lp(e,i)}}));const m=((t,e)=>{var n,r,i;const o={};null==t||t.forEach(((t,e)=>{o[t.v]={i:e,indegree:0,in:[],out:[],vs:[t.v]};const n=o[t.v];void 0!==t.barycenter&&(n.barycenter=t.barycenter,n.weight=t.weight)})),null===(n=e.getAllEdges())||void 0===n||n.forEach((t=>{const e=o[t.source],n=o[t.target];void 0!==e&&void 0!==n&&(n.indegree++,e.out.push(o[t.target]))}));const a=null===(i=(r=Object.values(o)).filter)||void 0===i?void 0:i.call(r,(t=>!t.indegree));return Ap(a)})(g,n);Ip(m,p),null===(a=m.filter((t=>t.vs.length>0)))||void 0===a||a.forEach((e=>{const n=t.getNode(e.vs[0]);n&&(e.fixorder=n.data.fixorder,e.order=n.data.order)}));const v=((t,e,n,r)=>{const i=((t,e)=>{const n={lhs:[],rhs:[]};return null==t||t.forEach((t=>{e(t)?n.lhs.push(t):n.rhs.push(t)})),n})(t,(t=>{const e=t.hasOwnProperty("fixorder")&&!isNaN(t.fixorder);return r?!e&&t.hasOwnProperty("barycenter"):e||t.hasOwnProperty("barycenter")})),o=i.lhs,a=i.rhs.sort(((t,e)=>-t.i- -e.i)),s=[];let u=0,c=0,h=0;null==o||o.sort(_p(!!e,!!n)),h=Rp(s,a,h),null==o||o.forEach((t=>{var e;h+=null===(e=t.vs)||void 0===e?void 0:e.length,s.push(t.vs),u+=t.barycenter*t.weight,c+=t.weight,h=Rp(s,a,h)}));const l={vs:s.flat()};return c&&(l.barycenter=u/c,l.weight=c),l})(m,r,i,o);if(d&&(v.vs=[d,v.vs,f].flat(),null===(s=t.getPredecessors(d))||void 0===s?void 0:s.length)){const e=t.getNode((null===(u=t.getPredecessors(d))||void 0===u?void 0:u[0].id)||""),n=t.getNode((null===(c=t.getPredecessors(f))||void 0===c?void 0:c[0].id)||"");v.hasOwnProperty("barycenter")||(v.barycenter=0,v.weight=0),v.barycenter=(v.barycenter*v.weight+e.data.order+n.data.order)/(v.weight+2),v.weight+=2}return v},Ip=(t,e)=>{null==t||t.forEach((t=>{var n;const r=null===(n=t.vs)||void 0===n?void 0:n.map((t=>e[t]?e[t].vs:t));t.vs=r.flat()}))},Lp=(t,e)=>{void 0!==t.barycenter?(t.barycenter=(t.barycenter*t.weight+e.barycenter*e.weight)/(t.weight+e.weight),t.weight+=e.weight):(t.barycenter=e.barycenter,t.weight=e.weight)},jp=(t,e,n)=>e.map((e=>((t,e,n)=>{const r=Tp(t),i=new Yf({tree:[{id:r,children:[],data:{}}]});return t.getAllNodes().forEach((o=>{const a=t.getParent(o.id);(o.data.rank===e||o.data.minRank<=e&&e<=o.data.maxRank)&&(i.hasNode(o.id)||i.addNode(Object.assign({},o)),(null==a?void 0:a.id)&&!i.hasNode(null==a?void 0:a.id)&&i.addNode(Object.assign({},a)),i.setParent(o.id,(null==a?void 0:a.id)||r),t.getRelatedEdges(o.id,n).forEach((e=>{const n=e.source===o.id?e.target:e.source;i.hasNode(n)||i.addNode(Object.assign({},t.getNode(n)));const r=i.getRelatedEdges(n,"out").find((({target:t})=>t===o.id)),a=void 0!==r?r.data.weight:0;r?i.updateEdgeData(r.id,Object.assign(Object.assign({},r.data),{weight:e.data.weight+a})):i.addEdge({id:e.id,source:n,target:o.id,data:{weight:e.data.weight+a}})})),o.data.hasOwnProperty("minRank")&&i.updateNodeData(o.id,Object.assign(Object.assign({},o.data),{borderLeft:o.data.borderLeft[e],borderRight:o.data.borderRight[e]})))})),i})(t,e,n))),zp=(t,e,n,r)=>{const i=new Yf;null==t||t.forEach((t=>{var o;const a=t.getRoots()[0].id,s=Dp(t,a,i,e,n,r);for(let e=0;e<(null===(o=s.vs)||void 0===o?void 0:o.length);e++){const n=t.getNode(s.vs[e]);n&&(n.data.order=e)}((t,e,n)=>{const r={};let i;null==n||n.forEach((n=>{let o,a,s=t.getParent(n);for(;s;){if(o=t.getParent(s.id),o?(a=r[o.id],r[o.id]=s.id):(a=i,i=s.id),a&&a!==s.id)return e.hasNode(a)||e.addNode({id:a,data:{}}),e.hasNode(s.id)||e.addNode({id:s.id,data:{}}),void(e.hasEdge(`e${a}-${s.id}`)||e.addEdge({id:`e${a}-${s.id}`,source:a,target:s.id,data:{}}));s=o}}))})(t,i,s.vs)}))},Fp=(t,e)=>{null==e||e.forEach((e=>{null==e||e.forEach(((e,n)=>{t.getNode(e).data.order=n}))}))},Bp=(t,e)=>{const n=(t=>{const e={};let n=0;const r=i=>{const o=n;t.getChildren(i).forEach((t=>r(t.id))),e[i]={low:o,lim:n++}};return t.getRoots().forEach((t=>r(t.id))),e})(t);e.forEach((e=>{var r,i;let o=e,a=t.getNode(o);const s=a.data.originalEdge;if(!s)return;const u=((t,e,n,r)=>{var i,o;const a=[],s=[],u=Math.min(e[n].low,e[r].low),c=Math.max(e[n].lim,e[r].lim);let h,l;h=n;do{h=null===(i=t.getParent(h))||void 0===i?void 0:i.id,a.push(h)}while(h&&(e[h].low>u||c>e[h].lim));for(l=h,h=r;h&&h!==l;)s.push(h),h=null===(o=t.getParent(h))||void 0===o?void 0:o.id;return{lca:l,path:a.concat(s.reverse())}})(t,n,s.source,s.target),c=u.path,h=u.lca;let l=0,d=c[l],f=!0;for(;o!==s.target;){if(a=t.getNode(o),f){for(;d!==h&&(null===(r=t.getNode(d))||void 0===r?void 0:r.data.maxRank)<a.data.rank;)l++,d=c[l];d===h&&(f=!1)}if(!f){for(;l<c.length-1&&(null===(i=t.getNode(c[l+1]))||void 0===i?void 0:i.data.minRank)<=a.data.rank;)l++;d=c[l]}t.hasNode(d)&&t.setParent(o,d),o=t.getSuccessors(o)[0].id}}))},Gp=(t,e)=>{const n={};function r(e,r){const i=function(t){return JSON.stringify(t.slice(1))}(e);r.get(i)||(!function(e,r,i,o,a){var s,u;let c;for(let h=r;h<i;h++)c=e[h],(null===(s=t.getNode(c))||void 0===s?void 0:s.data.dummy)&&(null===(u=t.getPredecessors(c))||void 0===u||u.forEach((e=>{const r=t.getNode(e.id);r.data.dummy&&(r.data.order<o||r.data.order>a)&&Up(n,e.id,c)})))}(...e),r.set(i,!0))}const i=(e,n)=>{let i,o=-1,a=0;const s=new Map;return null==n||n.forEach(((u,c)=>{var h;if("border"===(null===(h=t.getNode(u))||void 0===h?void 0:h.data.dummy)){const e=t.getPredecessors(u)||[];e.length&&(i=t.getNode(e[0].id).data.order,r([n,a,c,o,i],s),a=c,o=i)}r([n,a,n.length,i,e.length],s)})),n};return(null==e?void 0:e.length)&&e.reduce(i),n},Vp=(t,e)=>{var n,r;if(null===(n=t.getNode(e))||void 0===n?void 0:n.data.dummy)return null===(r=t.getPredecessors(e))||void 0===r?void 0:r.find((e=>t.getNode(e.id).data.dummy))},Up=(t,e,n)=>{let r=e,i=n;if(r>i){const t=r;r=i,i=t}let o=t[r];o||(t[r]=o={}),o[i]=!0},Wp=(t,e,n)=>{let r=e,i=n;if(r>n){r=n,i=e}return!!t[r]},Hp=(t,e,n,r,i,o)=>{const a=new Yf,s=qp(r,i,o);return null==e||e.forEach((e=>{let r;null==e||e.forEach((e=>{const i=n[e];if(a.hasNode(i)||a.addNode({id:i,data:{}}),r){const o=n[r],u=a.getRelatedEdges(o,"out").find((t=>t.target===i));u?a.updateEdgeData(u.id,Object.assign(Object.assign({},u.data),{weight:Math.max(s(t,e,r),u.data.weight||0)})):a.addEdge({id:`e${Math.random()}`,source:o,target:i,data:{weight:Math.max(s(t,e,r),0)}})}r=e}))})),a};const qp=(t,e,n)=>(r,i,o)=>{const a=r.getNode(i),s=r.getNode(o);let u=0,c=0;if(u+=a.data.width/2,a.data.hasOwnProperty("labelpos"))switch((a.data.labelpos||"").toLowerCase()){case"l":c=-a.data.width/2;break;case"r":c=a.data.width/2}if(c&&(u+=n?c:-c),c=0,u+=(a.data.dummy?e:t)/2,u+=(s.data.dummy?e:t)/2,u+=s.data.width/2,s.data.labelpos)switch((s.data.labelpos||"").toLowerCase()){case"l":c=s.data.width/2;break;case"r":c=-s.data.width/2}return c&&(u+=n?c:-c),c=0,u},Yp=(t,e)=>t.getNode(e).data.width||0,$p=(t,e)=>{const{align:n,nodesep:r=0,edgesep:i=0}=e||{},o=up(t),a=Object.assign(((t,e)=>{const n={},r=(e,r)=>{let i=0,o=0;const a=e.length,s=null==r?void 0:r[(null==r?void 0:r.length)-1];return null==r||r.forEach(((e,u)=>{var c;const h=Vp(t,e),l=h?t.getNode(h.id).data.order:a;(h||e===s)&&(null===(c=r.slice(o,u+1))||void 0===c||c.forEach((e=>{var r;null===(r=t.getPredecessors(e))||void 0===r||r.forEach((r=>{var o;const a=t.getNode(r.id),s=a.data.order;!(s<i||l<s)||a.data.dummy&&(null===(o=t.getNode(e))||void 0===o?void 0:o.data.dummy)||Up(n,r.id,e)}))})),o=u+1,i=l)})),r};return(null==e?void 0:e.length)&&e.reduce(r),n})(t,o),Gp(t,o)),s={};let u=[];["u","d"].forEach((e=>{u="u"===e?o:Object.values(o).reverse(),["l","r"].forEach((n=>{"r"===n&&(u=u.map((t=>Object.values(t).reverse())));const o=("u"===e?t.getPredecessors:t.getSuccessors).bind(t),c=((t,e,n,r)=>{const i={},o={},a={};return null==e||e.forEach((t=>{null==t||t.forEach(((t,e)=>{i[t]=t,o[t]=t,a[t]=e}))})),null==e||e.forEach((t=>{let e=-1;null==t||t.forEach((t=>{let s=r(t).map((t=>t.id));if(s.length){s=s.sort(((t,e)=>a[t]-a[e]));const r=(s.length-1)/2;for(let u=Math.floor(r),c=Math.ceil(r);u<=c;++u){const r=s[u];o[t]===t&&e<a[r]&&!Wp(n,t,r)&&(o[r]=t,o[t]=i[t]=i[r],e=a[r])}}}))})),{root:i,align:o}})(0,u,a,o),h=((t,e,n,r,i,o,a)=>{var s;const u={},c=Hp(t,e,n,i,o,a),h=a?"borderLeft":"borderRight",l=(t,e)=>{let n=c.getAllNodes(),r=n.pop();const i={};for(;r;)i[r.id]?t(r.id):(i[r.id]=!0,n.push(r),n=n.concat(e(r.id))),r=n.pop()};return l((t=>{u[t]=(c.getRelatedEdges(t,"in")||[]).reduce(((t,e)=>Math.max(t,(u[e.source]||0)+e.data.weight)),0)}),c.getPredecessors.bind(c)),l((e=>{const n=(c.getRelatedEdges(e,"out")||[]).reduce(((t,e)=>Math.min(t,(u[e.target]||0)-e.data.weight)),Number.POSITIVE_INFINITY),r=t.getNode(e);n!==Number.POSITIVE_INFINITY&&r.data.borderType!==h&&(u[e]=Math.max(u[e],n))}),c.getSuccessors.bind(c)),null===(s=Object.values(r))||void 0===s||s.forEach((t=>{u[t]=u[n[t]]})),u})(t,u,c.root,c.align,r,i,"r"===n);"r"===n&&Object.keys(h).forEach((t=>h[t]=-h[t])),s[e+n]=h}))}));const c=((t,e)=>lp(Object.values(e),(e=>{var n;let r=Number.NEGATIVE_INFINITY,i=Number.POSITIVE_INFINITY;return null===(n=Object.keys(e))||void 0===n||n.forEach((n=>{const o=e[n],a=Yp(t,n)/2;r=Math.max(o+a,r),i=Math.min(o-a,i)})),r-i})))(t,s);return c&&function(t,e){const n=Object.values(e),r=Math.min(...n),i=Math.max(...n);["u","d"].forEach((n=>{["l","r"].forEach((o=>{const a=n+o,s=t[a];let u;if(s===e)return;const c=Object.values(s);u="l"===o?r-Math.min(...c):i-Math.max(...c),u&&(t[a]={},Object.keys(s).forEach((e=>{t[a][e]=s[e]+u})))}))}))}(s,c),((t,e)=>{const n={};return Object.keys(t.ul).forEach((r=>{if(e)n[r]=t[e.toLowerCase()][r];else{const e=Object.values(t).map((t=>t[r]));n[r]=(e[0]+e[1])/2}})),n})(s,n)},Xp=(t,e)=>{var n;const r=ap(t);((t,e)=>{const{ranksep:n=0}=e||{},r=up(t);let i=0;null==r||r.forEach((e=>{const r=e.map((e=>t.getNode(e).data.height)),o=Math.max(...r,0);null==e||e.forEach((e=>{t.getNode(e).data.y=i+o/2})),i+=o+n}))})(r,e);const i=$p(r,e);null===(n=Object.keys(i))||void 0===n||n.forEach((t=>{r.getNode(t).data.x=i[t]}))},Kp=t=>{const e={},n=r=>{var i;const o=t.getNode(r);if(!o)return 0;if(e[r])return o.data.rank;let a;return e[r]=!0,null===(i=t.getRelatedEdges(r,"out"))||void 0===i||i.forEach((t=>{const e=n(t.target)-t.data.minlen;e&&(void 0===a||e<a)&&(a=e)})),a||(a=0),o.data.rank=a,a};t.getAllNodes().filter((e=>0===t.getRelatedEdges(e.id,"in").length)).forEach((t=>n(t.id)))},Zp=(t,e)=>t.getNode(e.target).data.rank-t.getNode(e.source).data.rank-e.data.minlen,Qp=(t,e)=>{const n=r=>{e.getRelatedEdges(r,"both").forEach((i=>{const o=i.source,a=r===o?i.target:o;t.hasNode(a)||Zp(e,i)||(t.addNode({id:a,data:{}}),t.addEdge({id:i.id,source:r,target:a,data:{}}),n(a))}))};return t.getAllNodes().forEach((t=>n(t.id))),t.getAllNodes().length},Jp=(t,e)=>{const n=r=>{var i;null===(i=e.getRelatedEdges(r,"both"))||void 0===i||i.forEach((i=>{const o=i.source,a=r===o?i.target:o;t.hasNode(a)||void 0===e.getNode(a).data.layer&&Zp(e,i)||(t.addNode({id:a,data:{}}),t.addEdge({id:i.id,source:r,target:a,data:{}}),n(a))}))};return t.getAllNodes().forEach((t=>n(t.id))),t.getAllNodes().length},tg=(t,e)=>lp(e.getAllEdges(),(n=>t.hasNode(n.source)!==t.hasNode(n.target)?Zp(e,n):1/0)),eg=(t,e,n)=>{t.getAllNodes().forEach((t=>{const r=e.getNode(t.id);r.data.rank||(r.data.rank=0),r.data.rank+=n}))},ng=t=>{const e=(t=>{const e=new Yf;return t.getAllNodes().forEach((t=>{e.addNode(Object.assign({},t))})),t.getAllEdges().forEach((t=>{const n=e.getRelatedEdges(t.source,"out").find((e=>e.target===t.target));n?e.updateEdgeData(null==n?void 0:n.id,Object.assign(Object.assign({},n.data),{weight:n.data.weight+t.data.weight||0,minlen:Math.max(n.data.minlen,t.data.minlen||1)})):e.addEdge({id:t.id,source:t.source,target:t.target,data:{weight:t.data.weight||0,minlen:t.data.minlen||1}})})),e})(t);Kp(e);const n=(t=>{const e=new Yf({tree:[]}),n=t.getAllNodes()[0],r=t.getAllNodes().length;let i,o;for(e.addNode(n);Qp(e,t)<r;)i=tg(e,t),o=e.hasNode(i.source)?Zp(t,i):-Zp(t,i),eg(e,t,o);return e})(e);let r,i;for(ag(n),rg(n,e);r=ug(n);)i=cg(n,e,r),hg(n,e,r,i)},rg=(t,e)=>{let n=fp(t,t.getAllNodes(),"post",!1);n=n.slice(0,(null==n?void 0:n.length)-1),n.forEach((n=>{ig(t,e,n)}))},ig=(t,e,n)=>{const r=t.getNode(n).data.parent;t.getRelatedEdges(n,"both").find((t=>t.target===r||t.source===r)).data.cutvalue=og(t,e,n)},og=(t,e,n)=>{const r=t.getNode(n).data.parent;let i=!0,o=e.getRelatedEdges(n,"out").find((t=>t.target===r)),a=0;return o||(i=!1,o=e.getRelatedEdges(r,"out").find((t=>t.target===n))),a=o.data.weight,e.getRelatedEdges(n,"both").forEach((e=>{const o=e.source===n,s=o?e.target:e.source;if(s!==r){const r=o===i,u=e.data.weight;if(a+=r?u:-u,dg(t,n,s)){const e=t.getRelatedEdges(n,"both").find((t=>t.source===s||t.target===s)).data.cutvalue;a+=r?-e:e}}})),a},ag=(t,e=t.getAllNodes()[0].id)=>{sg(t,{},1,e)},sg=(t,e,n,r,i)=>{var o;const a=n;let s=n;const u=t.getNode(r);return e[r]=!0,null===(o=t.getNeighbors(r))||void 0===o||o.forEach((n=>{e[n.id]||(s=sg(t,e,s,n.id,r))})),u.data.low=a,u.data.lim=s++,i?u.data.parent=i:delete u.data.parent,s},ug=t=>t.getAllEdges().find((t=>t.data.cutvalue<0)),cg=(t,e,n)=>{let r=n.source,i=n.target;e.getRelatedEdges(r,"out").find((t=>t.target===i))||(r=n.target,i=n.source);const o=t.getNode(r),a=t.getNode(i);let s=o,u=!1;o.data.lim>a.data.lim&&(s=a,u=!0);const c=e.getAllEdges().filter((e=>u===fg(t.getNode(e.source),s)&&u!==fg(t.getNode(e.target),s)));return lp(c,(t=>Zp(e,t)))},hg=(t,e,n,r)=>{const i=t.getRelatedEdges(n.source,"both").find((t=>t.source===n.target||t.target===n.target));i&&t.removeEdge(i.id),t.addEdge({id:`e${Math.random()}`,source:r.source,target:r.target,data:{}}),ag(t),rg(t,e),lg(t,e)},lg=(t,e)=>{const n=t.getAllNodes().find((t=>!t.data.parent));let r=fp(t,n,"pre",!1);r=r.slice(1),r.forEach((n=>{const r=t.getNode(n).data.parent;let i=e.getRelatedEdges(n,"out").find((t=>t.target===r)),o=!1;!i&&e.hasNode(r)&&(i=e.getRelatedEdges(r,"out").find((t=>t.target===n)),o=!0),e.getNode(n).data.rank=(e.hasNode(r)&&e.getNode(r).data.rank||0)+(o?null==i?void 0:i.data.minlen:-(null==i?void 0:i.data.minlen))}))},dg=(t,e,n)=>t.getRelatedEdges(e,"both").find((t=>t.source===n||t.target===n)),fg=(t,e)=>e.data.low<=t.data.lim&&t.data.lim<=e.data.lim,pg=Kp,gg=t=>{(t=>{const e={};let n;const r=i=>{var o;const a=t.getNode(i);if(!a)return 0;if(e[i])return a.data.rank;let s;return e[i]=!0,null===(o=t.getRelatedEdges(i,"out"))||void 0===o||o.forEach((t=>{const e=r(t.target)-t.data.minlen;e&&(void 0===s||e<s)&&(s=e)})),s||(s=0),(void 0===n||s<n)&&(n=s),a.data.rank=s,s};t.getAllNodes().filter((e=>0===t.getRelatedEdges(e.id,"in").length)).forEach((t=>{t&&r(t.id)})),void 0===n&&(n=0);const i={},o=(e,n)=>{var r;const a=t.getNode(e),s=isNaN(a.data.layer)?n:a.data.layer;(void 0===a.data.rank||a.data.rank<s)&&(a.data.rank=s),i[e]||(i[e]=!0,null===(r=t.getRelatedEdges(e,"out"))||void 0===r||r.forEach((t=>{o(t.target,s+t.data.minlen)})))};t.getAllNodes().forEach((t=>{const e=t.data;e&&(isNaN(e.layer)?e.rank-=n:o(t.id,e.layer))}))})(t),(t=>{const e=new Yf({tree:[]}),n=t.getAllNodes()[0],r=t.getAllNodes().length;let i,o;for(e.addNode(n);Jp(e,t)<r;)i=tg(e,t),o=e.hasNode(i.source)?Zp(t,i):-Zp(t,i),eg(e,t,o)})(t)},mg=t=>{ng(t)},vg=(t,e)=>{const{acyclicer:n,ranker:r,rankdir:i="tb",nodeOrder:o,keepNodeOrder:a,align:s,nodesep:u=50,edgesep:c=20,ranksep:h=50}=e;Ig(t),rp(t,n);const{nestingRoot:l,nodeRankFactor:d}=(t=>{const e=op(t,"root",{},"_root"),n=xp(t);let r=Math.max(...Object.values(n));Math.abs(r)===1/0&&(r=1);const i=r-1,o=2*i+1;t.getAllEdges().forEach((t=>{t.data.minlen*=o}));const a=Mp(t)+1;return t.getRoots().forEach((r=>{wp(t,e,o,a,i,n,r.id)})),{nestingRoot:e,nodeRankFactor:o}})(t);((t,e)=>{switch(e){case"network-simplex":mg(t);break;case"tight-tree":default:gg(t);break;case"longest-path":pg(t)}})(ap(t),r),kg(t),((t,e=0)=>{const n=t.getAllNodes(),r=n.filter((t=>void 0!==t.data.rank)).map((t=>t.data.rank)),i=Math.min(...r),o=[];n.forEach((t=>{const e=(t.data.rank||0)-i;o[e]||(o[e]=[]),o[e].push(t.id)}));let a=0;for(let n=0;n<o.length;n++){const r=o[n];void 0===r?n%e!=0&&(a-=1):a&&(null==r||r.forEach((e=>{const n=t.getNode(e);n&&(n.data.rank=n.data.rank||0,n.data.rank+=a)})))}})(t,d),((t,e)=>{e&&t.removeNode(e),t.getAllEdges().forEach((e=>{e.data.nestingEdge&&t.removeEdge(e.id)}))})(t,l),(t=>{const e=t.getAllNodes().filter((t=>void 0!==t.data.rank)).map((t=>t.data.rank)),n=Math.min(...e);t.getAllNodes().forEach((t=>{t.data.hasOwnProperty("rank")&&n!==1/0&&(t.data.rank-=n)}))})(t),Pg(t),Cg(t);const f=[];((t,e)=>{t.getAllEdges().forEach((n=>Sp(t,n,e)))})(t,f),Bp(t,f),(t=>{const e=n=>{const r=t.getChildren(n),i=t.getNode(n);if((null==r?void 0:r.length)&&r.forEach((t=>e(t.id))),i.data.hasOwnProperty("minRank")){i.data.borderLeft=[],i.data.borderRight=[];for(let e=i.data.minRank,r=i.data.maxRank+1;e<r;e+=1)pp(t,"borderLeft","_bl",n,i,e),pp(t,"borderRight","_br",n,i,e)}};t.getRoots().forEach((t=>e(t.id)))})(t),a&&((t,e)=>{const n=t.getAllNodes().filter((e=>{var n;return!(null===(n=t.getChildren(e.id))||void 0===n?void 0:n.length)})),r=n.map((t=>t.data.rank)),i=Math.max(...r),o=[];for(let t=0;t<i+1;t++)o[t]=[];null==e||e.forEach((e=>{const n=t.getNode(e);n&&!n.data.dummy&&(isNaN(n.data.rank)||(n.data.fixorder=o[n.data.rank].length,o[n.data.rank].push(e)))}))})(t,o),((t,e)=>{const n=hp(t),r=[],i=[];for(let t=1;t<n+1;t++)r.push(t);for(let t=n-1;t>-1;t--)i.push(t);const o=jp(t,r,"in"),a=jp(t,i,"out");let s=Cp(t);Fp(t,s);let u,c=Number.POSITIVE_INFINITY;for(let n=0,r=0;r<4;++n,++r){zp(n%2?o:a,n%4>=2,!1,e),s=up(t);const i=Pp(t,s);i<c&&(r=0,u=Qt(s),c=i)}s=Cp(t),Fp(t,s);for(let n=0,r=0;r<4;++n,++r){zp(n%2?o:a,n%4>=2,!0,e),s=up(t);const i=Pp(t,s);i<c&&(r=0,u=Qt(s),c=i)}Fp(t,u)})(t,a),Lg(t),((t,e)=>{const n=e.toLowerCase();"lr"!==n&&"rl"!==n||gp(t)})(t,i),Xp(t,{align:s,nodesep:u,edgesep:c,ranksep:h}),jg(t),Dg(t),((t,e)=>{e.forEach((e=>{let n=t.getNode(e);const{data:r}=n,i=r.originalEdge;let o;i&&t.addEdge(i);let a=e;for(;n.data.dummy;)o=t.getSuccessors(a)[0],t.removeNode(a),i.data.points.push({x:n.data.x,y:n.data.y}),n.data.dummy===Np&&(i.data.x=n.data.x,i.data.y=n.data.y,i.data.width=n.data.width,i.data.height=n.data.height),a=o.id,n=t.getNode(a)}))})(t,f),Rg(t),((t,e)=>{const n=e.toLowerCase();"bt"!==n&&"rl"!==n||vp(t),"lr"!==n&&"rl"!==n||(bp(t),gp(t))})(t,i);const{width:p,height:g}=Ag(t);return Og(t),_g(t),(t=>{t.getAllEdges().forEach((e=>{const n=e.data;if(n.reversed){t.removeEdge(e.id);const r=n.forwardName;delete n.reversed,delete n.forwardName,t.addEdge({id:e.id,source:e.target,target:e.source,data:Object.assign(Object.assign({},n),{forwardName:r})})}}))})(t),{width:p,height:g}},yg=(t,e)=>{t.getAllNodes().forEach((n=>{const r=t.getNode(n.id);if(e.hasNode(n.id)){const t=e.getNode(n.id);r.data.fixorder=t.data._order,delete t.data._order}else delete r.data.fixorder}))},bg=(t,e)=>{t.getAllNodes().forEach((n=>{var r;const i=t.getNode(n.id);if(i){const t=e.getNode(n.id);i.data.x=t.data.x,i.data.y=t.data.y,i.data._order=t.data.order,i.data._rank=t.data.rank,(null===(r=e.getChildren(n.id))||void 0===r?void 0:r.length)&&(i.data.width=t.data.width,i.data.height=t.data.height)}})),t.getAllEdges().forEach((n=>{const r=t.getEdge(n.id),i=e.getEdge(n.id);r.data.points=i?i.data.points:[],i&&i.data.hasOwnProperty("x")&&(r.data.x=i.data.x,r.data.y=i.data.y)}))},Eg=["width","height","layer","fixorder"],wg={width:0,height:0},xg=["minlen","weight","width","height","labeloffset"],Mg={minlen:1,weight:1,width:0,height:0,labeloffset:10,labelpos:"r"},Ng=["labelpos"],Sg=t=>{const e=new Yf({tree:[]});return t.getAllNodes().forEach((n=>{const r=Fg(t.getNode(n.id).data),i=Object.assign(Object.assign({},wg),r),o=zg(i,Eg);e.hasNode(n.id)||e.addNode({id:n.id,data:Object.assign({},o)});const a=t.hasTreeStructure("combo")?t.getParent(n.id,"combo"):t.getParent(n.id);Pt(a)||(e.hasNode(a.id)||e.addNode(Object.assign({},a)),e.setParent(n.id,a.id))})),t.getAllEdges().forEach((n=>{const r=Fg(t.getEdge(n.id).data),i={};null==Ng||Ng.forEach((t=>{void 0!==r[t]&&(i[t]=r[t])})),e.addEdge({id:n.id,source:n.source,target:n.target,data:Object.assign({},Mg,zg(r,xg),i)})})),e},Tg=(t,e)=>{const{ranksep:n=0,rankdir:r}=e;return t.getAllNodes().forEach((t=>{isNaN(t.data.layer)||t.data.layer||(t.data.layer=0)})),t.getAllEdges().forEach((t=>{var e;t.data.minlen*=2,"c"!==(null===(e=t.data.labelpos)||void 0===e?void 0:e.toLowerCase())&&("TB"===r||"BT"===r?t.data.width+=t.data.labeloffset:t.data.height+=t.data.labeloffset)})),n/2},kg=t=>{t.getAllEdges().forEach((e=>{if(e.data.width&&e.data.height){const n=t.getNode(e.source),r={e:e,rank:(t.getNode(e.target).data.rank-n.data.rank)/2+n.data.rank};op(t,"edge-proxy",r,"_ep")}}))},Pg=t=>{let e=0;return t.getAllNodes().forEach((n=>{var r,i;n.data.borderTop&&(n.data.minRank=null===(r=t.getNode(n.data.borderTop))||void 0===r?void 0:r.data.rank,n.data.maxRank=null===(i=t.getNode(n.data.borderBottom))||void 0===i?void 0:i.data.rank,e=Math.max(e,n.data.maxRank||-1/0))})),e},Cg=t=>{t.getAllNodes().forEach((e=>{"edge-proxy"===e.data.dummy&&(t.getEdge(e.data.e.id).data.labelRank=e.data.rank,t.removeNode(e.id))}))},Ag=(t,e)=>{let n,r,i=0,o=0;const{marginx:a=0,marginy:s=0}=e||{},u=t=>{if(!t.data)return;const e=t.data.x,a=t.data.y,s=t.data.width,u=t.data.height;isNaN(e)||isNaN(s)||(void 0===n&&(n=e-s/2),n=Math.min(n,e-s/2),i=Math.max(i,e+s/2)),isNaN(a)||isNaN(u)||(void 0===r&&(r=a-u/2),r=Math.min(r,a-u/2),o=Math.max(o,a+u/2))};return t.getAllNodes().forEach((t=>{u(t)})),t.getAllEdges().forEach((t=>{(null==t?void 0:t.data.hasOwnProperty("x"))&&u(t)})),n-=a,r-=s,t.getAllNodes().forEach((t=>{t.data.x-=n,t.data.y-=r})),t.getAllEdges().forEach((t=>{var e;null===(e=t.data.points)||void 0===e||e.forEach((t=>{t.x-=n,t.y-=r})),t.data.hasOwnProperty("x")&&(t.data.x-=n),t.data.hasOwnProperty("y")&&(t.data.y-=r)})),{width:i-n+a,height:o-r+s}},Og=t=>{t.getAllEdges().forEach((e=>{const n=t.getNode(e.source),r=t.getNode(e.target);let i,o;e.data.points?(i=e.data.points[0],o=e.data.points[e.data.points.length-1]):(e.data.points=[],i={x:r.data.x,y:r.data.y},o={x:n.data.x,y:n.data.y}),e.data.points.unshift(sp(n.data,i)),e.data.points.push(sp(r.data,o))}))},Rg=t=>{t.getAllEdges().forEach((t=>{if(t.data.hasOwnProperty("x"))switch("l"!==t.data.labelpos&&"r"!==t.data.labelpos||(t.data.width-=t.data.labeloffset),t.data.labelpos){case"l":t.data.x-=t.data.width/2+t.data.labeloffset;break;case"r":t.data.x+=t.data.width/2+t.data.labeloffset}}))},_g=t=>{t.getAllEdges().forEach((t=>{var e;t.data.reversed&&(null===(e=t.data.points)||void 0===e||e.reverse())}))},Dg=t=>{t.getAllNodes().forEach((e=>{var n,r,i;if(null===(n=t.getChildren(e.id))||void 0===n?void 0:n.length){const n=t.getNode(e.id),o=t.getNode(n.data.borderTop),a=t.getNode(n.data.borderBottom),s=t.getNode(n.data.borderLeft[(null===(r=n.data.borderLeft)||void 0===r?void 0:r.length)-1]),u=t.getNode(n.data.borderRight[(null===(i=n.data.borderRight)||void 0===i?void 0:i.length)-1]);n.data.width=Math.abs((null==u?void 0:u.data.x)-(null==s?void 0:s.data.x))||10,n.data.height=Math.abs((null==a?void 0:a.data.y)-(null==o?void 0:o.data.y))||10,n.data.x=((null==s?void 0:s.data.x)||0)+n.data.width/2,n.data.y=((null==o?void 0:o.data.y)||0)+n.data.height/2}})),t.getAllNodes().forEach((e=>{"border"===e.data.dummy&&t.removeNode(e.id)}))},Ig=t=>{t.getAllEdges().forEach((e=>{if(e.source===e.target){const n=t.getNode(e.source);n.data.selfEdges||(n.data.selfEdges=[]),n.data.selfEdges.push(e),t.removeEdge(e.id)}}))},Lg=t=>{const e=up(t);null==e||e.forEach((e=>{let n=0;null==e||e.forEach(((e,r)=>{var i;const o=t.getNode(e);o.data.order=r+n,null===(i=o.data.selfEdges)||void 0===i||i.forEach((e=>{op(t,"selfedge",{width:e.data.width,height:e.data.height,rank:o.data.rank,order:r+ ++n,e:e},"_se")})),delete o.data.selfEdges}))}))},jg=t=>{t.getAllNodes().forEach((e=>{const n=t.getNode(e.id);if("selfedge"===n.data.dummy){const r=t.getNode(n.data.e.source),i=r.data.x+r.data.width/2,o=r.data.y,a=n.data.x-i,s=r.data.height/2;t.hasEdge(n.data.e.id)?t.updateEdgeData(n.data.e.id,n.data.e.data):t.addEdge({id:n.data.e.id,source:n.data.e.source,target:n.data.e.target,data:n.data.e.data}),t.removeNode(e.id),n.data.e.data.points=[{x:i+2*a/3,y:o-s},{x:i+5*a/6,y:o-s},{y:o,x:i+a},{x:i+5*a/6,y:o+s},{x:i+2*a/3,y:o+s}],n.data.e.data.x=n.data.x,n.data.e.data.y=n.data.y}}))},zg=(t,e)=>{const n={};return null==e||e.forEach((e=>{void 0!==t[e]&&(n[e]=+t[e])})),n},Fg=(t={})=>{const e={};return Object.keys(t).forEach((n=>{e[n.toLowerCase()]=t[n]})),e},Bg=Array.isArray,Gg=t=>{const e=[],n=t.length;for(let r=0;r<n;r+=1){e[r]=[];for(let i=0;i<n;i+=1)r===i?e[r][i]=0:0!==t[r][i]&&t[r][i]?e[r][i]=t[r][i]:e[r][i]=1/0}for(let t=0;t<n;t+=1)for(let r=0;r<n;r+=1)for(let i=0;i<n;i+=1)e[r][i]>e[r][t]+e[t][i]&&(e[r][i]=e[r][t]+e[t][i]);return e},Vg=(t,e)=>{const{nodes:n,edges:r}=t,i=[],o={};if(!n)throw new Error("invalid nodes data!");return n&&n.forEach(((t,e)=>{o[t.id]=e;i.push([])})),null==r||r.forEach((t=>{const{source:n,target:r}=t,a=o[n],s=o[r];void 0!==a&&void 0!==s&&(i[a][s]=1,e||(i[s][a]=1))})),i},Ug=(t,e)=>Math.sqrt((t.x-e.x)*(t.x-e.x)+(t.y-e.y)*(t.y-e.y)),Wg=(t,e,n,r="TB",i,o={})=>{if(!(null==e?void 0:e.length))return;const{stopBranchFn:a,stopAllFn:s}=o;for(let u=0;u<e.length;u++){const c=e[u];if(t.hasNode(c.id)&&!(null==a?void 0:a(c))){if(null==s?void 0:s(c))return;"TB"===r&&n(c),Wg(t,t.getChildren(c.id,i),n,r,i,o),"TB"!==r&&n(c)}}},Hg=t=>{if(null===t)return t;if(t instanceof Date)return new Date(t.getTime());if(t instanceof Array){const e=[];return t.forEach((t=>{e.push(t)})),e.map((t=>Hg(t)))}if("object"==typeof t){const e={};return Object.keys(t).forEach((n=>{e[n]=Hg(t[n])})),e}return t},qg=(t,e)=>{const n=Hg(t);return n.data=n.data||{},e&&(Vt(n.data.x)||(n.data.x=Math.random()*e[0]),Vt(n.data.y)||(n.data.y=Math.random()*e[1])),n};function Yg(t,e){let n;return n=kt(e)?e:Vt(e)?()=>e:()=>t,n}function $g(t,e,n=!0){return e||0===e?kt(e)?e:Vt(e)?()=>e:Array.isArray(e)?()=>{if(n){const n=Math.max(...e);return isNaN(n)?t:n}return e}:Rt(e)?()=>{if(n){const n=Math.max(e.width,e.height);return isNaN(n)?t:n}return[e.width,e.height]}:()=>t:e=>{const{size:n}=e.data||{};return n?Array.isArray(n)?n[0]>n[1]?n[0]:n[1]:Rt(n)?n.width>n.height?n.width:n.height:n:t}}const Xg=(t,e)=>{let n,r;return r=Vt(e)?()=>e:kt(e)?e:()=>0,n=t?Array.isArray(t)?e=>(t[0]>t[1]?t[0]:t[1])+r(e):kt(t)?t:e=>t+r(e):t=>{var e,n;if(null===(e=t.data)||void 0===e?void 0:e.bboxSize)return Math.max(t.data.bboxSize[0],t.data.bboxSize[1])+r(t);if(null===(n=t.data)||void 0===n?void 0:n.size){if(Array.isArray(t.data.size))return Math.max(t.data.size[0],t.data.size[1])+r(t);const e=t.data.size;if(Rt(e)){return(e.width>e.height?e.width:e.height)+r(t)}return e+r(t)}return 10+r(t)},n},Kg={rankdir:"TB",nodesep:50,ranksep:50,edgeLabelSpace:!0,ranker:"tight-tree",controlPoints:!1,radial:!1,focusNode:null};const Zg=(t,e,n,r,i,o,a)=>{let s=(null==t?void 0:t.slice(1,t.length-1))||[];if(e&&n){let{x:t,y:u}=e.data,{x:c,y:h}=n.data;if(i&&(t=e.data.y,u=e.data.x,c=n.data.y,h=n.data.x),h!==u&&t!==c){const l=r.indexOf(u),d=r[l+1];if(d){const t=s[0],e=i?{x:(u+d)/2,y:(null==t?void 0:t.y)||c}:{x:(null==t?void 0:t.x)||c,y:(u+d)/2};t&&!o(t,e)||s.unshift(e)}const f=r.indexOf(h),p=Math.abs(f-l);if(1===p)s=a(s,e.data,n.data),s.length||s.push(i?{x:(u+h)/2,y:t}:{x:t,y:(u+h)/2});else if(p>1){const e=r[f-1];if(e){const n=s[s.length-1],r=i?{x:(h+e)/2,y:(null==n?void 0:n.y)||c}:{x:(null==n?void 0:n.x)||t,y:(h+e)/2};n&&!o(n,r)||s.push(r)}}}}return s},Qg=(t,e,n)=>{const r=t.getAllNodes(),i=t.getAllEdges();if(!(null==r?void 0:r.length)){return{nodes:[],edges:i}}if(1===r.length){e&&t.mergeNodeData(r[0].id,{x:n[0],y:n[1]});return{nodes:[Object.assign(Object.assign({},r[0]),{data:Object.assign(Object.assign({},r[0].data),{x:n[0],y:n[1]})})],edges:i}}},Jg={radius:null,startRadius:null,endRadius:null,startAngle:0,endAngle:2*Math.PI,clockwise:!0,divisions:1,ordering:null,angleRatio:1};const tm=(t,e,n=!1)=>{const r=[qg(e[0])],i={},o=e.length;i[e[0].id]=!0;let a=0;return e.forEach(((s,u)=>{if(0!==u)if(u!==o-1&&t.getDegree(s.id,"both")===t.getDegree(e[u+1].id,"both")&&!t.areNeighbors(r[a].id,s.id)||i[s.id]){const u=n?t.getSuccessors(r[a].id):t.getNeighbors(r[a].id);let c=!1;for(let e=0;e<u.length;e++){const n=u[e];if(t.getDegree(n.id)===t.getDegree(s.id)&&!i[n.id]){r.push(qg(n)),i[n.id]=!0,c=!0;break}}let h=0;for(;!c&&(i[e[h].id]||(r.push(qg(e[h])),i[e[h].id]=!0,c=!0),h++,h!==o););}else r.push(qg(s)),i[s.id]=!0,a++})),r};const em=(t,e,n)=>{let r=t,i=e,o=n;return r||"undefined"==typeof window||(r=window.innerWidth),i||"undefined"==typeof window||(i=window.innerHeight),o||(o=[r/2,i/2]),[r,i,o]},nm={nodeSize:30,nodeSpacing:10,preventOverlap:!1,sweep:void 0,equidistant:!1,startAngle:1.5*Math.PI,clockwise:!0,maxLevelDiff:void 0,sortBy:"degree"};class rm{constructor(t={}){this.options=t,this.id="concentric",this.options=Object.assign(Object.assign({},nm),t)}execute(t,e){return a(this,void 0,void 0,(function*(){return this.genericConcentricLayout(!1,t,e)}))}assign(t,e){return a(this,void 0,void 0,(function*(){this.genericConcentricLayout(!0,t,e)}))}genericConcentricLayout(t,e,n){return a(this,void 0,void 0,(function*(){const r=Object.assign(Object.assign({},this.options),n),{center:i,width:o,height:a,sortBy:s,maxLevelDiff:u,sweep:c,clockwise:h,equidistant:l,preventOverlap:d,startAngle:f=1.5*Math.PI,nodeSize:p,nodeSpacing:g}=r,m=e.getAllNodes(),v=e.getAllEdges(),y=o||"undefined"==typeof window?o:window.innerWidth,b=a||"undefined"==typeof window?a:window.innerHeight,E=i||[y/2,b/2];if(!(null==m?void 0:m.length)||1===m.length)return Qg(e,t,E);const w=[];let x,M=0;Bg(p)?x=Math.max(p[0],p[1]):kt(p)?(x=-1/0,m.forEach((t=>{const e=p(t);e>x&&(x=e)}))):x=p,Bg(g)?M=Math.max(g[0],g[1]):Vt(g)&&(M=g),m.forEach((t=>{const e=qg(t);w.push(e);let n=x;const{data:r}=e;Bg(r.size)?n=Math.max(r.size[0],r.size[1]):Vt(r.size)?n=r.size:Rt(r.size)&&(n=Math.max(r.size.width,r.size.height)),x=Math.max(x,n),kt(g)&&(M=Math.max(g(t),M))}));const N={};w.forEach(((t,e)=>{N[t.id]=e}));let S=s;zt(S)&&void 0!==w[0].data[S]||(S="degree"),"degree"===S?w.sort(((t,n)=>e.getDegree(n.id,"both")-e.getDegree(t.id,"both"))):w.sort(((t,e)=>e.data[S]-t.data[S]));const T=w[0],k=(u||("degree"===S?e.getDegree(T.id,"both"):T.data[S]))/4,P=[{nodes:[]}];let C=P[0];w.forEach((t=>{if(C.nodes.length>0){const n="degree"===S?Math.abs(e.getDegree(C.nodes[0].id,"both")-e.getDegree(t.id,"both")):Math.abs(C.nodes[0].data[S]-t.data[S]);k&&n>=k&&(C={nodes:[]},P.push(C))}C.nodes.push(t)}));let A=x+M;if(!d){const t=P.length>0&&P[0].nodes.length>1,e=(Math.min(y,b)/2-A)/(P.length+(t?1:0));A=Math.min(A,e)}let O=0;if(P.forEach((t=>{const e=void 0===c?2*Math.PI-2*Math.PI/t.nodes.length:c;if(t.dTheta=e/Math.max(1,t.nodes.length-1),t.nodes.length>1&&d){const e=Math.cos(t.dTheta)-Math.cos(0),n=Math.sin(t.dTheta)-Math.sin(0),r=Math.sqrt(A*A/(e*e+n*n));O=Math.max(r,O)}t.r=O,O+=A})),l){let t=0,e=0;for(let n=0;n<P.length;n++){const r=(P[n].r||0)-e;t=Math.max(t,r)}e=0,P.forEach(((n,r)=>{0===r&&(e=n.r||0),n.r=e,e+=t}))}P.forEach((t=>{const e=t.dTheta||0,n=t.r||0;t.nodes.forEach(((t,r)=>{const i=f+(h?1:-1)*e*r;t.data.x=E[0]+n*Math.cos(i),t.data.y=E[1]+n*Math.sin(i)}))})),t&&w.forEach((t=>e.mergeNodeData(t.id,{x:t.data.x,y:t.data.y})));return{nodes:w,edges:v}}))}}function im(t,e,n,r){if(isNaN(e)||isNaN(n))return t;var i,o,a,s,u,c,h,l,d,f=t._root,p={data:r},g=t._x0,m=t._y0,v=t._x1,y=t._y1;if(!f)return t._root=p,t;for(;f.length;)if((c=e>=(o=(g+v)/2))?g=o:v=o,(h=n>=(a=(m+y)/2))?m=a:y=a,i=f,!(f=f[l=h<<1|c]))return i[l]=p,t;if(s=+t._x.call(null,f.data),u=+t._y.call(null,f.data),e===s&&n===u)return p.next=f,i?i[l]=p:t._root=p,t;do{i=i?i[l]=new Array(4):t._root=new Array(4),(c=e>=(o=(g+v)/2))?g=o:v=o,(h=n>=(a=(m+y)/2))?m=a:y=a}while((l=h<<1|c)==(d=(u>=a)<<1|s>=o));return i[d]=f,i[l]=p,t}function om(t,e,n,r,i){this.node=t,this.x0=e,this.y0=n,this.x1=r,this.y1=i}function am(t){return t[0]}function sm(t){return t[1]}function um(t,e,n){var r=new cm(null==e?am:e,null==n?sm:n,NaN,NaN,NaN,NaN);return null==t?r:r.addAll(t)}function cm(t,e,n,r,i,o){this._x=t,this._y=e,this._x0=n,this._y0=r,this._x1=i,this._y1=o,this._root=void 0}function hm(t){for(var e={data:t.data},n=e;t=t.next;)n=n.next={data:t.data};return e}var lm=um.prototype=cm.prototype;function dm(t,e,n,r,i){if(isNaN(e)||isNaN(n)||isNaN(r))return t;var o,a,s,u,c,h,l,d,f,p,g,m,v=t._root,y={data:i},b=t._x0,E=t._y0,w=t._z0,x=t._x1,M=t._y1,N=t._z1;if(!v)return t._root=y,t;for(;v.length;)if((d=e>=(a=(b+x)/2))?b=a:x=a,(f=n>=(s=(E+M)/2))?E=s:M=s,(p=r>=(u=(w+N)/2))?w=u:N=u,o=v,!(v=v[g=p<<2|f<<1|d]))return o[g]=y,t;if(c=+t._x.call(null,v.data),h=+t._y.call(null,v.data),l=+t._z.call(null,v.data),e===c&&n===h&&r===l)return y.next=v,o?o[g]=y:t._root=y,t;do{o=o?o[g]=new Array(8):t._root=new Array(8),(d=e>=(a=(b+x)/2))?b=a:x=a,(f=n>=(s=(E+M)/2))?E=s:M=s,(p=r>=(u=(w+N)/2))?w=u:N=u}while((g=p<<2|f<<1|d)==(m=(l>=u)<<2|(h>=s)<<1|c>=a));return o[m]=v,o[g]=y,t}function fm(t,e,n,r,i,o,a){this.node=t,this.x0=e,this.y0=n,this.z0=r,this.x1=i,this.y1=o,this.z1=a}function pm(t){return t[0]}function gm(t){return t[1]}function mm(t){return t[2]}function vm(t,e,n,r){var i=new ym(null==e?pm:e,null==n?gm:n,null==r?mm:r,NaN,NaN,NaN,NaN,NaN,NaN);return null==t?i:i.addAll(t)}function ym(t,e,n,r,i,o,a,s,u){this._x=t,this._y=e,this._z=n,this._x0=r,this._y0=i,this._z0=o,this._x1=a,this._y1=s,this._z1=u,this._root=void 0}function bm(t){for(var e={data:t.data},n=e;t=t.next;)n=n.next={data:t.data};return e}lm.copy=function(){var t,e,n=new cm(this._x,this._y,this._x0,this._y0,this._x1,this._y1),r=this._root;if(!r)return n;if(!r.length)return n._root=hm(r),n;for(t=[{source:r,target:n._root=new Array(4)}];r=t.pop();)for(var i=0;i<4;++i)(e=r.source[i])&&(e.length?t.push({source:e,target:r.target[i]=new Array(4)}):r.target[i]=hm(e));return n},lm.add=function(t){const e=+this._x.call(null,t),n=+this._y.call(null,t);return im(this.cover(e,n),e,n,t)},lm.addAll=function(t){var e,n,r,i,o=t.length,a=new Array(o),s=new Array(o),u=1/0,c=1/0,h=-1/0,l=-1/0;for(n=0;n<o;++n)isNaN(r=+this._x.call(null,e=t[n]))||isNaN(i=+this._y.call(null,e))||(a[n]=r,s[n]=i,r<u&&(u=r),r>h&&(h=r),i<c&&(c=i),i>l&&(l=i));if(u>h||c>l)return this;for(this.cover(u,c).cover(h,l),n=0;n<o;++n)im(this,a[n],s[n],t[n]);return this},lm.cover=function(t,e){if(isNaN(t=+t)||isNaN(e=+e))return this;var n=this._x0,r=this._y0,i=this._x1,o=this._y1;if(isNaN(n))i=(n=Math.floor(t))+1,o=(r=Math.floor(e))+1;else{for(var a,s,u=i-n||1,c=this._root;n>t||t>=i||r>e||e>=o;)switch(s=(e<r)<<1|t<n,(a=new Array(4))[s]=c,c=a,u*=2,s){case 0:i=n+u,o=r+u;break;case 1:n=i-u,o=r+u;break;case 2:i=n+u,r=o-u;break;case 3:n=i-u,r=o-u}this._root&&this._root.length&&(this._root=c)}return this._x0=n,this._y0=r,this._x1=i,this._y1=o,this},lm.data=function(){var t=[];return this.visit((function(e){if(!e.length)do{t.push(e.data)}while(e=e.next)})),t},lm.extent=function(t){return arguments.length?this.cover(+t[0][0],+t[0][1]).cover(+t[1][0],+t[1][1]):isNaN(this._x0)?void 0:[[this._x0,this._y0],[this._x1,this._y1]]},lm.find=function(t,e,n){var r,i,o,a,s,u,c,h=this._x0,l=this._y0,d=this._x1,f=this._y1,p=[],g=this._root;for(g&&p.push(new om(g,h,l,d,f)),null==n?n=1/0:(h=t-n,l=e-n,d=t+n,f=e+n,n*=n);u=p.pop();)if(!(!(g=u.node)||(i=u.x0)>d||(o=u.y0)>f||(a=u.x1)<h||(s=u.y1)<l))if(g.length){var m=(i+a)/2,v=(o+s)/2;p.push(new om(g[3],m,v,a,s),new om(g[2],i,v,m,s),new om(g[1],m,o,a,v),new om(g[0],i,o,m,v)),(c=(e>=v)<<1|t>=m)&&(u=p[p.length-1],p[p.length-1]=p[p.length-1-c],p[p.length-1-c]=u)}else{var y=t-+this._x.call(null,g.data),b=e-+this._y.call(null,g.data),E=y*y+b*b;if(E<n){var w=Math.sqrt(n=E);h=t-w,l=e-w,d=t+w,f=e+w,r=g.data}}return r},lm.remove=function(t){if(isNaN(o=+this._x.call(null,t))||isNaN(a=+this._y.call(null,t)))return this;var e,n,r,i,o,a,s,u,c,h,l,d,f=this._root,p=this._x0,g=this._y0,m=this._x1,v=this._y1;if(!f)return this;if(f.length)for(;;){if((c=o>=(s=(p+m)/2))?p=s:m=s,(h=a>=(u=(g+v)/2))?g=u:v=u,e=f,!(f=f[l=h<<1|c]))return this;if(!f.length)break;(e[l+1&3]||e[l+2&3]||e[l+3&3])&&(n=e,d=l)}for(;f.data!==t;)if(r=f,!(f=f.next))return this;return(i=f.next)&&delete f.next,r?(i?r.next=i:delete r.next,this):e?(i?e[l]=i:delete e[l],(f=e[0]||e[1]||e[2]||e[3])&&f===(e[3]||e[2]||e[1]||e[0])&&!f.length&&(n?n[d]=f:this._root=f),this):(this._root=i,this)},lm.removeAll=function(t){for(var e=0,n=t.length;e<n;++e)this.remove(t[e]);return this},lm.root=function(){return this._root},lm.size=function(){var t=0;return this.visit((function(e){if(!e.length)do{++t}while(e=e.next)})),t},lm.visit=function(t){var e,n,r,i,o,a,s=[],u=this._root;for(u&&s.push(new om(u,this._x0,this._y0,this._x1,this._y1));e=s.pop();)if(!t(u=e.node,r=e.x0,i=e.y0,o=e.x1,a=e.y1)&&u.length){var c=(r+o)/2,h=(i+a)/2;(n=u[3])&&s.push(new om(n,c,h,o,a)),(n=u[2])&&s.push(new om(n,r,h,c,a)),(n=u[1])&&s.push(new om(n,c,i,o,h)),(n=u[0])&&s.push(new om(n,r,i,c,h))}return this},lm.visitAfter=function(t){var e,n=[],r=[];for(this._root&&n.push(new om(this._root,this._x0,this._y0,this._x1,this._y1));e=n.pop();){var i=e.node;if(i.length){var o,a=e.x0,s=e.y0,u=e.x1,c=e.y1,h=(a+u)/2,l=(s+c)/2;(o=i[0])&&n.push(new om(o,a,s,h,l)),(o=i[1])&&n.push(new om(o,h,s,u,l)),(o=i[2])&&n.push(new om(o,a,l,h,c)),(o=i[3])&&n.push(new om(o,h,l,u,c))}r.push(e)}for(;e=r.pop();)t(e.node,e.x0,e.y0,e.x1,e.y1);return this},lm.x=function(t){return arguments.length?(this._x=t,this):this._x},lm.y=function(t){return arguments.length?(this._y=t,this):this._y};var Em=vm.prototype=ym.prototype;Em.copy=function(){var t,e,n=new ym(this._x,this._y,this._z,this._x0,this._y0,this._z0,this._x1,this._y1,this._z1),r=this._root;if(!r)return n;if(!r.length)return n._root=bm(r),n;for(t=[{source:r,target:n._root=new Array(8)}];r=t.pop();)for(var i=0;i<8;++i)(e=r.source[i])&&(e.length?t.push({source:e,target:r.target[i]=new Array(8)}):r.target[i]=bm(e));return n},Em.add=function(t){const e=+this._x.call(null,t),n=+this._y.call(null,t),r=+this._z.call(null,t);return dm(this.cover(e,n,r),e,n,r,t)},Em.addAll=function(t){Array.isArray(t)||(t=Array.from(t));const e=t.length,n=new Float64Array(e),r=new Float64Array(e),i=new Float64Array(e);let o=1/0,a=1/0,s=1/0,u=-1/0,c=-1/0,h=-1/0;for(let l,d,f,p,g=0;g<e;++g)isNaN(d=+this._x.call(null,l=t[g]))||isNaN(f=+this._y.call(null,l))||isNaN(p=+this._z.call(null,l))||(n[g]=d,r[g]=f,i[g]=p,d<o&&(o=d),d>u&&(u=d),f<a&&(a=f),f>c&&(c=f),p<s&&(s=p),p>h&&(h=p));if(o>u||a>c||s>h)return this;this.cover(o,a,s).cover(u,c,h);for(let o=0;o<e;++o)dm(this,n[o],r[o],i[o],t[o]);return this},Em.cover=function(t,e,n){if(isNaN(t=+t)||isNaN(e=+e)||isNaN(n=+n))return this;var r=this._x0,i=this._y0,o=this._z0,a=this._x1,s=this._y1,u=this._z1;if(isNaN(r))a=(r=Math.floor(t))+1,s=(i=Math.floor(e))+1,u=(o=Math.floor(n))+1;else{for(var c,h,l=a-r||1,d=this._root;r>t||t>=a||i>e||e>=s||o>n||n>=u;)switch(h=(n<o)<<2|(e<i)<<1|t<r,(c=new Array(8))[h]=d,d=c,l*=2,h){case 0:a=r+l,s=i+l,u=o+l;break;case 1:r=a-l,s=i+l,u=o+l;break;case 2:a=r+l,i=s-l,u=o+l;break;case 3:r=a-l,i=s-l,u=o+l;break;case 4:a=r+l,s=i+l,o=u-l;break;case 5:r=a-l,s=i+l,o=u-l;break;case 6:a=r+l,i=s-l,o=u-l;break;case 7:r=a-l,i=s-l,o=u-l}this._root&&this._root.length&&(this._root=d)}return this._x0=r,this._y0=i,this._z0=o,this._x1=a,this._y1=s,this._z1=u,this},Em.data=function(){var t=[];return this.visit((function(e){if(!e.length)do{t.push(e.data)}while(e=e.next)})),t},Em.extent=function(t){return arguments.length?this.cover(+t[0][0],+t[0][1],+t[0][2]).cover(+t[1][0],+t[1][1],+t[1][2]):isNaN(this._x0)?void 0:[[this._x0,this._y0,this._z0],[this._x1,this._y1,this._z1]]},Em.find=function(t,e,n,r){var i,o,a,s,u,c,h,l,d,f=this._x0,p=this._y0,g=this._z0,m=this._x1,v=this._y1,y=this._z1,b=[],E=this._root;for(E&&b.push(new fm(E,f,p,g,m,v,y)),null==r?r=1/0:(f=t-r,p=e-r,g=n-r,m=t+r,v=e+r,y=n+r,r*=r);l=b.pop();)if(!(!(E=l.node)||(o=l.x0)>m||(a=l.y0)>v||(s=l.z0)>y||(u=l.x1)<f||(c=l.y1)<p||(h=l.z1)<g))if(E.length){var w=(o+u)/2,x=(a+c)/2,M=(s+h)/2;b.push(new fm(E[7],w,x,M,u,c,h),new fm(E[6],o,x,M,w,c,h),new fm(E[5],w,a,M,u,x,h),new fm(E[4],o,a,M,w,x,h),new fm(E[3],w,x,s,u,c,M),new fm(E[2],o,x,s,w,c,M),new fm(E[1],w,a,s,u,x,M),new fm(E[0],o,a,s,w,x,M)),(d=(n>=M)<<2|(e>=x)<<1|t>=w)&&(l=b[b.length-1],b[b.length-1]=b[b.length-1-d],b[b.length-1-d]=l)}else{var N=t-+this._x.call(null,E.data),S=e-+this._y.call(null,E.data),T=n-+this._z.call(null,E.data),k=N*N+S*S+T*T;if(k<r){var P=Math.sqrt(r=k);f=t-P,p=e-P,g=n-P,m=t+P,v=e+P,y=n+P,i=E.data}}return i},Em.remove=function(t){if(isNaN(o=+this._x.call(null,t))||isNaN(a=+this._y.call(null,t))||isNaN(s=+this._z.call(null,t)))return this;var e,n,r,i,o,a,s,u,c,h,l,d,f,p,g,m=this._root,v=this._x0,y=this._y0,b=this._z0,E=this._x1,w=this._y1,x=this._z1;if(!m)return this;if(m.length)for(;;){if((l=o>=(u=(v+E)/2))?v=u:E=u,(d=a>=(c=(y+w)/2))?y=c:w=c,(f=s>=(h=(b+x)/2))?b=h:x=h,e=m,!(m=m[p=f<<2|d<<1|l]))return this;if(!m.length)break;(e[p+1&7]||e[p+2&7]||e[p+3&7]||e[p+4&7]||e[p+5&7]||e[p+6&7]||e[p+7&7])&&(n=e,g=p)}for(;m.data!==t;)if(r=m,!(m=m.next))return this;return(i=m.next)&&delete m.next,r?(i?r.next=i:delete r.next,this):e?(i?e[p]=i:delete e[p],(m=e[0]||e[1]||e[2]||e[3]||e[4]||e[5]||e[6]||e[7])&&m===(e[7]||e[6]||e[5]||e[4]||e[3]||e[2]||e[1]||e[0])&&!m.length&&(n?n[g]=m:this._root=m),this):(this._root=i,this)},Em.removeAll=function(t){for(var e=0,n=t.length;e<n;++e)this.remove(t[e]);return this},Em.root=function(){return this._root},Em.size=function(){var t=0;return this.visit((function(e){if(!e.length)do{++t}while(e=e.next)})),t},Em.visit=function(t){var e,n,r,i,o,a,s,u,c=[],h=this._root;for(h&&c.push(new fm(h,this._x0,this._y0,this._z0,this._x1,this._y1,this._z1));e=c.pop();)if(!t(h=e.node,r=e.x0,i=e.y0,o=e.z0,a=e.x1,s=e.y1,u=e.z1)&&h.length){var l=(r+a)/2,d=(i+s)/2,f=(o+u)/2;(n=h[7])&&c.push(new fm(n,l,d,f,a,s,u)),(n=h[6])&&c.push(new fm(n,r,d,f,l,s,u)),(n=h[5])&&c.push(new fm(n,l,i,f,a,d,u)),(n=h[4])&&c.push(new fm(n,r,i,f,l,d,u)),(n=h[3])&&c.push(new fm(n,l,d,o,a,s,f)),(n=h[2])&&c.push(new fm(n,r,d,o,l,s,f)),(n=h[1])&&c.push(new fm(n,l,i,o,a,d,f)),(n=h[0])&&c.push(new fm(n,r,i,o,l,d,f))}return this},Em.visitAfter=function(t){var e,n=[],r=[];for(this._root&&n.push(new fm(this._root,this._x0,this._y0,this._z0,this._x1,this._y1,this._z1));e=n.pop();){var i=e.node;if(i.length){var o,a=e.x0,s=e.y0,u=e.z0,c=e.x1,h=e.y1,l=e.z1,d=(a+c)/2,f=(s+h)/2,p=(u+l)/2;(o=i[0])&&n.push(new fm(o,a,s,u,d,f,p)),(o=i[1])&&n.push(new fm(o,d,s,u,c,f,p)),(o=i[2])&&n.push(new fm(o,a,f,u,d,h,p)),(o=i[3])&&n.push(new fm(o,d,f,u,c,h,p)),(o=i[4])&&n.push(new fm(o,a,s,p,d,f,l)),(o=i[5])&&n.push(new fm(o,d,s,p,c,f,l)),(o=i[6])&&n.push(new fm(o,a,f,p,d,h,l)),(o=i[7])&&n.push(new fm(o,d,f,p,c,h,l))}r.push(e)}for(;e=r.pop();)t(e.node,e.x0,e.y0,e.z0,e.x1,e.y1,e.z1);return this},Em.x=function(t){return arguments.length?(this._x=t,this):this._x},Em.y=function(t){return arguments.length?(this._y=t,this):this._y},Em.z=function(t){return arguments.length?(this._z=t,this):this._z};function wm(t,e,n,r,i=2){const o=e/n,a=t.getAllNodes(),s=a.map(((t,e)=>{const{nodeStrength:n,x:r,y:i,z:a,size:s}=t.data;return{x:r,y:i,z:a,size:s,index:e,id:t.id,vx:0,vy:0,vz:0,weight:o*n}})),u=(2===i?um(s,(t=>t.x),(t=>t.y)):vm(s,(t=>t.x),(t=>t.y),(t=>t.z))).visitAfter(xm),c=new Map;return s.forEach((t=>{c.set(t.id,t),function(t,e,n){e.visit(((e,r,i,o,a)=>Mm(e,r,i,o,a,t,n)))}(t,u,i)})),s.map(((t,e)=>{const{id:n,data:i}=a[e],{mass:o=1}=i;r[n]={x:t.vx/o,y:t.vy/o,z:t.vz/o}})),r}function xm(t){let e=0,n=0,r=0,i=0,o=0;const a=t.length;if(a){for(let s=0;s<a;s++){const a=t[s];a&&a.weight&&(e+=a.weight,n+=a.x*a.weight,r+=a.y*a.weight,i+=a.z*a.weight,o+=a.size*a.weight)}t.x=n/e,t.y=r/e,t.z=i/e,t.size=o/e,t.weight=e}else{const e=t;t.x=e.data.x,t.y=e.data.y,t.z=e.data.z,t.size=e.data.size,t.weight=e.data.weight}}const Mm=(t,e,n,r,i,o,a)=>{var s;if((null===(s=t.data)||void 0===s?void 0:s.id)===o.id)return;const u=[n,r,i][a-1],c=o.x-t.x||.1,h=o.y-t.y||.1,l=o.z-t.z||.1,d=[c,h,l],f=u-e;let p=0;for(let t=0;t<a;t++)p+=d[t]*d[t];const g=Math.sqrt(p)*p;if(f*f*.81<p){const e=t.weight/g;return o.vx+=c*e,o.vy+=h*e,o.vz+=l*e,!0}if(t.length)return!1;if(t.data!==o){const e=t.data.weight/g;o.vx+=c*e,o.vy+=h*e,o.vz+=l*e}};const Nm={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"};class Sm{constructor(t={}){this.options=t,this.id="force",this.timeInterval=0,this.judgingDistance=0,this.running=!1,this.options=Object.assign(Object.assign({},Nm),t)}execute(t,e){return a(this,void 0,void 0,(function*(){return this.genericForceLayout(!1,t,e)}))}assign(t,e){return a(this,void 0,void 0,(function*(){this.genericForceLayout(!0,t,e)}))}stop(){this.timeInterval&&"undefined"!=typeof window&&window.clearInterval(this.timeInterval),this.running=!1}tick(t=this.options.maxIteration||1){if(this.lastResult)return this.lastResult;for(let e=0;(this.judgingDistance>this.lastOptions.minMovement||e<1)&&e<t;e++)this.runOneStep(this.lastCalcGraph,this.lastGraph,e,this.lastVelMap,this.lastOptions),this.updatePosition(this.lastGraph,this.lastCalcGraph,this.lastVelMap,this.lastOptions);const e={nodes:this.lastLayoutNodes,edges:this.lastLayoutEdges};return this.lastAssign&&e.nodes.forEach((t=>this.lastGraph.mergeNodeData(t.id,{x:t.data.x,y:t.data.y,z:3===this.options.dimensions?t.data.z:void 0}))),e}genericForceLayout(t,e,n){return a(this,void 0,void 0,(function*(){const r=Object.assign(Object.assign({},this.options),n),i=e.getAllNodes(),o=e.getAllEdges(),a=this.formatOptions(r,e),{dimensions:s,width:u,height:c,nodeSize:h,getMass:l,nodeStrength:d,edgeStrength:f,linkDistance:p}=a,g=i.map(((t,e)=>Object.assign(Object.assign({},t),{data:Object.assign(Object.assign({},t.data),{x:Vt(t.data.x)?t.data.x:Math.random()*u,y:Vt(t.data.y)?t.data.y:Math.random()*c,z:Vt(t.data.z)?t.data.z:Math.random()*Math.sqrt(u*c),size:h(t)||30,mass:l(t),nodeStrength:d(t)})}))),m=o.map((t=>Object.assign(Object.assign({},t),{data:Object.assign(Object.assign({},t.data),{edgeStrength:f(t),linkDistance:p(t,e.getNode(t.source),e.getNode(t.target))})})));if(!(null==i?void 0:i.length))return this.lastResult={nodes:[],edges:o},{nodes:[],edges:o};const v={};i.forEach(((t,e)=>{v[t.id]={x:0,y:0,z:0}}));const y=new Yf({nodes:g,edges:m});this.formatCentripetal(a,y);const{maxIteration:b,minMovement:E,onTick:w}=a;if(this.lastLayoutNodes=g,this.lastLayoutEdges=m,this.lastAssign=t,this.lastGraph=e,this.lastCalcGraph=y,this.lastOptions=a,this.lastVelMap=v,"undefined"==typeof window)return;let x=0;return new Promise((n=>{this.timeInterval=window.setInterval((()=>{i&&this.running||n({nodes:Am(e,g),edges:o}),this.runOneStep(y,e,x,v,a),this.updatePosition(e,y,v,a),t&&g.forEach((t=>e.mergeNodeData(t.id,{x:t.data.x,y:t.data.y,z:3===s?t.data.z:void 0}))),null==w||w({nodes:Am(e,g),edges:o}),x++,(x>=b||this.judgingDistance<E)&&(window.clearInterval(this.timeInterval),n({nodes:Am(e,g),edges:o}))}),0),this.running=!0}))}))}formatOptions(t,e){const n=Object.assign({},t),{width:r,height:i,getMass:o,nodeSize:a}=t;n.width=r||"undefined"==typeof window?r:window.innerWidth,n.height=i||"undefined"==typeof window?i:window.innerHeight,t.center||(n.center=[n.width/2,n.height/2]),o||(n.getMass=t=>{let n=1;Vt(null==t?void 0:t.data.mass)&&(n=null==t?void 0:t.data.mass);const r=e.getDegree(t.id,"both");return!r||r<5?n:5*r*n});const s=Yg(0,t.nodeSpacing);let u;u=a?kt(a)?t=>a(t)+s(t):Bg(a)?t=>{const e=a;return Math.max(e[0],e[1])+s(t)}:t=>a+s(t):t=>{const{size:e}=(null==t?void 0:t.data)||{};return e?Bg(e)?Math.max(e[0],e[1])+s(t):Rt(e)?Math.max(e.width,e.height)+s(t):e+s(t):10+s(t)},n.nodeSize=u;const c=t.linkDistance?Yg(1,t.linkDistance):t=>1+n.nodeSize(e.getNode(t.source))+n.nodeSize(e.getNode(t.target));return n.linkDistance=c,n.nodeStrength=Yg(1,t.nodeStrength),n.edgeStrength=Yg(1,t.edgeStrength),n}formatCentripetal(t,e){const{dimensions:n,centripetalOptions:r,center:i,clusterNodeStrength:o,leafCluster:a,clustering:s,nodeClusterBy:u}=t,c=e.getAllNodes(),h=r||{leaf:2,single:2,others:1,center:t=>({x:i[0],y:i[1],z:3===n?i[2]:void 0})};let l,d;if("function"!=typeof o&&(t.clusterNodeStrength=t=>o),a&&u&&(l=Tm(e,u),d=Array.from(new Set(null==c?void 0:c.map((t=>t.data[u]))))||[],t.centripetalOptions=Object.assign(h,{single:100,leaf:e=>{const{siblingLeaves:n,sameTypeLeaves:r}=l[e.id]||{};return(null==r?void 0:r.length)===(null==n?void 0:n.length)||1===(null==d?void 0:d.length)?1:t.clusterNodeStrength(e)},others:1,center:t=>{const n=e.getDegree(t.id,"both");if(!n)return{x:100,y:100,z:0};let r;if(1===n){const{sameTypeLeaves:e=[]}=l[t.id]||{};1===e.length?r=void 0:e.length>1&&(r=Cm(e))}else r=void 0;return{x:null==r?void 0:r.x,y:null==r?void 0:r.y,z:null==r?void 0:r.z}}})),s&&u){l||(l=Tm(e,u)),d||(d=Array.from(new Set(c.map((t=>t.data[u]))))),d=d.filter((t=>void 0!==t));const n={};d.forEach((t=>{const r=c.filter((e=>e.data[u]===t)).map((t=>e.getNode(t.id)));n[t]=Cm(r)})),t.centripetalOptions=Object.assign(h,{single:e=>t.clusterNodeStrength(e),leaf:e=>t.clusterNodeStrength(e),others:e=>t.clusterNodeStrength(e),center:t=>{const e=n[t.data[u]];return{x:null==e?void 0:e.x,y:null==e?void 0:e.y,z:null==e?void 0:e.z}}})}const{leaf:f,single:p,others:g}=t.centripetalOptions||{};f&&"function"!=typeof f&&(t.centripetalOptions.leaf=()=>f),p&&"function"!=typeof p&&(t.centripetalOptions.single=()=>p),g&&"function"!=typeof g&&(t.centripetalOptions.others=()=>g)}runOneStep(t,e,n,r,i){const o={},a=t.getAllNodes(),s=t.getAllEdges();if(!(null==a?void 0:a.length))return;const{monitor:u}=i;if(this.calRepulsive(t,o,i),s&&this.calAttractive(t,o,i),this.calGravity(t,e,o,i),this.updateVelocity(t,o,r,i),u){u({energy:this.calTotalEnergy(o,a),nodes:e.getAllNodes(),edges:e.getAllEdges(),iterations:n})}}calTotalEnergy(t,e){if(!(null==e?void 0:e.length))return 0;let n=0;return e.forEach(((e,r)=>{const i=t[e.id].x,o=t[e.id].y,a=3===this.options.dimensions?t[e.id].z:0,s=i*i+o*o+a*a,{mass:u=1}=e.data;n+=u*s*.5})),n}calRepulsive(t,e,n){const{dimensions:r,factor:i,coulombDisScale:o}=n;wm(t,i,o*o,e,r)}calAttractive(t,e,n){const{dimensions:r,nodeSize:i}=n;t.getAllEdges().forEach(((n,o)=>{const{source:a,target:s}=n,u=t.getNode(a),c=t.getNode(s);if(!u||!c)return;let h=c.data.x-u.data.x,l=c.data.y-u.data.y,d=3===r?c.data.z-u.data.z:0;h||l||(h=.01*Math.random(),l=.01*Math.random(),3!==r||d||(d=.01*Math.random()));const f=Math.sqrt(h*h+l*l+d*d);if(f<i(u)+i(c))return;const p=h/f,g=l/f,m=d/f,{linkDistance:v=200,edgeStrength:y=200}=n.data||{},b=(v-f)*y,E=1/(u.data.mass||1),w=1/(c.data.mass||1),x=p*b,M=g*b,N=m*b;e[a].x-=x*E,e[a].y-=M*E,e[a].z-=N*E,e[s].x+=x*w,e[s].y+=M*w,e[s].z+=N*w}))}calGravity(t,e,n,r){const{getCenter:i}=r,o=t.getAllNodes(),a=e.getAllNodes(),s=e.getAllEdges(),{width:u,height:c,center:h,gravity:l,centripetalOptions:d}=r;o&&o.forEach((r=>{const{id:o,data:f}=r,{mass:p,x:g,y:m,z:v}=f,y=e.getNode(o);let b=0,E=0,w=0,x=l;const M=t.getDegree(o,"in"),N=t.getDegree(o,"out"),S=t.getDegree(o,"both"),T=null==i?void 0:i(y,S);if(T){const[t,e,n]=T;b=g-t,E=m-e,x=n}else b=g-h[0],E=m-h[1],w=v-h[2];if(x&&(n[o].x-=x*b/p,n[o].y-=x*E/p,n[o].z-=x*w/p),d){const{leaf:t,single:e,others:r,center:i}=d,{x:h,y:l,z:f,centerStrength:b}=(null==i?void 0:i(y,a,s,u,c))||{x:0,y:0,z:0,centerStrength:0};if(!Vt(h)||!Vt(l))return;const E=(g-h)/p,w=(m-l)/p,x=(v-f)/p;if(b&&(n[o].x-=b*E,n[o].y-=b*w,n[o].z-=b*x),0===S){const t=e(y);if(!t)return;return n[o].x-=t*E,n[o].y-=t*w,void(n[o].z-=t*x)}if(0===M||0===N){const e=t(y,a,s);if(!e)return;return n[o].x-=e*E,n[o].y-=e*w,void(n[o].z-=e*x)}const T=r(y);if(!T)return;n[o].x-=T*E,n[o].y-=T*w,n[o].z-=T*x}}))}updateVelocity(t,e,n,r){const{damping:i,maxSpeed:o,interval:a,dimensions:s}=r,u=t.getAllNodes();(null==u?void 0:u.length)&&u.forEach((t=>{const{id:r}=t;let u=(n[r].x+e[r].x*a)*i||.01,c=(n[r].y+e[r].y*a)*i||.01,h=3===s?(n[r].z+e[r].z*a)*i||.01:0;const l=Math.sqrt(u*u+c*c+h*h);if(l>o){const t=o/l;u*=t,c*=t,h*=t}n[r]={x:u,y:c,z:h}}))}updatePosition(t,e,n,r){const{distanceThresholdMode:i,interval:o,dimensions:a}=r,s=e.getAllNodes();if(!(null==s?void 0:s.length))return void(this.judgingDistance=0);let u=0;"max"===i?this.judgingDistance=-1/0:"min"===i&&(this.judgingDistance=1/0),s.forEach((r=>{const{id:s}=r,c=t.getNode(s);if(Vt(c.data.fx)&&Vt(c.data.fy))return void e.mergeNodeData(s,{x:c.data.fx,y:c.data.fy,z:3===a?c.data.fz:void 0});const h=n[s].x*o,l=n[s].y*o,d=3===a?n[s].z*o:0;e.mergeNodeData(s,{x:r.data.x+h,y:r.data.y+l,z:r.data.z+d});const f=Math.sqrt(h*h+l*l+d*d);switch(i){case"max":this.judgingDistance<f&&(this.judgingDistance=f);break;case"min":this.judgingDistance>f&&(this.judgingDistance=f);break;default:u+=f}})),i&&"mean"!==i||(this.judgingDistance=u/s.length)}}const Tm=(t,e)=>{const n=t.getAllNodes();if(!(null==n?void 0:n.length))return{};const r={};return n.forEach(((n,i)=>{1===t.getDegree(n.id,"both")&&(r[n.id]=km(t,"leaf",n,e))})),r},km=(t,e,n,r)=>{const i=t.getDegree(n.id,"in"),o=t.getDegree(n.id,"out");let a=n,s=[];0===i?(a=t.getSuccessors(n.id)[0],s=t.getNeighbors(a.id)):0===o&&(a=t.getPredecessors(n.id)[0],s=t.getNeighbors(a.id)),s=s.filter((e=>0===t.getDegree(e.id,"in")||0===t.getDegree(e.id,"out")));return{coreNode:a,siblingLeaves:s,sameTypeLeaves:Pm(t,e,r,n,s)}},Pm=(t,e,n,r,i)=>{const o=r.data[n]||"";let a=(null==i?void 0:i.filter((t=>t.data[n]===o)))||[];return"leaf"===e&&(a=a.filter((e=>0===t.getDegree(e.id,"in")||0===t.getDegree(e.id,"out")))),a},Cm=t=>{const e={x:0,y:0};t.forEach((t=>{const{x:n,y:r}=t.data;e.x+=n||0,e.y+=r||0}));const n=t.length||1;return{x:e.x/n,y:e.y/n}},Am=(t,e)=>e.map((e=>{const{id:n,data:r}=e,i=t.getNode(n);return Object.assign(Object.assign({},i),{data:Object.assign(Object.assign({},i.data),{x:r.x,y:r.y,z:r.z})})}));var Om={};const Rm=Object.prototype.toString;function _m(t){const e=Rm.call(t);return e.endsWith("Array]")&&!e.includes("Big")}var Dm=f(Object.freeze({__proto__:null,isAnyArray:_m}));var Im=Object.freeze({__proto__:null,default:function(t){var e,n=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};if(!_m(t))throw new TypeError("input must be an array");if(0===t.length)throw new TypeError("input must not be empty");if(void 0!==n.output){if(!_m(n.output))throw new TypeError("output option must be an array if specified");e=n.output}else e=new Array(t.length);var r=function(t){var e=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};if(!_m(t))throw new TypeError("input must be an array");if(0===t.length)throw new TypeError("input must not be empty");var n=e.fromIndex,r=void 0===n?0:n,i=e.toIndex,o=void 0===i?t.length:i;if(r<0||r>=t.length||!Number.isInteger(r))throw new Error("fromIndex must be a positive integer smaller than length");if(o<=r||o>t.length||!Number.isInteger(o))throw new Error("toIndex must be an integer greater than fromIndex and at most equal to length");for(var a=t[r],s=r+1;s<o;s++)t[s]<a&&(a=t[s]);return a}(t),i=function(t){var e=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};if(!_m(t))throw new TypeError("input must be an array");if(0===t.length)throw new TypeError("input must not be empty");var n=e.fromIndex,r=void 0===n?0:n,i=e.toIndex,o=void 0===i?t.length:i;if(r<0||r>=t.length||!Number.isInteger(r))throw new Error("fromIndex must be a positive integer smaller than length");if(o<=r||o>t.length||!Number.isInteger(o))throw new Error("toIndex must be an integer greater than fromIndex and at most equal to length");for(var a=t[r],s=r+1;s<o;s++)t[s]>a&&(a=t[s]);return a}(t);if(r===i)throw new RangeError("minimum and maximum input values are equal. Cannot rescale a constant array");var o=n.min,a=void 0===o?n.autoMinMax?r:0:o,s=n.max,u=void 0===s?n.autoMinMax?i:1:s;if(a>=u)throw new RangeError("min option must be smaller than max option");for(var c=(u-a)/(i-r),h=0;h<t.length;h++)e[h]=(t[h]-r)*c+a;return e}}),Lm=f(Im);Object.defineProperty(Om,"__esModule",{value:!0});var jm=Dm,zm=Lm;const Fm=" ".repeat(2),Bm=" ".repeat(4);function Gm(t,e={}){const{maxRows:n=15,maxColumns:r=10,maxNumSize:i=8,padMinus:o="auto"}=e;return`${t.constructor.name} {\n${Fm}[\n${Bm}${function(t,e,n,r,i){const{rows:o,columns:a}=t,s=Math.min(o,e),u=Math.min(a,n),c=[];if("auto"===i){i=!1;t:for(let e=0;e<s;e++)for(let n=0;n<u;n++)if(t.get(e,n)<0){i=!0;break t}}for(let e=0;e<s;e++){let n=[];for(let o=0;o<u;o++)n.push(Vm(t.get(e,o),r,i));c.push(`${n.join(" ")}`)}u!==a&&(c[c.length-1]+=` ... ${a-n} more columns`);s!==o&&c.push(`... ${o-e} more rows`);return c.join(`\n${Bm}`)}(t,n,r,i,o)}\n${Fm}]\n${Fm}rows: ${t.rows}\n${Fm}columns: ${t.columns}\n}`}function Vm(t,e,n){return(t>=0&&n?` ${Um(t,e-1)}`:Um(t,e)).padEnd(e)}function Um(t,e){let n=t.toString();if(n.length<=e)return n;let r=t.toFixed(e);if(r.length>e&&(r=t.toFixed(Math.max(0,e-(r.length-e)))),r.length<=e&&!r.startsWith("0.000")&&!r.startsWith("-0.000"))return r;let i=t.toExponential(e);return i.length>e&&(i=t.toExponential(Math.max(0,e-(i.length-e)))),i.slice(0)}function Wm(t,e,n){let r=n?t.rows:t.rows-1;if(e<0||e>r)throw new RangeError("Row index out of range")}function Hm(t,e,n){let r=n?t.columns:t.columns-1;if(e<0||e>r)throw new RangeError("Column index out of range")}function qm(t,e){if(e.to1DArray&&(e=e.to1DArray()),e.length!==t.columns)throw new RangeError("vector size must be the same as the number of columns");return e}function Ym(t,e){if(e.to1DArray&&(e=e.to1DArray()),e.length!==t.rows)throw new RangeError("vector size must be the same as the number of rows");return e}function $m(t,e){if(!jm.isAnyArray(e))throw new TypeError("row indices must be an array");for(let n=0;n<e.length;n++)if(e[n]<0||e[n]>=t.rows)throw new RangeError("row indices are out of range")}function Xm(t,e){if(!jm.isAnyArray(e))throw new TypeError("column indices must be an array");for(let n=0;n<e.length;n++)if(e[n]<0||e[n]>=t.columns)throw new RangeError("column indices are out of range")}function Km(t,e,n,r,i){if(5!==arguments.length)throw new RangeError("expected 4 arguments");if(Qm("startRow",e),Qm("endRow",n),Qm("startColumn",r),Qm("endColumn",i),e>n||r>i||e<0||e>=t.rows||n<0||n>=t.rows||r<0||r>=t.columns||i<0||i>=t.columns)throw new RangeError("Submatrix indices are out of range")}function Zm(t,e=0){let n=[];for(let r=0;r<t;r++)n.push(e);return n}function Qm(t,e){if("number"!=typeof e)throw new TypeError(`${t} must be a number`)}function Jm(t){if(t.isEmpty())throw new Error("Empty matrix has no elements to index")}class tv{static from1DArray(t,e,n){if(t*e!==n.length)throw new RangeError("data length does not match given dimensions");let r=new nv(t,e);for(let i=0;i<t;i++)for(let t=0;t<e;t++)r.set(i,t,n[i*e+t]);return r}static rowVector(t){let e=new nv(1,t.length);for(let n=0;n<t.length;n++)e.set(0,n,t[n]);return e}static columnVector(t){let e=new nv(t.length,1);for(let n=0;n<t.length;n++)e.set(n,0,t[n]);return e}static zeros(t,e){return new nv(t,e)}static ones(t,e){return new nv(t,e).fill(1)}static rand(t,e,n={}){if("object"!=typeof n)throw new TypeError("options must be an object");const{random:r=Math.random}=n;let i=new nv(t,e);for(let n=0;n<t;n++)for(let t=0;t<e;t++)i.set(n,t,r());return i}static randInt(t,e,n={}){if("object"!=typeof n)throw new TypeError("options must be an object");const{min:r=0,max:i=1e3,random:o=Math.random}=n;if(!Number.isInteger(r))throw new TypeError("min must be an integer");if(!Number.isInteger(i))throw new TypeError("max must be an integer");if(r>=i)throw new RangeError("min must be smaller than max");let a=i-r,s=new nv(t,e);for(let n=0;n<t;n++)for(let t=0;t<e;t++){let e=r+Math.round(o()*a);s.set(n,t,e)}return s}static eye(t,e,n){void 0===e&&(e=t),void 0===n&&(n=1);let r=Math.min(t,e),i=this.zeros(t,e);for(let t=0;t<r;t++)i.set(t,t,n);return i}static diag(t,e,n){let r=t.length;void 0===e&&(e=r),void 0===n&&(n=e);let i=Math.min(r,e,n),o=this.zeros(e,n);for(let e=0;e<i;e++)o.set(e,e,t[e]);return o}static min(t,e){t=this.checkMatrix(t),e=this.checkMatrix(e);let n=t.rows,r=t.columns,i=new nv(n,r);for(let o=0;o<n;o++)for(let n=0;n<r;n++)i.set(o,n,Math.min(t.get(o,n),e.get(o,n)));return i}static max(t,e){t=this.checkMatrix(t),e=this.checkMatrix(e);let n=t.rows,r=t.columns,i=new this(n,r);for(let o=0;o<n;o++)for(let n=0;n<r;n++)i.set(o,n,Math.max(t.get(o,n),e.get(o,n)));return i}static checkMatrix(t){return tv.isMatrix(t)?t:new nv(t)}static isMatrix(t){return null!=t&&"Matrix"===t.klass}get size(){return this.rows*this.columns}apply(t){if("function"!=typeof t)throw new TypeError("callback must be a function");for(let e=0;e<this.rows;e++)for(let n=0;n<this.columns;n++)t.call(this,e,n);return this}to1DArray(){let t=[];for(let e=0;e<this.rows;e++)for(let n=0;n<this.columns;n++)t.push(this.get(e,n));return t}to2DArray(){let t=[];for(let e=0;e<this.rows;e++){t.push([]);for(let n=0;n<this.columns;n++)t[e].push(this.get(e,n))}return t}toJSON(){return this.to2DArray()}isRowVector(){return 1===this.rows}isColumnVector(){return 1===this.columns}isVector(){return 1===this.rows||1===this.columns}isSquare(){return this.rows===this.columns}isEmpty(){return 0===this.rows||0===this.columns}isSymmetric(){if(this.isSquare()){for(let t=0;t<this.rows;t++)for(let e=0;e<=t;e++)if(this.get(t,e)!==this.get(e,t))return!1;return!0}return!1}isDistance(){if(!this.isSymmetric())return!1;for(let t=0;t<this.rows;t++)if(0!==this.get(t,t))return!1;return!0}isEchelonForm(){let t=0,e=0,n=-1,r=!0,i=!1;for(;t<this.rows&&r;){for(e=0,i=!1;e<this.columns&&!1===i;)0===this.get(t,e)?e++:1===this.get(t,e)&&e>n?(i=!0,n=e):(r=!1,i=!0);t++}return r}isReducedEchelonForm(){let t=0,e=0,n=-1,r=!0,i=!1;for(;t<this.rows&&r;){for(e=0,i=!1;e<this.columns&&!1===i;)0===this.get(t,e)?e++:1===this.get(t,e)&&e>n?(i=!0,n=e):(r=!1,i=!0);for(let n=e+1;n<this.rows;n++)0!==this.get(t,n)&&(r=!1);t++}return r}echelonForm(){let t=this.clone(),e=0,n=0;for(;e<t.rows&&n<t.columns;){let r=e;for(let i=e;i<t.rows;i++)t.get(i,n)>t.get(r,n)&&(r=i);if(0===t.get(r,n))n++;else{t.swapRows(e,r);let i=t.get(e,n);for(let r=n;r<t.columns;r++)t.set(e,r,t.get(e,r)/i);for(let r=e+1;r<t.rows;r++){let i=t.get(r,n)/t.get(e,n);t.set(r,n,0);for(let o=n+1;o<t.columns;o++)t.set(r,o,t.get(r,o)-t.get(e,o)*i)}e++,n++}}return t}reducedEchelonForm(){let t=this.echelonForm(),e=t.columns,n=t.rows,r=n-1;for(;r>=0;)if(0===t.maxRow(r))r--;else{let i=0,o=!1;for(;i<n&&!1===o;)1===t.get(r,i)?o=!0:i++;for(let n=0;n<r;n++){let o=t.get(n,i);for(let a=i;a<e;a++){let e=t.get(n,a)-o*t.get(r,a);t.set(n,a,e)}}r--}return t}set(){throw new Error("set method is unimplemented")}get(){throw new Error("get method is unimplemented")}repeat(t={}){if("object"!=typeof t)throw new TypeError("options must be an object");const{rows:e=1,columns:n=1}=t;if(!Number.isInteger(e)||e<=0)throw new TypeError("rows must be a positive integer");if(!Number.isInteger(n)||n<=0)throw new TypeError("columns must be a positive integer");let r=new nv(this.rows*e,this.columns*n);for(let t=0;t<e;t++)for(let e=0;e<n;e++)r.setSubMatrix(this,this.rows*t,this.columns*e);return r}fill(t){for(let e=0;e<this.rows;e++)for(let n=0;n<this.columns;n++)this.set(e,n,t);return this}neg(){return this.mulS(-1)}getRow(t){Wm(this,t);let e=[];for(let n=0;n<this.columns;n++)e.push(this.get(t,n));return e}getRowVector(t){return nv.rowVector(this.getRow(t))}setRow(t,e){Wm(this,t),e=qm(this,e);for(let n=0;n<this.columns;n++)this.set(t,n,e[n]);return this}swapRows(t,e){Wm(this,t),Wm(this,e);for(let n=0;n<this.columns;n++){let r=this.get(t,n);this.set(t,n,this.get(e,n)),this.set(e,n,r)}return this}getColumn(t){Hm(this,t);let e=[];for(let n=0;n<this.rows;n++)e.push(this.get(n,t));return e}getColumnVector(t){return nv.columnVector(this.getColumn(t))}setColumn(t,e){Hm(this,t),e=Ym(this,e);for(let n=0;n<this.rows;n++)this.set(n,t,e[n]);return this}swapColumns(t,e){Hm(this,t),Hm(this,e);for(let n=0;n<this.rows;n++){let r=this.get(n,t);this.set(n,t,this.get(n,e)),this.set(n,e,r)}return this}addRowVector(t){t=qm(this,t);for(let e=0;e<this.rows;e++)for(let n=0;n<this.columns;n++)this.set(e,n,this.get(e,n)+t[n]);return this}subRowVector(t){t=qm(this,t);for(let e=0;e<this.rows;e++)for(let n=0;n<this.columns;n++)this.set(e,n,this.get(e,n)-t[n]);return this}mulRowVector(t){t=qm(this,t);for(let e=0;e<this.rows;e++)for(let n=0;n<this.columns;n++)this.set(e,n,this.get(e,n)*t[n]);return this}divRowVector(t){t=qm(this,t);for(let e=0;e<this.rows;e++)for(let n=0;n<this.columns;n++)this.set(e,n,this.get(e,n)/t[n]);return this}addColumnVector(t){t=Ym(this,t);for(let e=0;e<this.rows;e++)for(let n=0;n<this.columns;n++)this.set(e,n,this.get(e,n)+t[e]);return this}subColumnVector(t){t=Ym(this,t);for(let e=0;e<this.rows;e++)for(let n=0;n<this.columns;n++)this.set(e,n,this.get(e,n)-t[e]);return this}mulColumnVector(t){t=Ym(this,t);for(let e=0;e<this.rows;e++)for(let n=0;n<this.columns;n++)this.set(e,n,this.get(e,n)*t[e]);return this}divColumnVector(t){t=Ym(this,t);for(let e=0;e<this.rows;e++)for(let n=0;n<this.columns;n++)this.set(e,n,this.get(e,n)/t[e]);return this}mulRow(t,e){Wm(this,t);for(let n=0;n<this.columns;n++)this.set(t,n,this.get(t,n)*e);return this}mulColumn(t,e){Hm(this,t);for(let n=0;n<this.rows;n++)this.set(n,t,this.get(n,t)*e);return this}max(t){if(this.isEmpty())return NaN;switch(t){case"row":{const t=new Array(this.rows).fill(Number.NEGATIVE_INFINITY);for(let e=0;e<this.rows;e++)for(let n=0;n<this.columns;n++)this.get(e,n)>t[e]&&(t[e]=this.get(e,n));return t}case"column":{const t=new Array(this.columns).fill(Number.NEGATIVE_INFINITY);for(let e=0;e<this.rows;e++)for(let n=0;n<this.columns;n++)this.get(e,n)>t[n]&&(t[n]=this.get(e,n));return t}case void 0:{let t=this.get(0,0);for(let e=0;e<this.rows;e++)for(let n=0;n<this.columns;n++)this.get(e,n)>t&&(t=this.get(e,n));return t}default:throw new Error(`invalid option: ${t}`)}}maxIndex(){Jm(this);let t=this.get(0,0),e=[0,0];for(let n=0;n<this.rows;n++)for(let r=0;r<this.columns;r++)this.get(n,r)>t&&(t=this.get(n,r),e[0]=n,e[1]=r);return e}min(t){if(this.isEmpty())return NaN;switch(t){case"row":{const t=new Array(this.rows).fill(Number.POSITIVE_INFINITY);for(let e=0;e<this.rows;e++)for(let n=0;n<this.columns;n++)this.get(e,n)<t[e]&&(t[e]=this.get(e,n));return t}case"column":{const t=new Array(this.columns).fill(Number.POSITIVE_INFINITY);for(let e=0;e<this.rows;e++)for(let n=0;n<this.columns;n++)this.get(e,n)<t[n]&&(t[n]=this.get(e,n));return t}case void 0:{let t=this.get(0,0);for(let e=0;e<this.rows;e++)for(let n=0;n<this.columns;n++)this.get(e,n)<t&&(t=this.get(e,n));return t}default:throw new Error(`invalid option: ${t}`)}}minIndex(){Jm(this);let t=this.get(0,0),e=[0,0];for(let n=0;n<this.rows;n++)for(let r=0;r<this.columns;r++)this.get(n,r)<t&&(t=this.get(n,r),e[0]=n,e[1]=r);return e}maxRow(t){if(Wm(this,t),this.isEmpty())return NaN;let e=this.get(t,0);for(let n=1;n<this.columns;n++)this.get(t,n)>e&&(e=this.get(t,n));return e}maxRowIndex(t){Wm(this,t),Jm(this);let e=this.get(t,0),n=[t,0];for(let r=1;r<this.columns;r++)this.get(t,r)>e&&(e=this.get(t,r),n[1]=r);return n}minRow(t){if(Wm(this,t),this.isEmpty())return NaN;let e=this.get(t,0);for(let n=1;n<this.columns;n++)this.get(t,n)<e&&(e=this.get(t,n));return e}minRowIndex(t){Wm(this,t),Jm(this);let e=this.get(t,0),n=[t,0];for(let r=1;r<this.columns;r++)this.get(t,r)<e&&(e=this.get(t,r),n[1]=r);return n}maxColumn(t){if(Hm(this,t),this.isEmpty())return NaN;let e=this.get(0,t);for(let n=1;n<this.rows;n++)this.get(n,t)>e&&(e=this.get(n,t));return e}maxColumnIndex(t){Hm(this,t),Jm(this);let e=this.get(0,t),n=[0,t];for(let r=1;r<this.rows;r++)this.get(r,t)>e&&(e=this.get(r,t),n[0]=r);return n}minColumn(t){if(Hm(this,t),this.isEmpty())return NaN;let e=this.get(0,t);for(let n=1;n<this.rows;n++)this.get(n,t)<e&&(e=this.get(n,t));return e}minColumnIndex(t){Hm(this,t),Jm(this);let e=this.get(0,t),n=[0,t];for(let r=1;r<this.rows;r++)this.get(r,t)<e&&(e=this.get(r,t),n[0]=r);return n}diag(){let t=Math.min(this.rows,this.columns),e=[];for(let n=0;n<t;n++)e.push(this.get(n,n));return e}norm(t="frobenius"){switch(t){case"max":return this.max();case"frobenius":return Math.sqrt(this.dot(this));default:throw new RangeError(`unknown norm type: ${t}`)}}cumulativeSum(){let t=0;for(let e=0;e<this.rows;e++)for(let n=0;n<this.columns;n++)t+=this.get(e,n),this.set(e,n,t);return this}dot(t){tv.isMatrix(t)&&(t=t.to1DArray());let e=this.to1DArray();if(e.length!==t.length)throw new RangeError("vectors do not have the same size");let n=0;for(let r=0;r<e.length;r++)n+=e[r]*t[r];return n}mmul(t){t=nv.checkMatrix(t);let e=this.rows,n=this.columns,r=t.columns,i=new nv(e,r),o=new Float64Array(n);for(let a=0;a<r;a++){for(let e=0;e<n;e++)o[e]=t.get(e,a);for(let t=0;t<e;t++){let e=0;for(let r=0;r<n;r++)e+=this.get(t,r)*o[r];i.set(t,a,e)}}return i}strassen2x2(t){t=nv.checkMatrix(t);let e=new nv(2,2);const n=this.get(0,0),r=t.get(0,0),i=this.get(0,1),o=t.get(0,1),a=this.get(1,0),s=t.get(1,0),u=this.get(1,1),c=t.get(1,1),h=(n+u)*(r+c),l=(a+u)*r,d=n*(o-c),f=u*(s-r),p=(n+i)*c,g=h+f-p+(i-u)*(s+c),m=d+p,v=l+f,y=h-l+d+(a-n)*(r+o);return e.set(0,0,g),e.set(0,1,m),e.set(1,0,v),e.set(1,1,y),e}strassen3x3(t){t=nv.checkMatrix(t);let e=new nv(3,3);const n=this.get(0,0),r=this.get(0,1),i=this.get(0,2),o=this.get(1,0),a=this.get(1,1),s=this.get(1,2),u=this.get(2,0),c=this.get(2,1),h=this.get(2,2),l=t.get(0,0),d=t.get(0,1),f=t.get(0,2),p=t.get(1,0),g=t.get(1,1),m=t.get(1,2),v=t.get(2,0),y=t.get(2,1),b=t.get(2,2),E=(n-o)*(-d+g),w=(-n+o+a)*(l-d+g),x=(o+a)*(-l+d),M=n*l,N=(-n+u+c)*(l-f+m),S=(-n+u)*(f-m),T=(u+c)*(-l+f),k=(-i+c+h)*(g+v-y),P=(i-h)*(g-y),C=i*v,A=(c+h)*(-v+y),O=(-i+a+s)*(m+v-b),R=(i-s)*(m-b),_=(a+s)*(-v+b),D=M+C+r*p,I=(n+r+i-o-a-c-h)*g+w+x+M+k+C+A,L=M+N+T+(n+r+i-a-s-u-c)*m+C+O+_,j=E+a*(-l+d+p-g-m-v+b)+w+M+C+O+R,z=E+w+x+M+s*y,F=C+O+R+_+o*f,B=M+N+S+c*(-l+f+p-g-m-v+y)+k+P+C,G=k+P+C+A+u*d,V=M+N+S+T+h*b;return e.set(0,0,D),e.set(0,1,I),e.set(0,2,L),e.set(1,0,j),e.set(1,1,z),e.set(1,2,F),e.set(2,0,B),e.set(2,1,G),e.set(2,2,V),e}mmulStrassen(t){t=nv.checkMatrix(t);let e=this.clone(),n=e.rows,r=e.columns,i=t.rows,o=t.columns;function a(t,e,n){let r=t.rows,i=t.columns;if(r===e&&i===n)return t;{let r=tv.zeros(e,n);return r=r.setSubMatrix(t,0,0),r}}r!==i&&console.warn(`Multiplying ${n} x ${r} and ${i} x ${o} matrix: dimensions do not match.`);let s=Math.max(n,i),u=Math.max(r,o);return e=a(e,s,u),function t(e,n,r,i){if(r<=512||i<=512)return e.mmul(n);r%2==1&&i%2==1?(e=a(e,r+1,i+1),n=a(n,r+1,i+1)):r%2==1?(e=a(e,r+1,i),n=a(n,r+1,i)):i%2==1&&(e=a(e,r,i+1),n=a(n,r,i+1));let o=parseInt(e.rows/2,10),s=parseInt(e.columns/2,10),u=e.subMatrix(0,o-1,0,s-1),c=n.subMatrix(0,o-1,0,s-1),h=e.subMatrix(0,o-1,s,e.columns-1),l=n.subMatrix(0,o-1,s,n.columns-1),d=e.subMatrix(o,e.rows-1,0,s-1),f=n.subMatrix(o,n.rows-1,0,s-1),p=e.subMatrix(o,e.rows-1,s,e.columns-1),g=n.subMatrix(o,n.rows-1,s,n.columns-1),m=t(tv.add(u,p),tv.add(c,g),o,s),v=t(tv.add(d,p),c,o,s),y=t(u,tv.sub(l,g),o,s),b=t(p,tv.sub(f,c),o,s),E=t(tv.add(u,h),g,o,s),w=t(tv.sub(d,u),tv.add(c,l),o,s),x=t(tv.sub(h,p),tv.add(f,g),o,s),M=tv.add(m,b);M.sub(E),M.add(x);let N=tv.add(y,E),S=tv.add(v,b),T=tv.sub(m,v);T.add(y),T.add(w);let k=tv.zeros(2*M.rows,2*M.columns);return k=k.setSubMatrix(M,0,0),k=k.setSubMatrix(N,M.rows,0),k=k.setSubMatrix(S,0,M.columns),k=k.setSubMatrix(T,M.rows,M.columns),k.subMatrix(0,r-1,0,i-1)}(e,t=a(t,s,u),s,u)}scaleRows(t={}){if("object"!=typeof t)throw new TypeError("options must be an object");const{min:e=0,max:n=1}=t;if(!Number.isFinite(e))throw new TypeError("min must be a number");if(!Number.isFinite(n))throw new TypeError("max must be a number");if(e>=n)throw new RangeError("min must be smaller than max");let r=new nv(this.rows,this.columns);for(let t=0;t<this.rows;t++){const i=this.getRow(t);i.length>0&&zm(i,{min:e,max:n,output:i}),r.setRow(t,i)}return r}scaleColumns(t={}){if("object"!=typeof t)throw new TypeError("options must be an object");const{min:e=0,max:n=1}=t;if(!Number.isFinite(e))throw new TypeError("min must be a number");if(!Number.isFinite(n))throw new TypeError("max must be a number");if(e>=n)throw new RangeError("min must be smaller than max");let r=new nv(this.rows,this.columns);for(let t=0;t<this.columns;t++){const i=this.getColumn(t);i.length&&zm(i,{min:e,max:n,output:i}),r.setColumn(t,i)}return r}flipRows(){const t=Math.ceil(this.columns/2);for(let e=0;e<this.rows;e++)for(let n=0;n<t;n++){let t=this.get(e,n),r=this.get(e,this.columns-1-n);this.set(e,n,r),this.set(e,this.columns-1-n,t)}return this}flipColumns(){const t=Math.ceil(this.rows/2);for(let e=0;e<this.columns;e++)for(let n=0;n<t;n++){let t=this.get(n,e),r=this.get(this.rows-1-n,e);this.set(n,e,r),this.set(this.rows-1-n,e,t)}return this}kroneckerProduct(t){t=nv.checkMatrix(t);let e=this.rows,n=this.columns,r=t.rows,i=t.columns,o=new nv(e*r,n*i);for(let a=0;a<e;a++)for(let e=0;e<n;e++)for(let n=0;n<r;n++)for(let s=0;s<i;s++)o.set(r*a+n,i*e+s,this.get(a,e)*t.get(n,s));return o}kroneckerSum(t){if(t=nv.checkMatrix(t),!this.isSquare()||!t.isSquare())throw new Error("Kronecker Sum needs two Square Matrices");let e=this.rows,n=t.rows,r=this.kroneckerProduct(nv.eye(n,n)),i=nv.eye(e,e).kroneckerProduct(t);return r.add(i)}transpose(){let t=new nv(this.columns,this.rows);for(let e=0;e<this.rows;e++)for(let n=0;n<this.columns;n++)t.set(n,e,this.get(e,n));return t}sortRows(t=ev){for(let e=0;e<this.rows;e++)this.setRow(e,this.getRow(e).sort(t));return this}sortColumns(t=ev){for(let e=0;e<this.columns;e++)this.setColumn(e,this.getColumn(e).sort(t));return this}subMatrix(t,e,n,r){Km(this,t,e,n,r);let i=new nv(e-t+1,r-n+1);for(let o=t;o<=e;o++)for(let e=n;e<=r;e++)i.set(o-t,e-n,this.get(o,e));return i}subMatrixRow(t,e,n){if(void 0===e&&(e=0),void 0===n&&(n=this.columns-1),e>n||e<0||e>=this.columns||n<0||n>=this.columns)throw new RangeError("Argument out of range");let r=new nv(t.length,n-e+1);for(let i=0;i<t.length;i++)for(let o=e;o<=n;o++){if(t[i]<0||t[i]>=this.rows)throw new RangeError(`Row index out of range: ${t[i]}`);r.set(i,o-e,this.get(t[i],o))}return r}subMatrixColumn(t,e,n){if(void 0===e&&(e=0),void 0===n&&(n=this.rows-1),e>n||e<0||e>=this.rows||n<0||n>=this.rows)throw new RangeError("Argument out of range");let r=new nv(n-e+1,t.length);for(let i=0;i<t.length;i++)for(let o=e;o<=n;o++){if(t[i]<0||t[i]>=this.columns)throw new RangeError(`Column index out of range: ${t[i]}`);r.set(o-e,i,this.get(o,t[i]))}return r}setSubMatrix(t,e,n){if((t=nv.checkMatrix(t)).isEmpty())return this;Km(this,e,e+t.rows-1,n,n+t.columns-1);for(let r=0;r<t.rows;r++)for(let i=0;i<t.columns;i++)this.set(e+r,n+i,t.get(r,i));return this}selection(t,e){$m(this,t),Xm(this,e);let n=new nv(t.length,e.length);for(let r=0;r<t.length;r++){let i=t[r];for(let t=0;t<e.length;t++){let o=e[t];n.set(r,t,this.get(i,o))}}return n}trace(){let t=Math.min(this.rows,this.columns),e=0;for(let n=0;n<t;n++)e+=this.get(n,n);return e}clone(){return this.constructor.copy(this,new nv(this.rows,this.columns))}static copy(t,e){for(const[n,r,i]of t.entries())e.set(n,r,i);return e}sum(t){switch(t){case"row":return function(t){let e=Zm(t.rows);for(let n=0;n<t.rows;++n)for(let r=0;r<t.columns;++r)e[n]+=t.get(n,r);return e}(this);case"column":return function(t){let e=Zm(t.columns);for(let n=0;n<t.rows;++n)for(let r=0;r<t.columns;++r)e[r]+=t.get(n,r);return e}(this);case void 0:return function(t){let e=0;for(let n=0;n<t.rows;n++)for(let r=0;r<t.columns;r++)e+=t.get(n,r);return e}(this);default:throw new Error(`invalid option: ${t}`)}}product(t){switch(t){case"row":return function(t){let e=Zm(t.rows,1);for(let n=0;n<t.rows;++n)for(let r=0;r<t.columns;++r)e[n]*=t.get(n,r);return e}(this);case"column":return function(t){let e=Zm(t.columns,1);for(let n=0;n<t.rows;++n)for(let r=0;r<t.columns;++r)e[r]*=t.get(n,r);return e}(this);case void 0:return function(t){let e=1;for(let n=0;n<t.rows;n++)for(let r=0;r<t.columns;r++)e*=t.get(n,r);return e}(this);default:throw new Error(`invalid option: ${t}`)}}mean(t){const e=this.sum(t);switch(t){case"row":for(let t=0;t<this.rows;t++)e[t]/=this.columns;return e;case"column":for(let t=0;t<this.columns;t++)e[t]/=this.rows;return e;case void 0:return e/this.size;default:throw new Error(`invalid option: ${t}`)}}variance(t,e={}){if("object"==typeof t&&(e=t,t=void 0),"object"!=typeof e)throw new TypeError("options must be an object");const{unbiased:n=!0,mean:r=this.mean(t)}=e;if("boolean"!=typeof n)throw new TypeError("unbiased must be a boolean");switch(t){case"row":if(!jm.isAnyArray(r))throw new TypeError("mean must be an array");return function(t,e,n){const r=t.rows,i=t.columns,o=[];for(let a=0;a<r;a++){let r=0,s=0,u=0;for(let e=0;e<i;e++)u=t.get(a,e)-n[a],r+=u,s+=u*u;e?o.push((s-r*r/i)/(i-1)):o.push((s-r*r/i)/i)}return o}(this,n,r);case"column":if(!jm.isAnyArray(r))throw new TypeError("mean must be an array");return function(t,e,n){const r=t.rows,i=t.columns,o=[];for(let a=0;a<i;a++){let i=0,s=0,u=0;for(let e=0;e<r;e++)u=t.get(e,a)-n[a],i+=u,s+=u*u;e?o.push((s-i*i/r)/(r-1)):o.push((s-i*i/r)/r)}return o}(this,n,r);case void 0:if("number"!=typeof r)throw new TypeError("mean must be a number");return function(t,e,n){const r=t.rows,i=t.columns,o=r*i;let a=0,s=0,u=0;for(let e=0;e<r;e++)for(let r=0;r<i;r++)u=t.get(e,r)-n,a+=u,s+=u*u;return e?(s-a*a/o)/(o-1):(s-a*a/o)/o}(this,n,r);default:throw new Error(`invalid option: ${t}`)}}standardDeviation(t,e){"object"==typeof t&&(e=t,t=void 0);const n=this.variance(t,e);if(void 0===t)return Math.sqrt(n);for(let t=0;t<n.length;t++)n[t]=Math.sqrt(n[t]);return n}center(t,e={}){if("object"==typeof t&&(e=t,t=void 0),"object"!=typeof e)throw new TypeError("options must be an object");const{center:n=this.mean(t)}=e;switch(t){case"row":if(!jm.isAnyArray(n))throw new TypeError("center must be an array");return function(t,e){for(let n=0;n<t.rows;n++)for(let r=0;r<t.columns;r++)t.set(n,r,t.get(n,r)-e[n])}(this,n),this;case"column":if(!jm.isAnyArray(n))throw new TypeError("center must be an array");return function(t,e){for(let n=0;n<t.rows;n++)for(let r=0;r<t.columns;r++)t.set(n,r,t.get(n,r)-e[r])}(this,n),this;case void 0:if("number"!=typeof n)throw new TypeError("center must be a number");return function(t,e){for(let n=0;n<t.rows;n++)for(let r=0;r<t.columns;r++)t.set(n,r,t.get(n,r)-e)}(this,n),this;default:throw new Error(`invalid option: ${t}`)}}scale(t,e={}){if("object"==typeof t&&(e=t,t=void 0),"object"!=typeof e)throw new TypeError("options must be an object");let n=e.scale;switch(t){case"row":if(void 0===n)n=function(t){const e=[];for(let n=0;n<t.rows;n++){let r=0;for(let e=0;e<t.columns;e++)r+=Math.pow(t.get(n,e),2)/(t.columns-1);e.push(Math.sqrt(r))}return e}(this);else if(!jm.isAnyArray(n))throw new TypeError("scale must be an array");return function(t,e){for(let n=0;n<t.rows;n++)for(let r=0;r<t.columns;r++)t.set(n,r,t.get(n,r)/e[n])}(this,n),this;case"column":if(void 0===n)n=function(t){const e=[];for(let n=0;n<t.columns;n++){let r=0;for(let e=0;e<t.rows;e++)r+=Math.pow(t.get(e,n),2)/(t.rows-1);e.push(Math.sqrt(r))}return e}(this);else if(!jm.isAnyArray(n))throw new TypeError("scale must be an array");return function(t,e){for(let n=0;n<t.rows;n++)for(let r=0;r<t.columns;r++)t.set(n,r,t.get(n,r)/e[r])}(this,n),this;case void 0:if(void 0===n)n=function(t){const e=t.size-1;let n=0;for(let r=0;r<t.columns;r++)for(let i=0;i<t.rows;i++)n+=Math.pow(t.get(i,r),2)/e;return Math.sqrt(n)}(this);else if("number"!=typeof n)throw new TypeError("scale must be a number");return function(t,e){for(let n=0;n<t.rows;n++)for(let r=0;r<t.columns;r++)t.set(n,r,t.get(n,r)/e)}(this,n),this;default:throw new Error(`invalid option: ${t}`)}}toString(t){return Gm(this,t)}[Symbol.iterator](){return this.entries()}*entries(){for(let t=0;t<this.rows;t++)for(let e=0;e<this.columns;e++)yield[t,e,this.get(t,e)]}*values(){for(let t=0;t<this.rows;t++)for(let e=0;e<this.columns;e++)yield this.get(t,e)}}function ev(t,e){return t-e}tv.prototype.klass="Matrix","undefined"!=typeof Symbol&&(tv.prototype[Symbol.for("nodejs.util.inspect.custom")]=function(){return Gm(this)}),tv.random=tv.rand,tv.randomInt=tv.randInt,tv.diagonal=tv.diag,tv.prototype.diagonal=tv.prototype.diag,tv.identity=tv.eye,tv.prototype.negate=tv.prototype.neg,tv.prototype.tensorProduct=tv.prototype.kroneckerProduct;let nv=class t extends tv{data;#t(t,e){if(this.data=[],!(Number.isInteger(e)&&e>=0))throw new TypeError("nColumns must be a positive integer");for(let n=0;n<t;n++)this.data.push(new Float64Array(e));this.rows=t,this.columns=e}constructor(e,n){if(super(),t.isMatrix(e))this.#t(e.rows,e.columns),t.copy(e,this);else if(Number.isInteger(e)&&e>=0)this.#t(e,n);else{if(!jm.isAnyArray(e))throw new TypeError("First argument must be a positive number or an array");{const t=e;if("number"!=typeof(n=(e=t.length)?t[0].length:0))throw new TypeError("Data must be a 2D array with at least one element");this.data=[];for(let r=0;r<e;r++){if(t[r].length!==n)throw new RangeError("Inconsistent array dimensions");if(!t[r].every((t=>"number"==typeof t)))throw new TypeError("Input data contains non-numeric values");this.data.push(Float64Array.from(t[r]))}this.rows=e,this.columns=n}}}set(t,e,n){return this.data[t][e]=n,this}get(t,e){return this.data[t][e]}removeRow(t){return Wm(this,t),this.data.splice(t,1),this.rows-=1,this}addRow(t,e){return void 0===e&&(e=t,t=this.rows),Wm(this,t,!0),e=Float64Array.from(qm(this,e)),this.data.splice(t,0,e),this.rows+=1,this}removeColumn(t){Hm(this,t);for(let e=0;e<this.rows;e++){const n=new Float64Array(this.columns-1);for(let r=0;r<t;r++)n[r]=this.data[e][r];for(let r=t+1;r<this.columns;r++)n[r-1]=this.data[e][r];this.data[e]=n}return this.columns-=1,this}addColumn(t,e){void 0===e&&(e=t,t=this.columns),Hm(this,t,!0),e=Ym(this,e);for(let n=0;n<this.rows;n++){const r=new Float64Array(this.columns+1);let i=0;for(;i<t;i++)r[i]=this.data[n][i];for(r[i++]=e[n];i<this.columns+1;i++)r[i]=this.data[n][i-1];this.data[n]=r}return this.columns+=1,this}};!function(t,e){t.prototype.add=function(t){return"number"==typeof t?this.addS(t):this.addM(t)},t.prototype.addS=function(t){for(let e=0;e<this.rows;e++)for(let n=0;n<this.columns;n++)this.set(e,n,this.get(e,n)+t);return this},t.prototype.addM=function(t){if(t=e.checkMatrix(t),this.rows!==t.rows||this.columns!==t.columns)throw new RangeError("Matrices dimensions must be equal");for(let e=0;e<this.rows;e++)for(let n=0;n<this.columns;n++)this.set(e,n,this.get(e,n)+t.get(e,n));return this},t.add=function(t,n){return new e(t).add(n)},t.prototype.sub=function(t){return"number"==typeof t?this.subS(t):this.subM(t)},t.prototype.subS=function(t){for(let e=0;e<this.rows;e++)for(let n=0;n<this.columns;n++)this.set(e,n,this.get(e,n)-t);return this},t.prototype.subM=function(t){if(t=e.checkMatrix(t),this.rows!==t.rows||this.columns!==t.columns)throw new RangeError("Matrices dimensions must be equal");for(let e=0;e<this.rows;e++)for(let n=0;n<this.columns;n++)this.set(e,n,this.get(e,n)-t.get(e,n));return this},t.sub=function(t,n){return new e(t).sub(n)},t.prototype.subtract=t.prototype.sub,t.prototype.subtractS=t.prototype.subS,t.prototype.subtractM=t.prototype.subM,t.subtract=t.sub,t.prototype.mul=function(t){return"number"==typeof t?this.mulS(t):this.mulM(t)},t.prototype.mulS=function(t){for(let e=0;e<this.rows;e++)for(let n=0;n<this.columns;n++)this.set(e,n,this.get(e,n)*t);return this},t.prototype.mulM=function(t){if(t=e.checkMatrix(t),this.rows!==t.rows||this.columns!==t.columns)throw new RangeError("Matrices dimensions must be equal");for(let e=0;e<this.rows;e++)for(let n=0;n<this.columns;n++)this.set(e,n,this.get(e,n)*t.get(e,n));return this},t.mul=function(t,n){return new e(t).mul(n)},t.prototype.multiply=t.prototype.mul,t.prototype.multiplyS=t.prototype.mulS,t.prototype.multiplyM=t.prototype.mulM,t.multiply=t.mul,t.prototype.div=function(t){return"number"==typeof t?this.divS(t):this.divM(t)},t.prototype.divS=function(t){for(let e=0;e<this.rows;e++)for(let n=0;n<this.columns;n++)this.set(e,n,this.get(e,n)/t);return this},t.prototype.divM=function(t){if(t=e.checkMatrix(t),this.rows!==t.rows||this.columns!==t.columns)throw new RangeError("Matrices dimensions must be equal");for(let e=0;e<this.rows;e++)for(let n=0;n<this.columns;n++)this.set(e,n,this.get(e,n)/t.get(e,n));return this},t.div=function(t,n){return new e(t).div(n)},t.prototype.divide=t.prototype.div,t.prototype.divideS=t.prototype.divS,t.prototype.divideM=t.prototype.divM,t.divide=t.div,t.prototype.mod=function(t){return"number"==typeof t?this.modS(t):this.modM(t)},t.prototype.modS=function(t){for(let e=0;e<this.rows;e++)for(let n=0;n<this.columns;n++)this.set(e,n,this.get(e,n)%t);return this},t.prototype.modM=function(t){if(t=e.checkMatrix(t),this.rows!==t.rows||this.columns!==t.columns)throw new RangeError("Matrices dimensions must be equal");for(let e=0;e<this.rows;e++)for(let n=0;n<this.columns;n++)this.set(e,n,this.get(e,n)%t.get(e,n));return this},t.mod=function(t,n){return new e(t).mod(n)},t.prototype.modulus=t.prototype.mod,t.prototype.modulusS=t.prototype.modS,t.prototype.modulusM=t.prototype.modM,t.modulus=t.mod,t.prototype.and=function(t){return"number"==typeof t?this.andS(t):this.andM(t)},t.prototype.andS=function(t){for(let e=0;e<this.rows;e++)for(let n=0;n<this.columns;n++)this.set(e,n,this.get(e,n)&t);return this},t.prototype.andM=function(t){if(t=e.checkMatrix(t),this.rows!==t.rows||this.columns!==t.columns)throw new RangeError("Matrices dimensions must be equal");for(let e=0;e<this.rows;e++)for(let n=0;n<this.columns;n++)this.set(e,n,this.get(e,n)&t.get(e,n));return this},t.and=function(t,n){return new e(t).and(n)},t.prototype.or=function(t){return"number"==typeof t?this.orS(t):this.orM(t)},t.prototype.orS=function(t){for(let e=0;e<this.rows;e++)for(let n=0;n<this.columns;n++)this.set(e,n,this.get(e,n)|t);return this},t.prototype.orM=function(t){if(t=e.checkMatrix(t),this.rows!==t.rows||this.columns!==t.columns)throw new RangeError("Matrices dimensions must be equal");for(let e=0;e<this.rows;e++)for(let n=0;n<this.columns;n++)this.set(e,n,this.get(e,n)|t.get(e,n));return this},t.or=function(t,n){return new e(t).or(n)},t.prototype.xor=function(t){return"number"==typeof t?this.xorS(t):this.xorM(t)},t.prototype.xorS=function(t){for(let e=0;e<this.rows;e++)for(let n=0;n<this.columns;n++)this.set(e,n,this.get(e,n)^t);return this},t.prototype.xorM=function(t){if(t=e.checkMatrix(t),this.rows!==t.rows||this.columns!==t.columns)throw new RangeError("Matrices dimensions must be equal");for(let e=0;e<this.rows;e++)for(let n=0;n<this.columns;n++)this.set(e,n,this.get(e,n)^t.get(e,n));return this},t.xor=function(t,n){return new e(t).xor(n)},t.prototype.leftShift=function(t){return"number"==typeof t?this.leftShiftS(t):this.leftShiftM(t)},t.prototype.leftShiftS=function(t){for(let e=0;e<this.rows;e++)for(let n=0;n<this.columns;n++)this.set(e,n,this.get(e,n)<<t);return this},t.prototype.leftShiftM=function(t){if(t=e.checkMatrix(t),this.rows!==t.rows||this.columns!==t.columns)throw new RangeError("Matrices dimensions must be equal");for(let e=0;e<this.rows;e++)for(let n=0;n<this.columns;n++)this.set(e,n,this.get(e,n)<<t.get(e,n));return this},t.leftShift=function(t,n){return new e(t).leftShift(n)},t.prototype.signPropagatingRightShift=function(t){return"number"==typeof t?this.signPropagatingRightShiftS(t):this.signPropagatingRightShiftM(t)},t.prototype.signPropagatingRightShiftS=function(t){for(let e=0;e<this.rows;e++)for(let n=0;n<this.columns;n++)this.set(e,n,this.get(e,n)>>t);return this},t.prototype.signPropagatingRightShiftM=function(t){if(t=e.checkMatrix(t),this.rows!==t.rows||this.columns!==t.columns)throw new RangeError("Matrices dimensions must be equal");for(let e=0;e<this.rows;e++)for(let n=0;n<this.columns;n++)this.set(e,n,this.get(e,n)>>t.get(e,n));return this},t.signPropagatingRightShift=function(t,n){return new e(t).signPropagatingRightShift(n)},t.prototype.rightShift=function(t){return"number"==typeof t?this.rightShiftS(t):this.rightShiftM(t)},t.prototype.rightShiftS=function(t){for(let e=0;e<this.rows;e++)for(let n=0;n<this.columns;n++)this.set(e,n,this.get(e,n)>>>t);return this},t.prototype.rightShiftM=function(t){if(t=e.checkMatrix(t),this.rows!==t.rows||this.columns!==t.columns)throw new RangeError("Matrices dimensions must be equal");for(let e=0;e<this.rows;e++)for(let n=0;n<this.columns;n++)this.set(e,n,this.get(e,n)>>>t.get(e,n));return this},t.rightShift=function(t,n){return new e(t).rightShift(n)},t.prototype.zeroFillRightShift=t.prototype.rightShift,t.prototype.zeroFillRightShiftS=t.prototype.rightShiftS,t.prototype.zeroFillRightShiftM=t.prototype.rightShiftM,t.zeroFillRightShift=t.rightShift,t.prototype.not=function(){for(let t=0;t<this.rows;t++)for(let e=0;e<this.columns;e++)this.set(t,e,~this.get(t,e));return this},t.not=function(t){return new e(t).not()},t.prototype.abs=function(){for(let t=0;t<this.rows;t++)for(let e=0;e<this.columns;e++)this.set(t,e,Math.abs(this.get(t,e)));return this},t.abs=function(t){return new e(t).abs()},t.prototype.acos=function(){for(let t=0;t<this.rows;t++)for(let e=0;e<this.columns;e++)this.set(t,e,Math.acos(this.get(t,e)));return this},t.acos=function(t){return new e(t).acos()},t.prototype.acosh=function(){for(let t=0;t<this.rows;t++)for(let e=0;e<this.columns;e++)this.set(t,e,Math.acosh(this.get(t,e)));return this},t.acosh=function(t){return new e(t).acosh()},t.prototype.asin=function(){for(let t=0;t<this.rows;t++)for(let e=0;e<this.columns;e++)this.set(t,e,Math.asin(this.get(t,e)));return this},t.asin=function(t){return new e(t).asin()},t.prototype.asinh=function(){for(let t=0;t<this.rows;t++)for(let e=0;e<this.columns;e++)this.set(t,e,Math.asinh(this.get(t,e)));return this},t.asinh=function(t){return new e(t).asinh()},t.prototype.atan=function(){for(let t=0;t<this.rows;t++)for(let e=0;e<this.columns;e++)this.set(t,e,Math.atan(this.get(t,e)));return this},t.atan=function(t){return new e(t).atan()},t.prototype.atanh=function(){for(let t=0;t<this.rows;t++)for(let e=0;e<this.columns;e++)this.set(t,e,Math.atanh(this.get(t,e)));return this},t.atanh=function(t){return new e(t).atanh()},t.prototype.cbrt=function(){for(let t=0;t<this.rows;t++)for(let e=0;e<this.columns;e++)this.set(t,e,Math.cbrt(this.get(t,e)));return this},t.cbrt=function(t){return new e(t).cbrt()},t.prototype.ceil=function(){for(let t=0;t<this.rows;t++)for(let e=0;e<this.columns;e++)this.set(t,e,Math.ceil(this.get(t,e)));return this},t.ceil=function(t){return new e(t).ceil()},t.prototype.clz32=function(){for(let t=0;t<this.rows;t++)for(let e=0;e<this.columns;e++)this.set(t,e,Math.clz32(this.get(t,e)));return this},t.clz32=function(t){return new e(t).clz32()},t.prototype.cos=function(){for(let t=0;t<this.rows;t++)for(let e=0;e<this.columns;e++)this.set(t,e,Math.cos(this.get(t,e)));return this},t.cos=function(t){return new e(t).cos()},t.prototype.cosh=function(){for(let t=0;t<this.rows;t++)for(let e=0;e<this.columns;e++)this.set(t,e,Math.cosh(this.get(t,e)));return this},t.cosh=function(t){return new e(t).cosh()},t.prototype.exp=function(){for(let t=0;t<this.rows;t++)for(let e=0;e<this.columns;e++)this.set(t,e,Math.exp(this.get(t,e)));return this},t.exp=function(t){return new e(t).exp()},t.prototype.expm1=function(){for(let t=0;t<this.rows;t++)for(let e=0;e<this.columns;e++)this.set(t,e,Math.expm1(this.get(t,e)));return this},t.expm1=function(t){return new e(t).expm1()},t.prototype.floor=function(){for(let t=0;t<this.rows;t++)for(let e=0;e<this.columns;e++)this.set(t,e,Math.floor(this.get(t,e)));return this},t.floor=function(t){return new e(t).floor()},t.prototype.fround=function(){for(let t=0;t<this.rows;t++)for(let e=0;e<this.columns;e++)this.set(t,e,Math.fround(this.get(t,e)));return this},t.fround=function(t){return new e(t).fround()},t.prototype.log=function(){for(let t=0;t<this.rows;t++)for(let e=0;e<this.columns;e++)this.set(t,e,Math.log(this.get(t,e)));return this},t.log=function(t){return new e(t).log()},t.prototype.log1p=function(){for(let t=0;t<this.rows;t++)for(let e=0;e<this.columns;e++)this.set(t,e,Math.log1p(this.get(t,e)));return this},t.log1p=function(t){return new e(t).log1p()},t.prototype.log10=function(){for(let t=0;t<this.rows;t++)for(let e=0;e<this.columns;e++)this.set(t,e,Math.log10(this.get(t,e)));return this},t.log10=function(t){return new e(t).log10()},t.prototype.log2=function(){for(let t=0;t<this.rows;t++)for(let e=0;e<this.columns;e++)this.set(t,e,Math.log2(this.get(t,e)));return this},t.log2=function(t){return new e(t).log2()},t.prototype.round=function(){for(let t=0;t<this.rows;t++)for(let e=0;e<this.columns;e++)this.set(t,e,Math.round(this.get(t,e)));return this},t.round=function(t){return new e(t).round()},t.prototype.sign=function(){for(let t=0;t<this.rows;t++)for(let e=0;e<this.columns;e++)this.set(t,e,Math.sign(this.get(t,e)));return this},t.sign=function(t){return new e(t).sign()},t.prototype.sin=function(){for(let t=0;t<this.rows;t++)for(let e=0;e<this.columns;e++)this.set(t,e,Math.sin(this.get(t,e)));return this},t.sin=function(t){return new e(t).sin()},t.prototype.sinh=function(){for(let t=0;t<this.rows;t++)for(let e=0;e<this.columns;e++)this.set(t,e,Math.sinh(this.get(t,e)));return this},t.sinh=function(t){return new e(t).sinh()},t.prototype.sqrt=function(){for(let t=0;t<this.rows;t++)for(let e=0;e<this.columns;e++)this.set(t,e,Math.sqrt(this.get(t,e)));return this},t.sqrt=function(t){return new e(t).sqrt()},t.prototype.tan=function(){for(let t=0;t<this.rows;t++)for(let e=0;e<this.columns;e++)this.set(t,e,Math.tan(this.get(t,e)));return this},t.tan=function(t){return new e(t).tan()},t.prototype.tanh=function(){for(let t=0;t<this.rows;t++)for(let e=0;e<this.columns;e++)this.set(t,e,Math.tanh(this.get(t,e)));return this},t.tanh=function(t){return new e(t).tanh()},t.prototype.trunc=function(){for(let t=0;t<this.rows;t++)for(let e=0;e<this.columns;e++)this.set(t,e,Math.trunc(this.get(t,e)));return this},t.trunc=function(t){return new e(t).trunc()},t.pow=function(t,n){return new e(t).pow(n)},t.prototype.pow=function(t){return"number"==typeof t?this.powS(t):this.powM(t)},t.prototype.powS=function(t){for(let e=0;e<this.rows;e++)for(let n=0;n<this.columns;n++)this.set(e,n,Math.pow(this.get(e,n),t));return this},t.prototype.powM=function(t){if(t=e.checkMatrix(t),this.rows!==t.rows||this.columns!==t.columns)throw new RangeError("Matrices dimensions must be equal");for(let e=0;e<this.rows;e++)for(let n=0;n<this.columns;n++)this.set(e,n,Math.pow(this.get(e,n),t.get(e,n)));return this}}(tv,nv);class rv extends tv{#e;get size(){return this.#e.size}get rows(){return this.#e.rows}get columns(){return this.#e.columns}get diagonalSize(){return this.rows}static isSymmetricMatrix(t){return nv.isMatrix(t)&&"SymmetricMatrix"===t.klassType}static zeros(t){return new this(t)}static ones(t){return new this(t).fill(1)}constructor(t){if(super(),nv.isMatrix(t)){if(!t.isSymmetric())throw new TypeError("not symmetric data");this.#e=nv.copy(t,new nv(t.rows,t.rows))}else if(Number.isInteger(t)&&t>=0)this.#e=new nv(t,t);else if(this.#e=new nv(t),!this.isSymmetric())throw new TypeError("not symmetric data")}clone(){const t=new rv(this.diagonalSize);for(const[e,n,r]of this.upperRightEntries())t.set(e,n,r);return t}toMatrix(){return new nv(this)}get(t,e){return this.#e.get(t,e)}set(t,e,n){return this.#e.set(t,e,n),this.#e.set(e,t,n),this}removeCross(t){return this.#e.removeRow(t),this.#e.removeColumn(t),this}addCross(t,e){void 0===e&&(e=t,t=this.diagonalSize);const n=e.slice();return n.splice(t,1),this.#e.addRow(t,n),this.#e.addColumn(t,e),this}applyMask(t){if(t.length!==this.diagonalSize)throw new RangeError("Mask size do not match with matrix size");const e=[];for(const[n,r]of t.entries())r||e.push(n);e.reverse();for(const t of e)this.removeCross(t);return this}toCompact(){const{diagonalSize:t}=this,e=new Array(t*(t+1)/2);for(let n=0,r=0,i=0;i<e.length;i++)e[i]=this.get(r,n),++n>=t&&(n=++r);return e}static fromCompact(t){const e=t.length,n=(Math.sqrt(8*e+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 r=new rv(n);for(let i=0,o=0,a=0;a<e;a++)r.set(i,o,t[a]),++i>=n&&(i=++o);return r}*upperRightEntries(){for(let t=0,e=0;t<this.diagonalSize;void 0){const n=this.get(t,e);yield[t,e,n],++e>=this.diagonalSize&&(e=++t)}}*upperRightValues(){for(let t=0,e=0;t<this.diagonalSize;void 0){const n=this.get(t,e);yield n,++e>=this.diagonalSize&&(e=++t)}}}rv.prototype.klassType="SymmetricMatrix";class iv extends rv{static isDistanceMatrix(t){return rv.isSymmetricMatrix(t)&&"DistanceMatrix"===t.klassSubType}constructor(t){if(super(t),!this.isDistance())throw new TypeError("Provided arguments do no produce a distance matrix")}set(t,e,n){return t===e&&(n=0),super.set(t,e,n)}addCross(t,e){return void 0===e&&(e=t,t=this.diagonalSize),(e=e.slice())[t]=0,super.addCross(t,e)}toSymmetricMatrix(){return new rv(this)}clone(){const t=new iv(this.diagonalSize);for(const[e,n,r]of this.upperRightEntries())e!==n&&t.set(e,n,r);return t}toCompact(){const{diagonalSize:t}=this,e=new Array((t-1)*t/2);for(let n=1,r=0,i=0;i<e.length;i++)e[i]=this.get(r,n),++n>=t&&(n=1+ ++r);return e}static fromCompact(t){const e=t.length,n=(Math.sqrt(8*e+1)+1)/2;if(!Number.isInteger(n))throw new TypeError(`This array is not a compact representation of a DistanceMatrix, ${JSON.stringify(t)}`);const r=new this(n);for(let i=1,o=0,a=0;a<e;a++)r.set(i,o,t[a]),++i>=n&&(i=1+ ++o);return r}}iv.prototype.klassSubType="DistanceMatrix";class ov extends tv{constructor(t,e,n){super(),this.matrix=t,this.rows=e,this.columns=n}}class av extends ov{constructor(t,e,n){$m(t,e),Xm(t,n),super(t,e.length,n.length),this.rowIndices=e,this.columnIndices=n}set(t,e,n){return this.matrix.set(this.rowIndices[t],this.columnIndices[e],n),this}get(t,e){return this.matrix.get(this.rowIndices[t],this.columnIndices[e])}}class sv extends tv{constructor(t,e={}){const{rows:n=1}=e;if(t.length%n!=0)throw new Error("the data length is not divisible by the number of rows");super(),this.rows=n,this.columns=t.length/n,this.data=t}set(t,e,n){let r=this._calculateIndex(t,e);return this.data[r]=n,this}get(t,e){let n=this._calculateIndex(t,e);return this.data[n]}_calculateIndex(t,e){return t*this.columns+e}}class uv extends tv{constructor(t){super(),this.data=t,this.rows=t.length,this.columns=t[0].length}set(t,e,n){return this.data[t][e]=n,this}get(t,e){return this.data[t][e]}}class cv{constructor(t){let e,n,r,i,o,a,s,u,c,h=(t=uv.checkMatrix(t)).clone(),l=h.rows,d=h.columns,f=new Float64Array(l),p=1;for(e=0;e<l;e++)f[e]=e;for(u=new Float64Array(l),n=0;n<d;n++){for(e=0;e<l;e++)u[e]=h.get(e,n);for(e=0;e<l;e++){for(c=Math.min(e,n),o=0,r=0;r<c;r++)o+=h.get(e,r)*u[r];u[e]-=o,h.set(e,n,u[e])}for(i=n,e=n+1;e<l;e++)Math.abs(u[e])>Math.abs(u[i])&&(i=e);if(i!==n){for(r=0;r<d;r++)a=h.get(i,r),h.set(i,r,h.get(n,r)),h.set(n,r,a);s=f[i],f[i]=f[n],f[n]=s,p=-p}if(n<l&&0!==h.get(n,n))for(e=n+1;e<l;e++)h.set(e,n,h.get(e,n)/h.get(n,n))}this.LU=h,this.pivotVector=f,this.pivotSign=p}isSingular(){let t=this.LU,e=t.columns;for(let n=0;n<e;n++)if(0===t.get(n,n))return!0;return!1}solve(t){t=nv.checkMatrix(t);let e=this.LU;if(e.rows!==t.rows)throw new Error("Invalid matrix dimensions");if(this.isSingular())throw new Error("LU matrix is singular");let n,r,i,o=t.columns,a=t.subMatrixRow(this.pivotVector,0,o-1),s=e.columns;for(i=0;i<s;i++)for(n=i+1;n<s;n++)for(r=0;r<o;r++)a.set(n,r,a.get(n,r)-a.get(i,r)*e.get(n,i));for(i=s-1;i>=0;i--){for(r=0;r<o;r++)a.set(i,r,a.get(i,r)/e.get(i,i));for(n=0;n<i;n++)for(r=0;r<o;r++)a.set(n,r,a.get(n,r)-a.get(i,r)*e.get(n,i))}return a}get determinant(){let t=this.LU;if(!t.isSquare())throw new Error("Matrix must be square");let e=this.pivotSign,n=t.columns;for(let r=0;r<n;r++)e*=t.get(r,r);return e}get lowerTriangularMatrix(){let t=this.LU,e=t.rows,n=t.columns,r=new nv(e,n);for(let i=0;i<e;i++)for(let e=0;e<n;e++)i>e?r.set(i,e,t.get(i,e)):i===e?r.set(i,e,1):r.set(i,e,0);return r}get upperTriangularMatrix(){let t=this.LU,e=t.rows,n=t.columns,r=new nv(e,n);for(let i=0;i<e;i++)for(let e=0;e<n;e++)i<=e?r.set(i,e,t.get(i,e)):r.set(i,e,0);return r}get pivotPermutationVector(){return Array.from(this.pivotVector)}}function hv(t,e){let n=0;return Math.abs(t)>Math.abs(e)?(n=e/t,Math.abs(t)*Math.sqrt(1+n*n)):0!==e?(n=t/e,Math.abs(e)*Math.sqrt(1+n*n)):0}class lv{constructor(t){let e,n,r,i,o=(t=uv.checkMatrix(t)).clone(),a=t.rows,s=t.columns,u=new Float64Array(s);for(r=0;r<s;r++){let t=0;for(e=r;e<a;e++)t=hv(t,o.get(e,r));if(0!==t){for(o.get(r,r)<0&&(t=-t),e=r;e<a;e++)o.set(e,r,o.get(e,r)/t);for(o.set(r,r,o.get(r,r)+1),n=r+1;n<s;n++){for(i=0,e=r;e<a;e++)i+=o.get(e,r)*o.get(e,n);for(i=-i/o.get(r,r),e=r;e<a;e++)o.set(e,n,o.get(e,n)+i*o.get(e,r))}}u[r]=-t}this.QR=o,this.Rdiag=u}solve(t){t=nv.checkMatrix(t);let e=this.QR,n=e.rows;if(t.rows!==n)throw new Error("Matrix row dimensions must agree");if(!this.isFullRank())throw new Error("Matrix is rank deficient");let r,i,o,a,s=t.columns,u=t.clone(),c=e.columns;for(o=0;o<c;o++)for(i=0;i<s;i++){for(a=0,r=o;r<n;r++)a+=e.get(r,o)*u.get(r,i);for(a=-a/e.get(o,o),r=o;r<n;r++)u.set(r,i,u.get(r,i)+a*e.get(r,o))}for(o=c-1;o>=0;o--){for(i=0;i<s;i++)u.set(o,i,u.get(o,i)/this.Rdiag[o]);for(r=0;r<o;r++)for(i=0;i<s;i++)u.set(r,i,u.get(r,i)-u.get(o,i)*e.get(r,o))}return u.subMatrix(0,c-1,0,s-1)}isFullRank(){let t=this.QR.columns;for(let e=0;e<t;e++)if(0===this.Rdiag[e])return!1;return!0}get upperTriangularMatrix(){let t,e,n=this.QR,r=n.columns,i=new nv(r,r);for(t=0;t<r;t++)for(e=0;e<r;e++)t<e?i.set(t,e,n.get(t,e)):t===e?i.set(t,e,this.Rdiag[t]):i.set(t,e,0);return i}get orthogonalMatrix(){let t,e,n,r,i=this.QR,o=i.rows,a=i.columns,s=new nv(o,a);for(n=a-1;n>=0;n--){for(t=0;t<o;t++)s.set(t,n,0);for(s.set(n,n,1),e=n;e<a;e++)if(0!==i.get(n,n)){for(r=0,t=n;t<o;t++)r+=i.get(t,n)*s.get(t,e);for(r=-r/i.get(n,n),t=n;t<o;t++)s.set(t,e,s.get(t,e)+r*i.get(t,n))}}return s}}let dv=class{constructor(t,e={}){if((t=uv.checkMatrix(t)).isEmpty())throw new Error("Matrix must be non-empty");let n=t.rows,r=t.columns;const{computeLeftSingularVectors:i=!0,computeRightSingularVectors:o=!0,autoTranspose:a=!1}=e;let s,u=Boolean(i),c=Boolean(o),h=!1;if(n<r)if(a){s=t.transpose(),n=s.rows,r=s.columns,h=!0;let e=u;u=c,c=e}else s=t.clone(),console.warn("Computing SVD on a matrix with more columns than rows. Consider enabling autoTranspose");else s=t.clone();let l=Math.min(n,r),d=Math.min(n+1,r),f=new Float64Array(d),p=new nv(n,l),g=new nv(r,r),m=new Float64Array(r),v=new Float64Array(n),y=new Float64Array(d);for(let t=0;t<d;t++)y[t]=t;let b=Math.min(n-1,r),E=Math.max(0,Math.min(r-2,n)),w=Math.max(b,E);for(let t=0;t<w;t++){if(t<b){f[t]=0;for(let e=t;e<n;e++)f[t]=hv(f[t],s.get(e,t));if(0!==f[t]){s.get(t,t)<0&&(f[t]=-f[t]);for(let e=t;e<n;e++)s.set(e,t,s.get(e,t)/f[t]);s.set(t,t,s.get(t,t)+1)}f[t]=-f[t]}for(let e=t+1;e<r;e++){if(t<b&&0!==f[t]){let r=0;for(let i=t;i<n;i++)r+=s.get(i,t)*s.get(i,e);r=-r/s.get(t,t);for(let i=t;i<n;i++)s.set(i,e,s.get(i,e)+r*s.get(i,t))}m[e]=s.get(t,e)}if(u&&t<b)for(let e=t;e<n;e++)p.set(e,t,s.get(e,t));if(t<E){m[t]=0;for(let e=t+1;e<r;e++)m[t]=hv(m[t],m[e]);if(0!==m[t]){m[t+1]<0&&(m[t]=0-m[t]);for(let e=t+1;e<r;e++)m[e]/=m[t];m[t+1]+=1}if(m[t]=-m[t],t+1<n&&0!==m[t]){for(let e=t+1;e<n;e++)v[e]=0;for(let e=t+1;e<n;e++)for(let n=t+1;n<r;n++)v[e]+=m[n]*s.get(e,n);for(let e=t+1;e<r;e++){let r=-m[e]/m[t+1];for(let i=t+1;i<n;i++)s.set(i,e,s.get(i,e)+r*v[i])}}if(c)for(let e=t+1;e<r;e++)g.set(e,t,m[e])}}let x=Math.min(r,n+1);if(b<r&&(f[b]=s.get(b,b)),n<x&&(f[x-1]=0),E+1<x&&(m[E]=s.get(E,x-1)),m[x-1]=0,u){for(let t=b;t<l;t++){for(let e=0;e<n;e++)p.set(e,t,0);p.set(t,t,1)}for(let t=b-1;t>=0;t--)if(0!==f[t]){for(let e=t+1;e<l;e++){let r=0;for(let i=t;i<n;i++)r+=p.get(i,t)*p.get(i,e);r=-r/p.get(t,t);for(let i=t;i<n;i++)p.set(i,e,p.get(i,e)+r*p.get(i,t))}for(let e=t;e<n;e++)p.set(e,t,-p.get(e,t));p.set(t,t,1+p.get(t,t));for(let e=0;e<t-1;e++)p.set(e,t,0)}else{for(let e=0;e<n;e++)p.set(e,t,0);p.set(t,t,1)}}if(c)for(let t=r-1;t>=0;t--){if(t<E&&0!==m[t])for(let e=t+1;e<r;e++){let n=0;for(let i=t+1;i<r;i++)n+=g.get(i,t)*g.get(i,e);n=-n/g.get(t+1,t);for(let i=t+1;i<r;i++)g.set(i,e,g.get(i,e)+n*g.get(i,t))}for(let e=0;e<r;e++)g.set(e,t,0);g.set(t,t,1)}let M=x-1,N=Number.EPSILON;for(;x>0;){let t,e;for(t=x-2;t>=-1&&-1!==t;t--){const e=Number.MIN_VALUE+N*Math.abs(f[t]+Math.abs(f[t+1]));if(Math.abs(m[t])<=e||Number.isNaN(m[t])){m[t]=0;break}}if(t===x-2)e=4;else{let n;for(n=x-1;n>=t&&n!==t;n--){let e=(n!==x?Math.abs(m[n]):0)+(n!==t+1?Math.abs(m[n-1]):0);if(Math.abs(f[n])<=N*e){f[n]=0;break}}n===t?e=3:n===x-1?e=1:(e=2,t=n)}switch(t++,e){case 1:{let e=m[x-2];m[x-2]=0;for(let n=x-2;n>=t;n--){let i=hv(f[n],e),o=f[n]/i,a=e/i;if(f[n]=i,n!==t&&(e=-a*m[n-1],m[n-1]=o*m[n-1]),c)for(let t=0;t<r;t++)i=o*g.get(t,n)+a*g.get(t,x-1),g.set(t,x-1,-a*g.get(t,n)+o*g.get(t,x-1)),g.set(t,n,i)}break}case 2:{let e=m[t-1];m[t-1]=0;for(let r=t;r<x;r++){let i=hv(f[r],e),o=f[r]/i,a=e/i;if(f[r]=i,e=-a*m[r],m[r]=o*m[r],u)for(let e=0;e<n;e++)i=o*p.get(e,r)+a*p.get(e,t-1),p.set(e,t-1,-a*p.get(e,r)+o*p.get(e,t-1)),p.set(e,r,i)}break}case 3:{const e=Math.max(Math.abs(f[x-1]),Math.abs(f[x-2]),Math.abs(m[x-2]),Math.abs(f[t]),Math.abs(m[t])),i=f[x-1]/e,o=f[x-2]/e,a=m[x-2]/e,s=f[t]/e,h=m[t]/e,l=((o+i)*(o-i)+a*a)/2,d=i*a*(i*a);let v=0;0===l&&0===d||(v=l<0?0-Math.sqrt(l*l+d):Math.sqrt(l*l+d),v=d/(l+v));let y=(s+i)*(s-i)+v,b=s*h;for(let e=t;e<x-1;e++){let i=hv(y,b);0===i&&(i=Number.MIN_VALUE);let o=y/i,a=b/i;if(e!==t&&(m[e-1]=i),y=o*f[e]+a*m[e],m[e]=o*m[e]-a*f[e],b=a*f[e+1],f[e+1]=o*f[e+1],c)for(let t=0;t<r;t++)i=o*g.get(t,e)+a*g.get(t,e+1),g.set(t,e+1,-a*g.get(t,e)+o*g.get(t,e+1)),g.set(t,e,i);if(i=hv(y,b),0===i&&(i=Number.MIN_VALUE),o=y/i,a=b/i,f[e]=i,y=o*m[e]+a*f[e+1],f[e+1]=-a*m[e]+o*f[e+1],b=a*m[e+1],m[e+1]=o*m[e+1],u&&e<n-1)for(let t=0;t<n;t++)i=o*p.get(t,e)+a*p.get(t,e+1),p.set(t,e+1,-a*p.get(t,e)+o*p.get(t,e+1)),p.set(t,e,i)}m[x-2]=y;break}case 4:if(f[t]<=0&&(f[t]=f[t]<0?-f[t]:0,c))for(let e=0;e<=M;e++)g.set(e,t,-g.get(e,t));for(;t<M&&!(f[t]>=f[t+1]);){let e=f[t];if(f[t]=f[t+1],f[t+1]=e,c&&t<r-1)for(let n=0;n<r;n++)e=g.get(n,t+1),g.set(n,t+1,g.get(n,t)),g.set(n,t,e);if(u&&t<n-1)for(let r=0;r<n;r++)e=p.get(r,t+1),p.set(r,t+1,p.get(r,t)),p.set(r,t,e);t++}x--}}if(h){let t=g;g=p,p=t}this.m=n,this.n=r,this.s=f,this.U=p,this.V=g}solve(t){let e=t,n=this.threshold,r=this.s.length,i=nv.zeros(r,r);for(let t=0;t<r;t++)Math.abs(this.s[t])<=n?i.set(t,t,0):i.set(t,t,1/this.s[t]);let o=this.U,a=this.rightSingularVectors,s=a.mmul(i),u=a.rows,c=o.rows,h=nv.zeros(u,c);for(let t=0;t<u;t++)for(let e=0;e<c;e++){let n=0;for(let i=0;i<r;i++)n+=s.get(t,i)*o.get(e,i);h.set(t,e,n)}return h.mmul(e)}solveForDiagonal(t){return this.solve(nv.diag(t))}inverse(){let t=this.V,e=this.threshold,n=t.rows,r=t.columns,i=new nv(n,this.s.length);for(let o=0;o<n;o++)for(let n=0;n<r;n++)Math.abs(this.s[n])>e&&i.set(o,n,t.get(o,n)/this.s[n]);let o=this.U,a=o.rows,s=o.columns,u=new nv(n,a);for(let t=0;t<n;t++)for(let e=0;e<a;e++){let n=0;for(let r=0;r<s;r++)n+=i.get(t,r)*o.get(e,r);u.set(t,e,n)}return u}get condition(){return this.s[0]/this.s[Math.min(this.m,this.n)-1]}get norm2(){return this.s[0]}get rank(){let t=Math.max(this.m,this.n)*this.s[0]*Number.EPSILON,e=0,n=this.s;for(let r=0,i=n.length;r<i;r++)n[r]>t&&e++;return e}get diagonal(){return Array.from(this.s)}get threshold(){return Number.EPSILON/2*Math.max(this.m,this.n)*this.s[0]}get leftSingularVectors(){return this.U}get rightSingularVectors(){return this.V}get diagonalMatrix(){return nv.diag(this.s)}};function fv(t,e,n=!1){return t=uv.checkMatrix(t),e=uv.checkMatrix(e),n?new dv(t).solve(e):t.isSquare()?new cv(t).solve(e):new lv(t).solve(e)}function pv(t,e){let n=[];for(let r=0;r<t;r++)r!==e&&n.push(r);return n}function gv(t,e,n,r=1e-9,i=1e-9){if(t>i)return new Array(e.rows+1).fill(0);{let t=e.addRow(n,[0]);for(let e=0;e<t.rows;e++)Math.abs(t.get(e,0))<r&&t.set(e,0,0);return t.to1DArray()}}class mv{constructor(t,e={}){const{assumeSymmetric:n=!1}=e;if(!(t=uv.checkMatrix(t)).isSquare())throw new Error("Matrix is not a square matrix");if(t.isEmpty())throw new Error("Matrix must be non-empty");let r,i,o=t.columns,a=new nv(o,o),s=new Float64Array(o),u=new Float64Array(o),c=t,h=!1;if(h=!!n||t.isSymmetric(),h){for(r=0;r<o;r++)for(i=0;i<o;i++)a.set(r,i,c.get(r,i));!function(t,e,n,r){let i,o,a,s,u,c,h,l;for(u=0;u<t;u++)n[u]=r.get(t-1,u);for(s=t-1;s>0;s--){for(l=0,a=0,c=0;c<s;c++)l+=Math.abs(n[c]);if(0===l)for(e[s]=n[s-1],u=0;u<s;u++)n[u]=r.get(s-1,u),r.set(s,u,0),r.set(u,s,0);else{for(c=0;c<s;c++)n[c]/=l,a+=n[c]*n[c];for(i=n[s-1],o=Math.sqrt(a),i>0&&(o=-o),e[s]=l*o,a-=i*o,n[s-1]=i-o,u=0;u<s;u++)e[u]=0;for(u=0;u<s;u++){for(i=n[u],r.set(u,s,i),o=e[u]+r.get(u,u)*i,c=u+1;c<=s-1;c++)o+=r.get(c,u)*n[c],e[c]+=r.get(c,u)*i;e[u]=o}for(i=0,u=0;u<s;u++)e[u]/=a,i+=e[u]*n[u];for(h=i/(a+a),u=0;u<s;u++)e[u]-=h*n[u];for(u=0;u<s;u++){for(i=n[u],o=e[u],c=u;c<=s-1;c++)r.set(c,u,r.get(c,u)-(i*e[c]+o*n[c]));n[u]=r.get(s-1,u),r.set(s,u,0)}}n[s]=a}for(s=0;s<t-1;s++){if(r.set(t-1,s,r.get(s,s)),r.set(s,s,1),a=n[s+1],0!==a){for(c=0;c<=s;c++)n[c]=r.get(c,s+1)/a;for(u=0;u<=s;u++){for(o=0,c=0;c<=s;c++)o+=r.get(c,s+1)*r.get(c,u);for(c=0;c<=s;c++)r.set(c,u,r.get(c,u)-o*n[c])}}for(c=0;c<=s;c++)r.set(c,s+1,0)}for(u=0;u<t;u++)n[u]=r.get(t-1,u),r.set(t-1,u,0);r.set(t-1,t-1,1),e[0]=0}(o,u,s,a),function(t,e,n,r){let i,o,a,s,u,c,h,l,d,f,p,g,m,v,y,b;for(a=1;a<t;a++)e[a-1]=e[a];e[t-1]=0;let E=0,w=0,x=Number.EPSILON;for(c=0;c<t;c++){for(w=Math.max(w,Math.abs(n[c])+Math.abs(e[c])),h=c;h<t&&!(Math.abs(e[h])<=x*w);)h++;if(h>c)do{for(i=n[c],l=(n[c+1]-i)/(2*e[c]),d=hv(l,1),l<0&&(d=-d),n[c]=e[c]/(l+d),n[c+1]=e[c]*(l+d),f=n[c+1],o=i-n[c],a=c+2;a<t;a++)n[a]-=o;for(E+=o,l=n[h],p=1,g=p,m=p,v=e[c+1],y=0,b=0,a=h-1;a>=c;a--)for(m=g,g=p,b=y,i=p*e[a],o=p*l,d=hv(l,e[a]),e[a+1]=y*d,y=e[a]/d,p=l/d,l=p*n[a]-y*i,n[a+1]=o+y*(p*i+y*n[a]),u=0;u<t;u++)o=r.get(u,a+1),r.set(u,a+1,y*r.get(u,a)+p*o),r.set(u,a,p*r.get(u,a)-y*o);l=-y*b*m*v*e[c]/f,e[c]=y*l,n[c]=p*l}while(Math.abs(e[c])>x*w);n[c]=n[c]+E,e[c]=0}for(a=0;a<t-1;a++){for(u=a,l=n[a],s=a+1;s<t;s++)n[s]<l&&(u=s,l=n[s]);if(u!==a)for(n[u]=n[a],n[a]=l,s=0;s<t;s++)l=r.get(s,a),r.set(s,a,r.get(s,u)),r.set(s,u,l)}}(o,u,s,a)}else{let t=new nv(o,o),e=new Float64Array(o);for(i=0;i<o;i++)for(r=0;r<o;r++)t.set(r,i,c.get(r,i));!function(t,e,n,r){let i,o,a,s,u,c,h,l=0,d=t-1;for(c=l+1;c<=d-1;c++){for(h=0,s=c;s<=d;s++)h+=Math.abs(e.get(s,c-1));if(0!==h){for(a=0,s=d;s>=c;s--)n[s]=e.get(s,c-1)/h,a+=n[s]*n[s];for(o=Math.sqrt(a),n[c]>0&&(o=-o),a-=n[c]*o,n[c]=n[c]-o,u=c;u<t;u++){for(i=0,s=d;s>=c;s--)i+=n[s]*e.get(s,u);for(i/=a,s=c;s<=d;s++)e.set(s,u,e.get(s,u)-i*n[s])}for(s=0;s<=d;s++){for(i=0,u=d;u>=c;u--)i+=n[u]*e.get(s,u);for(i/=a,u=c;u<=d;u++)e.set(s,u,e.get(s,u)-i*n[u])}n[c]=h*n[c],e.set(c,c-1,h*o)}}for(s=0;s<t;s++)for(u=0;u<t;u++)r.set(s,u,s===u?1:0);for(c=d-1;c>=l+1;c--)if(0!==e.get(c,c-1)){for(s=c+1;s<=d;s++)n[s]=e.get(s,c-1);for(u=c;u<=d;u++){for(o=0,s=c;s<=d;s++)o+=n[s]*r.get(s,u);for(o=o/n[c]/e.get(c,c-1),s=c;s<=d;s++)r.set(s,u,r.get(s,u)+o*n[s])}}}(o,t,e,a),function(t,e,n,r,i){let o,a,s,u,c,h,l,d,f,p,g,m,v,y,b,E=t-1,w=0,x=t-1,M=Number.EPSILON,N=0,S=0,T=0,k=0,P=0,C=0,A=0,O=0;for(o=0;o<t;o++)for((o<w||o>x)&&(n[o]=i.get(o,o),e[o]=0),a=Math.max(o-1,0);a<t;a++)S+=Math.abs(i.get(o,a));for(;E>=w;){for(u=E;u>w&&(C=Math.abs(i.get(u-1,u-1))+Math.abs(i.get(u,u)),0===C&&(C=S),!(Math.abs(i.get(u,u-1))<M*C));)u--;if(u===E)i.set(E,E,i.get(E,E)+N),n[E]=i.get(E,E),e[E]=0,E--,O=0;else if(u===E-1){if(l=i.get(E,E-1)*i.get(E-1,E),T=(i.get(E-1,E-1)-i.get(E,E))/2,k=T*T+l,A=Math.sqrt(Math.abs(k)),i.set(E,E,i.get(E,E)+N),i.set(E-1,E-1,i.get(E-1,E-1)+N),d=i.get(E,E),k>=0){for(A=T>=0?T+A:T-A,n[E-1]=d+A,n[E]=n[E-1],0!==A&&(n[E]=d-l/A),e[E-1]=0,e[E]=0,d=i.get(E,E-1),C=Math.abs(d)+Math.abs(A),T=d/C,k=A/C,P=Math.sqrt(T*T+k*k),T/=P,k/=P,a=E-1;a<t;a++)A=i.get(E-1,a),i.set(E-1,a,k*A+T*i.get(E,a)),i.set(E,a,k*i.get(E,a)-T*A);for(o=0;o<=E;o++)A=i.get(o,E-1),i.set(o,E-1,k*A+T*i.get(o,E)),i.set(o,E,k*i.get(o,E)-T*A);for(o=w;o<=x;o++)A=r.get(o,E-1),r.set(o,E-1,k*A+T*r.get(o,E)),r.set(o,E,k*r.get(o,E)-T*A)}else n[E-1]=d+T,n[E]=d+T,e[E-1]=A,e[E]=-A;E-=2,O=0}else{if(d=i.get(E,E),f=0,l=0,u<E&&(f=i.get(E-1,E-1),l=i.get(E,E-1)*i.get(E-1,E)),10===O){for(N+=d,o=w;o<=E;o++)i.set(o,o,i.get(o,o)-d);C=Math.abs(i.get(E,E-1))+Math.abs(i.get(E-1,E-2)),d=f=.75*C,l=-.4375*C*C}if(30===O&&(C=(f-d)/2,C=C*C+l,C>0)){for(C=Math.sqrt(C),f<d&&(C=-C),C=d-l/((f-d)/2+C),o=w;o<=E;o++)i.set(o,o,i.get(o,o)-C);N+=C,d=f=l=.964}for(O+=1,c=E-2;c>=u&&(A=i.get(c,c),P=d-A,C=f-A,T=(P*C-l)/i.get(c+1,c)+i.get(c,c+1),k=i.get(c+1,c+1)-A-P-C,P=i.get(c+2,c+1),C=Math.abs(T)+Math.abs(k)+Math.abs(P),T/=C,k/=C,P/=C,c!==u)&&!(Math.abs(i.get(c,c-1))*(Math.abs(k)+Math.abs(P))<M*(Math.abs(T)*(Math.abs(i.get(c-1,c-1))+Math.abs(A)+Math.abs(i.get(c+1,c+1)))));)c--;for(o=c+2;o<=E;o++)i.set(o,o-2,0),o>c+2&&i.set(o,o-3,0);for(s=c;s<=E-1&&(y=s!==E-1,s!==c&&(T=i.get(s,s-1),k=i.get(s+1,s-1),P=y?i.get(s+2,s-1):0,d=Math.abs(T)+Math.abs(k)+Math.abs(P),0!==d&&(T/=d,k/=d,P/=d)),0!==d);s++)if(C=Math.sqrt(T*T+k*k+P*P),T<0&&(C=-C),0!==C){for(s!==c?i.set(s,s-1,-C*d):u!==c&&i.set(s,s-1,-i.get(s,s-1)),T+=C,d=T/C,f=k/C,A=P/C,k/=T,P/=T,a=s;a<t;a++)T=i.get(s,a)+k*i.get(s+1,a),y&&(T+=P*i.get(s+2,a),i.set(s+2,a,i.get(s+2,a)-T*A)),i.set(s,a,i.get(s,a)-T*d),i.set(s+1,a,i.get(s+1,a)-T*f);for(o=0;o<=Math.min(E,s+3);o++)T=d*i.get(o,s)+f*i.get(o,s+1),y&&(T+=A*i.get(o,s+2),i.set(o,s+2,i.get(o,s+2)-T*P)),i.set(o,s,i.get(o,s)-T),i.set(o,s+1,i.get(o,s+1)-T*k);for(o=w;o<=x;o++)T=d*r.get(o,s)+f*r.get(o,s+1),y&&(T+=A*r.get(o,s+2),r.set(o,s+2,r.get(o,s+2)-T*P)),r.set(o,s,r.get(o,s)-T),r.set(o,s+1,r.get(o,s+1)-T*k)}}}if(0===S)return;for(E=t-1;E>=0;E--)if(T=n[E],k=e[E],0===k)for(u=E,i.set(E,E,1),o=E-1;o>=0;o--){for(l=i.get(o,o)-T,P=0,a=u;a<=E;a++)P+=i.get(o,a)*i.get(a,E);if(e[o]<0)A=l,C=P;else if(u=o,0===e[o]?i.set(o,E,0!==l?-P/l:-P/(M*S)):(d=i.get(o,o+1),f=i.get(o+1,o),k=(n[o]-T)*(n[o]-T)+e[o]*e[o],h=(d*C-A*P)/k,i.set(o,E,h),i.set(o+1,E,Math.abs(d)>Math.abs(A)?(-P-l*h)/d:(-C-f*h)/A)),h=Math.abs(i.get(o,E)),M*h*h>1)for(a=o;a<=E;a++)i.set(a,E,i.get(a,E)/h)}else if(k<0)for(u=E-1,Math.abs(i.get(E,E-1))>Math.abs(i.get(E-1,E))?(i.set(E-1,E-1,k/i.get(E,E-1)),i.set(E-1,E,-(i.get(E,E)-T)/i.get(E,E-1))):(b=vv(0,-i.get(E-1,E),i.get(E-1,E-1)-T,k),i.set(E-1,E-1,b[0]),i.set(E-1,E,b[1])),i.set(E,E-1,0),i.set(E,E,1),o=E-2;o>=0;o--){for(p=0,g=0,a=u;a<=E;a++)p+=i.get(o,a)*i.get(a,E-1),g+=i.get(o,a)*i.get(a,E);if(l=i.get(o,o)-T,e[o]<0)A=l,P=p,C=g;else if(u=o,0===e[o]?(b=vv(-p,-g,l,k),i.set(o,E-1,b[0]),i.set(o,E,b[1])):(d=i.get(o,o+1),f=i.get(o+1,o),m=(n[o]-T)*(n[o]-T)+e[o]*e[o]-k*k,v=2*(n[o]-T)*k,0===m&&0===v&&(m=M*S*(Math.abs(l)+Math.abs(k)+Math.abs(d)+Math.abs(f)+Math.abs(A))),b=vv(d*P-A*p+k*g,d*C-A*g-k*p,m,v),i.set(o,E-1,b[0]),i.set(o,E,b[1]),Math.abs(d)>Math.abs(A)+Math.abs(k)?(i.set(o+1,E-1,(-p-l*i.get(o,E-1)+k*i.get(o,E))/d),i.set(o+1,E,(-g-l*i.get(o,E)-k*i.get(o,E-1))/d)):(b=vv(-P-f*i.get(o,E-1),-C-f*i.get(o,E),A,k),i.set(o+1,E-1,b[0]),i.set(o+1,E,b[1]))),h=Math.max(Math.abs(i.get(o,E-1)),Math.abs(i.get(o,E))),M*h*h>1)for(a=o;a<=E;a++)i.set(a,E-1,i.get(a,E-1)/h),i.set(a,E,i.get(a,E)/h)}for(o=0;o<t;o++)if(o<w||o>x)for(a=o;a<t;a++)r.set(o,a,i.get(o,a));for(a=t-1;a>=w;a--)for(o=w;o<=x;o++){for(A=0,s=w;s<=Math.min(a,x);s++)A+=r.get(o,s)*i.get(s,a);r.set(o,a,A)}}(o,u,s,a,t)}this.n=o,this.e=u,this.d=s,this.V=a}get realEigenvalues(){return Array.from(this.d)}get imaginaryEigenvalues(){return Array.from(this.e)}get eigenvectorMatrix(){return this.V}get diagonalMatrix(){let t,e,n=this.n,r=this.e,i=this.d,o=new nv(n,n);for(t=0;t<n;t++){for(e=0;e<n;e++)o.set(t,e,0);o.set(t,t,i[t]),r[t]>0?o.set(t,t+1,r[t]):r[t]<0&&o.set(t,t-1,r[t])}return o}}function vv(t,e,n,r){let i,o;return Math.abs(n)>Math.abs(r)?(i=r/n,o=n+i*r,[(t+i*e)/o,(e-i*t)/o]):(i=n/r,o=r+i*n,[(i*t+e)/o,(i*e-t)/o])}class yv{constructor(t){if(!(t=uv.checkMatrix(t)).isSymmetric())throw new Error("Matrix is not symmetric");let e,n,r,i=t,o=i.rows,a=new nv(o,o),s=!0;for(n=0;n<o;n++){let t=0;for(r=0;r<n;r++){let o=0;for(e=0;e<r;e++)o+=a.get(r,e)*a.get(n,e);o=(i.get(n,r)-o)/a.get(r,r),a.set(n,r,o),t+=o*o}for(t=i.get(n,n)-t,s&=t>0,a.set(n,n,Math.sqrt(Math.max(t,0))),r=n+1;r<o;r++)a.set(n,r,0)}this.L=a,this.positiveDefinite=Boolean(s)}isPositiveDefinite(){return this.positiveDefinite}solve(t){t=uv.checkMatrix(t);let e=this.L,n=e.rows;if(t.rows!==n)throw new Error("Matrix dimensions do not match");if(!1===this.isPositiveDefinite())throw new Error("Matrix is not positive definite");let r,i,o,a=t.columns,s=t.clone();for(o=0;o<n;o++)for(i=0;i<a;i++){for(r=0;r<o;r++)s.set(o,i,s.get(o,i)-s.get(r,i)*e.get(o,r));s.set(o,i,s.get(o,i)/e.get(o,o))}for(o=n-1;o>=0;o--)for(i=0;i<a;i++){for(r=o+1;r<n;r++)s.set(o,i,s.get(o,i)-s.get(r,i)*e.get(r,o));s.set(o,i,s.get(o,i)/e.get(o,o))}return s}get lowerTriangularMatrix(){return this.L}}class bv{constructor(t,e={}){t=uv.checkMatrix(t);let{Y:n}=e;const{scaleScores:r=!1,maxIterations:i=1e3,terminationCriteria:o=1e-10}=e;let a;if(n){if(n=jm.isAnyArray(n)&&"number"==typeof n[0]?nv.columnVector(n):uv.checkMatrix(n),n.rows!==t.rows)throw new Error("Y should have the same number of rows as X");a=n.getColumnVector(0)}else a=t.getColumnVector(0);let s,u,c,h,l=1;for(let e=0;e<i&&l>o;e++)c=t.transpose().mmul(a).div(a.transpose().mmul(a).get(0,0)),c=c.div(c.norm()),s=t.mmul(c).div(c.transpose().mmul(c).get(0,0)),e>0&&(l=s.clone().sub(h).pow(2).sum()),h=s.clone(),n?(u=n.transpose().mmul(s).div(s.transpose().mmul(s).get(0,0)),u=u.div(u.norm()),a=n.mmul(u).div(u.transpose().mmul(u).get(0,0))):a=s;if(n){let e=t.transpose().mmul(s).div(s.transpose().mmul(s).get(0,0));e=e.div(e.norm());let r=t.clone().sub(s.clone().mmul(e.transpose())),i=a.transpose().mmul(s).div(s.transpose().mmul(s).get(0,0)),o=n.clone().sub(s.clone().mulS(i.get(0,0)).mmul(u.transpose()));this.t=s,this.p=e.transpose(),this.w=c.transpose(),this.q=u,this.u=a,this.s=s.transpose().mmul(s),this.xResidual=r,this.yResidual=o,this.betas=i}else this.w=c.transpose(),this.s=s.transpose().mmul(s).sqrt(),this.t=r?s.clone().div(this.s.get(0,0)):s,this.xResidual=t.sub(s.mmul(c.transpose()))}}Om.AbstractMatrix=tv,Om.CHO=yv,Om.CholeskyDecomposition=yv,Om.DistanceMatrix=iv,Om.EVD=mv,Om.EigenvalueDecomposition=mv,Om.LU=cv,Om.LuDecomposition=cv;var Ev=Om.Matrix=nv;Om.MatrixColumnSelectionView=class extends ov{constructor(t,e){Xm(t,e),super(t,t.rows,e.length),this.columnIndices=e}set(t,e,n){return this.matrix.set(t,this.columnIndices[e],n),this}get(t,e){return this.matrix.get(t,this.columnIndices[e])}},Om.MatrixColumnView=class extends ov{constructor(t,e){Hm(t,e),super(t,t.rows,1),this.column=e}set(t,e,n){return this.matrix.set(t,this.column,n),this}get(t){return this.matrix.get(t,this.column)}},Om.MatrixFlipColumnView=class extends ov{constructor(t){super(t,t.rows,t.columns)}set(t,e,n){return this.matrix.set(t,this.columns-e-1,n),this}get(t,e){return this.matrix.get(t,this.columns-e-1)}},Om.MatrixFlipRowView=class extends ov{constructor(t){super(t,t.rows,t.columns)}set(t,e,n){return this.matrix.set(this.rows-t-1,e,n),this}get(t,e){return this.matrix.get(this.rows-t-1,e)}},Om.MatrixRowSelectionView=class extends ov{constructor(t,e){$m(t,e),super(t,e.length,t.columns),this.rowIndices=e}set(t,e,n){return this.matrix.set(this.rowIndices[t],e,n),this}get(t,e){return this.matrix.get(this.rowIndices[t],e)}},Om.MatrixRowView=class extends ov{constructor(t,e){Wm(t,e),super(t,1,t.columns),this.row=e}set(t,e,n){return this.matrix.set(this.row,e,n),this}get(t,e){return this.matrix.get(this.row,e)}},Om.MatrixSelectionView=av,Om.MatrixSubView=class extends ov{constructor(t,e,n,r,i){Km(t,e,n,r,i),super(t,n-e+1,i-r+1),this.startRow=e,this.startColumn=r}set(t,e,n){return this.matrix.set(this.startRow+t,this.startColumn+e,n),this}get(t,e){return this.matrix.get(this.startRow+t,this.startColumn+e)}},Om.MatrixTransposeView=class extends ov{constructor(t){super(t,t.columns,t.rows)}set(t,e,n){return this.matrix.set(e,t,n),this}get(t,e){return this.matrix.get(e,t)}},Om.NIPALS=bv,Om.Nipals=bv,Om.QR=lv,Om.QrDecomposition=lv,Om.SVD=dv;var wv=Om.SingularValueDecomposition=dv;Om.SymmetricMatrix=rv,Om.WrapperMatrix1D=sv,Om.WrapperMatrix2D=uv,Om.correlation=function(t,e=t,n={}){t=new nv(t);let r=!1;if("object"!=typeof e||nv.isMatrix(e)||jm.isAnyArray(e)?e=new nv(e):(n=e,e=t,r=!0),t.rows!==e.rows)throw new TypeError("Both matrices must have the same number of rows");const{center:i=!0,scale:o=!0}=n;i&&(t.center("column"),r||e.center("column")),o&&(t.scale("column"),r||e.scale("column"));const a=t.standardDeviation("column",{unbiased:!0}),s=r?a:e.standardDeviation("column",{unbiased:!0}),u=t.transpose().mmul(e);for(let e=0;e<u.rows;e++)for(let n=0;n<u.columns;n++)u.set(e,n,u.get(e,n)*(1/(a[e]*s[n]))*(1/(t.rows-1)));return u},Om.covariance=function(t,e=t,n={}){t=new nv(t);let r=!1;if("object"!=typeof e||nv.isMatrix(e)||jm.isAnyArray(e)?e=new nv(e):(n=e,e=t,r=!0),t.rows!==e.rows)throw new TypeError("Both matrices must have the same number of rows");const{center:i=!0}=n;i&&(t=t.center("column"),r||(e=e.center("column")));const o=t.transpose().mmul(e);for(let e=0;e<o.rows;e++)for(let n=0;n<o.columns;n++)o.set(e,n,o.get(e,n)*(1/(t.rows-1)));return o};var xv=Om.default=nv;Om.determinant=function t(e){if((e=nv.checkMatrix(e)).isSquare()){if(0===e.columns)return 1;let n,r,i,o;if(2===e.columns)return n=e.get(0,0),r=e.get(0,1),i=e.get(1,0),o=e.get(1,1),n*o-r*i;if(3===e.columns){let o,a,s;return o=new av(e,[1,2],[1,2]),a=new av(e,[1,2],[0,2]),s=new av(e,[1,2],[0,1]),n=e.get(0,0),r=e.get(0,1),i=e.get(0,2),n*t(o)-r*t(a)+i*t(s)}return new cv(e).determinant}throw Error("determinant can only be calculated for a square matrix")},Om.inverse=function(t,e=!1){return t=uv.checkMatrix(t),e?new dv(t).inverse():fv(t,nv.eye(t.rows))},Om.linearDependencies=function(t,e={}){const{thresholdValue:n=1e-9,thresholdError:r=1e-9}=e;let i=(t=nv.checkMatrix(t)).rows,o=new nv(i,i);for(let e=0;e<i;e++){let a=nv.columnVector(t.getRow(e)),s=t.subMatrixRow(pv(i,e)).transpose(),u=new dv(s).solve(a),c=nv.sub(a,s.mmul(u)).abs().max();o.setRow(e,gv(c,u,e,n,r))}return o},Om.pseudoInverse=function(t,e=Number.EPSILON){if((t=nv.checkMatrix(t)).isEmpty())return t.transpose();let n=new dv(t,{autoTranspose:!0}),r=n.leftSingularVectors,i=n.rightSingularVectors,o=n.diagonal;for(let t=0;t<o.length;t++)Math.abs(o[t])>e?o[t]=1/o[t]:o[t]=0;return i.mmul(nv.diag(o).mmul(r.transpose()))},Om.solve=fv,Om.wrap=function(t,e){if(jm.isAnyArray(t))return t[0]&&jm.isAnyArray(t[0])?new uv(t):new sv(t,e);throw new Error("the argument is not an array")};const Mv=Ev,Nv=wv;xv.Matrix&&xv.Matrix;const Sv={center:[0,0],linkDistance:50};class Tv{constructor(t={}){this.options=t,this.id="mds",this.options=Object.assign(Object.assign({},Sv),t)}execute(t,e){return a(this,void 0,void 0,(function*(){return this.genericMDSLayout(!1,t,e)}))}assign(t,e){return a(this,void 0,void 0,(function*(){this.genericMDSLayout(!0,t,e)}))}genericMDSLayout(t,e,n){return a(this,void 0,void 0,(function*(){const r=Object.assign(Object.assign({},this.options),n),{center:i=[0,0],linkDistance:o=50}=r,a=e.getAllNodes(),s=e.getAllEdges();if(!(null==a?void 0:a.length)||1===a.length)return Qg(e,t,i);const u=Vg({nodes:a,edges:s},!1),c=Gg(u);kv(c);const h=((t,e)=>{const n=[];return t.forEach((t=>{const r=[];t.forEach((t=>{r.push(t*e)})),n.push(r)})),n})(c,o),l=Pv(h),d=[];l.forEach(((t,e)=>{const n=qg(a[e]);n.data.x=t[0]+i[0],n.data.y=t[1]+i[1],d.push(n)})),t&&d.forEach((t=>e.mergeNodeData(t.id,{x:t.data.x,y:t.data.y})));return{nodes:d,edges:s}}))}}const kv=t=>{let e=-999999;t.forEach((t=>{t.forEach((t=>{t!==1/0&&e<t&&(e=t)}))})),t.forEach(((n,r)=>{n.forEach(((n,i)=>{n===1/0&&(t[r][i]=e)}))}))},Pv=t=>{const e=Mv.mul(Mv.pow(t,2),-.5),n=e.mean("row"),r=e.mean("column"),i=e.mean();e.add(i).subRowVector(n).subColumnVector(r);const o=new Nv(e),a=Mv.sqrt(o.diagonalMatrix).diagonal();return o.leftSingularVectors.toJSON().map((t=>Mv.mul([t],[a]).toJSON()[0].splice(0,2)))},Cv={gForce:!0,force2:!0,d3force:!0,fruchterman:!0,forceAtlas2:!0,force:!0,"graphin-force":!0},Av={center:[0,0],comboPadding:10,treeKey:"combo"};function Ov(t){return function(){return t}}function Rv(t){return 1e-6*(t()-.5)}function _v(t){return t.x+t.vx}function Dv(t){return t.y+t.vy}function Iv(t){var e,n,r,i=1,o=1;function a(){for(var t,a,u,c,h,l,d,f=e.length,p=0;p<o;++p)for(a=um(e,_v,Dv).visitAfter(s),t=0;t<f;++t)u=e[t],l=n[u.index],d=l*l,c=u.x+u.vx,h=u.y+u.vy,a.visit(g);function g(t,e,n,o,a){var s=t.data,f=t.r,p=l+f;if(!s)return e>c+p||o<c-p||n>h+p||a<h-p;if(s.index>u.index){var g=c-s.x-s.vx,m=h-s.y-s.vy,v=g*g+m*m;v<p*p&&(0===g&&(v+=(g=Rv(r))*g),0===m&&(v+=(m=Rv(r))*m),v=(p-(v=Math.sqrt(v)))/v*i,u.vx+=(g*=v)*(p=(f*=f)/(d+f)),u.vy+=(m*=v)*p,s.vx-=g*(p=1-p),s.vy-=m*p)}}}function s(t){if(t.data)return t.r=n[t.data.index];for(var e=t.r=0;e<4;++e)t[e]&&t[e].r>t.r&&(t.r=t[e].r)}function u(){if(e){var r,i,o=e.length;for(n=new Array(o),r=0;r<o;++r)i=e[r],n[i.index]=+t(i,r,e)}}return"function"!=typeof t&&(t=Ov(null==t?1:+t)),a.initialize=function(t,n){e=t,r=n,u()},a.iterations=function(t){return arguments.length?(o=+t,a):o},a.strength=function(t){return arguments.length?(i=+t,a):i},a.radius=function(e){return arguments.length?(t="function"==typeof e?e:Ov(+e),u(),a):t},a}function Lv(t){return t.index}function jv(t,e){var n=t.get(e);if(!n)throw new Error("node not found: "+e);return n}function zv(t){var e,n,r,i,o,a,s=Lv,u=function(t){return 1/Math.min(i[t.source.index],i[t.target.index])},c=Ov(30),h=1;function l(r){for(var i=0,s=t.length;i<h;++i)for(var u,c,l,d,f,p,g,m=0;m<s;++m)c=(u=t[m]).source,d=(l=u.target).x+l.vx-c.x-c.vx||Rv(a),f=l.y+l.vy-c.y-c.vy||Rv(a),d*=p=((p=Math.sqrt(d*d+f*f))-n[m])/p*r*e[m],f*=p,l.vx-=d*(g=o[m]),l.vy-=f*g,c.vx+=d*(g=1-g),c.vy+=f*g}function d(){if(r){var a,u,c=r.length,h=t.length,l=new Map(r.map(((t,e)=>[s(t,e,r),t])));for(a=0,i=new Array(c);a<h;++a)(u=t[a]).index=a,"object"!=typeof u.source&&(u.source=jv(l,u.source)),"object"!=typeof u.target&&(u.target=jv(l,u.target)),i[u.source.index]=(i[u.source.index]||0)+1,i[u.target.index]=(i[u.target.index]||0)+1;for(a=0,o=new Array(h);a<h;++a)u=t[a],o[a]=i[u.source.index]/(i[u.source.index]+i[u.target.index]);e=new Array(h),f(),n=new Array(h),p()}}function f(){if(r)for(var n=0,i=t.length;n<i;++n)e[n]=+u(t[n],n,t)}function p(){if(r)for(var e=0,i=t.length;e<i;++e)n[e]=+c(t[e],e,t)}return null==t&&(t=[]),l.initialize=function(t,e){r=t,a=e,d()},l.links=function(e){return arguments.length?(t=e,d(),l):t},l.id=function(t){return arguments.length?(s=t,l):s},l.iterations=function(t){return arguments.length?(h=+t,l):h},l.strength=function(t){return arguments.length?(u="function"==typeof t?t:Ov(+t),f(),l):u},l.distance=function(t){return arguments.length?(c="function"==typeof t?t:Ov(+t),p(),l):c},l}var Fv={value:()=>{}};function Bv(){for(var t,e=0,n=arguments.length,r={};e<n;++e){if(!(t=arguments[e]+"")||t in r||/[\s.]/.test(t))throw new Error("illegal type: "+t);r[t]=[]}return new Gv(r)}function Gv(t){this._=t}function Vv(t,e){for(var n,r=0,i=t.length;r<i;++r)if((n=t[r]).name===e)return n.value}function Uv(t,e,n){for(var r=0,i=t.length;r<i;++r)if(t[r].name===e){t[r]=Fv,t=t.slice(0,r).concat(t.slice(r+1));break}return null!=n&&t.push({name:e,value:n}),t}Gv.prototype=Bv.prototype={constructor:Gv,on:function(t,e){var n,r,i=this._,o=(r=i,(t+"").trim().split(/^|\s+/).map((function(t){var e="",n=t.indexOf(".");if(n>=0&&(e=t.slice(n+1),t=t.slice(0,n)),t&&!r.hasOwnProperty(t))throw new Error("unknown type: "+t);return{type:t,name:e}}))),a=-1,s=o.length;if(!(arguments.length<2)){if(null!=e&&"function"!=typeof e)throw new Error("invalid callback: "+e);for(;++a<s;)if(n=(t=o[a]).type)i[n]=Uv(i[n],t.name,e);else if(null==e)for(n in i)i[n]=Uv(i[n],t.name,null);return this}for(;++a<s;)if((n=(t=o[a]).type)&&(n=Vv(i[n],t.name)))return n},copy:function(){var t={},e=this._;for(var n in e)t[n]=e[n].slice();return new Gv(t)},call:function(t,e){if((n=arguments.length-2)>0)for(var n,r,i=new Array(n),o=0;o<n;++o)i[o]=arguments[o+2];if(!this._.hasOwnProperty(t))throw new Error("unknown type: "+t);for(o=0,n=(r=this._[t]).length;o<n;++o)r[o].value.apply(e,i)},apply:function(t,e,n){if(!this._.hasOwnProperty(t))throw new Error("unknown type: "+t);for(var r=this._[t],i=0,o=r.length;i<o;++i)r[i].value.apply(e,n)}};var Wv,Hv,qv=0,Yv=0,$v=0,Xv=1e3,Kv=0,Zv=0,Qv=0,Jv="object"==typeof performance&&performance.now?performance:Date,ty="object"==typeof window&&window.requestAnimationFrame?window.requestAnimationFrame.bind(window):function(t){setTimeout(t,17)};function ey(){return Zv||(ty(ny),Zv=Jv.now()+Qv)}function ny(){Zv=0}function ry(){this._call=this._time=this._next=null}function iy(t,e,n){var r=new ry;return r.restart(t,e,n),r}function oy(){Zv=(Kv=Jv.now())+Qv,qv=Yv=0;try{!function(){ey(),++qv;for(var t,e=Wv;e;)(t=Zv-e._time)>=0&&e._call.call(void 0,t),e=e._next;--qv}()}finally{qv=0,function(){var t,e,n=Wv,r=1/0;for(;n;)n._call?(r>n._time&&(r=n._time),t=n,n=n._next):(e=n._next,n._next=null,n=t?t._next=e:Wv=e);Hv=t,sy(r)}(),Zv=0}}function ay(){var t=Jv.now(),e=t-Kv;e>Xv&&(Qv-=e,Kv=t)}function sy(t){qv||(Yv&&(Yv=clearTimeout(Yv)),t-Zv>24?(t<1/0&&(Yv=setTimeout(oy,t-Jv.now()-Qv)),$v&&($v=clearInterval($v))):($v||(Kv=Jv.now(),$v=setInterval(ay,Xv)),qv=1,ty(oy)))}ry.prototype=iy.prototype={constructor:ry,restart:function(t,e,n){if("function"!=typeof t)throw new TypeError("callback is not a function");n=(null==n?ey():+n)+(null==e?0:+e),this._next||Hv===this||(Hv?Hv._next=this:Wv=this,Hv=this),this._call=t,this._time=n,sy()},stop:function(){this._call&&(this._call=null,this._time=1/0,sy())}};const uy=1664525,cy=1013904223,hy=4294967296;function ly(t){return t.x}function dy(t){return t.y}var fy=10,py=Math.PI*(3-Math.sqrt(5));function gy(t){var e,n=1,r=.001,i=1-Math.pow(r,1/300),o=0,a=.6,s=new Map,u=iy(l),c=Bv("tick","end"),h=function(){let t=1;return()=>(t=(uy*t+cy)%hy)/hy}();function l(){d(),c.call("tick",e),n<r&&(u.stop(),c.call("end",e))}function d(r){var u,c,h=t.length;void 0===r&&(r=1);for(var l=0;l<r;++l)for(n+=(o-n)*i,s.forEach((function(t){t(n)})),u=0;u<h;++u)null==(c=t[u]).fx?c.x+=c.vx*=a:(c.x=c.fx,c.vx=0),null==c.fy?c.y+=c.vy*=a:(c.y=c.fy,c.vy=0);return e}function f(){for(var e,n=0,r=t.length;n<r;++n){if((e=t[n]).index=n,null!=e.fx&&(e.x=e.fx),null!=e.fy&&(e.y=e.fy),isNaN(e.x)||isNaN(e.y)){var i=fy*Math.sqrt(.5+n),o=n*py;e.x=i*Math.cos(o),e.y=i*Math.sin(o)}(isNaN(e.vx)||isNaN(e.vy))&&(e.vx=e.vy=0)}}function p(e){return e.initialize&&e.initialize(t,h),e}return null==t&&(t=[]),f(),e={tick:d,restart:function(){return u.restart(l),e},stop:function(){return u.stop(),e},nodes:function(n){return arguments.length?(t=n,f(),s.forEach(p),e):t},alpha:function(t){return arguments.length?(n=+t,e):n},alphaMin:function(t){return arguments.length?(r=+t,e):r},alphaDecay:function(t){return arguments.length?(i=+t,e):+i},alphaTarget:function(t){return arguments.length?(o=+t,e):o},velocityDecay:function(t){return arguments.length?(a=1-t,e):1-a},randomSource:function(t){return arguments.length?(h=t,s.forEach(p),e):h},force:function(t,n){return arguments.length>1?(null==n?s.delete(t):s.set(t,p(n)),e):s.get(t)},find:function(e,n,r){var i,o,a,s,u,c=0,h=t.length;for(null==r?r=1/0:r*=r,c=0;c<h;++c)(a=(i=e-(s=t[c]).x)*i+(o=n-s.y)*o)<r&&(u=s,r=a);return u},on:function(t,n){return arguments.length>1?(c.on(t,n),e):c.on(t)}}}function my(){var t,e,n,r,i,o=Ov(-30),a=1,s=1/0,u=.81;function c(n){var i,o=t.length,a=um(t,ly,dy).visitAfter(l);for(r=n,i=0;i<o;++i)e=t[i],a.visit(d)}function h(){if(t){var e,n,r=t.length;for(i=new Array(r),e=0;e<r;++e)n=t[e],i[n.index]=+o(n,e,t)}}function l(t){var e,n,r,o,a,s=0,u=0;if(t.length){for(r=o=a=0;a<4;++a)(e=t[a])&&(n=Math.abs(e.value))&&(s+=e.value,u+=n,r+=n*e.x,o+=n*e.y);t.x=r/u,t.y=o/u}else{(e=t).x=e.data.x,e.y=e.data.y;do{s+=i[e.data.index]}while(e=e.next)}t.value=s}function d(t,o,c,h){if(!t.value)return!0;var l=t.x-e.x,d=t.y-e.y,f=h-o,p=l*l+d*d;if(f*f/u<p)return p<s&&(0===l&&(p+=(l=Rv(n))*l),0===d&&(p+=(d=Rv(n))*d),p<a&&(p=Math.sqrt(a*p)),e.vx+=l*t.value*r/p,e.vy+=d*t.value*r/p),!0;if(!(t.length||p>=s)){(t.data!==e||t.next)&&(0===l&&(p+=(l=Rv(n))*l),0===d&&(p+=(d=Rv(n))*d),p<a&&(p=Math.sqrt(a*p)));do{t.data!==e&&(f=i[t.data.index]*r/p,e.vx+=l*f,e.vy+=d*f)}while(t=t.next)}}return c.initialize=function(e,r){t=e,n=r,h()},c.strength=function(t){return arguments.length?(o="function"==typeof t?t:Ov(+t),h(),c):o},c.distanceMin=function(t){return arguments.length?(a=t*t,c):Math.sqrt(a)},c.distanceMax=function(t){return arguments.length?(s=t*t,c):Math.sqrt(s)},c.theta=function(t){return arguments.length?(u=t*t,c):Math.sqrt(u)},c}function vy(t){var e,n,r,i=Ov(.1);function o(t){for(var i,o=0,a=e.length;o<a;++o)(i=e[o]).vx+=(r[o]-i.x)*n[o]*t}function a(){if(e){var o,a=e.length;for(n=new Array(a),r=new Array(a),o=0;o<a;++o)n[o]=isNaN(r[o]=+t(e[o],o,e))?0:+i(e[o],o,e)}}return"function"!=typeof t&&(t=Ov(null==t?0:+t)),o.initialize=function(t){e=t,a()},o.strength=function(t){return arguments.length?(i="function"==typeof t?t:Ov(+t),a(),o):i},o.x=function(e){return arguments.length?(t="function"==typeof e?e:Ov(+e),a(),o):t},o}function yy(t){var e,n,r,i=Ov(.1);function o(t){for(var i,o=0,a=e.length;o<a;++o)(i=e[o]).vy+=(r[o]-i.y)*n[o]*t}function a(){if(e){var o,a=e.length;for(n=new Array(a),r=new Array(a),o=0;o<a;++o)n[o]=isNaN(r[o]=+t(e[o],o,e))?0:+i(e[o],o,e)}}return"function"!=typeof t&&(t=Ov(null==t?0:+t)),o.initialize=function(t){e=t,a()},o.strength=function(t){return arguments.length?(i="function"==typeof t?t:Ov(+t),a(),o):i},o.y=function(e){return arguments.length?(t="function"==typeof e?e:Ov(+e),a(),o):t},o}function by(){function t(t){return()=>t}let e,n=t=>t.cluster,r=t(1),i=t(-1),o=t(100),a=t(.1),s=[0,0],u=[],c={},h=[],l=100,d=100,f={none:{x:0,y:0}},p=[],g="force",m=!0,v=.1;function y(t){if(!m)return y;e.tick(),E();for(let e,r=0,i=u.length,o=t*v;r<i;++r)e=u[r],e.vx+=(f[n(e)].x-e.x)*o,e.vy+=(f[n(e)].y-e.y)*o}function b(){u&&function(){if(!u||!u.length)return;if(void 0===n(u[0]))throw Error("Couldnt find the grouping attribute for the nodes. Make sure to set it up with forceInBox.groupBy('clusterAttr') before calling .links()");const t=function(){const t=[],e=[],i={};let o=[],a={},s=[];return a=function(t){const e={};return t.forEach((t=>{const r=n(t);e[r]||(e[r]={count:0,sumforceNodeSize:0})})),t.forEach((t=>{const i=n(t),o=r(t),a=e[i];a.count=a.count+1,a.sumforceNodeSize=a.sumforceNodeSize+Math.PI*(o*o)*1.3,e[i]=a})),e}(u),s=function(t){const e={},r=[];t.forEach((t=>{const r=function(t){const e=t.source,r=t.target,i=n(c[e]),o=n(c[r]);return i<=o?`${i}~${o}`:`${o}~${i}`}(t);let i=0;void 0!==e[r]&&(i=e[r]),i+=1,e[r]=i}));return Object.entries(e).forEach((([t,e])=>{const n=t.split("~")[0],i=t.split("~")[1];void 0!==n&&void 0!==i&&r.push({source:n,target:i,count:e})})),r}(h),o=Object.keys(a),o.forEach(((e,n)=>{const r=a[e];t.push({id:e,size:r.count,r:Math.sqrt(r.sumforceNodeSize/Math.PI)}),i[e]=n})),s.forEach((t=>{const n=t.source,r=t.target,o=i[n],a=i[r];void 0!==o&&void 0!==a&&e.push({source:o,target:a,count:t.count})})),{nodes:t,links:e}}();e=gy(t.nodes).force("x",vy(l).strength(.1)).force("y",yy(d).strength(.1)).force("collide",Iv((t=>t.r)).iterations(4)).force("charge",my().strength(i)).force("links",zv(t.nodes.length?t.links:[]).distance(o).strength(a)),p=e.nodes(),E()}()}function E(){return f={none:{x:0,y:0}},p.forEach((t=>{f[t.id]={x:t.x-s[0],y:t.y-s[1]}})),f}return y.initialize=t=>{u=t,b()},y.template=function(t){return arguments.length?(g=t,b(),y):g},y.groupBy=function(t){return arguments.length?"string"==typeof t?(n=e=>e[t],y):(n=t,y):n},y.enableGrouping=function(t){return arguments.length?(m=t,y):m},y.strength=function(t){return arguments.length?(v=t,y):v},y.centerX=function(t){return arguments.length?(l=t,y):l},y.centerY=function(t){return arguments.length?(d=t,y):d},y.nodes=function(t){return arguments.length?(function(t){c={},t.forEach((t=>{c[t.id]=t}))}(t||[]),u=t||[],y):u},y.links=function(t){return arguments.length?(h=t||[],b(),y):h},y.forceNodeSize=function(e){return arguments.length?(r="function"==typeof e?e:t(+e),b(),y):r},y.nodeSize=y.forceNodeSize,y.forceCharge=function(e){return arguments.length?(i="function"==typeof e?e:t(+e),b(),y):i},y.forceLinkDistance=function(e){return arguments.length?(o="function"==typeof e?e:t(+e),b(),y):o},y.forceLinkStrength=function(e){return arguments.length?(a="function"==typeof e?e:t(+e),b(),y):a},y.offset=function(t){return arguments.length?(s=t,y):s},y.getFocis=E,y}const Ey={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};const wy=t=>t.map((t=>{const{x:e,y:n}=t,r=o(t,["x","y"]);return Object.assign(Object.assign({},r),{data:Object.assign(Object.assign({},r.data),{x:e,y:n})})})),xy=t=>t.map((t=>{const{source:e,target:n}=t,r=o(t,["source","target"]);return Object.assign(Object.assign({},r),{source:e.id,target:n.id})}));var My,Ny,Sy,Ty,ky,Py,Cy,Ay,Oy,Ry,_y,Dy,Iy,Ly,jy,zy,Fy,By,Gy,Vy,Uy,Wy,Hy,qy,Yy,$y,Xy,Ky,Zy,Qy,Jy,tb,eb,nb,rb,ib,ob,ab,sb,ub,cb,hb,lb,db,fb,pb,gb,mb,vb,yb,bb,Eb,wb,xb,Mb,Nb,Sb,Tb,kb,Pb,Cb,Ab,Ob,Rb,_b,Db,Ib,Lb,jb,zb,Fb,Bb,Gb,Vb,Ub,Wb,Hb,qb,Yb,$b,Xb,Kb,Zb,Qb,Jb,tE,eE,nE,rE,iE,oE,aE,sE,uE,cE,hE,lE,dE,fE,pE,gE,mE,vE,yE,bE,EE,wE,xE;function ME(){if(Ty)return Sy;return Ty=1,Sy=function(t,e){return t===e||t!=t&&e!=e}}function NE(){if(Py)return ky;Py=1;var t=ME();return ky=function(e,n){for(var r=e.length;r--;)if(t(e[r][0],n))return r;return-1},ky}function SE(){if(zy)return jy;zy=1;var t=Ny?My:(Ny=1,My=function(){this.__data__=[],this.size=0}),e=function(){if(Ay)return Cy;Ay=1;var t=NE(),e=Array.prototype.splice;return Cy=function(n){var r=this.__data__,i=t(r,n);return!(i<0||(i==r.length-1?r.pop():e.call(r,i,1),--this.size,0))},Cy}(),n=function(){if(Ry)return Oy;Ry=1;var t=NE();return Oy=function(e){var n=this.__data__,r=t(n,e);return r<0?void 0:n[r][1]},Oy}(),r=function(){if(Dy)return _y;Dy=1;var t=NE();return _y=function(e){return t(this.__data__,e)>-1}}(),i=function(){if(Ly)return Iy;Ly=1;var t=NE();return Iy=function(e,n){var r=this.__data__,i=t(r,e);return i<0?(++this.size,r.push([e,n])):r[i][1]=n,this},Iy}();function o(t){var e=-1,n=null==t?0:t.length;for(this.clear();++e<n;){var r=t[e];this.set(r[0],r[1])}}return o.prototype.clear=t,o.prototype.delete=e,o.prototype.get=n,o.prototype.has=r,o.prototype.set=i,jy=o}function TE(){if($y)return Yy;$y=1;var t="object"==typeof l&&l&&l.Object===Object&&l;return Yy=t}function kE(){if(Ky)return Xy;Ky=1;var t=TE(),e="object"==typeof self&&self&&self.Object===Object&&self,n=t||e||Function("return this")();return Xy=n}function PE(){if(Qy)return Zy;Qy=1;var t=kE().Symbol;return Zy=t}function CE(){if(ib)return rb;ib=1;var t=PE(),e=function(){if(tb)return Jy;tb=1;var t=PE(),e=Object.prototype,n=e.hasOwnProperty,r=e.toString,i=t?t.toStringTag:void 0;return Jy=function(t){var e=n.call(t,i),o=t[i];try{t[i]=void 0;var a=!0}catch(t){}var s=r.call(t);return a&&(e?t[i]=o:delete t[i]),s}}(),n=function(){if(nb)return eb;nb=1;var t=Object.prototype.toString;return eb=function(e){return t.call(e)}}(),r=t?t.toStringTag:void 0;return rb=function(t){return null==t?void 0===t?"[object Undefined]":"[object Null]":r&&r in Object(t)?e(t):n(t)}}function AE(){if(ab)return ob;return ab=1,ob=function(t){var e=typeof t;return null!=t&&("object"==e||"function"==e)}}function OE(){if(ub)return sb;ub=1;var t=CE(),e=AE();return sb=function(n){if(!e(n))return!1;var r=t(n);return"[object Function]"==r||"[object GeneratorFunction]"==r||"[object AsyncFunction]"==r||"[object Proxy]"==r}}function RE(){if(db)return lb;db=1;var t,e=function(){if(hb)return cb;hb=1;var t=kE()["__core-js_shared__"];return cb=t}(),n=(t=/[^.]+$/.exec(e&&e.keys&&e.keys.IE_PROTO||""))?"Symbol(src)_1."+t:"";return lb=function(t){return!!n&&n in t}}function _E(){if(pb)return fb;pb=1;var t=Function.prototype.toString;return fb=function(e){if(null!=e){try{return t.call(e)}catch(t){}try{return e+""}catch(t){}}return""}}function DE(){if(Eb)return bb;Eb=1;var t=function(){if(mb)return gb;mb=1;var t=OE(),e=RE(),n=AE(),r=_E(),i=/^\[object .+?Constructor\]$/,o=Function.prototype,a=Object.prototype,s=o.toString,u=a.hasOwnProperty,c=RegExp("^"+s.call(u).replace(/[\\^$.*+?()[\]{}|]/g,"\\$&").replace(/hasOwnProperty|(function).*?(?=\\\()| for .+?(?=\\\])/g,"$1.*?")+"$");return gb=function(o){return!(!n(o)||e(o))&&(t(o)?c:i).test(r(o))}}(),e=yb?vb:(yb=1,vb=function(t,e){return null==t?void 0:t[e]});return bb=function(n,r){var i=e(n,r);return t(i)?i:void 0}}function IE(){if(xb)return wb;xb=1;var t=DE()(kE(),"Map");return wb=t}function LE(){if(Nb)return Mb;Nb=1;var t=DE()(Object,"create");return Mb=t}function jE(){if(Lb)return Ib;Lb=1;var t=function(){if(Tb)return Sb;Tb=1;var t=LE();return Sb=function(){this.__data__=t?t(null):{},this.size=0}}(),e=Pb?kb:(Pb=1,kb=function(t){var e=this.has(t)&&delete this.__data__[t];return this.size-=e?1:0,e}),n=function(){if(Ab)return Cb;Ab=1;var t=LE(),e=Object.prototype.hasOwnProperty;return Cb=function(n){var r=this.__data__;if(t){var i=r[n];return"__lodash_hash_undefined__"===i?void 0:i}return e.call(r,n)?r[n]:void 0},Cb}(),r=function(){if(Rb)return Ob;Rb=1;var t=LE(),e=Object.prototype.hasOwnProperty;return Ob=function(n){var r=this.__data__;return t?void 0!==r[n]:e.call(r,n)},Ob}(),i=function(){if(Db)return _b;Db=1;var t=LE();return _b=function(e,n){var r=this.__data__;return this.size+=this.has(e)?0:1,r[e]=t&&void 0===n?"__lodash_hash_undefined__":n,this},_b}();function o(t){var e=-1,n=null==t?0:t.length;for(this.clear();++e<n;){var r=t[e];this.set(r[0],r[1])}}return o.prototype.clear=t,o.prototype.delete=e,o.prototype.get=n,o.prototype.has=r,o.prototype.set=i,Ib=o}function zE(){if(Vb)return Gb;Vb=1;var t=Bb?Fb:(Bb=1,Fb=function(t){var e=typeof t;return"string"==e||"number"==e||"symbol"==e||"boolean"==e?"__proto__"!==t:null===t});return Gb=function(e,n){var r=e.__data__;return t(n)?r["string"==typeof n?"string":"hash"]:r.map},Gb}function FE(){if(Qb)return Zb;Qb=1;var t=function(){if(zb)return jb;zb=1;var t=jE(),e=SE(),n=IE();return jb=function(){this.size=0,this.__data__={hash:new t,map:new(n||e),string:new t}}}(),e=function(){if(Wb)return Ub;Wb=1;var t=zE();return Ub=function(e){var n=t(this,e).delete(e);return this.size-=n?1:0,n}}(),n=function(){if(qb)return Hb;qb=1;var t=zE();return Hb=function(e){return t(this,e).get(e)}}(),r=function(){if($b)return Yb;$b=1;var t=zE();return Yb=function(e){return t(this,e).has(e)}}(),i=function(){if(Kb)return Xb;Kb=1;var t=zE();return Xb=function(e,n){var r=t(this,e),i=r.size;return r.set(e,n),this.size+=r.size==i?0:1,this},Xb}();function o(t){var e=-1,n=null==t?0:t.length;for(this.clear();++e<n;){var r=t[e];this.set(r[0],r[1])}}return o.prototype.clear=t,o.prototype.delete=e,o.prototype.get=n,o.prototype.has=r,o.prototype.set=i,Zb=o}function BE(){if(nE)return eE;nE=1;var t=SE(),e=function(){if(By)return Fy;By=1;var t=SE();return Fy=function(){this.__data__=new t,this.size=0}}(),n=(Vy||(Vy=1,Gy=function(t){var e=this.__data__,n=e.delete(t);return this.size=e.size,n}),Gy),r=Wy?Uy:(Wy=1,Uy=function(t){return this.__data__.get(t)}),i=qy?Hy:(qy=1,Hy=function(t){return this.__data__.has(t)}),o=function(){if(tE)return Jb;tE=1;var t=SE(),e=IE(),n=FE();return Jb=function(r,i){var o=this.__data__;if(o instanceof t){var a=o.__data__;if(!e||a.length<199)return a.push([r,i]),this.size=++o.size,this;o=this.__data__=new n(a)}return o.set(r,i),this.size=o.size,this},Jb}();function a(e){var n=this.__data__=new t(e);this.size=n.size}return a.prototype.clear=e,a.prototype.delete=n,a.prototype.get=r,a.prototype.has=i,a.prototype.set=o,eE=a}function GE(){if(iE)return rE;return iE=1,rE=function(t,e){for(var n=-1,r=null==t?0:t.length;++n<r&&!1!==e(t[n],n,t););return t},rE}function VE(){if(aE)return oE;aE=1;var t=DE(),e=function(){try{var e=t(Object,"defineProperty");return e({},"",{}),e}catch(t){}}();return oE=e}function UE(){if(uE)return sE;uE=1;var t=VE();return sE=function(e,n,r){"__proto__"==n&&t?t(e,n,{configurable:!0,enumerable:!0,value:r,writable:!0}):e[n]=r}}function WE(){if(hE)return cE;hE=1;var t=UE(),e=ME(),n=Object.prototype.hasOwnProperty;return cE=function(r,i,o){var a=r[i];n.call(r,i)&&e(a,o)&&(void 0!==o||i in r)||t(r,i,o)}}function HE(){if(dE)return lE;dE=1;var t=WE(),e=UE();return lE=function(n,r,i,o){var a=!i;i||(i={});for(var s=-1,u=r.length;++s<u;){var c=r[s],h=o?o(i[c],n[c],c,i,n):void 0;void 0===h&&(h=n[c]),a?e(i,c,h):t(i,c,h)}return i},lE}function qE(){if(mE)return gE;return mE=1,gE=function(t){return null!=t&&"object"==typeof t}}function YE(){if(EE)return bE;EE=1;var t=function(){if(yE)return vE;yE=1;var t=CE(),e=qE();return vE=function(n){return e(n)&&"[object Arguments]"==t(n)}}(),e=qE(),n=Object.prototype,r=n.hasOwnProperty,i=n.propertyIsEnumerable,o=t(function(){return arguments}())?t:function(t){return e(t)&&r.call(t,"callee")&&!i.call(t,"callee")};return bE=o}function $E(){if(xE)return wE;xE=1;var t=Array.isArray;return wE=t}var XE,KE,ZE,QE,JE,tw,ew,nw,rw,iw,ow,aw={exports:{}};function sw(){return ZE||(ZE=1,function(t,e){var n=kE(),r=KE?XE:(KE=1,XE=function(){return!1}),i=e&&!e.nodeType&&e,o=i&&t&&!t.nodeType&&t,a=o&&o.exports===i?n.Buffer:void 0,s=(a?a.isBuffer:void 0)||r;t.exports=s}(aw,aw.exports)),aw.exports}function uw(){if(JE)return QE;JE=1;var t=/^(?:0|[1-9]\d*)$/;return QE=function(e,n){var r=typeof e;return!!(n=null==n?9007199254740991:n)&&("number"==r||"symbol"!=r&&t.test(e))&&e>-1&&e%1==0&&e<n},QE}function cw(){if(ew)return tw;ew=1;return tw=function(t){return"number"==typeof t&&t>-1&&t%1==0&&t<=9007199254740991}}function hw(){if(ow)return iw;return ow=1,iw=function(t){return function(e){return t(e)}}}aw.exports;var lw,dw,fw,pw,gw,mw,vw,yw,bw,Ew,ww,xw,Mw,Nw,Sw,Tw,kw,Pw,Cw,Aw,Ow,Rw,_w,Dw,Iw,Lw,jw,zw={exports:{}};function Fw(){return lw||(lw=1,function(t,e){var n=TE(),r=e&&!e.nodeType&&e,i=r&&t&&!t.nodeType&&t,o=i&&i.exports===r&&n.process,a=function(){try{var t=i&&i.require&&i.require("util").types;return t||o&&o.binding&&o.binding("util")}catch(t){}}();t.exports=a}(zw,zw.exports)),zw.exports}function Bw(){if(fw)return dw;fw=1;var t=function(){if(rw)return nw;rw=1;var t=CE(),e=cw(),n=qE(),r={};return r["[object Float32Array]"]=r["[object Float64Array]"]=r["[object Int8Array]"]=r["[object Int16Array]"]=r["[object Int32Array]"]=r["[object Uint8Array]"]=r["[object Uint8ClampedArray]"]=r["[object Uint16Array]"]=r["[object Uint32Array]"]=!0,r["[object Arguments]"]=r["[object Array]"]=r["[object ArrayBuffer]"]=r["[object Boolean]"]=r["[object DataView]"]=r["[object Date]"]=r["[object Error]"]=r["[object Function]"]=r["[object Map]"]=r["[object Number]"]=r["[object Object]"]=r["[object RegExp]"]=r["[object Set]"]=r["[object String]"]=r["[object WeakMap]"]=!1,nw=function(i){return n(i)&&e(i.length)&&!!r[t(i)]}}(),e=hw(),n=Fw(),r=n&&n.isTypedArray,i=r?e(r):t;return dw=i}function Gw(){if(gw)return pw;gw=1;var t=(pE||(pE=1,fE=function(t,e){for(var n=-1,r=Array(t);++n<t;)r[n]=e(n);return r}),fE),e=YE(),n=$E(),r=sw(),i=uw(),o=Bw(),a=Object.prototype.hasOwnProperty;return pw=function(s,u){var c=n(s),h=!c&&e(s),l=!c&&!h&&r(s),d=!c&&!h&&!l&&o(s),f=c||h||l||d,p=f?t(s.length,String):[],g=p.length;for(var m in s)!u&&!a.call(s,m)||f&&("length"==m||l&&("offset"==m||"parent"==m)||d&&("buffer"==m||"byteLength"==m||"byteOffset"==m)||i(m,g))||p.push(m);return p},pw}function Vw(){if(vw)return mw;vw=1;var t=Object.prototype;return mw=function(e){var n=e&&e.constructor;return e===("function"==typeof n&&n.prototype||t)}}function Uw(){if(bw)return yw;return bw=1,yw=function(t,e){return function(n){return t(e(n))}}}function Ww(){if(Mw)return xw;Mw=1;var t=Vw(),e=function(){if(ww)return Ew;ww=1;var t=Uw()(Object.keys,Object);return Ew=t}(),n=Object.prototype.hasOwnProperty;return xw=function(r){if(!t(r))return e(r);var i=[];for(var o in Object(r))n.call(r,o)&&"constructor"!=o&&i.push(o);return i}}function Hw(){if(Sw)return Nw;Sw=1;var t=OE(),e=cw();return Nw=function(n){return null!=n&&e(n.length)&&!t(n)}}function qw(){if(kw)return Tw;kw=1;var t=Gw(),e=Ww(),n=Hw();return Tw=function(r){return n(r)?t(r):e(r)}}function Yw(){if(_w)return Rw;_w=1;var t=AE(),e=Vw(),n=Ow?Aw:(Ow=1,Aw=function(t){var e=[];if(null!=t)for(var n in Object(t))e.push(n);return e}),r=Object.prototype.hasOwnProperty;return Rw=function(i){if(!t(i))return n(i);var o=e(i),a=[];for(var s in i)("constructor"!=s||!o&&r.call(i,s))&&a.push(s);return a}}function $w(){if(Iw)return Dw;Iw=1;var t=Gw(),e=Yw(),n=Hw();return Dw=function(r){return n(r)?t(r,!0):e(r)}}zw.exports;var Xw,Kw,Zw,Qw,Jw,tx,ex,nx,rx,ix,ox,ax,sx,ux,cx,hx,lx,dx,fx,px,gx,mx,vx,yx,bx,Ex,wx,xx,Mx,Nx,Sx,Tx,kx,Px,Cx,Ax,Ox,Rx,_x,Dx,Ix,Lx,jx,zx,Fx,Bx,Gx,Vx,Ux,Wx,Hx,qx,Yx,$x,Xx,Kx,Zx,Qx,Jx,tM,eM,nM,rM,iM,oM,aM,sM,uM,cM,hM,lM,dM,fM,pM,gM,mM,vM,yM,bM,EM,wM,xM,MM,NM,SM,TM,kM,PM,CM,AM,OM,RM,_M,DM,IM,LM,jM,zM,FM,BM,GM,VM,UM,WM,HM,qM,YM,$M,XM,KM,ZM,QM,JM,tN,eN,nN,rN,iN,oN,aN,sN,uN,cN,hN,lN,dN,fN,pN,gN,mN,vN,yN,bN,EN,wN,xN,MN,NN,SN,TN,kN,PN,CN,AN,ON,RN,_N,DN,IN,LN,jN,zN,FN,BN,GN,VN,UN,WN,HN,qN,YN,$N,XN,KN,ZN,QN,JN,tS,eS,nS,rS,iS,oS,aS,sS,uS,cS,hS,lS,dS,fS,pS,gS,mS,vS,yS,bS,ES,wS,xS,MS,NS,SS,TS,kS,PS,CS,AS,OS,RS,_S,DS,IS,LS,jS,zS,FS,BS,GS,VS,US,WS,HS,qS,YS,$S,XS,KS,ZS,QS,JS,tT,eT,nT,rT,iT,oT,aT,sT,uT,cT,hT,lT,dT,fT,pT,gT,mT,vT,yT,bT,ET,wT,xT,MT,NT,ST,TT,kT,PT,CT,AT,OT,RT,_T,DT,IT,LT,jT,zT,FT,BT,GT,VT,UT,WT,HT,qT,YT,$T,XT,KT,ZT,QT,JT,tk,ek,nk,rk,ik,ok={exports:{}};function ak(){return Xw||(Xw=1,function(t,e){var n=kE(),r=e&&!e.nodeType&&e,i=r&&t&&!t.nodeType&&t,o=i&&i.exports===r?n.Buffer:void 0,a=o?o.allocUnsafe:void 0;t.exports=function(t,e){if(e)return t.slice();var n=t.length,r=a?a(n):new t.constructor(n);return t.copy(r),r}}(ok,ok.exports)),ok.exports}function sk(){if(Zw)return Kw;return Zw=1,Kw=function(t,e){var n=-1,r=t.length;for(e||(e=Array(r));++n<r;)e[n]=t[n];return e},Kw}function uk(){if(Jw)return Qw;return Jw=1,Qw=function(t,e){for(var n=-1,r=null==t?0:t.length,i=0,o=[];++n<r;){var a=t[n];e(a,n,t)&&(o[i++]=a)}return o},Qw}function ck(){if(ex)return tx;return ex=1,tx=function(){return[]}}function hk(){if(rx)return nx;rx=1;var t=uk(),e=ck(),n=Object.prototype.propertyIsEnumerable,r=Object.getOwnPropertySymbols;return nx=r?function(e){return null==e?[]:(e=Object(e),t(r(e),(function(t){return n.call(e,t)})))}:e}function lk(){if(sx)return ax;return sx=1,ax=function(t,e){for(var n=-1,r=e.length,i=t.length;++n<r;)t[i+n]=e[n];return t},ax}function dk(){if(cx)return ux;cx=1;var t=Uw()(Object.getPrototypeOf,Object);return ux=t}function fk(){if(lx)return hx;lx=1;var t=lk(),e=dk(),n=hk(),r=ck(),i=Object.getOwnPropertySymbols;return hx=i?function(r){for(var i=[];r;)t(i,n(r)),r=e(r);return i}:r}function pk(){if(gx)return px;gx=1;var t=lk(),e=$E();return px=function(n,r,i){var o=r(n);return e(n)?o:t(o,i(n))}}function gk(){if(vx)return mx;vx=1;var t=pk(),e=hk(),n=qw();return mx=function(r){return t(r,n,e)}}function mk(){if(Sx)return Nx;Sx=1;var t=DE()(kE(),"Set");return Nx=t}function vk(){if(Cx)return Px;Cx=1;var t=function(){if(wx)return Ex;wx=1;var t=DE()(kE(),"DataView");return Ex=t}(),e=IE(),n=function(){if(Mx)return xx;Mx=1;var t=DE()(kE(),"Promise");return xx=t}(),r=mk(),i=function(){if(kx)return Tx;kx=1;var t=DE()(kE(),"WeakMap");return Tx=t}(),o=CE(),a=_E(),s="[object Map]",u="[object Promise]",c="[object Set]",h="[object WeakMap]",l="[object DataView]",d=a(t),f=a(e),p=a(n),g=a(r),m=a(i),v=o;return(t&&v(new t(new ArrayBuffer(1)))!=l||e&&v(new e)!=s||n&&v(n.resolve())!=u||r&&v(new r)!=c||i&&v(new i)!=h)&&(v=function(t){var e=o(t),n="[object Object]"==e?t.constructor:void 0,r=n?a(n):"";if(r)switch(r){case d:return l;case f:return s;case p:return u;case g:return c;case m:return h}return e}),Px=v}function yk(){if(_x)return Rx;_x=1;var t=kE().Uint8Array;return Rx=t}function bk(){if(Ix)return Dx;Ix=1;var t=yk();return Dx=function(e){var n=new e.constructor(e.byteLength);return new t(n).set(new t(e)),n}}function Ek(){if(Ux)return Vx;Ux=1;var t=bk();return Vx=function(e,n){var r=n?t(e.buffer):e.buffer;return new e.constructor(r,e.byteOffset,e.length)}}function wk(){if(Hx)return Wx;Hx=1;var t=bk(),e=function(){if(jx)return Lx;jx=1;var t=bk();return Lx=function(e,n){var r=n?t(e.buffer):e.buffer;return new e.constructor(r,e.byteOffset,e.byteLength)}}(),n=function(){if(Fx)return zx;Fx=1;var t=/\w*$/;return zx=function(e){var n=new e.constructor(e.source,t.exec(e));return n.lastIndex=e.lastIndex,n}}(),r=function(){if(Gx)return Bx;Gx=1;var t=PE(),e=t?t.prototype:void 0,n=e?e.valueOf:void 0;return Bx=function(t){return n?Object(n.call(t)):{}}}(),i=Ek();return Wx=function(o,a,s){var u=o.constructor;switch(a){case"[object ArrayBuffer]":return t(o);case"[object Boolean]":case"[object Date]":return new u(+o);case"[object DataView]":return e(o,s);case"[object Float32Array]":case"[object Float64Array]":case"[object Int8Array]":case"[object Int16Array]":case"[object Int32Array]":case"[object Uint8Array]":case"[object Uint8ClampedArray]":case"[object Uint16Array]":case"[object Uint32Array]":return i(o,s);case"[object Map]":case"[object Set]":return new u;case"[object Number]":case"[object String]":return new u(o);case"[object RegExp]":return n(o);case"[object Symbol]":return r(o)}}}function xk(){if(Yx)return qx;Yx=1;var t=AE(),e=Object.create,n=function(){function n(){}return function(r){if(!t(r))return{};if(e)return e(r);n.prototype=r;var i=new n;return n.prototype=void 0,i}}();return qx=n}function Mk(){if(Xx)return $x;Xx=1;var t=xk(),e=dk(),n=Vw();return $x=function(r){return"function"!=typeof r.constructor||n(r)?{}:t(e(r))}}function Nk(){if(Jx)return Qx;Jx=1;var t=function(){if(Zx)return Kx;Zx=1;var t=vk(),e=qE();return Kx=function(n){return e(n)&&"[object Map]"==t(n)}}(),e=hw(),n=Fw(),r=n&&n.isMap,i=r?e(r):t;return Qx=i}function Sk(){if(rM)return nM;rM=1;var t=function(){if(eM)return tM;eM=1;var t=vk(),e=qE();return tM=function(n){return e(n)&&"[object Set]"==t(n)}}(),e=hw(),n=Fw(),r=n&&n.isSet,i=r?e(r):t;return nM=i}function Tk(){if(oM)return iM;oM=1;var t=BE(),e=GE(),n=WE(),r=function(){if(Cw)return Pw;Cw=1;var t=HE(),e=qw();return Pw=function(n,r){return n&&t(r,e(r),n)}}(),i=function(){if(jw)return Lw;jw=1;var t=HE(),e=$w();return Lw=function(n,r){return n&&t(r,e(r),n)}}(),o=ak(),a=sk(),s=function(){if(ox)return ix;ox=1;var t=HE(),e=hk();return ix=function(n,r){return t(n,e(n),r)}}(),u=function(){if(fx)return dx;fx=1;var t=HE(),e=fk();return dx=function(n,r){return t(n,e(n),r)}}(),c=gk(),h=function(){if(bx)return yx;bx=1;var t=pk(),e=fk(),n=$w();return yx=function(r){return t(r,n,e)}}(),l=vk(),d=function(){if(Ox)return Ax;Ox=1;var t=Object.prototype.hasOwnProperty;return Ax=function(e){var n=e.length,r=new e.constructor(n);return n&&"string"==typeof e[0]&&t.call(e,"index")&&(r.index=e.index,r.input=e.input),r},Ax}(),f=wk(),p=Mk(),g=$E(),m=sw(),v=Nk(),y=AE(),b=Sk(),E=qw(),w=$w(),x="[object Arguments]",M="[object Function]",N="[object Object]",S={};return S[x]=S["[object Array]"]=S["[object ArrayBuffer]"]=S["[object DataView]"]=S["[object Boolean]"]=S["[object Date]"]=S["[object Float32Array]"]=S["[object Float64Array]"]=S["[object Int8Array]"]=S["[object Int16Array]"]=S["[object Int32Array]"]=S["[object Map]"]=S["[object Number]"]=S[N]=S["[object RegExp]"]=S["[object Set]"]=S["[object String]"]=S["[object Symbol]"]=S["[object Uint8Array]"]=S["[object Uint8ClampedArray]"]=S["[object Uint16Array]"]=S["[object Uint32Array]"]=!0,S["[object Error]"]=S[M]=S["[object WeakMap]"]=!1,iM=function T(k,P,C,A,O,R){var _,D=1&P,I=2&P,L=4&P;if(C&&(_=O?C(k,A,O,R):C(k)),void 0!==_)return _;if(!y(k))return k;var j=g(k);if(j){if(_=d(k),!D)return a(k,_)}else{var z=l(k),F=z==M||"[object GeneratorFunction]"==z;if(m(k))return o(k,D);if(z==N||z==x||F&&!O){if(_=I||F?{}:p(k),!D)return I?u(k,i(_,k)):s(k,r(_,k))}else{if(!S[z])return O?k:{};_=f(k,z,D)}}R||(R=new t);var B=R.get(k);if(B)return B;R.set(k,_),b(k)?k.forEach((function(t){_.add(T(t,P,C,t,k,R))})):v(k)&&k.forEach((function(t,e){_.set(e,T(t,P,C,e,k,R))}));var G=j?void 0:(L?I?h:c:I?w:E)(k);return e(G||k,(function(t,e){G&&(t=k[e=t]),n(_,e,T(t,P,C,e,k,R))})),_},iM}function kk(){if(sM)return aM;sM=1;var t=Tk();return aM=function(e){return t(e,4)}}function Pk(){if(cM)return uM;return cM=1,uM=function(t){return function(){return t}}}function Ck(){if(fM)return dM;fM=1;var t=(lM||(lM=1,hM=function(t){return function(e,n,r){for(var i=-1,o=Object(e),a=r(e),s=a.length;s--;){var u=a[t?s:++i];if(!1===n(o[u],u,o))break}return e}}),hM),e=t();return dM=e}function Ak(){if(gM)return pM;gM=1;var t=Ck(),e=qw();return pM=function(n,r){return n&&t(n,r,e)}}function Ok(){if(bM)return yM;bM=1;var t=Ak(),e=function(){if(vM)return mM;vM=1;var t=Hw();return mM=function(e,n){return function(r,i){if(null==r)return r;if(!t(r))return e(r,i);for(var o=r.length,a=n?o:-1,s=Object(r);(n?a--:++a<o)&&!1!==i(s[a],a,s););return r}},mM}(),n=e(t);return yM=n}function Rk(){if(wM)return EM;return wM=1,EM=function(t){return t}}function _k(){if(MM)return xM;MM=1;var t=Rk();return xM=function(e){return"function"==typeof e?e:t}}function Dk(){if(SM)return NM;SM=1;var t=GE(),e=Ok(),n=_k(),r=$E();return NM=function(i,o){return(r(i)?t:e)(i,n(o))}}function Ik(){return kM?TM:(kM=1,TM=Dk())}function Lk(){if(IM)return DM;IM=1;var t=FE(),e=OM?AM:(OM=1,AM=function(t){return this.__data__.set(t,"__lodash_hash_undefined__"),this}),n=_M?RM:(_M=1,RM=function(t){return this.__data__.has(t)});function r(e){var n=-1,r=null==e?0:e.length;for(this.__data__=new t;++n<r;)this.add(e[n])}return r.prototype.add=r.prototype.push=e,r.prototype.has=n,DM=r}function jk(){if(FM)return zM;return FM=1,zM=function(t,e){return t.has(e)}}function zk(){if(GM)return BM;GM=1;var t=Lk(),e=(jM||(jM=1,LM=function(t,e){for(var n=-1,r=null==t?0:t.length;++n<r;)if(e(t[n],n,t))return!0;return!1}),LM),n=jk();return BM=function(r,i,o,a,s,u){var c=1&o,h=r.length,l=i.length;if(h!=l&&!(c&&l>h))return!1;var d=u.get(r),f=u.get(i);if(d&&f)return d==i&&f==r;var p=-1,g=!0,m=2&o?new t:void 0;for(u.set(r,i),u.set(i,r);++p<h;){var v=r[p],y=i[p];if(a)var b=c?a(y,v,p,i,r,u):a(v,y,p,r,i,u);if(void 0!==b){if(b)continue;g=!1;break}if(m){if(!e(i,(function(t,e){if(!n(m,e)&&(v===t||s(v,t,o,a,u)))return m.push(e)}))){g=!1;break}}else if(v!==y&&!s(v,y,o,a,u)){g=!1;break}}return u.delete(r),u.delete(i),g},BM}function Fk(){if(HM)return WM;return HM=1,WM=function(t){var e=-1,n=Array(t.size);return t.forEach((function(t){n[++e]=t})),n},WM}function Bk(){if(YM)return qM;YM=1;var t=PE(),e=yk(),n=ME(),r=zk(),i=(UM||(UM=1,VM=function(t){var e=-1,n=Array(t.size);return t.forEach((function(t,r){n[++e]=[r,t]})),n}),VM),o=Fk(),a=t?t.prototype:void 0,s=a?a.valueOf:void 0;return qM=function(t,a,u,c,h,l,d){switch(u){case"[object DataView]":if(t.byteLength!=a.byteLength||t.byteOffset!=a.byteOffset)return!1;t=t.buffer,a=a.buffer;case"[object ArrayBuffer]":return!(t.byteLength!=a.byteLength||!l(new e(t),new e(a)));case"[object Boolean]":case"[object Date]":case"[object Number]":return n(+t,+a);case"[object Error]":return t.name==a.name&&t.message==a.message;case"[object RegExp]":case"[object String]":return t==a+"";case"[object Map]":var f=i;case"[object Set]":var p=1&c;if(f||(f=o),t.size!=a.size&&!p)return!1;var g=d.get(t);if(g)return g==a;c|=2,d.set(t,a);var m=r(f(t),f(a),c,h,l,d);return d.delete(t),m;case"[object Symbol]":if(s)return s.call(t)==s.call(a)}return!1}}function Gk(){if(ZM)return KM;ZM=1;var t=BE(),e=zk(),n=Bk(),r=function(){if(XM)return $M;XM=1;var t=gk(),e=Object.prototype.hasOwnProperty;return $M=function(n,r,i,o,a,s){var u=1&i,c=t(n),h=c.length;if(h!=t(r).length&&!u)return!1;for(var l=h;l--;){var d=c[l];if(!(u?d in r:e.call(r,d)))return!1}var f=s.get(n),p=s.get(r);if(f&&p)return f==r&&p==n;var g=!0;s.set(n,r),s.set(r,n);for(var m=u;++l<h;){var v=n[d=c[l]],y=r[d];if(o)var b=u?o(y,v,d,r,n,s):o(v,y,d,n,r,s);if(!(void 0===b?v===y||a(v,y,i,o,s):b)){g=!1;break}m||(m="constructor"==d)}if(g&&!m){var E=n.constructor,w=r.constructor;E==w||!("constructor"in n)||!("constructor"in r)||"function"==typeof E&&E instanceof E&&"function"==typeof w&&w instanceof w||(g=!1)}return s.delete(n),s.delete(r),g},$M}(),i=vk(),o=$E(),a=sw(),s=Bw(),u="[object Arguments]",c="[object Array]",h="[object Object]",l=Object.prototype.hasOwnProperty;return KM=function(d,f,p,g,m,v){var y=o(d),b=o(f),E=y?c:i(d),w=b?c:i(f),x=(E=E==u?h:E)==h,M=(w=w==u?h:w)==h,N=E==w;if(N&&a(d)){if(!a(f))return!1;y=!0,x=!1}if(N&&!x)return v||(v=new t),y||s(d)?e(d,f,p,g,m,v):n(d,f,E,p,g,m,v);if(!(1&p)){var S=x&&l.call(d,"__wrapped__"),T=M&&l.call(f,"__wrapped__");if(S||T){var k=S?d.value():d,P=T?f.value():f;return v||(v=new t),m(k,P,p,g,v)}}return!!N&&(v||(v=new t),r(d,f,p,g,m,v))}}function Vk(){if(JM)return QM;JM=1;var t=Gk(),e=qE();return QM=function n(r,i,o,a,s){return r===i||(null==r||null==i||!e(r)&&!e(i)?r!=r&&i!=i:t(r,i,o,a,n,s))},QM}function Uk(){if(rN)return nN;rN=1;var t=AE();return nN=function(e){return e==e&&!t(e)}}function Wk(){if(sN)return aN;return sN=1,aN=function(t,e){return function(n){return null!=n&&(n[t]===e&&(void 0!==e||t in Object(n)))}}}function Hk(){if(cN)return uN;cN=1;var t=function(){if(eN)return tN;eN=1;var t=BE(),e=Vk();return tN=function(n,r,i,o){var a=i.length,s=a,u=!o;if(null==n)return!s;for(n=Object(n);a--;){var c=i[a];if(u&&c[2]?c[1]!==n[c[0]]:!(c[0]in n))return!1}for(;++a<s;){var h=(c=i[a])[0],l=n[h],d=c[1];if(u&&c[2]){if(void 0===l&&!(h in n))return!1}else{var f=new t;if(o)var p=o(l,d,h,n,r,f);if(!(void 0===p?e(d,l,3,o,f):p))return!1}}return!0},tN}(),e=function(){if(oN)return iN;oN=1;var t=Uk(),e=qw();return iN=function(n){for(var r=e(n),i=r.length;i--;){var o=r[i],a=n[o];r[i]=[o,a,t(a)]}return r},iN}(),n=Wk();return uN=function(r){var i=e(r);return 1==i.length&&i[0][2]?n(i[0][0],i[0][1]):function(e){return e===r||t(e,r,i)}}}function qk(){if(lN)return hN;lN=1;var t=CE(),e=qE();return hN=function(n){return"symbol"==typeof n||e(n)&&"[object Symbol]"==t(n)}}function Yk(){if(fN)return dN;fN=1;var t=$E(),e=qk(),n=/\.|\[(?:[^[\]]*|(["'])(?:(?!\1)[^\\]|\\.)*?\1)\]/,r=/^\w*$/;return dN=function(i,o){if(t(i))return!1;var a=typeof i;return!("number"!=a&&"symbol"!=a&&"boolean"!=a&&null!=i&&!e(i))||(r.test(i)||!n.test(i)||null!=o&&i in Object(o))}}function $k(){if(vN)return mN;vN=1;var t=function(){if(gN)return pN;gN=1;var t=FE();function e(n,r){if("function"!=typeof n||null!=r&&"function"!=typeof r)throw new TypeError("Expected a function");var i=function(){var t=arguments,e=r?r.apply(this,t):t[0],o=i.cache;if(o.has(e))return o.get(e);var a=n.apply(this,t);return i.cache=o.set(e,a)||o,a};return i.cache=new(e.Cache||t),i}return e.Cache=t,pN=e}();return mN=function(e){var n=t(e,(function(t){return 500===r.size&&r.clear(),t})),r=n.cache;return n}}function Xk(){if(wN)return EN;return wN=1,EN=function(t,e){for(var n=-1,r=null==t?0:t.length,i=Array(r);++n<r;)i[n]=e(t[n],n,t);return i},EN}function Kk(){if(SN)return NN;SN=1;var t=function(){if(MN)return xN;MN=1;var t=PE(),e=Xk(),n=$E(),r=qk(),i=t?t.prototype:void 0,o=i?i.toString:void 0;return xN=function t(i){if("string"==typeof i)return i;if(n(i))return e(i,t)+"";if(r(i))return o?o.call(i):"";var a=i+"";return"0"==a&&1/i==-1/0?"-0":a},xN}();return NN=function(e){return null==e?"":t(e)}}function Zk(){if(kN)return TN;kN=1;var t=$E(),e=Yk(),n=function(){if(bN)return yN;bN=1;var t=$k(),e=/[^.[\]]+|\[(?:(-?\d+(?:\.\d+)?)|(["'])((?:(?!\2)[^\\]|\\.)*?)\2)\]|(?=(?:\.|\[\])(?:\.|\[\]|$))/g,n=/\\(\\)?/g,r=t((function(t){var r=[];return 46===t.charCodeAt(0)&&r.push(""),t.replace(e,(function(t,e,i,o){r.push(i?o.replace(n,"$1"):e||t)})),r}));return yN=r}(),r=Kk();return TN=function(i,o){return t(i)?i:e(i,o)?[i]:n(r(i))}}function Qk(){if(CN)return PN;CN=1;var t=qk();return PN=function(e){if("string"==typeof e||t(e))return e;var n=e+"";return"0"==n&&1/e==-Infinity?"-0":n}}function Jk(){if(ON)return AN;ON=1;var t=Zk(),e=Qk();return AN=function(n,r){for(var i=0,o=(r=t(r,n)).length;null!=n&&i<o;)n=n[e(r[i++])];return i&&i==o?n:void 0},AN}function tP(){if(jN)return LN;jN=1;var t=Zk(),e=YE(),n=$E(),r=uw(),i=cw(),o=Qk();return LN=function(a,s,u){for(var c=-1,h=(s=t(s,a)).length,l=!1;++c<h;){var d=o(s[c]);if(!(l=null!=a&&u(a,d)))break;a=a[d]}return l||++c!=h?l:!!(h=null==a?0:a.length)&&i(h)&&r(d,h)&&(n(a)||e(a))},LN}function eP(){if(FN)return zN;FN=1;var t=IN?DN:(IN=1,DN=function(t,e){return null!=t&&e in Object(t)}),e=tP();return zN=function(n,r){return null!=n&&e(n,r,t)}}function nP(){if(GN)return BN;GN=1;var t=Vk(),e=function(){if(_N)return RN;_N=1;var t=Jk();return RN=function(e,n,r){var i=null==e?void 0:t(e,n);return void 0===i?r:i}}(),n=eP(),r=Yk(),i=Uk(),o=Wk(),a=Qk();return BN=function(s,u){return r(s)&&i(u)?o(a(s),u):function(r){var i=e(r,s);return void 0===i&&i===u?n(r,s):t(u,i,3)}}}function rP(){if(UN)return VN;return UN=1,VN=function(t){return function(e){return null==e?void 0:e[t]}}}function iP(){if(YN)return qN;YN=1;var t=rP(),e=function(){if(HN)return WN;HN=1;var t=Jk();return WN=function(e){return function(n){return t(n,e)}}}(),n=Yk(),r=Qk();return qN=function(i){return n(i)?t(r(i)):e(i)}}function oP(){if(XN)return $N;XN=1;var t=Hk(),e=nP(),n=Rk(),r=$E(),i=iP();return $N=function(o){return"function"==typeof o?o:null==o?n:"object"==typeof o?r(o)?e(o[0],o[1]):t(o):i(o)}}function aP(){if(ZN)return KN;ZN=1;var t=uk(),e=function(){if(CM)return PM;CM=1;var t=Ok();return PM=function(e,n){var r=[];return t(e,(function(t,e,i){n(t,e,i)&&r.push(t)})),r},PM}(),n=oP(),r=$E();return KN=function(i,o){return(r(i)?t:e)(i,n(o,3))}}function sP(){if(eS)return tS;eS=1;var t=function(){if(JN)return QN;JN=1;var t=Object.prototype.hasOwnProperty;return QN=function(e,n){return null!=e&&t.call(e,n)}}(),e=tP();return tS=function(n,r){return null!=n&&e(n,r,t)}}function uP(){if(rS)return nS;rS=1;var t=Ww(),e=vk(),n=YE(),r=$E(),i=Hw(),o=sw(),a=Vw(),s=Bw(),u=Object.prototype.hasOwnProperty;return nS=function(c){if(null==c)return!0;if(i(c)&&(r(c)||"string"==typeof c||"function"==typeof c.splice||o(c)||s(c)||n(c)))return!c.length;var h=e(c);if("[object Map]"==h||"[object Set]"==h)return!c.size;if(a(c))return!t(c).length;for(var l in c)if(u.call(c,l))return!1;return!0}}function cP(){if(oS)return iS;return oS=1,iS=function(t){return void 0===t}}function hP(){if(sS)return aS;sS=1;var t=Ok(),e=Hw();return aS=function(n,r){var i=-1,o=e(n)?Array(n.length):[];return t(n,(function(t,e,n){o[++i]=r(t,e,n)})),o},aS}function lP(){if(cS)return uS;cS=1;var t=Xk(),e=oP(),n=hP(),r=$E();return uS=function(i,o){return(r(i)?t:n)(i,e(o,3))}}function dP(){if(gS)return pS;gS=1;var t=(lS||(lS=1,hS=function(t,e,n,r){var i=-1,o=null==t?0:t.length;for(r&&o&&(n=t[++i]);++i<o;)n=e(n,t[i],i,t);return n}),hS),e=Ok(),n=oP(),r=(fS||(fS=1,dS=function(t,e,n,r,i){return i(t,(function(t,i,o){n=r?(r=!1,t):e(n,t,i,o)})),n}),dS),i=$E();return pS=function(o,a,s){var u=i(o)?t:r,c=arguments.length<3;return u(o,n(a,4),s,c,e)},pS}function fP(){if(SS)return NS;SS=1;var t=function(){if(bS)return yS;bS=1;var t=rP()("length");return yS=t}(),e=function(){if(wS)return ES;wS=1;var t=RegExp("[\\u200d\\ud800-\\udfff\\u0300-\\u036f\\ufe20-\\ufe2f\\u20d0-\\u20ff\\ufe0e\\ufe0f]");return ES=function(e){return t.test(e)}}(),n=function(){if(MS)return xS;MS=1;var t="\\ud800-\\udfff",e="["+t+"]",n="[\\u0300-\\u036f\\ufe20-\\ufe2f\\u20d0-\\u20ff]",r="\\ud83c[\\udffb-\\udfff]",i="[^"+t+"]",o="(?:\\ud83c[\\udde6-\\uddff]){2}",a="[\\ud800-\\udbff][\\udc00-\\udfff]",s="(?:"+n+"|"+r+")?",u="[\\ufe0e\\ufe0f]?",c=u+s+"(?:\\u200d(?:"+[i,o,a].join("|")+")"+u+s+")*",h="(?:"+[i+n+"?",n,o,a,e].join("|")+")",l=RegExp(r+"(?="+r+")|"+h+c,"g");return xS=function(t){for(var e=l.lastIndex=0;l.test(t);)++e;return e}}();return NS=function(r){return e(r)?n(r):t(r)}}function pP(){if(kS)return TS;kS=1;var t=Ww(),e=vk(),n=Hw(),r=function(){if(vS)return mS;vS=1;var t=CE(),e=$E(),n=qE();return mS=function(r){return"string"==typeof r||!e(r)&&n(r)&&"[object String]"==t(r)}}(),i=fP();return TS=function(o){if(null==o)return 0;if(n(o))return r(o)?i(o):o.length;var a=e(o);return"[object Map]"==a||"[object Set]"==a?o.size:t(o).length}}function gP(){if(CS)return PS;CS=1;var t=GE(),e=xk(),n=Ak(),r=oP(),i=dk(),o=$E(),a=sw(),s=OE(),u=AE(),c=Bw();return PS=function(h,l,d){var f=o(h),p=f||a(h)||c(h);if(l=r(l,4),null==d){var g=h&&h.constructor;d=p?f?new g:[]:u(h)&&s(g)?e(i(h)):{}}return(p?t:n)(h,(function(t,e,n){return l(d,t,e,n)})),d},PS}function mP(){if(_S)return RS;_S=1;var t=lk(),e=function(){if(OS)return AS;OS=1;var t=PE(),e=YE(),n=$E(),r=t?t.isConcatSpreadable:void 0;return AS=function(t){return n(t)||e(t)||!!(r&&t&&t[r])}}();return RS=function n(r,i,o,a,s){var u=-1,c=r.length;for(o||(o=e),s||(s=[]);++u<c;){var h=r[u];i>0&&o(h)?i>1?n(h,i-1,o,a,s):t(s,h):a||(s[s.length]=h)}return s},RS}function vP(){if(jS)return LS;jS=1;var t=IS?DS:(IS=1,DS=function(t,e,n){switch(n.length){case 0:return t.call(e);case 1:return t.call(e,n[0]);case 2:return t.call(e,n[0],n[1]);case 3:return t.call(e,n[0],n[1],n[2])}return t.apply(e,n)}),e=Math.max;return LS=function(n,r,i){return r=e(void 0===r?n.length-1:r,0),function(){for(var o=arguments,a=-1,s=e(o.length-r,0),u=Array(s);++a<s;)u[a]=o[r+a];a=-1;for(var c=Array(r+1);++a<r;)c[a]=o[a];return c[r]=i(u),t(n,this,c)}},LS}function yP(){if(US)return VS;US=1;var t=function(){if(FS)return zS;FS=1;var t=Pk(),e=VE(),n=Rk();return zS=e?function(n,r){return e(n,"toString",{configurable:!0,enumerable:!1,value:t(r),writable:!0})}:n}(),e=function(){if(GS)return BS;GS=1;var t=Date.now;return BS=function(e){var n=0,r=0;return function(){var i=t(),o=16-(i-r);if(r=i,o>0){if(++n>=800)return arguments[0]}else n=0;return e.apply(void 0,arguments)}},BS}(),n=e(t);return VS=n}function bP(){if(HS)return WS;HS=1;var t=Rk(),e=vP(),n=yP();return WS=function(r,i){return n(e(r,i,t),r+"")}}function EP(){if(YS)return qS;return YS=1,qS=function(t,e,n,r){for(var i=t.length,o=n+(r?1:-1);r?o--:++o<i;)if(e(t[o],o,t))return o;return-1},qS}function wP(){if(JS)return QS;JS=1;var t=EP(),e=XS?$S:(XS=1,$S=function(t){return t!=t}),n=(ZS||(ZS=1,KS=function(t,e,n){for(var r=n-1,i=t.length;++r<i;)if(t[r]===e)return r;return-1}),KS);return QS=function(r,i,o){return i==i?n(r,i,o):t(r,e,o)}}function xP(){if(sT)return aT;sT=1;var t=mk(),e=oT?iT:(oT=1,iT=function(){}),n=Fk(),r=t&&1/n(new t([,-0]))[1]==1/0?function(e){return new t(e)}:e;return aT=r}function MP(){if(cT)return uT;cT=1;var t=Lk(),e=function(){if(eT)return tT;eT=1;var t=wP();return tT=function(e,n){return!(null==e||!e.length)&&t(e,n,0)>-1}}(),n=(rT||(rT=1,nT=function(t,e,n){for(var r=-1,i=null==t?0:t.length;++r<i;)if(n(e,t[r]))return!0;return!1}),nT),r=jk(),i=xP(),o=Fk();return uT=function(a,s,u){var c=-1,h=e,l=a.length,d=!0,f=[],p=f;if(u)d=!1,h=n;else if(l>=200){var g=s?null:i(a);if(g)return o(g);d=!1,h=r,p=new t}else p=s?[]:f;t:for(;++c<l;){var m=a[c],v=s?s(m):m;if(m=u||0!==m?m:0,d&&v==v){for(var y=p.length;y--;)if(p[y]===v)continue t;s&&p.push(v),f.push(m)}else h(p,v,u)||(p!==f&&p.push(v),f.push(m))}return f},uT}function NP(){if(lT)return hT;lT=1;var t=Hw(),e=qE();return hT=function(n){return e(n)&&t(n)}}function SP(){if(fT)return dT;fT=1;var t=mP(),e=bP(),n=MP(),r=NP(),i=e((function(e){return n(t(e,1,r,!0))}));return dT=i}function TP(){if(vT)return mT;vT=1;var t=function(){if(gT)return pT;gT=1;var t=Xk();return pT=function(e,n){return t(n,(function(t){return e[t]}))}}(),e=qw();return mT=function(n){return null==n?[]:t(n,e(n))}}function kP(){if(bT)return yT;var t;bT=1;try{t={clone:kk(),constant:Pk(),each:Ik(),filter:aP(),has:sP(),isArray:$E(),isEmpty:uP(),isFunction:OE(),isUndefined:cP(),keys:qw(),map:lP(),reduce:dP(),size:pP(),transform:gP(),union:SP(),values:TP()}}catch(t){}return t||(t=window._),yT=t}function PP(){if(wT)return ET;wT=1;var t=kP();ET=i;var e="\0",n="\0",r="";function i(e){this._isDirected=!t.has(e,"directed")||e.directed,this._isMultigraph=!!t.has(e,"multigraph")&&e.multigraph,this._isCompound=!!t.has(e,"compound")&&e.compound,this._label=void 0,this._defaultNodeLabelFn=t.constant(void 0),this._defaultEdgeLabelFn=t.constant(void 0),this._nodes={},this._isCompound&&(this._parent={},this._children={},this._children[n]={}),this._in={},this._preds={},this._out={},this._sucs={},this._edgeObjs={},this._edgeLabels={}}function o(t,e){t[e]?t[e]++:t[e]=1}function a(t,e){--t[e]||delete t[e]}function s(n,i,o,a){var s=""+i,u=""+o;if(!n&&s>u){var c=s;s=u,u=c}return s+r+u+r+(t.isUndefined(a)?e:a)}function u(t,e){return s(t,e.v,e.w,e.name)}return i.prototype._nodeCount=0,i.prototype._edgeCount=0,i.prototype.isDirected=function(){return this._isDirected},i.prototype.isMultigraph=function(){return this._isMultigraph},i.prototype.isCompound=function(){return this._isCompound},i.prototype.setGraph=function(t){return this._label=t,this},i.prototype.graph=function(){return this._label},i.prototype.setDefaultNodeLabel=function(e){return t.isFunction(e)||(e=t.constant(e)),this._defaultNodeLabelFn=e,this},i.prototype.nodeCount=function(){return this._nodeCount},i.prototype.nodes=function(){return t.keys(this._nodes)},i.prototype.sources=function(){var e=this;return t.filter(this.nodes(),(function(n){return t.isEmpty(e._in[n])}))},i.prototype.sinks=function(){var e=this;return t.filter(this.nodes(),(function(n){return t.isEmpty(e._out[n])}))},i.prototype.setNodes=function(e,n){var r=arguments,i=this;return t.each(e,(function(t){r.length>1?i.setNode(t,n):i.setNode(t)})),this},i.prototype.setNode=function(e,r){return t.has(this._nodes,e)?(arguments.length>1&&(this._nodes[e]=r),this):(this._nodes[e]=arguments.length>1?r:this._defaultNodeLabelFn(e),this._isCompound&&(this._parent[e]=n,this._children[e]={},this._children[n][e]=!0),this._in[e]={},this._preds[e]={},this._out[e]={},this._sucs[e]={},++this._nodeCount,this)},i.prototype.node=function(t){return this._nodes[t]},i.prototype.hasNode=function(e){return t.has(this._nodes,e)},i.prototype.removeNode=function(e){var n=this;if(t.has(this._nodes,e)){var r=function(t){n.removeEdge(n._edgeObjs[t])};delete this._nodes[e],this._isCompound&&(this._removeFromParentsChildList(e),delete this._parent[e],t.each(this.children(e),(function(t){n.setParent(t)})),delete this._children[e]),t.each(t.keys(this._in[e]),r),delete this._in[e],delete this._preds[e],t.each(t.keys(this._out[e]),r),delete this._out[e],delete this._sucs[e],--this._nodeCount}return this},i.prototype.setParent=function(e,r){if(!this._isCompound)throw new Error("Cannot set parent in a non-compound graph");if(t.isUndefined(r))r=n;else{for(var i=r+="";!t.isUndefined(i);i=this.parent(i))if(i===e)throw new Error("Setting "+r+" as parent of "+e+" would create a cycle");this.setNode(r)}return this.setNode(e),this._removeFromParentsChildList(e),this._parent[e]=r,this._children[r][e]=!0,this},i.prototype._removeFromParentsChildList=function(t){delete this._children[this._parent[t]][t]},i.prototype.parent=function(t){if(this._isCompound){var e=this._parent[t];if(e!==n)return e}},i.prototype.children=function(e){if(t.isUndefined(e)&&(e=n),this._isCompound){var r=this._children[e];if(r)return t.keys(r)}else{if(e===n)return this.nodes();if(this.hasNode(e))return[]}},i.prototype.predecessors=function(e){var n=this._preds[e];if(n)return t.keys(n)},i.prototype.successors=function(e){var n=this._sucs[e];if(n)return t.keys(n)},i.prototype.neighbors=function(e){var n=this.predecessors(e);if(n)return t.union(n,this.successors(e))},i.prototype.isLeaf=function(t){return 0===(this.isDirected()?this.successors(t):this.neighbors(t)).length},i.prototype.filterNodes=function(e){var n=new this.constructor({directed:this._isDirected,multigraph:this._isMultigraph,compound:this._isCompound});n.setGraph(this.graph());var r=this;t.each(this._nodes,(function(t,r){e(r)&&n.setNode(r,t)})),t.each(this._edgeObjs,(function(t){n.hasNode(t.v)&&n.hasNode(t.w)&&n.setEdge(t,r.edge(t))}));var i={};function o(t){var e=r.parent(t);return void 0===e||n.hasNode(e)?(i[t]=e,e):e in i?i[e]:o(e)}return this._isCompound&&t.each(n.nodes(),(function(t){n.setParent(t,o(t))})),n},i.prototype.setDefaultEdgeLabel=function(e){return t.isFunction(e)||(e=t.constant(e)),this._defaultEdgeLabelFn=e,this},i.prototype.edgeCount=function(){return this._edgeCount},i.prototype.edges=function(){return t.values(this._edgeObjs)},i.prototype.setPath=function(e,n){var r=this,i=arguments;return t.reduce(e,(function(t,e){return i.length>1?r.setEdge(t,e,n):r.setEdge(t,e),e})),this},i.prototype.setEdge=function(){var e,n,r,i,a=!1,u=arguments[0];"object"==typeof u&&null!==u&&"v"in u?(e=u.v,n=u.w,r=u.name,2===arguments.length&&(i=arguments[1],a=!0)):(e=u,n=arguments[1],r=arguments[3],arguments.length>2&&(i=arguments[2],a=!0)),e=""+e,n=""+n,t.isUndefined(r)||(r=""+r);var c=s(this._isDirected,e,n,r);if(t.has(this._edgeLabels,c))return a&&(this._edgeLabels[c]=i),this;if(!t.isUndefined(r)&&!this._isMultigraph)throw new Error("Cannot set a named edge when isMultigraph = false");this.setNode(e),this.setNode(n),this._edgeLabels[c]=a?i:this._defaultEdgeLabelFn(e,n,r);var h=function(t,e,n,r){var i=""+e,o=""+n;if(!t&&i>o){var a=i;i=o,o=a}var s={v:i,w:o};r&&(s.name=r);return s}(this._isDirected,e,n,r);return e=h.v,n=h.w,Object.freeze(h),this._edgeObjs[c]=h,o(this._preds[n],e),o(this._sucs[e],n),this._in[n][c]=h,this._out[e][c]=h,this._edgeCount++,this},i.prototype.edge=function(t,e,n){var r=1===arguments.length?u(this._isDirected,arguments[0]):s(this._isDirected,t,e,n);return this._edgeLabels[r]},i.prototype.hasEdge=function(e,n,r){var i=1===arguments.length?u(this._isDirected,arguments[0]):s(this._isDirected,e,n,r);return t.has(this._edgeLabels,i)},i.prototype.removeEdge=function(t,e,n){var r=1===arguments.length?u(this._isDirected,arguments[0]):s(this._isDirected,t,e,n),i=this._edgeObjs[r];return i&&(t=i.v,e=i.w,delete this._edgeLabels[r],delete this._edgeObjs[r],a(this._preds[e],t),a(this._sucs[t],e),delete this._in[e][r],delete this._out[t][r],this._edgeCount--),this},i.prototype.inEdges=function(e,n){var r=this._in[e];if(r){var i=t.values(r);return n?t.filter(i,(function(t){return t.v===n})):i}},i.prototype.outEdges=function(e,n){var r=this._out[e];if(r){var i=t.values(r);return n?t.filter(i,(function(t){return t.w===n})):i}},i.prototype.nodeEdges=function(t,e){var n=this.inEdges(t,e);if(n)return n.concat(this.outEdges(t,e))},ET}function CP(){return ST?NT:(ST=1,NT={Graph:PP(),version:MT?xT:(MT=1,xT="2.1.8")})}function AP(){if(kT)return TT;kT=1;var t=kP(),e=PP();function n(e){return t.map(e.nodes(),(function(n){var r=e.node(n),i=e.parent(n),o={v:n};return t.isUndefined(r)||(o.value=r),t.isUndefined(i)||(o.parent=i),o}))}function r(e){return t.map(e.edges(),(function(n){var r=e.edge(n),i={v:n.v,w:n.w};return t.isUndefined(n.name)||(i.name=n.name),t.isUndefined(r)||(i.value=r),i}))}return TT={write:function(e){var i={options:{directed:e.isDirected(),multigraph:e.isMultigraph(),compound:e.isCompound()},nodes:n(e),edges:r(e)};t.isUndefined(e.graph())||(i.value=t.clone(e.graph()));return i},read:function(n){var r=new e(n.options).setGraph(n.value);return t.each(n.nodes,(function(t){r.setNode(t.v,t.value),t.parent&&r.setParent(t.v,t.parent)})),t.each(n.edges,(function(t){r.setEdge({v:t.v,w:t.w,name:t.name},t.value)})),r}}}function OP(){if(CT)return PT;CT=1;var t=kP();return PT=function(e){var n,r={},i=[];function o(i){t.has(r,i)||(r[i]=!0,n.push(i),t.each(e.successors(i),o),t.each(e.predecessors(i),o))}return t.each(e.nodes(),(function(t){n=[],o(t),n.length&&i.push(n)})),i},PT}function RP(){if(OT)return AT;OT=1;var t=kP();function e(){this._arr=[],this._keyIndices={}}return AT=e,e.prototype.size=function(){return this._arr.length},e.prototype.keys=function(){return this._arr.map((function(t){return t.key}))},e.prototype.has=function(e){return t.has(this._keyIndices,e)},e.prototype.priority=function(t){var e=this._keyIndices[t];if(void 0!==e)return this._arr[e].priority},e.prototype.min=function(){if(0===this.size())throw new Error("Queue underflow");return this._arr[0].key},e.prototype.add=function(e,n){var r=this._keyIndices;if(e=String(e),!t.has(r,e)){var i=this._arr,o=i.length;return r[e]=o,i.push({key:e,priority:n}),this._decrease(o),!0}return!1},e.prototype.removeMin=function(){this._swap(0,this._arr.length-1);var t=this._arr.pop();return delete this._keyIndices[t.key],this._heapify(0),t.key},e.prototype.decrease=function(t,e){var n=this._keyIndices[t];if(e>this._arr[n].priority)throw new Error("New priority is greater than current priority. Key: "+t+" Old: "+this._arr[n].priority+" New: "+e);this._arr[n].priority=e,this._decrease(n)},e.prototype._heapify=function(t){var e=this._arr,n=2*t,r=n+1,i=t;n<e.length&&(i=e[n].priority<e[i].priority?n:i,r<e.length&&(i=e[r].priority<e[i].priority?r:i),i!==t&&(this._swap(t,i),this._heapify(i)))},e.prototype._decrease=function(t){for(var e,n=this._arr,r=n[t].priority;0!==t&&!(n[e=t>>1].priority<r);)this._swap(t,e),t=e},e.prototype._swap=function(t,e){var n=this._arr,r=this._keyIndices,i=n[t],o=n[e];n[t]=o,n[e]=i,r[o.key]=t,r[i.key]=e},AT}function _P(){if(_T)return RT;_T=1;var t=kP(),e=RP();RT=function(t,r,i,o){return function(t,n,r,i){var o,a,s={},u=new e,c=function(t){var e=t.v!==o?t.v:t.w,n=s[e],i=r(t),c=a.distance+i;if(i<0)throw new Error("dijkstra does not allow negative edge weights. Bad edge: "+t+" Weight: "+i);c<n.distance&&(n.distance=c,n.predecessor=o,u.decrease(e,c))};t.nodes().forEach((function(t){var e=t===n?0:Number.POSITIVE_INFINITY;s[t]={distance:e},u.add(t,e)}));for(;u.size()>0&&(o=u.removeMin(),(a=s[o]).distance!==Number.POSITIVE_INFINITY);)i(o).forEach(c);return s}(t,String(r),i||n,o||function(e){return t.outEdges(e)})};var n=t.constant(1);return RT}function DP(){if(IT)return DT;IT=1;var t=_P(),e=kP();return DT=function(n,r,i){return e.transform(n.nodes(),(function(e,o){e[o]=t(n,o,r,i)}),{})}}function IP(){if(jT)return LT;jT=1;var t=kP();return LT=function(e){var n=0,r=[],i={},o=[];function a(s){var u=i[s]={onStack:!0,lowlink:n,index:n++};if(r.push(s),e.successors(s).forEach((function(e){t.has(i,e)?i[e].onStack&&(u.lowlink=Math.min(u.lowlink,i[e].index)):(a(e),u.lowlink=Math.min(u.lowlink,i[e].lowlink))})),u.lowlink===u.index){var c,h=[];do{c=r.pop(),i[c].onStack=!1,h.push(c)}while(s!==c);o.push(h)}}return e.nodes().forEach((function(e){t.has(i,e)||a(e)})),o},LT}function LP(){if(FT)return zT;FT=1;var t=kP(),e=IP();return zT=function(n){return t.filter(e(n),(function(t){return t.length>1||1===t.length&&n.hasEdge(t[0],t[0])}))}}function jP(){if(GT)return BT;GT=1;var t=kP();BT=function(t,n,r){return function(t,e,n){var r={},i=t.nodes();return i.forEach((function(t){r[t]={},r[t][t]={distance:0},i.forEach((function(e){t!==e&&(r[t][e]={distance:Number.POSITIVE_INFINITY})})),n(t).forEach((function(n){var i=n.v===t?n.w:n.v,o=e(n);r[t][i]={distance:o,predecessor:t}}))})),i.forEach((function(t){var e=r[t];i.forEach((function(n){var o=r[n];i.forEach((function(n){var r=o[t],i=e[n],a=o[n],s=r.distance+i.distance;s<a.distance&&(a.distance=s,a.predecessor=i.predecessor)}))}))})),r}(t,n||e,r||function(e){return t.outEdges(e)})};var e=t.constant(1);return BT}function zP(){if(UT)return VT;UT=1;var t=kP();function e(e){var r={},i={},o=[];if(t.each(e.sinks(),(function a(s){if(t.has(i,s))throw new n;t.has(r,s)||(i[s]=!0,r[s]=!0,t.each(e.predecessors(s),a),delete i[s],o.push(s))})),t.size(r)!==e.nodeCount())throw new n;return o}function n(){}return VT=e,e.CycleException=n,n.prototype=new Error,VT}function FP(){if(HT)return WT;HT=1;var t=zP();return WT=function(e){try{t(e)}catch(e){if(e instanceof t.CycleException)return!1;throw e}return!0}}function BP(){if(YT)return qT;YT=1;var t=kP();function e(n,r,i,o,a,s){t.has(o,r)||(o[r]=!0,i||s.push(r),t.each(a(r),(function(t){e(n,t,i,o,a,s)})),i&&s.push(r))}return qT=function(n,r,i){t.isArray(r)||(r=[r]);var o=(n.isDirected()?n.successors:n.neighbors).bind(n),a=[],s={};return t.each(r,(function(t){if(!n.hasNode(t))throw new Error("Graph does not have node: "+t);e(n,t,"post"===i,s,o,a)})),a},qT}function GP(){if(XT)return $T;XT=1;var t=BP();return $T=function(e,n){return t(e,n,"post")}}function VP(){if(ZT)return KT;ZT=1;var t=BP();return KT=function(e,n){return t(e,n,"pre")}}function UP(){if(JT)return QT;JT=1;var t=kP(),e=PP(),n=RP();return QT=function(r,i){var o,a=new e,s={},u=new n;function c(t){var e=t.v===o?t.w:t.v,n=u.priority(e);if(void 0!==n){var r=i(t);r<n&&(s[e]=o,u.decrease(e,r))}}if(0===r.nodeCount())return a;t.each(r.nodes(),(function(t){u.add(t,Number.POSITIVE_INFINITY),a.setNode(t)})),u.decrease(r.nodes()[0],0);var h=!1;for(;u.size()>0;){if(o=u.removeMin(),t.has(s,o))a.setEdge(o,s[o]);else{if(h)throw new Error("Input graph is not connected: "+r);h=!0}r.nodeEdges(o).forEach(c)}return a}}ok.exports;try{ik=function(){if(rk)return nk;rk=1;var t=CP();return nk={Graph:t.Graph,json:AP(),alg:ek?tk:(ek=1,tk={components:OP(),dijkstra:_P(),dijkstraAll:DP(),findCycles:LP(),floydWarshall:jP(),isAcyclic:FP(),postorder:GP(),preorder:VP(),prim:UP(),tarjan:IP(),topsort:zP()}),version:t.version}}()}catch(t){}ik||(ik=window.graphlib);var WP,HP,qP,YP,$P,XP,KP,ZP,QP,JP,tC,eC,nC,rC,iC,oC,aC,sC,uC,cC,hC,lC,dC,fC,pC,gC,mC,vC,yC,bC,EC,wC,xC,MC,NC,SC,TC,kC,PC,CC,AC,OC,RC,_C,DC,IC,LC,jC,zC,FC,BC,GC,VC,UC,WC,HC,qC,YC,$C,XC,KC,ZC,QC,JC,tA,eA,nA,rA,iA,oA,aA,sA,uA,cA,hA,lA,dA,fA,pA,gA,mA,vA,yA,bA,EA,wA,xA,MA,NA,SA,TA,kA,PA,CA=ik;function AA(){if(YP)return qP;YP=1;var t=ME(),e=Hw(),n=uw(),r=AE();return qP=function(i,o,a){if(!r(a))return!1;var s=typeof o;return!!("number"==s?e(a)&&n(o,a.length):"string"==s&&o in a)&&t(a[o],i)},qP}function OA(){if(eC)return tC;eC=1;var t=function(){if(JP)return QP;JP=1;var t=/\s/;return QP=function(e){for(var n=e.length;n--&&t.test(e.charAt(n)););return n},QP}(),e=/^\s+/;return tC=function(n){return n?n.slice(0,t(n)+1).replace(e,""):n}}function RA(){if(oC)return iC;oC=1;var t=function(){if(rC)return nC;rC=1;var t=OA(),e=AE(),n=qk(),r=/^[-+]0x[0-9a-f]+$/i,i=/^0b[01]+$/i,o=/^0o[0-7]+$/i,a=parseInt;return nC=function(s){if("number"==typeof s)return s;if(n(s))return NaN;if(e(s)){var u="function"==typeof s.valueOf?s.valueOf():s;s=e(u)?u+"":u}if("string"!=typeof s)return 0===s?s:+s;s=t(s);var c=i.test(s);return c||o.test(s)?a(s.slice(2),c?2:8):r.test(s)?NaN:+s}}(),e=1/0;return iC=function(n){return n?(n=t(n))===e||n===-1/0?17976931348623157e292*(n<0?-1:1):n==n?n:0:0===n?n:0}}function _A(){if(cC)return uC;cC=1;var t=EP(),e=oP(),n=function(){if(sC)return aC;sC=1;var t=RA();return aC=function(e){var n=t(e),r=n%1;return n==n?r?n-r:n:0}}(),r=Math.max;return uC=function(i,o,a){var s=null==i?0:i.length;if(!s)return-1;var u=null==a?0:n(a);return u<0&&(u=r(s+u,0)),t(i,e(o,3),u)},uC}function DA(){if(fC)return dC;fC=1;var t=mP();return dC=function(e){return(null==e?0:e.length)?t(e,1):[]}}function IA(){if(wC)return EC;wC=1;var t=qk();return EC=function(e,n,r){for(var i=-1,o=e.length;++i<o;){var a=e[i],s=n(a);if(null!=s&&(void 0===u?s==s&&!t(s):r(s,u)))var u=s,c=a}return c},EC}function LA(){if(kC)return TC;kC=1;var t=UE(),e=ME();return TC=function(n,r,i){(void 0!==i&&!e(n[r],i)||void 0===i&&!(r in n))&&t(n,r,i)}}function jA(){if(OC)return AC;return OC=1,AC=function(t,e){if(("constructor"!==e||"function"!=typeof t[e])&&"__proto__"!=e)return t[e]}}function zA(){if(IC)return DC;IC=1;var t=LA(),e=ak(),n=Ek(),r=sk(),i=Mk(),o=YE(),a=$E(),s=NP(),u=sw(),c=OE(),h=AE(),l=function(){if(CC)return PC;CC=1;var t=CE(),e=dk(),n=qE(),r=Function.prototype,i=Object.prototype,o=r.toString,a=i.hasOwnProperty,s=o.call(Object);return PC=function(r){if(!n(r)||"[object Object]"!=t(r))return!1;var i=e(r);if(null===i)return!0;var u=a.call(i,"constructor")&&i.constructor;return"function"==typeof u&&u instanceof u&&o.call(u)==s}}(),d=Bw(),f=jA(),p=function(){if(_C)return RC;_C=1;var t=HE(),e=$w();return RC=function(n){return t(n,e(n))}}();return DC=function(g,m,v,y,b,E,w){var x=f(g,v),M=f(m,v),N=w.get(M);if(N)t(g,v,N);else{var S=E?E(x,M,v+"",g,m,w):void 0,T=void 0===S;if(T){var k=a(M),P=!k&&u(M),C=!k&&!P&&d(M);S=M,k||P||C?a(x)?S=x:s(x)?S=r(x):P?(T=!1,S=e(M,!0)):C?(T=!1,S=n(M,!0)):S=[]:l(M)||o(M)?(S=x,o(x)?S=p(x):h(x)&&!c(x)||(S=i(M))):T=!1}T&&(w.set(M,S),b(S,M,y,E,w),w.delete(M)),t(g,v,S)}}}function FA(){if(UC)return VC;return UC=1,VC=function(t,e){return t<e}}function BA(){if(JC)return QC;JC=1;var t=Jk(),e=function(){if(ZC)return KC;ZC=1;var t=WE(),e=Zk(),n=uw(),r=AE(),i=Qk();return KC=function(o,a,s,u){if(!r(o))return o;for(var c=-1,h=(a=e(a,o)).length,l=h-1,d=o;null!=d&&++c<h;){var f=i(a[c]),p=s;if("__proto__"===f||"constructor"===f||"prototype"===f)return o;if(c!=l){var g=d[f];void 0===(p=u?u(g,f,d):void 0)&&(p=r(g)?g:n(a[c+1])?[]:{})}t(d,f,p),d=d[f]}return o},KC}(),n=Zk();return QC=function(r,i,o){for(var a=-1,s=i.length,u={};++a<s;){var c=i[a],h=t(r,c);o(h,c)&&e(u,n(c,r),h)}return u},QC}function GA(){if(cA)return uA;cA=1;var t=function(){if(sA)return aA;sA=1;var t=Math.ceil,e=Math.max;return aA=function(n,r,i,o){for(var a=-1,s=e(t((r-n)/(i||1)),0),u=Array(s);s--;)u[o?s:++a]=n,n+=i;return u},aA}(),e=AA(),n=RA();return uA=function(r){return function(i,o,a){return a&&"number"!=typeof a&&e(i,o,a)&&(o=a=void 0),i=n(i),void 0===o?(o=i,i=0):o=n(o),a=void 0===a?i<o?1:-1:n(a),t(i,o,a,r)}},uA}function VA(){if(vA)return mA;vA=1;var t=function(){if(gA)return pA;gA=1;var t=qk();return pA=function(e,n){if(e!==n){var r=void 0!==e,i=null===e,o=e==e,a=t(e),s=void 0!==n,u=null===n,c=n==n,h=t(n);if(!u&&!h&&!a&&e>n||a&&s&&c&&!u&&!h||i&&s&&c||!r&&c||!o)return 1;if(!i&&!a&&!h&&e<n||h&&r&&o&&!i&&!a||u&&r&&o||!s&&o||!c)return-1}return 0}}();return mA=function(e,n,r){for(var i=-1,o=e.criteria,a=n.criteria,s=o.length,u=r.length;++i<s;){var c=t(o[i],a[i]);if(c)return i>=u?c:c*("desc"==r[i]?-1:1)}return e.index-n.index},mA}function UA(){if(bA)return yA;bA=1;var t=Xk(),e=Jk(),n=oP(),r=hP(),i=(fA||(fA=1,dA=function(t,e){var n=t.length;for(t.sort(e);n--;)t[n]=t[n].value;return t}),dA),o=hw(),a=VA(),s=Rk(),u=$E();return yA=function(c,h,l){h=h.length?t(h,(function(t){return u(t)?function(n){return e(n,1===t.length?t[0]:t)}:t})):[s];var d=-1;h=t(h,o(n));var f=r(c,(function(e,n,r){return{criteria:t(h,(function(t){return t(e)})),index:++d,value:e}}));return i(f,(function(t,e){return a(t,e,l)}))},yA}try{PA={cloneDeep:function(){if(HP)return WP;HP=1;var t=Tk();return WP=function(e){return t(e,5)}}(),constant:Pk(),defaults:function(){if(XP)return $P;XP=1;var t=bP(),e=ME(),n=AA(),r=$w(),i=Object.prototype,o=i.hasOwnProperty,a=t((function(t,a){t=Object(t);var s=-1,u=a.length,c=u>2?a[2]:void 0;for(c&&n(a[0],a[1],c)&&(u=1);++s<u;)for(var h=a[s],l=r(h),d=-1,f=l.length;++d<f;){var p=l[d],g=t[p];(void 0===g||e(g,i[p])&&!o.call(t,p))&&(t[p]=h[p])}return t}));return $P=a}(),each:Ik(),filter:aP(),find:function(){if(lC)return hC;lC=1;var t=function(){if(ZP)return KP;ZP=1;var t=oP(),e=Hw(),n=qw();return KP=function(r){return function(i,o,a){var s=Object(i);if(!e(i)){var u=t(o,3);i=n(i),o=function(t){return u(s[t],t,s)}}var c=r(i,o,a);return c>-1?s[u?i[c]:c]:void 0}},KP}(),e=t(_A());return hC=e}(),flatten:DA(),forEach:Dk(),forIn:function(){if(gC)return pC;gC=1;var t=Ck(),e=_k(),n=$w();return pC=function(r,i){return null==r?r:t(r,e(i),n)}}(),has:sP(),isUndefined:cP(),last:(vC||(vC=1,mC=function(t){var e=null==t?0:t.length;return e?t[e-1]:void 0}),mC),map:lP(),mapValues:function(){if(bC)return yC;bC=1;var t=UE(),e=Ak(),n=oP();return yC=function(r,i){var o={};return i=n(i,3),e(r,(function(e,n,r){t(o,n,i(e,n,r))})),o}}(),max:function(){if(SC)return NC;SC=1;var t=IA(),e=MC?xC:(MC=1,xC=function(t,e){return t>e}),n=Rk();return NC=function(r){return r&&r.length?t(r,n,e):void 0}}(),merge:function(){if(GC)return BC;GC=1;var t=function(){if(jC)return LC;jC=1;var t=BE(),e=LA(),n=Ck(),r=zA(),i=AE(),o=$w(),a=jA();return LC=function s(u,c,h,l,d){u!==c&&n(c,(function(n,o){if(d||(d=new t),i(n))r(u,c,o,h,s,l,d);else{var f=l?l(a(u,o),n,o+"",u,c,d):void 0;void 0===f&&(f=n),e(u,o,f)}}),o)},LC}(),e=function(){if(FC)return zC;FC=1;var t=bP(),e=AA();return zC=function(n){return t((function(t,r){var i=-1,o=r.length,a=o>1?r[o-1]:void 0,s=o>2?r[2]:void 0;for(a=n.length>3&&"function"==typeof a?(o--,a):void 0,s&&e(r[0],r[1],s)&&(a=o<3?void 0:a,o=1),t=Object(t);++i<o;){var u=r[i];u&&n(t,u,i,a)}return t}))},zC}(),n=e((function(e,n,r){t(e,n,r)}));return BC=n}(),min:function(){if(HC)return WC;HC=1;var t=IA(),e=FA(),n=Rk();return WC=function(r){return r&&r.length?t(r,n,e):void 0}}(),minBy:function(){if(YC)return qC;YC=1;var t=IA(),e=oP(),n=FA();return qC=function(r,i){return r&&r.length?t(r,e(i,2),n):void 0}}(),now:function(){if(XC)return $C;XC=1;var t=kE();return $C=function(){return t.Date.now()}}(),pick:function(){if(oA)return iA;oA=1;var t=function(){if(eA)return tA;eA=1;var t=BA(),e=eP();return tA=function(n,r){return t(n,r,(function(t,r){return e(n,r)}))}}(),e=function(){if(rA)return nA;rA=1;var t=DA(),e=vP(),n=yP();return nA=function(r){return n(e(r,void 0,t),r+"")}}(),n=e((function(e,n){return null==e?{}:t(e,n)}));return iA=n}(),range:function(){if(lA)return hA;lA=1;var t=GA()();return hA=t}(),reduce:dP(),sortBy:function(){if(wA)return EA;wA=1;var t=mP(),e=UA(),n=bP(),r=AA(),i=n((function(n,i){if(null==n)return[];var o=i.length;return o>1&&r(n,i[0],i[1])?i=[]:o>2&&r(i[0],i[1],i[2])&&(i=[i[0]]),e(n,t(i,1),[])}));return EA=i}(),uniqueId:function(){if(MA)return xA;MA=1;var t=Kk(),e=0;return xA=function(n){var r=++e;return t(n)+r},xA}(),values:TP(),zipObject:function(){if(kA)return TA;kA=1;var t=WE(),e=(SA||(SA=1,NA=function(t,e,n){for(var r=-1,i=t.length,o=e.length,a={};++r<i;){var s=r<o?e[r]:void 0;n(a,t[r],s)}return a}),NA);return TA=function(n,r){return e(n||[],r||[],t)},TA}()}}catch(t){}PA||(PA=window._);var WA=PA,HA=qA;function qA(){var t={};t._next=t._prev=t,this._sentinel=t}function YA(t){t._prev._next=t._next,t._next._prev=t._prev,delete t._next,delete t._prev}function $A(t,e){if("_next"!==t&&"_prev"!==t)return e}qA.prototype.dequeue=function(){var t=this._sentinel,e=t._prev;if(e!==t)return YA(e),e},qA.prototype.enqueue=function(t){var e=this._sentinel;t._prev&&t._next&&YA(t),t._next=e._next,e._next._prev=t,e._next=t,t._prev=e},qA.prototype.toString=function(){for(var t=[],e=this._sentinel,n=e._prev;n!==e;)t.push(JSON.stringify(n,$A)),n=n._prev;return"["+t.join(", ")+"]"};var XA=WA,KA=CA.Graph,ZA=HA,QA=function(t,e){if(t.nodeCount()<=1)return[];var n=function(t,e){var n=new KA,r=0,i=0;XA.forEach(t.nodes(),(function(t){n.setNode(t,{v:t,in:0,out:0})})),XA.forEach(t.edges(),(function(t){var o=n.edge(t.v,t.w)||0,a=e(t),s=o+a;n.setEdge(t.v,t.w,s),i=Math.max(i,n.node(t.v).out+=a),r=Math.max(r,n.node(t.w).in+=a)}));var o=XA.range(i+r+3).map((function(){return new ZA})),a=r+1;return XA.forEach(n.nodes(),(function(t){eO(o,a,n.node(t))})),{graph:n,buckets:o,zeroIdx:a}}(t,e||JA),r=function(t,e,n){var r,i=[],o=e[e.length-1],a=e[0];for(;t.nodeCount();){for(;r=a.dequeue();)tO(t,e,n,r);for(;r=o.dequeue();)tO(t,e,n,r);if(t.nodeCount())for(var s=e.length-2;s>0;--s)if(r=e[s].dequeue()){i=i.concat(tO(t,e,n,r,!0));break}}return i}(n.graph,n.buckets,n.zeroIdx);return XA.flatten(XA.map(r,(function(e){return t.outEdges(e.v,e.w)})),!0)},JA=XA.constant(1);function tO(t,e,n,r,i){var o=i?[]:void 0;return XA.forEach(t.inEdges(r.v),(function(r){var a=t.edge(r),s=t.node(r.v);i&&o.push({v:r.v,w:r.w}),s.out-=a,eO(e,n,s)})),XA.forEach(t.outEdges(r.v),(function(r){var i=t.edge(r),o=r.w,a=t.node(o);a.in-=i,eO(e,n,a)})),t.removeNode(r.v),o}function eO(t,e,n){n.out?n.in?t[n.out-n.in+e].enqueue(n):t[t.length-1].enqueue(n):t[0].enqueue(n)}var nO=WA,rO=QA,iO={run:function(t){var e="greedy"===t.graph().acyclicer?rO(t,function(t){return function(e){return t.edge(e).weight}}(t)):function(t){var e=[],n={},r={};function i(o){nO.has(r,o)||(r[o]=!0,n[o]=!0,nO.forEach(t.outEdges(o),(function(t){nO.has(n,t.w)?e.push(t):i(t.w)})),delete n[o])}return nO.forEach(t.nodes(),i),e}(t);nO.forEach(e,(function(e){var n=t.edge(e);t.removeEdge(e),n.forwardName=e.name,n.reversed=!0,t.setEdge(e.w,e.v,n,nO.uniqueId("rev"))}))},undo:function(t){nO.forEach(t.edges(),(function(e){var n=t.edge(e);if(n.reversed){t.removeEdge(e);var r=n.forwardName;delete n.reversed,delete n.forwardName,t.setEdge(e.w,e.v,n,r)}}))}};var oO=WA,aO=CA.Graph,sO={addDummyNode:uO,simplify:function(t){var e=(new aO).setGraph(t.graph());return oO.forEach(t.nodes(),(function(n){e.setNode(n,t.node(n))})),oO.forEach(t.edges(),(function(n){var r=e.edge(n.v,n.w)||{weight:0,minlen:1},i=t.edge(n);e.setEdge(n.v,n.w,{weight:r.weight+i.weight,minlen:Math.max(r.minlen,i.minlen)})})),e},asNonCompoundGraph:function(t){var e=new aO({multigraph:t.isMultigraph()}).setGraph(t.graph());return oO.forEach(t.nodes(),(function(n){t.children(n).length||e.setNode(n,t.node(n))})),oO.forEach(t.edges(),(function(n){e.setEdge(n,t.edge(n))})),e},successorWeights:function(t){var e=oO.map(t.nodes(),(function(e){var n={};return oO.forEach(t.outEdges(e),(function(e){n[e.w]=(n[e.w]||0)+t.edge(e).weight})),n}));return oO.zipObject(t.nodes(),e)},predecessorWeights:function(t){var e=oO.map(t.nodes(),(function(e){var n={};return oO.forEach(t.inEdges(e),(function(e){n[e.v]=(n[e.v]||0)+t.edge(e).weight})),n}));return oO.zipObject(t.nodes(),e)},intersectRect:function(t,e){var n,r,i=t.x,o=t.y,a=e.x-i,s=e.y-o,u=t.width/2,c=t.height/2;if(!a&&!s)throw new Error("Not possible to find intersection inside of the rectangle");Math.abs(s)*u>Math.abs(a)*c?(s<0&&(c=-c),n=c*a/s,r=c):(a<0&&(u=-u),n=u,r=u*s/a);return{x:i+n,y:o+r}},buildLayerMatrix:function(t){var e=oO.map(oO.range(cO(t)+1),(function(){return[]}));return oO.forEach(t.nodes(),(function(n){var r=t.node(n),i=r.rank;oO.isUndefined(i)||(e[i][r.order]=n)})),e},normalizeRanks:function(t){var e=oO.min(oO.map(t.nodes(),(function(e){return t.node(e).rank})));oO.forEach(t.nodes(),(function(n){var r=t.node(n);oO.has(r,"rank")&&(r.rank-=e)}))},removeEmptyRanks:function(t){var e=oO.min(oO.map(t.nodes(),(function(e){return t.node(e).rank}))),n=[];oO.forEach(t.nodes(),(function(r){var i=t.node(r).rank-e;n[i]||(n[i]=[]),n[i].push(r)}));var r=0,i=t.graph().nodeRankFactor;oO.forEach(n,(function(e,n){oO.isUndefined(e)&&n%i!=0?--r:r&&oO.forEach(e,(function(e){t.node(e).rank+=r}))}))},addBorderNode:function(t,e,n,r){var i={width:0,height:0};arguments.length>=4&&(i.rank=n,i.order=r);return uO(t,"border",i,e)},maxRank:cO,partition:function(t,e){var n={lhs:[],rhs:[]};return oO.forEach(t,(function(t){e(t)?n.lhs.push(t):n.rhs.push(t)})),n},time:function(t,e){var n=oO.now();try{return e()}finally{console.log(t+" time: "+(oO.now()-n)+"ms")}},notime:function(t,e){return e()}};function uO(t,e,n,r){var i;do{i=oO.uniqueId(r)}while(t.hasNode(i));return n.dummy=e,t.setNode(i,n),i}function cO(t){return oO.max(oO.map(t.nodes(),(function(e){var n=t.node(e).rank;if(!oO.isUndefined(n))return n})))}var hO=WA,lO=sO,dO={run:function(t){t.graph().dummyChains=[],hO.forEach(t.edges(),(function(e){!function(t,e){var n,r,i,o=e.v,a=t.node(o).rank,s=e.w,u=t.node(s).rank,c=e.name,h=t.edge(e),l=h.labelRank;if(u===a+1)return;for(t.removeEdge(e),i=0,++a;a<u;++i,++a)h.points=[],r={width:0,height:0,edgeLabel:h,edgeObj:e,rank:a},n=lO.addDummyNode(t,"edge",r,"_d"),a===l&&(r.width=h.width,r.height=h.height,r.dummy="edge-label",r.labelpos=h.labelpos),t.setEdge(o,n,{weight:h.weight},c),0===i&&t.graph().dummyChains.push(n),o=n;t.setEdge(o,s,{weight:h.weight},c)}(t,e)}))},undo:function(t){hO.forEach(t.graph().dummyChains,(function(e){var n,r=t.node(e),i=r.edgeLabel;for(t.setEdge(r.edgeObj,i);r.dummy;)n=t.successors(e)[0],t.removeNode(e),i.points.push({x:r.x,y:r.y}),"edge-label"===r.dummy&&(i.x=r.x,i.y=r.y,i.width=r.width,i.height=r.height),e=n,r=t.node(e)}))}};var fO=WA,pO={longestPath:function(t){var e={};fO.forEach(t.sources(),(function n(r){var i=t.node(r);if(fO.has(e,r))return i.rank;e[r]=!0;var o=fO.min(fO.map(t.outEdges(r),(function(e){return n(e.w)-t.edge(e).minlen})));return o!==Number.POSITIVE_INFINITY&&null!=o||(o=0),i.rank=o}))},slack:function(t,e){return t.node(e.w).rank-t.node(e.v).rank-t.edge(e).minlen}};var gO=WA,mO=CA.Graph,vO=pO.slack,yO=function(t){var e,n,r=new mO({directed:!1}),i=t.nodes()[0],o=t.nodeCount();r.setNode(i,{});for(;bO(r,t)<o;)e=EO(r,t),n=r.hasNode(e.v)?vO(t,e):-vO(t,e),wO(r,t,n);return r};function bO(t,e){return gO.forEach(t.nodes(),(function n(r){gO.forEach(e.nodeEdges(r),(function(i){var o=i.v,a=r===o?i.w:o;t.hasNode(a)||vO(e,i)||(t.setNode(a,{}),t.setEdge(r,a,{}),n(a))}))})),t.nodeCount()}function EO(t,e){return gO.minBy(e.edges(),(function(n){if(t.hasNode(n.v)!==t.hasNode(n.w))return vO(e,n)}))}function wO(t,e,n){gO.forEach(t.nodes(),(function(t){e.node(t).rank+=n}))}var xO=WA,MO=yO,NO=pO.slack,SO=pO.longestPath,TO=CA.alg.preorder,kO=CA.alg.postorder,PO=sO.simplify,CO=AO;function AO(t){t=PO(t),SO(t);var e,n=MO(t);for(_O(n),OO(n,t);e=IO(n);)jO(n,t,e,LO(n,t,e))}function OO(t,e){var n=kO(t,t.nodes());n=n.slice(0,n.length-1),xO.forEach(n,(function(n){!function(t,e,n){var r=t.node(n),i=r.parent;t.edge(n,i).cutvalue=RO(t,e,n)}(t,e,n)}))}function RO(t,e,n){var r=t.node(n).parent,i=!0,o=e.edge(n,r),a=0;return o||(i=!1,o=e.edge(r,n)),a=o.weight,xO.forEach(e.nodeEdges(n),(function(o){var s,u,c=o.v===n,h=c?o.w:o.v;if(h!==r){var l=c===i,d=e.edge(o).weight;if(a+=l?d:-d,s=n,u=h,t.hasEdge(s,u)){var f=t.edge(n,h).cutvalue;a+=l?-f:f}}})),a}function _O(t,e){arguments.length<2&&(e=t.nodes()[0]),DO(t,{},1,e)}function DO(t,e,n,r,i){var o=n,a=t.node(r);return e[r]=!0,xO.forEach(t.neighbors(r),(function(i){xO.has(e,i)||(n=DO(t,e,n,i,r))})),a.low=o,a.lim=n++,i?a.parent=i:delete a.parent,n}function IO(t){return xO.find(t.edges(),(function(e){return t.edge(e).cutvalue<0}))}function LO(t,e,n){var r=n.v,i=n.w;e.hasEdge(r,i)||(r=n.w,i=n.v);var o=t.node(r),a=t.node(i),s=o,u=!1;o.lim>a.lim&&(s=a,u=!0);var c=xO.filter(e.edges(),(function(e){return u===zO(t,t.node(e.v),s)&&u!==zO(t,t.node(e.w),s)}));return xO.minBy(c,(function(t){return NO(e,t)}))}function jO(t,e,n,r){var i=n.v,o=n.w;t.removeEdge(i,o),t.setEdge(r.v,r.w,{}),_O(t),OO(t,e),function(t,e){var n=xO.find(t.nodes(),(function(t){return!e.node(t).parent})),r=TO(t,n);r=r.slice(1),xO.forEach(r,(function(n){var r=t.node(n).parent,i=e.edge(n,r),o=!1;i||(i=e.edge(r,n),o=!0),e.node(n).rank=e.node(r).rank+(o?i.minlen:-i.minlen)}))}(t,e)}function zO(t,e,n){return n.low<=e.lim&&e.lim<=n.lim}AO.initLowLimValues=_O,AO.initCutValues=OO,AO.calcCutValue=RO,AO.leaveEdge=IO,AO.enterEdge=LO,AO.exchangeEdges=jO;var FO=pO.longestPath,BO=yO,GO=CO,VO=function(t){switch(t.graph().ranker){case"network-simplex":default:WO(t);break;case"tight-tree":!function(t){FO(t),BO(t)}(t);break;case"longest-path":UO(t)}};var UO=FO;function WO(t){GO(t)}var HO=WA,qO=function(t){var e=function(t){var e={},n=0;function r(i){var o=n;HO.forEach(t.children(i),r),e[i]={low:o,lim:n++}}return HO.forEach(t.children(),r),e}(t);HO.forEach(t.graph().dummyChains,(function(n){for(var r=t.node(n),i=r.edgeObj,o=function(t,e,n,r){var i,o,a=[],s=[],u=Math.min(e[n].low,e[r].low),c=Math.max(e[n].lim,e[r].lim);i=n;do{i=t.parent(i),a.push(i)}while(i&&(e[i].low>u||c>e[i].lim));o=i,i=r;for(;(i=t.parent(i))!==o;)s.push(i);return{path:a.concat(s.reverse()),lca:o}}(t,e,i.v,i.w),a=o.path,s=o.lca,u=0,c=a[u],h=!0;n!==i.w;){if(r=t.node(n),h){for(;(c=a[u])!==s&&t.node(c).maxRank<r.rank;)u++;c===s&&(h=!1)}if(!h){for(;u<a.length-1&&t.node(c=a[u+1]).minRank<=r.rank;)u++;c=a[u]}t.setParent(n,c),n=t.successors(n)[0]}}))};var YO=WA,$O=sO,XO={run:function(t){var e=$O.addDummyNode(t,"root",{},"_root"),n=function(t){var e={};function n(r,i){var o=t.children(r);o&&o.length&&YO.forEach(o,(function(t){n(t,i+1)})),e[r]=i}return YO.forEach(t.children(),(function(t){n(t,1)})),e}(t),r=YO.max(YO.values(n))-1,i=2*r+1;t.graph().nestingRoot=e,YO.forEach(t.edges(),(function(e){t.edge(e).minlen*=i}));var o=function(t){return YO.reduce(t.edges(),(function(e,n){return e+t.edge(n).weight}),0)}(t)+1;YO.forEach(t.children(),(function(a){KO(t,e,i,o,r,n,a)})),t.graph().nodeRankFactor=i},cleanup:function(t){var e=t.graph();t.removeNode(e.nestingRoot),delete e.nestingRoot,YO.forEach(t.edges(),(function(e){t.edge(e).nestingEdge&&t.removeEdge(e)}))}};function KO(t,e,n,r,i,o,a){var s=t.children(a);if(s.length){var u=$O.addBorderNode(t,"_bt"),c=$O.addBorderNode(t,"_bb"),h=t.node(a);t.setParent(u,a),h.borderTop=u,t.setParent(c,a),h.borderBottom=c,YO.forEach(s,(function(s){KO(t,e,n,r,i,o,s);var h=t.node(s),l=h.borderTop?h.borderTop:s,d=h.borderBottom?h.borderBottom:s,f=h.borderTop?r:2*r,p=l!==d?1:i-o[a]+1;t.setEdge(u,l,{weight:f,minlen:p,nestingEdge:!0}),t.setEdge(d,c,{weight:f,minlen:p,nestingEdge:!0})})),t.parent(a)||t.setEdge(e,u,{weight:0,minlen:i+o[a]})}else a!==e&&t.setEdge(e,a,{weight:0,minlen:n})}var ZO=WA,QO=sO,JO=function(t){ZO.forEach(t.children(),(function e(n){var r=t.children(n),i=t.node(n);if(r.length&&ZO.forEach(r,e),ZO.has(i,"minRank")){i.borderLeft=[],i.borderRight=[];for(var o=i.minRank,a=i.maxRank+1;o<a;++o)tR(t,"borderLeft","_bl",n,i,o),tR(t,"borderRight","_br",n,i,o)}}))};function tR(t,e,n,r,i,o){var a={width:0,height:0,rank:o,borderType:e},s=i[e][o-1],u=QO.addDummyNode(t,"border",a,n);i[e][o]=u,t.setParent(u,r),s&&t.setEdge(s,u,{weight:1})}var eR=WA,nR={adjust:function(t){var e=t.graph().rankdir.toLowerCase();"lr"!==e&&"rl"!==e||rR(t)},undo:function(t){var e=t.graph().rankdir.toLowerCase();"bt"!==e&&"rl"!==e||function(t){eR.forEach(t.nodes(),(function(e){oR(t.node(e))})),eR.forEach(t.edges(),(function(e){var n=t.edge(e);eR.forEach(n.points,oR),eR.has(n,"y")&&oR(n)}))}(t);"lr"!==e&&"rl"!==e||(!function(t){eR.forEach(t.nodes(),(function(e){aR(t.node(e))})),eR.forEach(t.edges(),(function(e){var n=t.edge(e);eR.forEach(n.points,aR),eR.has(n,"x")&&aR(n)}))}(t),rR(t))}};function rR(t){eR.forEach(t.nodes(),(function(e){iR(t.node(e))})),eR.forEach(t.edges(),(function(e){iR(t.edge(e))}))}function iR(t){var e=t.width;t.width=t.height,t.height=e}function oR(t){t.y=-t.y}function aR(t){var e=t.x;t.x=t.y,t.y=e}var sR=WA,uR=function(t){var e={},n=sR.filter(t.nodes(),(function(e){return!t.children(e).length})),r=sR.max(sR.map(n,(function(e){return t.node(e).rank}))),i=sR.map(sR.range(r+1),(function(){return[]}));function o(n){if(!sR.has(e,n)){e[n]=!0;var r=t.node(n);i[r.rank].push(n),sR.forEach(t.successors(n),o)}}var a=sR.sortBy(n,(function(e){return t.node(e).rank}));return sR.forEach(a,o),i};var cR=WA,hR=function(t,e){for(var n=0,r=1;r<e.length;++r)n+=lR(t,e[r-1],e[r]);return n};function lR(t,e,n){for(var r=cR.zipObject(n,cR.map(n,(function(t,e){return e}))),i=cR.flatten(cR.map(e,(function(e){return cR.sortBy(cR.map(t.outEdges(e),(function(e){return{pos:r[e.w],weight:t.edge(e).weight}})),"pos")})),!0),o=1;o<n.length;)o<<=1;var a=2*o-1;o-=1;var s=cR.map(new Array(a),(function(){return 0})),u=0;return cR.forEach(i.forEach((function(t){var e=t.pos+o;s[e]+=t.weight;for(var n=0;e>0;)e%2&&(n+=s[e+1]),s[e=e-1>>1]+=t.weight;u+=t.weight*n}))),u}var dR=WA;var fR=WA,pR=function(t,e){var n={};return fR.forEach(t,(function(t,e){var r=n[t.v]={indegree:0,in:[],out:[],vs:[t.v],i:e};fR.isUndefined(t.barycenter)||(r.barycenter=t.barycenter,r.weight=t.weight)})),fR.forEach(e.edges(),(function(t){var e=n[t.v],r=n[t.w];fR.isUndefined(e)||fR.isUndefined(r)||(r.indegree++,e.out.push(n[t.w]))})),function(t){var e=[];function n(t){return function(e){e.merged||(fR.isUndefined(e.barycenter)||fR.isUndefined(t.barycenter)||e.barycenter>=t.barycenter)&&function(t,e){var n=0,r=0;t.weight&&(n+=t.barycenter*t.weight,r+=t.weight);e.weight&&(n+=e.barycenter*e.weight,r+=e.weight);t.vs=e.vs.concat(t.vs),t.barycenter=n/r,t.weight=r,t.i=Math.min(e.i,t.i),e.merged=!0}(t,e)}}function r(e){return function(n){n.in.push(e),0==--n.indegree&&t.push(n)}}for(;t.length;){var i=t.pop();e.push(i),fR.forEach(i.in.reverse(),n(i)),fR.forEach(i.out,r(i))}return fR.map(fR.filter(e,(function(t){return!t.merged})),(function(t){return fR.pick(t,["vs","i","barycenter","weight"])}))}(fR.filter(n,(function(t){return!t.indegree})))};var gR=WA,mR=sO;function vR(t,e,n){for(var r;e.length&&(r=gR.last(e)).i<=n;)e.pop(),t.push(r.vs),n++;return n}var yR=WA,bR=function(t,e){return dR.map(e,(function(e){var n=t.inEdges(e);if(n.length){var r=dR.reduce(n,(function(e,n){var r=t.edge(n),i=t.node(n.v);return{sum:e.sum+r.weight*i.order,weight:e.weight+r.weight}}),{sum:0,weight:0});return{v:e,barycenter:r.sum/r.weight,weight:r.weight}}return{v:e}}))},ER=pR,wR=function(t,e){var n=mR.partition(t,(function(t){return gR.has(t,"barycenter")})),r=n.lhs,i=gR.sortBy(n.rhs,(function(t){return-t.i})),o=[],a=0,s=0,u=0;r.sort((c=!!e,function(t,e){return t.barycenter<e.barycenter?-1:t.barycenter>e.barycenter?1:c?e.i-t.i:t.i-e.i})),u=vR(o,i,u),gR.forEach(r,(function(t){u+=t.vs.length,o.push(t.vs),a+=t.barycenter*t.weight,s+=t.weight,u=vR(o,i,u)}));var c;var h={vs:gR.flatten(o,!0)};s&&(h.barycenter=a/s,h.weight=s);return h},xR=function t(e,n,r,i){var o=e.children(n),a=e.node(n),s=a?a.borderLeft:void 0,u=a?a.borderRight:void 0,c={};s&&(o=yR.filter(o,(function(t){return t!==s&&t!==u})));var h=bR(e,o);yR.forEach(h,(function(n){if(e.children(n.v).length){var o=t(e,n.v,r,i);c[n.v]=o,yR.has(o,"barycenter")&&(a=n,s=o,yR.isUndefined(a.barycenter)?(a.barycenter=s.barycenter,a.weight=s.weight):(a.barycenter=(a.barycenter*a.weight+s.barycenter*s.weight)/(a.weight+s.weight),a.weight+=s.weight))}var a,s}));var l=ER(h,r);!function(t,e){yR.forEach(t,(function(t){t.vs=yR.flatten(t.vs.map((function(t){return e[t]?e[t].vs:t})),!0)}))}(l,c);var d=wR(l,i);if(s&&(d.vs=yR.flatten([s,d.vs,u],!0),e.predecessors(s).length)){var f=e.node(e.predecessors(s)[0]),p=e.node(e.predecessors(u)[0]);yR.has(d,"barycenter")||(d.barycenter=0,d.weight=0),d.barycenter=(d.barycenter*d.weight+f.order+p.order)/(d.weight+2),d.weight+=2}return d};var MR=WA,NR=CA.Graph,SR=function(t,e,n){var r=function(t){var e;for(;t.hasNode(e=MR.uniqueId("_root")););return e}(t),i=new NR({compound:!0}).setGraph({root:r}).setDefaultNodeLabel((function(e){return t.node(e)}));return MR.forEach(t.nodes(),(function(o){var a=t.node(o),s=t.parent(o);(a.rank===e||a.minRank<=e&&e<=a.maxRank)&&(i.setNode(o),i.setParent(o,s||r),MR.forEach(t[n](o),(function(e){var n=e.v===o?e.w:e.v,r=i.edge(n,o),a=MR.isUndefined(r)?0:r.weight;i.setEdge(n,o,{weight:t.edge(e).weight+a})})),MR.has(a,"minRank")&&i.setNode(o,{borderLeft:a.borderLeft[e],borderRight:a.borderRight[e]}))})),i};var TR=WA;var kR=WA,PR=uR,CR=hR,AR=xR,OR=SR,RR=function(t,e,n){var r,i={};TR.forEach(n,(function(n){for(var o,a,s=t.parent(n);s;){if((o=t.parent(s))?(a=i[o],i[o]=s):(a=r,r=s),a&&a!==s)return void e.setEdge(a,s);s=o}}))},_R=CA.Graph,DR=sO,IR=function(t){var e=DR.maxRank(t),n=LR(t,kR.range(1,e+1),"inEdges"),r=LR(t,kR.range(e-1,-1,-1),"outEdges"),i=PR(t);zR(t,i);for(var o,a=Number.POSITIVE_INFINITY,s=0,u=0;u<4;++s,++u){jR(s%2?n:r,s%4>=2),i=DR.buildLayerMatrix(t);var c=CR(t,i);c<a&&(u=0,o=kR.cloneDeep(i),a=c)}zR(t,o)};function LR(t,e,n){return kR.map(e,(function(e){return OR(t,e,n)}))}function jR(t,e){var n=new _R;kR.forEach(t,(function(t){var r=t.graph().root,i=AR(t,r,n,e);kR.forEach(i.vs,(function(e,n){t.node(e).order=n})),RR(t,n,i.vs)}))}function zR(t,e){kR.forEach(e,(function(e){kR.forEach(e,(function(e,n){t.node(e).order=n}))}))}var FR=WA,BR=CA.Graph,GR=sO,VR=function(t){var e,n=GR.buildLayerMatrix(t),r=FR.merge(UR(t,n),WR(t,n)),i={};FR.forEach(["u","d"],(function(o){e="u"===o?n:FR.values(n).reverse(),FR.forEach(["l","r"],(function(n){"r"===n&&(e=FR.map(e,(function(t){return FR.values(t).reverse()})));var a=("u"===o?t.predecessors:t.successors).bind(t),s=YR(t,e,r,a),u=$R(t,e,s.root,s.align,"r"===n);"r"===n&&(u=FR.mapValues(u,(function(t){return-t}))),i[o+n]=u}))}));var o=XR(t,i);return KR(i,o),ZR(i,t.graph().align)};function UR(t,e){var n={};return FR.reduce(e,(function(e,r){var i=0,o=0,a=e.length,s=FR.last(r);return FR.forEach(r,(function(e,u){var c=function(t,e){if(t.node(e).dummy)return FR.find(t.predecessors(e),(function(e){return t.node(e).dummy}))}(t,e),h=c?t.node(c).order:a;(c||e===s)&&(FR.forEach(r.slice(o,u+1),(function(e){FR.forEach(t.predecessors(e),(function(r){var o=t.node(r),a=o.order;!(a<i||h<a)||o.dummy&&t.node(e).dummy||HR(n,r,e)}))})),o=u+1,i=h)})),r})),n}function WR(t,e){var n={};function r(e,r,i,o,a){var s;FR.forEach(FR.range(r,i),(function(r){s=e[r],t.node(s).dummy&&FR.forEach(t.predecessors(s),(function(e){var r=t.node(e);r.dummy&&(r.order<o||r.order>a)&&HR(n,e,s)}))}))}return FR.reduce(e,(function(e,n){var i,o=-1,a=0;return FR.forEach(n,(function(s,u){if("border"===t.node(s).dummy){var c=t.predecessors(s);c.length&&(i=t.node(c[0]).order,r(n,a,u,o,i),a=u,o=i)}r(n,a,n.length,i,e.length)})),n})),n}function HR(t,e,n){if(e>n){var r=e;e=n,n=r}var i=t[e];i||(t[e]=i={}),i[n]=!0}function qR(t,e,n){if(e>n){var r=e;e=n,n=r}return FR.has(t[e],n)}function YR(t,e,n,r){var i={},o={},a={};return FR.forEach(e,(function(t){FR.forEach(t,(function(t,e){i[t]=t,o[t]=t,a[t]=e}))})),FR.forEach(e,(function(t){var e=-1;FR.forEach(t,(function(t){var s=r(t);if(s.length){s=FR.sortBy(s,(function(t){return a[t]}));for(var u=(s.length-1)/2,c=Math.floor(u),h=Math.ceil(u);c<=h;++c){var l=s[c];o[t]===t&&e<a[l]&&!qR(n,t,l)&&(o[l]=t,o[t]=i[t]=i[l],e=a[l])}}}))})),{root:i,align:o}}function $R(t,e,n,r,i){var o={},a=function(t,e,n,r){var i=new BR,o=t.graph(),a=function(t,e,n){return function(r,i,o){var a,s=r.node(i),u=r.node(o),c=0;if(c+=s.width/2,FR.has(s,"labelpos"))switch(s.labelpos.toLowerCase()){case"l":a=-s.width/2;break;case"r":a=s.width/2}if(a&&(c+=n?a:-a),a=0,c+=(s.dummy?e:t)/2,c+=(u.dummy?e:t)/2,c+=u.width/2,FR.has(u,"labelpos"))switch(u.labelpos.toLowerCase()){case"l":a=u.width/2;break;case"r":a=-u.width/2}return a&&(c+=n?a:-a),a=0,c}}(o.nodesep,o.edgesep,r);return FR.forEach(e,(function(e){var r;FR.forEach(e,(function(e){var o=n[e];if(i.setNode(o),r){var s=n[r],u=i.edge(s,o);i.setEdge(s,o,Math.max(a(t,e,r),u||0))}r=e}))})),i}(t,e,n,i),s=i?"borderLeft":"borderRight";function u(t,e){for(var n=a.nodes(),r=n.pop(),i={};r;)i[r]?t(r):(i[r]=!0,n.push(r),n=n.concat(e(r))),r=n.pop()}return u((function(t){o[t]=a.inEdges(t).reduce((function(t,e){return Math.max(t,o[e.v]+a.edge(e))}),0)}),a.predecessors.bind(a)),u((function(e){var n=a.outEdges(e).reduce((function(t,e){return Math.min(t,o[e.w]-a.edge(e))}),Number.POSITIVE_INFINITY),r=t.node(e);n!==Number.POSITIVE_INFINITY&&r.borderType!==s&&(o[e]=Math.max(o[e],n))}),a.successors.bind(a)),FR.forEach(r,(function(t){o[t]=o[n[t]]})),o}function XR(t,e){return FR.minBy(FR.values(e),(function(e){var n=Number.NEGATIVE_INFINITY,r=Number.POSITIVE_INFINITY;return FR.forIn(e,(function(e,i){var o=function(t,e){return t.node(e).width}(t,i)/2;n=Math.max(e+o,n),r=Math.min(e-o,r)})),n-r}))}function KR(t,e){var n=FR.values(e),r=FR.min(n),i=FR.max(n);FR.forEach(["u","d"],(function(n){FR.forEach(["l","r"],(function(o){var a,s=n+o,u=t[s];if(u!==e){var c=FR.values(u);(a="l"===o?r-FR.min(c):i-FR.max(c))&&(t[s]=FR.mapValues(u,(function(t){return t+a})))}}))}))}function ZR(t,e){return FR.mapValues(t.ul,(function(n,r){if(e)return t[e.toLowerCase()][r];var i=FR.sortBy(FR.map(t,r));return(i[1]+i[2])/2}))}var QR=WA,JR=sO,t_=VR,e_=function(t){(function(t){var e=JR.buildLayerMatrix(t),n=t.graph().ranksep,r=0;QR.forEach(e,(function(e){var i=QR.max(QR.map(e,(function(e){return t.node(e).height})));QR.forEach(e,(function(e){t.node(e).y=r+i/2})),r+=i+n}))})(t=JR.asNonCompoundGraph(t)),QR.forEach(t_(t),(function(e,n){t.node(n).x=e}))};var n_=WA,r_=iO,i_=dO,o_=VO,a_=sO.normalizeRanks,s_=qO,u_=sO.removeEmptyRanks,c_=XO,h_=JO,l_=nR,d_=IR,f_=e_,p_=sO,g_=CA.Graph,m_=function(t,e){var n=e&&e.debugTiming?p_.time:p_.notime;n("layout",(function(){var e=n(" buildLayoutGraph",(function(){return function(t){var e=new g_({multigraph:!0,compound:!0}),n=T_(t.graph());return e.setGraph(n_.merge({},y_,S_(n,v_),n_.pick(n,b_))),n_.forEach(t.nodes(),(function(n){var r=T_(t.node(n));e.setNode(n,n_.defaults(S_(r,E_),w_)),e.setParent(n,t.parent(n))})),n_.forEach(t.edges(),(function(n){var r=T_(t.edge(n));e.setEdge(n,n_.merge({},M_,S_(r,x_),n_.pick(r,N_)))})),e}(t)}));n(" runLayout",(function(){!function(t,e){e(" makeSpaceForEdgeLabels",(function(){!function(t){var e=t.graph();e.ranksep/=2,n_.forEach(t.edges(),(function(n){var r=t.edge(n);r.minlen*=2,"c"!==r.labelpos.toLowerCase()&&("TB"===e.rankdir||"BT"===e.rankdir?r.width+=r.labeloffset:r.height+=r.labeloffset)}))}(t)})),e(" removeSelfEdges",(function(){!function(t){n_.forEach(t.edges(),(function(e){if(e.v===e.w){var n=t.node(e.v);n.selfEdges||(n.selfEdges=[]),n.selfEdges.push({e:e,label:t.edge(e)}),t.removeEdge(e)}}))}(t)})),e(" acyclic",(function(){r_.run(t)})),e(" nestingGraph.run",(function(){c_.run(t)})),e(" rank",(function(){o_(p_.asNonCompoundGraph(t))})),e(" injectEdgeLabelProxies",(function(){!function(t){n_.forEach(t.edges(),(function(e){var n=t.edge(e);if(n.width&&n.height){var r=t.node(e.v),i={rank:(t.node(e.w).rank-r.rank)/2+r.rank,e:e};p_.addDummyNode(t,"edge-proxy",i,"_ep")}}))}(t)})),e(" removeEmptyRanks",(function(){u_(t)})),e(" nestingGraph.cleanup",(function(){c_.cleanup(t)})),e(" normalizeRanks",(function(){a_(t)})),e(" assignRankMinMax",(function(){!function(t){var e=0;n_.forEach(t.nodes(),(function(n){var r=t.node(n);r.borderTop&&(r.minRank=t.node(r.borderTop).rank,r.maxRank=t.node(r.borderBottom).rank,e=n_.max(e,r.maxRank))})),t.graph().maxRank=e}(t)})),e(" removeEdgeLabelProxies",(function(){!function(t){n_.forEach(t.nodes(),(function(e){var n=t.node(e);"edge-proxy"===n.dummy&&(t.edge(n.e).labelRank=n.rank,t.removeNode(e))}))}(t)})),e(" normalize.run",(function(){i_.run(t)})),e(" parentDummyChains",(function(){s_(t)})),e(" addBorderSegments",(function(){h_(t)})),e(" order",(function(){d_(t)})),e(" insertSelfEdges",(function(){!function(t){var e=p_.buildLayerMatrix(t);n_.forEach(e,(function(e){var n=0;n_.forEach(e,(function(e,r){var i=t.node(e);i.order=r+n,n_.forEach(i.selfEdges,(function(e){p_.addDummyNode(t,"selfedge",{width:e.label.width,height:e.label.height,rank:i.rank,order:r+ ++n,e:e.e,label:e.label},"_se")})),delete i.selfEdges}))}))}(t)})),e(" adjustCoordinateSystem",(function(){l_.adjust(t)})),e(" position",(function(){f_(t)})),e(" positionSelfEdges",(function(){!function(t){n_.forEach(t.nodes(),(function(e){var n=t.node(e);if("selfedge"===n.dummy){var r=t.node(n.e.v),i=r.x+r.width/2,o=r.y,a=n.x-i,s=r.height/2;t.setEdge(n.e,n.label),t.removeNode(e),n.label.points=[{x:i+2*a/3,y:o-s},{x:i+5*a/6,y:o-s},{x:i+a,y:o},{x:i+5*a/6,y:o+s},{x:i+2*a/3,y:o+s}],n.label.x=n.x,n.label.y=n.y}}))}(t)})),e(" removeBorderNodes",(function(){!function(t){n_.forEach(t.nodes(),(function(e){if(t.children(e).length){var n=t.node(e),r=t.node(n.borderTop),i=t.node(n.borderBottom),o=t.node(n_.last(n.borderLeft)),a=t.node(n_.last(n.borderRight));n.width=Math.abs(a.x-o.x),n.height=Math.abs(i.y-r.y),n.x=o.x+n.width/2,n.y=r.y+n.height/2}})),n_.forEach(t.nodes(),(function(e){"border"===t.node(e).dummy&&t.removeNode(e)}))}(t)})),e(" normalize.undo",(function(){i_.undo(t)})),e(" fixupEdgeLabelCoords",(function(){!function(t){n_.forEach(t.edges(),(function(e){var n=t.edge(e);if(n_.has(n,"x"))switch("l"!==n.labelpos&&"r"!==n.labelpos||(n.width-=n.labeloffset),n.labelpos){case"l":n.x-=n.width/2+n.labeloffset;break;case"r":n.x+=n.width/2+n.labeloffset}}))}(t)})),e(" undoCoordinateSystem",(function(){l_.undo(t)})),e(" translateGraph",(function(){!function(t){var e=Number.POSITIVE_INFINITY,n=0,r=Number.POSITIVE_INFINITY,i=0,o=t.graph(),a=o.marginx||0,s=o.marginy||0;function u(t){var o=t.x,a=t.y,s=t.width,u=t.height;e=Math.min(e,o-s/2),n=Math.max(n,o+s/2),r=Math.min(r,a-u/2),i=Math.max(i,a+u/2)}n_.forEach(t.nodes(),(function(e){u(t.node(e))})),n_.forEach(t.edges(),(function(e){var n=t.edge(e);n_.has(n,"x")&&u(n)})),e-=a,r-=s,n_.forEach(t.nodes(),(function(n){var i=t.node(n);i.x-=e,i.y-=r})),n_.forEach(t.edges(),(function(n){var i=t.edge(n);n_.forEach(i.points,(function(t){t.x-=e,t.y-=r})),n_.has(i,"x")&&(i.x-=e),n_.has(i,"y")&&(i.y-=r)})),o.width=n-e+a,o.height=i-r+s}(t)})),e(" assignNodeIntersects",(function(){!function(t){n_.forEach(t.edges(),(function(e){var n,r,i=t.edge(e),o=t.node(e.v),a=t.node(e.w);i.points?(n=i.points[0],r=i.points[i.points.length-1]):(i.points=[],n=a,r=o),i.points.unshift(p_.intersectRect(o,n)),i.points.push(p_.intersectRect(a,r))}))}(t)})),e(" reversePoints",(function(){!function(t){n_.forEach(t.edges(),(function(e){var n=t.edge(e);n.reversed&&n.points.reverse()}))}(t)})),e(" acyclic.undo",(function(){r_.undo(t)}))}(e,n)})),n(" updateInputGraph",(function(){!function(t,e){n_.forEach(t.nodes(),(function(n){var r=t.node(n),i=e.node(n);r&&(r.x=i.x,r.y=i.y,e.children(n).length&&(r.width=i.width,r.height=i.height))})),n_.forEach(t.edges(),(function(n){var r=t.edge(n),i=e.edge(n);r.points=i.points,n_.has(i,"x")&&(r.x=i.x,r.y=i.y)})),t.graph().width=e.graph().width,t.graph().height=e.graph().height}(t,e)}))}))};var v_=["nodesep","edgesep","ranksep","marginx","marginy"],y_={ranksep:50,edgesep:20,nodesep:50,rankdir:"tb"},b_=["acyclicer","ranker","rankdir","align"],E_=["width","height"],w_={width:0,height:0},x_=["minlen","weight","width","height","labeloffset"],M_={minlen:1,weight:1,width:0,height:0,labeloffset:10,labelpos:"r"},N_=["labelpos"];function S_(t,e){return n_.mapValues(n_.pick(t,e),Number)}function T_(t){var e={};return n_.forEach(t,(function(t,n){e[n.toLowerCase()]=t})),e}var k_=WA,P_=sO,C_=CA.Graph,A_={debugOrdering:function(t){var e=P_.buildLayerMatrix(t),n=new C_({compound:!0,multigraph:!0}).setGraph({});return k_.forEach(t.nodes(),(function(e){n.setNode(e,{label:e}),n.setParent(e,"layer"+t.node(e).rank)})),k_.forEach(t.edges(),(function(t){n.setEdge(t.v,t.w,{},t.name)})),k_.forEach(e,(function(t,e){var r="layer"+e;n.setNode(r,{rank:"same"}),k_.reduce(t,(function(t,e){return n.setEdge(t,e,{style:"invis"}),e}))})),n}};var O_={graphlib:CA,layout:m_,debug:A_,util:{time:sO.time,notime:sO.notime},version:"0.8.5"},R_=d(O_);class __{constructor(t){this.id="dagre",this.options={},Object.assign(this.options,__.defaultOptions,t)}execute(t,e){return a(this,void 0,void 0,(function*(){return this.genericDagreLayout(!1,t,Object.assign(Object.assign({},this.options),e))}))}assign(t,e){return a(this,void 0,void 0,(function*(){yield this.genericDagreLayout(!0,t,Object.assign(Object.assign({},this.options),e))}))}genericDagreLayout(t,e,n){return a(this,void 0,void 0,(function*(){const{nodeSize:r}=n,i=new O_.graphlib.Graph;i.setGraph(n),i.setDefaultEdgeLabel((()=>({})));[...e.getAllNodes(),...e.getAllEdges()].some((({id:t})=>Vt(t)))&&console.error("Dagre layout only support string id, it will convert number to string."),e.getAllNodes().forEach((t=>{const{id:e}=t,n=Object.assign({},t.data);if(void 0!==r){const[e,i]=function(t){if(!t)return[0,0,0];if(Vt(t))return[t,t,t];if(0===t.length)return[0,0,0];const[e,n=e,r=e]=t;return[e,n,r]}(kt(r)?r(t):r);Object.assign(n,{width:e,height:i})}i.setNode(e.toString(),n)})),e.getAllEdges().forEach((({id:t,source:e,target:n})=>{i.setEdge(e.toString(),n.toString(),{id:t})})),R_.layout(i);const a={nodes:[],edges:[]};return i.nodes().forEach((n=>{const r=i.node(n);a.nodes.push({id:n,data:r}),t&&e.mergeNodeData(n,r)})),i.edges().forEach((n=>{const r=i.edge(n),{id:s}=r,u=o(r,["id"]),{v:c,w:h}=n;a.edges.push({id:s,source:c,target:h,data:u}),t&&e.mergeEdgeData(s,u)})),a}))}}__.defaultOptions={};class D_{constructor(t){this.id=t.id||0,this.rx=t.rx,this.ry=t.ry,this.fx=0,this.fy=0,this.mass=t.mass,this.degree=t.degree,this.g=t.g||0}distanceTo(t){const e=this.rx-t.rx,n=this.ry-t.ry;return Math.hypot(e,n)}setPos(t,e){this.rx=t,this.ry=e}resetForce(){this.fx=0,this.fy=0}addForce(t){const e=t.rx-this.rx,n=t.ry-this.ry;let r=Math.hypot(e,n);r=r<1e-4?1e-4:r;const i=this.g*(this.degree+1)*(t.degree+1)/r;this.fx+=i*e/r,this.fy+=i*n/r}in(t){return t.contains(this.rx,this.ry)}add(t){const e=this.mass+t.mass,n=(this.rx*this.mass+t.rx*t.mass)/e,r=(this.ry*this.mass+t.ry*t.mass)/e,i=this.degree+t.degree;return new D_({rx:n,ry:r,mass:e,degree:i})}}class I_{constructor(t){this.xmid=t.xmid,this.ymid=t.ymid,this.length=t.length,this.massCenter=t.massCenter||[0,0],this.mass=t.mass||1}getLength(){return this.length}contains(t,e){const n=this.length/2;return t<=this.xmid+n&&t>=this.xmid-n&&e<=this.ymid+n&&e>=this.ymid-n}NW(){const t=this.xmid-this.length/4,e=this.ymid+this.length/4,n=this.length/2;return new I_({xmid:t,ymid:e,length:n})}NE(){const t=this.xmid+this.length/4,e=this.ymid+this.length/4,n=this.length/2;return new I_({xmid:t,ymid:e,length:n})}SW(){const t=this.xmid-this.length/4,e=this.ymid-this.length/4,n=this.length/2;return new I_({xmid:t,ymid:e,length:n})}SE(){const t=this.xmid+this.length/4,e=this.ymid-this.length/4,n=this.length/2;return new I_({xmid:t,ymid:e,length:n})}}class L_{constructor(t){this.body=null,this.quad=null,this.NW=null,this.NE=null,this.SW=null,this.SE=null,this.theta=.5,null!=t&&(this.quad=t)}insert(t){null!=this.body?this._isExternal()?(this.quad&&(this.NW=new L_(this.quad.NW()),this.NE=new L_(this.quad.NE()),this.SW=new L_(this.quad.SW()),this.SE=new L_(this.quad.SE())),this._putBody(this.body),this._putBody(t),this.body=this.body.add(t)):(this.body=this.body.add(t),this._putBody(t)):this.body=t}_putBody(t){this.quad&&(t.in(this.quad.NW())&&this.NW?this.NW.insert(t):t.in(this.quad.NE())&&this.NE?this.NE.insert(t):t.in(this.quad.SW())&&this.SW?this.SW.insert(t):t.in(this.quad.SE())&&this.SE&&this.SE.insert(t))}_isExternal(){return null==this.NW&&null==this.NE&&null==this.SW&&null==this.SE}updateForce(t){if(null!=this.body&&t!==this.body)if(this._isExternal())t.addForce(this.body);else{(this.quad?this.quad.getLength():0)/this.body.distanceTo(t)<this.theta?t.addForce(this.body):(this.NW&&this.NW.updateForce(t),this.NE&&this.NE.updateForce(t),this.SW&&this.SW.updateForce(t),this.SE&&this.SE.updateForce(t))}}}const j_={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};const z_={maxIteration:1e3,gravity:10,speed:5,clustering:!1,clusterGravity:10,width:300,height:300,nodeClusterBy:"cluster"};const F_={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};const B_=(t,e)=>{let n;const r=t.rows||5,i=t.cols||5;if(null==e)n=Math.min(r,i);else{Math.min(r,i)===t.rows?t.rows=e:t.cols=e}return n},G_=(t,e)=>{let n;const r=t.rows||5,i=t.cols||5;if(null==e)n=Math.max(r,i);else{Math.max(r,i)===t.rows?t.rows=e:t.cols=e}return n},V_=(t,e)=>t[`c-${e.row}-${e.col}`]||!1,U_=(t,e)=>t[`c-${e.row}-${e.col}`]=!0,W_=(t,e)=>{const n=t.cols||5;e.col++,e.col>=n&&(e.col=0,e.row++)},H_=(t,e,n,r,i,o,a,s)=>{let u,c;const h=i[t.id];if(h)u=h.col*n+n/2+e[0],c=h.row*r+r/2+e[1];else{for(;V_(s,a);)W_(o,a);u=a.col*n+n/2+e[0],c=a.row*r+r/2+e[1],U_(s,a),W_(o,a)}t.data.x=u,t.data.y=c},q_={iterations:10,height:10,width:10,speed:100,gravity:10,k:5},Y_=(t,e,n,r,i,o)=>{e.forEach(((a,s)=>{n[s]={x:0,y:0},e.forEach(((e,u)=>{if(s===u)return;if(i[s]!==i[u])return;let c=a.x-e.x,h=a.y-e.y,l=Math.sqrt(c*c+h*h);if(0===l){l=1;const t=s>u?1:-1;c=.01*t,h=.01*t}if(l<o(t[s])/2+o(t[u])/2){const t=r*r/l;n[s].x+=c/l*t,n[s].y+=h/l*t}}))}))},$_=(t,e,n,r,i,o,a,s)=>{const u=o||a/10;return r&&e.forEach(((e,n)=>{const r=t[n].x-t[i].x,o=t[n].y-t[i].y,a=Math.sqrt(r*r+o*o);let s=o/a,u=-r/a;const c=Math.sqrt(e.x*e.x+e.y*e.y);let h=Math.acos((s*e.x+u*e.y)/c);h>Math.PI/2&&(h-=Math.PI/2,s*=-1,u*=-1);const l=Math.cos(h)*c;e.x=s*l,e.y=u*l})),t.forEach(((o,a)=>{if(a===i)return;const c=Math.sqrt(e[a].x*e[a].x+e[a].y*e[a].y);if(c>0&&a!==i){const h=Math.min(u*(n/800),c);if(o.x+=e[a].x/c*h,o.y+=e[a].y/c*h,r){let e=o.x-t[i].x,n=o.y-t[i].y;const r=Math.sqrt(e*e+n*n);e=e/r*s[a],n=n/r*s[a],o.x=t[i].x+e,o.y=t[i].y+n}}})),t},X_={maxIteration:1e3,focusNode:null,unitRadius:null,linkDistance:50,preventOverlap:!1,strictRadial:!0,maxPreventOverlapIteration:200,sortStrength:10};const K_=(t,e,n,r,i,o,a)=>{if(!t)return[];const s=[];if(e){const u={};e.forEach(((e,c)=>{const h=[];e.forEach(((e,s)=>{var l,d;if(c===s)h.push(0);else if(r[c]===r[s])if("data"===o)h.push(e*(Math.abs(c-s)*a)/(r[c]/i));else if(o){let n,f;if(u[t[c].id])n=u[t[c].id];else{const e=("id"===o?t[c].id:null===(l=t[c].data)||void 0===l?void 0:l[o])||0;n=zt(e)?e.charCodeAt(0):e,u[t[c].id]=n}if(u[t[s].id])f=u[t[s].id];else{const e=("id"===o?t[s].id:null===(d=t[s].data)||void 0===d?void 0:d[o])||0;f=zt(e)?e.charCodeAt(0):e,u[t[s].id]=f}h.push(e*(Math.abs(n-f)*a)/(r[c]/i))}else h.push(e*n/(r[c]/i));else{const t=(n+i)/2;h.push(e*t)}})),s.push(h)}))}return s},Z_=t=>{const e=t.length,n=t[0].length,r=[];for(let i=0;i<e;i++){const e=[];for(let r=0;r<n;r++)0!==t[i][r]?e.push(1/(t[i][r]*t[i][r])):e.push(0);r.push(e)}return r},Q_=(t,e)=>{let n=-1;return t.forEach(((t,r)=>{t.id===e&&(n=r)})),Math.max(n,0)},J_=(t,e,n)=>{const r=t.length;for(let i=0;i<r;i++)if(t[e][i]===1/0){t[e][i]=n,t[i][e]=n;for(let o=0;o<r;o++)t[i][o]!==1/0&&t[e][o]===1/0&&(t[e][o]=n+t[i][o],t[o][e]=n+t[i][o])}for(let n=0;n<r;n++)if(n!==e)for(let i=0;i<r;i++)if(t[n][i]===1/0){let r=Math.abs(t[e][n]-t[e][i]);r=0===r?1:r,t[n][i]=r}},tD=(t,e)=>{let n=0;for(let r=0;r<t[e].length;r++)t[e][r]!==1/0&&(n=t[e][r]>n?t[e][r]:n);return n},eD={center:[0,0],width:300,height:300};function nD(t){return!!t.tick&&!!t.stop}
2
2
  /**
3
3
  * @license
4
4
  * Copyright 2019 Google LLC
5
5
  * SPDX-License-Identifier: Apache-2.0
6
- */
7
- const rp=Symbol("Comlink.proxy"),ip=Symbol("Comlink.endpoint"),op=Symbol("Comlink.releaseProxy"),ap=Symbol("Comlink.finalizer"),sp=Symbol("Comlink.thrown"),up=t=>"object"==typeof t&&null!==t||"function"==typeof t,cp=new Map([["proxy",{canHandle:t=>up(t)&&t[rp],serialize(t){const{port1:e,port2:n}=new MessageChannel;return hp(t,e),[n,[n]]},deserialize:t=>(t.start(),dp(t))}],["throw",{canHandle:t=>up(t)&&sp in t,serialize({value:t}){let e;return e=t instanceof Error?{isError:!0,value:{message:t.message,name:t.name,stack:t.stack}}:{isError:!1,value:t},[e,[]]},deserialize(t){if(t.isError)throw Object.assign(new Error(t.value.message),t.value);throw t.value}}]]);function hp(t,e=globalThis,n=["*"]){e.addEventListener("message",(function r(i){if(!i||!i.data)return;if(!function(t,e){for(const n of t){if(e===n||"*"===n)return!0;if(n instanceof RegExp&&n.test(e))return!0}return!1}(n,i.origin))return void console.warn(`Invalid origin '${i.origin}' for comlink proxy`);const{id:o,type:a,path:s}=Object.assign({path:[]},i.data),u=(i.data.argumentList||[]).map(bp);let c;try{const e=s.slice(0,-1).reduce(((t,e)=>t[e]),t),n=s.reduce(((t,e)=>t[e]),t);switch(a){case"GET":c=n;break;case"SET":e[s.slice(-1)[0]]=bp(i.data.value),c=!0;break;case"APPLY":c=n.apply(e,u);break;case"CONSTRUCT":c=function(t){return Object.assign(t,{[rp]:!0})}(new n(...u));break;case"ENDPOINT":{const{port1:e,port2:n}=new MessageChannel;hp(t,n),c=function(t,e){return Ep.set(t,e),t}(e,[e])}break;case"RELEASE":c=void 0;break;default:return}}catch(t){c={value:t,[sp]:0}}Promise.resolve(c).catch((t=>({value:t,[sp]:0}))).then((n=>{const[i,s]=xp(n);e.postMessage(Object.assign(Object.assign({},i),{id:o}),s),"RELEASE"===a&&(e.removeEventListener("message",r),lp(e),ap in t&&"function"==typeof t[ap]&&t[ap]())})).catch((t=>{const[n,r]=xp({value:new TypeError("Unserializable return value"),[sp]:0});e.postMessage(Object.assign(Object.assign({},n),{id:o}),r)}))})),e.start&&e.start()}function lp(t){(function(t){return"MessagePort"===t.constructor.name})(t)&&t.close()}function dp(t,e){return vp(t,[],e)}function fp(t){if(t)throw new Error("Proxy has been released and is not useable")}function pp(t){return wp(t,{type:"RELEASE"}).then((()=>{lp(t)}))}const gp=new WeakMap,mp="FinalizationRegistry"in globalThis&&new FinalizationRegistry((t=>{const e=(gp.get(t)||0)-1;gp.set(t,e),0===e&&pp(t)}));function vp(t,e=[],n=function(){}){let r=!1;const i=new Proxy(n,{get(n,o){if(fp(r),o===op)return()=>{!function(t){mp&&mp.unregister(t)}(i),pp(t),r=!0};if("then"===o){if(0===e.length)return{then:()=>i};const n=wp(t,{type:"GET",path:e.map((t=>t.toString()))}).then(bp);return n.then.bind(n)}return vp(t,[...e,o])},set(n,i,o){fp(r);const[a,s]=xp(o);return wp(t,{type:"SET",path:[...e,i].map((t=>t.toString())),value:a},s).then(bp)},apply(n,i,o){fp(r);const a=e[e.length-1];if(a===ip)return wp(t,{type:"ENDPOINT"}).then(bp);if("bind"===a)return vp(t,e.slice(0,-1));const[s,u]=yp(o);return wp(t,{type:"APPLY",path:e.map((t=>t.toString())),argumentList:s},u).then(bp)},construct(n,i){fp(r);const[o,a]=yp(i);return wp(t,{type:"CONSTRUCT",path:e.map((t=>t.toString())),argumentList:o},a).then(bp)}});return function(t,e){const n=(gp.get(e)||0)+1;gp.set(e,n),mp&&mp.register(t,e,t)}(i,t),i}function yp(t){const e=t.map(xp);return[e.map((t=>t[0])),(n=e.map((t=>t[1])),Array.prototype.concat.apply([],n))];var n}const Ep=new WeakMap;function xp(t){for(const[e,n]of cp)if(n.canHandle(t)){const[r,i]=n.serialize(t);return[{type:"HANDLER",name:e,value:r},i]}return[{type:"RAW",value:t},Ep.get(t)||[]]}function bp(t){switch(t.type){case"HANDLER":return cp.get(t.name).deserialize(t.value);case"RAW":return t.value}}function wp(t,e,n){return new Promise((r=>{const i=new Array(4).fill(0).map((()=>Math.floor(Math.random()*Number.MAX_SAFE_INTEGER).toString(16))).join("-");t.addEventListener("message",(function e(n){n.data&&n.data.id&&n.data.id===i&&(t.removeEventListener("message",e),r(n.data))})),t.start&&t.start(),t.postMessage(Object.assign({id:i},e),n)}))}var Mp=function(t){function n(e,n,r){var i=t.call(this)||this;return i.graph=e,i.layout=n,i.options=r,i.spawnWorker(),i}return r(n,t),n.prototype.spawnWorker=function(){this.proxy=dp(new Worker(new URL("./worker.js","undefined"==typeof document&&"undefined"==typeof location?require("url").pathToFileURL(__filename).href:"undefined"==typeof document?location.href:e&&e.src||new URL("g6.min.js",document.baseURI).href),{type:"module"})),this.running&&(this.running=!1,this.execute())},n.prototype.execute=function(){var t;return a(this,void 0,void 0,(function(){var e,n,r,i,a,u;return s(this,(function(s){switch(s.label){case 0:return this.running?[2,this]:(this.running=!0,(e=this.layout.options).onTick,n=o(e,["onTick"]),r={},Object.keys(n).forEach((function(t){Tt(n[t])||(r[t]=n[t])})),i={layout:{id:this.layout.id,options:r,iterations:null===(t=this.options)||void 0===t?void 0:t.iterations},nodes:this.graph.getAllNodes(),edges:this.graph.getAllEdges()},a=new Float32Array([0]),[4,this.proxy.calculateLayout(i,[a])]);case 1:return u=c.apply(void 0,[s.sent(),1]),[2,u[0]]}}))}))},n.prototype.stop=function(){return this.running=!1,this.proxy.stopLayout(),this},n.prototype.kill=function(){this.proxy[op]()},n.prototype.isRunning=function(){return this.running},n}(np);function Np(t,e,n,r){for(;t.length;){const i=t.shift();if(n(i))return!0;e.add(i.id),r(i.id).forEach((n=>{e.has(n.id)||(e.add(n.id),t.push(n))}))}return!1}function Sp(t,e,n,r){if(n(t))return!0;e.add(t.id);for(const i of r(t.id))if(!e.has(i.id)&&Sp(i,e,n,r))return!0;return!1}const Tp=()=>!0;class Pp{graph;nodeFilter;edgeFilter;cacheEnabled;inEdgesMap=new Map;outEdgesMap=new Map;bothEdgesMap=new Map;allNodesMap=new Map;allEdgesMap=new Map;constructor(t){this.graph=t.graph;const e=t.nodeFilter||Tp,n=t.edgeFilter||Tp;this.nodeFilter=e,this.edgeFilter=t=>{const{source:r,target:i}=this.graph.getEdgeDetail(t.id);return!(!e(r)||!e(i))&&n(t,r,i)},"auto"===t.cache?(this.cacheEnabled=!0,this.startAutoCache()):"manual"===t.cache?this.cacheEnabled=!0:this.cacheEnabled=!1}clearCache=()=>{this.inEdgesMap.clear(),this.outEdgesMap.clear(),this.bothEdgesMap.clear(),this.allNodesMap.clear(),this.allEdgesMap.clear()};refreshCache=()=>{this.clearCache(),this.updateCache(this.graph.getAllNodes().map((t=>t.id)))};updateCache=t=>{const e=new Set;t.forEach((t=>{const n=this.bothEdgesMap.get(t);if(n&&n.forEach((t=>e.add(t.id))),this.hasNode(t)){const n=this.graph.getRelatedEdges(t,"in").filter(this.edgeFilter),r=this.graph.getRelatedEdges(t,"out").filter(this.edgeFilter),i=Array.from(new Set([...n,...r]));i.forEach((t=>e.add(t.id))),this.inEdgesMap.set(t,n),this.outEdgesMap.set(t,r),this.bothEdgesMap.set(t,i),this.allNodesMap.set(t,this.graph.getNode(t))}else this.inEdgesMap.delete(t),this.outEdgesMap.delete(t),this.bothEdgesMap.delete(t),this.allNodesMap.delete(t)})),e.forEach((t=>{this.hasEdge(t)?this.allEdgesMap.set(t,this.graph.getEdge(t)):this.allEdgesMap.delete(t)}))};startAutoCache(){this.refreshCache(),this.graph.on("changed",this.handleGraphChanged)}stopAutoCache(){this.graph.off("changed",this.handleGraphChanged)}handleGraphChanged=t=>{const e=new Set;t.changes.forEach((n=>{switch(n.type){case"NodeAdded":case"NodeRemoved":e.add(n.value.id);break;case"NodeDataUpdated":e.add(n.id);break;case"EdgeAdded":case"EdgeRemoved":e.add(n.value.source),e.add(n.value.target);break;case"EdgeUpdated":"source"!==n.propertyName&&"target"!==n.propertyName||(e.add(n.oldValue),e.add(n.newValue));break;case"EdgeDataUpdated":if(t.graph.hasEdge(n.id)){const r=t.graph.getEdge(n.id);e.add(r.source),e.add(r.target)}}})),this.updateCache(e)};checkNodeExistence(t){this.getNode(t)}hasNode(t){if(!this.graph.hasNode(t))return!1;const e=this.graph.getNode(t);return this.nodeFilter(e)}areNeighbors(t,e){return this.checkNodeExistence(t),this.getNeighbors(e).some((e=>e.id===t))}getNode(t){const e=this.graph.getNode(t);if(!this.nodeFilter(e))throw new Error("Node not found for id: "+t);return e}getRelatedEdges(t,e){if(this.checkNodeExistence(t),this.cacheEnabled)return"in"===e?this.inEdgesMap.get(t):"out"===e?this.outEdgesMap.get(t):this.bothEdgesMap.get(t);return this.graph.getRelatedEdges(t,e).filter(this.edgeFilter)}getDegree(t,e){return this.getRelatedEdges(t,e).length}getSuccessors(t){const e=this.getRelatedEdges(t,"out").map((t=>this.getNode(t.target)));return Array.from(new Set(e))}getPredecessors(t){const e=this.getRelatedEdges(t,"in").map((t=>this.getNode(t.source)));return Array.from(new Set(e))}getNeighbors(t){const e=this.getPredecessors(t),n=this.getSuccessors(t);return Array.from(new Set([...e,...n]))}hasEdge(t){if(!this.graph.hasEdge(t))return!1;const e=this.graph.getEdge(t);return this.edgeFilter(e)}getEdge(t){const e=this.graph.getEdge(t);if(!this.edgeFilter(e))throw new Error("Edge not found for id: "+t);return e}getEdgeDetail(t){const e=this.getEdge(t);return{edge:e,source:this.getNode(e.source),target:this.getNode(e.target)}}hasTreeStructure(t){return this.graph.hasTreeStructure(t)}getRoots(t){return this.graph.getRoots(t).filter(this.nodeFilter)}getChildren(t,e){return this.checkNodeExistence(t),this.graph.getChildren(t,e).filter(this.nodeFilter)}getParent(t,e){this.checkNodeExistence(t);const n=this.graph.getParent(t,e);return n&&this.nodeFilter(n)?n:null}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(t,e,n="out"){const r={in:this.getPredecessors.bind(this),out:this.getSuccessors.bind(this),both:this.getNeighbors.bind(this)}[n];Np([this.getNode(t)],new Set,e,r)}dfs(t,e,n="out"){const r={in:this.getPredecessors.bind(this),out:this.getSuccessors.bind(this),both:this.getNeighbors.bind(this)}[n];Sp(this.getNode(t),new Set,e,r)}}let Cp=class t extends np{nodeMap=new Map;edgeMap=new Map;inEdgesMap=new Map;outEdgesMap=new Map;bothEdgesMap=new Map;treeIndices=new Map;changes=[];batchCount=0;onChanged=()=>{};constructor(t){super(),t&&(t.nodes&&this.addNodes(t.nodes),t.edges&&this.addEdges(t.edges),t.tree&&this.addTree(t.tree),t.onChanged&&(this.onChanged=t.onChanged))}batch=t=>{this.batchCount+=1,t(),this.batchCount-=1,this.batchCount||this.commit()};commit(){const t=this.changes;this.changes=[];const e={graph:this,changes:t};this.emit("changed",e),this.onChanged(e)}reduceChanges(t){let e=[];return t.forEach((t=>{switch(t.type){case"NodeRemoved":{let n=!1;e=e.filter((e=>{if("NodeAdded"===e.type){const r=e.value.id===t.value.id;return r&&(n=!0),!r}return"NodeDataUpdated"===e.type?e.id!==t.value.id:"TreeStructureChanged"!==e.type||e.nodeId!==t.value.id})),n||e.push(t);break}case"EdgeRemoved":{let n=!1;e=e.filter((e=>{if("EdgeAdded"===e.type){const r=e.value.id===t.value.id;return r&&(n=!0),!r}return"EdgeDataUpdated"!==e.type&&"EdgeUpdated"!==e.type||e.id!==t.value.id})),n||e.push(t);break}case"NodeDataUpdated":case"EdgeDataUpdated":case"EdgeUpdated":{const n=e.findIndex((e=>e.type===t.type&&e.id===t.id&&(void 0===t.propertyName||e.propertyName===t.propertyName))),r=e[n];r?void 0!==t.propertyName?r.newValue=t.newValue:(e.splice(n,1),e.push(t)):e.push(t);break}case"TreeStructureDetached":e=e.filter((e=>"TreeStructureAttached"===e.type?e.treeKey!==t.treeKey:"TreeStructureChanged"!==e.type||e.treeKey!==t.treeKey)),e.push(t);break;case"TreeStructureChanged":{const n=e.find((e=>"TreeStructureChanged"===e.type&&e.treeKey===t.treeKey&&e.nodeId===t.nodeId));n?n.newParentId=t.newParentId:e.push(t);break}default:e.push(t)}})),e}checkNodeExistence(t){this.getNode(t)}hasNode(t){return this.nodeMap.has(t)}areNeighbors(t,e){return this.getNeighbors(e).some((e=>e.id===t))}getNode(t){const e=this.nodeMap.get(t);if(!e)throw new Error("Node not found for id: "+t);return e}getRelatedEdges(t,e){if(this.checkNodeExistence(t),"in"===e){const e=this.inEdgesMap.get(t);return Array.from(e)}if("out"===e){const e=this.outEdgesMap.get(t);return Array.from(e)}{const e=this.bothEdgesMap.get(t);return Array.from(e)}}getDegree(t,e){return this.getRelatedEdges(t,e).length}getSuccessors(t){const e=this.getRelatedEdges(t,"out").map((t=>this.getNode(t.target)));return Array.from(new Set(e))}getPredecessors(t){const e=this.getRelatedEdges(t,"in").map((t=>this.getNode(t.source)));return Array.from(new Set(e))}getNeighbors(t){const e=this.getPredecessors(t),n=this.getSuccessors(t);return Array.from(new Set([...e,...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((e=>{e.childrenMap.set(t.id,new Set)})),this.changes.push({type:"NodeAdded",value:t})}addNodes(t){this.batch((()=>{for(const e of t)this.doAddNode(e)}))}addNode(t){this.addNodes([t])}doRemoveNode(t){const e=this.getNode(t),n=this.bothEdgesMap.get(t);n?.forEach((t=>this.doRemoveEdge(t.id))),this.nodeMap.delete(t),this.treeIndices.forEach((e=>{e.childrenMap.get(t)?.forEach((t=>{e.parentMap.delete(t.id)})),e.parentMap.delete(t),e.childrenMap.delete(t)})),this.changes.push({type:"NodeRemoved",value:e})}removeNodes(t){this.batch((()=>{t.forEach((t=>this.doRemoveNode(t)))}))}removeNode(t){this.removeNodes([t])}updateNodeDataProperty(t,e,n){const r=this.getNode(t);this.batch((()=>{const i=r.data[e],o=n;r.data[e]=o,this.changes.push({type:"NodeDataUpdated",id:t,propertyName:e,oldValue:i,newValue:o})}))}mergeNodeData(t,e){this.batch((()=>{Object.entries(e).forEach((([e,n])=>{this.updateNodeDataProperty(t,e,n)}))}))}updateNodeData(...t){const e=t[0],n=this.getNode(e);if("string"==typeof t[1])return void this.updateNodeDataProperty(e,t[1],t[2]);let r;if("function"==typeof t[1]){const e=t[1];r=e(n.data)}else"object"==typeof t[1]&&(r=t[1]);this.batch((()=>{const t=n.data,i=r;n.data=r,this.changes.push({type:"NodeDataUpdated",id:e,oldValue:t,newValue:i})}))}checkEdgeExistence(t){if(!this.hasEdge(t))throw new Error("Edge not found for id: "+t)}hasEdge(t){return this.edgeMap.has(t)}getEdge(t){return this.checkEdgeExistence(t),this.edgeMap.get(t)}getEdgeDetail(t){const e=this.getEdge(t);return{edge:e,source:this.getNode(e.source),target:this.getNode(e.target)}}doAddEdge(t){if(this.hasEdge(t.id))throw new Error("Edge already exists: "+t.id);this.checkNodeExistence(t.source),this.checkNodeExistence(t.target),this.edgeMap.set(t.id,t);const e=this.inEdgesMap.get(t.target),n=this.outEdgesMap.get(t.source),r=this.bothEdgesMap.get(t.source),i=this.bothEdgesMap.get(t.target);e.add(t),n.add(t),r.add(t),i.add(t),this.changes.push({type:"EdgeAdded",value:t})}addEdges(t){this.batch((()=>{for(const e of t)this.doAddEdge(e)}))}addEdge(t){this.addEdges([t])}doRemoveEdge(t){const e=this.getEdge(t),n=this.outEdgesMap.get(e.source),r=this.inEdgesMap.get(e.target),i=this.bothEdgesMap.get(e.source),o=this.bothEdgesMap.get(e.target);n.delete(e),r.delete(e),i.delete(e),o.delete(e),this.edgeMap.delete(t),this.changes.push({type:"EdgeRemoved",value:e})}removeEdges(t){this.batch((()=>{t.forEach((t=>this.doRemoveEdge(t)))}))}removeEdge(t){this.removeEdges([t])}updateEdgeSource(t,e){const n=this.getEdge(t);this.checkNodeExistence(e);const r=n.source,i=e;this.outEdgesMap.get(r).delete(n),this.bothEdgesMap.get(r).delete(n),this.outEdgesMap.get(i).add(n),this.bothEdgesMap.get(i).add(n),n.source=e,this.batch((()=>{this.changes.push({type:"EdgeUpdated",id:t,propertyName:"source",oldValue:r,newValue:i})}))}updateEdgeTarget(t,e){const n=this.getEdge(t);this.checkNodeExistence(e);const r=n.target,i=e;this.inEdgesMap.get(r).delete(n),this.bothEdgesMap.get(r).delete(n),this.inEdgesMap.get(i).add(n),this.bothEdgesMap.get(i).add(n),n.target=e,this.batch((()=>{this.changes.push({type:"EdgeUpdated",id:t,propertyName:"target",oldValue:r,newValue:i})}))}updateEdgeDataProperty(t,e,n){const r=this.getEdge(t);this.batch((()=>{const i=r.data[e],o=n;r.data[e]=o,this.changes.push({type:"EdgeDataUpdated",id:t,propertyName:e,oldValue:i,newValue:o})}))}updateEdgeData(...t){const e=t[0],n=this.getEdge(e);if("string"==typeof t[1])return void this.updateEdgeDataProperty(e,t[1],t[2]);let r;if("function"==typeof t[1]){const e=t[1];r=e(n.data)}else"object"==typeof t[1]&&(r=t[1]);this.batch((()=>{const t=n.data,i=r;n.data=r,this.changes.push({type:"EdgeDataUpdated",id:e,oldValue:t,newValue:i})}))}mergeEdgeData(t,e){this.batch((()=>{Object.entries(e).forEach((([e,n])=>{this.updateEdgeDataProperty(t,e,n)}))}))}checkTreeExistence(t){if(!this.hasTreeStructure(t))throw new Error("Tree structure not found for treeKey: "+t)}hasTreeStructure(t){return this.treeIndices.has(t)}attachTreeStructure(t){this.treeIndices.has(t)||(this.treeIndices.set(t,{parentMap:new Map,childrenMap:new Map}),this.batch((()=>{this.changes.push({type:"TreeStructureAttached",treeKey:t})})))}detachTreeStructure(t){this.checkTreeExistence(t),this.treeIndices.delete(t),this.batch((()=>{this.changes.push({type:"TreeStructureDetached",treeKey:t})}))}addTree(t,e){this.batch((()=>{this.attachTreeStructure(e);const n=[],r=Array.isArray(t)?t:[t];for(;r.length;){const t=r.shift();n.push(t),t.children&&r.push(...t.children)}this.addNodes(n),n.forEach((t=>{t.children?.forEach((n=>{this.setParent(n.id,t.id,e)}))}))}))}getRoots(t){return this.checkTreeExistence(t),this.getAllNodes().filter((e=>!this.getParent(e.id,t)))}getChildren(t,e){this.checkNodeExistence(t),this.checkTreeExistence(e);const n=this.treeIndices.get(e).childrenMap.get(t);return Array.from(n||[])}getParent(t,e){this.checkNodeExistence(t),this.checkTreeExistence(e);return this.treeIndices.get(e).parentMap.get(t)||null}getAncestors(t,e){const n=[];let r,i=this.getNode(t);for(;r=this.getParent(i.id,e);)n.push(r),i=r;return n}setParent(t,e,n){this.checkTreeExistence(n);const r=this.treeIndices.get(n),i=this.getNode(t),o=r.parentMap.get(t);if(o?.id===e)return;if(void 0===e)return o&&r.childrenMap.get(o.id)?.delete(i),void r.parentMap.delete(t);const a=this.getNode(e);r.parentMap.set(t,a),o&&r.childrenMap.get(o.id)?.delete(i);let s=r.childrenMap.get(a.id);s||(s=new Set,r.childrenMap.set(a.id,s)),s.add(i),this.batch((()=>{this.changes.push({type:"TreeStructureChanged",treeKey:n,nodeId:t,oldParentId:o?.id,newParentId:a.id})}))}dfsTree(t,e,n){return Sp(this.getNode(t),new Set,e,(t=>this.getChildren(t,n)))}bfsTree(t,e,n){return Np([this.getNode(t)],new Set,e,(t=>this.getChildren(t,n)))}getAllNodes(){return Array.from(this.nodeMap.values())}getAllEdges(){return Array.from(this.edgeMap.values())}bfs(t,e,n="out"){const r={in:this.getPredecessors.bind(this),out:this.getSuccessors.bind(this),both:this.getNeighbors.bind(this)}[n];return Np([this.getNode(t)],new Set,e,r)}dfs(t,e,n="out"){const r={in:this.getPredecessors.bind(this),out:this.getSuccessors.bind(this),both:this.getNeighbors.bind(this)}[n];return Sp(this.getNode(t),new Set,e,r)}clone(){const e=this.getAllNodes().map((t=>({...t,data:{...t.data}}))),n=this.getAllEdges().map((t=>({...t,data:{...t.data}}))),r=new t({nodes:e,edges:n});return this.treeIndices.forEach((({parentMap:t,childrenMap:e},n)=>{const i=new Map;t.forEach(((t,e)=>{i.set(e,r.getNode(t.id))}));const o=new Map;e.forEach(((t,e)=>{o.set(e,new Set(Array.from(t).map((t=>r.getNode(t.id)))))})),r.treeIndices.set(n,{parentMap:i,childrenMap:o})})),r}toJSON(){return JSON.stringify({nodes:this.getAllNodes(),edges:this.getAllEdges()})}createView(t){return new Pp({graph:this,...t})}};var kp={};const Ap=Object.prototype.toString;function Op(t){const e=Ap.call(t);return e.endsWith("Array]")&&!e.includes("Big")}var Rp=d(Object.freeze({__proto__:null,isAnyArray:Op}));var Dp=Object.freeze({__proto__:null,default:function(t){var e,n=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};if(!Op(t))throw new TypeError("input must be an array");if(0===t.length)throw new TypeError("input must not be empty");if(void 0!==n.output){if(!Op(n.output))throw new TypeError("output option must be an array if specified");e=n.output}else e=new Array(t.length);var r=function(t){var e=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};if(!Op(t))throw new TypeError("input must be an array");if(0===t.length)throw new TypeError("input must not be empty");var n=e.fromIndex,r=void 0===n?0:n,i=e.toIndex,o=void 0===i?t.length:i;if(r<0||r>=t.length||!Number.isInteger(r))throw new Error("fromIndex must be a positive integer smaller than length");if(o<=r||o>t.length||!Number.isInteger(o))throw new Error("toIndex must be an integer greater than fromIndex and at most equal to length");for(var a=t[r],s=r+1;s<o;s++)t[s]<a&&(a=t[s]);return a}(t),i=function(t){var e=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};if(!Op(t))throw new TypeError("input must be an array");if(0===t.length)throw new TypeError("input must not be empty");var n=e.fromIndex,r=void 0===n?0:n,i=e.toIndex,o=void 0===i?t.length:i;if(r<0||r>=t.length||!Number.isInteger(r))throw new Error("fromIndex must be a positive integer smaller than length");if(o<=r||o>t.length||!Number.isInteger(o))throw new Error("toIndex must be an integer greater than fromIndex and at most equal to length");for(var a=t[r],s=r+1;s<o;s++)t[s]>a&&(a=t[s]);return a}(t);if(r===i)throw new RangeError("minimum and maximum input values are equal. Cannot rescale a constant array");var o=n.min,a=void 0===o?n.autoMinMax?r:0:o,s=n.max,u=void 0===s?n.autoMinMax?i:1:s;if(a>=u)throw new RangeError("min option must be smaller than max option");for(var c=(u-a)/(i-r),h=0;h<t.length;h++)e[h]=(t[h]-r)*c+a;return e}}),Ip=d(Dp);Object.defineProperty(kp,"__esModule",{value:!0});var Lp=Rp,_p=Ip;const zp=" ".repeat(2),Fp=" ".repeat(4);function Bp(t,e={}){const{maxRows:n=15,maxColumns:r=10,maxNumSize:i=8,padMinus:o="auto"}=e;return`${t.constructor.name} {\n${zp}[\n${Fp}${function(t,e,n,r,i){const{rows:o,columns:a}=t,s=Math.min(o,e),u=Math.min(a,n),c=[];if("auto"===i){i=!1;t:for(let e=0;e<s;e++)for(let n=0;n<u;n++)if(t.get(e,n)<0){i=!0;break t}}for(let e=0;e<s;e++){let n=[];for(let o=0;o<u;o++)n.push(Gp(t.get(e,o),r,i));c.push(`${n.join(" ")}`)}u!==a&&(c[c.length-1]+=` ... ${a-n} more columns`);s!==o&&c.push(`... ${o-e} more rows`);return c.join(`\n${Fp}`)}(t,n,r,i,o)}\n${zp}]\n${zp}rows: ${t.rows}\n${zp}columns: ${t.columns}\n}`}function Gp(t,e,n){return(t>=0&&n?` ${jp(t,e-1)}`:jp(t,e)).padEnd(e)}function jp(t,e){let n=t.toString();if(n.length<=e)return n;let r=t.toFixed(e);if(r.length>e&&(r=t.toFixed(Math.max(0,e-(r.length-e)))),r.length<=e&&!r.startsWith("0.000")&&!r.startsWith("-0.000"))return r;let i=t.toExponential(e);return i.length>e&&(i=t.toExponential(Math.max(0,e-(i.length-e)))),i.slice(0)}function Vp(t,e,n){let r=n?t.rows:t.rows-1;if(e<0||e>r)throw new RangeError("Row index out of range")}function Up(t,e,n){let r=n?t.columns:t.columns-1;if(e<0||e>r)throw new RangeError("Column index out of range")}function Wp(t,e){if(e.to1DArray&&(e=e.to1DArray()),e.length!==t.columns)throw new RangeError("vector size must be the same as the number of columns");return e}function Hp(t,e){if(e.to1DArray&&(e=e.to1DArray()),e.length!==t.rows)throw new RangeError("vector size must be the same as the number of rows");return e}function qp(t,e){if(!Lp.isAnyArray(e))throw new TypeError("row indices must be an array");for(let n=0;n<e.length;n++)if(e[n]<0||e[n]>=t.rows)throw new RangeError("row indices are out of range")}function Yp(t,e){if(!Lp.isAnyArray(e))throw new TypeError("column indices must be an array");for(let n=0;n<e.length;n++)if(e[n]<0||e[n]>=t.columns)throw new RangeError("column indices are out of range")}function Xp(t,e,n,r,i){if(5!==arguments.length)throw new RangeError("expected 4 arguments");if($p("startRow",e),$p("endRow",n),$p("startColumn",r),$p("endColumn",i),e>n||r>i||e<0||e>=t.rows||n<0||n>=t.rows||r<0||r>=t.columns||i<0||i>=t.columns)throw new RangeError("Submatrix indices are out of range")}function Kp(t,e=0){let n=[];for(let r=0;r<t;r++)n.push(e);return n}function $p(t,e){if("number"!=typeof e)throw new TypeError(`${t} must be a number`)}function Zp(t){if(t.isEmpty())throw new Error("Empty matrix has no elements to index")}class Qp{static from1DArray(t,e,n){if(t*e!==n.length)throw new RangeError("data length does not match given dimensions");let r=new tg(t,e);for(let i=0;i<t;i++)for(let t=0;t<e;t++)r.set(i,t,n[i*e+t]);return r}static rowVector(t){let e=new tg(1,t.length);for(let n=0;n<t.length;n++)e.set(0,n,t[n]);return e}static columnVector(t){let e=new tg(t.length,1);for(let n=0;n<t.length;n++)e.set(n,0,t[n]);return e}static zeros(t,e){return new tg(t,e)}static ones(t,e){return new tg(t,e).fill(1)}static rand(t,e,n={}){if("object"!=typeof n)throw new TypeError("options must be an object");const{random:r=Math.random}=n;let i=new tg(t,e);for(let n=0;n<t;n++)for(let t=0;t<e;t++)i.set(n,t,r());return i}static randInt(t,e,n={}){if("object"!=typeof n)throw new TypeError("options must be an object");const{min:r=0,max:i=1e3,random:o=Math.random}=n;if(!Number.isInteger(r))throw new TypeError("min must be an integer");if(!Number.isInteger(i))throw new TypeError("max must be an integer");if(r>=i)throw new RangeError("min must be smaller than max");let a=i-r,s=new tg(t,e);for(let n=0;n<t;n++)for(let t=0;t<e;t++){let e=r+Math.round(o()*a);s.set(n,t,e)}return s}static eye(t,e,n){void 0===e&&(e=t),void 0===n&&(n=1);let r=Math.min(t,e),i=this.zeros(t,e);for(let t=0;t<r;t++)i.set(t,t,n);return i}static diag(t,e,n){let r=t.length;void 0===e&&(e=r),void 0===n&&(n=e);let i=Math.min(r,e,n),o=this.zeros(e,n);for(let e=0;e<i;e++)o.set(e,e,t[e]);return o}static min(t,e){t=this.checkMatrix(t),e=this.checkMatrix(e);let n=t.rows,r=t.columns,i=new tg(n,r);for(let o=0;o<n;o++)for(let n=0;n<r;n++)i.set(o,n,Math.min(t.get(o,n),e.get(o,n)));return i}static max(t,e){t=this.checkMatrix(t),e=this.checkMatrix(e);let n=t.rows,r=t.columns,i=new this(n,r);for(let o=0;o<n;o++)for(let n=0;n<r;n++)i.set(o,n,Math.max(t.get(o,n),e.get(o,n)));return i}static checkMatrix(t){return Qp.isMatrix(t)?t:new tg(t)}static isMatrix(t){return null!=t&&"Matrix"===t.klass}get size(){return this.rows*this.columns}apply(t){if("function"!=typeof t)throw new TypeError("callback must be a function");for(let e=0;e<this.rows;e++)for(let n=0;n<this.columns;n++)t.call(this,e,n);return this}to1DArray(){let t=[];for(let e=0;e<this.rows;e++)for(let n=0;n<this.columns;n++)t.push(this.get(e,n));return t}to2DArray(){let t=[];for(let e=0;e<this.rows;e++){t.push([]);for(let n=0;n<this.columns;n++)t[e].push(this.get(e,n))}return t}toJSON(){return this.to2DArray()}isRowVector(){return 1===this.rows}isColumnVector(){return 1===this.columns}isVector(){return 1===this.rows||1===this.columns}isSquare(){return this.rows===this.columns}isEmpty(){return 0===this.rows||0===this.columns}isSymmetric(){if(this.isSquare()){for(let t=0;t<this.rows;t++)for(let e=0;e<=t;e++)if(this.get(t,e)!==this.get(e,t))return!1;return!0}return!1}isDistance(){if(!this.isSymmetric())return!1;for(let t=0;t<this.rows;t++)if(0!==this.get(t,t))return!1;return!0}isEchelonForm(){let t=0,e=0,n=-1,r=!0,i=!1;for(;t<this.rows&&r;){for(e=0,i=!1;e<this.columns&&!1===i;)0===this.get(t,e)?e++:1===this.get(t,e)&&e>n?(i=!0,n=e):(r=!1,i=!0);t++}return r}isReducedEchelonForm(){let t=0,e=0,n=-1,r=!0,i=!1;for(;t<this.rows&&r;){for(e=0,i=!1;e<this.columns&&!1===i;)0===this.get(t,e)?e++:1===this.get(t,e)&&e>n?(i=!0,n=e):(r=!1,i=!0);for(let n=e+1;n<this.rows;n++)0!==this.get(t,n)&&(r=!1);t++}return r}echelonForm(){let t=this.clone(),e=0,n=0;for(;e<t.rows&&n<t.columns;){let r=e;for(let i=e;i<t.rows;i++)t.get(i,n)>t.get(r,n)&&(r=i);if(0===t.get(r,n))n++;else{t.swapRows(e,r);let i=t.get(e,n);for(let r=n;r<t.columns;r++)t.set(e,r,t.get(e,r)/i);for(let r=e+1;r<t.rows;r++){let i=t.get(r,n)/t.get(e,n);t.set(r,n,0);for(let o=n+1;o<t.columns;o++)t.set(r,o,t.get(r,o)-t.get(e,o)*i)}e++,n++}}return t}reducedEchelonForm(){let t=this.echelonForm(),e=t.columns,n=t.rows,r=n-1;for(;r>=0;)if(0===t.maxRow(r))r--;else{let i=0,o=!1;for(;i<n&&!1===o;)1===t.get(r,i)?o=!0:i++;for(let n=0;n<r;n++){let o=t.get(n,i);for(let a=i;a<e;a++){let e=t.get(n,a)-o*t.get(r,a);t.set(n,a,e)}}r--}return t}set(){throw new Error("set method is unimplemented")}get(){throw new Error("get method is unimplemented")}repeat(t={}){if("object"!=typeof t)throw new TypeError("options must be an object");const{rows:e=1,columns:n=1}=t;if(!Number.isInteger(e)||e<=0)throw new TypeError("rows must be a positive integer");if(!Number.isInteger(n)||n<=0)throw new TypeError("columns must be a positive integer");let r=new tg(this.rows*e,this.columns*n);for(let t=0;t<e;t++)for(let e=0;e<n;e++)r.setSubMatrix(this,this.rows*t,this.columns*e);return r}fill(t){for(let e=0;e<this.rows;e++)for(let n=0;n<this.columns;n++)this.set(e,n,t);return this}neg(){return this.mulS(-1)}getRow(t){Vp(this,t);let e=[];for(let n=0;n<this.columns;n++)e.push(this.get(t,n));return e}getRowVector(t){return tg.rowVector(this.getRow(t))}setRow(t,e){Vp(this,t),e=Wp(this,e);for(let n=0;n<this.columns;n++)this.set(t,n,e[n]);return this}swapRows(t,e){Vp(this,t),Vp(this,e);for(let n=0;n<this.columns;n++){let r=this.get(t,n);this.set(t,n,this.get(e,n)),this.set(e,n,r)}return this}getColumn(t){Up(this,t);let e=[];for(let n=0;n<this.rows;n++)e.push(this.get(n,t));return e}getColumnVector(t){return tg.columnVector(this.getColumn(t))}setColumn(t,e){Up(this,t),e=Hp(this,e);for(let n=0;n<this.rows;n++)this.set(n,t,e[n]);return this}swapColumns(t,e){Up(this,t),Up(this,e);for(let n=0;n<this.rows;n++){let r=this.get(n,t);this.set(n,t,this.get(n,e)),this.set(n,e,r)}return this}addRowVector(t){t=Wp(this,t);for(let e=0;e<this.rows;e++)for(let n=0;n<this.columns;n++)this.set(e,n,this.get(e,n)+t[n]);return this}subRowVector(t){t=Wp(this,t);for(let e=0;e<this.rows;e++)for(let n=0;n<this.columns;n++)this.set(e,n,this.get(e,n)-t[n]);return this}mulRowVector(t){t=Wp(this,t);for(let e=0;e<this.rows;e++)for(let n=0;n<this.columns;n++)this.set(e,n,this.get(e,n)*t[n]);return this}divRowVector(t){t=Wp(this,t);for(let e=0;e<this.rows;e++)for(let n=0;n<this.columns;n++)this.set(e,n,this.get(e,n)/t[n]);return this}addColumnVector(t){t=Hp(this,t);for(let e=0;e<this.rows;e++)for(let n=0;n<this.columns;n++)this.set(e,n,this.get(e,n)+t[e]);return this}subColumnVector(t){t=Hp(this,t);for(let e=0;e<this.rows;e++)for(let n=0;n<this.columns;n++)this.set(e,n,this.get(e,n)-t[e]);return this}mulColumnVector(t){t=Hp(this,t);for(let e=0;e<this.rows;e++)for(let n=0;n<this.columns;n++)this.set(e,n,this.get(e,n)*t[e]);return this}divColumnVector(t){t=Hp(this,t);for(let e=0;e<this.rows;e++)for(let n=0;n<this.columns;n++)this.set(e,n,this.get(e,n)/t[e]);return this}mulRow(t,e){Vp(this,t);for(let n=0;n<this.columns;n++)this.set(t,n,this.get(t,n)*e);return this}mulColumn(t,e){Up(this,t);for(let n=0;n<this.rows;n++)this.set(n,t,this.get(n,t)*e);return this}max(t){if(this.isEmpty())return NaN;switch(t){case"row":{const t=new Array(this.rows).fill(Number.NEGATIVE_INFINITY);for(let e=0;e<this.rows;e++)for(let n=0;n<this.columns;n++)this.get(e,n)>t[e]&&(t[e]=this.get(e,n));return t}case"column":{const t=new Array(this.columns).fill(Number.NEGATIVE_INFINITY);for(let e=0;e<this.rows;e++)for(let n=0;n<this.columns;n++)this.get(e,n)>t[n]&&(t[n]=this.get(e,n));return t}case void 0:{let t=this.get(0,0);for(let e=0;e<this.rows;e++)for(let n=0;n<this.columns;n++)this.get(e,n)>t&&(t=this.get(e,n));return t}default:throw new Error(`invalid option: ${t}`)}}maxIndex(){Zp(this);let t=this.get(0,0),e=[0,0];for(let n=0;n<this.rows;n++)for(let r=0;r<this.columns;r++)this.get(n,r)>t&&(t=this.get(n,r),e[0]=n,e[1]=r);return e}min(t){if(this.isEmpty())return NaN;switch(t){case"row":{const t=new Array(this.rows).fill(Number.POSITIVE_INFINITY);for(let e=0;e<this.rows;e++)for(let n=0;n<this.columns;n++)this.get(e,n)<t[e]&&(t[e]=this.get(e,n));return t}case"column":{const t=new Array(this.columns).fill(Number.POSITIVE_INFINITY);for(let e=0;e<this.rows;e++)for(let n=0;n<this.columns;n++)this.get(e,n)<t[n]&&(t[n]=this.get(e,n));return t}case void 0:{let t=this.get(0,0);for(let e=0;e<this.rows;e++)for(let n=0;n<this.columns;n++)this.get(e,n)<t&&(t=this.get(e,n));return t}default:throw new Error(`invalid option: ${t}`)}}minIndex(){Zp(this);let t=this.get(0,0),e=[0,0];for(let n=0;n<this.rows;n++)for(let r=0;r<this.columns;r++)this.get(n,r)<t&&(t=this.get(n,r),e[0]=n,e[1]=r);return e}maxRow(t){if(Vp(this,t),this.isEmpty())return NaN;let e=this.get(t,0);for(let n=1;n<this.columns;n++)this.get(t,n)>e&&(e=this.get(t,n));return e}maxRowIndex(t){Vp(this,t),Zp(this);let e=this.get(t,0),n=[t,0];for(let r=1;r<this.columns;r++)this.get(t,r)>e&&(e=this.get(t,r),n[1]=r);return n}minRow(t){if(Vp(this,t),this.isEmpty())return NaN;let e=this.get(t,0);for(let n=1;n<this.columns;n++)this.get(t,n)<e&&(e=this.get(t,n));return e}minRowIndex(t){Vp(this,t),Zp(this);let e=this.get(t,0),n=[t,0];for(let r=1;r<this.columns;r++)this.get(t,r)<e&&(e=this.get(t,r),n[1]=r);return n}maxColumn(t){if(Up(this,t),this.isEmpty())return NaN;let e=this.get(0,t);for(let n=1;n<this.rows;n++)this.get(n,t)>e&&(e=this.get(n,t));return e}maxColumnIndex(t){Up(this,t),Zp(this);let e=this.get(0,t),n=[0,t];for(let r=1;r<this.rows;r++)this.get(r,t)>e&&(e=this.get(r,t),n[0]=r);return n}minColumn(t){if(Up(this,t),this.isEmpty())return NaN;let e=this.get(0,t);for(let n=1;n<this.rows;n++)this.get(n,t)<e&&(e=this.get(n,t));return e}minColumnIndex(t){Up(this,t),Zp(this);let e=this.get(0,t),n=[0,t];for(let r=1;r<this.rows;r++)this.get(r,t)<e&&(e=this.get(r,t),n[0]=r);return n}diag(){let t=Math.min(this.rows,this.columns),e=[];for(let n=0;n<t;n++)e.push(this.get(n,n));return e}norm(t="frobenius"){switch(t){case"max":return this.max();case"frobenius":return Math.sqrt(this.dot(this));default:throw new RangeError(`unknown norm type: ${t}`)}}cumulativeSum(){let t=0;for(let e=0;e<this.rows;e++)for(let n=0;n<this.columns;n++)t+=this.get(e,n),this.set(e,n,t);return this}dot(t){Qp.isMatrix(t)&&(t=t.to1DArray());let e=this.to1DArray();if(e.length!==t.length)throw new RangeError("vectors do not have the same size");let n=0;for(let r=0;r<e.length;r++)n+=e[r]*t[r];return n}mmul(t){t=tg.checkMatrix(t);let e=this.rows,n=this.columns,r=t.columns,i=new tg(e,r),o=new Float64Array(n);for(let a=0;a<r;a++){for(let e=0;e<n;e++)o[e]=t.get(e,a);for(let t=0;t<e;t++){let e=0;for(let r=0;r<n;r++)e+=this.get(t,r)*o[r];i.set(t,a,e)}}return i}strassen2x2(t){t=tg.checkMatrix(t);let e=new tg(2,2);const n=this.get(0,0),r=t.get(0,0),i=this.get(0,1),o=t.get(0,1),a=this.get(1,0),s=t.get(1,0),u=this.get(1,1),c=t.get(1,1),h=(n+u)*(r+c),l=(a+u)*r,d=n*(o-c),f=u*(s-r),p=(n+i)*c,g=h+f-p+(i-u)*(s+c),m=d+p,v=l+f,y=h-l+d+(a-n)*(r+o);return e.set(0,0,g),e.set(0,1,m),e.set(1,0,v),e.set(1,1,y),e}strassen3x3(t){t=tg.checkMatrix(t);let e=new tg(3,3);const n=this.get(0,0),r=this.get(0,1),i=this.get(0,2),o=this.get(1,0),a=this.get(1,1),s=this.get(1,2),u=this.get(2,0),c=this.get(2,1),h=this.get(2,2),l=t.get(0,0),d=t.get(0,1),f=t.get(0,2),p=t.get(1,0),g=t.get(1,1),m=t.get(1,2),v=t.get(2,0),y=t.get(2,1),E=t.get(2,2),x=(n-o)*(-d+g),b=(-n+o+a)*(l-d+g),w=(o+a)*(-l+d),M=n*l,N=(-n+u+c)*(l-f+m),S=(-n+u)*(f-m),T=(u+c)*(-l+f),P=(-i+c+h)*(g+v-y),C=(i-h)*(g-y),k=i*v,A=(c+h)*(-v+y),O=(-i+a+s)*(m+v-E),R=(i-s)*(m-E),D=(a+s)*(-v+E),I=M+k+r*p,L=(n+r+i-o-a-c-h)*g+b+w+M+P+k+A,_=M+N+T+(n+r+i-a-s-u-c)*m+k+O+D,z=x+a*(-l+d+p-g-m-v+E)+b+M+k+O+R,F=x+b+w+M+s*y,B=k+O+R+D+o*f,G=M+N+S+c*(-l+f+p-g-m-v+y)+P+C+k,j=P+C+k+A+u*d,V=M+N+S+T+h*E;return e.set(0,0,I),e.set(0,1,L),e.set(0,2,_),e.set(1,0,z),e.set(1,1,F),e.set(1,2,B),e.set(2,0,G),e.set(2,1,j),e.set(2,2,V),e}mmulStrassen(t){t=tg.checkMatrix(t);let e=this.clone(),n=e.rows,r=e.columns,i=t.rows,o=t.columns;function a(t,e,n){let r=t.rows,i=t.columns;if(r===e&&i===n)return t;{let r=Qp.zeros(e,n);return r=r.setSubMatrix(t,0,0),r}}r!==i&&console.warn(`Multiplying ${n} x ${r} and ${i} x ${o} matrix: dimensions do not match.`);let s=Math.max(n,i),u=Math.max(r,o);return e=a(e,s,u),function t(e,n,r,i){if(r<=512||i<=512)return e.mmul(n);r%2==1&&i%2==1?(e=a(e,r+1,i+1),n=a(n,r+1,i+1)):r%2==1?(e=a(e,r+1,i),n=a(n,r+1,i)):i%2==1&&(e=a(e,r,i+1),n=a(n,r,i+1));let o=parseInt(e.rows/2,10),s=parseInt(e.columns/2,10),u=e.subMatrix(0,o-1,0,s-1),c=n.subMatrix(0,o-1,0,s-1),h=e.subMatrix(0,o-1,s,e.columns-1),l=n.subMatrix(0,o-1,s,n.columns-1),d=e.subMatrix(o,e.rows-1,0,s-1),f=n.subMatrix(o,n.rows-1,0,s-1),p=e.subMatrix(o,e.rows-1,s,e.columns-1),g=n.subMatrix(o,n.rows-1,s,n.columns-1),m=t(Qp.add(u,p),Qp.add(c,g),o,s),v=t(Qp.add(d,p),c,o,s),y=t(u,Qp.sub(l,g),o,s),E=t(p,Qp.sub(f,c),o,s),x=t(Qp.add(u,h),g,o,s),b=t(Qp.sub(d,u),Qp.add(c,l),o,s),w=t(Qp.sub(h,p),Qp.add(f,g),o,s),M=Qp.add(m,E);M.sub(x),M.add(w);let N=Qp.add(y,x),S=Qp.add(v,E),T=Qp.sub(m,v);T.add(y),T.add(b);let P=Qp.zeros(2*M.rows,2*M.columns);return P=P.setSubMatrix(M,0,0),P=P.setSubMatrix(N,M.rows,0),P=P.setSubMatrix(S,0,M.columns),P=P.setSubMatrix(T,M.rows,M.columns),P.subMatrix(0,r-1,0,i-1)}(e,t=a(t,s,u),s,u)}scaleRows(t={}){if("object"!=typeof t)throw new TypeError("options must be an object");const{min:e=0,max:n=1}=t;if(!Number.isFinite(e))throw new TypeError("min must be a number");if(!Number.isFinite(n))throw new TypeError("max must be a number");if(e>=n)throw new RangeError("min must be smaller than max");let r=new tg(this.rows,this.columns);for(let t=0;t<this.rows;t++){const i=this.getRow(t);i.length>0&&_p(i,{min:e,max:n,output:i}),r.setRow(t,i)}return r}scaleColumns(t={}){if("object"!=typeof t)throw new TypeError("options must be an object");const{min:e=0,max:n=1}=t;if(!Number.isFinite(e))throw new TypeError("min must be a number");if(!Number.isFinite(n))throw new TypeError("max must be a number");if(e>=n)throw new RangeError("min must be smaller than max");let r=new tg(this.rows,this.columns);for(let t=0;t<this.columns;t++){const i=this.getColumn(t);i.length&&_p(i,{min:e,max:n,output:i}),r.setColumn(t,i)}return r}flipRows(){const t=Math.ceil(this.columns/2);for(let e=0;e<this.rows;e++)for(let n=0;n<t;n++){let t=this.get(e,n),r=this.get(e,this.columns-1-n);this.set(e,n,r),this.set(e,this.columns-1-n,t)}return this}flipColumns(){const t=Math.ceil(this.rows/2);for(let e=0;e<this.columns;e++)for(let n=0;n<t;n++){let t=this.get(n,e),r=this.get(this.rows-1-n,e);this.set(n,e,r),this.set(this.rows-1-n,e,t)}return this}kroneckerProduct(t){t=tg.checkMatrix(t);let e=this.rows,n=this.columns,r=t.rows,i=t.columns,o=new tg(e*r,n*i);for(let a=0;a<e;a++)for(let e=0;e<n;e++)for(let n=0;n<r;n++)for(let s=0;s<i;s++)o.set(r*a+n,i*e+s,this.get(a,e)*t.get(n,s));return o}kroneckerSum(t){if(t=tg.checkMatrix(t),!this.isSquare()||!t.isSquare())throw new Error("Kronecker Sum needs two Square Matrices");let e=this.rows,n=t.rows,r=this.kroneckerProduct(tg.eye(n,n)),i=tg.eye(e,e).kroneckerProduct(t);return r.add(i)}transpose(){let t=new tg(this.columns,this.rows);for(let e=0;e<this.rows;e++)for(let n=0;n<this.columns;n++)t.set(n,e,this.get(e,n));return t}sortRows(t=Jp){for(let e=0;e<this.rows;e++)this.setRow(e,this.getRow(e).sort(t));return this}sortColumns(t=Jp){for(let e=0;e<this.columns;e++)this.setColumn(e,this.getColumn(e).sort(t));return this}subMatrix(t,e,n,r){Xp(this,t,e,n,r);let i=new tg(e-t+1,r-n+1);for(let o=t;o<=e;o++)for(let e=n;e<=r;e++)i.set(o-t,e-n,this.get(o,e));return i}subMatrixRow(t,e,n){if(void 0===e&&(e=0),void 0===n&&(n=this.columns-1),e>n||e<0||e>=this.columns||n<0||n>=this.columns)throw new RangeError("Argument out of range");let r=new tg(t.length,n-e+1);for(let i=0;i<t.length;i++)for(let o=e;o<=n;o++){if(t[i]<0||t[i]>=this.rows)throw new RangeError(`Row index out of range: ${t[i]}`);r.set(i,o-e,this.get(t[i],o))}return r}subMatrixColumn(t,e,n){if(void 0===e&&(e=0),void 0===n&&(n=this.rows-1),e>n||e<0||e>=this.rows||n<0||n>=this.rows)throw new RangeError("Argument out of range");let r=new tg(n-e+1,t.length);for(let i=0;i<t.length;i++)for(let o=e;o<=n;o++){if(t[i]<0||t[i]>=this.columns)throw new RangeError(`Column index out of range: ${t[i]}`);r.set(o-e,i,this.get(o,t[i]))}return r}setSubMatrix(t,e,n){if((t=tg.checkMatrix(t)).isEmpty())return this;Xp(this,e,e+t.rows-1,n,n+t.columns-1);for(let r=0;r<t.rows;r++)for(let i=0;i<t.columns;i++)this.set(e+r,n+i,t.get(r,i));return this}selection(t,e){qp(this,t),Yp(this,e);let n=new tg(t.length,e.length);for(let r=0;r<t.length;r++){let i=t[r];for(let t=0;t<e.length;t++){let o=e[t];n.set(r,t,this.get(i,o))}}return n}trace(){let t=Math.min(this.rows,this.columns),e=0;for(let n=0;n<t;n++)e+=this.get(n,n);return e}clone(){return this.constructor.copy(this,new tg(this.rows,this.columns))}static copy(t,e){for(const[n,r,i]of t.entries())e.set(n,r,i);return e}sum(t){switch(t){case"row":return function(t){let e=Kp(t.rows);for(let n=0;n<t.rows;++n)for(let r=0;r<t.columns;++r)e[n]+=t.get(n,r);return e}(this);case"column":return function(t){let e=Kp(t.columns);for(let n=0;n<t.rows;++n)for(let r=0;r<t.columns;++r)e[r]+=t.get(n,r);return e}(this);case void 0:return function(t){let e=0;for(let n=0;n<t.rows;n++)for(let r=0;r<t.columns;r++)e+=t.get(n,r);return e}(this);default:throw new Error(`invalid option: ${t}`)}}product(t){switch(t){case"row":return function(t){let e=Kp(t.rows,1);for(let n=0;n<t.rows;++n)for(let r=0;r<t.columns;++r)e[n]*=t.get(n,r);return e}(this);case"column":return function(t){let e=Kp(t.columns,1);for(let n=0;n<t.rows;++n)for(let r=0;r<t.columns;++r)e[r]*=t.get(n,r);return e}(this);case void 0:return function(t){let e=1;for(let n=0;n<t.rows;n++)for(let r=0;r<t.columns;r++)e*=t.get(n,r);return e}(this);default:throw new Error(`invalid option: ${t}`)}}mean(t){const e=this.sum(t);switch(t){case"row":for(let t=0;t<this.rows;t++)e[t]/=this.columns;return e;case"column":for(let t=0;t<this.columns;t++)e[t]/=this.rows;return e;case void 0:return e/this.size;default:throw new Error(`invalid option: ${t}`)}}variance(t,e={}){if("object"==typeof t&&(e=t,t=void 0),"object"!=typeof e)throw new TypeError("options must be an object");const{unbiased:n=!0,mean:r=this.mean(t)}=e;if("boolean"!=typeof n)throw new TypeError("unbiased must be a boolean");switch(t){case"row":if(!Lp.isAnyArray(r))throw new TypeError("mean must be an array");return function(t,e,n){const r=t.rows,i=t.columns,o=[];for(let a=0;a<r;a++){let r=0,s=0,u=0;for(let e=0;e<i;e++)u=t.get(a,e)-n[a],r+=u,s+=u*u;e?o.push((s-r*r/i)/(i-1)):o.push((s-r*r/i)/i)}return o}(this,n,r);case"column":if(!Lp.isAnyArray(r))throw new TypeError("mean must be an array");return function(t,e,n){const r=t.rows,i=t.columns,o=[];for(let a=0;a<i;a++){let i=0,s=0,u=0;for(let e=0;e<r;e++)u=t.get(e,a)-n[a],i+=u,s+=u*u;e?o.push((s-i*i/r)/(r-1)):o.push((s-i*i/r)/r)}return o}(this,n,r);case void 0:if("number"!=typeof r)throw new TypeError("mean must be a number");return function(t,e,n){const r=t.rows,i=t.columns,o=r*i;let a=0,s=0,u=0;for(let e=0;e<r;e++)for(let r=0;r<i;r++)u=t.get(e,r)-n,a+=u,s+=u*u;return e?(s-a*a/o)/(o-1):(s-a*a/o)/o}(this,n,r);default:throw new Error(`invalid option: ${t}`)}}standardDeviation(t,e){"object"==typeof t&&(e=t,t=void 0);const n=this.variance(t,e);if(void 0===t)return Math.sqrt(n);for(let t=0;t<n.length;t++)n[t]=Math.sqrt(n[t]);return n}center(t,e={}){if("object"==typeof t&&(e=t,t=void 0),"object"!=typeof e)throw new TypeError("options must be an object");const{center:n=this.mean(t)}=e;switch(t){case"row":if(!Lp.isAnyArray(n))throw new TypeError("center must be an array");return function(t,e){for(let n=0;n<t.rows;n++)for(let r=0;r<t.columns;r++)t.set(n,r,t.get(n,r)-e[n])}(this,n),this;case"column":if(!Lp.isAnyArray(n))throw new TypeError("center must be an array");return function(t,e){for(let n=0;n<t.rows;n++)for(let r=0;r<t.columns;r++)t.set(n,r,t.get(n,r)-e[r])}(this,n),this;case void 0:if("number"!=typeof n)throw new TypeError("center must be a number");return function(t,e){for(let n=0;n<t.rows;n++)for(let r=0;r<t.columns;r++)t.set(n,r,t.get(n,r)-e)}(this,n),this;default:throw new Error(`invalid option: ${t}`)}}scale(t,e={}){if("object"==typeof t&&(e=t,t=void 0),"object"!=typeof e)throw new TypeError("options must be an object");let n=e.scale;switch(t){case"row":if(void 0===n)n=function(t){const e=[];for(let n=0;n<t.rows;n++){let r=0;for(let e=0;e<t.columns;e++)r+=Math.pow(t.get(n,e),2)/(t.columns-1);e.push(Math.sqrt(r))}return e}(this);else if(!Lp.isAnyArray(n))throw new TypeError("scale must be an array");return function(t,e){for(let n=0;n<t.rows;n++)for(let r=0;r<t.columns;r++)t.set(n,r,t.get(n,r)/e[n])}(this,n),this;case"column":if(void 0===n)n=function(t){const e=[];for(let n=0;n<t.columns;n++){let r=0;for(let e=0;e<t.rows;e++)r+=Math.pow(t.get(e,n),2)/(t.rows-1);e.push(Math.sqrt(r))}return e}(this);else if(!Lp.isAnyArray(n))throw new TypeError("scale must be an array");return function(t,e){for(let n=0;n<t.rows;n++)for(let r=0;r<t.columns;r++)t.set(n,r,t.get(n,r)/e[r])}(this,n),this;case void 0:if(void 0===n)n=function(t){const e=t.size-1;let n=0;for(let r=0;r<t.columns;r++)for(let i=0;i<t.rows;i++)n+=Math.pow(t.get(i,r),2)/e;return Math.sqrt(n)}(this);else if("number"!=typeof n)throw new TypeError("scale must be a number");return function(t,e){for(let n=0;n<t.rows;n++)for(let r=0;r<t.columns;r++)t.set(n,r,t.get(n,r)/e)}(this,n),this;default:throw new Error(`invalid option: ${t}`)}}toString(t){return Bp(this,t)}[Symbol.iterator](){return this.entries()}*entries(){for(let t=0;t<this.rows;t++)for(let e=0;e<this.columns;e++)yield[t,e,this.get(t,e)]}*values(){for(let t=0;t<this.rows;t++)for(let e=0;e<this.columns;e++)yield this.get(t,e)}}function Jp(t,e){return t-e}Qp.prototype.klass="Matrix","undefined"!=typeof Symbol&&(Qp.prototype[Symbol.for("nodejs.util.inspect.custom")]=function(){return Bp(this)}),Qp.random=Qp.rand,Qp.randomInt=Qp.randInt,Qp.diagonal=Qp.diag,Qp.prototype.diagonal=Qp.prototype.diag,Qp.identity=Qp.eye,Qp.prototype.negate=Qp.prototype.neg,Qp.prototype.tensorProduct=Qp.prototype.kroneckerProduct;let tg=class t extends Qp{data;#t(t,e){if(this.data=[],!(Number.isInteger(e)&&e>=0))throw new TypeError("nColumns must be a positive integer");for(let n=0;n<t;n++)this.data.push(new Float64Array(e));this.rows=t,this.columns=e}constructor(e,n){if(super(),t.isMatrix(e))this.#t(e.rows,e.columns),t.copy(e,this);else if(Number.isInteger(e)&&e>=0)this.#t(e,n);else{if(!Lp.isAnyArray(e))throw new TypeError("First argument must be a positive number or an array");{const t=e;if("number"!=typeof(n=(e=t.length)?t[0].length:0))throw new TypeError("Data must be a 2D array with at least one element");this.data=[];for(let r=0;r<e;r++){if(t[r].length!==n)throw new RangeError("Inconsistent array dimensions");if(!t[r].every((t=>"number"==typeof t)))throw new TypeError("Input data contains non-numeric values");this.data.push(Float64Array.from(t[r]))}this.rows=e,this.columns=n}}}set(t,e,n){return this.data[t][e]=n,this}get(t,e){return this.data[t][e]}removeRow(t){return Vp(this,t),this.data.splice(t,1),this.rows-=1,this}addRow(t,e){return void 0===e&&(e=t,t=this.rows),Vp(this,t,!0),e=Float64Array.from(Wp(this,e)),this.data.splice(t,0,e),this.rows+=1,this}removeColumn(t){Up(this,t);for(let e=0;e<this.rows;e++){const n=new Float64Array(this.columns-1);for(let r=0;r<t;r++)n[r]=this.data[e][r];for(let r=t+1;r<this.columns;r++)n[r-1]=this.data[e][r];this.data[e]=n}return this.columns-=1,this}addColumn(t,e){void 0===e&&(e=t,t=this.columns),Up(this,t,!0),e=Hp(this,e);for(let n=0;n<this.rows;n++){const r=new Float64Array(this.columns+1);let i=0;for(;i<t;i++)r[i]=this.data[n][i];for(r[i++]=e[n];i<this.columns+1;i++)r[i]=this.data[n][i-1];this.data[n]=r}return this.columns+=1,this}};!function(t,e){t.prototype.add=function(t){return"number"==typeof t?this.addS(t):this.addM(t)},t.prototype.addS=function(t){for(let e=0;e<this.rows;e++)for(let n=0;n<this.columns;n++)this.set(e,n,this.get(e,n)+t);return this},t.prototype.addM=function(t){if(t=e.checkMatrix(t),this.rows!==t.rows||this.columns!==t.columns)throw new RangeError("Matrices dimensions must be equal");for(let e=0;e<this.rows;e++)for(let n=0;n<this.columns;n++)this.set(e,n,this.get(e,n)+t.get(e,n));return this},t.add=function(t,n){return new e(t).add(n)},t.prototype.sub=function(t){return"number"==typeof t?this.subS(t):this.subM(t)},t.prototype.subS=function(t){for(let e=0;e<this.rows;e++)for(let n=0;n<this.columns;n++)this.set(e,n,this.get(e,n)-t);return this},t.prototype.subM=function(t){if(t=e.checkMatrix(t),this.rows!==t.rows||this.columns!==t.columns)throw new RangeError("Matrices dimensions must be equal");for(let e=0;e<this.rows;e++)for(let n=0;n<this.columns;n++)this.set(e,n,this.get(e,n)-t.get(e,n));return this},t.sub=function(t,n){return new e(t).sub(n)},t.prototype.subtract=t.prototype.sub,t.prototype.subtractS=t.prototype.subS,t.prototype.subtractM=t.prototype.subM,t.subtract=t.sub,t.prototype.mul=function(t){return"number"==typeof t?this.mulS(t):this.mulM(t)},t.prototype.mulS=function(t){for(let e=0;e<this.rows;e++)for(let n=0;n<this.columns;n++)this.set(e,n,this.get(e,n)*t);return this},t.prototype.mulM=function(t){if(t=e.checkMatrix(t),this.rows!==t.rows||this.columns!==t.columns)throw new RangeError("Matrices dimensions must be equal");for(let e=0;e<this.rows;e++)for(let n=0;n<this.columns;n++)this.set(e,n,this.get(e,n)*t.get(e,n));return this},t.mul=function(t,n){return new e(t).mul(n)},t.prototype.multiply=t.prototype.mul,t.prototype.multiplyS=t.prototype.mulS,t.prototype.multiplyM=t.prototype.mulM,t.multiply=t.mul,t.prototype.div=function(t){return"number"==typeof t?this.divS(t):this.divM(t)},t.prototype.divS=function(t){for(let e=0;e<this.rows;e++)for(let n=0;n<this.columns;n++)this.set(e,n,this.get(e,n)/t);return this},t.prototype.divM=function(t){if(t=e.checkMatrix(t),this.rows!==t.rows||this.columns!==t.columns)throw new RangeError("Matrices dimensions must be equal");for(let e=0;e<this.rows;e++)for(let n=0;n<this.columns;n++)this.set(e,n,this.get(e,n)/t.get(e,n));return this},t.div=function(t,n){return new e(t).div(n)},t.prototype.divide=t.prototype.div,t.prototype.divideS=t.prototype.divS,t.prototype.divideM=t.prototype.divM,t.divide=t.div,t.prototype.mod=function(t){return"number"==typeof t?this.modS(t):this.modM(t)},t.prototype.modS=function(t){for(let e=0;e<this.rows;e++)for(let n=0;n<this.columns;n++)this.set(e,n,this.get(e,n)%t);return this},t.prototype.modM=function(t){if(t=e.checkMatrix(t),this.rows!==t.rows||this.columns!==t.columns)throw new RangeError("Matrices dimensions must be equal");for(let e=0;e<this.rows;e++)for(let n=0;n<this.columns;n++)this.set(e,n,this.get(e,n)%t.get(e,n));return this},t.mod=function(t,n){return new e(t).mod(n)},t.prototype.modulus=t.prototype.mod,t.prototype.modulusS=t.prototype.modS,t.prototype.modulusM=t.prototype.modM,t.modulus=t.mod,t.prototype.and=function(t){return"number"==typeof t?this.andS(t):this.andM(t)},t.prototype.andS=function(t){for(let e=0;e<this.rows;e++)for(let n=0;n<this.columns;n++)this.set(e,n,this.get(e,n)&t);return this},t.prototype.andM=function(t){if(t=e.checkMatrix(t),this.rows!==t.rows||this.columns!==t.columns)throw new RangeError("Matrices dimensions must be equal");for(let e=0;e<this.rows;e++)for(let n=0;n<this.columns;n++)this.set(e,n,this.get(e,n)&t.get(e,n));return this},t.and=function(t,n){return new e(t).and(n)},t.prototype.or=function(t){return"number"==typeof t?this.orS(t):this.orM(t)},t.prototype.orS=function(t){for(let e=0;e<this.rows;e++)for(let n=0;n<this.columns;n++)this.set(e,n,this.get(e,n)|t);return this},t.prototype.orM=function(t){if(t=e.checkMatrix(t),this.rows!==t.rows||this.columns!==t.columns)throw new RangeError("Matrices dimensions must be equal");for(let e=0;e<this.rows;e++)for(let n=0;n<this.columns;n++)this.set(e,n,this.get(e,n)|t.get(e,n));return this},t.or=function(t,n){return new e(t).or(n)},t.prototype.xor=function(t){return"number"==typeof t?this.xorS(t):this.xorM(t)},t.prototype.xorS=function(t){for(let e=0;e<this.rows;e++)for(let n=0;n<this.columns;n++)this.set(e,n,this.get(e,n)^t);return this},t.prototype.xorM=function(t){if(t=e.checkMatrix(t),this.rows!==t.rows||this.columns!==t.columns)throw new RangeError("Matrices dimensions must be equal");for(let e=0;e<this.rows;e++)for(let n=0;n<this.columns;n++)this.set(e,n,this.get(e,n)^t.get(e,n));return this},t.xor=function(t,n){return new e(t).xor(n)},t.prototype.leftShift=function(t){return"number"==typeof t?this.leftShiftS(t):this.leftShiftM(t)},t.prototype.leftShiftS=function(t){for(let e=0;e<this.rows;e++)for(let n=0;n<this.columns;n++)this.set(e,n,this.get(e,n)<<t);return this},t.prototype.leftShiftM=function(t){if(t=e.checkMatrix(t),this.rows!==t.rows||this.columns!==t.columns)throw new RangeError("Matrices dimensions must be equal");for(let e=0;e<this.rows;e++)for(let n=0;n<this.columns;n++)this.set(e,n,this.get(e,n)<<t.get(e,n));return this},t.leftShift=function(t,n){return new e(t).leftShift(n)},t.prototype.signPropagatingRightShift=function(t){return"number"==typeof t?this.signPropagatingRightShiftS(t):this.signPropagatingRightShiftM(t)},t.prototype.signPropagatingRightShiftS=function(t){for(let e=0;e<this.rows;e++)for(let n=0;n<this.columns;n++)this.set(e,n,this.get(e,n)>>t);return this},t.prototype.signPropagatingRightShiftM=function(t){if(t=e.checkMatrix(t),this.rows!==t.rows||this.columns!==t.columns)throw new RangeError("Matrices dimensions must be equal");for(let e=0;e<this.rows;e++)for(let n=0;n<this.columns;n++)this.set(e,n,this.get(e,n)>>t.get(e,n));return this},t.signPropagatingRightShift=function(t,n){return new e(t).signPropagatingRightShift(n)},t.prototype.rightShift=function(t){return"number"==typeof t?this.rightShiftS(t):this.rightShiftM(t)},t.prototype.rightShiftS=function(t){for(let e=0;e<this.rows;e++)for(let n=0;n<this.columns;n++)this.set(e,n,this.get(e,n)>>>t);return this},t.prototype.rightShiftM=function(t){if(t=e.checkMatrix(t),this.rows!==t.rows||this.columns!==t.columns)throw new RangeError("Matrices dimensions must be equal");for(let e=0;e<this.rows;e++)for(let n=0;n<this.columns;n++)this.set(e,n,this.get(e,n)>>>t.get(e,n));return this},t.rightShift=function(t,n){return new e(t).rightShift(n)},t.prototype.zeroFillRightShift=t.prototype.rightShift,t.prototype.zeroFillRightShiftS=t.prototype.rightShiftS,t.prototype.zeroFillRightShiftM=t.prototype.rightShiftM,t.zeroFillRightShift=t.rightShift,t.prototype.not=function(){for(let t=0;t<this.rows;t++)for(let e=0;e<this.columns;e++)this.set(t,e,~this.get(t,e));return this},t.not=function(t){return new e(t).not()},t.prototype.abs=function(){for(let t=0;t<this.rows;t++)for(let e=0;e<this.columns;e++)this.set(t,e,Math.abs(this.get(t,e)));return this},t.abs=function(t){return new e(t).abs()},t.prototype.acos=function(){for(let t=0;t<this.rows;t++)for(let e=0;e<this.columns;e++)this.set(t,e,Math.acos(this.get(t,e)));return this},t.acos=function(t){return new e(t).acos()},t.prototype.acosh=function(){for(let t=0;t<this.rows;t++)for(let e=0;e<this.columns;e++)this.set(t,e,Math.acosh(this.get(t,e)));return this},t.acosh=function(t){return new e(t).acosh()},t.prototype.asin=function(){for(let t=0;t<this.rows;t++)for(let e=0;e<this.columns;e++)this.set(t,e,Math.asin(this.get(t,e)));return this},t.asin=function(t){return new e(t).asin()},t.prototype.asinh=function(){for(let t=0;t<this.rows;t++)for(let e=0;e<this.columns;e++)this.set(t,e,Math.asinh(this.get(t,e)));return this},t.asinh=function(t){return new e(t).asinh()},t.prototype.atan=function(){for(let t=0;t<this.rows;t++)for(let e=0;e<this.columns;e++)this.set(t,e,Math.atan(this.get(t,e)));return this},t.atan=function(t){return new e(t).atan()},t.prototype.atanh=function(){for(let t=0;t<this.rows;t++)for(let e=0;e<this.columns;e++)this.set(t,e,Math.atanh(this.get(t,e)));return this},t.atanh=function(t){return new e(t).atanh()},t.prototype.cbrt=function(){for(let t=0;t<this.rows;t++)for(let e=0;e<this.columns;e++)this.set(t,e,Math.cbrt(this.get(t,e)));return this},t.cbrt=function(t){return new e(t).cbrt()},t.prototype.ceil=function(){for(let t=0;t<this.rows;t++)for(let e=0;e<this.columns;e++)this.set(t,e,Math.ceil(this.get(t,e)));return this},t.ceil=function(t){return new e(t).ceil()},t.prototype.clz32=function(){for(let t=0;t<this.rows;t++)for(let e=0;e<this.columns;e++)this.set(t,e,Math.clz32(this.get(t,e)));return this},t.clz32=function(t){return new e(t).clz32()},t.prototype.cos=function(){for(let t=0;t<this.rows;t++)for(let e=0;e<this.columns;e++)this.set(t,e,Math.cos(this.get(t,e)));return this},t.cos=function(t){return new e(t).cos()},t.prototype.cosh=function(){for(let t=0;t<this.rows;t++)for(let e=0;e<this.columns;e++)this.set(t,e,Math.cosh(this.get(t,e)));return this},t.cosh=function(t){return new e(t).cosh()},t.prototype.exp=function(){for(let t=0;t<this.rows;t++)for(let e=0;e<this.columns;e++)this.set(t,e,Math.exp(this.get(t,e)));return this},t.exp=function(t){return new e(t).exp()},t.prototype.expm1=function(){for(let t=0;t<this.rows;t++)for(let e=0;e<this.columns;e++)this.set(t,e,Math.expm1(this.get(t,e)));return this},t.expm1=function(t){return new e(t).expm1()},t.prototype.floor=function(){for(let t=0;t<this.rows;t++)for(let e=0;e<this.columns;e++)this.set(t,e,Math.floor(this.get(t,e)));return this},t.floor=function(t){return new e(t).floor()},t.prototype.fround=function(){for(let t=0;t<this.rows;t++)for(let e=0;e<this.columns;e++)this.set(t,e,Math.fround(this.get(t,e)));return this},t.fround=function(t){return new e(t).fround()},t.prototype.log=function(){for(let t=0;t<this.rows;t++)for(let e=0;e<this.columns;e++)this.set(t,e,Math.log(this.get(t,e)));return this},t.log=function(t){return new e(t).log()},t.prototype.log1p=function(){for(let t=0;t<this.rows;t++)for(let e=0;e<this.columns;e++)this.set(t,e,Math.log1p(this.get(t,e)));return this},t.log1p=function(t){return new e(t).log1p()},t.prototype.log10=function(){for(let t=0;t<this.rows;t++)for(let e=0;e<this.columns;e++)this.set(t,e,Math.log10(this.get(t,e)));return this},t.log10=function(t){return new e(t).log10()},t.prototype.log2=function(){for(let t=0;t<this.rows;t++)for(let e=0;e<this.columns;e++)this.set(t,e,Math.log2(this.get(t,e)));return this},t.log2=function(t){return new e(t).log2()},t.prototype.round=function(){for(let t=0;t<this.rows;t++)for(let e=0;e<this.columns;e++)this.set(t,e,Math.round(this.get(t,e)));return this},t.round=function(t){return new e(t).round()},t.prototype.sign=function(){for(let t=0;t<this.rows;t++)for(let e=0;e<this.columns;e++)this.set(t,e,Math.sign(this.get(t,e)));return this},t.sign=function(t){return new e(t).sign()},t.prototype.sin=function(){for(let t=0;t<this.rows;t++)for(let e=0;e<this.columns;e++)this.set(t,e,Math.sin(this.get(t,e)));return this},t.sin=function(t){return new e(t).sin()},t.prototype.sinh=function(){for(let t=0;t<this.rows;t++)for(let e=0;e<this.columns;e++)this.set(t,e,Math.sinh(this.get(t,e)));return this},t.sinh=function(t){return new e(t).sinh()},t.prototype.sqrt=function(){for(let t=0;t<this.rows;t++)for(let e=0;e<this.columns;e++)this.set(t,e,Math.sqrt(this.get(t,e)));return this},t.sqrt=function(t){return new e(t).sqrt()},t.prototype.tan=function(){for(let t=0;t<this.rows;t++)for(let e=0;e<this.columns;e++)this.set(t,e,Math.tan(this.get(t,e)));return this},t.tan=function(t){return new e(t).tan()},t.prototype.tanh=function(){for(let t=0;t<this.rows;t++)for(let e=0;e<this.columns;e++)this.set(t,e,Math.tanh(this.get(t,e)));return this},t.tanh=function(t){return new e(t).tanh()},t.prototype.trunc=function(){for(let t=0;t<this.rows;t++)for(let e=0;e<this.columns;e++)this.set(t,e,Math.trunc(this.get(t,e)));return this},t.trunc=function(t){return new e(t).trunc()},t.pow=function(t,n){return new e(t).pow(n)},t.prototype.pow=function(t){return"number"==typeof t?this.powS(t):this.powM(t)},t.prototype.powS=function(t){for(let e=0;e<this.rows;e++)for(let n=0;n<this.columns;n++)this.set(e,n,Math.pow(this.get(e,n),t));return this},t.prototype.powM=function(t){if(t=e.checkMatrix(t),this.rows!==t.rows||this.columns!==t.columns)throw new RangeError("Matrices dimensions must be equal");for(let e=0;e<this.rows;e++)for(let n=0;n<this.columns;n++)this.set(e,n,Math.pow(this.get(e,n),t.get(e,n)));return this}}(Qp,tg);class eg extends Qp{#e;get size(){return this.#e.size}get rows(){return this.#e.rows}get columns(){return this.#e.columns}get diagonalSize(){return this.rows}static isSymmetricMatrix(t){return tg.isMatrix(t)&&"SymmetricMatrix"===t.klassType}static zeros(t){return new this(t)}static ones(t){return new this(t).fill(1)}constructor(t){if(super(),tg.isMatrix(t)){if(!t.isSymmetric())throw new TypeError("not symmetric data");this.#e=tg.copy(t,new tg(t.rows,t.rows))}else if(Number.isInteger(t)&&t>=0)this.#e=new tg(t,t);else if(this.#e=new tg(t),!this.isSymmetric())throw new TypeError("not symmetric data")}clone(){const t=new eg(this.diagonalSize);for(const[e,n,r]of this.upperRightEntries())t.set(e,n,r);return t}toMatrix(){return new tg(this)}get(t,e){return this.#e.get(t,e)}set(t,e,n){return this.#e.set(t,e,n),this.#e.set(e,t,n),this}removeCross(t){return this.#e.removeRow(t),this.#e.removeColumn(t),this}addCross(t,e){void 0===e&&(e=t,t=this.diagonalSize);const n=e.slice();return n.splice(t,1),this.#e.addRow(t,n),this.#e.addColumn(t,e),this}applyMask(t){if(t.length!==this.diagonalSize)throw new RangeError("Mask size do not match with matrix size");const e=[];for(const[n,r]of t.entries())r||e.push(n);e.reverse();for(const t of e)this.removeCross(t);return this}toCompact(){const{diagonalSize:t}=this,e=new Array(t*(t+1)/2);for(let n=0,r=0,i=0;i<e.length;i++)e[i]=this.get(r,n),++n>=t&&(n=++r);return e}static fromCompact(t){const e=t.length,n=(Math.sqrt(8*e+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 r=new eg(n);for(let i=0,o=0,a=0;a<e;a++)r.set(i,o,t[a]),++i>=n&&(i=++o);return r}*upperRightEntries(){for(let t=0,e=0;t<this.diagonalSize;void 0){const n=this.get(t,e);yield[t,e,n],++e>=this.diagonalSize&&(e=++t)}}*upperRightValues(){for(let t=0,e=0;t<this.diagonalSize;void 0){const n=this.get(t,e);yield n,++e>=this.diagonalSize&&(e=++t)}}}eg.prototype.klassType="SymmetricMatrix";class ng extends eg{static isDistanceMatrix(t){return eg.isSymmetricMatrix(t)&&"DistanceMatrix"===t.klassSubType}constructor(t){if(super(t),!this.isDistance())throw new TypeError("Provided arguments do no produce a distance matrix")}set(t,e,n){return t===e&&(n=0),super.set(t,e,n)}addCross(t,e){return void 0===e&&(e=t,t=this.diagonalSize),(e=e.slice())[t]=0,super.addCross(t,e)}toSymmetricMatrix(){return new eg(this)}clone(){const t=new ng(this.diagonalSize);for(const[e,n,r]of this.upperRightEntries())e!==n&&t.set(e,n,r);return t}toCompact(){const{diagonalSize:t}=this,e=new Array((t-1)*t/2);for(let n=1,r=0,i=0;i<e.length;i++)e[i]=this.get(r,n),++n>=t&&(n=1+ ++r);return e}static fromCompact(t){const e=t.length,n=(Math.sqrt(8*e+1)+1)/2;if(!Number.isInteger(n))throw new TypeError(`This array is not a compact representation of a DistanceMatrix, ${JSON.stringify(t)}`);const r=new this(n);for(let i=1,o=0,a=0;a<e;a++)r.set(i,o,t[a]),++i>=n&&(i=1+ ++o);return r}}ng.prototype.klassSubType="DistanceMatrix";class rg extends Qp{constructor(t,e,n){super(),this.matrix=t,this.rows=e,this.columns=n}}class ig extends rg{constructor(t,e,n){qp(t,e),Yp(t,n),super(t,e.length,n.length),this.rowIndices=e,this.columnIndices=n}set(t,e,n){return this.matrix.set(this.rowIndices[t],this.columnIndices[e],n),this}get(t,e){return this.matrix.get(this.rowIndices[t],this.columnIndices[e])}}class og extends Qp{constructor(t,e={}){const{rows:n=1}=e;if(t.length%n!=0)throw new Error("the data length is not divisible by the number of rows");super(),this.rows=n,this.columns=t.length/n,this.data=t}set(t,e,n){let r=this._calculateIndex(t,e);return this.data[r]=n,this}get(t,e){let n=this._calculateIndex(t,e);return this.data[n]}_calculateIndex(t,e){return t*this.columns+e}}class ag extends Qp{constructor(t){super(),this.data=t,this.rows=t.length,this.columns=t[0].length}set(t,e,n){return this.data[t][e]=n,this}get(t,e){return this.data[t][e]}}class sg{constructor(t){let e,n,r,i,o,a,s,u,c,h=(t=ag.checkMatrix(t)).clone(),l=h.rows,d=h.columns,f=new Float64Array(l),p=1;for(e=0;e<l;e++)f[e]=e;for(u=new Float64Array(l),n=0;n<d;n++){for(e=0;e<l;e++)u[e]=h.get(e,n);for(e=0;e<l;e++){for(c=Math.min(e,n),o=0,r=0;r<c;r++)o+=h.get(e,r)*u[r];u[e]-=o,h.set(e,n,u[e])}for(i=n,e=n+1;e<l;e++)Math.abs(u[e])>Math.abs(u[i])&&(i=e);if(i!==n){for(r=0;r<d;r++)a=h.get(i,r),h.set(i,r,h.get(n,r)),h.set(n,r,a);s=f[i],f[i]=f[n],f[n]=s,p=-p}if(n<l&&0!==h.get(n,n))for(e=n+1;e<l;e++)h.set(e,n,h.get(e,n)/h.get(n,n))}this.LU=h,this.pivotVector=f,this.pivotSign=p}isSingular(){let t=this.LU,e=t.columns;for(let n=0;n<e;n++)if(0===t.get(n,n))return!0;return!1}solve(t){t=tg.checkMatrix(t);let e=this.LU;if(e.rows!==t.rows)throw new Error("Invalid matrix dimensions");if(this.isSingular())throw new Error("LU matrix is singular");let n,r,i,o=t.columns,a=t.subMatrixRow(this.pivotVector,0,o-1),s=e.columns;for(i=0;i<s;i++)for(n=i+1;n<s;n++)for(r=0;r<o;r++)a.set(n,r,a.get(n,r)-a.get(i,r)*e.get(n,i));for(i=s-1;i>=0;i--){for(r=0;r<o;r++)a.set(i,r,a.get(i,r)/e.get(i,i));for(n=0;n<i;n++)for(r=0;r<o;r++)a.set(n,r,a.get(n,r)-a.get(i,r)*e.get(n,i))}return a}get determinant(){let t=this.LU;if(!t.isSquare())throw new Error("Matrix must be square");let e=this.pivotSign,n=t.columns;for(let r=0;r<n;r++)e*=t.get(r,r);return e}get lowerTriangularMatrix(){let t=this.LU,e=t.rows,n=t.columns,r=new tg(e,n);for(let i=0;i<e;i++)for(let e=0;e<n;e++)i>e?r.set(i,e,t.get(i,e)):i===e?r.set(i,e,1):r.set(i,e,0);return r}get upperTriangularMatrix(){let t=this.LU,e=t.rows,n=t.columns,r=new tg(e,n);for(let i=0;i<e;i++)for(let e=0;e<n;e++)i<=e?r.set(i,e,t.get(i,e)):r.set(i,e,0);return r}get pivotPermutationVector(){return Array.from(this.pivotVector)}}function ug(t,e){let n=0;return Math.abs(t)>Math.abs(e)?(n=e/t,Math.abs(t)*Math.sqrt(1+n*n)):0!==e?(n=t/e,Math.abs(e)*Math.sqrt(1+n*n)):0}class cg{constructor(t){let e,n,r,i,o=(t=ag.checkMatrix(t)).clone(),a=t.rows,s=t.columns,u=new Float64Array(s);for(r=0;r<s;r++){let t=0;for(e=r;e<a;e++)t=ug(t,o.get(e,r));if(0!==t){for(o.get(r,r)<0&&(t=-t),e=r;e<a;e++)o.set(e,r,o.get(e,r)/t);for(o.set(r,r,o.get(r,r)+1),n=r+1;n<s;n++){for(i=0,e=r;e<a;e++)i+=o.get(e,r)*o.get(e,n);for(i=-i/o.get(r,r),e=r;e<a;e++)o.set(e,n,o.get(e,n)+i*o.get(e,r))}}u[r]=-t}this.QR=o,this.Rdiag=u}solve(t){t=tg.checkMatrix(t);let e=this.QR,n=e.rows;if(t.rows!==n)throw new Error("Matrix row dimensions must agree");if(!this.isFullRank())throw new Error("Matrix is rank deficient");let r,i,o,a,s=t.columns,u=t.clone(),c=e.columns;for(o=0;o<c;o++)for(i=0;i<s;i++){for(a=0,r=o;r<n;r++)a+=e.get(r,o)*u.get(r,i);for(a=-a/e.get(o,o),r=o;r<n;r++)u.set(r,i,u.get(r,i)+a*e.get(r,o))}for(o=c-1;o>=0;o--){for(i=0;i<s;i++)u.set(o,i,u.get(o,i)/this.Rdiag[o]);for(r=0;r<o;r++)for(i=0;i<s;i++)u.set(r,i,u.get(r,i)-u.get(o,i)*e.get(r,o))}return u.subMatrix(0,c-1,0,s-1)}isFullRank(){let t=this.QR.columns;for(let e=0;e<t;e++)if(0===this.Rdiag[e])return!1;return!0}get upperTriangularMatrix(){let t,e,n=this.QR,r=n.columns,i=new tg(r,r);for(t=0;t<r;t++)for(e=0;e<r;e++)t<e?i.set(t,e,n.get(t,e)):t===e?i.set(t,e,this.Rdiag[t]):i.set(t,e,0);return i}get orthogonalMatrix(){let t,e,n,r,i=this.QR,o=i.rows,a=i.columns,s=new tg(o,a);for(n=a-1;n>=0;n--){for(t=0;t<o;t++)s.set(t,n,0);for(s.set(n,n,1),e=n;e<a;e++)if(0!==i.get(n,n)){for(r=0,t=n;t<o;t++)r+=i.get(t,n)*s.get(t,e);for(r=-r/i.get(n,n),t=n;t<o;t++)s.set(t,e,s.get(t,e)+r*i.get(t,n))}}return s}}let hg=class{constructor(t,e={}){if((t=ag.checkMatrix(t)).isEmpty())throw new Error("Matrix must be non-empty");let n=t.rows,r=t.columns;const{computeLeftSingularVectors:i=!0,computeRightSingularVectors:o=!0,autoTranspose:a=!1}=e;let s,u=Boolean(i),c=Boolean(o),h=!1;if(n<r)if(a){s=t.transpose(),n=s.rows,r=s.columns,h=!0;let e=u;u=c,c=e}else s=t.clone(),console.warn("Computing SVD on a matrix with more columns than rows. Consider enabling autoTranspose");else s=t.clone();let l=Math.min(n,r),d=Math.min(n+1,r),f=new Float64Array(d),p=new tg(n,l),g=new tg(r,r),m=new Float64Array(r),v=new Float64Array(n),y=new Float64Array(d);for(let t=0;t<d;t++)y[t]=t;let E=Math.min(n-1,r),x=Math.max(0,Math.min(r-2,n)),b=Math.max(E,x);for(let t=0;t<b;t++){if(t<E){f[t]=0;for(let e=t;e<n;e++)f[t]=ug(f[t],s.get(e,t));if(0!==f[t]){s.get(t,t)<0&&(f[t]=-f[t]);for(let e=t;e<n;e++)s.set(e,t,s.get(e,t)/f[t]);s.set(t,t,s.get(t,t)+1)}f[t]=-f[t]}for(let e=t+1;e<r;e++){if(t<E&&0!==f[t]){let r=0;for(let i=t;i<n;i++)r+=s.get(i,t)*s.get(i,e);r=-r/s.get(t,t);for(let i=t;i<n;i++)s.set(i,e,s.get(i,e)+r*s.get(i,t))}m[e]=s.get(t,e)}if(u&&t<E)for(let e=t;e<n;e++)p.set(e,t,s.get(e,t));if(t<x){m[t]=0;for(let e=t+1;e<r;e++)m[t]=ug(m[t],m[e]);if(0!==m[t]){m[t+1]<0&&(m[t]=0-m[t]);for(let e=t+1;e<r;e++)m[e]/=m[t];m[t+1]+=1}if(m[t]=-m[t],t+1<n&&0!==m[t]){for(let e=t+1;e<n;e++)v[e]=0;for(let e=t+1;e<n;e++)for(let n=t+1;n<r;n++)v[e]+=m[n]*s.get(e,n);for(let e=t+1;e<r;e++){let r=-m[e]/m[t+1];for(let i=t+1;i<n;i++)s.set(i,e,s.get(i,e)+r*v[i])}}if(c)for(let e=t+1;e<r;e++)g.set(e,t,m[e])}}let w=Math.min(r,n+1);if(E<r&&(f[E]=s.get(E,E)),n<w&&(f[w-1]=0),x+1<w&&(m[x]=s.get(x,w-1)),m[w-1]=0,u){for(let t=E;t<l;t++){for(let e=0;e<n;e++)p.set(e,t,0);p.set(t,t,1)}for(let t=E-1;t>=0;t--)if(0!==f[t]){for(let e=t+1;e<l;e++){let r=0;for(let i=t;i<n;i++)r+=p.get(i,t)*p.get(i,e);r=-r/p.get(t,t);for(let i=t;i<n;i++)p.set(i,e,p.get(i,e)+r*p.get(i,t))}for(let e=t;e<n;e++)p.set(e,t,-p.get(e,t));p.set(t,t,1+p.get(t,t));for(let e=0;e<t-1;e++)p.set(e,t,0)}else{for(let e=0;e<n;e++)p.set(e,t,0);p.set(t,t,1)}}if(c)for(let t=r-1;t>=0;t--){if(t<x&&0!==m[t])for(let e=t+1;e<r;e++){let n=0;for(let i=t+1;i<r;i++)n+=g.get(i,t)*g.get(i,e);n=-n/g.get(t+1,t);for(let i=t+1;i<r;i++)g.set(i,e,g.get(i,e)+n*g.get(i,t))}for(let e=0;e<r;e++)g.set(e,t,0);g.set(t,t,1)}let M=w-1,N=Number.EPSILON;for(;w>0;){let t,e;for(t=w-2;t>=-1&&-1!==t;t--){const e=Number.MIN_VALUE+N*Math.abs(f[t]+Math.abs(f[t+1]));if(Math.abs(m[t])<=e||Number.isNaN(m[t])){m[t]=0;break}}if(t===w-2)e=4;else{let n;for(n=w-1;n>=t&&n!==t;n--){let e=(n!==w?Math.abs(m[n]):0)+(n!==t+1?Math.abs(m[n-1]):0);if(Math.abs(f[n])<=N*e){f[n]=0;break}}n===t?e=3:n===w-1?e=1:(e=2,t=n)}switch(t++,e){case 1:{let e=m[w-2];m[w-2]=0;for(let n=w-2;n>=t;n--){let i=ug(f[n],e),o=f[n]/i,a=e/i;if(f[n]=i,n!==t&&(e=-a*m[n-1],m[n-1]=o*m[n-1]),c)for(let t=0;t<r;t++)i=o*g.get(t,n)+a*g.get(t,w-1),g.set(t,w-1,-a*g.get(t,n)+o*g.get(t,w-1)),g.set(t,n,i)}break}case 2:{let e=m[t-1];m[t-1]=0;for(let r=t;r<w;r++){let i=ug(f[r],e),o=f[r]/i,a=e/i;if(f[r]=i,e=-a*m[r],m[r]=o*m[r],u)for(let e=0;e<n;e++)i=o*p.get(e,r)+a*p.get(e,t-1),p.set(e,t-1,-a*p.get(e,r)+o*p.get(e,t-1)),p.set(e,r,i)}break}case 3:{const e=Math.max(Math.abs(f[w-1]),Math.abs(f[w-2]),Math.abs(m[w-2]),Math.abs(f[t]),Math.abs(m[t])),i=f[w-1]/e,o=f[w-2]/e,a=m[w-2]/e,s=f[t]/e,h=m[t]/e,l=((o+i)*(o-i)+a*a)/2,d=i*a*(i*a);let v=0;0===l&&0===d||(v=l<0?0-Math.sqrt(l*l+d):Math.sqrt(l*l+d),v=d/(l+v));let y=(s+i)*(s-i)+v,E=s*h;for(let e=t;e<w-1;e++){let i=ug(y,E);0===i&&(i=Number.MIN_VALUE);let o=y/i,a=E/i;if(e!==t&&(m[e-1]=i),y=o*f[e]+a*m[e],m[e]=o*m[e]-a*f[e],E=a*f[e+1],f[e+1]=o*f[e+1],c)for(let t=0;t<r;t++)i=o*g.get(t,e)+a*g.get(t,e+1),g.set(t,e+1,-a*g.get(t,e)+o*g.get(t,e+1)),g.set(t,e,i);if(i=ug(y,E),0===i&&(i=Number.MIN_VALUE),o=y/i,a=E/i,f[e]=i,y=o*m[e]+a*f[e+1],f[e+1]=-a*m[e]+o*f[e+1],E=a*m[e+1],m[e+1]=o*m[e+1],u&&e<n-1)for(let t=0;t<n;t++)i=o*p.get(t,e)+a*p.get(t,e+1),p.set(t,e+1,-a*p.get(t,e)+o*p.get(t,e+1)),p.set(t,e,i)}m[w-2]=y;break}case 4:if(f[t]<=0&&(f[t]=f[t]<0?-f[t]:0,c))for(let e=0;e<=M;e++)g.set(e,t,-g.get(e,t));for(;t<M&&!(f[t]>=f[t+1]);){let e=f[t];if(f[t]=f[t+1],f[t+1]=e,c&&t<r-1)for(let n=0;n<r;n++)e=g.get(n,t+1),g.set(n,t+1,g.get(n,t)),g.set(n,t,e);if(u&&t<n-1)for(let r=0;r<n;r++)e=p.get(r,t+1),p.set(r,t+1,p.get(r,t)),p.set(r,t,e);t++}w--}}if(h){let t=g;g=p,p=t}this.m=n,this.n=r,this.s=f,this.U=p,this.V=g}solve(t){let e=t,n=this.threshold,r=this.s.length,i=tg.zeros(r,r);for(let t=0;t<r;t++)Math.abs(this.s[t])<=n?i.set(t,t,0):i.set(t,t,1/this.s[t]);let o=this.U,a=this.rightSingularVectors,s=a.mmul(i),u=a.rows,c=o.rows,h=tg.zeros(u,c);for(let t=0;t<u;t++)for(let e=0;e<c;e++){let n=0;for(let i=0;i<r;i++)n+=s.get(t,i)*o.get(e,i);h.set(t,e,n)}return h.mmul(e)}solveForDiagonal(t){return this.solve(tg.diag(t))}inverse(){let t=this.V,e=this.threshold,n=t.rows,r=t.columns,i=new tg(n,this.s.length);for(let o=0;o<n;o++)for(let n=0;n<r;n++)Math.abs(this.s[n])>e&&i.set(o,n,t.get(o,n)/this.s[n]);let o=this.U,a=o.rows,s=o.columns,u=new tg(n,a);for(let t=0;t<n;t++)for(let e=0;e<a;e++){let n=0;for(let r=0;r<s;r++)n+=i.get(t,r)*o.get(e,r);u.set(t,e,n)}return u}get condition(){return this.s[0]/this.s[Math.min(this.m,this.n)-1]}get norm2(){return this.s[0]}get rank(){let t=Math.max(this.m,this.n)*this.s[0]*Number.EPSILON,e=0,n=this.s;for(let r=0,i=n.length;r<i;r++)n[r]>t&&e++;return e}get diagonal(){return Array.from(this.s)}get threshold(){return Number.EPSILON/2*Math.max(this.m,this.n)*this.s[0]}get leftSingularVectors(){return this.U}get rightSingularVectors(){return this.V}get diagonalMatrix(){return tg.diag(this.s)}};function lg(t,e,n=!1){return t=ag.checkMatrix(t),e=ag.checkMatrix(e),n?new hg(t).solve(e):t.isSquare()?new sg(t).solve(e):new cg(t).solve(e)}function dg(t,e){let n=[];for(let r=0;r<t;r++)r!==e&&n.push(r);return n}function fg(t,e,n,r=1e-9,i=1e-9){if(t>i)return new Array(e.rows+1).fill(0);{let t=e.addRow(n,[0]);for(let e=0;e<t.rows;e++)Math.abs(t.get(e,0))<r&&t.set(e,0,0);return t.to1DArray()}}class pg{constructor(t,e={}){const{assumeSymmetric:n=!1}=e;if(!(t=ag.checkMatrix(t)).isSquare())throw new Error("Matrix is not a square matrix");if(t.isEmpty())throw new Error("Matrix must be non-empty");let r,i,o=t.columns,a=new tg(o,o),s=new Float64Array(o),u=new Float64Array(o),c=t,h=!1;if(h=!!n||t.isSymmetric(),h){for(r=0;r<o;r++)for(i=0;i<o;i++)a.set(r,i,c.get(r,i));!function(t,e,n,r){let i,o,a,s,u,c,h,l;for(u=0;u<t;u++)n[u]=r.get(t-1,u);for(s=t-1;s>0;s--){for(l=0,a=0,c=0;c<s;c++)l+=Math.abs(n[c]);if(0===l)for(e[s]=n[s-1],u=0;u<s;u++)n[u]=r.get(s-1,u),r.set(s,u,0),r.set(u,s,0);else{for(c=0;c<s;c++)n[c]/=l,a+=n[c]*n[c];for(i=n[s-1],o=Math.sqrt(a),i>0&&(o=-o),e[s]=l*o,a-=i*o,n[s-1]=i-o,u=0;u<s;u++)e[u]=0;for(u=0;u<s;u++){for(i=n[u],r.set(u,s,i),o=e[u]+r.get(u,u)*i,c=u+1;c<=s-1;c++)o+=r.get(c,u)*n[c],e[c]+=r.get(c,u)*i;e[u]=o}for(i=0,u=0;u<s;u++)e[u]/=a,i+=e[u]*n[u];for(h=i/(a+a),u=0;u<s;u++)e[u]-=h*n[u];for(u=0;u<s;u++){for(i=n[u],o=e[u],c=u;c<=s-1;c++)r.set(c,u,r.get(c,u)-(i*e[c]+o*n[c]));n[u]=r.get(s-1,u),r.set(s,u,0)}}n[s]=a}for(s=0;s<t-1;s++){if(r.set(t-1,s,r.get(s,s)),r.set(s,s,1),a=n[s+1],0!==a){for(c=0;c<=s;c++)n[c]=r.get(c,s+1)/a;for(u=0;u<=s;u++){for(o=0,c=0;c<=s;c++)o+=r.get(c,s+1)*r.get(c,u);for(c=0;c<=s;c++)r.set(c,u,r.get(c,u)-o*n[c])}}for(c=0;c<=s;c++)r.set(c,s+1,0)}for(u=0;u<t;u++)n[u]=r.get(t-1,u),r.set(t-1,u,0);r.set(t-1,t-1,1),e[0]=0}(o,u,s,a),function(t,e,n,r){let i,o,a,s,u,c,h,l,d,f,p,g,m,v,y,E;for(a=1;a<t;a++)e[a-1]=e[a];e[t-1]=0;let x=0,b=0,w=Number.EPSILON;for(c=0;c<t;c++){for(b=Math.max(b,Math.abs(n[c])+Math.abs(e[c])),h=c;h<t&&!(Math.abs(e[h])<=w*b);)h++;if(h>c)do{for(i=n[c],l=(n[c+1]-i)/(2*e[c]),d=ug(l,1),l<0&&(d=-d),n[c]=e[c]/(l+d),n[c+1]=e[c]*(l+d),f=n[c+1],o=i-n[c],a=c+2;a<t;a++)n[a]-=o;for(x+=o,l=n[h],p=1,g=p,m=p,v=e[c+1],y=0,E=0,a=h-1;a>=c;a--)for(m=g,g=p,E=y,i=p*e[a],o=p*l,d=ug(l,e[a]),e[a+1]=y*d,y=e[a]/d,p=l/d,l=p*n[a]-y*i,n[a+1]=o+y*(p*i+y*n[a]),u=0;u<t;u++)o=r.get(u,a+1),r.set(u,a+1,y*r.get(u,a)+p*o),r.set(u,a,p*r.get(u,a)-y*o);l=-y*E*m*v*e[c]/f,e[c]=y*l,n[c]=p*l}while(Math.abs(e[c])>w*b);n[c]=n[c]+x,e[c]=0}for(a=0;a<t-1;a++){for(u=a,l=n[a],s=a+1;s<t;s++)n[s]<l&&(u=s,l=n[s]);if(u!==a)for(n[u]=n[a],n[a]=l,s=0;s<t;s++)l=r.get(s,a),r.set(s,a,r.get(s,u)),r.set(s,u,l)}}(o,u,s,a)}else{let t=new tg(o,o),e=new Float64Array(o);for(i=0;i<o;i++)for(r=0;r<o;r++)t.set(r,i,c.get(r,i));!function(t,e,n,r){let i,o,a,s,u,c,h,l=0,d=t-1;for(c=l+1;c<=d-1;c++){for(h=0,s=c;s<=d;s++)h+=Math.abs(e.get(s,c-1));if(0!==h){for(a=0,s=d;s>=c;s--)n[s]=e.get(s,c-1)/h,a+=n[s]*n[s];for(o=Math.sqrt(a),n[c]>0&&(o=-o),a-=n[c]*o,n[c]=n[c]-o,u=c;u<t;u++){for(i=0,s=d;s>=c;s--)i+=n[s]*e.get(s,u);for(i/=a,s=c;s<=d;s++)e.set(s,u,e.get(s,u)-i*n[s])}for(s=0;s<=d;s++){for(i=0,u=d;u>=c;u--)i+=n[u]*e.get(s,u);for(i/=a,u=c;u<=d;u++)e.set(s,u,e.get(s,u)-i*n[u])}n[c]=h*n[c],e.set(c,c-1,h*o)}}for(s=0;s<t;s++)for(u=0;u<t;u++)r.set(s,u,s===u?1:0);for(c=d-1;c>=l+1;c--)if(0!==e.get(c,c-1)){for(s=c+1;s<=d;s++)n[s]=e.get(s,c-1);for(u=c;u<=d;u++){for(o=0,s=c;s<=d;s++)o+=n[s]*r.get(s,u);for(o=o/n[c]/e.get(c,c-1),s=c;s<=d;s++)r.set(s,u,r.get(s,u)+o*n[s])}}}(o,t,e,a),function(t,e,n,r,i){let o,a,s,u,c,h,l,d,f,p,g,m,v,y,E,x=t-1,b=0,w=t-1,M=Number.EPSILON,N=0,S=0,T=0,P=0,C=0,k=0,A=0,O=0;for(o=0;o<t;o++)for((o<b||o>w)&&(n[o]=i.get(o,o),e[o]=0),a=Math.max(o-1,0);a<t;a++)S+=Math.abs(i.get(o,a));for(;x>=b;){for(u=x;u>b&&(k=Math.abs(i.get(u-1,u-1))+Math.abs(i.get(u,u)),0===k&&(k=S),!(Math.abs(i.get(u,u-1))<M*k));)u--;if(u===x)i.set(x,x,i.get(x,x)+N),n[x]=i.get(x,x),e[x]=0,x--,O=0;else if(u===x-1){if(l=i.get(x,x-1)*i.get(x-1,x),T=(i.get(x-1,x-1)-i.get(x,x))/2,P=T*T+l,A=Math.sqrt(Math.abs(P)),i.set(x,x,i.get(x,x)+N),i.set(x-1,x-1,i.get(x-1,x-1)+N),d=i.get(x,x),P>=0){for(A=T>=0?T+A:T-A,n[x-1]=d+A,n[x]=n[x-1],0!==A&&(n[x]=d-l/A),e[x-1]=0,e[x]=0,d=i.get(x,x-1),k=Math.abs(d)+Math.abs(A),T=d/k,P=A/k,C=Math.sqrt(T*T+P*P),T/=C,P/=C,a=x-1;a<t;a++)A=i.get(x-1,a),i.set(x-1,a,P*A+T*i.get(x,a)),i.set(x,a,P*i.get(x,a)-T*A);for(o=0;o<=x;o++)A=i.get(o,x-1),i.set(o,x-1,P*A+T*i.get(o,x)),i.set(o,x,P*i.get(o,x)-T*A);for(o=b;o<=w;o++)A=r.get(o,x-1),r.set(o,x-1,P*A+T*r.get(o,x)),r.set(o,x,P*r.get(o,x)-T*A)}else n[x-1]=d+T,n[x]=d+T,e[x-1]=A,e[x]=-A;x-=2,O=0}else{if(d=i.get(x,x),f=0,l=0,u<x&&(f=i.get(x-1,x-1),l=i.get(x,x-1)*i.get(x-1,x)),10===O){for(N+=d,o=b;o<=x;o++)i.set(o,o,i.get(o,o)-d);k=Math.abs(i.get(x,x-1))+Math.abs(i.get(x-1,x-2)),d=f=.75*k,l=-.4375*k*k}if(30===O&&(k=(f-d)/2,k=k*k+l,k>0)){for(k=Math.sqrt(k),f<d&&(k=-k),k=d-l/((f-d)/2+k),o=b;o<=x;o++)i.set(o,o,i.get(o,o)-k);N+=k,d=f=l=.964}for(O+=1,c=x-2;c>=u&&(A=i.get(c,c),C=d-A,k=f-A,T=(C*k-l)/i.get(c+1,c)+i.get(c,c+1),P=i.get(c+1,c+1)-A-C-k,C=i.get(c+2,c+1),k=Math.abs(T)+Math.abs(P)+Math.abs(C),T/=k,P/=k,C/=k,c!==u)&&!(Math.abs(i.get(c,c-1))*(Math.abs(P)+Math.abs(C))<M*(Math.abs(T)*(Math.abs(i.get(c-1,c-1))+Math.abs(A)+Math.abs(i.get(c+1,c+1)))));)c--;for(o=c+2;o<=x;o++)i.set(o,o-2,0),o>c+2&&i.set(o,o-3,0);for(s=c;s<=x-1&&(y=s!==x-1,s!==c&&(T=i.get(s,s-1),P=i.get(s+1,s-1),C=y?i.get(s+2,s-1):0,d=Math.abs(T)+Math.abs(P)+Math.abs(C),0!==d&&(T/=d,P/=d,C/=d)),0!==d);s++)if(k=Math.sqrt(T*T+P*P+C*C),T<0&&(k=-k),0!==k){for(s!==c?i.set(s,s-1,-k*d):u!==c&&i.set(s,s-1,-i.get(s,s-1)),T+=k,d=T/k,f=P/k,A=C/k,P/=T,C/=T,a=s;a<t;a++)T=i.get(s,a)+P*i.get(s+1,a),y&&(T+=C*i.get(s+2,a),i.set(s+2,a,i.get(s+2,a)-T*A)),i.set(s,a,i.get(s,a)-T*d),i.set(s+1,a,i.get(s+1,a)-T*f);for(o=0;o<=Math.min(x,s+3);o++)T=d*i.get(o,s)+f*i.get(o,s+1),y&&(T+=A*i.get(o,s+2),i.set(o,s+2,i.get(o,s+2)-T*C)),i.set(o,s,i.get(o,s)-T),i.set(o,s+1,i.get(o,s+1)-T*P);for(o=b;o<=w;o++)T=d*r.get(o,s)+f*r.get(o,s+1),y&&(T+=A*r.get(o,s+2),r.set(o,s+2,r.get(o,s+2)-T*C)),r.set(o,s,r.get(o,s)-T),r.set(o,s+1,r.get(o,s+1)-T*P)}}}if(0===S)return;for(x=t-1;x>=0;x--)if(T=n[x],P=e[x],0===P)for(u=x,i.set(x,x,1),o=x-1;o>=0;o--){for(l=i.get(o,o)-T,C=0,a=u;a<=x;a++)C+=i.get(o,a)*i.get(a,x);if(e[o]<0)A=l,k=C;else if(u=o,0===e[o]?i.set(o,x,0!==l?-C/l:-C/(M*S)):(d=i.get(o,o+1),f=i.get(o+1,o),P=(n[o]-T)*(n[o]-T)+e[o]*e[o],h=(d*k-A*C)/P,i.set(o,x,h),i.set(o+1,x,Math.abs(d)>Math.abs(A)?(-C-l*h)/d:(-k-f*h)/A)),h=Math.abs(i.get(o,x)),M*h*h>1)for(a=o;a<=x;a++)i.set(a,x,i.get(a,x)/h)}else if(P<0)for(u=x-1,Math.abs(i.get(x,x-1))>Math.abs(i.get(x-1,x))?(i.set(x-1,x-1,P/i.get(x,x-1)),i.set(x-1,x,-(i.get(x,x)-T)/i.get(x,x-1))):(E=gg(0,-i.get(x-1,x),i.get(x-1,x-1)-T,P),i.set(x-1,x-1,E[0]),i.set(x-1,x,E[1])),i.set(x,x-1,0),i.set(x,x,1),o=x-2;o>=0;o--){for(p=0,g=0,a=u;a<=x;a++)p+=i.get(o,a)*i.get(a,x-1),g+=i.get(o,a)*i.get(a,x);if(l=i.get(o,o)-T,e[o]<0)A=l,C=p,k=g;else if(u=o,0===e[o]?(E=gg(-p,-g,l,P),i.set(o,x-1,E[0]),i.set(o,x,E[1])):(d=i.get(o,o+1),f=i.get(o+1,o),m=(n[o]-T)*(n[o]-T)+e[o]*e[o]-P*P,v=2*(n[o]-T)*P,0===m&&0===v&&(m=M*S*(Math.abs(l)+Math.abs(P)+Math.abs(d)+Math.abs(f)+Math.abs(A))),E=gg(d*C-A*p+P*g,d*k-A*g-P*p,m,v),i.set(o,x-1,E[0]),i.set(o,x,E[1]),Math.abs(d)>Math.abs(A)+Math.abs(P)?(i.set(o+1,x-1,(-p-l*i.get(o,x-1)+P*i.get(o,x))/d),i.set(o+1,x,(-g-l*i.get(o,x)-P*i.get(o,x-1))/d)):(E=gg(-C-f*i.get(o,x-1),-k-f*i.get(o,x),A,P),i.set(o+1,x-1,E[0]),i.set(o+1,x,E[1]))),h=Math.max(Math.abs(i.get(o,x-1)),Math.abs(i.get(o,x))),M*h*h>1)for(a=o;a<=x;a++)i.set(a,x-1,i.get(a,x-1)/h),i.set(a,x,i.get(a,x)/h)}for(o=0;o<t;o++)if(o<b||o>w)for(a=o;a<t;a++)r.set(o,a,i.get(o,a));for(a=t-1;a>=b;a--)for(o=b;o<=w;o++){for(A=0,s=b;s<=Math.min(a,w);s++)A+=r.get(o,s)*i.get(s,a);r.set(o,a,A)}}(o,u,s,a,t)}this.n=o,this.e=u,this.d=s,this.V=a}get realEigenvalues(){return Array.from(this.d)}get imaginaryEigenvalues(){return Array.from(this.e)}get eigenvectorMatrix(){return this.V}get diagonalMatrix(){let t,e,n=this.n,r=this.e,i=this.d,o=new tg(n,n);for(t=0;t<n;t++){for(e=0;e<n;e++)o.set(t,e,0);o.set(t,t,i[t]),r[t]>0?o.set(t,t+1,r[t]):r[t]<0&&o.set(t,t-1,r[t])}return o}}function gg(t,e,n,r){let i,o;return Math.abs(n)>Math.abs(r)?(i=r/n,o=n+i*r,[(t+i*e)/o,(e-i*t)/o]):(i=n/r,o=r+i*n,[(i*t+e)/o,(i*e-t)/o])}class mg{constructor(t){if(!(t=ag.checkMatrix(t)).isSymmetric())throw new Error("Matrix is not symmetric");let e,n,r,i=t,o=i.rows,a=new tg(o,o),s=!0;for(n=0;n<o;n++){let t=0;for(r=0;r<n;r++){let o=0;for(e=0;e<r;e++)o+=a.get(r,e)*a.get(n,e);o=(i.get(n,r)-o)/a.get(r,r),a.set(n,r,o),t+=o*o}for(t=i.get(n,n)-t,s&=t>0,a.set(n,n,Math.sqrt(Math.max(t,0))),r=n+1;r<o;r++)a.set(n,r,0)}this.L=a,this.positiveDefinite=Boolean(s)}isPositiveDefinite(){return this.positiveDefinite}solve(t){t=ag.checkMatrix(t);let e=this.L,n=e.rows;if(t.rows!==n)throw new Error("Matrix dimensions do not match");if(!1===this.isPositiveDefinite())throw new Error("Matrix is not positive definite");let r,i,o,a=t.columns,s=t.clone();for(o=0;o<n;o++)for(i=0;i<a;i++){for(r=0;r<o;r++)s.set(o,i,s.get(o,i)-s.get(r,i)*e.get(o,r));s.set(o,i,s.get(o,i)/e.get(o,o))}for(o=n-1;o>=0;o--)for(i=0;i<a;i++){for(r=o+1;r<n;r++)s.set(o,i,s.get(o,i)-s.get(r,i)*e.get(r,o));s.set(o,i,s.get(o,i)/e.get(o,o))}return s}get lowerTriangularMatrix(){return this.L}}class vg{constructor(t,e={}){t=ag.checkMatrix(t);let{Y:n}=e;const{scaleScores:r=!1,maxIterations:i=1e3,terminationCriteria:o=1e-10}=e;let a;if(n){if(n=Lp.isAnyArray(n)&&"number"==typeof n[0]?tg.columnVector(n):ag.checkMatrix(n),n.rows!==t.rows)throw new Error("Y should have the same number of rows as X");a=n.getColumnVector(0)}else a=t.getColumnVector(0);let s,u,c,h,l=1;for(let e=0;e<i&&l>o;e++)c=t.transpose().mmul(a).div(a.transpose().mmul(a).get(0,0)),c=c.div(c.norm()),s=t.mmul(c).div(c.transpose().mmul(c).get(0,0)),e>0&&(l=s.clone().sub(h).pow(2).sum()),h=s.clone(),n?(u=n.transpose().mmul(s).div(s.transpose().mmul(s).get(0,0)),u=u.div(u.norm()),a=n.mmul(u).div(u.transpose().mmul(u).get(0,0))):a=s;if(n){let e=t.transpose().mmul(s).div(s.transpose().mmul(s).get(0,0));e=e.div(e.norm());let r=t.clone().sub(s.clone().mmul(e.transpose())),i=a.transpose().mmul(s).div(s.transpose().mmul(s).get(0,0)),o=n.clone().sub(s.clone().mulS(i.get(0,0)).mmul(u.transpose()));this.t=s,this.p=e.transpose(),this.w=c.transpose(),this.q=u,this.u=a,this.s=s.transpose().mmul(s),this.xResidual=r,this.yResidual=o,this.betas=i}else this.w=c.transpose(),this.s=s.transpose().mmul(s).sqrt(),this.t=r?s.clone().div(this.s.get(0,0)):s,this.xResidual=t.sub(s.mmul(c.transpose()))}}kp.AbstractMatrix=Qp,kp.CHO=mg,kp.CholeskyDecomposition=mg,kp.DistanceMatrix=ng,kp.EVD=pg,kp.EigenvalueDecomposition=pg,kp.LU=sg,kp.LuDecomposition=sg;var yg=kp.Matrix=tg;kp.MatrixColumnSelectionView=class extends rg{constructor(t,e){Yp(t,e),super(t,t.rows,e.length),this.columnIndices=e}set(t,e,n){return this.matrix.set(t,this.columnIndices[e],n),this}get(t,e){return this.matrix.get(t,this.columnIndices[e])}},kp.MatrixColumnView=class extends rg{constructor(t,e){Up(t,e),super(t,t.rows,1),this.column=e}set(t,e,n){return this.matrix.set(t,this.column,n),this}get(t){return this.matrix.get(t,this.column)}},kp.MatrixFlipColumnView=class extends rg{constructor(t){super(t,t.rows,t.columns)}set(t,e,n){return this.matrix.set(t,this.columns-e-1,n),this}get(t,e){return this.matrix.get(t,this.columns-e-1)}},kp.MatrixFlipRowView=class extends rg{constructor(t){super(t,t.rows,t.columns)}set(t,e,n){return this.matrix.set(this.rows-t-1,e,n),this}get(t,e){return this.matrix.get(this.rows-t-1,e)}},kp.MatrixRowSelectionView=class extends rg{constructor(t,e){qp(t,e),super(t,e.length,t.columns),this.rowIndices=e}set(t,e,n){return this.matrix.set(this.rowIndices[t],e,n),this}get(t,e){return this.matrix.get(this.rowIndices[t],e)}},kp.MatrixRowView=class extends rg{constructor(t,e){Vp(t,e),super(t,1,t.columns),this.row=e}set(t,e,n){return this.matrix.set(this.row,e,n),this}get(t,e){return this.matrix.get(this.row,e)}},kp.MatrixSelectionView=ig,kp.MatrixSubView=class extends rg{constructor(t,e,n,r,i){Xp(t,e,n,r,i),super(t,n-e+1,i-r+1),this.startRow=e,this.startColumn=r}set(t,e,n){return this.matrix.set(this.startRow+t,this.startColumn+e,n),this}get(t,e){return this.matrix.get(this.startRow+t,this.startColumn+e)}},kp.MatrixTransposeView=class extends rg{constructor(t){super(t,t.columns,t.rows)}set(t,e,n){return this.matrix.set(e,t,n),this}get(t,e){return this.matrix.get(e,t)}},kp.NIPALS=vg,kp.Nipals=vg,kp.QR=cg,kp.QrDecomposition=cg,kp.SVD=hg;var Eg=kp.SingularValueDecomposition=hg;kp.SymmetricMatrix=eg,kp.WrapperMatrix1D=og,kp.WrapperMatrix2D=ag,kp.correlation=function(t,e=t,n={}){t=new tg(t);let r=!1;if("object"!=typeof e||tg.isMatrix(e)||Lp.isAnyArray(e)?e=new tg(e):(n=e,e=t,r=!0),t.rows!==e.rows)throw new TypeError("Both matrices must have the same number of rows");const{center:i=!0,scale:o=!0}=n;i&&(t.center("column"),r||e.center("column")),o&&(t.scale("column"),r||e.scale("column"));const a=t.standardDeviation("column",{unbiased:!0}),s=r?a:e.standardDeviation("column",{unbiased:!0}),u=t.transpose().mmul(e);for(let e=0;e<u.rows;e++)for(let n=0;n<u.columns;n++)u.set(e,n,u.get(e,n)*(1/(a[e]*s[n]))*(1/(t.rows-1)));return u},kp.covariance=function(t,e=t,n={}){t=new tg(t);let r=!1;if("object"!=typeof e||tg.isMatrix(e)||Lp.isAnyArray(e)?e=new tg(e):(n=e,e=t,r=!0),t.rows!==e.rows)throw new TypeError("Both matrices must have the same number of rows");const{center:i=!0}=n;i&&(t=t.center("column"),r||(e=e.center("column")));const o=t.transpose().mmul(e);for(let e=0;e<o.rows;e++)for(let n=0;n<o.columns;n++)o.set(e,n,o.get(e,n)*(1/(t.rows-1)));return o};var xg=kp.default=tg;kp.determinant=function t(e){if((e=tg.checkMatrix(e)).isSquare()){if(0===e.columns)return 1;let n,r,i,o;if(2===e.columns)return n=e.get(0,0),r=e.get(0,1),i=e.get(1,0),o=e.get(1,1),n*o-r*i;if(3===e.columns){let o,a,s;return o=new ig(e,[1,2],[1,2]),a=new ig(e,[1,2],[0,2]),s=new ig(e,[1,2],[0,1]),n=e.get(0,0),r=e.get(0,1),i=e.get(0,2),n*t(o)-r*t(a)+i*t(s)}return new sg(e).determinant}throw Error("determinant can only be calculated for a square matrix")},kp.inverse=function(t,e=!1){return t=ag.checkMatrix(t),e?new hg(t).inverse():lg(t,tg.eye(t.rows))},kp.linearDependencies=function(t,e={}){const{thresholdValue:n=1e-9,thresholdError:r=1e-9}=e;let i=(t=tg.checkMatrix(t)).rows,o=new tg(i,i);for(let e=0;e<i;e++){let a=tg.columnVector(t.getRow(e)),s=t.subMatrixRow(dg(i,e)).transpose(),u=new hg(s).solve(a),c=tg.sub(a,s.mmul(u)).abs().max();o.setRow(e,fg(c,u,e,n,r))}return o},kp.pseudoInverse=function(t,e=Number.EPSILON){if((t=tg.checkMatrix(t)).isEmpty())return t.transpose();let n=new hg(t,{autoTranspose:!0}),r=n.leftSingularVectors,i=n.rightSingularVectors,o=n.diagonal;for(let t=0;t<o.length;t++)Math.abs(o[t])>e?o[t]=1/o[t]:o[t]=0;return i.mmul(tg.diag(o).mmul(r.transpose()))},kp.solve=lg,kp.wrap=function(t,e){if(Lp.isAnyArray(t))return t[0]&&Lp.isAnyArray(t[0])?new ag(t):new og(t,e);throw new Error("the argument is not an array")};const bg=yg,wg=Eg;xg.Matrix&&xg.Matrix;var Mg={center:[0,0],linkDistance:50},Ng=function(){function t(t){void 0===t&&(t={}),this.options=t,this.id="mds",this.options=i(i({},Mg),t)}return t.prototype.execute=function(t,e){return a(this,void 0,void 0,(function(){return s(this,(function(n){return[2,this.genericMDSLayout(!1,t,e)]}))}))},t.prototype.assign=function(t,e){return a(this,void 0,void 0,(function(){return s(this,(function(n){return this.genericMDSLayout(!0,t,e),[2]}))}))},t.prototype.genericMDSLayout=function(t,e,n){return a(this,void 0,void 0,(function(){var r,o,a,u,c,h,l,d,f,p,g,m;return s(this,(function(s){return r=i(i({},this.options),n),o=r.center,a=void 0===o?[0,0]:o,u=r.linkDistance,c=void 0===u?50:u,h=e.getAllNodes(),l=e.getAllEdges(),(null==h?void 0:h.length)&&1!==h.length?(d=Uf({nodes:h,edges:l},!1),f=Vf(d),Sg(f),p=function(t,e){var n=[];return t.forEach((function(t){var r=[];t.forEach((function(t){r.push(t*e)})),n.push(r)})),n}(f,c),g=Tg(p),m=[],g.forEach((function(t,e){var n=Yf(h[e]);n.data.x=t[0]+a[0],n.data.y=t[1]+a[1],m.push(n)})),t&&m.forEach((function(t){return e.mergeNodeData(t.id,{x:t.data.x,y:t.data.y})})),[2,{nodes:m,edges:l}]):[2,Zf(e,t,a)]}))}))},t}(),Sg=function(t){var e=-999999;t.forEach((function(t){t.forEach((function(t){t!==1/0&&e<t&&(e=t)}))})),t.forEach((function(n,r){n.forEach((function(n,i){n===1/0&&(t[r][i]=e)}))}))},Tg=function(t){var e=bg.mul(bg.pow(t,2),-.5),n=e.mean("row"),r=e.mean("column"),i=e.mean();e.add(i).subRowVector(n).subColumnVector(r);var o=new wg(e),a=bg.sqrt(o.diagonalMatrix).diagonal();return o.leftSingularVectors.toJSON().map((function(t){return bg.mul([t],[a]).toJSON()[0].splice(0,2)}))};function Pg(t,e,n,r){if(isNaN(e)||isNaN(n))return t;var i,o,a,s,u,c,h,l,d,f=t._root,p={data:r},g=t._x0,m=t._y0,v=t._x1,y=t._y1;if(!f)return t._root=p,t;for(;f.length;)if((c=e>=(o=(g+v)/2))?g=o:v=o,(h=n>=(a=(m+y)/2))?m=a:y=a,i=f,!(f=f[l=h<<1|c]))return i[l]=p,t;if(s=+t._x.call(null,f.data),u=+t._y.call(null,f.data),e===s&&n===u)return p.next=f,i?i[l]=p:t._root=p,t;do{i=i?i[l]=new Array(4):t._root=new Array(4),(c=e>=(o=(g+v)/2))?g=o:v=o,(h=n>=(a=(m+y)/2))?m=a:y=a}while((l=h<<1|c)==(d=(u>=a)<<1|s>=o));return i[d]=f,i[l]=p,t}function Cg(t,e,n,r,i){this.node=t,this.x0=e,this.y0=n,this.x1=r,this.y1=i}function kg(t){return t[0]}function Ag(t){return t[1]}function Og(t,e,n){var r=new Rg(null==e?kg:e,null==n?Ag:n,NaN,NaN,NaN,NaN);return null==t?r:r.addAll(t)}function Rg(t,e,n,r,i,o){this._x=t,this._y=e,this._x0=n,this._y0=r,this._x1=i,this._y1=o,this._root=void 0}function Dg(t){for(var e={data:t.data},n=e;t=t.next;)n=n.next={data:t.data};return e}var Ig=Og.prototype=Rg.prototype;function Lg(t,e,n,r,i){if(isNaN(e)||isNaN(n)||isNaN(r))return t;var o,a,s,u,c,h,l,d,f,p,g,m,v=t._root,y={data:i},E=t._x0,x=t._y0,b=t._z0,w=t._x1,M=t._y1,N=t._z1;if(!v)return t._root=y,t;for(;v.length;)if((d=e>=(a=(E+w)/2))?E=a:w=a,(f=n>=(s=(x+M)/2))?x=s:M=s,(p=r>=(u=(b+N)/2))?b=u:N=u,o=v,!(v=v[g=p<<2|f<<1|d]))return o[g]=y,t;if(c=+t._x.call(null,v.data),h=+t._y.call(null,v.data),l=+t._z.call(null,v.data),e===c&&n===h&&r===l)return y.next=v,o?o[g]=y:t._root=y,t;do{o=o?o[g]=new Array(8):t._root=new Array(8),(d=e>=(a=(E+w)/2))?E=a:w=a,(f=n>=(s=(x+M)/2))?x=s:M=s,(p=r>=(u=(b+N)/2))?b=u:N=u}while((g=p<<2|f<<1|d)==(m=(l>=u)<<2|(h>=s)<<1|c>=a));return o[m]=v,o[g]=y,t}function _g(t,e,n,r,i,o,a){this.node=t,this.x0=e,this.y0=n,this.z0=r,this.x1=i,this.y1=o,this.z1=a}function zg(t){return t[0]}function Fg(t){return t[1]}function Bg(t){return t[2]}function Gg(t,e,n,r){var i=new jg(null==e?zg:e,null==n?Fg:n,null==r?Bg:r,NaN,NaN,NaN,NaN,NaN,NaN);return null==t?i:i.addAll(t)}function jg(t,e,n,r,i,o,a,s,u){this._x=t,this._y=e,this._z=n,this._x0=r,this._y0=i,this._z0=o,this._x1=a,this._y1=s,this._z1=u,this._root=void 0}function Vg(t){for(var e={data:t.data},n=e;t=t.next;)n=n.next={data:t.data};return e}Ig.copy=function(){var t,e,n=new Rg(this._x,this._y,this._x0,this._y0,this._x1,this._y1),r=this._root;if(!r)return n;if(!r.length)return n._root=Dg(r),n;for(t=[{source:r,target:n._root=new Array(4)}];r=t.pop();)for(var i=0;i<4;++i)(e=r.source[i])&&(e.length?t.push({source:e,target:r.target[i]=new Array(4)}):r.target[i]=Dg(e));return n},Ig.add=function(t){const e=+this._x.call(null,t),n=+this._y.call(null,t);return Pg(this.cover(e,n),e,n,t)},Ig.addAll=function(t){var e,n,r,i,o=t.length,a=new Array(o),s=new Array(o),u=1/0,c=1/0,h=-1/0,l=-1/0;for(n=0;n<o;++n)isNaN(r=+this._x.call(null,e=t[n]))||isNaN(i=+this._y.call(null,e))||(a[n]=r,s[n]=i,r<u&&(u=r),r>h&&(h=r),i<c&&(c=i),i>l&&(l=i));if(u>h||c>l)return this;for(this.cover(u,c).cover(h,l),n=0;n<o;++n)Pg(this,a[n],s[n],t[n]);return this},Ig.cover=function(t,e){if(isNaN(t=+t)||isNaN(e=+e))return this;var n=this._x0,r=this._y0,i=this._x1,o=this._y1;if(isNaN(n))i=(n=Math.floor(t))+1,o=(r=Math.floor(e))+1;else{for(var a,s,u=i-n||1,c=this._root;n>t||t>=i||r>e||e>=o;)switch(s=(e<r)<<1|t<n,(a=new Array(4))[s]=c,c=a,u*=2,s){case 0:i=n+u,o=r+u;break;case 1:n=i-u,o=r+u;break;case 2:i=n+u,r=o-u;break;case 3:n=i-u,r=o-u}this._root&&this._root.length&&(this._root=c)}return this._x0=n,this._y0=r,this._x1=i,this._y1=o,this},Ig.data=function(){var t=[];return this.visit((function(e){if(!e.length)do{t.push(e.data)}while(e=e.next)})),t},Ig.extent=function(t){return arguments.length?this.cover(+t[0][0],+t[0][1]).cover(+t[1][0],+t[1][1]):isNaN(this._x0)?void 0:[[this._x0,this._y0],[this._x1,this._y1]]},Ig.find=function(t,e,n){var r,i,o,a,s,u,c,h=this._x0,l=this._y0,d=this._x1,f=this._y1,p=[],g=this._root;for(g&&p.push(new Cg(g,h,l,d,f)),null==n?n=1/0:(h=t-n,l=e-n,d=t+n,f=e+n,n*=n);u=p.pop();)if(!(!(g=u.node)||(i=u.x0)>d||(o=u.y0)>f||(a=u.x1)<h||(s=u.y1)<l))if(g.length){var m=(i+a)/2,v=(o+s)/2;p.push(new Cg(g[3],m,v,a,s),new Cg(g[2],i,v,m,s),new Cg(g[1],m,o,a,v),new Cg(g[0],i,o,m,v)),(c=(e>=v)<<1|t>=m)&&(u=p[p.length-1],p[p.length-1]=p[p.length-1-c],p[p.length-1-c]=u)}else{var y=t-+this._x.call(null,g.data),E=e-+this._y.call(null,g.data),x=y*y+E*E;if(x<n){var b=Math.sqrt(n=x);h=t-b,l=e-b,d=t+b,f=e+b,r=g.data}}return r},Ig.remove=function(t){if(isNaN(o=+this._x.call(null,t))||isNaN(a=+this._y.call(null,t)))return this;var e,n,r,i,o,a,s,u,c,h,l,d,f=this._root,p=this._x0,g=this._y0,m=this._x1,v=this._y1;if(!f)return this;if(f.length)for(;;){if((c=o>=(s=(p+m)/2))?p=s:m=s,(h=a>=(u=(g+v)/2))?g=u:v=u,e=f,!(f=f[l=h<<1|c]))return this;if(!f.length)break;(e[l+1&3]||e[l+2&3]||e[l+3&3])&&(n=e,d=l)}for(;f.data!==t;)if(r=f,!(f=f.next))return this;return(i=f.next)&&delete f.next,r?(i?r.next=i:delete r.next,this):e?(i?e[l]=i:delete e[l],(f=e[0]||e[1]||e[2]||e[3])&&f===(e[3]||e[2]||e[1]||e[0])&&!f.length&&(n?n[d]=f:this._root=f),this):(this._root=i,this)},Ig.removeAll=function(t){for(var e=0,n=t.length;e<n;++e)this.remove(t[e]);return this},Ig.root=function(){return this._root},Ig.size=function(){var t=0;return this.visit((function(e){if(!e.length)do{++t}while(e=e.next)})),t},Ig.visit=function(t){var e,n,r,i,o,a,s=[],u=this._root;for(u&&s.push(new Cg(u,this._x0,this._y0,this._x1,this._y1));e=s.pop();)if(!t(u=e.node,r=e.x0,i=e.y0,o=e.x1,a=e.y1)&&u.length){var c=(r+o)/2,h=(i+a)/2;(n=u[3])&&s.push(new Cg(n,c,h,o,a)),(n=u[2])&&s.push(new Cg(n,r,h,c,a)),(n=u[1])&&s.push(new Cg(n,c,i,o,h)),(n=u[0])&&s.push(new Cg(n,r,i,c,h))}return this},Ig.visitAfter=function(t){var e,n=[],r=[];for(this._root&&n.push(new Cg(this._root,this._x0,this._y0,this._x1,this._y1));e=n.pop();){var i=e.node;if(i.length){var o,a=e.x0,s=e.y0,u=e.x1,c=e.y1,h=(a+u)/2,l=(s+c)/2;(o=i[0])&&n.push(new Cg(o,a,s,h,l)),(o=i[1])&&n.push(new Cg(o,h,s,u,l)),(o=i[2])&&n.push(new Cg(o,a,l,h,c)),(o=i[3])&&n.push(new Cg(o,h,l,u,c))}r.push(e)}for(;e=r.pop();)t(e.node,e.x0,e.y0,e.x1,e.y1);return this},Ig.x=function(t){return arguments.length?(this._x=t,this):this._x},Ig.y=function(t){return arguments.length?(this._y=t,this):this._y};var Ug=Gg.prototype=jg.prototype;Ug.copy=function(){var t,e,n=new jg(this._x,this._y,this._z,this._x0,this._y0,this._z0,this._x1,this._y1,this._z1),r=this._root;if(!r)return n;if(!r.length)return n._root=Vg(r),n;for(t=[{source:r,target:n._root=new Array(8)}];r=t.pop();)for(var i=0;i<8;++i)(e=r.source[i])&&(e.length?t.push({source:e,target:r.target[i]=new Array(8)}):r.target[i]=Vg(e));return n},Ug.add=function(t){const e=+this._x.call(null,t),n=+this._y.call(null,t),r=+this._z.call(null,t);return Lg(this.cover(e,n,r),e,n,r,t)},Ug.addAll=function(t){Array.isArray(t)||(t=Array.from(t));const e=t.length,n=new Float64Array(e),r=new Float64Array(e),i=new Float64Array(e);let o=1/0,a=1/0,s=1/0,u=-1/0,c=-1/0,h=-1/0;for(let l,d,f,p,g=0;g<e;++g)isNaN(d=+this._x.call(null,l=t[g]))||isNaN(f=+this._y.call(null,l))||isNaN(p=+this._z.call(null,l))||(n[g]=d,r[g]=f,i[g]=p,d<o&&(o=d),d>u&&(u=d),f<a&&(a=f),f>c&&(c=f),p<s&&(s=p),p>h&&(h=p));if(o>u||a>c||s>h)return this;this.cover(o,a,s).cover(u,c,h);for(let o=0;o<e;++o)Lg(this,n[o],r[o],i[o],t[o]);return this},Ug.cover=function(t,e,n){if(isNaN(t=+t)||isNaN(e=+e)||isNaN(n=+n))return this;var r=this._x0,i=this._y0,o=this._z0,a=this._x1,s=this._y1,u=this._z1;if(isNaN(r))a=(r=Math.floor(t))+1,s=(i=Math.floor(e))+1,u=(o=Math.floor(n))+1;else{for(var c,h,l=a-r||1,d=this._root;r>t||t>=a||i>e||e>=s||o>n||n>=u;)switch(h=(n<o)<<2|(e<i)<<1|t<r,(c=new Array(8))[h]=d,d=c,l*=2,h){case 0:a=r+l,s=i+l,u=o+l;break;case 1:r=a-l,s=i+l,u=o+l;break;case 2:a=r+l,i=s-l,u=o+l;break;case 3:r=a-l,i=s-l,u=o+l;break;case 4:a=r+l,s=i+l,o=u-l;break;case 5:r=a-l,s=i+l,o=u-l;break;case 6:a=r+l,i=s-l,o=u-l;break;case 7:r=a-l,i=s-l,o=u-l}this._root&&this._root.length&&(this._root=d)}return this._x0=r,this._y0=i,this._z0=o,this._x1=a,this._y1=s,this._z1=u,this},Ug.data=function(){var t=[];return this.visit((function(e){if(!e.length)do{t.push(e.data)}while(e=e.next)})),t},Ug.extent=function(t){return arguments.length?this.cover(+t[0][0],+t[0][1],+t[0][2]).cover(+t[1][0],+t[1][1],+t[1][2]):isNaN(this._x0)?void 0:[[this._x0,this._y0,this._z0],[this._x1,this._y1,this._z1]]},Ug.find=function(t,e,n,r){var i,o,a,s,u,c,h,l,d,f=this._x0,p=this._y0,g=this._z0,m=this._x1,v=this._y1,y=this._z1,E=[],x=this._root;for(x&&E.push(new _g(x,f,p,g,m,v,y)),null==r?r=1/0:(f=t-r,p=e-r,g=n-r,m=t+r,v=e+r,y=n+r,r*=r);l=E.pop();)if(!(!(x=l.node)||(o=l.x0)>m||(a=l.y0)>v||(s=l.z0)>y||(u=l.x1)<f||(c=l.y1)<p||(h=l.z1)<g))if(x.length){var b=(o+u)/2,w=(a+c)/2,M=(s+h)/2;E.push(new _g(x[7],b,w,M,u,c,h),new _g(x[6],o,w,M,b,c,h),new _g(x[5],b,a,M,u,w,h),new _g(x[4],o,a,M,b,w,h),new _g(x[3],b,w,s,u,c,M),new _g(x[2],o,w,s,b,c,M),new _g(x[1],b,a,s,u,w,M),new _g(x[0],o,a,s,b,w,M)),(d=(n>=M)<<2|(e>=w)<<1|t>=b)&&(l=E[E.length-1],E[E.length-1]=E[E.length-1-d],E[E.length-1-d]=l)}else{var N=t-+this._x.call(null,x.data),S=e-+this._y.call(null,x.data),T=n-+this._z.call(null,x.data),P=N*N+S*S+T*T;if(P<r){var C=Math.sqrt(r=P);f=t-C,p=e-C,g=n-C,m=t+C,v=e+C,y=n+C,i=x.data}}return i},Ug.remove=function(t){if(isNaN(o=+this._x.call(null,t))||isNaN(a=+this._y.call(null,t))||isNaN(s=+this._z.call(null,t)))return this;var e,n,r,i,o,a,s,u,c,h,l,d,f,p,g,m=this._root,v=this._x0,y=this._y0,E=this._z0,x=this._x1,b=this._y1,w=this._z1;if(!m)return this;if(m.length)for(;;){if((l=o>=(u=(v+x)/2))?v=u:x=u,(d=a>=(c=(y+b)/2))?y=c:b=c,(f=s>=(h=(E+w)/2))?E=h:w=h,e=m,!(m=m[p=f<<2|d<<1|l]))return this;if(!m.length)break;(e[p+1&7]||e[p+2&7]||e[p+3&7]||e[p+4&7]||e[p+5&7]||e[p+6&7]||e[p+7&7])&&(n=e,g=p)}for(;m.data!==t;)if(r=m,!(m=m.next))return this;return(i=m.next)&&delete m.next,r?(i?r.next=i:delete r.next,this):e?(i?e[p]=i:delete e[p],(m=e[0]||e[1]||e[2]||e[3]||e[4]||e[5]||e[6]||e[7])&&m===(e[7]||e[6]||e[5]||e[4]||e[3]||e[2]||e[1]||e[0])&&!m.length&&(n?n[g]=m:this._root=m),this):(this._root=i,this)},Ug.removeAll=function(t){for(var e=0,n=t.length;e<n;++e)this.remove(t[e]);return this},Ug.root=function(){return this._root},Ug.size=function(){var t=0;return this.visit((function(e){if(!e.length)do{++t}while(e=e.next)})),t},Ug.visit=function(t){var e,n,r,i,o,a,s,u,c=[],h=this._root;for(h&&c.push(new _g(h,this._x0,this._y0,this._z0,this._x1,this._y1,this._z1));e=c.pop();)if(!t(h=e.node,r=e.x0,i=e.y0,o=e.z0,a=e.x1,s=e.y1,u=e.z1)&&h.length){var l=(r+a)/2,d=(i+s)/2,f=(o+u)/2;(n=h[7])&&c.push(new _g(n,l,d,f,a,s,u)),(n=h[6])&&c.push(new _g(n,r,d,f,l,s,u)),(n=h[5])&&c.push(new _g(n,l,i,f,a,d,u)),(n=h[4])&&c.push(new _g(n,r,i,f,l,d,u)),(n=h[3])&&c.push(new _g(n,l,d,o,a,s,f)),(n=h[2])&&c.push(new _g(n,r,d,o,l,s,f)),(n=h[1])&&c.push(new _g(n,l,i,o,a,d,f)),(n=h[0])&&c.push(new _g(n,r,i,o,l,d,f))}return this},Ug.visitAfter=function(t){var e,n=[],r=[];for(this._root&&n.push(new _g(this._root,this._x0,this._y0,this._z0,this._x1,this._y1,this._z1));e=n.pop();){var i=e.node;if(i.length){var o,a=e.x0,s=e.y0,u=e.z0,c=e.x1,h=e.y1,l=e.z1,d=(a+c)/2,f=(s+h)/2,p=(u+l)/2;(o=i[0])&&n.push(new _g(o,a,s,u,d,f,p)),(o=i[1])&&n.push(new _g(o,d,s,u,c,f,p)),(o=i[2])&&n.push(new _g(o,a,f,u,d,h,p)),(o=i[3])&&n.push(new _g(o,d,f,u,c,h,p)),(o=i[4])&&n.push(new _g(o,a,s,p,d,f,l)),(o=i[5])&&n.push(new _g(o,d,s,p,c,f,l)),(o=i[6])&&n.push(new _g(o,a,f,p,d,h,l)),(o=i[7])&&n.push(new _g(o,d,f,p,c,h,l))}r.push(e)}for(;e=r.pop();)t(e.node,e.x0,e.y0,e.z0,e.x1,e.y1,e.z1);return this},Ug.x=function(t){return arguments.length?(this._x=t,this):this._x},Ug.y=function(t){return arguments.length?(this._y=t,this):this._y},Ug.z=function(t){return arguments.length?(this._z=t,this):this._z};function Wg(t,e,n,r,i){void 0===i&&(i=2);var o=e/n,a=t.getAllNodes(),s=a.map((function(t,e){var n=t.data,r=n.nodeStrength;return{x:n.x,y:n.y,z:n.z,size:n.size,index:e,id:t.id,vx:0,vy:0,vz:0,weight:o*r}})),u=(2===i?Og(s,(function(t){return t.x}),(function(t){return t.y})):Gg(s,(function(t){return t.x}),(function(t){return t.y}),(function(t){return t.z}))).visitAfter(Hg),c=new Map;return s.forEach((function(t){c.set(t.id,t),function(t,e,n){e.visit((function(e,r,i,o,a){return qg(e,r,i,o,a,t,n)}))}(t,u,i)})),s.map((function(t,e){var n=a[e],i=n.id,o=n.data.mass,s=void 0===o?1:o;r[i]={x:t.vx/s,y:t.vy/s,z:t.vz/s}})),r}function Hg(t){var e=0,n=0,r=0,i=0,o=0,a=t.length;if(a){for(var s=0;s<a;s++){(u=t[s])&&u.weight&&(e+=u.weight,n+=u.x*u.weight,r+=u.y*u.weight,i+=u.z*u.weight,o+=u.size*u.weight)}t.x=n/e,t.y=r/e,t.z=i/e,t.size=o/e,t.weight=e}else{var u=t;t.x=u.data.x,t.y=u.data.y,t.z=u.data.z,t.size=u.data.size,t.weight=u.data.weight}}var qg=function(t,e,n,r,i,o,a){var s;if((null===(s=t.data)||void 0===s?void 0:s.id)!==o.id){for(var u=[n,r,i][a-1],c=o.x-t.x||.1,h=o.y-t.y||.1,l=o.z-t.z||.1,d=[c,h,l],f=u-e,p=0,g=0;g<a;g++)p+=d[g]*d[g];var m=Math.sqrt(p)*p;if(f*f*.81<p){var v=t.weight/m;return o.vx+=c*v,o.vy+=h*v,o.vz+=l*v,!0}if(t.length)return!1;if(t.data!==o){v=t.data.weight/m;o.vx+=c*v,o.vy+=h*v,o.vz+=l*v}}};var Yg={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"},Xg=function(){function t(t){void 0===t&&(t={}),this.options=t,this.id="force",this.timeInterval=0,this.judgingDistance=0,this.running=!1,this.options=i(i({},Yg),t)}return t.prototype.execute=function(t,e){return a(this,void 0,void 0,(function(){return s(this,(function(n){return[2,this.genericForceLayout(!1,t,e)]}))}))},t.prototype.assign=function(t,e){return a(this,void 0,void 0,(function(){return s(this,(function(n){return this.genericForceLayout(!0,t,e),[2]}))}))},t.prototype.stop=function(){this.timeInterval&&"undefined"!=typeof window&&window.clearInterval(this.timeInterval),this.running=!1},t.prototype.tick=function(t){var e=this;if(void 0===t&&(t=this.options.maxIteration||1),this.lastResult)return this.lastResult;for(var n=0;(this.judgingDistance>this.lastOptions.minMovement||n<1)&&n<t;n++)this.runOneStep(this.lastCalcGraph,this.lastGraph,n,this.lastVelMap,this.lastOptions),this.updatePosition(this.lastGraph,this.lastCalcGraph,this.lastVelMap,this.lastOptions);var r={nodes:this.lastLayoutNodes,edges:this.lastLayoutEdges};return this.lastAssign&&r.nodes.forEach((function(t){return e.lastGraph.mergeNodeData(t.id,{x:t.data.x,y:t.data.y,z:3===e.options.dimensions?t.data.z:void 0})})),r},t.prototype.genericForceLayout=function(t,e,n){return a(this,void 0,void 0,(function(){var r,o,a,u,c,h,l,d,f,p,g,m,v,y,E,x,b,w,M,N,S=this;return s(this,(function(s){return r=i(i({},this.options),n),o=e.getAllNodes(),a=e.getAllEdges(),u=this.formatOptions(r,e),c=u.dimensions,h=u.width,l=u.height,d=u.nodeSize,f=u.getMass,p=u.nodeStrength,g=u.edgeStrength,m=u.linkDistance,v=o.map((function(t,e){return i(i({},t),{data:i(i({},t.data),{x:jt(t.data.x)?t.data.x:Math.random()*h,y:jt(t.data.y)?t.data.y:Math.random()*l,z:jt(t.data.z)?t.data.z:Math.random()*Math.sqrt(h*l),size:d(t)||30,mass:f(t),nodeStrength:p(t)})})})),y=a.map((function(t){return i(i({},t),{data:i(i({},t.data),{edgeStrength:g(t),linkDistance:m(t,e.getNode(t.source),e.getNode(t.target))})})})),(null==o?void 0:o.length)?(E={},o.forEach((function(t,e){E[t.id]={x:0,y:0,z:0}})),x=new Cp({nodes:v,edges:y}),this.formatCentripetal(u,x),b=u.maxIteration,w=u.minMovement,M=u.onTick,this.lastLayoutNodes=v,this.lastLayoutEdges=y,this.lastAssign=t,this.lastGraph=e,this.lastCalcGraph=x,this.lastOptions=u,this.lastVelMap=E,"undefined"==typeof window?[2]:(N=0,[2,new Promise((function(n){S.timeInterval=window.setInterval((function(){o&&S.running||n({nodes:Jg(e,v),edges:a}),S.runOneStep(x,e,N,E,u),S.updatePosition(e,x,E,u),t&&v.forEach((function(t){return e.mergeNodeData(t.id,{x:t.data.x,y:t.data.y,z:3===c?t.data.z:void 0})})),null==M||M({nodes:Jg(e,v),edges:a}),(++N>=b||S.judgingDistance<w)&&(window.clearInterval(S.timeInterval),n({nodes:Jg(e,v),edges:a}))}),0),S.running=!0}))])):(this.lastResult={nodes:[],edges:a},[2,{nodes:[],edges:a}])}))}))},t.prototype.formatOptions=function(t,e){var n=i({},t),r=t.width,o=t.height,a=t.getMass,s=t.nodeSize;n.width=r||"undefined"==typeof window?r:window.innerWidth,n.height=o||"undefined"==typeof window?o:window.innerHeight,t.center||(n.center=[n.width/2,n.height/2]),a||(n.getMass=function(t){var n=1;jt(null==t?void 0:t.data.mass)&&(n=null==t?void 0:t.data.mass);var r=e.getDegree(t.id,"both");return!r||r<5?n:5*r*n});var u,c=Xf(0,t.nodeSpacing);u=s?Tt(s)?function(t){return s(t)+c(t)}:jf(s)?function(t){var e=s;return Math.max(e[0],e[1])+c(t)}:function(t){return s+c(t)}:function(t){var e=((null==t?void 0:t.data)||{}).size;return e?jf(e)?Math.max(e[0],e[1])+c(t):Ot(e)?Math.max(e.width,e.height)+c(t):e+c(t):10+c(t)},n.nodeSize=u;var h=t.linkDistance?Xf(1,t.linkDistance):function(t){return 1+n.nodeSize(e.getNode(t.source))+n.nodeSize(e.getNode(t.target))};return n.linkDistance=h,n.nodeStrength=Xf(1,t.nodeStrength),n.edgeStrength=Xf(1,t.edgeStrength),n},t.prototype.formatCentripetal=function(t,e){var n,r,i=t.dimensions,o=t.centripetalOptions,a=t.center,s=t.clusterNodeStrength,u=t.leafCluster,c=t.clustering,h=t.nodeClusterBy,l=e.getAllNodes(),d=o||{leaf:2,single:2,others:1,center:function(t){return{x:a[0],y:a[1],z:3===i?a[2]:void 0}}};if("function"!=typeof s&&(t.clusterNodeStrength=function(t){return s}),u&&h&&(n=Kg(e,h),r=Array.from(new Set(null==l?void 0:l.map((function(t){return t.data[h]}))))||[],t.centripetalOptions=Object.assign(d,{single:100,leaf:function(e){var i=n[e.id]||{},o=i.siblingLeaves,a=i.sameTypeLeaves;return(null==a?void 0:a.length)===(null==o?void 0:o.length)||1===(null==r?void 0:r.length)?1:t.clusterNodeStrength(e)},others:1,center:function(t){var r,i=e.getDegree(t.id,"both");if(!i)return{x:100,y:100,z:0};if(1===i){var o=(n[t.id]||{}).sameTypeLeaves,a=void 0===o?[]:o;1===a.length?r=void 0:a.length>1&&(r=Qg(a))}else r=void 0;return{x:null==r?void 0:r.x,y:null==r?void 0:r.y,z:null==r?void 0:r.z}}})),c&&h){n||(n=Kg(e,h)),r||(r=Array.from(new Set(l.map((function(t){return t.data[h]}))))),r=r.filter((function(t){return void 0!==t}));var f={};r.forEach((function(t){var n=l.filter((function(e){return e.data[h]===t})).map((function(t){return e.getNode(t.id)}));f[t]=Qg(n)})),t.centripetalOptions=Object.assign(d,{single:function(e){return t.clusterNodeStrength(e)},leaf:function(e){return t.clusterNodeStrength(e)},others:function(e){return t.clusterNodeStrength(e)},center:function(t){var e=f[t.data[h]];return{x:null==e?void 0:e.x,y:null==e?void 0:e.y,z:null==e?void 0:e.z}}})}var p=t.centripetalOptions||{},g=p.leaf,m=p.single,v=p.others;g&&"function"!=typeof g&&(t.centripetalOptions.leaf=function(){return g}),m&&"function"!=typeof m&&(t.centripetalOptions.single=function(){return m}),v&&"function"!=typeof v&&(t.centripetalOptions.others=function(){return v})},t.prototype.runOneStep=function(t,e,n,r,i){var o={},a=t.getAllNodes(),s=t.getAllEdges();if(null==a?void 0:a.length){var u=i.monitor;if(this.calRepulsive(t,o,i),s&&this.calAttractive(t,o,i),this.calGravity(t,e,o,i),this.updateVelocity(t,o,r,i),u)u({energy:this.calTotalEnergy(o,a),nodes:e.getAllNodes(),edges:e.getAllEdges(),iterations:n})}},t.prototype.calTotalEnergy=function(t,e){var n=this;if(!(null==e?void 0:e.length))return 0;var r=0;return e.forEach((function(e,i){var o=t[e.id].x,a=t[e.id].y,s=3===n.options.dimensions?t[e.id].z:0,u=o*o+a*a+s*s,c=e.data.mass;r+=(void 0===c?1:c)*u*.5})),r},t.prototype.calRepulsive=function(t,e,n){var r=n.dimensions,i=n.factor,o=n.coulombDisScale;Wg(t,i,o*o,e,r)},t.prototype.calAttractive=function(t,e,n){var r=n.dimensions,i=n.nodeSize;t.getAllEdges().forEach((function(n,o){var a=n.source,s=n.target,u=t.getNode(a),c=t.getNode(s);if(u&&c){var h=c.data.x-u.data.x,l=c.data.y-u.data.y,d=3===r?c.data.z-u.data.z:0;h||l||(h=.01*Math.random(),l=.01*Math.random(),3!==r||d||(d=.01*Math.random()));var f=Math.sqrt(h*h+l*l+d*d);if(!(f<i(u)+i(c))){var p=h/f,g=l/f,m=d/f,v=n.data||{},y=v.linkDistance,E=void 0===y?200:y,x=v.edgeStrength,b=(E-f)*(void 0===x?200:x),w=1/(u.data.mass||1),M=1/(c.data.mass||1),N=p*b,S=g*b,T=m*b;e[a].x-=N*w,e[a].y-=S*w,e[a].z-=T*w,e[s].x+=N*M,e[s].y+=S*M,e[s].z+=T*M}}}))},t.prototype.calGravity=function(t,e,n,r){var i=r.getCenter,o=t.getAllNodes(),a=e.getAllNodes(),s=e.getAllEdges(),u=r.width,h=r.height,l=r.center,d=r.gravity,f=r.centripetalOptions;o&&o.forEach((function(r){var o=r.id,p=r.data,g=p.mass,m=p.x,v=p.y,y=p.z,E=e.getNode(o),x=0,b=0,w=0,M=d,N=t.getDegree(o,"in"),S=t.getDegree(o,"out"),T=t.getDegree(o,"both"),P=null==i?void 0:i(E,T);if(P){var C=c(P,3);x=m-C[0],b=v-C[1],M=C[2]}else x=m-l[0],b=v-l[1],w=y-l[2];if(M&&(n[o].x-=M*x/g,n[o].y-=M*b/g,n[o].z-=M*w/g),f){var k=f.leaf,A=f.single,O=f.others,R=f.center,D=(null==R?void 0:R(E,a,s,u,h))||{x:0,y:0,z:0,centerStrength:0},I=D.x,L=D.y,_=D.z,z=D.centerStrength;if(!jt(I)||!jt(L))return;var F=(m-I)/g,B=(v-L)/g,G=(y-_)/g;if(z&&(n[o].x-=z*F,n[o].y-=z*B,n[o].z-=z*G),0===T){var j=A(E);if(!j)return;return n[o].x-=j*F,n[o].y-=j*B,void(n[o].z-=j*G)}if(0===N||0===S){var V=k(E,a,s);if(!V)return;return n[o].x-=V*F,n[o].y-=V*B,void(n[o].z-=V*G)}var U=O(E);if(!U)return;n[o].x-=U*F,n[o].y-=U*B,n[o].z-=U*G}}))},t.prototype.updateVelocity=function(t,e,n,r){var i=r.damping,o=r.maxSpeed,a=r.interval,s=r.dimensions,u=t.getAllNodes();(null==u?void 0:u.length)&&u.forEach((function(t){var r=t.id,u=(n[r].x+e[r].x*a)*i||.01,c=(n[r].y+e[r].y*a)*i||.01,h=3===s?(n[r].z+e[r].z*a)*i||.01:0,l=Math.sqrt(u*u+c*c+h*h);if(l>o){var d=o/l;u*=d,c*=d,h*=d}n[r]={x:u,y:c,z:h}}))},t.prototype.updatePosition=function(t,e,n,r){var i=this,o=r.distanceThresholdMode,a=r.interval,s=r.dimensions,u=e.getAllNodes();if(null==u?void 0:u.length){var c=0;"max"===o?this.judgingDistance=-1/0:"min"===o&&(this.judgingDistance=1/0),u.forEach((function(r){var u=r.id,h=t.getNode(u);if(jt(h.data.fx)&&jt(h.data.fy))e.mergeNodeData(u,{x:h.data.fx,y:h.data.fy,z:3===s?h.data.fz:void 0});else{var l=n[u].x*a,d=n[u].y*a,f=3===s?n[u].z*a:0;e.mergeNodeData(u,{x:r.data.x+l,y:r.data.y+d,z:r.data.z+f});var p=Math.sqrt(l*l+d*d+f*f);switch(o){case"max":i.judgingDistance<p&&(i.judgingDistance=p);break;case"min":i.judgingDistance>p&&(i.judgingDistance=p);break;default:c+=p}}})),o&&"mean"!==o||(this.judgingDistance=c/u.length)}else this.judgingDistance=0},t}(),Kg=function(t,e){var n=t.getAllNodes();if(!(null==n?void 0:n.length))return{};var r={};return n.forEach((function(n,i){1===t.getDegree(n.id,"both")&&(r[n.id]=$g(t,"leaf",n,e))})),r},$g=function(t,e,n,r){var i=t.getDegree(n.id,"in"),o=t.getDegree(n.id,"out"),a=n,s=[];return 0===i?(a=t.getSuccessors(n.id)[0],s=t.getNeighbors(a.id)):0===o&&(a=t.getPredecessors(n.id)[0],s=t.getNeighbors(a.id)),s=s.filter((function(e){return 0===t.getDegree(e.id,"in")||0===t.getDegree(e.id,"out")})),{coreNode:a,siblingLeaves:s,sameTypeLeaves:Zg(t,e,r,n,s)}},Zg=function(t,e,n,r,i){var o=r.data[n]||"",a=(null==i?void 0:i.filter((function(t){return t.data[n]===o})))||[];return"leaf"===e&&(a=a.filter((function(e){return 0===t.getDegree(e.id,"in")||0===t.getDegree(e.id,"out")}))),a},Qg=function(t){var e={x:0,y:0};t.forEach((function(t){var n=t.data,r=n.x,i=n.y;e.x+=r||0,e.y+=i||0}));var n=t.length||1;return{x:e.x/n,y:e.y/n}},Jg=function(t,e){return e.map((function(e){var n=e.id,r=e.data,o=t.getNode(n);return i(i({},o),{data:i(i({},o.data),{x:r.x,y:r.y,z:r.z})})}))},tm={nodeSize:30,nodeSpacing:10,preventOverlap:!1,sweep:void 0,equidistant:!1,startAngle:1.5*Math.PI,clockwise:!0,maxLevelDiff:void 0,sortBy:"degree"},em=function(){function t(t){void 0===t&&(t={}),this.options=t,this.id="concentric",this.options=i(i({},tm),t)}return t.prototype.execute=function(t,e){return a(this,void 0,void 0,(function(){return s(this,(function(n){return[2,this.genericConcentricLayout(!1,t,e)]}))}))},t.prototype.assign=function(t,e){return a(this,void 0,void 0,(function(){return s(this,(function(n){return this.genericConcentricLayout(!0,t,e),[2]}))}))},t.prototype.genericConcentricLayout=function(t,e,n){return a(this,void 0,void 0,(function(){var r,o,a,u,c,h,l,d,f,p,g,m,v,y,E,x,b,w,M,N,S,T,P,C,k,A,O,R,D,I,L,_,z,F,B,G,j,V;return s(this,(function(s){if(r=i(i({},this.options),n),o=r.center,a=r.width,u=r.height,c=r.sortBy,h=r.maxLevelDiff,l=r.sweep,d=r.clockwise,f=r.equidistant,p=r.preventOverlap,g=r.startAngle,m=void 0===g?1.5*Math.PI:g,v=r.nodeSize,y=r.nodeSpacing,E=e.getAllNodes(),x=e.getAllEdges(),b=a||"undefined"==typeof window?a:window.innerWidth,w=u||"undefined"==typeof window?u:window.innerHeight,M=o||[b/2,w/2],!(null==E?void 0:E.length)||1===E.length)return[2,Zf(e,t,M)];if(N=[],T=0,jf(v)?S=Math.max(v[0],v[1]):Tt(v)?(S=-1/0,E.forEach((function(t){var e=v(t);e>S&&(S=e)}))):S=v,jf(y)?T=Math.max(y[0],y[1]):jt(y)&&(T=y),E.forEach((function(t){var e=Yf(t);N.push(e);var n=S,r=e.data;jf(r.size)?n=Math.max(r.size[0],r.size[1]):jt(r.size)?n=r.size:Ot(r.size)&&(n=Math.max(r.size.width,r.size.height)),S=Math.max(S,n),Tt(y)&&(T=Math.max(y(t),T))})),P={},N.forEach((function(t,e){P[t.id]=e})),zt(C=c)&&void 0!==N[0].data[C]||(C="degree"),"degree"===C?N.sort((function(t,n){return e.getDegree(n.id,"both")-e.getDegree(t.id,"both")})):N.sort((function(t,e){return e.data[C]-t.data[C]})),k=N[0],A=(h||("degree"===C?e.getDegree(k.id,"both"):k.data[C]))/4,R=(O=[{nodes:[]}])[0],N.forEach((function(t){if(R.nodes.length>0){var n="degree"===C?Math.abs(e.getDegree(R.nodes[0].id,"both")-e.getDegree(t.id,"both")):Math.abs(R.nodes[0].data[C]-t.data[C]);A&&n>=A&&(R={nodes:[]},O.push(R))}R.nodes.push(t)})),D=S+T,p||(I=O.length>0&&O[0].nodes.length>1,L=Math.min(b,w)/2-D,_=L/(O.length+(I?1:0)),D=Math.min(D,_)),z=0,O.forEach((function(t){var e=void 0===l?2*Math.PI-2*Math.PI/t.nodes.length:l;if(t.dTheta=e/Math.max(1,t.nodes.length-1),t.nodes.length>1&&p){var n=Math.cos(t.dTheta)-Math.cos(0),r=Math.sin(t.dTheta)-Math.sin(0),i=Math.sqrt(D*D/(n*n+r*r));z=Math.max(i,z)}t.r=z,z+=D})),f){for(F=0,B=0,G=0;G<O.length;G++)j=O[G],V=(j.r||0)-B,F=Math.max(F,V);B=0,O.forEach((function(t,e){0===e&&(B=t.r||0),t.r=B,B+=F}))}return O.forEach((function(t){var e=t.dTheta||0,n=t.r||0;t.nodes.forEach((function(t,r){var i=m+(d?1:-1)*e*r;t.data.x=M[0]+n*Math.cos(i),t.data.y=M[1]+n*Math.sin(i)}))})),t&&N.forEach((function(t){return e.mergeNodeData(t.id,{x:t.data.x,y:t.data.y})})),[2,{nodes:N,edges:x}]}))}))},t}(),nm={gForce:!0,force2:!0,d3force:!0,fruchterman:!0,forceAtlas2:!0,force:!0,"graphin-force":!0},rm={center:[0,0],comboPadding:10,treeKey:"combo"},im=function(){function t(t){void 0===t&&(t={}),this.options=t,this.id="comboCombined",this.options=i(i({},rm),t)}return t.prototype.execute=function(t,e){return a(this,void 0,void 0,(function(){return s(this,(function(n){return[2,this.genericComboCombinedLayout(!1,t,e)]}))}))},t.prototype.assign=function(t,e){return a(this,void 0,void 0,(function(){return s(this,(function(n){switch(n.label){case 0:return[4,this.genericComboCombinedLayout(!0,t,e)];case 1:return n.sent(),[2]}}))}))},t.prototype.genericComboCombinedLayout=function(t,e,n){return a(this,void 0,void 0,(function(){var r,o,a,u,l,d,f,p,g,m,v,y,E,x,b,w,M,N,S,T,P;return s(this,(function(s){switch(s.label){case 0:return r=this.initVals(i(i({},this.options),n)),o=r.center,a=r.treeKey,u=r.outerLayout,l=e.getAllNodes().filter((function(t){return!t.data._isCombo})),d=e.getAllNodes().filter((function(t){return t.data._isCombo})),f=e.getAllEdges(),(p=null==l?void 0:l.length)&&1!==p?(g=[],m=new Map,l.forEach((function(t){m.set(t.id,t)})),v=new Map,d.forEach((function(t){v.set(t.id,t)})),y=new Map,E=this.getInnerGraphs(e,a,m,v,f,r,y),[4,Promise.all(E)]):[2,Zf(e,t,o)];case 1:return s.sent(),x=new Map,b=[],w=new Map,M=!0,e.getRoots(a).forEach((function(t){var n=y.get(t.id),r=v.get(t.id)||m.get(t.id),o={id:t.id,data:i(i({},t.data),{x:n.data.x||r.data.x,y:n.data.y||r.data.y,fx:n.data.fx||r.data.fx,fy:n.data.fy||r.data.fy,mass:n.data.mass||r.data.mass,size:n.data.size})};b.push(o),x.set(t.id,!0),isNaN(o.data.x)||0===o.data.x||isNaN(o.data.y)||0===o.data.y?(o.data.x=100*Math.random(),o.data.y=100*Math.random()):M=!1,Hf(e,[t],(function(e){e.id!==t.id&&w.set(e.id,t.id)}),"TB",a)})),N=[],f.forEach((function(t){var e=w.get(t.source)||t.source,n=w.get(t.target)||t.target;e!==n&&x.has(e)&&x.has(n)&&N.push({id:t.id,source:e,target:n,data:{}})})),(null==b?void 0:b.length)?1!==b.length?[3,2]:(b[0].data.x=o[0],b[0].data.y=o[1],[3,6]):[3,7];case 2:return T=new Cp({nodes:b,edges:N}),P=u||new Xg,M&&nm[P.id]?[4,(b.length<100?new Ng:new em).assign(T)]:[3,4];case 3:s.sent(),s.label=4;case 4:return[4,P.execute(T,i({center:o,kg:5,preventOverlap:!0,animate:!1},"force"===P.id?{gravity:1,factor:4,linkDistance:function(t,e,n){return(Math.max.apply(Math,h([],c(e.data.size)))||32)/2+(Math.max.apply(Math,h([],c(n.data.size)))||32)/2+200}}:{}))];case 5:S=s.sent(),s.label=6;case 6:y.forEach((function(t){var e,n=S.nodes.find((function(e){return e.id===t.id}));if(n){var r=n.data,i=r.x,o=r.y;t.data.visited=!0,t.data.x=i,t.data.y=o,g.push({id:t.id,data:{x:i,y:o}})}var a=t.data,s=a.x,u=a.y;null===(e=t.data.nodes)||void 0===e||e.forEach((function(t){g.push({id:t.id,data:{x:t.data.x+s,y:t.data.y+u}})}))})),y.forEach((function(t){var e,n=t.data,r=n.x,i=n.y,o=n.visited;null===(e=n.nodes)||void 0===e||e.forEach((function(t){if(!o){var e=g.find((function(e){return e.id===t.id}));e.data.x+=r||0,e.data.y+=i||0}}))})),s.label=7;case 7:return t&&g.forEach((function(t){e.mergeNodeData(t.id,{x:t.data.x,y:t.data.y})})),[2,{nodes:g,edges:f}]}}))}))},t.prototype.initVals=function(t){var e,n,r,o=i({},t),a=t.nodeSize,s=t.spacing,u=t.comboPadding;if(n=jt(s)?function(){return s}:Tt(s)?s:function(){return 0},o.spacing=n,a)if(Tt(a))e=function(t){var e=a(t),r=n(t);return jf(t.size)?((t.size[0]>t.size[1]?t.size[0]:t.size[1])+r)/2:((e||32)+r)/2};else if(jf(a)){var c=(a[0]>a[1]?a[0]:a[1])/2;e=function(t){return c+n(t)/2}}else{var h=a/2;e=function(t){return h+n(t)/2}}else e=function(t){var e=n(t);return t.size?jf(t.size)?((t.size[0]>t.size[1]?t.size[0]:t.size[1])+e)/2:Ot(t.size)?((t.size.width>t.size.height?t.size.width:t.size.height)+e)/2:(t.size+e)/2:32+e/2};return o.nodeSize=e,r=jt(u)?function(){return u}:jf(u)?function(){return Math.max.apply(null,u)}:Tt(u)?u:function(){return 0},o.comboPadding=r,o},t.prototype.getInnerGraphs=function(t,e,n,r,o,u,l){var d=this,f=u.nodeSize,p=u.comboPadding,g=u.spacing,m=u.innerLayout||new em({}),v={center:[0,0],preventOverlap:!0,nodeSpacing:g},y=[],E=function(t){var e=(null==p?void 0:p(t))||10;return jf(e)&&(e=Math.max.apply(Math,h([],c(e)))),{size:e?[2*e,2*e]:[30,30],padding:e}};return t.getRoots(e).forEach((function(u){l.set(u.id,{id:u.id,data:{nodes:[],size:E(u).size}});var h=Promise.resolve();Hf(t,[u],(function(u){var p;if(u.data._isCombo){var g=E(u),y=g.size,x=g.padding;if(null===(p=t.getChildren(u.id,e))||void 0===p?void 0:p.length){var b=l.get(u.id);l.set(u.id,{id:u.id,data:i({nodes:[]},null==b?void 0:b.data)});var w=new Map,M=t.getChildren(u.id,e).map((function(t){if(t.data._isCombo)return l.has(t.id)||l.set(t.id,{id:t.id,data:i({},t.data)}),w.set(t.id,!0),l.get(t.id);var e=n.get(t.id)||r.get(t.id);return w.set(t.id,!0),{id:t.id,data:i(i({},e.data),t.data)}})),N={nodes:M,edges:o.filter((function(t){return w.has(t.source)&&w.has(t.target)}))},S=1/0;M.forEach((function(t){var e,n,r=t.data.size;r||(r=(null===(e=l.get(t.id))||void 0===e?void 0:e.data.size)||(null===(n=f)||void 0===n?void 0:n(t))||[30,30]),jt(r)&&(r=[r,r]);var i=c(r,2),o=i[0],a=i[1];S>o&&(S=o),S>a&&(S=a),t.data.size=r})),h=h.then((function(){return a(d,void 0,void 0,(function(){var t,e,n,r,i,o,a,c,h;return s(this,(function(s){switch(s.label){case 0:return t=new Cp(N),[4,m.assign(t,v)];case 1:return e=s.sent(),n=function(t){var e=1/0,n=1/0,r=-1/0,i=-1/0;return t.forEach((function(t){var o=t.data.size;jf(o)?1===o.length&&(o=[o[0],o[0]]):jt(o)?o=[o,o]:(void 0===o||isNaN(o))&&(o=[30,30]);var a=[o[0]/2,o[1]/2],s=t.data.x-a[0],u=t.data.x+a[0],c=t.data.y-a[1],h=t.data.y+a[1];e>s&&(e=s),n>c&&(n=c),r<u&&(r=u),i<h&&(i=h)})),{minX:e,minY:n,maxX:r,maxY:i}}(M),r=n.minX,i=n.minY,o=n.maxX,a=n.maxY,c={x:(o+r)/2,y:(a+i)/2},N.nodes.forEach((function(t){t.data.x-=c.x,t.data.y-=c.y})),h=[Math.max(o-r,S)+2*x,Math.max(a-i,S)+2*x],l.get(u.id).data.size=h,l.get(u.id).data.nodes=M,[2,e]}}))}))}))}else l.set(u.id,{id:u.id,data:i(i({},u.data),{size:y})});return!0}}),"BT",e),y.push(h)})),y},t}();function om(t){return function(){return t}}function am(t){return 1e-6*(t()-.5)}function sm(t){return t.x+t.vx}function um(t){return t.y+t.vy}function cm(t){var e,n,r,i=1,o=1;function a(){for(var t,a,u,c,h,l,d,f=e.length,p=0;p<o;++p)for(a=Og(e,sm,um).visitAfter(s),t=0;t<f;++t)u=e[t],l=n[u.index],d=l*l,c=u.x+u.vx,h=u.y+u.vy,a.visit(g);function g(t,e,n,o,a){var s=t.data,f=t.r,p=l+f;if(!s)return e>c+p||o<c-p||n>h+p||a<h-p;if(s.index>u.index){var g=c-s.x-s.vx,m=h-s.y-s.vy,v=g*g+m*m;v<p*p&&(0===g&&(v+=(g=am(r))*g),0===m&&(v+=(m=am(r))*m),v=(p-(v=Math.sqrt(v)))/v*i,u.vx+=(g*=v)*(p=(f*=f)/(d+f)),u.vy+=(m*=v)*p,s.vx-=g*(p=1-p),s.vy-=m*p)}}}function s(t){if(t.data)return t.r=n[t.data.index];for(var e=t.r=0;e<4;++e)t[e]&&t[e].r>t.r&&(t.r=t[e].r)}function u(){if(e){var r,i,o=e.length;for(n=new Array(o),r=0;r<o;++r)i=e[r],n[i.index]=+t(i,r,e)}}return"function"!=typeof t&&(t=om(null==t?1:+t)),a.initialize=function(t,n){e=t,r=n,u()},a.iterations=function(t){return arguments.length?(o=+t,a):o},a.strength=function(t){return arguments.length?(i=+t,a):i},a.radius=function(e){return arguments.length?(t="function"==typeof e?e:om(+e),u(),a):t},a}function hm(t){return t.index}function lm(t,e){var n=t.get(e);if(!n)throw new Error("node not found: "+e);return n}function dm(t){var e,n,r,i,o,a,s=hm,u=function(t){return 1/Math.min(i[t.source.index],i[t.target.index])},c=om(30),h=1;function l(r){for(var i=0,s=t.length;i<h;++i)for(var u,c,l,d,f,p,g,m=0;m<s;++m)c=(u=t[m]).source,d=(l=u.target).x+l.vx-c.x-c.vx||am(a),f=l.y+l.vy-c.y-c.vy||am(a),d*=p=((p=Math.sqrt(d*d+f*f))-n[m])/p*r*e[m],f*=p,l.vx-=d*(g=o[m]),l.vy-=f*g,c.vx+=d*(g=1-g),c.vy+=f*g}function d(){if(r){var a,u,c=r.length,h=t.length,l=new Map(r.map(((t,e)=>[s(t,e,r),t])));for(a=0,i=new Array(c);a<h;++a)(u=t[a]).index=a,"object"!=typeof u.source&&(u.source=lm(l,u.source)),"object"!=typeof u.target&&(u.target=lm(l,u.target)),i[u.source.index]=(i[u.source.index]||0)+1,i[u.target.index]=(i[u.target.index]||0)+1;for(a=0,o=new Array(h);a<h;++a)u=t[a],o[a]=i[u.source.index]/(i[u.source.index]+i[u.target.index]);e=new Array(h),f(),n=new Array(h),p()}}function f(){if(r)for(var n=0,i=t.length;n<i;++n)e[n]=+u(t[n],n,t)}function p(){if(r)for(var e=0,i=t.length;e<i;++e)n[e]=+c(t[e],e,t)}return null==t&&(t=[]),l.initialize=function(t,e){r=t,a=e,d()},l.links=function(e){return arguments.length?(t=e,d(),l):t},l.id=function(t){return arguments.length?(s=t,l):s},l.iterations=function(t){return arguments.length?(h=+t,l):h},l.strength=function(t){return arguments.length?(u="function"==typeof t?t:om(+t),f(),l):u},l.distance=function(t){return arguments.length?(c="function"==typeof t?t:om(+t),p(),l):c},l}var fm={value:()=>{}};function pm(){for(var t,e=0,n=arguments.length,r={};e<n;++e){if(!(t=arguments[e]+"")||t in r||/[\s.]/.test(t))throw new Error("illegal type: "+t);r[t]=[]}return new gm(r)}function gm(t){this._=t}function mm(t,e){for(var n,r=0,i=t.length;r<i;++r)if((n=t[r]).name===e)return n.value}function vm(t,e,n){for(var r=0,i=t.length;r<i;++r)if(t[r].name===e){t[r]=fm,t=t.slice(0,r).concat(t.slice(r+1));break}return null!=n&&t.push({name:e,value:n}),t}gm.prototype=pm.prototype={constructor:gm,on:function(t,e){var n,r,i=this._,o=(r=i,(t+"").trim().split(/^|\s+/).map((function(t){var e="",n=t.indexOf(".");if(n>=0&&(e=t.slice(n+1),t=t.slice(0,n)),t&&!r.hasOwnProperty(t))throw new Error("unknown type: "+t);return{type:t,name:e}}))),a=-1,s=o.length;if(!(arguments.length<2)){if(null!=e&&"function"!=typeof e)throw new Error("invalid callback: "+e);for(;++a<s;)if(n=(t=o[a]).type)i[n]=vm(i[n],t.name,e);else if(null==e)for(n in i)i[n]=vm(i[n],t.name,null);return this}for(;++a<s;)if((n=(t=o[a]).type)&&(n=mm(i[n],t.name)))return n},copy:function(){var t={},e=this._;for(var n in e)t[n]=e[n].slice();return new gm(t)},call:function(t,e){if((n=arguments.length-2)>0)for(var n,r,i=new Array(n),o=0;o<n;++o)i[o]=arguments[o+2];if(!this._.hasOwnProperty(t))throw new Error("unknown type: "+t);for(o=0,n=(r=this._[t]).length;o<n;++o)r[o].value.apply(e,i)},apply:function(t,e,n){if(!this._.hasOwnProperty(t))throw new Error("unknown type: "+t);for(var r=this._[t],i=0,o=r.length;i<o;++i)r[i].value.apply(e,n)}};var ym,Em,xm=0,bm=0,wm=0,Mm=1e3,Nm=0,Sm=0,Tm=0,Pm="object"==typeof performance&&performance.now?performance:Date,Cm="object"==typeof window&&window.requestAnimationFrame?window.requestAnimationFrame.bind(window):function(t){setTimeout(t,17)};function km(){return Sm||(Cm(Am),Sm=Pm.now()+Tm)}function Am(){Sm=0}function Om(){this._call=this._time=this._next=null}function Rm(t,e,n){var r=new Om;return r.restart(t,e,n),r}function Dm(){Sm=(Nm=Pm.now())+Tm,xm=bm=0;try{!function(){km(),++xm;for(var t,e=ym;e;)(t=Sm-e._time)>=0&&e._call.call(void 0,t),e=e._next;--xm}()}finally{xm=0,function(){var t,e,n=ym,r=1/0;for(;n;)n._call?(r>n._time&&(r=n._time),t=n,n=n._next):(e=n._next,n._next=null,n=t?t._next=e:ym=e);Em=t,Lm(r)}(),Sm=0}}function Im(){var t=Pm.now(),e=t-Nm;e>Mm&&(Tm-=e,Nm=t)}function Lm(t){xm||(bm&&(bm=clearTimeout(bm)),t-Sm>24?(t<1/0&&(bm=setTimeout(Dm,t-Pm.now()-Tm)),wm&&(wm=clearInterval(wm))):(wm||(Nm=Pm.now(),wm=setInterval(Im,Mm)),xm=1,Cm(Dm)))}Om.prototype=Rm.prototype={constructor:Om,restart:function(t,e,n){if("function"!=typeof t)throw new TypeError("callback is not a function");n=(null==n?km():+n)+(null==e?0:+e),this._next||Em===this||(Em?Em._next=this:ym=this,Em=this),this._call=t,this._time=n,Lm()},stop:function(){this._call&&(this._call=null,this._time=1/0,Lm())}};const _m=1664525,zm=1013904223,Fm=4294967296;function Bm(t){return t.x}function Gm(t){return t.y}var jm=10,Vm=Math.PI*(3-Math.sqrt(5));function Um(t){var e,n=1,r=.001,i=1-Math.pow(r,1/300),o=0,a=.6,s=new Map,u=Rm(l),c=pm("tick","end"),h=function(){let t=1;return()=>(t=(_m*t+zm)%Fm)/Fm}();function l(){d(),c.call("tick",e),n<r&&(u.stop(),c.call("end",e))}function d(r){var u,c,h=t.length;void 0===r&&(r=1);for(var l=0;l<r;++l)for(n+=(o-n)*i,s.forEach((function(t){t(n)})),u=0;u<h;++u)null==(c=t[u]).fx?c.x+=c.vx*=a:(c.x=c.fx,c.vx=0),null==c.fy?c.y+=c.vy*=a:(c.y=c.fy,c.vy=0);return e}function f(){for(var e,n=0,r=t.length;n<r;++n){if((e=t[n]).index=n,null!=e.fx&&(e.x=e.fx),null!=e.fy&&(e.y=e.fy),isNaN(e.x)||isNaN(e.y)){var i=jm*Math.sqrt(.5+n),o=n*Vm;e.x=i*Math.cos(o),e.y=i*Math.sin(o)}(isNaN(e.vx)||isNaN(e.vy))&&(e.vx=e.vy=0)}}function p(e){return e.initialize&&e.initialize(t,h),e}return null==t&&(t=[]),f(),e={tick:d,restart:function(){return u.restart(l),e},stop:function(){return u.stop(),e},nodes:function(n){return arguments.length?(t=n,f(),s.forEach(p),e):t},alpha:function(t){return arguments.length?(n=+t,e):n},alphaMin:function(t){return arguments.length?(r=+t,e):r},alphaDecay:function(t){return arguments.length?(i=+t,e):+i},alphaTarget:function(t){return arguments.length?(o=+t,e):o},velocityDecay:function(t){return arguments.length?(a=1-t,e):1-a},randomSource:function(t){return arguments.length?(h=t,s.forEach(p),e):h},force:function(t,n){return arguments.length>1?(null==n?s.delete(t):s.set(t,p(n)),e):s.get(t)},find:function(e,n,r){var i,o,a,s,u,c=0,h=t.length;for(null==r?r=1/0:r*=r,c=0;c<h;++c)(a=(i=e-(s=t[c]).x)*i+(o=n-s.y)*o)<r&&(u=s,r=a);return u},on:function(t,n){return arguments.length>1?(c.on(t,n),e):c.on(t)}}}function Wm(){var t,e,n,r,i,o=om(-30),a=1,s=1/0,u=.81;function c(n){var i,o=t.length,a=Og(t,Bm,Gm).visitAfter(l);for(r=n,i=0;i<o;++i)e=t[i],a.visit(d)}function h(){if(t){var e,n,r=t.length;for(i=new Array(r),e=0;e<r;++e)n=t[e],i[n.index]=+o(n,e,t)}}function l(t){var e,n,r,o,a,s=0,u=0;if(t.length){for(r=o=a=0;a<4;++a)(e=t[a])&&(n=Math.abs(e.value))&&(s+=e.value,u+=n,r+=n*e.x,o+=n*e.y);t.x=r/u,t.y=o/u}else{(e=t).x=e.data.x,e.y=e.data.y;do{s+=i[e.data.index]}while(e=e.next)}t.value=s}function d(t,o,c,h){if(!t.value)return!0;var l=t.x-e.x,d=t.y-e.y,f=h-o,p=l*l+d*d;if(f*f/u<p)return p<s&&(0===l&&(p+=(l=am(n))*l),0===d&&(p+=(d=am(n))*d),p<a&&(p=Math.sqrt(a*p)),e.vx+=l*t.value*r/p,e.vy+=d*t.value*r/p),!0;if(!(t.length||p>=s)){(t.data!==e||t.next)&&(0===l&&(p+=(l=am(n))*l),0===d&&(p+=(d=am(n))*d),p<a&&(p=Math.sqrt(a*p)));do{t.data!==e&&(f=i[t.data.index]*r/p,e.vx+=l*f,e.vy+=d*f)}while(t=t.next)}}return c.initialize=function(e,r){t=e,n=r,h()},c.strength=function(t){return arguments.length?(o="function"==typeof t?t:om(+t),h(),c):o},c.distanceMin=function(t){return arguments.length?(a=t*t,c):Math.sqrt(a)},c.distanceMax=function(t){return arguments.length?(s=t*t,c):Math.sqrt(s)},c.theta=function(t){return arguments.length?(u=t*t,c):Math.sqrt(u)},c}function Hm(t){var e,n,r,i=om(.1);function o(t){for(var i,o=0,a=e.length;o<a;++o)(i=e[o]).vx+=(r[o]-i.x)*n[o]*t}function a(){if(e){var o,a=e.length;for(n=new Array(a),r=new Array(a),o=0;o<a;++o)n[o]=isNaN(r[o]=+t(e[o],o,e))?0:+i(e[o],o,e)}}return"function"!=typeof t&&(t=om(null==t?0:+t)),o.initialize=function(t){e=t,a()},o.strength=function(t){return arguments.length?(i="function"==typeof t?t:om(+t),a(),o):i},o.x=function(e){return arguments.length?(t="function"==typeof e?e:om(+e),a(),o):t},o}function qm(t){var e,n,r,i=om(.1);function o(t){for(var i,o=0,a=e.length;o<a;++o)(i=e[o]).vy+=(r[o]-i.y)*n[o]*t}function a(){if(e){var o,a=e.length;for(n=new Array(a),r=new Array(a),o=0;o<a;++o)n[o]=isNaN(r[o]=+t(e[o],o,e))?0:+i(e[o],o,e)}}return"function"!=typeof t&&(t=om(null==t?0:+t)),o.initialize=function(t){e=t,a()},o.strength=function(t){return arguments.length?(i="function"==typeof t?t:om(+t),a(),o):i},o.y=function(e){return arguments.length?(t="function"==typeof e?e:om(+e),a(),o):t},o}function Ym(){function t(t){return function(){return t}}var e,n=function(t){return t.cluster},r=t(1),i=t(-1),o=t(100),a=t(.1),s=[0,0],u=[],h={},l=[],d=100,f=100,p={none:{x:0,y:0}},g=[],m="force",v=!0,y=.1;function E(t){if(!v)return E;e.tick(),b();for(var r=0,i=u.length,o=void 0,a=t*y;r<i;++r)(o=u[r]).vx+=(p[n(o)].x-o.x)*a,o.vy+=(p[n(o)].y-o.y)*a}function x(){u&&function(){if(!u||!u.length)return;if(void 0===n(u[0]))throw Error("Couldnt find the grouping attribute for the nodes. Make sure to set it up with forceInBox.groupBy('clusterAttr') before calling .links()");var t=(s=[],p=[],m={},v={},y=[],v=function(t){var e={};return t.forEach((function(t){var r=n(t);e[r]||(e[r]={count:0,sumforceNodeSize:0})})),t.forEach((function(t){var i=n(t),o=r(t),a=e[i];a.count=a.count+1,a.sumforceNodeSize=a.sumforceNodeSize+Math.PI*(o*o)*1.3,e[i]=a})),e}(u),y=function(t){var e={},r=[];return t.forEach((function(t){var r=function(t){var e=t.source,r=t.target,i=n(h[e]),o=n(h[r]);return i<=o?i+"~"+o:o+"~"+i}(t),i=0;void 0!==e[r]&&(i=e[r]),i+=1,e[r]=i})),Object.entries(e).forEach((function(t){var e=c(t,2),n=e[0],i=e[1],o=n.split("~")[0],a=n.split("~")[1];void 0!==o&&void 0!==a&&r.push({source:o,target:a,count:i})})),r}(l),Object.keys(v).forEach((function(t,e){var n=v[t];s.push({id:t,size:n.count,r:Math.sqrt(n.sumforceNodeSize/Math.PI)}),m[t]=e})),y.forEach((function(t){var e=t.source,n=t.target,r=m[e],i=m[n];void 0!==r&&void 0!==i&&p.push({source:r,target:i,count:t.count})})),{nodes:s,links:p});var s,p,m,v,y;e=Um(t.nodes).force("x",Hm(d).strength(.1)).force("y",qm(f).strength(.1)).force("collide",cm((function(t){return t.r})).iterations(4)).force("charge",Wm().strength(i)).force("links",dm(t.nodes.length?t.links:[]).distance(o).strength(a)),g=e.nodes(),b()}()}function b(){return p={none:{x:0,y:0}},g.forEach((function(t){p[t.id]={x:t.x-s[0],y:t.y-s[1]}})),p}return E.initialize=function(t){u=t,x()},E.template=function(t){return arguments.length?(m=t,x(),E):m},E.groupBy=function(t){return arguments.length?"string"==typeof t?(n=function(e){return e[t]},E):(n=t,E):n},E.enableGrouping=function(t){return arguments.length?(v=t,E):v},E.strength=function(t){return arguments.length?(y=t,E):y},E.centerX=function(t){return arguments.length?(d=t,E):d},E.centerY=function(t){return arguments.length?(f=t,E):f},E.nodes=function(t){return arguments.length?(function(t){h={},t.forEach((function(t){h[t.id]=t}))}(t||[]),u=t||[],E):u},E.links=function(t){return arguments.length?(l=t||[],x(),E):l},E.forceNodeSize=function(e){return arguments.length?(r="function"==typeof e?e:t(+e),x(),E):r},E.nodeSize=E.forceNodeSize,E.forceCharge=function(e){return arguments.length?(i="function"==typeof e?e:t(+e),x(),E):i},E.forceLinkDistance=function(e){return arguments.length?(o="function"==typeof e?e:t(+e),x(),E):o},E.forceLinkStrength=function(e){return arguments.length?(a="function"==typeof e?e:t(+e),x(),E):a},E.offset=function(t){return arguments.length?(s=t,E):s},E.getFocis=b,E}var Xm={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},Km=function(){function t(t){void 0===t&&(t={}),this.options=t,this.id="d3force",this.options=i(i({},Xm),t)}return t.prototype.execute=function(t,e){return a(this,void 0,void 0,(function(){return s(this,(function(n){return[2,this.genericForceLayout(!1,t,e)]}))}))},t.prototype.assign=function(t,e){return a(this,void 0,void 0,(function(){return s(this,(function(n){return this.genericForceLayout(!0,t,e),[2]}))}))},t.prototype.stop=function(){var t;null===(t=this.forceSimulation)||void 0===t||t.stop()},t.prototype.tick=function(t){var e=this;void 0===t&&(t=1),this.forceSimulation.tick(t);var n={nodes:$m(this.lastLayoutNodes),edges:Zm(this.lastLayoutEdges)};return this.lastAssign&&n.nodes.forEach((function(t){return e.lastGraph.mergeNodeData(t.id,{x:t.data.x,y:t.data.y})})),n},t.prototype.genericForceLayout=function(t,e,n){return a(this,void 0,void 0,(function(){var r,o,a,u,c,h,l,d,f,p,g,m,v,y,E,x,b,w,M,N,S,T,P,C,k,A,O=this;return s(this,(function(s){return r=i(i({},this.options),n),o=e.getAllNodes(),a=e.getAllEdges(),u=o.map((function(t){var e,n;return i(i({},Yf(t)),{x:null===(e=t.data)||void 0===e?void 0:e.x,y:null===(n=t.data)||void 0===n?void 0:n.y})})),c=a.map((function(t){return Yf(t)})),this.lastLayoutNodes=u,this.lastLayoutEdges=c,this.lastAssign=t,this.lastGraph=e,h=r.alphaMin,l=r.alphaDecay,d=r.alpha,f=r.nodeStrength,p=r.edgeStrength,g=r.linkDistance,m=r.clustering,v=r.clusterFociStrength,y=r.clusterEdgeDistance,E=r.clusterEdgeStrength,x=r.clusterNodeStrength,b=r.clusterNodeSize,w=r.collideStrength,M=void 0===w?1:w,N=r.center,S=void 0===N?[0,0]:N,T=r.preventOverlap,P=r.nodeSize,C=r.nodeSpacing,k=r.onTick,A=r.forceSimulation,[2,new Promise((function(n){if(A){if(m)(o=Ym()).nodes(u),o.links(c);if(A.nodes(u),c){s=dm().id((function(t){return t.id})).links(c);p&&s.strength(p),g&&s.distance(g),A.force("link",s)}T&&O.overlapProcess(A,{nodeSize:P,nodeSpacing:C,collideStrength:M}),A.alpha(d).restart();var r=$m(u),i=Zm(c);t&&r.forEach((function(t){return e.mergeNodeData(t.id,{x:t.data.x,y:t.data.y})})),n({nodes:r,edges:i})}else try{var o,a=Wm();if(f&&a.strength(f),A=Um().nodes(u),m)(o=Ym()).centerX(S[0]).centerY(S[1]).template("force").strength(v),c&&o.links(c),u&&o.nodes(u),o.forceLinkDistance(y).forceLinkStrength(E).forceCharge(x).forceNodeSize(b),A.force("group",o);if(A.force("center",function(t,e){var n,r=1;function i(){var i,o,a=n.length,s=0,u=0;for(i=0;i<a;++i)s+=(o=n[i]).x,u+=o.y;for(s=(s/a-t)*r,u=(u/a-e)*r,i=0;i<a;++i)(o=n[i]).x-=s,o.y-=u}return null==t&&(t=0),null==e&&(e=0),i.initialize=function(t){n=t},i.x=function(e){return arguments.length?(t=+e,i):t},i.y=function(t){return arguments.length?(e=+t,i):e},i.strength=function(t){return arguments.length?(r=+t,i):r},i}(S[0],S[1])).force("charge",a).alpha(d).alphaDecay(l).alphaMin(h),T&&O.overlapProcess(A,{nodeSize:P,nodeSpacing:C,collideStrength:M}),c){var s=dm().id((function(t){return t.id})).links(c);p&&s.strength(p),g&&s.distance(g),A.force("link",s)}A.on("tick",(function(){var n=$m(u);null==k||k({nodes:n,edges:Zm(c)}),t&&n.forEach((function(t){return e.mergeNodeData(t.id,{x:t.data.x,y:t.data.y})}))})).on("end",(function(){var r=$m(u);t&&r.forEach((function(t){return e.mergeNodeData(t.id,{x:t.data.x,y:t.data.y})})),n({nodes:r,edges:Zm(c)})}))}catch(t){console.warn(t)}O.forceSimulation=A}))]}))}))},t.prototype.overlapProcess=function(t,e){var n,r,i=e.nodeSize,o=e.nodeSpacing,a=e.collideStrength;if(r=jt(o)?function(){return o}:Tt(o)?o:function(){return 0},i)if(Tt(i))n=function(t){return i(t)+r(t)};else if(jf(i)){var s=(i[0]>i[1]?i[0]:i[1])/2;n=function(t){return s+r(t)}}else if(jt(i)){var u=i/2;n=function(t){return u+r(t)}}else n=function(){return 10};else n=function(t){return t.size?jf(t.size)?(t.size[0]>t.size[1]?t.size[0]:t.size[1])/2+r(t):Ot(t.size)?(t.size.width>t.size.height?t.size.width:t.size.height)/2+r(t):t.size/2+r(t):10+r(t)};t.force("collisionForce",cm(n).strength(a))},t}(),$m=function(t){return t.map((function(t){var e=t.x,n=t.y,r=o(t,["x","y"]);return i(i({},r),{data:i(i({},r.data),{x:e,y:n})})}))},Zm=function(t){return t.map((function(t){var e=t.source,n=t.target,r=o(t,["source","target"]);return i(i({},r),{source:e.id,target:n.id})}))},Qm=function(t,e){if("next"!==t&&"prev"!==t)return e},Jm=function(t){t.prev.next=t.next,t.next.prev=t.prev,delete t.next,delete t.prev},tv=function(){function t(){var t={};t.prev=t,t.next=t.prev,this.shortcut=t}return t.prototype.dequeue=function(){var t=this.shortcut,e=t.prev;if(e&&e!==t)return Jm(e),e},t.prototype.enqueue=function(t){var e=this.shortcut;t.prev&&t.next&&Jm(t),t.next=e.next,e.next.prev=t,e.next=t,t.prev=e},t.prototype.toString=function(){for(var t=[],e=this.shortcut,n=e.prev;n!==e;)t.push(JSON.stringify(n,Qm)),n=null==n?void 0:n.prev;return"["+t.join(", ")+"]"},t}(),ev=function(t){function e(){return null!==t&&t.apply(this,arguments)||this}return r(e,t),e}(tv),nv=function(){return 1},rv=function(t,e,n){for(var r,i=[],o=e[e.length-1],a=e[0];t.getAllNodes().length;){for(;r=a.dequeue();)iv(t,e,n,r);for(;r=o.dequeue();)iv(t,e,n,r);if(t.getAllNodes().length)for(var s=e.length-2;s>0;--s)if(r=e[s].dequeue()){i=i.concat(iv(t,e,n,r,!0));break}}return i},iv=function(t,e,n,r,o){var a,s,u=[];return t.hasNode(r.v)&&(null===(a=t.getRelatedEdges(r.v,"in"))||void 0===a||a.forEach((function(r){var a=r.data.weight,s=t.getNode(r.source);o&&u.push({v:r.source,w:r.target,in:0,out:0}),void 0===s.data.out&&(s.data.out=0),s.data.out-=a,av(e,n,i({v:s.id},s.data))})),null===(s=t.getRelatedEdges(r.v,"out"))||void 0===s||s.forEach((function(r){var o=r.data.weight,a=r.target,s=t.getNode(a);void 0===s.data.in&&(s.data.in=0),s.data.in-=o,av(e,n,i({v:s.id},s.data))})),t.removeNode(r.v)),o?u:void 0},ov=function(t,e){var n=new Cp,r=0,o=0;t.getAllNodes().forEach((function(t){n.addNode({id:t.id,data:{v:t.id,in:0,out:0}})})),t.getAllEdges().forEach((function(t){var a=n.getRelatedEdges(t.source,"out").find((function(e){return e.target===t.target})),s=(null==e?void 0:e(t))||1;a?n.updateEdgeData(null==a?void 0:a.id,i(i({},a.data),{weight:a.data.weight+s})):n.addEdge({id:t.id,source:t.source,target:t.target,data:{weight:s}}),o=Math.max(o,n.getNode(t.source).data.out+=s),r=Math.max(r,n.getNode(t.target).data.in+=s)}));for(var a=[],s=o+r+3,u=0;u<s;u++)a.push(new ev);var c=r+1;return n.getAllNodes().forEach((function(t){av(a,c,i({v:t.id},n.getNode(t.id).data))})),{buckets:a,zeroIdx:c,graph:n}},av=function(t,e,n){n.out?n.in?t[n.out-n.in+e].enqueue(n):t[t.length-1].enqueue(n):t[0].enqueue(n)},sv=function(t,e){var n="greedy"===e?function(t,e){var n;if(t.getAllNodes().length<=1)return[];var r=ov(t,e||nv);return null===(n=rv(r.graph,r.buckets,r.zeroIdx).map((function(e){return t.getRelatedEdges(e.v,"out").filter((function(t){return t.target===e.w}))})))||void 0===n?void 0:n.flat()}(t,(function(t){return t.data.weight||1})):uv(t);null==n||n.forEach((function(e){var n=e.data;t.removeEdge(e.id),n.forwardName=e.data.name,n.reversed=!0,t.addEdge({id:e.id,source:e.target,target:e.source,data:i({},n)})}))},uv=function(t){var e=[],n={},r={},i=function(o){r[o]||(r[o]=!0,n[o]=!0,t.getRelatedEdges(o,"out").forEach((function(t){n[t.target]?e.push(t):i(t.target)})),delete n[o])};return t.getAllNodes().forEach((function(t){return i(t.id)})),e},cv=function(t,e,n,r){var i;do{i=""+r+Math.random()}while(t.hasNode(i));return n.dummy=e,t.addNode({id:i,data:n}),i},hv=function(t){var e=new Cp;return t.getAllNodes().forEach((function(n){t.getChildren(n.id).length||e.addNode(i({},n))})),t.getAllEdges().forEach((function(t){e.addEdge(t)})),e},lv=function(t,e){var n,r,i=Number(t.x),o=Number(t.y),a=Number(e.x)-i,s=Number(e.y)-o,u=Number(t.width)/2,c=Number(t.height)/2;return a||s?(Math.abs(s)*u>Math.abs(a)*c?(s<0&&(c=-c),n=c*a/s,r=c):(a<0&&(u=-u),n=u,r=u*s/a),{x:i+n,y:o+r}):{x:0,y:0}},dv=function(t){for(var e=[],n=pv(t)+1,r=0;r<n;r++)e.push([]);t.getAllNodes().forEach((function(t){var n=t.data.rank;void 0!==n&&e[n]&&e[n].push(t.id)}));for(r=0;r<n;r++)e[r]=e[r].sort((function(e,n){return r=t.getNode(e).data.order,i=t.getNode(n).data.order,Number(r)-Number(i);var r,i}));return e},fv=function(t,e,n,r){var i={width:0,height:0};return jt(n)&&jt(r)&&(i.rank=n,i.order=r),cv(t,"border",i,e)},pv=function(t){var e;return t.getAllNodes().forEach((function(t){var n=t.data.rank;void 0!==n&&(void 0===e||n>e)&&(e=n)})),e||(e=0),e},gv=function(t,e){return t.reduce((function(t,n){return e(t)>e(n)?n:t}))},mv=function(t,e,n,r,i,o){r.includes(e.id)||(r.push(e.id),n||o.push(e.id),i(e.id).forEach((function(e){return mv(t,e,n,r,i,o)})),n&&o.push(e.id))},vv=function(t,e,n,r){var i=Array.isArray(e)?e:[e],o=function(e){return r?t.getSuccessors(e):t.getNeighbors(e)},a=[],s=[];return i.forEach((function(e){if(!t.hasNode(e.id))throw new Error("Graph does not have node: "+e);mv(t,e,"post"===n,s,o,a)})),a},yv="edge-label",Ev=function(t,e,n){var r=e.source,i=t.getNode(r).data.rank,o=e.target,a=t.getNode(o).data.rank,s=e.data.labelRank;if(a!==i+1){var u,c,h;for(t.removeEdge(e.id),h=0,++i;i<a;++h,++i)e.data.points=[],u=cv(t,"edge",c={originalEdge:e,width:0,height:0,rank:i},"_d"),i===s&&(c.width=e.data.width,c.height=e.data.height,c.dummy=yv,c.labelpos=e.data.labelpos),t.addEdge({id:"e"+Math.random(),source:r,target:u,data:{weight:e.data.weight}}),0===h&&n.push(u),r=u;t.addEdge({id:"e"+Math.random(),source:r,target:o,data:{weight:e.data.weight}})}},xv=function(t){var e={},n=function(r){var i,o,a=t.getNode(r);return a?e[r]?a.data.rank:(e[r]=!0,null===(i=t.getRelatedEdges(r,"out"))||void 0===i||i.forEach((function(t){var e=n(t.target)-t.data.minlen;e&&(void 0===o||e<o)&&(o=e)})),o||(o=0),a.data.rank=o,o):0};t.getAllNodes().filter((function(e){return 0===t.getRelatedEdges(e.id,"in").length})).forEach((function(t){return n(t.id)}))},bv=function(t,e){return t.getNode(e.target).data.rank-t.getNode(e.source).data.rank-e.data.minlen},wv=function(t,e){var n=function(r){e.getRelatedEdges(r,"both").forEach((function(i){var o=i.source,a=r===o?i.target:o;t.hasNode(a)||bv(e,i)||(t.addNode({id:a,data:{}}),t.addEdge({id:i.id,source:r,target:a,data:{}}),n(a))}))};return t.getAllNodes().forEach((function(t){return n(t.id)})),t.getAllNodes().length},Mv=function(t,e){var n=function(r){var i;null===(i=e.getRelatedEdges(r,"both"))||void 0===i||i.forEach((function(i){var o=i.source,a=r===o?i.target:o;t.hasNode(a)||void 0===e.getNode(a).data.layer&&bv(e,i)||(t.addNode({id:a,data:{}}),t.addEdge({id:i.id,source:r,target:a,data:{}}),n(a))}))};return t.getAllNodes().forEach((function(t){return n(t.id)})),t.getAllNodes().length},Nv=function(t,e){return gv(e.getAllEdges(),(function(n){return t.hasNode(n.source)!==t.hasNode(n.target)?bv(e,n):1/0}))},Sv=function(t,e,n){t.getAllNodes().forEach((function(t){var r=e.getNode(t.id);r.data.rank||(r.data.rank=0),r.data.rank+=n}))},Tv=function(t){var e=function(t){var e=new Cp;return t.getAllNodes().forEach((function(t){e.addNode(i({},t))})),t.getAllEdges().forEach((function(t){var n=e.getRelatedEdges(t.source,"out").find((function(e){return e.target===t.target}));n?e.updateEdgeData(null==n?void 0:n.id,i(i({},n.data),{weight:n.data.weight+t.data.weight||0,minlen:Math.max(n.data.minlen,t.data.minlen||1)})):e.addEdge({id:t.id,source:t.source,target:t.target,data:{weight:t.data.weight||0,minlen:t.data.minlen||1}})})),e}(t);xv(e);var n,r,o=function(t){var e,n,r=new Cp({tree:[]}),i=t.getAllNodes()[0],o=t.getAllNodes().length;for(r.addNode(i);wv(r,t)<o;)e=Nv(r,t),n=r.hasNode(e.source)?bv(t,e):-bv(t,e),Sv(r,t,n);return r}(e);for(Av(o),Pv(o,e);n=Rv(o);)r=Dv(o,e,n),Iv(o,e,n,r)},Pv=function(t,e){var n=vv(t,t.getAllNodes(),"post",!1);(n=n.slice(0,(null==n?void 0:n.length)-1)).forEach((function(n){Cv(t,e,n)}))},Cv=function(t,e,n){var r=t.getNode(n).data.parent;t.getRelatedEdges(n,"both").find((function(t){return t.target===r||t.source===r})).data.cutvalue=kv(t,e,n)},kv=function(t,e,n){var r=t.getNode(n).data.parent,i=!0,o=e.getRelatedEdges(n,"out").find((function(t){return t.target===r})),a=0;return o||(i=!1,o=e.getRelatedEdges(r,"out").find((function(t){return t.target===n}))),a=o.data.weight,e.getRelatedEdges(n,"both").forEach((function(e){var o=e.source===n,s=o?e.target:e.source;if(s!==r){var u=o===i,c=e.data.weight;if(a+=u?c:-c,_v(t,n,s)){var h=t.getRelatedEdges(n,"both").find((function(t){return t.source===s||t.target===s})).data.cutvalue;a+=u?-h:h}}})),a},Av=function(t,e){void 0===e&&(e=t.getAllNodes()[0].id),Ov(t,{},1,e)},Ov=function(t,e,n,r,i){var o,a=n,s=n,u=t.getNode(r);return e[r]=!0,null===(o=t.getNeighbors(r))||void 0===o||o.forEach((function(n){e[n.id]||(s=Ov(t,e,s,n.id,r))})),u.data.low=a,u.data.lim=s++,i?u.data.parent=i:delete u.data.parent,s},Rv=function(t){return t.getAllEdges().find((function(t){return t.data.cutvalue<0}))},Dv=function(t,e,n){var r=n.source,i=n.target;e.getRelatedEdges(r,"out").find((function(t){return t.target===i}))||(r=n.target,i=n.source);var o=t.getNode(r),a=t.getNode(i),s=o,u=!1;o.data.lim>a.data.lim&&(s=a,u=!0);var c=e.getAllEdges().filter((function(e){return u===zv(t.getNode(e.source),s)&&u!==zv(t.getNode(e.target),s)}));return gv(c,(function(t){return bv(e,t)}))},Iv=function(t,e,n,r){var i=t.getRelatedEdges(n.source,"both").find((function(t){return t.source===n.target||t.target===n.target}));i&&t.removeEdge(i.id),t.addEdge({id:"e"+Math.random(),source:r.source,target:r.target,data:{}}),Av(t),Pv(t,e),Lv(t,e)},Lv=function(t,e){var n=t.getAllNodes().find((function(t){return!t.data.parent})),r=vv(t,n,"pre",!1);(r=r.slice(1)).forEach((function(n){var r=t.getNode(n).data.parent,i=e.getRelatedEdges(n,"out").find((function(t){return t.target===r})),o=!1;!i&&e.hasNode(r)&&(i=e.getRelatedEdges(r,"out").find((function(t){return t.target===n})),o=!0),e.getNode(n).data.rank=(e.hasNode(r)&&e.getNode(r).data.rank||0)+(o?null==i?void 0:i.data.minlen:-(null==i?void 0:i.data.minlen))}))},_v=function(t,e,n){return t.getRelatedEdges(e,"both").find((function(t){return t.source===n||t.target===n}))},zv=function(t,e){return e.data.low<=t.data.lim&&t.data.lim<=e.data.lim},Fv=xv,Bv=function(t){!function(t){var e,n={},r=function(i){var o,a,s=t.getNode(i);return s?n[i]?s.data.rank:(n[i]=!0,null===(o=t.getRelatedEdges(i,"out"))||void 0===o||o.forEach((function(t){var e=r(t.target)-t.data.minlen;e&&(void 0===a||e<a)&&(a=e)})),a||(a=0),(void 0===e||a<e)&&(e=a),s.data.rank=a,a):0};t.getAllNodes().filter((function(e){return 0===t.getRelatedEdges(e.id,"in").length})).forEach((function(t){t&&r(t.id)})),void 0===e&&(e=0);var i={},o=function(e,n){var r,a=t.getNode(e),s=isNaN(a.data.layer)?n:a.data.layer;(void 0===a.data.rank||a.data.rank<s)&&(a.data.rank=s),i[e]||(i[e]=!0,null===(r=t.getRelatedEdges(e,"out"))||void 0===r||r.forEach((function(t){o(t.target,s+t.data.minlen)})))};t.getAllNodes().forEach((function(t){var n=t.data;n&&(isNaN(n.layer)?n.rank-=e:o(t.id,n.layer))}))}(t),function(t){var e,n,r=new Cp({tree:[]}),i=t.getAllNodes()[0],o=t.getAllNodes().length;for(r.addNode(i);Mv(r,t)<o;)e=Nv(r,t),n=r.hasNode(e.source)?bv(t,e):-bv(t,e),Sv(r,t,n)}(t)},Gv=function(t){Tv(t)},jv=function(t,e){var n=function(t){var e={},n=0,r=function(i){var o=n;t.getChildren(i).forEach((function(t){return r(t.id)})),e[i]={low:o,lim:n++}};return t.getRoots().forEach((function(t){return r(t.id)})),e}(t);e.forEach((function(e){var r,i,o=e,a=t.getNode(o),s=a.data.originalEdge;if(s)for(var u=function(t,e,n,r){var i,o,a,s,u=[],c=[],h=Math.min(e[n].low,e[r].low),l=Math.max(e[n].lim,e[r].lim);a=n;do{a=null===(i=t.getParent(a))||void 0===i?void 0:i.id,u.push(a)}while(a&&(e[a].low>h||l>e[a].lim));for(s=a,a=r;a&&a!==s;)c.push(a),a=null===(o=t.getParent(a))||void 0===o?void 0:o.id;return{lca:s,path:u.concat(c.reverse())}}(t,n,s.source,s.target),c=u.path,h=u.lca,l=0,d=c[l],f=!0;o!==s.target;){if(a=t.getNode(o),f){for(;d!==h&&(null===(r=t.getNode(d))||void 0===r?void 0:r.data.maxRank)<a.data.rank;)d=c[++l];d===h&&(f=!1)}if(!f){for(;l<c.length-1&&(null===(i=t.getNode(c[l+1]))||void 0===i?void 0:i.data.minRank)<=a.data.rank;)l++;d=c[l]}t.hasNode(d)&&t.setParent(o,d),o=t.getSuccessors(o)[0].id}}))},Vv=function(t,e,n,r,i,o,a){var s=t.getChildren(a);if(null==s?void 0:s.length){var u=fv(t,"_bt"),c=fv(t,"_bb"),h=t.getNode(a);t.setParent(u,a),h.data.borderTop=u,t.setParent(c,a),h.data.borderBottom=c,null==s||s.forEach((function(s){Vv(t,e,n,r,i,o,s.id);var h=s.data.borderTop?s.data.borderTop:s.id,l=s.data.borderBottom?s.data.borderBottom:s.id,d=s.data.borderTop?r:2*r,f=h!==l?1:i-o[a]+1;t.addEdge({id:"e"+Math.random(),source:u,target:h,data:{minlen:f,weight:d,nestingEdge:!0}}),t.addEdge({id:"e"+Math.random(),source:l,target:c,data:{minlen:f,weight:d,nestingEdge:!0}})})),t.getParent(a)||t.addEdge({id:"e"+Math.random(),source:e,target:u,data:{weight:0,minlen:i+o[a]}})}else a!==e&&t.addEdge({id:"e"+Math.random(),source:e,target:a,data:{weight:0,minlen:n}})},Uv=function(t){var e={},n=function(r,i){var o=t.getChildren(r);null==o||o.forEach((function(t){return n(t.id,i+1)})),e[r]=i};return t.getRoots().forEach((function(t){return n(t.id,1)})),e},Wv=function(t){var e=0;return t.getAllEdges().forEach((function(t){e+=t.data.weight})),e},Hv=function(t,e,n,r,i,o){var a={rank:o,borderType:e,width:0,height:0},s=i.data[e][o-1],u=cv(t,"border",a,n);i.data[e][o]=u,t.setParent(u,r),s&&t.addEdge({id:"e"+Math.random(),source:s,target:u,data:{weight:1}})},qv=function(t){t.getAllNodes().forEach((function(t){Yv(t)})),t.getAllEdges().forEach((function(t){Yv(t)}))},Yv=function(t){var e=t.data.width;t.data.width=t.data.height,t.data.height=e},Xv=function(t){t.getAllNodes().forEach((function(t){Kv(t.data)})),t.getAllEdges().forEach((function(t){var e;null===(e=t.data.points)||void 0===e||e.forEach((function(t){return Kv(t)})),t.data.hasOwnProperty("y")&&Kv(t.data)}))},Kv=function(t){(null==t?void 0:t.y)&&(t.y=-t.y)},$v=function(t){t.getAllNodes().forEach((function(t){Zv(t.data)})),t.getAllEdges().forEach((function(t){var e;null===(e=t.data.points)||void 0===e||e.forEach((function(t){return Zv(t)})),t.data.hasOwnProperty("x")&&Zv(t.data)}))},Zv=function(t){var e=t.x;t.x=t.y,t.y=e},Qv=function(t){for(var e={},n=t.getAllNodes(),r=n.map((function(t){var e;return null!==(e=t.data.rank)&&void 0!==e?e:-1/0})),i=Math.max.apply(Math,h([],c(r))),o=[],a=0;a<i+1;a++)o.push([]);var s=n.sort((function(e,n){return t.getNode(e.id).data.rank-t.getNode(n.id).data.rank})),u=s.filter((function(e){return void 0!==t.getNode(e.id).data.fixorder})).sort((function(e,n){return t.getNode(e.id).data.fixorder-t.getNode(n.id).data.fixorder}));return null==u||u.forEach((function(n){isNaN(t.getNode(n.id).data.rank)||o[t.getNode(n.id).data.rank].push(n.id),e[n.id]=!0})),null==s||s.forEach((function(n){return t.dfsTree(n.id,(function(t){if(e.hasOwnProperty(t.id))return!0;e[t.id]=!0,isNaN(t.data.rank)||o[t.data.rank].push(t.id)}))})),o},Jv=function(t,e,n){for(var r=function(t,e){return null==t?void 0:t.reduce((function(t,n,r){return t[n]=e[r],t}),{})}(n,n.map((function(t,e){return e}))),i=e.map((function(e){var n=t.getRelatedEdges(e,"out").map((function(t){return{pos:r[t.target]||0,weight:t.data.weight}}));return null==n?void 0:n.sort((function(t,e){return t.pos-e.pos}))})),o=i.flat().filter((function(t){return void 0!==t})),a=1;a<n.length;)a<<=1;var s=2*a-1;a-=1;var u=Array(s).fill(0,0,s),c=0;return null==o||o.forEach((function(t){if(t){var e=t.pos+a;u[e]+=t.weight;for(var n=0;e>0;)e%2&&(n+=u[e+1]),u[e=e-1>>1]+=t.weight;c+=t.weight*n}})),c},ty=function(t,e){for(var n=0,r=1;r<(null==e?void 0:e.length);r+=1)n+=Jv(t,e[r-1],e[r]);return n},ey=function(t){for(var e;t.hasNode(e="_root"+Math.random()););return e},ny=function(t){for(var e,n,r=[],i=function(){var i=t.pop();r.push(i),null===(e=i.in.reverse())||void 0===e||e.forEach((function(t){return(e=i,function(t){t.merged||(void 0===t.barycenter||void 0===e.barycenter||t.barycenter>=e.barycenter)&&ry(e,t)})(t);var e})),null===(n=i.out)||void 0===n||n.forEach((function(e){return(n=i,function(e){e.in.push(n),0==--e.indegree&&t.push(e)})(e);var n}))};null==t?void 0:t.length;)i();var o=r.filter((function(t){return!t.merged})),a=["vs","i","barycenter","weight"];return o.map((function(t){var e={};return null==a||a.forEach((function(n){void 0!==t[n]&&(e[n]=t[n])})),e}))},ry=function(t,e){var n,r=0,i=0;t.weight&&(r+=t.barycenter*t.weight,i+=t.weight),e.weight&&(r+=e.barycenter*e.weight,i+=e.weight),t.vs=null===(n=e.vs)||void 0===n?void 0:n.concat(t.vs),t.barycenter=r/i,t.weight=i,t.i=Math.min(e.i,t.i),e.merged=!0},iy=function(t,e,n){for(var r,i=n;e.length&&(r=e[e.length-1]).i<=i;)e.pop(),null==t||t.push(r.vs),i++;return i},oy=function(t,e){return function(n,r){if(void 0!==n.fixorder&&void 0!==r.fixorder)return n.fixorder-r.fixorder;if(n.barycenter<r.barycenter)return-1;if(n.barycenter>r.barycenter)return 1;if(e&&void 0!==n.order&&void 0!==r.order){if(n.order<r.order)return-1;if(n.order>r.order)return 1}return t?r.i-n.i:n.i-r.i}},ay=function(t,e,n,r,i,o){var a,s,u,c,h=t.getChildren(e).map((function(t){return t.id})),l=t.getNode(e),d=l?l.data.borderLeft:void 0,f=l?l.data.borderRight:void 0,p={};d&&(h=null==h?void 0:h.filter((function(t){return t!==d&&t!==f})));var g=function(t,e){return e.map((function(e){var n=t.getRelatedEdges(e,"in");if(!(null==n?void 0:n.length))return{v:e};var r={sum:0,weight:0};return null==n||n.forEach((function(e){var n=t.getNode(e.source);r.sum+=e.data.weight*n.data.order,r.weight+=e.data.weight})),{v:e,barycenter:r.sum/r.weight,weight:r.weight}}))}(t,h||[]);null==g||g.forEach((function(e){var i;if(null===(i=t.getChildren(e.v))||void 0===i?void 0:i.length){var a=ay(t,e.v,n,r,o);p[e.v]=a,a.hasOwnProperty("barycenter")&&uy(e,a)}}));var m=function(t,e){var n,r,i,o={};null==t||t.forEach((function(t,e){o[t.v]={i:e,indegree:0,in:[],out:[],vs:[t.v]};var n=o[t.v];void 0!==t.barycenter&&(n.barycenter=t.barycenter,n.weight=t.weight)})),null===(n=e.getAllEdges())||void 0===n||n.forEach((function(t){var e=o[t.source],n=o[t.target];void 0!==e&&void 0!==n&&(n.indegree++,e.out.push(o[t.target]))}));var a=null===(i=(r=Object.values(o)).filter)||void 0===i?void 0:i.call(r,(function(t){return!t.indegree}));return ny(a)}(g,n);sy(m,p),null===(a=m.filter((function(t){return t.vs.length>0})))||void 0===a||a.forEach((function(e){var n=t.getNode(e.vs[0]);n&&(e.fixorder=n.data.fixorder,e.order=n.data.order)}));var v=function(t,e,n,r){var i=function(t,e){var n={lhs:[],rhs:[]};return null==t||t.forEach((function(t){e(t)?n.lhs.push(t):n.rhs.push(t)})),n}(t,(function(t){var e=t.hasOwnProperty("fixorder")&&!isNaN(t.fixorder);return r?!e&&t.hasOwnProperty("barycenter"):e||t.hasOwnProperty("barycenter")})),o=i.lhs,a=i.rhs.sort((function(t,e){return-t.i- -e.i})),s=[],u=0,c=0,h=0;null==o||o.sort(oy(!!e,!!n)),h=iy(s,a,h),null==o||o.forEach((function(t){var e;h+=null===(e=t.vs)||void 0===e?void 0:e.length,s.push(t.vs),u+=t.barycenter*t.weight,c+=t.weight,h=iy(s,a,h)}));var l={vs:s.flat()};return c&&(l.barycenter=u/c,l.weight=c),l}(m,r,i,o);if(d&&(v.vs=[d,v.vs,f].flat(),null===(s=t.getPredecessors(d))||void 0===s?void 0:s.length)){var y=t.getNode((null===(u=t.getPredecessors(d))||void 0===u?void 0:u[0].id)||""),E=t.getNode((null===(c=t.getPredecessors(f))||void 0===c?void 0:c[0].id)||"");v.hasOwnProperty("barycenter")||(v.barycenter=0,v.weight=0),v.barycenter=(v.barycenter*v.weight+y.data.order+E.data.order)/(v.weight+2),v.weight+=2}return v},sy=function(t,e){null==t||t.forEach((function(t){var n,r=null===(n=t.vs)||void 0===n?void 0:n.map((function(t){return e[t]?e[t].vs:t}));t.vs=r.flat()}))},uy=function(t,e){void 0!==t.barycenter?(t.barycenter=(t.barycenter*t.weight+e.barycenter*e.weight)/(t.weight+e.weight),t.weight+=e.weight):(t.barycenter=e.barycenter,t.weight=e.weight)},cy=function(t,e,n){return e.map((function(e){return function(t,e,n){var r=ey(t),o=new Cp({tree:[{id:r,children:[],data:{}}]});return t.getAllNodes().forEach((function(a){var s=t.getParent(a.id);(a.data.rank===e||a.data.minRank<=e&&e<=a.data.maxRank)&&(o.hasNode(a.id)||o.addNode(i({},a)),(null==s?void 0:s.id)&&!o.hasNode(null==s?void 0:s.id)&&o.addNode(i({},s)),o.setParent(a.id,(null==s?void 0:s.id)||r),t.getRelatedEdges(a.id,n).forEach((function(e){var n=e.source===a.id?e.target:e.source;o.hasNode(n)||o.addNode(i({},t.getNode(n)));var r=o.getRelatedEdges(n,"out").find((function(t){return t.target===a.id})),s=void 0!==r?r.data.weight:0;r?o.updateEdgeData(r.id,i(i({},r.data),{weight:e.data.weight+s})):o.addEdge({id:e.id,source:n,target:a.id,data:{weight:e.data.weight+s}})})),a.data.hasOwnProperty("minRank")&&o.updateNodeData(a.id,i(i({},a.data),{borderLeft:a.data.borderLeft[e],borderRight:a.data.borderRight[e]})))})),o}(t,e,n)}))},hy=function(t,e,n,r){var i=new Cp;null==t||t.forEach((function(t){for(var o,a=t.getRoots()[0].id,s=ay(t,a,i,e,n,r),u=0;u<(null===(o=s.vs)||void 0===o?void 0:o.length);u++){var c=t.getNode(s.vs[u]);c&&(c.data.order=u)}!function(t,e,n){var r,i={};null==n||n.forEach((function(n){for(var o,a,s=t.getParent(n);s;){if((o=t.getParent(s.id))?(a=i[o.id],i[o.id]=s.id):(a=r,r=s.id),a&&a!==s.id)return e.hasNode(a)||e.addNode({id:a,data:{}}),e.hasNode(s.id)||e.addNode({id:s.id,data:{}}),void(e.hasEdge("e"+a+"-"+s.id)||e.addEdge({id:"e"+a+"-"+s.id,source:a,target:s.id,data:{}}));s=o}}))}(t,i,s.vs)}))},ly=function(t,e){null==e||e.forEach((function(e){null==e||e.forEach((function(e,n){t.getNode(e).data.order=n}))}))},dy=function(t,e){var n={};function r(e,r,i,o,a){for(var s,u,c,h=r;h<i;h++)c=e[h],(null===(s=t.getNode(c))||void 0===s?void 0:s.data.dummy)&&(null===(u=t.getPredecessors(c))||void 0===u||u.forEach((function(e){var r=t.getNode(e.id);r.data.dummy&&(r.data.order<o||r.data.order>a)&&py(n,e.id,c)})))}function i(t,e){var n=function(t){return JSON.stringify(t.slice(1))}(t);e.get(n)||(r.apply(void 0,h([],c(t))),e.set(n,!0))}return(null==e?void 0:e.length)&&e.reduce((function(e,n){var r,o=-1,a=0,s=new Map;return null==n||n.forEach((function(u,c){var h;if("border"===(null===(h=t.getNode(u))||void 0===h?void 0:h.data.dummy)){var l=t.getPredecessors(u)||[];l.length&&(r=t.getNode(l[0].id).data.order,i([n,a,c,o,r],s),a=c,o=r)}i([n,a,n.length,r,e.length],s)})),n})),n},fy=function(t,e){var n,r;if(null===(n=t.getNode(e))||void 0===n?void 0:n.data.dummy)return null===(r=t.getPredecessors(e))||void 0===r?void 0:r.find((function(e){return t.getNode(e.id).data.dummy}))},py=function(t,e,n){var r=e,i=n;if(r>i){var o=r;r=i,i=o}var a=t[r];a||(t[r]=a={}),a[i]=!0},gy=function(t,e,n){var r=e;r>n&&(r=n);return!!t[r]},my=function(t,e,n,r,o,a){var s=new Cp,u=vy(r,o,a);return null==e||e.forEach((function(e){var r;null==e||e.forEach((function(e){var o=n[e];if(s.hasNode(o)||s.addNode({id:o,data:{}}),r){var a=n[r],c=s.getRelatedEdges(a,"out").find((function(t){return t.target===o}));c?s.updateEdgeData(c.id,i(i({},c.data),{weight:Math.max(u(t,e,r),c.data.weight||0)})):s.addEdge({id:"e"+Math.random(),source:a,target:o,data:{weight:Math.max(u(t,e,r),0)}})}r=e}))})),s};var vy=function(t,e,n){return function(r,i,o){var a=r.getNode(i),s=r.getNode(o),u=0,c=0;if(u+=a.data.width/2,a.data.hasOwnProperty("labelpos"))switch((a.data.labelpos||"").toLowerCase()){case"l":c=-a.data.width/2;break;case"r":c=a.data.width/2}if(c&&(u+=n?c:-c),c=0,u+=(a.data.dummy?e:t)/2,u+=(s.data.dummy?e:t)/2,u+=s.data.width/2,s.data.labelpos)switch((s.data.labelpos||"").toLowerCase()){case"l":c=s.data.width/2;break;case"r":c=-s.data.width/2}return c&&(u+=n?c:-c),c=0,u}},yy=function(t,e){return t.getNode(e).data.width||0},Ey=function(t,e){var n=e||{},r=n.align,i=n.nodesep,o=void 0===i?0:i,a=n.edgesep,s=void 0===a?0:a,u=dv(t),l=Object.assign(function(t,e){var n={};return(null==e?void 0:e.length)&&e.reduce((function(e,r){var i=0,o=0,a=e.length,s=null==r?void 0:r[(null==r?void 0:r.length)-1];return null==r||r.forEach((function(e,u){var c,h=fy(t,e),l=h?t.getNode(h.id).data.order:a;(h||e===s)&&(null===(c=r.slice(o,u+1))||void 0===c||c.forEach((function(e){var r;null===(r=t.getPredecessors(e))||void 0===r||r.forEach((function(r){var o,a=t.getNode(r.id),s=a.data.order;!(s<i||l<s)||a.data.dummy&&(null===(o=t.getNode(e))||void 0===o?void 0:o.data.dummy)||py(n,r.id,e)}))})),o=u+1,i=l)})),r})),n}(t,u),dy(t,u)),d={},f=[];["u","d"].forEach((function(e){f="u"===e?u:Object.values(u).reverse(),["l","r"].forEach((function(n){"r"===n&&(f=f.map((function(t){return Object.values(t).reverse()})));var r=("u"===e?t.getPredecessors:t.getSuccessors).bind(t),i=function(t,e,n,r){var i={},o={},a={};return null==e||e.forEach((function(t){null==t||t.forEach((function(t,e){i[t]=t,o[t]=t,a[t]=e}))})),null==e||e.forEach((function(t){var e=-1;null==t||t.forEach((function(t){var s=r(t).map((function(t){return t.id}));if(s.length){s=s.sort((function(t,e){return a[t]-a[e]}));for(var u=(s.length-1)/2,c=Math.floor(u),h=Math.ceil(u);c<=h;++c){var l=s[c];o[t]===t&&e<a[l]&&!gy(n,t,l)&&(o[l]=t,o[t]=i[t]=i[l],e=a[l])}}}))})),{root:i,align:o}}(0,f,l,r),a=function(t,e,n,r,i,o,a){var s,u={},c=my(t,e,n,i,o,a),h=a?"borderLeft":"borderRight",l=function(t,e){for(var n=c.getAllNodes(),r=n.pop(),i={};r;)i[r.id]?t(r.id):(i[r.id]=!0,n.push(r),n=n.concat(e(r.id))),r=n.pop()};return l((function(t){u[t]=(c.getRelatedEdges(t,"in")||[]).reduce((function(t,e){return Math.max(t,(u[e.source]||0)+e.data.weight)}),0)}),c.getPredecessors.bind(c)),l((function(e){var n=(c.getRelatedEdges(e,"out")||[]).reduce((function(t,e){return Math.min(t,(u[e.target]||0)-e.data.weight)}),Number.POSITIVE_INFINITY),r=t.getNode(e);n!==Number.POSITIVE_INFINITY&&r.data.borderType!==h&&(u[e]=Math.max(u[e],n))}),c.getSuccessors.bind(c)),null===(s=Object.values(r))||void 0===s||s.forEach((function(t){u[t]=u[n[t]]})),u}(t,f,i.root,i.align,o,s,"r"===n);"r"===n&&Object.keys(a).forEach((function(t){return a[t]=-a[t]})),d[e+n]=a}))}));var p=function(t,e){return gv(Object.values(e),(function(e){var n,r=Number.NEGATIVE_INFINITY,i=Number.POSITIVE_INFINITY;return null===(n=Object.keys(e))||void 0===n||n.forEach((function(n){var o=e[n],a=yy(t,n)/2;r=Math.max(o+a,r),i=Math.min(o-a,i)})),r-i}))}(t,d);return p&&function(t,e){var n=Object.values(e),r=Math.min.apply(Math,h([],c(n))),i=Math.max.apply(Math,h([],c(n)));["u","d"].forEach((function(n){["l","r"].forEach((function(o){var a,s=n+o,u=t[s];if(u!==e){var l=Object.values(u);(a="l"===o?r-Math.min.apply(Math,h([],c(l))):i-Math.max.apply(Math,h([],c(l))))&&(t[s]={},Object.keys(u).forEach((function(e){t[s][e]=u[e]+a})))}}))}))}(d,p),function(t,e){var n={};return Object.keys(t.ul).forEach((function(r){if(e)n[r]=t[e.toLowerCase()][r];else{var i=Object.values(t).map((function(t){return t[r]}));n[r]=(i[0]+i[1])/2}})),n}(d,r)},xy=function(t,e){var n,r=hv(t);!function(t,e){var n=(e||{}).ranksep,r=void 0===n?0:n,i=dv(t),o=0;null==i||i.forEach((function(e){var n=e.map((function(e){return t.getNode(e).data.height})),i=Math.max.apply(Math,h(h([],c(n)),[0]));null==e||e.forEach((function(e){t.getNode(e).data.y=o+i/2})),o+=i+r}))}(r,e);var i=Ey(r,e);null===(n=Object.keys(i))||void 0===n||n.forEach((function(t){r.getNode(t).data.x=i[t]}))},by=function(t,e){var n=e.acyclicer,r=e.ranker,o=e.rankdir,a=void 0===o?"tb":o,s=e.nodeOrder,u=e.keepNodeOrder,l=e.align,d=e.nodesep,f=void 0===d?50:d,p=e.edgesep,g=void 0===p?20:p,m=e.ranksep,v=void 0===m?50:m;By(t),sv(t,n);var y=function(t){var e=cv(t,"root",{},"_root"),n=Uv(t),r=Math.max.apply(Math,h([],c(Object.values(n))));Math.abs(r)===1/0&&(r=1);var i=r-1,o=2*i+1;t.getAllEdges().forEach((function(t){t.data.minlen*=o}));var a=Wv(t)+1;return t.getRoots().forEach((function(r){Vv(t,e,o,a,i,n,r.id)})),{nestingRoot:e,nodeRankFactor:o}}(t),E=y.nestingRoot,x=y.nodeRankFactor;!function(t,e){switch(e){case"network-simplex":Gv(t);break;case"tight-tree":default:Bv(t);break;case"longest-path":Fv(t)}}(hv(t),r),Oy(t),function(t,e){void 0===e&&(e=0);var n=t.getAllNodes(),r=n.filter((function(t){return void 0!==t.data.rank})).map((function(t){return t.data.rank})),i=Math.min.apply(Math,h([],c(r))),o=[];n.forEach((function(t){var e=(t.data.rank||0)-i;o[e]||(o[e]=[]),o[e].push(t.id)}));for(var a=0,s=0;s<o.length;s++){var u=o[s];void 0===u?s%e!=0&&(a-=1):a&&(null==u||u.forEach((function(e){var n=t.getNode(e);n&&(n.data.rank=n.data.rank||0,n.data.rank+=a)})))}}(t,x),function(t,e){e&&t.removeNode(e),t.getAllEdges().forEach((function(e){e.data.nestingEdge&&t.removeEdge(e.id)}))}(t,E),function(t){var e=t.getAllNodes().filter((function(t){return void 0!==t.data.rank})).map((function(t){return t.data.rank})),n=Math.min.apply(Math,h([],c(e)));t.getAllNodes().forEach((function(t){t.data.hasOwnProperty("rank")&&n!==1/0&&(t.data.rank-=n)}))}(t),Ry(t),Dy(t);var b=[];!function(t,e){t.getAllEdges().forEach((function(n){return Ev(t,n,e)}))}(t,b),jv(t,b),function(t){var e=function(n){var r=t.getChildren(n),i=t.getNode(n);if((null==r?void 0:r.length)&&r.forEach((function(t){return e(t.id)})),i.data.hasOwnProperty("minRank")){i.data.borderLeft=[],i.data.borderRight=[];for(var o=i.data.minRank,a=i.data.maxRank+1;o<a;o+=1)Hv(t,"borderLeft","_bl",n,i,o),Hv(t,"borderRight","_br",n,i,o)}};t.getRoots().forEach((function(t){return e(t.id)}))}(t),u&&function(t,e){for(var n=t.getAllNodes().filter((function(e){var n;return!(null===(n=t.getChildren(e.id))||void 0===n?void 0:n.length)})),r=n.map((function(t){return t.data.rank})),i=Math.max.apply(Math,h([],c(r))),o=[],a=0;a<i+1;a++)o[a]=[];null==e||e.forEach((function(e){var n=t.getNode(e);n&&!n.data.dummy&&(isNaN(n.data.rank)||(n.data.fixorder=o[n.data.rank].length,o[n.data.rank].push(e)))}))}(t,s),function(t,e){for(var n=pv(t),r=[],i=[],o=1;o<n+1;o++)r.push(o);for(o=n-1;o>-1;o--)i.push(o);var a=cy(t,r,"in"),s=cy(t,i,"out"),u=Qv(t);ly(t,u);for(var c,h=Number.POSITIVE_INFINITY,l=(o=0,0);l<4;++o,++l)hy(o%2?a:s,o%4>=2,!1,e),u=dv(t),(d=ty(t,u))<h&&(l=0,c=Zt(u),h=d);for(u=Qv(t),ly(t,u),o=0,l=0;l<4;++o,++l){var d;hy(o%2?a:s,o%4>=2,!0,e),u=dv(t),(d=ty(t,u))<h&&(l=0,c=Zt(u),h=d)}ly(t,c)}(t,u),Gy(t),function(t,e){var n=e.toLowerCase();"lr"!==n&&"rl"!==n||qv(t)}(t,a),xy(t,{align:l,nodesep:f,edgesep:g,ranksep:v}),jy(t),Fy(t),function(t,e){e.forEach((function(e){var n,r=t.getNode(e),i=r.data.originalEdge;i&&t.addEdge(i);for(var o=e;r.data.dummy;)n=t.getSuccessors(o)[0],t.removeNode(o),i.data.points.push({x:r.data.x,y:r.data.y}),r.data.dummy===yv&&(i.data.x=r.data.x,i.data.y=r.data.y,i.data.width=r.data.width,i.data.height=r.data.height),o=n.id,r=t.getNode(o)}))}(t,b),_y(t),function(t,e){var n=e.toLowerCase();"bt"!==n&&"rl"!==n||Xv(t),"lr"!==n&&"rl"!==n||($v(t),qv(t))}(t,a);var w=Iy(t),M=w.width,N=w.height;return Ly(t),zy(t),function(t){t.getAllEdges().forEach((function(e){var n=e.data;if(n.reversed){t.removeEdge(e.id);var r=n.forwardName;delete n.reversed,delete n.forwardName,t.addEdge({id:e.id,source:e.target,target:e.source,data:i(i({},n),{forwardName:r})})}}))}(t),{width:M,height:N}},wy=function(t,e){t.getAllNodes().forEach((function(n){var r=t.getNode(n.id);if(e.hasNode(n.id)){var i=e.getNode(n.id);r.data.fixorder=i.data._order,delete i.data._order}else delete r.data.fixorder}))},My=function(t,e){t.getAllNodes().forEach((function(n){var r,i=t.getNode(n.id);if(i){var o=e.getNode(n.id);i.data.x=o.data.x,i.data.y=o.data.y,i.data._order=o.data.order,i.data._rank=o.data.rank,(null===(r=e.getChildren(n.id))||void 0===r?void 0:r.length)&&(i.data.width=o.data.width,i.data.height=o.data.height)}})),t.getAllEdges().forEach((function(n){var r=t.getEdge(n.id),i=e.getEdge(n.id);r.data.points=i?i.data.points:[],i&&i.data.hasOwnProperty("x")&&(r.data.x=i.data.x,r.data.y=i.data.y)}))},Ny=["width","height","layer","fixorder"],Sy={width:0,height:0},Ty=["minlen","weight","width","height","labeloffset"],Py={minlen:1,weight:1,width:0,height:0,labeloffset:10,labelpos:"r"},Cy=["labelpos"],ky=function(t){var e=new Cp({tree:[]});return t.getAllNodes().forEach((function(n){var r=Uy(t.getNode(n.id).data),o=i(i({},Sy),r),a=Vy(o,Ny);e.hasNode(n.id)||e.addNode({id:n.id,data:i({},a)});var s=t.hasTreeStructure("combo")?t.getParent(n.id,"combo"):t.getParent(n.id);Pt(s)||(e.hasNode(s.id)||e.addNode(i({},s)),e.setParent(n.id,s.id))})),t.getAllEdges().forEach((function(n){var r=Uy(t.getEdge(n.id).data),i={};null==Cy||Cy.forEach((function(t){void 0!==r[t]&&(i[t]=r[t])})),e.addEdge({id:n.id,source:n.source,target:n.target,data:Object.assign({},Py,Vy(r,Ty),i)})})),e},Ay=function(t,e){var n=e.ranksep,r=void 0===n?0:n,i=e.rankdir;return t.getAllNodes().forEach((function(t){isNaN(t.data.layer)||t.data.layer||(t.data.layer=0)})),t.getAllEdges().forEach((function(t){var e;t.data.minlen*=2,"c"!==(null===(e=t.data.labelpos)||void 0===e?void 0:e.toLowerCase())&&("TB"===i||"BT"===i?t.data.width+=t.data.labeloffset:t.data.height+=t.data.labeloffset)})),r/2},Oy=function(t){t.getAllEdges().forEach((function(e){if(e.data.width&&e.data.height){var n=t.getNode(e.source),r={e:e,rank:(t.getNode(e.target).data.rank-n.data.rank)/2+n.data.rank};cv(t,"edge-proxy",r,"_ep")}}))},Ry=function(t){var e=0;return t.getAllNodes().forEach((function(n){var r,i;n.data.borderTop&&(n.data.minRank=null===(r=t.getNode(n.data.borderTop))||void 0===r?void 0:r.data.rank,n.data.maxRank=null===(i=t.getNode(n.data.borderBottom))||void 0===i?void 0:i.data.rank,e=Math.max(e,n.data.maxRank||-1/0))})),e},Dy=function(t){t.getAllNodes().forEach((function(e){"edge-proxy"===e.data.dummy&&(t.getEdge(e.data.e.id).data.labelRank=e.data.rank,t.removeNode(e.id))}))},Iy=function(t,e){var n,r,i=0,o=0,a=e||{},s=a.marginx,u=void 0===s?0:s,c=a.marginy,h=void 0===c?0:c,l=function(t){if(t.data){var e=t.data.x,a=t.data.y,s=t.data.width,u=t.data.height;isNaN(e)||isNaN(s)||(void 0===n&&(n=e-s/2),n=Math.min(n,e-s/2),i=Math.max(i,e+s/2)),isNaN(a)||isNaN(u)||(void 0===r&&(r=a-u/2),r=Math.min(r,a-u/2),o=Math.max(o,a+u/2))}};return t.getAllNodes().forEach((function(t){l(t)})),t.getAllEdges().forEach((function(t){(null==t?void 0:t.data.hasOwnProperty("x"))&&l(t)})),n-=u,r-=h,t.getAllNodes().forEach((function(t){t.data.x-=n,t.data.y-=r})),t.getAllEdges().forEach((function(t){var e;null===(e=t.data.points)||void 0===e||e.forEach((function(t){t.x-=n,t.y-=r})),t.data.hasOwnProperty("x")&&(t.data.x-=n),t.data.hasOwnProperty("y")&&(t.data.y-=r)})),{width:i-n+u,height:o-r+h}},Ly=function(t){t.getAllEdges().forEach((function(e){var n,r,i=t.getNode(e.source),o=t.getNode(e.target);e.data.points?(n=e.data.points[0],r=e.data.points[e.data.points.length-1]):(e.data.points=[],n={x:o.data.x,y:o.data.y},r={x:i.data.x,y:i.data.y}),e.data.points.unshift(lv(i.data,n)),e.data.points.push(lv(o.data,r))}))},_y=function(t){t.getAllEdges().forEach((function(t){if(t.data.hasOwnProperty("x"))switch("l"!==t.data.labelpos&&"r"!==t.data.labelpos||(t.data.width-=t.data.labeloffset),t.data.labelpos){case"l":t.data.x-=t.data.width/2+t.data.labeloffset;break;case"r":t.data.x+=t.data.width/2+t.data.labeloffset}}))},zy=function(t){t.getAllEdges().forEach((function(t){var e;t.data.reversed&&(null===(e=t.data.points)||void 0===e||e.reverse())}))},Fy=function(t){t.getAllNodes().forEach((function(e){var n,r,i;if(null===(n=t.getChildren(e.id))||void 0===n?void 0:n.length){var o=t.getNode(e.id),a=t.getNode(o.data.borderTop),s=t.getNode(o.data.borderBottom),u=t.getNode(o.data.borderLeft[(null===(r=o.data.borderLeft)||void 0===r?void 0:r.length)-1]),c=t.getNode(o.data.borderRight[(null===(i=o.data.borderRight)||void 0===i?void 0:i.length)-1]);o.data.width=Math.abs((null==c?void 0:c.data.x)-(null==u?void 0:u.data.x))||10,o.data.height=Math.abs((null==s?void 0:s.data.y)-(null==a?void 0:a.data.y))||10,o.data.x=((null==u?void 0:u.data.x)||0)+o.data.width/2,o.data.y=((null==a?void 0:a.data.y)||0)+o.data.height/2}})),t.getAllNodes().forEach((function(e){"border"===e.data.dummy&&t.removeNode(e.id)}))},By=function(t){t.getAllEdges().forEach((function(e){if(e.source===e.target){var n=t.getNode(e.source);n.data.selfEdges||(n.data.selfEdges=[]),n.data.selfEdges.push(e),t.removeEdge(e.id)}}))},Gy=function(t){var e=dv(t);null==e||e.forEach((function(e){var n=0;null==e||e.forEach((function(e,r){var i,o=t.getNode(e);o.data.order=r+n,null===(i=o.data.selfEdges)||void 0===i||i.forEach((function(e){cv(t,"selfedge",{width:e.data.width,height:e.data.height,rank:o.data.rank,order:r+ ++n,e:e},"_se")})),delete o.data.selfEdges}))}))},jy=function(t){t.getAllNodes().forEach((function(e){var n=t.getNode(e.id);if("selfedge"===n.data.dummy){var r=t.getNode(n.data.e.source),i=r.data.x+r.data.width/2,o=r.data.y,a=n.data.x-i,s=r.data.height/2;t.hasEdge(n.data.e.id)?t.updateEdgeData(n.data.e.id,n.data.e.data):t.addEdge({id:n.data.e.id,source:n.data.e.source,target:n.data.e.target,data:n.data.e.data}),t.removeNode(e.id),n.data.e.data.points=[{x:i+2*a/3,y:o-s},{x:i+5*a/6,y:o-s},{y:o,x:i+a},{x:i+5*a/6,y:o+s},{x:i+2*a/3,y:o+s}],n.data.e.data.x=n.data.x,n.data.e.data.y=n.data.y}}))},Vy=function(t,e){var n={};return null==e||e.forEach((function(e){void 0!==t[e]&&(n[e]=+t[e])})),n},Uy=function(t){void 0===t&&(t={});var e={};return Object.keys(t).forEach((function(n){e[n.toLowerCase()]=t[n]})),e},Wy={rankdir:"TB",nodesep:50,ranksep:50,edgeLabelSpace:!0,ranker:"tight-tree",controlPoints:!1,radial:!1,focusNode:null},Hy=function(){function t(t){void 0===t&&(t={}),this.options=t,this.id="dagre",this.options=i(i({},Wy),t)}return t.prototype.execute=function(t,e){return a(this,void 0,void 0,(function(){return s(this,(function(n){return[2,this.genericDagreLayout(!1,t,e)]}))}))},t.prototype.assign=function(t,e){return a(this,void 0,void 0,(function(){return s(this,(function(n){switch(n.label){case 0:return[4,this.genericDagreLayout(!0,t,e)];case 1:return n.sent(),[2]}}))}))},t.prototype.genericDagreLayout=function(t,e,n){return a(this,void 0,void 0,(function(){var r,o,a,u,c,h,l,d,f,p,g,m,v,y,E,x,b,w,M,N,S,T,P,C,k,A,O,R,D,I,L,_,z,F,B,G,j;return s(this,(function(s){return r=i(i({},this.options),n),o=r.nodeSize,a=r.align,u=r.rankdir,c=void 0===u?"TB":u,h=r.ranksep,l=r.nodesep,d=r.ranksepFunc,f=r.nodesepFunc,p=r.edgeLabelSpace,g=r.ranker,m=r.nodeOrder,v=r.begin,y=r.controlPoints,E=r.radial,x=r.sortByCombo,b=r.preset,w=new Cp({tree:[]}),M=Xf(h||50,d),N=Xf(l||50,f),S=N,T=M,"LR"!==c&&"RL"!==c||(S=M,T=N),P=$f(o,void 0),C=e.getAllNodes(),k=e.getAllEdges(),C.forEach((function(t){var e=P(t),n=T(t),r=e+2*S(t),i=e+2*n,o=t.data.layer;jt(o)?w.addNode({id:t.id,data:{width:r,height:i,layer:o}}):w.addNode({id:t.id,data:{width:r,height:i}})})),x&&(w.attachTreeStructure("combo"),C.forEach((function(t){var e=t.data.parentId;void 0!==e&&w.hasNode(e)&&w.setParent(t.id,e,"combo")}))),k.forEach((function(t){w.addEdge({id:t.id,source:t.source,target:t.target,data:{weight:t.data.weight||1}})})),A=void 0,(null==b?void 0:b.length)&&(A=new Cp({nodes:b})),function(t,e){var n=e.edgeLabelSpace,r=e.keepNodeOrder,i=e.prevGraph,o=e.rankdir,a=e.ranksep;!r&&i&&wy(t,i);var s,u=ky(t);n&&(e.ranksep=Ay(u,{rankdir:o,ranksep:a}));try{s=by(u,e)}catch(t){if("Not possible to find intersection inside of the rectangle"===t.message)return void console.error("The following error may be caused by improper layer setting, please make sure your manual layer setting does not violate the graph's structure:\n",t);throw t}My(t,u)}(w,{prevGraph:A,edgeLabelSpace:p,keepNodeOrder:!!m,nodeOrder:m||[],acyclicer:"greedy",ranker:g,rankdir:c,nodesep:l,align:a}),O=[0,0],v&&(R=1/0,D=1/0,w.getAllNodes().forEach((function(t){R>t.data.x&&(R=t.data.x),D>t.data.y&&(D=t.data.y)})),w.getAllEdges().forEach((function(t){var e;null===(e=t.data.points)||void 0===e||e.forEach((function(t){R>t.x&&(R=t.x),D>t.y&&(D=t.y)}))})),O[0]=v[0]-R,O[1]=v[1]-D),I="LR"===c||"RL"===c,E||(L=new Set,_="BT"===c||"RL"===c?function(t,e){return e-t}:function(t,e){return t-e},w.getAllNodes().forEach((function(t){t.data.x=t.data.x+O[0],t.data.y=t.data.y+O[1],L.add(I?t.data.x:t.data.y)})),z=Array.from(L).sort(_),F=I?function(t,e){return t.x!==e.x}:function(t,e){return t.y!==e.y},B=I?function(t,e,n){var r=Math.max(e.y,n.y),i=Math.min(e.y,n.y);return t.filter((function(t){return t.y<=r&&t.y>=i}))}:function(t,e,n){var r=Math.max(e.x,n.x),i=Math.min(e.x,n.x);return t.filter((function(t){return t.x<=r&&t.x>=i}))},w.getAllEdges().forEach((function(t,e){var n;p&&y&&"loop"!==t.data.type&&(t.data.controlPoints=qy(null===(n=t.data.points)||void 0===n?void 0:n.map((function(t){var e=t.x,n=t.y;return{x:e+O[0],y:n+O[1]}})),w.getNode(t.source),w.getNode(t.target),z,I,F,B))}))),G=[],G=w.getAllNodes().map((function(t){return Yf(t)})),j=w.getAllEdges(),t&&(G.forEach((function(t){e.mergeNodeData(t.id,{x:t.data.x,y:t.data.y})})),j.forEach((function(t){e.mergeEdgeData(t.id,{controlPoints:t.data.controlPoints})}))),[2,{nodes:G,edges:j}]}))}))},t}(),qy=function(t,e,n,r,i,o,a){var s=(null==t?void 0:t.slice(1,t.length-1))||[];if(e&&n){var u=e.data,c=u.x,h=u.y,l=n.data,d=l.x,f=l.y;if(i&&(c=e.data.y,h=e.data.x,d=n.data.y,f=n.data.x),f!==h&&c!==d){var p=r.indexOf(h),g=r[p+1];if(g){var m=s[0],v=i?{x:(h+g)/2,y:(null==m?void 0:m.y)||d}:{x:(null==m?void 0:m.x)||d,y:(h+g)/2};m&&!o(m,v)||s.unshift(v)}var y=r.indexOf(f),E=Math.abs(y-p);if(1===E)(s=a(s,e.data,n.data)).length||s.push(i?{x:(h+f)/2,y:c}:{x:c,y:(h+f)/2});else if(E>1){var x=r[y-1];if(x){var b=s[s.length-1],w=i?{x:(f+x)/2,y:(null==b?void 0:b.y)||d}:{x:(null==b?void 0:b.x)||c,y:(f+x)/2};b&&!o(b,w)||s.push(w)}}}}return s},Yy=function(){function t(t){this.id=t.id||0,this.rx=t.rx,this.ry=t.ry,this.fx=0,this.fy=0,this.mass=t.mass,this.degree=t.degree,this.g=t.g||0}return t.prototype.distanceTo=function(t){var e=this.rx-t.rx,n=this.ry-t.ry;return Math.hypot(e,n)},t.prototype.setPos=function(t,e){this.rx=t,this.ry=e},t.prototype.resetForce=function(){this.fx=0,this.fy=0},t.prototype.addForce=function(t){var e=t.rx-this.rx,n=t.ry-this.ry,r=Math.hypot(e,n);r=r<1e-4?1e-4:r;var i=this.g*(this.degree+1)*(t.degree+1)/r;this.fx+=i*e/r,this.fy+=i*n/r},t.prototype.in=function(t){return t.contains(this.rx,this.ry)},t.prototype.add=function(e){var n=this.mass+e.mass;return new t({rx:(this.rx*this.mass+e.rx*e.mass)/n,ry:(this.ry*this.mass+e.ry*e.mass)/n,mass:n,degree:this.degree+e.degree})},t}(),Xy=function(){function t(t){this.xmid=t.xmid,this.ymid=t.ymid,this.length=t.length,this.massCenter=t.massCenter||[0,0],this.mass=t.mass||1}return t.prototype.getLength=function(){return this.length},t.prototype.contains=function(t,e){var n=this.length/2;return t<=this.xmid+n&&t>=this.xmid-n&&e<=this.ymid+n&&e>=this.ymid-n},t.prototype.NW=function(){return new t({xmid:this.xmid-this.length/4,ymid:this.ymid+this.length/4,length:this.length/2})},t.prototype.NE=function(){return new t({xmid:this.xmid+this.length/4,ymid:this.ymid+this.length/4,length:this.length/2})},t.prototype.SW=function(){return new t({xmid:this.xmid-this.length/4,ymid:this.ymid-this.length/4,length:this.length/2})},t.prototype.SE=function(){return new t({xmid:this.xmid+this.length/4,ymid:this.ymid-this.length/4,length:this.length/2})},t}(),Ky=function(){function t(t){this.body=null,this.quad=null,this.NW=null,this.NE=null,this.SW=null,this.SE=null,this.theta=.5,null!=t&&(this.quad=t)}return t.prototype.insert=function(e){null!=this.body?this._isExternal()?(this.quad&&(this.NW=new t(this.quad.NW()),this.NE=new t(this.quad.NE()),this.SW=new t(this.quad.SW()),this.SE=new t(this.quad.SE())),this._putBody(this.body),this._putBody(e),this.body=this.body.add(e)):(this.body=this.body.add(e),this._putBody(e)):this.body=e},t.prototype._putBody=function(t){this.quad&&(t.in(this.quad.NW())&&this.NW?this.NW.insert(t):t.in(this.quad.NE())&&this.NE?this.NE.insert(t):t.in(this.quad.SW())&&this.SW?this.SW.insert(t):t.in(this.quad.SE())&&this.SE&&this.SE.insert(t))},t.prototype._isExternal=function(){return null==this.NW&&null==this.NE&&null==this.SW&&null==this.SE},t.prototype.updateForce=function(t){null!=this.body&&t!==this.body&&(this._isExternal()||(this.quad?this.quad.getLength():0)/this.body.distanceTo(t)<this.theta?t.addForce(this.body):(this.NW&&this.NW.updateForce(t),this.NE&&this.NE.updateForce(t),this.SW&&this.SW.updateForce(t),this.SE&&this.SE.updateForce(t)))},t}(),$y={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},Zy=function(){function t(t){void 0===t&&(t={}),this.options=t,this.id="forceAtlas2",this.options=i(i({},$y),t)}return t.prototype.execute=function(t,e){return a(this,void 0,void 0,(function(){return s(this,(function(n){return[2,this.genericForceAtlas2Layout(!1,t,e)]}))}))},t.prototype.assign=function(t,e){return a(this,void 0,void 0,(function(){return s(this,(function(n){return this.genericForceAtlas2Layout(!0,t,e),[2]}))}))},t.prototype.genericForceAtlas2Layout=function(t,e,n){return a(this,void 0,void 0,(function(){var r,o,a,u,c,h,l,d,f,p,g,m,v,y,E,x,b,w,M,N,S,T;return s(this,(function(s){if(r=e.getAllEdges(),o=e.getAllNodes(),a=this.formatOptions(n,o.length),u=a.width,c=a.height,h=a.prune,l=a.maxIteration,d=a.nodeSize,f=a.center,!(null==o?void 0:o.length)||1===o.length)return[2,Zf(e,t,f)];if(p=o.map((function(t){return Yf(t,[u,c])})),g=r.filter((function(t){return t.source!==t.target})),m=new Cp({nodes:p,edges:g}),v=this.getSizes(m,e,d),this.run(m,e,l,v,t,a),h){for(y=0;y<g.length;y+=1)E=g[y],x=E.source,b=E.target,w=m.getDegree(x),M=m.getDegree(x),w<=1?(N=m.getNode(b),m.mergeNodeData(x,{x:N.data.x,y:N.data.y})):M<=1&&(S=m.getNode(x),m.mergeNodeData(b,{x:S.data.x,y:S.data.y}));T=i(i({},a),{prune:!1,barnesHut:!1}),this.run(m,e,100,v,t,T)}return[2,{nodes:p,edges:r}]}))}))},t.prototype.getSizes=function(t,e,n){for(var r=t.getAllNodes(),i={},o=0;o<r.length;o+=1){var a=r[o],s=a.id,u=a.data;if(i[s]=10,jt(u.size))i[s]=u.size;else if(jf(u.size))isNaN(u.size[0])||(i[s]=Math.max(u.size[0])),isNaN(u.size[1])||(i[s]=Math.max(u.size[1]));else if(Ot(u.size))i[s]=Math.max(u.size.width,u.size.height);else if(Tt(n)){var l=n(e.getNode(s));jf(l)?i[s]=Math.max.apply(Math,h([],c(l))):i[s]=l}else jf(n)?i[s]=Math.max.apply(Math,h([],c(n))):jt(n)&&(i[s]=n)}return i},t.prototype.formatOptions=function(t,e){void 0===t&&(t={});var n=i(i({},this.options),t),r=n.center,o=n.width,a=n.height,s=n.barnesHut,u=n.prune,c=n.maxIteration,h=n.kr,l=n.kg;return n.width=o||"undefined"==typeof window?o:window.innerWidth,n.height=a||"undefined"==typeof window?a:window.innerHeight,n.center=r||[n.width/2,n.height/2],void 0===s&&e>250&&(n.barnesHut=!0),void 0===u&&e>100&&(n.prune=!0),0!==c||u?0===c&&u&&(n.maxIteration=100,e<=200&&e>100?n.maxIteration=500:e>200&&(n.maxIteration=950)):(n.maxIteration=250,e<=200&&e>100?n.maxIteration=1e3:e>200&&(n.maxIteration=1200)),h||(n.kr=50,e>100&&e<=500?n.kr=20:e>500&&(n.kr=1)),l||(n.kg=20,e>100&&e<=500?n.kg=10:e>500&&(n.kg=1)),n},t.prototype.run=function(t,e,n,r,i,o){for(var a=o.kr,s=o.barnesHut,u=o.onTick,c=t.getAllNodes(),h=0,l=n,d={},f={},p={},g=0;g<c.length;g+=1){var m=c[g],v=m.data,y=m.id;if(d[y]=[0,0],s){var E={id:g,rx:v.x,ry:v.y,mass:1,g:a,degree:t.getDegree(y)};p[y]=new Yy(E)}}for(;l>0;)h=this.oneStep(t,{iter:l,preventOverlapIters:50,krPrime:100,sg:h,forces:d,preForces:f,bodies:p,sizes:r},o),l--,null==u||u({nodes:c,edges:e.getAllEdges()});return t},t.prototype.oneStep=function(t,e,n){for(var r=e.iter,i=e.preventOverlapIters,o=e.krPrime,a=e.sg,s=e.preForces,u=e.bodies,l=e.sizes,d=e.forces,f=n.preventOverlap,p=n.barnesHut,g=t.getAllNodes(),m=0;m<g.length;m+=1){var v=g[m].id;s[v]=h([],c(d[v])),d[v]=[0,0]}return d=this.getAttrForces(t,r,i,l,d,n),d=p&&(f&&r>i||!f)?this.getOptRepGraForces(t,d,u,n):this.getRepGraForces(t,r,i,d,o,l,n),this.updatePos(t,d,s,a,n)},t.prototype.getAttrForces=function(t,e,n,r,i,o){for(var a=o.preventOverlap,s=o.dissuadeHubs,u=o.mode,c=o.prune,h=t.getAllEdges(),l=0;l<h.length;l+=1){var d=h[l],f=d.source,p=d.target,g=t.getNode(f),m=t.getNode(p),v=t.getDegree(f),y=t.getDegree(p);if(!c||!(v<=1||y<=1)){var E=[m.data.x-g.data.x,m.data.y-g.data.y],x=Math.hypot(E[0],E[1]);x=x<1e-4?1e-4:x,E[0]=E[0]/x,E[1]=E[1]/x,a&&e<n&&(x=x-r[f]-r[p]);var b=x,w=b;"linlog"===u&&(w=b=Math.log(1+x)),s&&(b=x/v,w=x/y),a&&e<n&&x<=0?(b=0,w=0):a&&e<n&&x>0&&(b=x,w=x),i[f][0]+=b*E[0],i[p][0]-=w*E[0],i[f][1]+=b*E[1],i[p][1]-=w*E[1]}}return i},t.prototype.getOptRepGraForces=function(t,e,n,r){for(var i=r.kg,o=r.center,a=r.prune,s=t.getAllNodes(),u=s.length,c=9e10,h=-9e10,l=9e10,d=-9e10,f=0;f<u;f+=1){var p=s[f],g=p.id,m=p.data;a&&t.getDegree(g)<=1||(n[g].setPos(m.x,m.y),m.x>=h&&(h=m.x),m.x<=c&&(c=m.x),m.y>=d&&(d=m.y),m.y<=l&&(l=m.y))}var v=Math.max(h-c,d-l),y=new Xy({xmid:(h+c)/2,ymid:(d+l)/2,length:v,massCenter:o,mass:u}),E=new Ky(y);for(f=0;f<u;f+=1){g=s[f].id;a&&t.getDegree(g)<=1||n[g].in(y)&&E.insert(n[g])}for(f=0;f<u;f+=1){var x=s[f],b=(g=x.id,m=x.data,t.getDegree(g));if(!(a&&b<=1)){n[g].resetForce(),E.updateForce(n[g]),e[g][0]-=n[g].fx,e[g][1]-=n[g].fy;var w=[m.x-o[0],m.y-o[1]],M=Math.hypot(w[0],w[1]);M=M<1e-4?1e-4:M,w[0]=w[0]/M,w[1]=w[1]/M;var N=i*(b+1);e[g][0]-=N*w[0],e[g][1]-=N*w[1]}}return e},t.prototype.getRepGraForces=function(t,e,n,r,i,o,a){for(var s=a.preventOverlap,u=a.kr,c=a.kg,h=a.center,l=a.prune,d=t.getAllNodes(),f=d.length,p=0;p<f;p+=1){for(var g=d[p],m=t.getDegree(g.id),v=p+1;v<f;v+=1){var y=d[v],E=t.getDegree(y.id);if(!l||!(m<=1||E<=1)){var x=[y.data.x-g.data.x,y.data.y-g.data.y],b=Math.hypot(x[0],x[1]);b=b<1e-4?1e-4:b,x[0]=x[0]/b,x[1]=x[1]/b,s&&e<n&&(b=b-o[g.id]-o[y.id]);var w=u*(m+1)*(E+1)/b;s&&e<n&&b<0?w=i*(m+1)*(E+1):s&&e<n&&0===b?w=0:s&&e<n&&b>0&&(w=u*(m+1)*(E+1)/b),r[g.id][0]-=w*x[0],r[y.id][0]+=w*x[0],r[g.id][1]-=w*x[1],r[y.id][1]+=w*x[1]}}var M=[g.data.x-h[0],g.data.y-h[1]],N=Math.hypot(M[0],M[1]);M[0]=M[0]/N,M[1]=M[1]/N;var S=c*(m+1);r[g.id][0]-=S*M[0],r[g.id][1]-=S*M[1]}return r},t.prototype.updatePos=function(t,e,n,r,i){for(var o=i.ks,a=i.tao,s=i.prune,u=i.ksmax,c=t.getAllNodes(),h=c.length,l=[],d=[],f=0,p=0,g=r,m=0;m<h;m+=1){var v=c[m].id,y=t.getDegree(v);if(!(s&&y<=1)){var E=[e[v][0]-n[v][0],e[v][1]-n[v][1]],x=Math.hypot(E[0],E[1]),b=[e[v][0]+n[v][0],e[v][1]+n[v][1]],w=Math.hypot(b[0],b[1]);l[m]=x,d[m]=w/2,f+=(y+1)*l[m],p+=(y+1)*d[m]}}var M=g;g=a*p/f,0!==M&&(g=g>1.5*M?1.5*M:g);for(m=0;m<h;m+=1){var N=c[m],S=(v=N.id,N.data);y=t.getDegree(v);if(!(s&&y<=1)&&(!jt(S.fx)||!jt(S.fy))){var T=o*g/(1+g*Math.sqrt(l[m])),P=Math.hypot(e[v][0],e[v][1]),C=u/(P=P<1e-4?1e-4:P),k=(T=T>C?C:T)*e[v][0],A=T*e[v][1];t.mergeNodeData(v,{x:S.x+k,y:S.y+A})}}return g},t}(),Qy={maxIteration:1e3,gravity:10,speed:5,clustering:!1,clusterGravity:10,width:300,height:300,nodeClusterBy:"cluster"},Jy=function(){function t(t){void 0===t&&(t={}),this.options=t,this.id="fruchterman",this.timeInterval=0,this.running=!1,this.options=i(i({},Qy),t)}return t.prototype.execute=function(t,e){return a(this,void 0,void 0,(function(){return s(this,(function(n){return[2,this.genericFruchtermanLayout(!1,t,e)]}))}))},t.prototype.assign=function(t,e){return a(this,void 0,void 0,(function(){return s(this,(function(n){return this.genericFruchtermanLayout(!0,t,e),[2]}))}))},t.prototype.stop=function(){this.timeInterval&&"undefined"!=typeof window&&window.clearInterval(this.timeInterval),this.running=!1},t.prototype.tick=function(t){var e=this;if(void 0===t&&(t=this.options.maxIteration||1),this.lastResult)return this.lastResult;for(var n=0;n<t;n++)this.runOneStep(this.lastGraph,this.lastClusterMap,this.lastOptions);var r={nodes:this.lastLayoutNodes,edges:this.lastLayoutEdges};return this.lastAssign&&r.nodes.forEach((function(t){return e.lastGraph.mergeNodeData(t.id,{x:t.data.x,y:t.data.y,z:3===e.options.dimensions?t.data.z:void 0})})),r},t.prototype.genericFruchtermanLayout=function(t,e,n){return a(this,void 0,void 0,(function(){var r,o,a,u,c,h,l,d,f,p,g,m,v,y,E,x,b=this;return s(this,(function(s){return this.running?[2]:(r=this.formatOptions(n),o=r.dimensions,a=r.width,u=r.height,c=r.center,h=r.clustering,l=r.nodeClusterBy,d=r.maxIteration,f=r.onTick,p=e.getAllNodes(),g=e.getAllEdges(),(null==p?void 0:p.length)?1===p.length?(t&&e.mergeNodeData(p[0].id,{x:c[0],y:c[1],z:3===o?c[2]:void 0}),m={nodes:[i(i({},p[0]),{data:i(i({},p[0].data),{x:c[0],y:c[1],z:3===o?c[2]:void 0})})],edges:g},this.lastResult=m,[2,m]):(v=p.map((function(t){return Yf(t,[a,u])})),y=new Cp({nodes:v,edges:g}),E={},h&&v.forEach((function(t){var e=t.data[l];E[e]||(E[e]={name:e,cx:0,cy:0,count:0})})),this.lastLayoutNodes=v,this.lastLayoutEdges=g,this.lastAssign=t,this.lastGraph=y,this.lastOptions=r,this.lastClusterMap=E,"undefined"==typeof window?[2]:(x=0,[2,new Promise((function(n){b.timeInterval=window.setInterval((function(){b.running?(b.runOneStep(y,E,r),t&&v.forEach((function(t){var n=t.id,r=t.data;return e.mergeNodeData(n,{x:r.x,y:r.y,z:3===o?r.z:void 0})})),null==f||f({nodes:v,edges:g}),++x>=d&&(window.clearInterval(b.timeInterval),n({nodes:v,edges:g}))):n({nodes:v,edges:g})}),0),b.running=!0}))])):(m={nodes:[],edges:g},this.lastResult=m,[2,m]))}))}))},t.prototype.formatOptions=function(t){void 0===t&&(t={});var e=i(i({},this.options),t),n=e.clustering,r=e.nodeClusterBy,o=e.center,a=e.width,s=e.height;return e.width=a||"undefined"==typeof window?a:window.innerWidth,e.height=s||"undefined"==typeof window?s:window.innerHeight,e.center=o||[e.width/2,e.height/2],e.clustering=n&&!!r,e},t.prototype.runOneStep=function(t,e,n){var r=n.dimensions,i=n.height,o=n.width,a=n.gravity,s=n.center,u=n.speed,c=n.clustering,h=n.nodeClusterBy,l=n.clusterGravity,d=i*o,f=Math.sqrt(d)/10,p=t.getAllNodes(),g=d/(p.length+1),m=Math.sqrt(g),v={};if(this.applyCalculate(t,v,m,g),c){for(var y in e)e[y].cx=0,e[y].cy=0,e[y].count=0;for(var y in p.forEach((function(t){var n=t.data,r=e[n[h]];jt(n.x)&&(r.cx+=n.x),jt(n.y)&&(r.cy+=n.y),r.count++})),e)e[y].cx/=e[y].count,e[y].cy/=e[y].count;var E=l||a;p.forEach((function(t,n){var r=t.id,i=t.data;if(jt(i.x)&&jt(i.y)){var o=e[i[h]],a=Math.sqrt((i.x-o.cx)*(i.x-o.cx)+(i.y-o.cy)*(i.y-o.cy)),s=m*E;v[r].x-=s*(i.x-o.cx)/a,v[r].y-=s*(i.y-o.cy)/a}}))}p.forEach((function(t,e){var n=t.id,i=t.data;if(jt(i.x)&&jt(i.y)){var o=.01*m*a;v[n].x-=o*(i.x-s[0]),v[n].y-=o*(i.y-s[1]),3===r&&(v[n].z-=o*(i.z-s[2]))}})),p.forEach((function(e,n){var i=e.id,o=e.data;if(jt(o.fx)&&jt(o.fy))return o.x=o.fx,o.y=o.fy,void(3===r&&(o.z=o.fz));if(jt(o.x)&&jt(o.y)){var a=Math.sqrt(v[i].x*v[i].x+v[i].y*v[i].y+(3===r?v[i].z*v[i].z:0));if(a>0){var s=Math.min(f*(u/800),a);t.mergeNodeData(i,{x:o.x+v[i].x/a*s,y:o.y+v[i].y/a*s,z:3===r?o.z+v[i].z/a*s:void 0})}}}))},t.prototype.applyCalculate=function(t,e,n,r){this.calRepulsive(t,e,r),this.calAttractive(t,e,n)},t.prototype.calRepulsive=function(t,e,n){var r=this,i=t.getAllNodes();i.forEach((function(t,o){var a=t.data,s=t.id;e[s]={x:0,y:0,z:0},i.forEach((function(t,i){var u=t.data,c=t.id;if(!(o<=i)&&jt(a.x)&&jt(u.x)&&jt(a.y)&&jt(u.y)){var h=a.x-u.x,l=a.y-u.y,d=3===r.options.dimensions?a.z-u.z:0,f=h*h+l*l+d*d;0===f&&(f=1,h=.01,l=.01,d=.01);var p=n/f,g=h*p,m=l*p,v=d*p;e[s].x+=g,e[s].y+=m,e[c].x-=g,e[c].y-=m,3===r.options.dimensions&&(e[s].z+=v,e[c].z-=v)}}))}))},t.prototype.calAttractive=function(t,e,n){var r=this;t.getAllEdges().forEach((function(i){var o=i.source,a=i.target;if(o&&a&&o!==a){var s=t.getNode(o).data,u=t.getNode(a).data;if(jt(u.x)&&jt(s.x)&&jt(u.y)&&jt(s.y)){var c=u.x-s.x,h=u.y-s.y,l=3===r.options.dimensions?u.z-s.z:0,d=Math.sqrt(c*c+h*h+l*l)/n,f=c*d,p=h*d,g=l*d;e[o].x+=f,e[o].y+=p,e[a].x-=f,e[a].y-=p,3===r.options.dimensions&&(e[o].z+=g,e[a].z-=g)}}}))},t}(),tE={begin:[0,0],preventOverlap:!0,preventOverlapPadding:10,condense:!1,rows:void 0,cols:void 0,position:void 0,sortBy:"degree",nodeSize:30,width:300,height:300},eE=function(){function t(t){void 0===t&&(t={}),this.options=t,this.id="grid",this.options=i(i({},tE),t)}return t.prototype.execute=function(t,e){return a(this,void 0,void 0,(function(){return s(this,(function(n){return[2,this.genericGridLayout(!1,t,e)]}))}))},t.prototype.assign=function(t,e){return a(this,void 0,void 0,(function(){return s(this,(function(n){return this.genericGridLayout(!0,t,e),[2]}))}))},t.prototype.genericGridLayout=function(t,e,n){return a(this,void 0,void 0,(function(){var r,o,a,u,c,h,l,d,f,p,g,m,v,y,E,x,b,w,M,N,S,T,P,C,k,A,O,R,D,I,L,_,z,F,B,G,j;return s(this,(function(s){if(r=i(i({},this.options),n),o=r.begin,a=void 0===o?[0,0]:o,u=r.condense,c=r.preventOverlapPadding,h=r.preventOverlap,l=r.rows,d=r.cols,f=r.nodeSpacing,p=r.nodeSize,g=r.width,m=r.height,v=r.position,y=r.sortBy,E=e.getAllNodes(),x=e.getAllEdges(),!(b=null==E?void 0:E.length)||1===b)return[2,Zf(e,t,a)];if(w=E.map((function(t){return Yf(t)})),"id"===y||zt(y)&&void 0!==w[0].data[y]||(y="degree"),"degree"===y?w.sort((function(t,n){return e.getDegree(n.id,"both")-e.getDegree(t.id,"both")})):"id"===y?w.sort((function(t,e){return jt(e.id)&&jt(t.id)?e.id-t.id:(""+t.id).localeCompare(""+e.id)})):w.sort((function(t,e){return e.data[y]-t.data[y]})),M=g||"undefined"==typeof window?g:window.innerWidth,N=m||"undefined"==typeof window?m:window.innerHeight,S=b,T={rows:l,cols:d},null!=l&&null!=d?(T.rows=l,T.cols=d):null!=l&&null==d?(T.rows=l,T.cols=Math.ceil(S/T.rows)):null==l&&null!=d?(T.cols=d,T.rows=Math.ceil(S/T.cols)):(P=Math.sqrt(S*N/M),T.rows=Math.round(P),T.cols=Math.round(M/N*P)),T.rows=Math.max(T.rows,1),T.cols=Math.max(T.cols,1),T.cols*T.rows>S)C=nE(T),k=rE(T),(C-1)*k>=S?nE(T,C-1):(k-1)*C>=S&&rE(T,k-1);else for(;T.cols*T.rows<S;)C=nE(T),((k=rE(T))+1)*C>=S?rE(T,k+1):nE(T,C+1);for(A=u?0:M/T.cols,O=u?0:N/T.rows,(h||f)&&(R=Xf(10,f),D=Kf(30,p,!1),w.forEach((function(t){t.data.x&&t.data.y||(t.data.x=0,t.data.y=0);var n,r,i=e.getNode(t.id),o=D(i)||30;jf(o)?(n=o[0],r=o[1]):(n=o,r=o);var a=void 0!==R?R(t):c,s=n+a,u=r+a;A=Math.max(A,s),O=Math.max(O,u)}))),I={},L={row:0,col:0},_={},z=0;z<w.length;z++){if(F=w[z],B=void 0,v&&(B=v(e.getNode(F.id))),B&&(void 0!==B.row||void 0!==B.col)){if(void 0===(G={row:B.row,col:B.col}).col)for(G.col=0;iE(I,G);)G.col++;else if(void 0===G.row)for(G.row=0;iE(I,G);)G.row++;_[F.id]=G,oE(I,G)}sE(F,a,A,O,_,T,L,I)}return j={nodes:w,edges:x},t&&w.forEach((function(t){e.mergeNodeData(t.id,{x:t.data.x,y:t.data.y})})),[2,j]}))}))},t}(),nE=function(t,e){var n,r=t.rows||5,i=t.cols||5;null==e?n=Math.min(r,i):Math.min(r,i)===t.rows?t.rows=e:t.cols=e;return n},rE=function(t,e){var n,r=t.rows||5,i=t.cols||5;null==e?n=Math.max(r,i):Math.max(r,i)===t.rows?t.rows=e:t.cols=e;return n},iE=function(t,e){return t["c-"+e.row+"-"+e.col]||!1},oE=function(t,e){return t["c-"+e.row+"-"+e.col]=!0},aE=function(t,e){var n=t.cols||5;e.col++,e.col>=n&&(e.col=0,e.row++)},sE=function(t,e,n,r,i,o,a,s){var u,c,h=i[t.id];if(h)u=h.col*n+n/2+e[0],c=h.row*r+r/2+e[1];else{for(;iE(s,a);)aE(o,a);u=a.col*n+n/2+e[0],c=a.row*r+r/2+e[1],oE(s,a),aE(o,a)}t.data.x=u,t.data.y=c},uE={iterations:10,height:10,width:10,speed:100,gravity:10,k:5},cE=function(t,e,n,r,i,o){e.forEach((function(a,s){n[s]={x:0,y:0},e.forEach((function(e,u){if(s!==u&&i[s]===i[u]){var c=a.x-e.x,h=a.y-e.y,l=Math.sqrt(c*c+h*h);if(0===l){l=1;var d=s>u?1:-1;c=.01*d,h=.01*d}if(l<o(t[s])/2+o(t[u])/2){var f=r*r/l;n[s].x+=c/l*f,n[s].y+=h/l*f}}}))}))},hE=function(t,e,n,r,i,o,a,s){var u=o||a/10;return r&&e.forEach((function(e,n){var r=t[n].x-t[i].x,o=t[n].y-t[i].y,a=Math.sqrt(r*r+o*o),s=o/a,u=-r/a,c=Math.sqrt(e.x*e.x+e.y*e.y),h=Math.acos((s*e.x+u*e.y)/c);h>Math.PI/2&&(h-=Math.PI/2,s*=-1,u*=-1);var l=Math.cos(h)*c;e.x=s*l,e.y=u*l})),t.forEach((function(o,a){if(a!==i){var c=Math.sqrt(e[a].x*e[a].x+e[a].y*e[a].y);if(c>0&&a!==i){var h=Math.min(u*(n/800),c);if(o.x+=e[a].x/c*h,o.y+=e[a].y/c*h,r){var l=o.x-t[i].x,d=o.y-t[i].y,f=Math.sqrt(l*l+d*d);l=l/f*s[a],d=d/f*s[a],o.x=t[i].x+l,o.y=t[i].y+d}}}})),t},lE={maxIteration:1e3,focusNode:null,unitRadius:null,linkDistance:50,preventOverlap:!1,strictRadial:!0,maxPreventOverlapIteration:200,sortStrength:10},dE=function(){function t(t){void 0===t&&(t={}),this.options=t,this.id="radial",this.options=i(i({},lE),t)}return t.prototype.execute=function(t,e){return a(this,void 0,void 0,(function(){return s(this,(function(n){return[2,this.genericRadialLayout(!1,t,e)]}))}))},t.prototype.assign=function(t,e){return a(this,void 0,void 0,(function(){return s(this,(function(n){return this.genericRadialLayout(!0,t,e),[2]}))}))},t.prototype.genericRadialLayout=function(t,e,n){return a(this,void 0,void 0,(function(){var r,o,a,u,l,d,f,p,g,m,v,y,E,x,b,w,M,N,S,T,P,C,k,A,O,R,D,I,L,_,z,F,B,G,j,V,U,W,H,q,Y,X,K;return s(this,(function(s){if(r=i(i({},this.options),n),o=r.width,a=r.height,u=r.center,l=r.focusNode,d=r.unitRadius,f=r.nodeSize,p=r.nodeSpacing,g=r.strictRadial,m=r.preventOverlap,v=r.maxPreventOverlapIteration,y=r.sortBy,E=r.linkDistance,x=void 0===E?50:E,b=r.sortStrength,w=void 0===b?10:b,M=r.maxIteration,N=void 0===M?1e3:M,S=e.getAllNodes(),T=e.getAllEdges(),P=o||"undefined"==typeof window?o:window.innerWidth,C=a||"undefined"==typeof window?a:window.innerHeight,k=u||[P/2,C/2],!(null==S?void 0:S.length)||1===S.length)return[2,Zf(e,t,k)];if(A=S[0],zt(l)){for(O=0;O<S.length;O++)if(S[O].id===l){A=S[O];break}}else A=l||S[0];return R=gE(S,A.id),D=Uf({nodes:S,edges:T},!1),I=Vf(D),L=vE(I,R),mE(I,R,L+1),_=I[R],z=P-k[0]>k[0]?k[0]:P-k[0],F=C-k[1]>k[1]?k[1]:C-k[1],0===z&&(z=P/2),0===F&&(F=C/2),B=Math.min(z,F),G=Math.max.apply(Math,h([],c(_))),j=[],V=d||B/G,_.forEach((function(t,e){j[e]=t*V})),U=fE(S,I,x,j,V,y,w),W=pE(U),H=function(t,e,n){try{var r=bg.mul(bg.pow(e,2),-.5),i=r.mean("row"),o=r.mean("column"),a=r.mean();r.add(a).subRowVector(i).subColumnVector(o);var s=new wg(r),u=bg.sqrt(s.diagonalMatrix).diagonal();return s.leftSingularVectors.toJSON().map((function(e){return bg.mul([e],[u]).toJSON()[0].splice(0,t)}))}catch(t){for(var c=[],h=0;h<e.length;h++){var l=Math.random()*n,d=Math.random()*n;c.push([l,d])}return c}}(x,U,x),q=H.map((function(t){var e=c(t,2),n=e[0],r=e[1];return{x:(isNaN(n)?Math.random()*x:n)-H[R][0],y:(isNaN(r)?Math.random()*x:r)-H[R][1]}})),this.run(N,q,W,U,j,R),m&&(Y=$f(f,p),X={nodes:S,nodeSizeFunc:Y,positions:q,radii:j,height:C,width:P,strictRadial:Boolean(g),focusIdx:R,iterations:v||200,k:q.length/4.5},q=function(t,e){for(var n=i(i({},uE),e),r=n.positions,o=n.iterations,a=n.width,s=n.k,u=n.speed,c=void 0===u?100:u,h=n.strictRadial,l=n.focusIdx,d=n.radii,f=void 0===d?[]:d,p=n.nodeSizeFunc,g=t.getAllNodes(),m=[],v=a/10,y=0;y<o;y++)r.forEach((function(t,e){m[e]={x:0,y:0}})),cE(g,r,m,s,f,p),hE(r,m,c,h,l,v,a,f);return r}(e,X)),K=[],q.forEach((function(t,e){var n=Yf(S[e]);n.data.x=t.x+k[0],n.data.y=t.y+k[1],K.push(n)})),t&&K.forEach((function(t){return e.mergeNodeData(t.id,{x:t.data.x,y:t.data.y})})),[2,{nodes:K,edges:T}]}))}))},t.prototype.run=function(t,e,n,r,i,o){for(var a=0;a<=t;a++){var s=a/t;this.oneIteration(s,e,i,r,n,o)}},t.prototype.oneIteration=function(t,e,n,r,i,o){var a=1-t;e.forEach((function(s,u){var c=Wf(s,{x:0,y:0}),h=0===c?0:1/c;if(u!==o){var l=0,d=0,f=0;e.forEach((function(t,e){if(u!==e){var n=Wf(s,t),o=0===n?0:1/n,a=r[e][u];f+=i[u][e],l+=i[u][e]*(t.x+a*(s.x-t.x)*o),d+=i[u][e]*(t.y+a*(s.y-t.y)*o)}}));var p=0===n[u]?0:1/n[u];f*=a,f+=t*p*p,l*=a,l+=t*p*s.x*h,s.x=l/f,d*=a,d+=t*p*s.y*h,s.y=d/f}}))},t}(),fE=function(t,e,n,r,i,o,a){if(!t)return[];var s=[];if(e){var u={};e.forEach((function(e,c){var h=[];e.forEach((function(e,s){var l,d;if(c===s)h.push(0);else if(r[c]===r[s])if("data"===o)h.push(e*(Math.abs(c-s)*a)/(r[c]/i));else if(o){var f=void 0,p=void 0;if(u[t[c].id])f=u[t[c].id];else{var g=("id"===o?t[c].id:null===(l=t[c].data)||void 0===l?void 0:l[o])||0;f=zt(g)?g.charCodeAt(0):g,u[t[c].id]=f}if(u[t[s].id])p=u[t[s].id];else{g=("id"===o?t[s].id:null===(d=t[s].data)||void 0===d?void 0:d[o])||0;p=zt(g)?g.charCodeAt(0):g,u[t[s].id]=p}h.push(e*(Math.abs(f-p)*a)/(r[c]/i))}else h.push(e*n/(r[c]/i));else{var m=(n+i)/2;h.push(e*m)}})),s.push(h)}))}return s},pE=function(t){for(var e=t.length,n=t[0].length,r=[],i=0;i<e;i++){for(var o=[],a=0;a<n;a++)0!==t[i][a]?o.push(1/(t[i][a]*t[i][a])):o.push(0);r.push(o)}return r},gE=function(t,e){var n=-1;return t.forEach((function(t,r){t.id===e&&(n=r)})),Math.max(n,0)},mE=function(t,e,n){for(var r=t.length,i=0;i<r;i++)if(t[e][i]===1/0){t[e][i]=n,t[i][e]=n;for(var o=0;o<r;o++)t[i][o]!==1/0&&t[e][o]===1/0&&(t[e][o]=n+t[i][o],t[o][e]=n+t[i][o])}for(i=0;i<r;i++)if(i!==e)for(o=0;o<r;o++)if(t[i][o]===1/0){var a=Math.abs(t[e][i]-t[e][o]);a=0===a?1:a,t[i][o]=a}},vE=function(t,e){for(var n=0,r=0;r<t[e].length;r++)t[e][r]!==1/0&&(n=t[e][r]>n?t[e][r]:n);return n},yE={center:[0,0],width:300,height:300},EE=function(){function t(t){void 0===t&&(t={}),this.options=t,this.id="random",this.options=i(i({},yE),t)}return t.prototype.execute=function(t,e){return a(this,void 0,void 0,(function(){return s(this,(function(n){return[2,this.genericRandomLayout(!1,t,e)]}))}))},t.prototype.assign=function(t,e){return a(this,void 0,void 0,(function(){return s(this,(function(n){return this.genericRandomLayout(!0,t,e),[2]}))}))},t.prototype.genericRandomLayout=function(t,e,n){return a(this,void 0,void 0,(function(){var r,o,a,u,c,h,l,d,f;return s(this,(function(s){return r=i(i({},this.options),n),o=r.center,a=r.width,u=r.height,c=e.getAllNodes(),.9,h=a||"undefined"==typeof window?a:window.innerWidth,l=u||"undefined"==typeof window?u:window.innerHeight,d=o||[h/2,l/2],f=[],c&&c.forEach((function(t){f.push({id:t.id,data:{x:.9*(Math.random()-.5)*h+d[0],y:.9*(Math.random()-.5)*l+d[1]}})})),t&&f.forEach((function(t){return e.mergeNodeData(t.id,{x:t.data.x,y:t.data.y})})),[2,{nodes:f,edges:e.getAllEdges()}]}))}))},t}();function xE(t){return!!t.tick&&!!t.stop}class bE extends Nl{}class wE extends bE{static defaultOptions={lineWidth:1,border:!0,borderLineWidth:1,borderStroke:"#0001",borderStyle:"solid",stroke:"#0001",size:20,tickCount:4,tickStrokeOpacity:.5};$element=document.createElement("div");offset=[0,0];constructor(t,e){super(t,Object.assign({},wE.defaultOptions,e)),this.render(),this.bindEvents()}update(t){super.update(t),this.updateStyle()}bindEvents(){const{graph:e}=this.context;e.on(t.GraphEvent.AFTER_TRANSFORM,this.onTransform)}render(){const{canvas:t}=this.context,e=t.getContainer();e&&(this.$element.className="g6-grid-line",this.updateStyle(),e.appendChild(this.$element))}updateStyle(){const{size:t,stroke:e,lineWidth:n,border:r,borderLineWidth:i,borderStroke:o,borderStyle:a}=this.options;Object.assign(this.$element.style,{width:"100%",height:"100%",border:r?`${i}px ${a} ${o}`:"none",backgroundImage:`linear-gradient(${e} ${n}px, transparent ${n}px), linear-gradient(90deg, ${e} ${n}px, transparent ${n}px)`,backgroundSize:`${t}px ${t}px`})}updateOffset(t){this.offset=function(t,e){return t.map((t=>t%e))}(Gc(this.offset,t),this.options.size),this.$element.style.backgroundPosition=`${this.offset[0]}px ${this.offset[1]}px`}onTransform=t=>{if(!this.options.follow)return;const{data:{translate:e}}=t;e&&this.updateOffset(e)};destroy(){this.context.graph.off(t.GraphEvent.AFTER_TRANSFORM,this.onTransform),this.$element.remove(),super.destroy()}}const ME=["#7E92B5","#f5222d","#faad14"],NE={type:"group",color:["#1783FF","#00C9C9","#F08F56","#D580FF","#7863FF","#DB9D0D","#60C42D","#FF80CA","#2491B3","#17C76F"]},SE={type:"group",color:["#99ADD1","#1783FF","#00C9C9","#F08F56","#D580FF","#7863FF","#DB9D0D","#60C42D","#FF80CA","#2491B3","#17C76F"]};function TE(t){const{bgColor:e,textColor:n,nodeColor:r,nodeColorDisabled:i,nodeStroke:o,nodeBadgePalette:a=ME,nodePaletteOptions:s=NE,edgeColor:u,edgeColorDisabled:c,edgePaletteOptions:h=SE,comboColor:l,comboColorDisabled:d,comboStroke:f,comboStrokeDisabled:p}=t;return{background:e,node:{palette:s,style:{badgeFill:e,badgeFontSize:8,badgePadding:[1,4],badgePalette:a,color:r,halo:!1,haloLineWidth:12,haloStrokeOpacity:.25,iconFill:e,iconFontSize:16,labelBackground:!1,labelBackgroundFill:e,labelBackgroundLineWidth:0,labelBackgroundOpacity:.5,labelBackgroundPadding:[0,2],labelFill:n,labelFontSize:12,portFill:r,portLineWidth:1,portStroke:o,portStrokeOpacity:.65},state:{selected:{halo:!0,labelFontSize:14,labelFontWeight:700,lineWidth:3,stroke:o},active:{halo:!0},highlight:{labelFontWeight:700,lineWidth:3,stroke:o,strokeOpacity:.85},inactive:{iconOpacity:.25,labelOpacity:.25,opacity:.25},disabled:{color:i,labelOpacity:.25}},animation:{enter:"fade",exit:"fade",visibility:"fade",update:[{fields:["x","y","color","stroke"]}]}},edge:{palette:h,style:{color:u,halo:!1,haloLineWidth:12,haloStrokeOpacity:.25,increasedLineWidthForHitTesting:2,labelBackground:!1,labelBackgroundFill:e,labelBackgroundLineWidth:0,labelBackgroundOpacity:.75,labelBackgroundPadding:[4,4,4,4],labelFill:n,labelFontSize:12,labelPlacement:"center",labelTextBaseline:"middle",lineWidth:1},state:{selected:{halo:!0,labelFontSize:14,labelFontWeight:700,lineWidth:2},active:{halo:!0},highlight:{labelFontWeight:700,lineWidth:2},inactive:{labelOpacity:.25,opacity:.25},disabled:{labelOpacity:.25,color:c}},animation:{enter:"fade",exit:"fade",visibility:"fade",update:[{fields:["color"]},{fields:["path"],shape:"key"}]}},combo:{style:{collapsedMaskFill:l,collapsedMaskFontSize:12,collapsedSize:32,color:l,haloLineWidth:12,haloStrokeOpacity:.25,labelBackground:!1,labelBackgroundFill:e,labelBackgroundLineWidth:0,labelBackgroundOpacity:.75,labelBackgroundPadding:[2,4,2,4],labelFill:n,labelFontSize:12,lineDash:0,lineWidth:1,padding:10,stroke:f},state:{selected:{halo:!0,labelFontSize:14,labelFontWeight:700,lineWidth:4},active:{halo:!0},highlight:{labelFontWeight:700,lineWidth:4},inactive:{labelOpacity:.25,opacity:.65},disabled:{color:d,labelOpacity:.25,opacity:.25,stroke:p}},animation:{enter:"fade",exit:"fade",visibility:"fade",expand:"combo-collapse-expand",collapse:"combo-collapse-expand",update:[{fields:["x","y"]},{fields:["size","color","stroke"],shape:"key"}]}}}}const PE=TE({bgColor:"#000000",textColor:"#ffffffd9",nodeColor:"#1783ff",nodeColorDisabled:"#d0e4ff",nodeStroke:"#d0e4ff",edgeColor:"#99add1",edgeColorDisabled:"#969696",comboColor:"#fdfdfd",comboColorDisabled:"#d0e4ff",comboStroke:"#99add1",comboStrokeDisabled:"#969696"}),CE=TE({bgColor:"#fff",textColor:"#000000d9",nodeColor:"#1783ff",nodeColorDisabled:"#f0f0f0",nodeStroke:"#000000",edgeColor:"#99add1",edgeColorDisabled:"#d9d9d9",comboColor:"#fdfdfd",comboColorDisabled:"#f0f0f0",comboStroke:"#99add1",comboStrokeDisabled:"#d9d9d9"}),kE={animation:{fade:[{fields:["opacity"]}],translate:[{fields:["x","y"]}],"combo-collapse-expand":[{fields:["x","y"]},{fields:["r","width","height"],shape:"key"}]},behavior:{"zoom-canvas":Al,"drag-canvas":Cl,"drag-element":kl,"collapse-expand":Tl},combo:{circle:class extends Sh{constructor(t){super(t)}drawKeyShape(t,e){return this.upsert("key",Ms,this.getKeyStyle(t),e)}getKeyStyle(t){const{collapsed:e}=t,n=super.getKeyStyle(t),r=_c(n,"collapsed"),[i]=this.getKeySize(t);return{...n,...e&&r,r:i/2}}getCollapsedKeySize(t){const[e,n]=kc(t.collapsedSize),r=Math.max(e,n)/2;return[2*r,2*r,0]}getExpandedKeySize(t){if(!ne(t.size)){const[e,n]=kc(t.size),r=Math.sqrt(e**2+n**2)/2;return[2*r,2*r,0]}const e=this.getContentBBox(t),[n,r]=yc(e),i=Math.sqrt(n**2+r**2)/2;return[2*i,2*i,0]}getCollapsedOriginPosition(t){return Rc(t.collapsedOrigin,this.getContentBBox(t).center,this.getCollapsedKeySize(t),this.getExpandedKeySize(t),Oc)}},rect:Th},edge:{cubic:Kh,line:Qh,polyline:Jh,quadratic:tl,"cubic-horizontal":$h,"cubic-vertical":Zh},layout:{"combo-combined":im,"compact-box":Gf.compactBox,"force-atlas2":Zy,circular:Jf,concentric:em,d3force:Km,dagre:Hy,dendrogram:Gf.dendrogram,force:Xg,fruchterman:Jy,grid:eE,indented:Gf.indented,mds:Ng,mindmap:Gf.mindmap,radial:dE,random:EE},node:{circle:Eh,ellipse:bh,image:wh,rect:Mh,star:class extends xh{constructor(t){super(t)}getInnerR(t){return t.innerR||3*this.getOuterR(t)/8}getOuterR(t){return Math.min(...this.getSize(t))/2}getPoints(t){return e=this.getOuterR(t),n=this.getInnerR(t),[[0,-e],[n*Math.cos(3*Math.PI/10),-n*Math.sin(3*Math.PI/10)],[e*Math.cos(Math.PI/10),-e*Math.sin(Math.PI/10)],[n*Math.cos(Math.PI/10),n*Math.sin(Math.PI/10)],[e*Math.cos(3*Math.PI/10),e*Math.sin(3*Math.PI/10)],[0,n],[-e*Math.cos(3*Math.PI/10),e*Math.sin(3*Math.PI/10)],[-n*Math.cos(Math.PI/10),n*Math.sin(Math.PI/10)],[-e*Math.cos(Math.PI/10),-e*Math.sin(Math.PI/10)],[-n*Math.cos(3*Math.PI/10),-n*Math.sin(3*Math.PI/10)]];var e,n}getIconStyle(t){const e=super.getIconStyle(t),n=2*this.getInnerR(t)*yh;return!!e&&{width:n,height:n,...e}}getPortXY(t,e){const{placement:n="top"}=e;return ol(this.getKey().getLocalBounds(),n,function(t,e){const n={};return n.top=[0,-t],n.left=[-t*Math.cos(Math.PI/10),-t*Math.sin(Math.PI/10)],n["left-bottom"]=[-t*Math.cos(3*Math.PI/10),t*Math.sin(3*Math.PI/10)],n.bottom=[0,e],n["right-bottom"]=[t*Math.cos(3*Math.PI/10),t*Math.sin(3*Math.PI/10)],n.right=n.default=[t*Math.cos(Math.PI/10),-t*Math.sin(Math.PI/10)],n}(this.getOuterR(t),this.getInnerR(t)),!1)}},triangle:Nh,diamond:class extends xh{constructor(t){super(t)}getPoints(t){const[e,n]=this.getSize(t);return function(t,e){return[[0,-e/2],[t/2,0],[0,e/2],[-t/2,0]]}(e,n)}getIntersectPoint(t){const{points:e}=this.getKeyStyle(this.attributes);return nh(t,[this.attributes.x,this.attributes.y],e)}}},palette:{spectral:["rgb(158, 1, 66)","rgb(213, 62, 79)","rgb(244, 109, 67)","rgb(253, 174, 97)","rgb(254, 224, 139)","rgb(255, 255, 191)","rgb(230, 245, 152)","rgb(171, 221, 164)","rgb(102, 194, 165)","rgb(50, 136, 189)","rgb(94, 79, 162)"],oranges:["rgb(255, 245, 235)","rgb(254, 230, 206)","rgb(253, 208, 162)","rgb(253, 174, 107)","rgb(253, 141, 60)","rgb(241, 105, 19)","rgb(217, 72, 1)","rgb(166, 54, 3)","rgb(127, 39, 4)"],greens:["rgb(247, 252, 245)","rgb(229, 245, 224)","rgb(199, 233, 192)","rgb(161, 217, 155)","rgb(116, 196, 118)","rgb(65, 171, 93)","rgb(35, 139, 69)","rgb(0, 109, 44)","rgb(0, 68, 27)"],blues:["rgb(247, 251, 255)","rgb(222, 235, 247)","rgb(198, 219, 239)","rgb(158, 202, 225)","rgb(107, 174, 214)","rgb(66, 146, 198)","rgb(33, 113, 181)","rgb(8, 81, 156)","rgb(8, 48, 107)"]},theme:{dark:PE,light:CE},plugin:{"grid-line":wE}},AE={animation:{},behavior:{},combo:{},edge:{},layout:{},node:{},palette:{},theme:{},plugin:{}};function OE(t,e,n){AE[t][e]?console.error(`The extension ${e} of ${t} has been registered before.`):Object.assign(AE[t],{[e]:n})}function RE(t,e){const n=AE[t]?.[e];if(n)return n}function DE(t,e,n,r,i=0){"TB"===r&&e(t,i);const o=n(t);if(o)for(const t of o)DE(t,e,n,r,i+1);"BT"===r&&e(t,i)}as.enableCSSParsing=!1,Object.entries(kE).forEach((([t,e])=>{Object.entries(e).forEach((([e,n])=>{OE(t,e,n)}))}));const IE=t=>t?parseInt(t):0;function LE(t){let e=640,n=480;const[r,i]=function(t){const e=getComputedStyle(t),n=t.clientWidth||IE(e.width),r=t.clientHeight||IE(e.height);return[n-(IE(e.paddingLeft)+IE(e.paddingRight)),r-(IE(e.paddingTop)+IE(e.paddingBottom))]}(t);e=r||e,n=i||n;return[Math.max(jt(e)?e:1,1),Math.max(jt(n)?n:1,1)]}class _E{type;constructor(t){this.type=t}}class zE extends _E{data;constructor(t,e){super(t),this.data=e}}class FE extends _E{animationType;animation;data;constructor(t,e,n,r){super(t),this.animationType=e,this.animation=n,this.data=r}}class BE extends _E{data;constructor(t,e){super(t),this.data=e}}class GE extends _E{states;constructor(t,e){super(t),this.states=e}}function jE(t,e){t.emit(e.type,e)}function VE(t,e){const{datum:n,index:r,elementData:i}=e;return Tt(t)?t(n,r,i):Object.fromEntries(Object.entries(t).map((([t,e])=>Tt(e)?[t,e(n,r,i)]:[t,e])))}function UE(t){return t.style?.zIndex??yl("zIndex")??0}class WE extends Ml{currentTarget=null;category="behavior";constructor(t){super(t),this.forwardEvents(),this.setBehaviors(this.context.options.behaviors||[])}setBehaviors(t){this.setExtensions(t)}forwardEvents(){const e=this.context.canvas.getContainer();e&&[t.ContainerEvent.KEY_DOWN,t.ContainerEvent.KEY_UP].forEach((t=>{e.addEventListener(t,this.forwardContainerEvents.bind(this))}));const n=this.context.canvas.document;n&&[t.CanvasEvent.CLICK,t.CanvasEvent.DBLCLICK,t.CanvasEvent.POINTER_OVER,t.CanvasEvent.POINTER_LEAVE,t.CanvasEvent.POINTER_ENTER,t.CanvasEvent.POINTER_MOVE,t.CanvasEvent.POINTER_OUT,t.CanvasEvent.POINTER_DOWN,t.CanvasEvent.POINTER_UP,t.CanvasEvent.CONTEXT_MENU,t.CanvasEvent.DRAG_START,t.CanvasEvent.DRAG,t.CanvasEvent.DRAG_END,t.CanvasEvent.DRAG_ENTER,t.CanvasEvent.DRAG_OVER,t.CanvasEvent.DRAG_LEAVE,t.CanvasEvent.DROP,t.CanvasEvent.WHEEL].forEach((t=>{n.addEventListener(t,this.forwardCanvasEvents)}))}forwardCanvasEvents=e=>{const n=function(t){if(!t)return null;if(t instanceof _s)return{type:"canvas",element:t};let e=t;for(;e;){if(el(e))return{type:"node",element:e};if(nl(e))return{type:"edge",element:e};if(rl(e))return{type:"combo",element:e};e=e.parentElement}return null}(e.target);if(!n)return;const{graph:r,canvas:i}=this.context,{type:o,element:a}=n,{type:s,detail:u,button:c}=e,h={...e,target:a,targetType:o};if(s===t.CanvasEvent.POINTER_MOVE&&(this.currentTarget!==a&&(this.currentTarget&&r.emit(`${o}:${t.CanvasEvent.POINTER_LEAVE}`,{...h,target:this.currentTarget}),a&&r.emit(`${o}:${t.CanvasEvent.POINTER_ENTER}`,h)),this.currentTarget=a),s===t.CanvasEvent.CLICK&&2===c||(r.emit(`${o}:${s}`,h),r.emit(s,h)),s===t.CanvasEvent.CLICK&&2===u&&(r.emit(`${o}:${t.CanvasEvent.DBLCLICK}`,h),r.emit(t.CanvasEvent.DBLCLICK,h)),s===t.CanvasEvent.POINTER_DOWN&&2===c){const e={...h,preventDefault:()=>{i.getContainer()?.addEventListener(t.CanvasEvent.CONTEXT_MENU,(t=>t.preventDefault()),{once:!0})}};r.emit(`${o}:${t.CanvasEvent.CONTEXT_MENU}`,e),r.emit(t.CanvasEvent.CONTEXT_MENU,e)}};forwardContainerEvents(t){this.context.graph.emit(t.type,t)}}function HE(t,e){var n=e.r;t.arc(n,n,n,0,2*Math.PI,!1)}function qE(t,e){var n=e.rx,r=e.ry;if(t.ellipse)t.ellipse(n,r,n,r,0,0,2*Math.PI,!1);else{var i=n>r?n:r,o=n>r?1:n/r,a=n>r?r/n:1;t.save(),t.scale(o,a),t.arc(i,i,i,0,2*Math.PI)}}function YE(t,e){var n,r,i=e.x1,o=e.y1,a=e.x2,s=e.y2,u=e.defX,c=void 0===u?0:u,h=e.defY,l=void 0===h?0:h,d=e.markerStart,f=e.markerEnd,p=e.markerStartOffset,g=e.markerEndOffset,m=0,v=0,y=0,E=0,x=0;d&&ps(d)&&p&&(n=a-i,r=s-o,x=Math.atan2(r,n),m=Math.cos(x)*(p||0),v=Math.sin(x)*(p||0)),f&&ps(f)&&g&&(n=i-a,r=o-s,x=Math.atan2(r,n),y=Math.cos(x)*(g||0),E=Math.sin(x)*(g||0)),t.moveTo(i-c+m,o-l+v),t.lineTo(a-c+y,s-l+E)}function XE(t,e){var n,r,i=e.defX,o=void 0===i?0:i,a=e.defY,s=void 0===a?0:a,u=e.markerStart,h=e.markerEnd,l=e.markerStartOffset,d=e.markerEndOffset,f=e.path,p=f.absolutePath,g=f.segments,m=0,v=0,y=0,E=0,x=0;if(u&&ps(u)&&l){var b=c(u.parentNode.getStartTangent(),2),w=b[0],M=b[1];n=w[0]-M[0],r=w[1]-M[1],x=Math.atan2(r,n),m=Math.cos(x)*(l||0),v=Math.sin(x)*(l||0)}if(h&&ps(h)&&d){var N=c(h.parentNode.getEndTangent(),2);w=N[0],M=N[1];n=w[0]-M[0],r=w[1]-M[1],x=Math.atan2(r,n),y=Math.cos(x)*(d||0),E=Math.sin(x)*(d||0)}for(var S=0;S<p.length;S++){var T=p[S],P=T[0],C=p[S+1],k=0===S&&(0!==m||0!==v),A=(S===p.length-1||C&&("M"===C[0]||"Z"===C[0]))&&0!==y&&0!==E;switch(P){case"M":k?(t.moveTo(T[1]-o+m,T[2]-s+v),t.lineTo(T[1]-o,T[2]-s)):t.moveTo(T[1]-o,T[2]-s);break;case"L":A?t.lineTo(T[1]-o+y,T[2]-s+E):t.lineTo(T[1]-o,T[2]-s);break;case"Q":t.quadraticCurveTo(T[1]-o,T[2]-s,T[3]-o,T[4]-s),A&&t.lineTo(T[3]-o+y,T[4]-s+E);break;case"C":t.bezierCurveTo(T[1]-o,T[2]-s,T[3]-o,T[4]-s,T[5]-o,T[6]-s),A&&t.lineTo(T[5]-o+y,T[6]-s+E);break;case"A":var O=g[S].arcParams,R=O.cx,D=O.cy,I=O.rx,L=O.ry,_=O.startAngle,z=O.endAngle,F=O.xRotation,B=O.sweepFlag;if(t.ellipse)t.ellipse(R-o,D-s,I,L,F,_,z,!!(1-B));else{var G=I>L?I:L,j=I>L?1:I/L,V=I>L?L/I:1;t.translate(R-o,D-s),t.rotate(F),t.scale(j,V),t.arc(0,0,G,_,z,!!(1-B)),t.scale(1/j,1/V),t.rotate(-F),t.translate(-(R-o),-(D-s))}A&&t.lineTo(T[6]-o+y,T[7]-s+E);break;case"Z":t.closePath()}}}function KE(t,e){var n,r,i=e.defX,o=void 0===i?0:i,a=e.defY,s=void 0===a?0:a,u=e.markerStart,c=e.markerEnd,h=e.markerStartOffset,l=e.markerEndOffset,d=e.points.points,f=d.length,p=d[0][0]-o,g=d[0][1]-s,m=d[f-1][0]-o,v=d[f-1][1]-s,y=0,E=0,x=0,b=0,w=0;u&&ps(u)&&h&&(n=d[1][0]-d[0][0],r=d[1][1]-d[0][1],w=Math.atan2(r,n),y=Math.cos(w)*(h||0),E=Math.sin(w)*(h||0)),c&&ps(c)&&l&&(n=d[f-1][0]-d[0][0],r=d[f-1][1]-d[0][1],w=Math.atan2(r,n),x=Math.cos(w)*(l||0),b=Math.sin(w)*(l||0)),t.moveTo(p+(y||x),g+(E||b));for(var M=1;M<f-1;M++){var N=d[M];t.lineTo(N[0]-o,N[1]-s)}t.lineTo(m,v)}function $E(t,e){var n,r,i=e.defX,o=void 0===i?0:i,a=e.defY,s=void 0===a?0:a,u=e.markerStart,c=e.markerEnd,h=e.markerStartOffset,l=e.markerEndOffset,d=e.points.points,f=d.length,p=d[0][0]-o,g=d[0][1]-s,m=d[f-1][0]-o,v=d[f-1][1]-s,y=0,E=0,x=0,b=0,w=0;u&&ps(u)&&h&&(n=d[1][0]-d[0][0],r=d[1][1]-d[0][1],w=Math.atan2(r,n),y=Math.cos(w)*(h||0),E=Math.sin(w)*(h||0)),c&&ps(c)&&l&&(n=d[f-2][0]-d[f-1][0],r=d[f-2][1]-d[f-1][1],w=Math.atan2(r,n),x=Math.cos(w)*(l||0),b=Math.sin(w)*(l||0)),t.moveTo(p+y,g+E);for(var M=1;M<f-1;M++){var N=d[M];t.lineTo(N[0]-o,N[1]-s)}t.lineTo(m+x,v+b)}function ZE(t,e){var n=e.radius,r=e.width,i=e.height,o=r,a=i;if(n&&n.some((function(t){return 0!==t}))){var s=r>0?1:-1,u=i>0?1:-1,h=s+u===0,l=c(n.map((function(t){return Gt(t,0,Math.min(Math.abs(o)/2,Math.abs(a)/2))})),4),d=l[0],f=l[1],p=l[2],g=l[3];t.moveTo(s*d,0),t.lineTo(o-s*f,0),0!==f&&t.arc(o-s*f,u*f,f,-u*Math.PI/2,s>0?0:Math.PI,h),t.lineTo(o,a-u*p),0!==p&&t.arc(o-s*p,a-u*p,p,s>0?0:Math.PI,u>0?Math.PI/2:1.5*Math.PI,h),t.lineTo(s*g,a),0!==g&&t.arc(s*g,a-u*g,g,u>0?Math.PI/2:-Math.PI/2,s>0?Math.PI:0,h),t.lineTo(0,u*d),0!==d&&t.arc(s*d,u*d,d,s>0?Math.PI:0,u>0?1.5*Math.PI:Math.PI/2,h)}else t.rect(0,0,o,a)}var QE=function(t){function e(){var e=t.apply(this,h([],c(arguments),!1))||this;return e.name="canvas-path-generator",e}return r(e,t),e.prototype.init=function(){var t,e=((t={})[jn.CIRCLE]=HE,t[jn.ELLIPSE]=qE,t[jn.RECT]=ZE,t[jn.LINE]=YE,t[jn.POLYLINE]=$E,t[jn.POLYGON]=KE,t[jn.PATH]=XE,t[jn.TEXT]=void 0,t[jn.GROUP]=void 0,t[jn.IMAGE]=void 0,t[jn.HTML]=void 0,t[jn.MESH]=void 0,t);this.context.pathGeneratorFactory=e},e.prototype.destroy=function(){delete this.context.pathGeneratorFactory},e}(Wn),JE=K(),tx=K(),ex=K(),nx=y(),rx=function(){function t(){var t=this;this.isHit=function(e,n,r,i){var o=t.context.pointInPathPickerFactory[e.nodeName];if(o){var a=N(nx,r),s=ut(tx,tt(ex,n[0],n[1],0),a),u=e.getGeometryBounds().halfExtents,c=e.parsedStyle.anchor;if(s[0]+=(c&&c[0]||0)*u[0]*2,s[1]+=(c&&c[1]||0)*u[1]*2,o(e,new mr(s[0],s[1]),i,t.isPointInPath,t.context,t.runtime))return!0}return!1},this.isPointInPath=function(e,n){var r=t.runtime.offscreenCanvasCreator.getOrCreateContext(t.context.config.offscreenCanvas),i=t.context.pathGeneratorFactory[e.nodeName];return i&&(r.beginPath(),i(r,e.parsedStyle),r.closePath()),r.isPointInPath(n.x,n.y)}}return t.prototype.apply=function(e,n){var r,i=this,o=e.renderingService,u=e.renderingContext;this.context=e,this.runtime=n;var c=null===(r=u.root)||void 0===r?void 0:r.ownerDocument;o.hooks.pick.tapPromise(t.tag,(function(t){return a(i,void 0,void 0,(function(){return s(this,(function(e){return[2,this.pick(c,t)]}))}))})),o.hooks.pickSync.tap(t.tag,(function(t){return i.pick(c,t)}))},t.prototype.pick=function(t,e){var n,r,i=e.topmost,o=e.position,a=o.x,s=o.y,c=tt(JE,a,s,0),h=t.elementsFromBBox(c[0],c[1],c[0],c[1]),l=[];try{for(var d=u(h),f=d.next();!f.done;f=d.next()){var p=f.value,g=p.getWorldTransform();if(this.isHit(p,c,g,!1)){var m=na(p);if(m){var v=m.parsedStyle.clipPath;if(this.isHit(v,c,v.getWorldTransform(),!0)){if(i)return e.picked=[p],e;l.push(p)}}else{if(i)return e.picked=[p],e;l.push(p)}}}}catch(t){n={error:t}}finally{try{f&&!f.done&&(r=d.return)&&r.call(d)}finally{if(n)throw n.error}}return e.picked=l,e},t.tag="CanvasPicker",t}();function ix(t,e,n){var r=t.parsedStyle,i=r.r,o=r.fill,a=r.stroke,s=r.lineWidth,u=r.increasedLineWidthForHitTesting,h=r.pointerEvents,l=((s||0)+(u||0))/2,d=bn(i,i,e.x,e.y),f=c(aa(h,o,a),2),p=f[0],g=f[1];return p&&g||n?d<=i+l:p?d<=i:!!g&&(d>=i-l&&d<=i+l)}function ox(t,e,n,r){return t/(n*n)+e/(r*r)}function ax(t,e,n){var r=t.parsedStyle,i=r.rx,o=r.ry,a=r.fill,s=r.stroke,u=r.lineWidth,h=r.increasedLineWidthForHitTesting,l=r.pointerEvents,d=e.x,f=e.y,p=c(aa(l,a,s),2),g=p[0],m=p[1],v=((u||0)+(h||0))/2,y=(d-i)*(d-i),E=(f-o)*(f-o);return g&&m||n?ox(y,E,i+v,o+v)<=1:g?ox(y,E,i,o)<=1:!!m&&(ox(y,E,i-v,o-v)>=1&&ox(y,E,i+v,o+v)<=1)}function sx(t,e,n,r,i,o){return i>=t&&i<=t+n&&o>=e&&o<=e+r}function ux(t,e,n,r,i,o,a,s){var u=(Math.atan2(s-e,a-t)+2*Math.PI)%(2*Math.PI),c={x:t+n*Math.cos(u),y:e+n*Math.sin(u)};return bn(c.x,c.y,a,s)<=o/2}function cx(t,e,n,r,i,o,a){var s=Math.min(t,n),u=Math.max(t,n),c=Math.min(e,r),h=Math.max(e,r),l=i/2;return o>=s-l&&o<=u+l&&a>=c-l&&a<=h+l&&An(t,e,n,r,o,a)<=i/2}function hx(t,e,n,r,i){var o=t.length;if(o<2)return!1;for(var a=0;a<o-1;a++){if(cx(t[a][0],t[a][1],t[a+1][0],t[a+1][1],e,n,r))return!0}if(i){var s=t[0],u=t[o-1];if(cx(s[0],s[1],u[0],u[1],e,n,r))return!0}return!1}var lx=1e-6;function dx(t){return Math.abs(t)<lx?0:t<0?-1:1}function fx(t,e,n){return(n[0]-t[0])*(e[1]-t[1])==(e[0]-t[0])*(n[1]-t[1])&&Math.min(t[0],e[0])<=n[0]&&n[0]<=Math.max(t[0],e[0])&&Math.min(t[1],e[1])<=n[1]&&n[1]<=Math.max(t[1],e[1])}function px(t,e,n){var r=!1,i=t.length;if(i<=2)return!1;for(var o=0;o<i;o++){var a=t[o],s=t[(o+1)%i];if(fx(a,s,[e,n]))return!0;dx(a[1]-n)>0!=dx(s[1]-n)>0&&dx(e-(n-a[1])*(a[0]-s[0])/(a[1]-s[1])-a[0])<0&&(r=!r)}return r}function gx(t,e,n){for(var r=!1,i=0;i<t.length;i++){if(r=px(t[i],e,n))break}return r}function mx(t,e,n){var r=t.parsedStyle,i=r.x1,o=r.y1,a=r.x2,s=r.y2,u=r.lineWidth,h=r.increasedLineWidthForHitTesting,l=r.defX,d=void 0===l?0:l,f=r.defY,p=void 0===f?0:f;return!(!c(aa(r.pointerEvents,r.fill,r.stroke),2)[1]&&!n||!u)&&cx(i,o,a,s,(u||0)+(h||0),e.x+d,e.y+p)}function vx(t,e,n,r,i,o){var a=t.parsedStyle,s=a.lineWidth,u=a.increasedLineWidthForHitTesting,h=a.stroke,l=a.fill,d=a.defX,f=void 0===d?0:d,p=a.defY,g=void 0===p?0:p,m=a.path,v=a.pointerEvents,y=m.segments,E=m.hasArc,x=m.polylines,b=m.polygons,w=c(aa(v,(null==b?void 0:b.length)&&l,h),2),M=w[0],N=w[1],S=Wi(t),T=!1;return M||n?T=E?r(t,e):gx(b,e.x+f,e.y+g)||gx(x,e.x+f,e.y+g):((N||n)&&(T=function(t,e,n,r,i){for(var o=!1,a=e/2,s=0;s<t.length;s++){var u=t[s],c=u.currentPoint,h=u.params,l=u.prePoint,d=u.box;if(!d||sx(d.x-a,d.y-a,d.width+e,d.height+e,n,r))switch(u.command){case"L":case"Z":if(o=cx(l[0],l[1],c[0],c[1],e,n,r))return!0;break;case"Q":if(o=Bn(l[0],l[1],h[1],h[2],h[3],h[4],n,r)<=e/2)return!0;break;case"C":if(o=In(l[0],l[1],h[1],h[2],h[3],h[4],h[5],h[6],n,r,i)<=e/2)return!0;break;case"A":u.cubicParams||(u.cubicParams=Te(l[0],l[1],h[1],h[2],h[3],h[4],h[5],h[6],h[7],void 0));for(var f=u.cubicParams,p=l,g=0;g<f.length;g+=6){var m=In(p[0],p[1],f[g],f[g+1],f[g+2],f[g+3],f[g+4],f[g+5],n,r,i);if(p=[f[g+4],f[g+5]],o=m<=e/2)return!0}}}return o}(y,(s||0)+(u||0),e.x+f,e.y+g,S)),T)}function yx(t,e,n){var r=t.parsedStyle,i=r.stroke,o=r.fill,a=r.lineWidth,s=r.increasedLineWidthForHitTesting,u=r.points,h=r.defX,l=void 0===h?0:h,d=r.defY,f=void 0===d?0:d,p=c(aa(r.pointerEvents,o,i),2),g=p[0],m=!1;return(p[1]||n)&&(m=hx(u.points,(a||0)+(s||0),e.x+l,e.y+f,!0)),m||!g&&!n||(m=px(u.points,e.x+l,e.y+f)),m}function Ex(t,e,n){var r=t.parsedStyle,i=r.lineWidth,o=r.increasedLineWidthForHitTesting,a=r.points,s=r.defX,u=void 0===s?0:s,h=r.defY,l=void 0===h?0:h;return!(!c(aa(r.pointerEvents,r.fill,r.stroke),2)[1]&&!n||!i)&&hx(a.points,(i||0)+(o||0),e.x+u,e.y+l,!1)}function xx(t,e,n,r,i){var o=t.parsedStyle,a=o.radius,s=o.fill,u=o.stroke,h=o.lineWidth,l=o.increasedLineWidthForHitTesting,d=o.width,f=o.height,p=c(aa(o.pointerEvents,s,u),2),g=p[0],m=p[1],v=(h||0)+(l||0);if(a&&a.some((function(t){return 0!==t}))){var y=!1;return(m||n)&&(y=function(t,e,n,r,i,o,a,s){var u=c(i,4),h=u[0],l=u[1],d=u[2],f=u[3];return cx(t+h,e,t+n-l,e,o,a,s)||cx(t+n,e+l,t+n,e+r-d,o,a,s)||cx(t+n-d,e+r,t+f,e+r,o,a,s)||cx(t,e+r-f,t,e+h,o,a,s)||ux(t+n-l,e+l,l,Math.PI,Math.PI,o,a,s)||ux(t+n-d,e+r-d,d,0,Math.PI,o,a,s)||ux(t+f,e+r-f,f,Math.PI,Math.PI,o,a,s)||ux(t+h,e+h,h,Math.PI,Math.PI,o,a,s)}(0,0,d,f,a.map((function(t){return Gt(t,0,Math.min(Math.abs(d)/2,Math.abs(f)/2))})),v,e.x,e.y)),y||!g&&!n||(y=r(t,e)),y}var E=v/2;return g&&m||n?sx(0-E,0-E,d+E,f+E,e.x,e.y):g?sx(0,0,d,f,e.x,e.y):!!m&&function(t,e,n,r,i,o,a){var s=i/2;return sx(t-s,e-s,n,i,o,a)||sx(t+n-s,e-s,i,r,o,a)||sx(t+s,e+r-s,n,i,o,a)||sx(t-s,e+s,i,r,o,a)}(0,0,d,f,v,e.x,e.y)}function bx(t,e,n,r,i,o){var a=t.parsedStyle,s=a.pointerEvents,u=a.width,c=a.height;if("non-transparent-pixel"===s){var h=i.config.offscreenCanvas,l=o.offscreenCanvasCreator.getOrCreateCanvas(h),d=o.offscreenCanvasCreator.getOrCreateContext(h,{willReadFrequently:!0});return l.width=u,l.height=c,i.defaultStyleRendererFactory[jn.IMAGE].render(d,t.parsedStyle,t,void 0,void 0,void 0),d.getImageData(e.x,e.y,1,1).data.every((function(t){return 0!==t}))}return!0}var wx=function(t){function e(){var e=t.apply(this,h([],c(arguments),!1))||this;return e.name="canvas-picker",e}return r(e,t),e.prototype.init=function(){var t,e=((t={})[jn.CIRCLE]=ix,t[jn.ELLIPSE]=ax,t[jn.RECT]=xx,t[jn.LINE]=mx,t[jn.POLYLINE]=Ex,t[jn.POLYGON]=yx,t[jn.PATH]=vx,t[jn.TEXT]=function(){return!0},t[jn.GROUP]=null,t[jn.IMAGE]=bx,t[jn.HTML]=null,t[jn.MESH]=null,t);this.context.pointInPathPickerFactory=e,this.addRenderingPlugin(new rx)},e.prototype.destroy=function(){delete this.context.pointInPathPickerFactory,this.removeAllRenderingPlugins()},e}(Wn),Mx=function(){function t(t){this.canvasRendererPluginOptions=t,this.removedRBushNodeAABBs=[],this.renderQueue=[],this.restoreStack=[],this.clearFullScreen=!1,this.vpMatrix=y(),this.dprMatrix=y(),this.tmpMat4=y(),this.vec3a=K(),this.vec3b=K(),this.vec3c=K(),this.vec3d=K()}return t.prototype.apply=function(e,n){var r=this;this.context=e;var i=e.config,o=e.camera,a=e.renderingService,s=e.renderingContext,u=e.rBushRoot,l=e.pathGeneratorFactory;this.rBush=u,this.pathGeneratorFactory=l;var d=e.contextService,f=s.root.ownerDocument.defaultView,p=function(t){var e=t.target.rBushNode;e.aabb&&r.removedRBushNodeAABBs.push(e.aabb)},g=function(t){var e=t.target.rBushNode;e.aabb&&r.removedRBushNodeAABBs.push(e.aabb)};a.hooks.init.tap(t.tag,(function(){f.addEventListener(Wa.UNMOUNTED,p),f.addEventListener(Wa.CULLED,g);var t=d.getDPR(),e=i.width,n=i.height,o=d.getContext();r.clearRect(o,0,0,e*t,n*t,i.background)})),a.hooks.destroy.tap(t.tag,(function(){f.removeEventListener(Wa.UNMOUNTED,p),f.removeEventListener(Wa.CULLED,g),r.renderQueue=[],r.removedRBushNodeAABBs=[],r.restoreStack=[]})),a.hooks.beginFrame.tap(t.tag,(function(){var t=d.getContext(),e=d.getDPR(),n=i.width,o=i.height,s=r.canvasRendererPluginOptions,u=s.dirtyObjectNumThreshold,c=s.dirtyObjectRatioThreshold,h=a.getStats(),l=h.total,f=h.rendered,p=f/l;r.clearFullScreen=a.disableDirtyRectangleRendering()||f>u&&p>c,t&&(t.resetTransform?t.resetTransform():t.setTransform(1,0,0,1,0,0),r.clearFullScreen&&r.clearRect(t,0,0,n*e,o*e,i.background))}));var m=function(t,e){t.isVisible()&&!t.isCulled()&&(r.renderDisplayObject(t,e,r.context,r.restoreStack,n),r.saveDirtyAABB(t)),(t.sortable.sorted||t.childNodes).forEach((function(t){m(t,e)}))};a.hooks.endFrame.tap(t.tag,(function(){var t=d.getContext(),e=d.getDPR();if(R(r.dprMatrix,[e,e,1]),T(r.vpMatrix,r.dprMatrix,o.getOrthoMatrix()),r.clearFullScreen)m(s.root,t);else{var a=r.safeMergeAABB.apply(r,h([r.mergeDirtyAABBs(r.renderQueue)],c(r.removedRBushNodeAABBs.map((function(t){var e=t.minX,n=t.minY,r=t.maxX,i=t.maxY,o=new hr;return o.setMinMax([e,n,0],[r,i,0]),o}))),!1));if(r.removedRBushNodeAABBs=[],hr.isEmpty(a))return void(r.renderQueue=[]);var u=r.convertAABB2Rect(a),l=u.x,p=u.y,g=u.width,v=u.height,y=ut(r.vec3a,[l,p,0],r.vpMatrix),E=ut(r.vec3b,[l+g,p,0],r.vpMatrix),x=ut(r.vec3c,[l,p+v,0],r.vpMatrix),b=ut(r.vec3d,[l+g,p+v,0],r.vpMatrix),w=Math.min(y[0],E[0],b[0],x[0]),M=Math.min(y[1],E[1],b[1],x[1]),N=Math.max(y[0],E[0],b[0],x[0]),S=Math.max(y[1],E[1],b[1],x[1]),P=Math.floor(w),C=Math.floor(M),k=Math.ceil(N-w),A=Math.ceil(S-M);t.save(),r.clearRect(t,P,C,k,A,i.background),t.beginPath(),t.rect(P,C,k,A),t.clip(),t.setTransform(r.vpMatrix[0],r.vpMatrix[1],r.vpMatrix[4],r.vpMatrix[5],r.vpMatrix[12],r.vpMatrix[13]),i.renderer.getConfig().enableDirtyRectangleRenderingDebug&&f.dispatchEvent(new Ba(gs.DIRTY_RECTANGLE,{dirtyRect:{x:P,y:C,width:k,height:A}})),r.searchDirtyObjects(a).sort((function(t,e){return t.sortable.renderOrder-e.sortable.renderOrder})).forEach((function(e){e&&e.isVisible()&&!e.isCulled()&&r.renderDisplayObject(e,t,r.context,r.restoreStack,n)})),t.restore(),r.renderQueue.forEach((function(t){r.saveDirtyAABB(t)})),r.renderQueue=[]}r.restoreStack.forEach((function(){t.restore()})),r.restoreStack=[]})),a.hooks.render.tap(t.tag,(function(t){r.clearFullScreen||r.renderQueue.push(t)}))},t.prototype.clearRect=function(t,e,n,r,i,o){t.clearRect(e,n,r,i),o&&(t.fillStyle=o,t.fillRect(e,n,r,i))},t.prototype.renderDisplayObject=function(t,e,n,r,i){var o=t.nodeName,a=r[r.length-1];!a||t.compareDocumentPosition(a)&ja.DOCUMENT_POSITION_CONTAINS||(e.restore(),r.pop());var s=this.context.styleRendererFactory[o],u=this.pathGeneratorFactory[o],c=t.parsedStyle.clipPath;if(c){this.applyWorldTransform(e,c);var h=this.pathGeneratorFactory[c.nodeName];h&&(e.save(),r.push(t),e.beginPath(),h(e,c.parsedStyle),e.closePath(),e.clip())}s&&(this.applyWorldTransform(e,t),e.save(),this.applyAttributesToContext(e,t)),u&&(e.beginPath(),u(e,t.parsedStyle),t.nodeName!==jn.LINE&&t.nodeName!==jn.PATH&&t.nodeName!==jn.POLYLINE&&e.closePath()),s&&(s.render(e,t.parsedStyle,t,n,this,i),e.restore()),t.renderable.dirty=!1},t.prototype.convertAABB2Rect=function(t){var e=t.getMin(),n=t.getMax(),r=Math.floor(e[0]),i=Math.floor(e[1]);return{x:r,y:i,width:Math.ceil(n[0])-r,height:Math.ceil(n[1])-i}},t.prototype.mergeDirtyAABBs=function(t){var e=new hr;return t.forEach((function(t){var n=t.getRenderBounds();e.add(n);var r=t.renderable.dirtyRenderBounds;r&&e.add(r)})),e},t.prototype.searchDirtyObjects=function(t){var e=c(t.getMin(),2),n=e[0],r=e[1],i=c(t.getMax(),2),o=i[0],a=i[1];return this.rBush.search({minX:n,minY:r,maxX:o,maxY:a}).map((function(t){return t.displayObject}))},t.prototype.saveDirtyAABB=function(t){var e=t.renderable;e.dirtyRenderBounds||(e.dirtyRenderBounds=new hr);var n=t.getRenderBounds();n&&e.dirtyRenderBounds.update(n.center,n.halfExtents)},t.prototype.applyAttributesToContext=function(t,e){var n=e.parsedStyle,r=n.stroke,i=n.fill,o=n.opacity,a=n.lineDash,s=n.lineDashOffset;a&&t.setLineDash(a),Pt(s)||(t.lineDashOffset=s),Pt(o)||(t.globalAlpha*=o),Pt(r)||Array.isArray(r)||r.isNone||(t.strokeStyle=e.attributes.stroke),Pt(i)||Array.isArray(i)||i.isNone||(t.fillStyle=e.attributes.fill)},t.prototype.applyWorldTransform=function(t,e,n){var r=0,i=0,o=(e.parsedStyle||{}).anchor,a=o&&o[0]||0,s=o&&o[1]||0;if(0!==a||0!==s){var u=e.geometry.contentBounds;r=-a*(u&&2*u.halfExtents[0]||0),i=-s*(u&&2*u.halfExtents[1]||0)}n?(x(this.tmpMat4,e.getLocalTransform()),this.vec3a[0]=r,this.vec3a[1]=i,this.vec3a[2]=0,P(this.tmpMat4,this.tmpMat4,this.vec3a),T(this.tmpMat4,n,this.tmpMat4),T(this.tmpMat4,this.vpMatrix,this.tmpMat4)):(x(this.tmpMat4,e.getWorldTransform()),this.vec3a[0]=r,this.vec3a[1]=i,this.vec3a[2]=0,P(this.tmpMat4,this.tmpMat4,this.vec3a),T(this.tmpMat4,this.vpMatrix,this.tmpMat4)),t.setTransform(this.tmpMat4[0],this.tmpMat4[1],this.tmpMat4[4],this.tmpMat4[5],this.tmpMat4[12],this.tmpMat4[13])},t.prototype.safeMergeAABB=function(){for(var t=[],e=0;e<arguments.length;e++)t[e]=arguments[e];var n=new hr;return t.forEach((function(t){n.add(t)})),n},t.tag="CanvasRenderer",t}(),Nx=function(){function t(t){this.imagePool=t}return t.prototype.render=function(t,e,n,r,i,o){var a=e.fill,s=e.fillRule,u=e.opacity,c=e.fillOpacity,h=e.stroke,l=e.strokeOpacity,d=e.lineWidth,f=e.lineCap,p=e.lineJoin,g=e.shadowType,m=e.shadowColor,v=e.shadowBlur,y=e.filter,E=e.miterLimit,x=!Pt(a)&&!a.isNone,b=!Pt(h)&&!h.isNone&&d>0,w=0===a.alpha,M=!(!y||!y.length),N=!Pt(m)&&v>0,S=n.nodeName,T="inner"===g,P=b&&N&&(S===jn.PATH||S===jn.LINE||S===jn.POLYLINE||w||T);x&&(t.globalAlpha=u*c,P||Sx(n,t,N),this.fill(t,n,a,s,r,i,o),P||this.clearShadowAndFilter(t,M,N)),b&&(t.globalAlpha=u*l,t.lineWidth=d,Pt(E)||(t.miterLimit=E),Pt(f)||(t.lineCap=f),Pt(p)||(t.lineJoin=p),P&&(T&&(t.globalCompositeOperation="source-atop"),Sx(n,t,!0),T&&(this.stroke(t,n,h,r,i,o),t.globalCompositeOperation="source-over",this.clearShadowAndFilter(t,M,!0))),this.stroke(t,n,h,r,i,o))},t.prototype.clearShadowAndFilter=function(t,e,n){if(n&&(t.shadowColor="transparent",t.shadowBlur=0),e){var r=t.filter;!Pt(r)&&r.indexOf("drop-shadow")>-1&&(t.filter=r.replace(/drop-shadow\([^)]*\)/,"").trim()||"none")}},t.prototype.fill=function(t,e,n,r,i,o,a){var s=this;Array.isArray(n)?n.forEach((function(n){t.fillStyle=s.getColor(n,e,t),r?t.fill(r):t.fill()})):(xi(n)&&(t.fillStyle=this.getPattern(n,e,t,i,o,a)),r?t.fill(r):t.fill())},t.prototype.stroke=function(t,e,n,r,i,o){var a=this;Array.isArray(n)?n.forEach((function(n){t.strokeStyle=a.getColor(n,e,t),t.stroke()})):(xi(n)&&(t.strokeStyle=this.getPattern(n,e,t,r,i,o)),t.stroke())},t.prototype.getPattern=function(t,e,n,r,i,o){var a,s;if("rect"===t.image.nodeName){var u=t.image.parsedStyle,c=u.width,h=u.height;s=r.contextService.getDPR();var l=r.config.offscreenCanvas;(a=o.offscreenCanvasCreator.getOrCreateCanvas(l)).width=c*s,a.height=h*s;var d=o.offscreenCanvasCreator.getOrCreateContext(l),f=[];t.image.forEach((function(t){i.renderDisplayObject(t,d,r,f,o)})),f.forEach((function(){d.restore()}))}return this.imagePool.getOrCreatePatternSync(t,n,a,s,(function(){e.renderable.dirty=!0,r.renderingService.dirtify()}))},t.prototype.getColor=function(t,e,n){var r;if(t.type===Or.LinearGradient||t.type===Or.RadialGradient){var o=e.getGeometryBounds(),a=o&&2*o.halfExtents[0]||1,s=o&&2*o.halfExtents[1]||1;r=this.imagePool.getOrCreateGradient(i(i({type:t.type},t.value),{width:a,height:s}),n)}return r},t}();function Sx(t,e,n){var r=t.parsedStyle,i=r.filter,o=r.shadowColor,a=r.shadowBlur,s=r.shadowOffsetX,u=r.shadowOffsetY;i&&i.length&&(e.filter=t.style.filter),n&&(e.shadowColor=o.toString(),e.shadowBlur=a||0,e.shadowOffsetX=s||0,e.shadowOffsetY=u||0)}var Tx=function(){function t(t){this.imagePool=t}return t.prototype.render=function(t,e,n){var r,i=e.width,o=e.height,a=e.img,s=e.shadowColor,u=e.shadowBlur,c=i,h=o;if(zt(a)?r=this.imagePool.getImageSync(a):(c||(c=a.width),h||(h=a.height),r=a),r){Sx(n,t,!Pt(s)&&u>0);try{t.drawImage(r,0,0,c,h)}catch(t){}}},t}(),Px=function(){function t(){}return t.prototype.render=function(t,e,n,r,i,o){var a=e,s=a.lineWidth,u=a.textAlign,c=a.textBaseline,h=a.lineJoin,l=a.miterLimit,d=a.letterSpacing,f=a.stroke,p=a.fill,g=a.fillOpacity,m=a.strokeOpacity,v=a.opacity,y=a.metrics,E=a.dx,x=a.dy,b=a.shadowColor,w=a.shadowBlur,M=y.font,N=y.lines,S=y.height,T=y.lineHeight,P=y.lineMetrics;t.font=M,t.lineWidth=s,t.textAlign="middle"===u?"center":u;var C=c;o.enableCSSParsing||"alphabetic"!==C||(C="bottom"),t.lineJoin=h,Pt(l)||(t.miterLimit=l);var k=0;"middle"===c?k=-S/2-T/2:"bottom"===c||"alphabetic"===c||"ideographic"===c?k=-S:"top"!==c&&"hanging"!==c||(k=-T);var A=E||0;k+=x||0,1===N.length&&("bottom"===C?(C="middle",k-=.5*S):"top"===C&&(C="middle",k+=.5*S)),t.textBaseline=C,Sx(n,t,!Pt(b)&&w>0);for(var O=0;O<N.length;O++){var R=s/2+A;k+=T,Pt(f)||f.isNone||!s||this.drawLetterSpacing(t,N[O],P[O],u,R,k,d,g,m,v,!0),Pt(p)||this.drawLetterSpacing(t,N[O],P[O],u,R,k,d,g,m,v)}},t.prototype.drawLetterSpacing=function(t,e,n,r,i,o,a,s,u,c,h){if(void 0===h&&(h=!1),0!==a){var l=t.textAlign;t.textAlign="left";var d=i;"center"===r||"middle"===r?d=i-n.width/2:"right"!==r&&"end"!==r||(d=i-n.width);for(var f=Array.from(e),p=t.measureText(e).width,g=0,m=0;m<f.length;++m){var v=f[m];h?this.strokeText(t,v,d,o,u):this.fillText(t,v,d,o,s,c),d+=p-(g=t.measureText(e.substring(m+1)).width)+a,p=g}t.textAlign=l}else h?this.strokeText(t,e,i,o,u):this.fillText(t,e,i,o,s,c)},t.prototype.fillText=function(t,e,n,r,i,o){var a,s=!Pt(i)&&1!==i;s&&(a=t.globalAlpha,t.globalAlpha=i*o),t.fillText(e,n,r),s&&(t.globalAlpha=a)},t.prototype.strokeText=function(t,e,n,r,i){var o,a=!Pt(i)&&1!==i;a&&(o=t.globalAlpha,t.globalAlpha=i),t.strokeText(e,n,r),a&&(t.globalAlpha=o)},t}();!function(t){function e(){return null!==t&&t.apply(this,arguments)||this}r(e,t)}(Nx),function(t){function e(){return null!==t&&t.apply(this,arguments)||this}r(e,t)}(Nx),function(t){function e(){return null!==t&&t.apply(this,arguments)||this}r(e,t)}(Nx),function(t){function e(){return null!==t&&t.apply(this,arguments)||this}r(e,t)}(Nx),function(t){function e(){return null!==t&&t.apply(this,arguments)||this}r(e,t)}(Nx),function(t){function e(){return null!==t&&t.apply(this,arguments)||this}r(e,t)}(Nx),function(t){function e(){return null!==t&&t.apply(this,arguments)||this}r(e,t)}(Nx);var Cx=function(t){function e(e){void 0===e&&(e={});var n=t.call(this)||this;return n.options=e,n.name="canvas-renderer",n}return r(e,t),e.prototype.init=function(){var t,e=i({dirtyObjectNumThreshold:500,dirtyObjectRatioThreshold:.8},this.options),n=this.context.imagePool,r=new Nx(n),o=((t={})[jn.CIRCLE]=r,t[jn.ELLIPSE]=r,t[jn.RECT]=r,t[jn.IMAGE]=new Tx(n),t[jn.TEXT]=new Px,t[jn.LINE]=r,t[jn.POLYLINE]=r,t[jn.POLYGON]=r,t[jn.PATH]=r,t[jn.GROUP]=void 0,t[jn.HTML]=void 0,t[jn.MESH]=void 0,t);this.context.defaultStyleRendererFactory=o,this.context.styleRendererFactory=o,this.addRenderingPlugin(new Mx(e))},e.prototype.destroy=function(){this.removeAllRenderingPlugins(),delete this.context.defaultStyleRendererFactory,delete this.context.styleRendererFactory},e}(Wn),kx=function(){function t(){}return t.prototype.apply=function(e,n){var r=this,i=e.renderingService,o=e.renderingContext,a=e.config;this.context=e;var s=o.root.ownerDocument.defaultView,u=function(t){i.hooks.pointerMove.call(t)},c=function(t){i.hooks.pointerUp.call(t)},h=function(t){i.hooks.pointerDown.call(t)},l=function(t){i.hooks.pointerOver.call(t)},d=function(t){i.hooks.pointerOut.call(t)},f=function(t){i.hooks.pointerCancel.call(t)},p=function(t){i.hooks.pointerWheel.call(t)},g=function(t){i.hooks.click.call(t)};i.hooks.init.tap(t.tag,(function(){var t=r.context.contextService.getDomElement();n.globalThis.navigator.msPointerEnabled?(t.style.msContentZooming="none",t.style.msTouchAction="none"):s.supportsPointerEvents&&(t.style.touchAction="none"),s.supportsPointerEvents?function(t){n.globalThis.document.addEventListener("pointermove",u,!0),t.addEventListener("pointerdown",h,!0),t.addEventListener("pointerleave",d,!0),t.addEventListener("pointerover",l,!0),n.globalThis.addEventListener("pointerup",c,!0),n.globalThis.addEventListener("pointercancel",f,!0)}(t):function(t){n.globalThis.document.addEventListener("mousemove",u,!0),t.addEventListener("mousedown",h,!0),t.addEventListener("mouseout",d,!0),t.addEventListener("mouseover",l,!0),n.globalThis.addEventListener("mouseup",c,!0)}(t),s.supportsTouchEvents&&function(t){t.addEventListener("touchstart",h,!0),t.addEventListener("touchend",c,!0),t.addEventListener("touchmove",u,!0),t.addEventListener("touchcancel",f,!0)}(t),a.useNativeClickEvent&&t.addEventListener("click",g,!0),t.addEventListener("wheel",p,{passive:!0,capture:!0})})),i.hooks.destroy.tap(t.tag,(function(){var t=r.context.contextService.getDomElement();n.globalThis.navigator.msPointerEnabled?(t.style.msContentZooming="",t.style.msTouchAction=""):s.supportsPointerEvents&&(t.style.touchAction=""),s.supportsPointerEvents?function(t){n.globalThis.document.removeEventListener("pointermove",u,!0),t.removeEventListener("pointerdown",h,!0),t.removeEventListener("pointerleave",d,!0),t.removeEventListener("pointerover",l,!0),n.globalThis.removeEventListener("pointerup",c,!0)}(t):function(t){n.globalThis.document.removeEventListener("mousemove",u,!0),t.removeEventListener("mousedown",h,!0),t.removeEventListener("mouseout",d,!0),t.removeEventListener("mouseover",l,!0),n.globalThis.removeEventListener("mouseup",c,!0)}(t),s.supportsTouchEvents&&function(t){t.removeEventListener("touchstart",h,!0),t.removeEventListener("touchend",c,!0),t.removeEventListener("touchmove",u,!0),t.removeEventListener("touchcancel",f,!0)}(t),a.useNativeClickEvent&&t.removeEventListener("click",g,!0),t.removeEventListener("wheel",p,!0)}))},t.tag="DOMInteraction",t}(),Ax=function(t){function e(){var e=t.apply(this,h([],c(arguments),!1))||this;return e.name="dom-interaction",e}return r(e,t),e.prototype.init=function(){this.addRenderingPlugin(new kx)},e.prototype.destroy=function(){this.removeAllRenderingPlugins()},e}(Wn),Ox=function(){function t(){this.displayObjectHTMLElementMap=new WeakMap}return t.prototype.joinTransformMatrix=function(t){return"matrix(".concat([t[0],t[1],t[4],t[5],t[12],t[13]].join(","),")")},t.prototype.apply=function(e,n){var r=this,i=e.camera,o=e.renderingContext,a=e.renderingService;this.context=e;var s=o.root.ownerDocument.defaultView,u=s.context.eventService.nativeHTMLMap,c=function(t,e){e.style.transform=r.joinTransformMatrix(t.getWorldTransform())},h=function(t){var e=t.target;if(e.nodeName===jn.HTML){r.$camera||(r.$camera=r.createCamera(i));var o=r.getOrCreateEl(e);if(r.$camera.appendChild(o),n.enableCSSParsing){var a=e.ownerDocument.documentElement.attributes;Object.keys(a).forEach((function(t){o.style[t]=a[t]}))}Object.keys(e.attributes).forEach((function(t){r.updateAttribute(t,e)})),c(e,o),u.set(o,e)}},l=function(t){var e=t.target;if(e.nodeName===jn.HTML&&r.$camera){var n=r.getOrCreateEl(e);n&&(n.remove(),u.delete(n))}},d=function(t){var e=t.target;if(e.nodeName===jn.HTML){var n=t.attrName;r.updateAttribute(n,e)}},f=function(t){var e=t.target;if(e.nodeName===jn.HTML){var n=r.getOrCreateEl(e);c(e,n)}},p=function(){if(r.$camera){var t=r.context.config,e=t.width,n=t.height;r.$camera.style.width="".concat(e||0,"px"),r.$camera.style.height="".concat(n||0,"px")}};a.hooks.init.tap(t.tag,(function(){s.addEventListener(gs.RESIZE,p),s.addEventListener(Wa.MOUNTED,h),s.addEventListener(Wa.UNMOUNTED,l),s.addEventListener(Wa.ATTR_MODIFIED,d),s.addEventListener(Wa.BOUNDS_CHANGED,f)})),a.hooks.endFrame.tap(t.tag,(function(){r.$camera&&o.renderReasons.has(Ia.CAMERA_CHANGED)&&(r.$camera.style.transform=r.joinTransformMatrix(i.getOrthoMatrix()))})),a.hooks.destroy.tap(t.tag,(function(){r.$camera&&r.$camera.remove(),s.removeEventListener(gs.RESIZE,p),s.removeEventListener(Wa.MOUNTED,h),s.removeEventListener(Wa.UNMOUNTED,l),s.removeEventListener(Wa.ATTR_MODIFIED,d),s.removeEventListener(Wa.BOUNDS_CHANGED,f)}))},t.prototype.createCamera=function(t){var e=this.context.config,n=e.document,r=e.width,i=e.height,o=this.context.contextService.getDomElement(),a=o.parentNode;if(a){var s="g-canvas-camera",u=a.querySelector("#"+s);if(!u){var c=(n||document).createElement("div");u=c,c.id=s,c.style.position="absolute",c.style.left="".concat(o.offsetLeft||0,"px"),c.style.top="".concat(o.offsetTop||0,"px"),c.style.transformOrigin="left top",c.style.transform=this.joinTransformMatrix(t.getOrthoMatrix()),c.style.overflow="hidden",c.style.pointerEvents="none",c.style.width="".concat(r||0,"px"),c.style.height="".concat(i||0,"px"),a.appendChild(c)}return u}return null},t.prototype.getOrCreateEl=function(t){var e=this.context.config.document,n=this.displayObjectHTMLElementMap.get(t);return n||(n=(e||document).createElement("div"),t.parsedStyle.$el=n,this.displayObjectHTMLElementMap.set(t,n),t.id&&(n.id=t.id),t.name&&n.setAttribute("name",t.name),t.className&&(n.className=t.className),n.style.position="absolute",n.style.left="0px",n.style.top="0px",n.style["will-change"]="transform",n.style.transform=this.joinTransformMatrix(t.getWorldTransform())),n},t.prototype.updateAttribute=function(t,e){var n=this.getOrCreateEl(e);switch(t){case"innerHTML":var r=e.parsedStyle.innerHTML;zt(r)?n.innerHTML=r:(n.innerHTML="",n.appendChild(r));break;case"transformOrigin":var i=e.parsedStyle.transformOrigin;n.style["transform-origin"]="".concat(i[0].value," ").concat(i[1].value);break;case"width":if(this.context.enableCSSParsing){var o=e.computedStyleMap().get("width");n.style.width=o.toString()}else{o=e.parsedStyle.width;n.style.width=jt(o)?"".concat(o,"px"):o.toString()}break;case"height":if(this.context.enableCSSParsing){var a=e.computedStyleMap().get("height");n.style.height=a.toString()}else{a=e.parsedStyle.height;n.style.height=jt(a)?"".concat(a,"px"):a.toString()}break;case"zIndex":var s=e.parsedStyle.zIndex;n.style["z-index"]="".concat(s);break;case"visibility":var u=e.parsedStyle.visibility;n.style.visibility=u;break;case"pointerEvents":var c=e.parsedStyle.pointerEvents;n.style.pointerEvents=c;break;case"opacity":var h=e.parsedStyle.opacity;n.style.opacity="".concat(h);break;case"fill":var l=e.parsedStyle.fill,d="";bi(l)?d=l.isNone?"transparent":e.getAttribute("fill"):Array.isArray(l)?d=e.getAttribute("fill"):xi(l),n.style.background=d;break;case"stroke":var f=e.parsedStyle.stroke,p="";bi(f)?p=f.isNone?"transparent":e.getAttribute("stroke"):Array.isArray(f)?p=e.getAttribute("stroke"):xi(f),n.style["border-color"]=p,n.style["border-style"]="solid";break;case"lineWidth":var g=e.parsedStyle.lineWidth;n.style["border-width"]="".concat(g||0,"px");break;case"lineDash":n.style["border-style"]="dashed";break;case"filter":var m=e.style.filter;n.style.filter=m;break;default:"x"!==t&&"y"!==t&&(Pt(e.style[t])||""===e.style[t]||(n.style[t]=e.style[t]))}},t.tag="HTMLRendering",t}(),Rx=function(t){function e(){var e=t.apply(this,h([],c(arguments),!1))||this;return e.name="html-renderer",e}return r(e,t),e.prototype.init=function(){this.addRenderingPlugin(new Ox)},e.prototype.destroy=function(){this.removeAllRenderingPlugins()},e}(Wn),Dx=function(){function t(t){this.canvasConfig=t,this.imageCache={},this.gradientCache={},this.patternCache={}}return t.prototype.getImageSync=function(t,e){return this.imageCache[t]?e&&e(this.imageCache[t]):this.getOrCreateImage(t).then((function(t){e&&e(t)})),this.imageCache[t]},t.prototype.getOrCreateImage=function(t){var e=this;if(this.imageCache[t])return Promise.resolve(this.imageCache[t]);var n=this.canvasConfig.createImage;return new Promise((function(r,i){var o;n?o=n(t):Jo&&(o=new window.Image),o&&(o.onload=function(){e.imageCache[t]=o,r(o)},o.onerror=function(t){i(t)},o.crossOrigin="Anonymous",o.src=t)}))},t.prototype.getOrCreatePatternSync=function(t,e,n,r,i){var o=this.generatePatternKey(t);if(o&&this.patternCache[o])return this.patternCache[o];var a,s=t.image,u=t.repetition,c=t.transform,h=!1;zt(s)?a=this.getImageSync(s,i):n?(a=n,h=!0):a=s;var l=a&&e.createPattern(a,u);if(l){var d=void 0;d=c?Go(lo(c),new ws({})):w(y()),h&&C(d,d,[1/r,1/r,1]),l.setTransform({a:d[0],b:d[1],c:d[4],d:d[5],e:d[12],f:d[13]})}return o&&l&&(this.patternCache[o]=l),l},t.prototype.getOrCreateGradient=function(t,e){var n=this.generateGradientKey(t),r=t.type,i=t.steps,o=t.width,a=t.height,s=t.angle,u=t.cx,c=t.cy,h=t.size;if(this.gradientCache[n])return this.gradientCache[n];var l=null;if(r===Or.LinearGradient){var d=function(t,e,n){var r=Qn(n.value),i=0+t/2,o=0+e/2,a=Math.abs(t*Math.cos(r))+Math.abs(e*Math.sin(r));return{x1:i-Math.cos(r)*a/2,y1:o-Math.sin(r)*a/2,x2:i+Math.cos(r)*a/2,y2:o+Math.sin(r)*a/2}}(o,a,s),f=d.x1,p=d.y1,g=d.x2,m=d.y2;l=e.createLinearGradient(f,p,g,m)}else if(r===Or.RadialGradient){var v=function(t,e,n,r,i){var o=n.value,a=r.value;n.unit===xr.kPercentage&&(o=n.value/100*t),r.unit===xr.kPercentage&&(a=r.value/100*e);var s=Math.max(Oe([0,0],[o,a]),Oe([0,e],[o,a]),Oe([t,e],[o,a]),Oe([t,0],[o,a]));return i&&(i instanceof qr?s=i.value:i instanceof Fr&&("closest-side"===i.value?s=Math.min(o,t-o,a,e-a):"farthest-side"===i.value?s=Math.max(o,t-o,a,e-a):"closest-corner"===i.value&&(s=Math.min(Oe([0,0],[o,a]),Oe([0,e],[o,a]),Oe([t,e],[o,a]),Oe([t,0],[o,a]))))),{x:o,y:a,r:s}}(o,a,u,c,h),y=v.x,E=v.y,x=v.r;l=e.createRadialGradient(y,E,0,y,E,x)}return l&&(i.forEach((function(t){var e=t.offset,n=t.color;e.unit===xr.kPercentage&&(null==l||l.addColorStop(e.value/100,n.toString()))})),this.gradientCache[n]=l),this.gradientCache[n]},t.prototype.generateGradientKey=function(t){var e=t.type,n=t.width,r=t.height,i=t.steps,o=t.angle,a=t.cx,s=t.cy,u=t.size;return"gradient-".concat(e,"-").concat((null==o?void 0:o.toString())||0,"-").concat((null==a?void 0:a.toString())||0,"-").concat((null==s?void 0:s.toString())||0,"-").concat((null==u?void 0:u.toString())||0,"-").concat(n,"-").concat(r,"-").concat(i.map((function(t){var e=t.offset,n=t.color;return"".concat(e).concat(n)})).join("-"))},t.prototype.generatePatternKey=function(t){var e=t.image,n=t.repetition;return zt(e)?"pattern-".concat(e,"-").concat(n):"rect"===e.nodeName?"pattern-".concat(e.entity,"-").concat(n):void 0},t}(),Ix=function(){function t(){}return t.prototype.apply=function(e){var n=e.renderingService,r=e.renderingContext,i=e.imagePool,o=r.root.ownerDocument.defaultView,a=function(t,e,n){var r=t.parsedStyle,i=r.width,o=r.height;i&&!o?t.setAttribute("height",n/e*i):!i&&o&&t.setAttribute("width",e/n*o)},s=function(t){var e=t.target,r=e.nodeName,o=e.attributes;if(r===jn.IMAGE){var s=o.img,u=o.keepAspectRatio;zt(s)&&i.getImageSync(s,(function(t){var r=t.width,i=t.height;u&&a(e,r,i),e.renderable.dirty=!0,n.dirtify()}))}},u=function(t){var e=t.target,r=t.attrName,o=t.newValue;e.nodeName===jn.IMAGE&&"img"===r&&zt(o)&&i.getOrCreateImage(o).then((function(t){var r=t.width,i=t.height;e.attributes.keepAspectRatio&&a(e,r,i),e.renderable.dirty=!0,n.dirtify()}))};n.hooks.init.tap(t.tag,(function(){o.addEventListener(Wa.MOUNTED,s),o.addEventListener(Wa.ATTR_MODIFIED,u)})),n.hooks.destroy.tap(t.tag,(function(){o.removeEventListener(Wa.MOUNTED,s),o.removeEventListener(Wa.ATTR_MODIFIED,u)}))},t.tag="LoadImage",t}(),Lx=function(t){function e(){var e=t.apply(this,h([],c(arguments),!1))||this;return e.name="image-loader",e}return r(e,t),e.prototype.init=function(){this.context.imagePool=new Dx(this.context.config),this.addRenderingPlugin(new Ix)},e.prototype.destroy=function(){this.removeAllRenderingPlugins()},e}(Wn),_x=function(){function t(t){this.renderingContext=t.renderingContext,this.canvasConfig=t.config}return t.prototype.init=function(){var t=this.canvasConfig,e=t.container,n=t.canvas;if(n)this.$canvas=n,e&&n.parentElement!==e&&e.appendChild(n),this.$container=n.parentElement,this.canvasConfig.container=this.$container;else if(e&&(this.$container=zt(e)?document.getElementById(e):e,this.$container)){var r=document.createElement("canvas");this.$container.appendChild(r),this.$container.style.position||(this.$container.style.position="relative"),this.$canvas=r}this.context=this.$canvas.getContext("2d"),this.resize(this.canvasConfig.width,this.canvasConfig.height)},t.prototype.getContext=function(){return this.context},t.prototype.getDomElement=function(){return this.$canvas},t.prototype.getDPR=function(){return this.dpr},t.prototype.getBoundingClientRect=function(){if(this.$canvas.getBoundingClientRect)return this.$canvas.getBoundingClientRect()},t.prototype.destroy=function(){this.$container&&this.$canvas&&this.$canvas.parentNode&&this.$container.removeChild(this.$canvas)},t.prototype.resize=function(t,e){var n=this.canvasConfig.devicePixelRatio||Jo&&window.devicePixelRatio||1;n=n>=1?Math.ceil(n):1,this.dpr=n,this.$canvas&&(this.$canvas.width=this.dpr*t,this.$canvas.height=this.dpr*e,function(t,e,n){Jo&&t.style&&(t.style.width=e+"px",t.style.height=n+"px")}(this.$canvas,t,e)),this.renderingContext.renderReasons.add(Ia.CAMERA_CHANGED)},t.prototype.applyCursorStyle=function(t){this.$container&&this.$container.style&&(this.$container.style.cursor=t)},t.prototype.toDataURL=function(t){return void 0===t&&(t={}),a(this,void 0,void 0,(function(){var e,n;return s(this,(function(r){return e=t.type,n=t.encoderOptions,[2,this.context.canvas.toDataURL(e,n)]}))}))},t}(),zx=function(t){function e(){var e=t.apply(this,h([],c(arguments),!1))||this;return e.name="canvas-context-register",e}return r(e,t),e.prototype.init=function(){this.context.ContextService=_x},e.prototype.destroy=function(){delete this.context.ContextService},e}(Wn),Fx=function(t){function e(e){var n=t.call(this,e)||this;return n.registerPlugin(new zx),n.registerPlugin(new Lx),n.registerPlugin(new QE),n.registerPlugin(new Cx),n.registerPlugin(new Ax),n.registerPlugin(new wx),n.registerPlugin(new Rx),n}return r(e,t),e}(Hn),Bx=function(){function t(t){this.dragndropPluginOptions=t}return t.prototype.apply=function(e){var n=this,r=e.renderingService,i=e.renderingContext.root.ownerDocument,o=i.defaultView,u=function(t){var e=t.target,r=e===i,u=r&&n.dragndropPluginOptions.isDocumentDraggable?i:e.closest&&e.closest("[draggable=true]");if(u){var c=!1,h=t.timeStamp,l=[t.clientX,t.clientY],d=null,f=[t.clientX,t.clientY],p=function(t){return a(n,void 0,void 0,(function(){var n,o,a,p,g,m;return s(this,(function(s){switch(s.label){case 0:if(!c){if(n=t.timeStamp-h,o=Oe([t.clientX,t.clientY],l),n<=this.dragndropPluginOptions.dragstartTimeThreshold||o<=this.dragndropPluginOptions.dragstartDistanceThreshold)return[2];t.type="dragstart",u.dispatchEvent(t),c=!0}return t.type="drag",t.dx=t.clientX-f[0],t.dy=t.clientY-f[1],u.dispatchEvent(t),f=[t.clientX,t.clientY],r?[3,2]:(a="pointer"===this.dragndropPluginOptions.overlap?[t.canvasX,t.canvasY]:e.getBounds().center,[4,i.elementsFromPoint(a[0],a[1])]);case 1:p=s.sent(),g=p[p.indexOf(e)+1],m=(null==g?void 0:g.closest("[droppable=true]"))||(this.dragndropPluginOptions.isDocumentDroppable?i:null),d!==m&&(d&&(t.type="dragleave",t.target=d,d.dispatchEvent(t)),m&&(t.type="dragenter",t.target=m,m.dispatchEvent(t)),(d=m)&&(t.type="dragover",t.target=d,d.dispatchEvent(t))),s.label=2;case 2:return[2]}}))}))};o.addEventListener("pointermove",p);var g=function(t){if(c){t.detail={preventClick:!0};var e=t.clone();d&&(e.type="drop",e.target=d,d.dispatchEvent(e)),e.type="dragend",u.dispatchEvent(e),c=!1}o.removeEventListener("pointermove",p)};e.addEventListener("pointerup",g,{once:!0}),e.addEventListener("pointerupoutside",g,{once:!0})}};r.hooks.init.tap(t.tag,(function(){o.addEventListener("pointerdown",u)})),r.hooks.destroy.tap(t.tag,(function(){o.removeEventListener("pointerdown",u)}))},t.tag="Dragndrop",t}(),Gx=function(t){function e(e){void 0===e&&(e={});var n=t.call(this)||this;return n.options=e,n.name="dragndrop",n}return r(e,t),e.prototype.init=function(){this.addRenderingPlugin(new Bx(i({overlap:"pointer",isDocumentDraggable:!1,isDocumentDroppable:!1,dragstartDistanceThreshold:0,dragstartTimeThreshold:0},this.options)))},e.prototype.destroy=function(){this.removeAllRenderingPlugins()},e.prototype.setOptions=function(t){Object.assign(this.plugins[0].dragndropPluginOptions,t)},e}(Wn);class jx{config;background;main;label;transient;transientLabel;get canvas(){return{main:this.main,label:this.label,transient:this.transient,transientLabel:this.transientLabel,background:this.background}}get document(){return this.main.document}renderers;constructor(t){this.config=t}async init(){if(Object.entries(this.canvas).every((([,t])=>!t))){const{renderer:t,background:e,...n}=this.config,r=["main","label","transient","transientLabel","background"],{renderers:i,canvas:o}=r.reduce(((e,r)=>{const i=Tt(t)?t?.(r):new Fx;i.registerPlugin(new Gx({isDocumentDraggable:!0,isDocumentDroppable:!0,dragstartDistanceThreshold:10,dragstartTimeThreshold:100})),"main"!==r&&i.unregisterPlugin(i.getPlugin("dom-interaction"));const o=new Ys({renderer:i,supportsMutipleCanvasesInOneContainer:!0,...n});return e.renderers[r]=i,e.canvas[r]=o,this[r]=o,e}),{renderers:{},canvas:{}});this.renderers=i,Object.entries(o).forEach((([t,e])=>{const n=e.getContextService().getDomElement();n.style.position="absolute",n.style.outline="none",n.tabIndex=1,"main"!==t&&(n.style.pointerEvents="none")}))}return this.setBackground(),Promise.all(Object.values(this.canvas).map((t=>t.ready)))}getRendererType(t="main"){const e=this.renderers[t].getPlugins();for(const t of e){if("canvas-renderer"===t.name)return"canvas";if("svg-renderer"===t.name)return"svg";if("device-renderer"===t.name)return"gpu"}return"unknown"}get context(){return this.main.context}getDevice(){return this.main.context?.deviceRendererPlugin?.getDevice()}getConfig(){return this.config}setBackground(t=this.config.background){const e=this.getContainer();e&&t&&(e.style.background=t,e.style.transition="background 0.5s")}setCursor(t){Object.values(this.canvas).forEach((e=>{e.setCursor(t)}))}getSize(){return[this.config.width||0,this.config.height||0]}resize(t,e){this.config.width=t,this.config.height=e,Object.values(this.canvas).forEach((n=>{n.resize(t,e)}))}getCamera(){return this.main.getCamera()}getBounds(){return bc(Object.values(this.canvas).map((t=>t.document.documentElement)).filter((t=>t.childNodes.length>0)).map((t=>t.getBounds())))}getContainer(){const t=this.config.container;return zt(t)?document.getElementById(t):t}appendChild(t){return this[t.style?.$layer||"main"].appendChild(t)}getContextService(){return this.main.getContextService()}viewport2Client(t){return this.main.viewport2Client(t)}viewport2Canvas(t){return this.main.viewport2Canvas(t)}client2Viewport(t){return this.main.client2Viewport(t)}canvas2Viewport(t){return this.main.canvas2Viewport(t)}async toDataURL(t={}){const e=window.devicePixelRatio||1,{width:n,height:r,renderer:i}=this.config,o=function(t){var e=document.createElement("div");e.innerHTML=t;var n=e.childNodes[0];return n&&e.contains(n)&&e.removeChild(n),n}('<div id="virtual-image"></div>'),a=new Ys({width:n,height:r,renderer:i?.("main")||new Fx,devicePixelRatio:e,container:o,background:this.background.getConfig().background});await a.ready,a.appendChild(this.background.getRoot().cloneNode(!0)),a.appendChild(this.main.getRoot().cloneNode(!0));const s=this.label.getRoot().cloneNode(!0),u=a.viewport2Canvas({x:0,y:0}),c=this.main.viewport2Canvas({x:0,y:0});s.translate([c.x-u.x,c.y-u.y]),s.scale(1/this.main.getCamera().getZoom()),a.appendChild(s),a.appendChild(this.transient.getRoot().cloneNode(!0));const h=this.main.getCamera(),l=a.getCamera();l.setZoom(h.getZoom()),l.setPosition(h.getPosition()),l.setFocalPoint(h.getFocalPoint());return a.getContextService().toDataURL(t)}destroy(){Object.values(this.canvas).forEach((t=>{const e=t.getCamera();e.landmarks?.length&&e.cancelLandmarkAnimation(),t.destroy()}))}}function Vx(t,e){const{data:n,style:r,...i}=t,{data:o,style:a,...s}=e,u={...i,...s};return(n||o)&&Object.assign(u,{data:{...n,...o}}),(r||a)&&Object.assign(u,{style:{...r,...a}}),u}function Ux(t){const{data:e,style:n,...r}=t,i=r;return e&&(i.data={...e}),n&&(i.style={...n}),i}function Wx(t){const{id:e=Dc(t),style:n,data:r,...i}=t,o={...t,style:{...n},data:{...r}};return dc(t)?{id:e,data:o,...i}:{id:e,data:o}}function Hx(t){return t.data}class qx{model;latestRemovedComboIds=new Set;comboIds=new Set;changes=[];batchCount=0;isTraceless=!1;constructor(){this.model=new Cp}pushChange(t){if(this.isTraceless)return;const{type:e}=t;if(e===nc.NodeUpdated||e===nc.EdgeUpdated||e===nc.ComboUpdated){const{value:n,original:r}=t;this.changes.push({value:Ux(n),original:Ux(r),type:e})}else this.changes.push({value:Ux(t.value),type:e})}getChanges(){const t=this.changes;return this.changes=[],t}batch(t){this.batchCount++,this.model.batch(t),this.batchCount--}silence(t){this.isTraceless=!0,t(),this.isTraceless=!1}isCombo(t){return this.comboIds.has(t)||this.latestRemovedComboIds.has(t)}getData(){return{nodes:this.getNodeData(),edges:this.getEdgeData(),combos:this.getComboData()}}getNodeData(t){return this.model.getAllNodes().reduce(((e,n)=>{const r=Hx(n);return this.isCombo(Dc(r))||(void 0===t||t.includes(Dc(r)))&&e.push(r),e}),[])}getEdgeData(t){return this.model.getAllEdges().reduce(((e,n)=>{const r=Hx(n);return(void 0===t||t.includes(Dc(r)))&&e.push(r),e}),[])}getComboData(t){return this.model.getAllNodes().reduce(((e,n)=>{const r=Hx(n);return this.isCombo(Dc(r))?((void 0===t||t.includes(Dc(r)))&&e.push(r),e):e}),[])}getAncestorsData(t,e){const{model:n}=this;return n.hasNode(t)&&n.hasTreeStructure(e)?n.getAncestors(t,e).map(Hx):[]}getDescendantsData(t){const e=this.getElementsData([t])[0],n=[];return DE(e,(t=>{t!==e&&n.push(t)}),(t=>this.getChildrenData(Dc(t))),"TB"),n}getParentData(t,e=this.inferStructureKey(t)){const{model:n}=this;if(!e)return void console.error("The hierarchy structure key is not specified");if(!n.hasNode(t)||!n.hasTreeStructure(e))return;const r=n.getParent(t,e);return r?Hx(r):void 0}getChildrenData(t){const e="node"===this.getElementType(t)?lc:hc,{model:n}=this;return n.hasNode(t)&&n.hasTreeStructure(e)?n.getChildren(t,e).map(Hx):[]}inferStructureKey(t){if(this.isCombo(t))return hc}getElementData(t){return"node"===t?this.getNodeData():"edge"===t?this.getEdgeData():"combo"===t?this.getComboData():[]}getElementsData(t){return t.map((t=>{const e=this.getElementType(t);return"node"===e?this.getNodeData([t])[0]:"edge"===e?this.getEdgeData([t])[0]:this.getComboData([t])[0]}))}getNodeLikeData(t){return this.model.getAllNodes().reduce(((e,n)=>{const r=Hx(n);return t?t.includes(Dc(r))&&e.push(r):e.push(r),e}),[])}getElementDataByState(t,e){return this.getElementData(t).filter((t=>t.style?.states?.includes(e)))}getElementState(t){return this.getElementsData([t])?.[0]?.style?.states||[]}hasNode(t){return this.model.hasNode(t)&&!this.isCombo(t)}hasEdge(t){return this.model.hasEdge(t)}hasCombo(t){return this.model.hasNode(t)&&this.isCombo(t)}getRelatedEdgesData(t,e="both"){return this.model.getRelatedEdges(t,e).map(Hx)}getNeighborNodesData(t){return this.model.getNeighbors(t).map(Hx)}setData(t){const{nodes:e=[],edges:n=[],combos:r=[]}=t,{nodes:i=[],edges:o=[],combos:a=[]}=this.getData(),s=wl(i,e,(t=>Dc(t))),u=wl(o,n,(t=>Dc(t))),c=wl(a,r,(t=>Dc(t)));this.batch((()=>{this.addData({nodes:s.enter,edges:u.enter,combos:c.enter}),this.updateData({nodes:s.update,edges:u.update,combos:c.update}),this.removeData({nodes:s.exit.map(Dc),edges:u.exit.map(Dc),combos:c.exit.map(Dc)})}))}addData(t){const{nodes:e,edges:n,combos:r}=t;this.batch((()=>{this.addComboData(r),this.addNodeData(e),this.addEdgeData(n)}))}addNodeData(t=[]){t.length&&(this.model.addNodes(t.map((t=>(this.pushChange({value:t,type:nc.NodeAdded}),Wx(t))))),this.updateNodeLikeHierarchy(t))}addEdgeData(t=[]){t.length&&this.model.addEdges(t.map((t=>(this.pushChange({value:t,type:nc.EdgeAdded}),Wx(t)))))}addComboData(t=[]){if(!t.length)return;const{model:e}=this;e.hasTreeStructure(hc)||e.attachTreeStructure(hc),e.addNodes(t.map((t=>(this.comboIds.add(Dc(t)),this.pushChange({value:t,type:nc.ComboAdded}),Wx(t))))),this.updateNodeLikeHierarchy(t)}updateNodeLikeHierarchy(t){if(!this.enableUpdateNodeLikeHierarchy)return;const{model:e}=this;t.forEach((t=>{const n=Dc(t);e.attachTreeStructure(hc),this.setParent(n,Ic(t),hc);const r=t?.style?.children;void 0!==r&&(e.attachTreeStructure(lc),r.forEach((t=>{this.setParent(t,n,lc)})))}))}enableUpdateNodeLikeHierarchy=!0;preventUpdateNodeLikeHierarchy(t){this.enableUpdateNodeLikeHierarchy=!1,t(),this.enableUpdateNodeLikeHierarchy=!0}updateData(t){const{nodes:e,edges:n,combos:r}=t;this.batch((()=>{this.updateNodeData(e),this.updateComboData(r),this.updateEdgeData(n)}))}updateNodeData(t=[]){if(!t.length)return;const{model:e}=this;this.batch((()=>{const n=[];t.forEach((t=>{const r=Dc(t),i=Hx(e.getNode(r));if(re(i,t))return;const o=Vx(i,t);this.pushChange({value:o,original:i,type:nc.NodeUpdated}),e.mergeNodeData(r,o),n.push(o)})),this.updateNodeLikeHierarchy(n)}))}syncNodeDatum(t){const{model:e}=this,n=Dc(t),r=Vx(Hx(e.getNode(n)),t);e.mergeNodeData(n,r)}updateEdgeData(t=[]){if(!t.length)return;const{model:e}=this;this.batch((()=>{t.forEach((t=>{const n=Dc(t),r=Hx(e.getEdge(n));if(re(r,t))return;t.source&&r.source!==t.source&&e.updateEdgeSource(n,t.source),t.target&&r.target!==t.target&&e.updateEdgeTarget(n,t.target);const i=Vx(r,t);e.mergeEdgeData(n,i),this.pushChange({value:i,original:r,type:nc.EdgeUpdated})}))}))}updateComboData(t=[]){if(!t.length)return;const{model:e}=this;e.batch((()=>{const n=[];t.forEach((t=>{const r=Dc(t),i=Hx(e.getNode(r));if(re(i,t))return;const o=Vx(i,t);this.pushChange({value:o,original:i,type:nc.ComboUpdated}),e.mergeNodeData(r,o),n.push(o)})),this.updateNodeLikeHierarchy(n)}))}setParent(t,e,n,r=!0){if(t===e)return;const i=Ic(this.getNodeLikeData([t])[0]);if(i!==e){const n={id:t,style:{parentId:e}};this.isCombo(t)?this.syncComboDatum(n):this.syncNodeDatum(n)}this.model.setParent(t,e,n),r&&new Set([i,e]).forEach((t=>{void 0!==t&&this.refreshComboData(t)}))}refreshComboData(t){const e=this.getComboData([t])[0],n=this.getAncestorsData(t,hc);e&&this.pushChange({value:e,original:e,type:nc.ComboUpdated}),n.forEach((t=>{this.pushChange({value:t,original:t,type:nc.ComboUpdated})}))}syncComboDatum(t){const{model:e}=this,n=Dc(t),r=Vx(Hx(e.getNode(n)),t);e.mergeNodeData(n,r)}getElementPosition(t){return Sc(this.getElementsData([t])[0])}translateNodeBy(t,e){const n=Gc(this.getElementPosition(t),[...e,0].slice(0,3));this.translateNodeTo(t,n)}translateNodeTo(t,e){const[n=0,r=0,i=0]=e;this.preventUpdateNodeLikeHierarchy((()=>{this.updateNodeData([{id:t,style:{x:n,y:r,z:i}}])}))}translateComboBy(t,e){const[n=0,r=0,i=0]=e;if([n,r,i].some(isNaN)||[n,r,i].every((t=>0===t)))return;const o=this.getComboData([t])[0];o&&DE(o,(t=>{const e=Dc(t),[o,a,s]=Sc(t),u=Vx(t,{style:{x:o+n,y:a+r,z:s+i}});this.pushChange({value:u,original:t,type:this.isCombo(e)?nc.ComboUpdated:nc.NodeUpdated}),this.model.mergeNodeData(e,u)}),(t=>this.getChildrenData(Dc(t))),"BT")}translateComboTo(t,e){if(e.some(isNaN))return;const[n=0,r=0,i=0]=e,o=this.getComboData([t])?.[0];if(!o)return;const[a,s,u]=Sc(o),c=n-a,h=r-s,l=i-u;DE(o,(t=>{const e=Dc(t),[n,r,i]=Sc(t),o=Vx(t,{style:{x:n+c,y:r+h,z:i+l}});this.pushChange({value:o,original:t,type:this.isCombo(e)?nc.ComboUpdated:nc.NodeUpdated}),this.model.mergeNodeData(e,o)}),(t=>this.getChildrenData(Dc(t))),"BT")}removeData(t){const{nodes:e,edges:n,combos:r}=t;this.batch((()=>{this.removeEdgeData(n),this.removeNodeData(e),this.removeComboData(r),this.latestRemovedComboIds=new Set(r)}))}removeNodeData(t=[]){t.length&&this.batch((()=>{t.forEach((t=>{this.removeEdgeData(this.getRelatedEdgesData(t).map(Dc)),this.pushChange({value:this.getNodeData([t])[0],type:nc.NodeRemoved}),this.removeNodeLikeHierarchy(t)})),this.model.removeNodes(t)}))}removeEdgeData(t=[]){t.length&&(t.forEach((t=>this.pushChange({value:this.getEdgeData([t])[0],type:nc.EdgeRemoved}))),this.model.removeEdges(t))}removeComboData(t=[]){t.length&&this.batch((()=>{t.forEach((t=>{this.pushChange({value:this.getComboData([t])[0],type:nc.ComboRemoved}),this.removeNodeLikeHierarchy(t),this.comboIds.delete(t)})),this.model.removeNodes(t)}))}removeNodeLikeHierarchy(t){if(this.model.hasTreeStructure(hc)){const e=Ic(this.getNodeLikeData([t])[0]);this.setParent(t,void 0,hc,!1),this.model.getChildren(t,hc).forEach((t=>{const n=Hx(t),r=Dc(n);this.setParent(Dc(n),e,hc,!1);const i=Vx(n,{id:Dc(n),style:{parentId:e}});this.pushChange({value:i,original:n,type:this.isCombo(r)?nc.ComboUpdated:nc.NodeUpdated}),this.model.mergeNodeData(Dc(n),i)})),$t(e)||this.refreshComboData(e)}}getElementType(t){if(this.model.hasNode(t))return this.isCombo(t)?"combo":"node";if(this.model.hasEdge(t))return"edge";throw new Error(`Unknown element type of id: ${t}`)}getFrontZIndex(t){let e=[];if("combo"===this.getElementType(t)){const n=[t,...this.getAncestorsData(t,hc).map(Dc)];e=this.getComboData().filter((t=>{const e=Dc(t),r=this.getAncestorsData(e,hc),i=r.map(Dc);return!r.some((t=>!!t.style?.collapsed))&&!n.includes(e)&&!i.includes(e)}))}else e=this.getNodeData().filter((e=>Dc(e)!==t));return Math.max(0,...e.map(UE))+1}destroy(){const{model:t}=this,e=t.getAllNodes(),n=t.getAllEdges();t.removeEdges(n.map((t=>t.id))),t.removeNodes(e.map((t=>t.id))),delete this.context}}class Yx{context;container;elementMap={};shapeTypeMap={};constructor(t){this.context=t}init(){const{canvas:t}=this.context;this.container||(this.container={node:t.appendChild(new Ts({style:{zIndex:2}})),edge:t.appendChild(new Ts({style:{zIndex:1}})),combo:t.appendChild(new Ts({style:{zIndex:0}}))})}emit(t){const{graph:e}=this.context;e.emit(t.type,t)}forEachElementData(t){["node","edge","combo"].forEach((e=>{const n=this.context.model.getElementData(e);t(e,n)}))}getTheme(t){const{theme:e}=this.context.options;if(!e)return{};const n=RE("theme",e);return n?.[t]||{}}getThemeStyle(t){return this.getTheme(t).style||{}}getThemeStateStyle(t,e){const{state:n={}}=this.getTheme(t);return Object.assign({},...e.map((t=>n[t]||{})))}paletteStyle={};computePaletteStyle(){const{options:t}=this.context;this.paletteStyle={},this.forEachElementData(((e,n)=>{const r=Object.assign({},Xc(this.getTheme(e)?.palette),Xc(t[e]?.palette));!ne(r)&&r?.field&&Object.assign(this.paletteStyle,function(t,e){if(!e)return{};const{type:n,color:r,field:i,invert:o}=e,a=t=>{const e=zt(r)?RE("palette",r):r;if(Tt(e))return Object.fromEntries(t.map((([t,n])=>[t,e(o?1-n:n)])));if(Array.isArray(e)){const n=o?[...e].reverse():e;return Object.fromEntries(t.map((([t,r])=>[t,n[r%e.length]])))}return{}},s=(t,e)=>zt(t)?e.data?.[t]:t?.(e);if("group"===n){const e=Bt(t,(t=>{if(!i)return"default";const e=s(i,t);return e?String(e):"default"})),n=a(Object.keys(e).map(((t,e)=>[t,e]))),r={};return Object.entries(e).forEach((([t,e])=>{e.forEach((e=>{r[Dc(e)]=n[t]}))})),r}if("value"===n){const[e,n]=t.reduce((([t,e],n)=>{const r=s(i,n);if(!jt(r))throw new Error(`Palette field ${i} is not a number`);return[Math.min(t,r),Math.max(e,r)]}),[1/0,-1/0]),r=n-e;return a(t.map((t=>[t.id,(s(i,t)-e)/r])))}}(n,r))}))}getPaletteStyle(t){const e=this.paletteStyle[t];return e?{color:e}:{}}defaultStyle={};computedElementDefaultStyle(t,e){const{options:n}=this.context,r=n[t]?.style||{};this.defaultStyle[Dc(e.datum)]=VE(r,e)}computeElementsDefaultStyle(t){this.forEachElementData(((e,n)=>{n.filter((e=>void 0===t||t.includes(Dc(e)))).forEach(((t,r)=>{this.computedElementDefaultStyle(e,{datum:t,index:r,elementData:n})}))}))}getDefaultStyle(t){return this.defaultStyle[t]||{}}getElementState(t){try{const{model:e}=this.context;return e.getElementState(t)}catch{return[]}}stateStyle={};getElementStateStyle(t,e,n){const{options:r}=this.context;return VE(r[t]?.state?.[e]||{},n)}computeElementStatesStyle(t,e,n){this.stateStyle[Dc(n.datum)]=Object.assign({},...e.map((e=>this.getElementStateStyle(t,e,n))))}computeElementsStatesStyle(t){this.forEachElementData(((e,n)=>{n.filter((e=>void 0===t||t.includes(Dc(e)))).forEach(((t,r)=>{const i=this.getElementState(Dc(t));this.computeElementStatesStyle(e,i,{datum:t,index:r,elementData:n})}))}))}getStateStyle(t){return this.stateStyle[t]||{}}computeStyle(t){this.computePaletteStyle(),this.computeElementsDefaultStyle(t),this.computeElementsStatesStyle(t)}getElement(t){return this.elementMap[t]}getNodes(){return this.container.node.children}getEdges(){return this.container.edge.children}getCombos(){return this.container.combo.children}getAnimation(t,e){const{options:n}=this.context,r=n?.[t]?.animation;if(!1===r)return!1;const i=r?.[e];if(i)return i;const o=this.getTheme(t)?.animation;if(!1===o)return!1;const a=o?.[e];return a??!1}getAnimationExecutor(t,e,n=!0,r){const{options:i}=this.context;return!1!==i.animation&&n?(n,i,o,a)=>bl(i,this.getAnimation(t,e),{},{originalStyle:o,modifiedStyle:a,states:this.getElementState(n),...r}):()=>null}getEdgeEndsContext(t){const{source:e,target:n}=t;return{sourceNode:this.getElement(e),targetNode:this.getElement(n)}}getElementComputedStyle(t,e){const n=Dc(e),r=this.getThemeStyle(t),i=this.getPaletteStyle(n),o=e.style||{},a=this.getDefaultStyle(n),s=this.getThemeStateStyle(t,this.getElementState(n)),u=this.getStateStyle(n),c=Object.assign({},r,i,o,a,s,u);if("edge"===t)Object.assign(c,this.getEdgeEndsContext(e));else if("combo"===t){const t=this.context.model.getChildrenData(n),e=!!c.collapsed?[]:t.map((t=>this.getElement(Dc(t)))).filter(Boolean);Object.assign(c,{childrenNode:e,childrenData:t})}return c.type||(c.type={node:"circle",edge:"line",combo:"circle"}[t]),c}async draw(e={animation:!0}){const n=this.computeDrawData();if(!n)return;this.init(),this.computeStyle();const{add:r,update:i,remove:o}=n,a=this.getDestroyTasks(o,e),s=this.getCreateTasks(r,e),u=this.getUpdateTasks(i,e);await(function(t,e={}){if(0===t.length)return null;const{before:n,...r}=e;e.before?.();const i=ml(t.map((t=>t())).map((t=>t())).flat().filter(Boolean));return El(i,r),i}([...a,...s,...u],e.silence?{}:{before:()=>this.emit(new zE(t.GraphEvent.BEFORE_DRAW)),beforeAnimate:e=>this.emit(new FE(t.GraphEvent.BEFORE_ANIMATE,rc.DRAW,e,n)),afterAnimate:e=>this.emit(new FE(t.GraphEvent.AFTER_ANIMATE,rc.DRAW,e,n)),after:()=>this.emit(new zE(t.GraphEvent.AFTER_DRAW))})?.finished)}computeDrawData(){const{model:t}=this.context,e=function(t){const e={Added:new Map,Updated:new Map,Removed:new Map};return t.forEach((t=>{const{type:n,value:r}=t,i=Dc(r);if("NodeAdded"===n||"EdgeAdded"===n||"ComboAdded"===n)e.Added.set(i,t);else if("NodeUpdated"===n||"EdgeUpdated"===n||"ComboUpdated"===n)if(e.Added.has(i))e.Added.set(i,{type:n.replace("Updated","Added"),value:r});else if(e.Updated.has(i)){const{original:t}=e.Updated.get(i);e.Updated.set(i,{type:n,value:r,original:t})}else e.Updated.set(i,t);else"NodeRemoved"!==n&&"EdgeRemoved"!==n&&"ComboRemoved"!==n||(e.Added.has(i)||e.Updated.has(i)?(e.Added.delete(i),e.Updated.delete(i)):e.Removed.set(i,t))})),[...Array.from(e.Added.values()),...Array.from(e.Updated.values()),...Array.from(e.Removed.values())]}(t.getChanges());if(0===e.length)return null;const{NodeAdded:n=[],NodeUpdated:r=[],NodeRemoved:i=[],EdgeAdded:o=[],EdgeUpdated:a=[],EdgeRemoved:s=[],ComboAdded:u=[],ComboUpdated:c=[],ComboRemoved:h=[]}=Bt(e,(t=>t.type)),l=t=>new Map(t.map((t=>{const e=t.value;return[Dc(e),e]}))),d={add:{nodes:l(n),edges:l(o),combos:l(u)},update:{nodes:l(r),edges:l(a),combos:l(c)},remove:{nodes:l(i),edges:l(s),combos:l(h)}},f=[this.updateRelatedEdgeFlow,this.arrangeDrawOrderFlow,this.collapseExpandFlow].reduce(((t,e)=>e(t)),d);return f}updateRelatedEdgeFlow=t=>{const{model:e}=this.context,{update:{nodes:n,edges:r,combos:i}}=t,o=(t,n)=>{e.getRelatedEdgesData(n).forEach((t=>r.set(Dc(t),t)))};return n.forEach(o),i.forEach(o),t};arrangeDrawOrderFlow=t=>{const{model:e}=this.context,n=t.add.combos,r=[];return n.forEach(((t,n)=>{const i=e.getAncestorsData(n,"combo").map((t=>Dc(t))).reverse();r.push([n,t,i.length])})),t.add.combos=new Map(r.sort((([,,t],[,,e])=>e-t)).map((([t,e])=>[t,e]))),t};collapseExpandFlow=t=>{const{model:e}=this.context,{add:n,update:r}=t,i=(e,n,r)=>{const i=`${n}s`;Object.entries(t).forEach((([t,n])=>{e===t?n[i].set(Dc(r),r):n[i].delete(Dc(r))}))},o=[...t.update.combos.entries(),...t.add.combos.entries()];for(;o.length;){const[t,a]=o.pop();if(!!a.style?.collapsed){const s=e.getDescendantsData(t),u=s.map(Dc),{internal:c,external:h}=Hh(u,(t=>e.getRelatedEdgesData(t)));s.forEach((t=>{const n=Dc(t),r=o.findIndex((([t])=>t===n));-1!==r&&o.splice(r,1);const a=e.getElementType(n);i("remove",a,t)})),c.forEach((t=>i("remove","edge",t))),h.forEach((t=>{const e=Dc(t),i=u.includes(t.source)?"source":"target",o={...t,[i]:Dc(a)};n.edges.has(e)&&n.edges.set(e,o),r.edges.has(e)&&r.edges.set(e,o)}))}else{const n=e.getChildrenData(t),r=n.map(Dc),{edges:a}=Hh(r,(t=>e.getRelatedEdgesData(t)));[...n,...a].forEach((t=>{const n=Dc(t),r=e.getElementType(n),a=this.getElement(n);i(a?"update":"add",r,t),"combo"===r&&o.push([n,t])}))}}return t};createElement(t,e,n){const{animator:r}=n,i=Dc(e);if(this.getElement(i))return()=>null;const{type:o,...a}=this.getElementComputedStyle(t,e),s=RE(t,o);if(!s)return()=>null;const u=this.container[t].appendChild(new s({id:i,style:{context:this.context,...a}}));return this.shapeTypeMap[i]=o,this.elementMap[i]=u,()=>r?.(i,u,{...u.attributes,opacity:0})||null}getCreateTasks(t,e){const{nodes:n,edges:r,combos:i}=t,o=[];return[["node",n],["combo",i],["edge",r]].forEach((([t,n])=>{if(0===n.size)return;const r=this.getAnimationExecutor(t,"enter");n.forEach((n=>o.push((()=>this.createElement(t,n,{...e,animator:r})))))})),o}latestElementVisibilityMap=new WeakMap;updateElement(t,e,n){const{animator:r}=n,i=Dc(e),o=this.getElement(i);if(!o)return()=>null;const{type:a,...s}=this.getElementComputedStyle(t,e);if(this.shapeTypeMap[i]!==a)return()=>(this.destroyElement(e,{...n,animation:!1})(),this.createElement(t,e,{...n,animation:!1})(),null);if("visibility"===n.stage&&"visibility"in s){hh(o,"opacity")||uh(o,"opacity");const t=ch(o,"opacity")??yl("opacity");if(this.latestElementVisibilityMap.set(o,s.visibility),"hidden"!==s.visibility)return gl(o,{visibility:"visible"}),()=>r?.(i,o,{...o.attributes,opacity:0},{opacity:t})||null;if("hidden"===s.visibility)return()=>El(r?.(i,o,{...o.attributes,opacity:t},{opacity:0})||null,{after:()=>gl(o,{visibility:this.latestElementVisibilityMap.get(o)})})}const u={...o.attributes};return gl(o,s),()=>r?.(i,o,u)||null}getUpdateTasks(t,e){const{nodes:n,edges:r,combos:i}=t,o=[["node",n],["combo",i],["edge",r]],{animation:a,stage:s}=e,u=[];return o.forEach((([t,n])=>{if(0===n.size)return[];const r=this.getAnimationExecutor(t,s||"update",a);n.forEach((n=>u.push((()=>this.updateElement(t,n,{...e,animator:r})))))})),u}destroyElement(t,e){const{animator:n}=e,r=Dc(t),i=this.elementMap[r];return i?()=>{const t=n?.(r,i,{...i.attributes},{opacity:0})||null;return El(t,{after:()=>{this.clearElement(r),i.destroy()}}),t}:()=>null}getDestroyTasks(t,e){const{nodes:n,edges:r,combos:i}=t,o=[["combo",i],["edge",r],["node",n]],{animation:a,stage:s}=e,u=[];return o.forEach((([t,n])=>{if(0===n.size)return[];const r=this.getAnimationExecutor(t,s||"exit",a);n.forEach((t=>u.push((()=>this.destroyElement(t,{...e,animator:r})))))})),u}clearElement(t){delete this.paletteStyle[t],delete this.defaultStyle[t],delete this.stateStyle[t],delete this.elementMap[t],delete this.shapeTypeMap[t]}destroy(){Object.values(this.container).forEach((t=>t.destroy())),this.elementMap={},this.shapeTypeMap={},this.defaultStyle={},this.stateStyle={},this.paletteStyle={},delete this.context}}function Xx(t){return jt(t.x)&&jt(t.y)}class Kx{context;supervisor;instance;animationResult;get presetOptions(){return{animation:!!xl(this.context.options,!0)}}get options(){const{options:t}=this.context;return t.layout}constructor(t){this.context=t}async presetLayout(t,e){if(!e)return;if(e.type)return this.stepLayout(t,e);const n=t.getAllNodes().reduce(((e,n)=>{if(!Xx(n.data)){let r=[0,0,0],i=0;t.getNeighbors(n.id).forEach((t=>{if(Xx(t.data)){const{x:e,y:n,z:o=0}=t.data;r=Gc(r,[e,n,o]),i++}})),i&&e.push({id:n.id,data:{x:r[0]/i,y:r[1]/i,z:r[2]/i}})}return e}),[]);this.updateElementPosition({nodes:n,edges:[]},!1)}async layout(){if(!this.options)return;const e=Array.isArray(this.options)?this.options:[this.options],{graph:n}=this.context;jE(n,new zE(t.GraphEvent.BEFORE_LAYOUT));for(const t of e){const{presetLayout:e}=t,n=this.getLayoutDataModel(t);await this.presetLayout(n,e);const r=await this.stepLayout(n,{...this.presetOptions,...t});t.animation||this.updateElementPosition(r,!1)}jE(n,new zE(t.GraphEvent.AFTER_LAYOUT))}async stepLayout(t,e){return function(t){const{type:e}=t;return["compact-box","mindmap","dendrogram","indented"].includes(e)}(e)?await this.treeLayout(t,e):await this.graphLayout(t,e)}async graphLayout(t,e){const{animation:n,enableWorker:r,iterations:i=300}=e,o=this.initGraphLayout(t,e);if(this.instance=o,r)return this.supervisor=new Mp(t,o,{iterations:i}),await this.supervisor.execute();if(xE(o))return n?await o.execute(t,{onTick:t=>{this.updateElementPosition(t,!1)}}):(o.execute(t),o.stop(),o.tick(i));const a=await o.execute(t);return n&&this.updateElementPosition(a,n),a}async treeLayout(t,e){const{type:n,animation:r}=e,i=RE("layout",n);if(!i)throw new Error(`The layout type ${n} is not found`);!function(t){if(t.hasTreeStructure(lc))return;t.attachTreeStructure(lc);const e=t.getAllEdges();for(const n of e){const{source:e,target:r}=n;t.setParent(r,e,lc)}}(t);const o={nodes:[],edges:[]};return t.getRoots(lc).forEach((n=>{DE(n,(e=>{e.children=t.getSuccessors(e.id)}),(e=>t.getSuccessors(e.id)),"TB");DE(i(n,e),(t=>{const{id:e,x:n,y:r}=t;o.nodes.push({id:e,data:{x:n,y:r}})}),(t=>t.children),"TB")})),r&&this.updateElementPosition(o,r),o}stopLayout(){this.instance&&xE(this.instance)&&(this.instance.stop(),this.instance=void 0),this.supervisor&&(this.supervisor.stop(),this.supervisor=void 0),this.animationResult&&(this.animationResult.finish(),this.animationResult=void 0)}getLayoutDataModel(t){const{model:e,element:n}=this.context;if(!n)return new Cp;const{nodesFilter:r=(()=>!0)}=t,i=Object.fromEntries(n.getNodes().map((t=>[t.id,t]))),o=Object.fromEntries(n.getCombos().map((t=>[t.id,t]))),a=Object.fromEntries(n.getEdges().map((t=>[t.id,t]))),s=e.model.getAllNodes().filter((t=>r(t.data))),u=e.model.getAllEdges(),c=(function(t){const{type:e}=t;return!!["comboCombined","comboForce"].includes(e)||!("dagre"!==e||!t.sortByCombo)}(t)?s:s.filter((t=>!o[t.id]&&function(t){return"hidden"!==ie(t,["style","visibility"])}(i[t.id])))).map((t=>{const{id:e}=t,n={id:e};return!!o[e]?Object.assign(n,{data:{...$x(o[e].attributes),_isCombo:!0}}):Object.assign(n,{data:$x(i[e]?.attributes||{})}),n})),h=new Map(c.map((t=>[t.id,t]))),l=u.filter((t=>{const e=h.get(t.source),n=h.get(t.target);return e&&n})).map((t=>{const{id:e,source:n,target:r}=t;return{id:e,source:n,target:r,data:$x(a[e].attributes)}})),d=new Cp({nodes:c,edges:l});return e.model.hasTreeStructure(hc)&&(d.attachTreeStructure(hc),c.forEach((t=>{const n=e.model.getParent(t.id,hc);n&&d.hasNode(n.id)&&d.setParent(t.id,n.id,hc)}))),d}initGraphLayout(t,e){const{element:n,viewport:r}=this.context,{type:i,enableWorker:o,animation:a,iterations:s,...u}=e,[c,h]=r.getCanvasSize(),l=[c/2,h/2],d=e?.nodeSize??(t=>{const e=n?.getElement(t.id),{size:r}=e?.attributes||{};return Math.max(...kc(r))}),f=RE("layout",i);if(!f)throw new Error(`The layout type ${i} is not found`);const p={nodeSize:d,width:c,height:h,center:l,...u};return"force"===i?Object.assign(p,{getMass:n=>{const{id:r}=n,{getMass:i}=e;if(i)return i(n);const{mass:o}=n.data;return jt(o)?o:Xx(t.getNode(r).data)||Xx(n.data)?10:1}}):"dagre"===i&&Object.assign(p,{preset:[]}),new f(p)}updateElementPosition(t,e){const{model:n,element:r}=this.context;if(!r)return null;const{nodes:i,edges:o}=t,a={nodes:[],edges:[],combos:[]};return i.forEach((({id:t,data:{x:e,y:n,z:r=0}})=>{a.nodes.push({id:t,style:{x:e,y:n,z:r}})})),o.forEach((({id:t,data:{controlPoints:e}})=>{e?.length&&a.edges.push({id:t,style:{controlPoints:e.map(Kc)}})})),n.updateData(a),r.draw({animation:e,silence:!0})}destroy(){this.stopLayout(),delete this.context}}const $x=t=>Object.entries(t).reduce(((t,[e,n])=>(["function","object"].includes(typeof n)||["x","y","z"].includes(e)||(t[e]=n),t)),{});class Zx extends Ml{category="plugin";constructor(t){super(t),this.setPlugins(this.context.options.plugins||[])}setPlugins(t){this.setExtensions(t)}}class Qx{context;get padding(){return gc(this.context.options.padding)}get paddingOffset(){const[t,e,n,r]=this.padding,[i,o,a]=[(r-e)/2,(t-n)/2,0];return[i,o,a]}constructor(t){this.context=t;const[e,n]=this.paddingOffset,{zoom:r,rotation:i,x:o=e,y:a=n}=t.options;this.transform({mode:"absolute",scale:r,translate:[o,a],rotate:i},!1)}get camera(){return this.context.canvas.getCamera()}landmarkCounter=0;createLandmark(t){return this.camera.createLandmark("landmark-"+this.landmarkCounter++,t)}getAnimation(t){const e=xl(this.context.options,t);return!!e&&function(t,e){if(null===t||!It(t))return{};var n={};return Rt(e,(function(e){ae.call(t,e)&&(n[e]=t[e])})),n}({...e},["easing","duration"])}getCanvasSize(){const{canvas:t}=this.context,{width:e=0,height:n=0}=t.getConfig();return[e,n]}getCanvasCenter(){const{canvas:t}=this.context,{width:e=0,height:n=0}=t.getConfig();return[e/2,n/2,0]}getViewportCenter(){const[t,e]=this.camera.getPosition();return[t,e,0]}getGraphCenter(){return this.context.graph.getViewportByCanvas(this.getCanvasCenter())}getZoom(){return this.camera.getZoom()}getRotation(){return this.camera.getRoll()}getTranslateArgs(t){const e=this.getZoom(),{camera:n}=this,{mode:r,translate:i=[]}=t,[o=0,a=0]=i,[s=0,u=0]=this.getCanvasCenter(),[c,h]=n.getPosition(),l=Uc([-o,-a],e);return"relative"===r?l:Gc([s-c,u-h],l)}getAnimationTranslateArgs(t){const{camera:e}=this,{mode:n,translate:r=[]}=t,i=this.getZoom(),o=e.getPosition(),a=e.getFocalPoint(),s=this.getCanvasCenter(),[u=0,c=0,h=0]=r,l=Uc([-u,-c,-h],i);return"relative"===n?{position:Gc(o,l),focalPoint:Gc(a,l)}:{position:Gc(s,l),focalPoint:Gc(a,l)}}getRotateArgs(t){const{mode:e,rotate:n=0}=t;return"relative"===e?n:n-this.camera.getRoll()}getAnimationRotateArgs(t){const{mode:e,rotate:n=0}=t;return{roll:"relative"===e?this.camera.getRoll()+n:n}}getZoomArgs(t){const{zoomRange:e}=this.context.options,n=this.camera.getZoom(),{mode:r,scale:i=1}=t;return Gt("relative"===r?n*i:i,...e)}async transform(e,n){const{camera:r}=this,{graph:i}=this.context,{translate:o,rotate:a,scale:s,origin:u=this.getGraphCenter()}=e;this.cancelAnimation(),jE(i,new BE(t.GraphEvent.BEFORE_TRANSFORM,e));const c=this.getAnimation(n);if(c){const n={};return o&&Object.assign(n,this.getAnimationTranslateArgs(e)),jt(a)&&Object.assign(n,this.getAnimationRotateArgs(e)),jt(s)&&Object.assign(n,{zoom:this.getZoomArgs(e)}),jE(i,new FE(t.GraphEvent.BEFORE_ANIMATE,rc.TRANSFORM,null,e)),new Promise((r=>{this.camera.gotoLandmark(this.createLandmark(n),{...c,onfinish:()=>{jE(i,new FE(t.GraphEvent.AFTER_ANIMATE,rc.TRANSFORM,null,e)),jE(i,new BE(t.GraphEvent.AFTER_TRANSFORM,e)),r()}})}))}if(o&&r.pan(...this.getTranslateArgs(e)),jt(a)){const[t,n]=r.getFocalPoint();u&&r.pan(u[0]-t,u[1]-n);const i=this.getRotateArgs(e);r.rotate(0,0,i),u&&r.pan(t-u[0],n-u[1])}if(jt(s)){const t=this.getZoomArgs(e);r.setZoomByViewportPoint(t,u)}jE(i,new BE(t.GraphEvent.AFTER_TRANSFORM,e))}async fitView(t,e){const[n,r,i,o]=this.padding,{when:a="always",direction:s="both"}=t||{},[u,c]=this.context.canvas.getSize(),h=u-o-r,l=c-n-i,d=this.context.canvas.getBounds(),f=this.getBBoxInViewport(d),[p,g]=yc(f);if("overflow"===a&&!("x"===s&&p>=h||"y"===s&&g>=l||"both"===s&&p>=h&&g>=l))return await this.fitCenter(e);const m=h/p,v=l/g,y="x"===s?m:"y"===s?v:Math.min(m,v),E=this.getAnimation(e);await this.transform({mode:"relative",scale:y,translate:Gc(jc(this.getCanvasCenter(),this.getBBoxInViewport(d).center),E?Uc(this.paddingOffset,y):this.paddingOffset)},E)}async fitCenter(t){const e=this.context.canvas.getBounds();await this.focus(e,t)}async focusElements(t,e){const{element:n}=this.context;if(!n)return;const r=bc(t.map((t=>n.getElement(t).getRenderBounds())));await this.focus(r,e)}async focus(t,e){const{center:n}=this.getBBoxInViewport(t),r=jc(this.getCanvasCenter(),n);await this.transform({mode:"relative",translate:Gc(r,this.paddingOffset)},e)}getBBoxInViewport(t){const{min:e,max:n}=t,{graph:r}=this.context,[i,o]=r.getViewportByCanvas(e),[a,s]=r.getViewportByCanvas(n),u=new hr;return u.setMinMax([i,o,0],[a,s,0]),u}cancelAnimation(){this.camera.landmarks?.length&&this.camera.cancelLandmarkAnimation()}}class Jx extends np{options;static defaultOptions={autoResize:!1,width:800,height:600,theme:"light",rotation:0,zoom:1,zoomRange:[.01,10]};destroyed=!1;context={model:new qx};constructor(t){super(),this.options=Object.assign({},Jx.defaultOptions,t),this.setOptions(this.options),this.context.graph=this,this.options.autoResize&&window.addEventListener("resize",this.onResize)}getOptions(){return this.options}setOptions(t){const{animation:e,background:n,behaviors:r,combo:i,container:o,data:a,edge:s,height:u,layout:c,node:h,padding:l,theme:d,plugins:f,width:p,zoomRange:g,zoom:m}=t;n&&this.setBackground(n),r&&this.setBehaviors(r),i&&this.setCombo(i),a&&this.setData(a),s&&this.setEdge(s),c&&this.setLayout(c),h&&this.setNode(h),d&&this.setTheme(d),f&&this.setPlugins(f),(jt(p)||jt(u))&&this.setSize(p??this.options.width??0,u??this.options.height??0),g&&(this.options.zoomRange=g),jt(m)&&(this.options.zoom=m),jt(l)&&(this.options.padding=l)}setBackground(t){this.options.background=t,this.context.canvas?.setBackground(t)}getBackground(){return this.options.background}getSize(){return this.context.canvas?this.context.canvas.getSize():[this.options.width||0,this.options.height||0]}setSize(t,e){this.options.width=t,this.options.height=e}setZoomRange(t){this.options.zoomRange=t}getZoomRange(){return this.options.zoomRange}setNode(t){this.options.node=t}setEdge(t){this.options.edge=t}setCombo(t){this.options.combo=t}getTheme(){return this.options.theme}setTheme(t){this.options.theme=Tt(t)?t(this.getTheme()):t;const{background:e}=RE("theme",this.options.theme)||{};e&&!this.options.background&&this.setBackground(e)}setLayout(t){this.options.layout=Tt(t)?t(this.getLayout()):t}getLayout(){return this.options.layout}setBehaviors(t){this.options.behaviors=Tt(t)?t(this.getBehaviors()):t,this.context.behavior?.setBehaviors(this.options.behaviors)}getBehaviors(){return this.options.behaviors||[]}setPlugins(t){this.options.plugins=Tt(t)?t(this.getPlugins()):t,this.context.plugin?.setPlugins(this.options.plugins)}getPlugins(){return this.options.plugins||[]}getData(){return this.context.model.getData()}getNodeData(t){return void 0===t?this.context.model.getNodeData():Array.isArray(t)?this.context.model.getNodeData(t):this.context.model.getNodeData([t])?.[0]}getEdgeData(t){return void 0===t?this.context.model.getEdgeData():Array.isArray(t)?this.context.model.getEdgeData(t):this.context.model.getEdgeData([t])?.[0]}getComboData(t){return void 0===t?this.context.model.getComboData():Array.isArray(t)?this.context.model.getComboData(t):this.context.model.getComboData([t])?.[0]}setData(t){this.context.model.setData(Tt(t)?t(this.getData()):t)}addData(t){this.context.model.addData(Tt(t)?t(this.getData()):t)}addNodeData(t){this.context.model.addNodeData(Tt(t)?t(this.getNodeData()):t)}addEdgeData(t){this.context.model.addEdgeData(Tt(t)?t(this.getEdgeData()):t)}addComboData(t){this.context.model.addComboData(Tt(t)?t(this.getComboData()):t)}updateData(t){this.context.model.updateData(Tt(t)?t(this.getData()):t)}updateNodeData(t){this.context.model.updateNodeData(Tt(t)?t(this.getNodeData()):t)}updateEdgeData(t){this.context.model.updateEdgeData(Tt(t)?t(this.getEdgeData()):t)}updateComboData(t){this.context.model.updateComboData(Tt(t)?t(this.getComboData()):t)}removeData(t){this.context.model.removeData(Tt(t)?t(this.getData()):t)}removeNodeData(t){this.context.model.removeNodeData(Tt(t)?t(this.getNodeData()):t)}removeEdgeData(t){this.context.model.removeEdgeData(Tt(t)?t(this.getEdgeData()):t)}removeComboData(t){this.context.model.removeComboData(Tt(t)?t(this.getComboData()):t)}getElementType(t){return this.context.model.getElementType(t)}getRelatedEdgesData(t,e="both"){return this.context.model.getRelatedEdgesData(t,e)}getNeighborNodesData(t){return this.context.model.getNeighborNodesData(t)}getAncestorsData(t,e){return this.context.model.getAncestorsData(t,e)}getParentData(t,e){return this.context.model.getParentData(t,e)}getChildrenData(t){return this.context.model.getChildrenData(t)}getElementDataByState(t,e){return this.context.model.getElementDataByState(t,e)}createCanvas(){if(this.context.canvas)return this.context.canvas;const{container:t="container",width:e,height:n,renderer:r,background:i}=this.options;if(t instanceof jx)this.context.canvas=t,t.setBackground(i);else{const i=zt(t)?document.getElementById(t):t;this.context.canvas=new jx({container:i,width:e,height:n,renderer:r})}return this.context.canvas}createRuntime(){this.context.options=this.options,this.context.plugin||(this.context.plugin=new Zx(this.context)),this.context.viewport||(this.context.viewport=new Qx(this.context)),this.context.element||(this.context.element=new Yx(this.context)),this.context.layout||(this.context.layout=new Kx(this.context)),this.context.behavior||(this.context.behavior=new WE(this.context))}async prepare(){if(this.destroyed)throw new Error("Graph has been destroyed");await this.createCanvas().init(),this.createRuntime()}async render(){jE(this,new zE(t.GraphEvent.BEFORE_RENDER)),await this.prepare(),await Promise.all([this.context.element?.draw(),this.context.layout?.layout()]),await this.autoFit(),jE(this,new zE(t.GraphEvent.AFTER_RENDER))}async draw(){return await this.prepare(),this.context.element.draw()}layout(){return this.context.layout.layout()}stopLayout(){return this.context.layout.stopLayout()}async clear(){this.context.model.setData({}),await this.draw()}destroy(){const{layout:t,element:e,model:n,canvas:r,behavior:i,plugin:o}=this.context;t?.destroy(),e?.destroy(),n.destroy(),r?.destroy(),i?.destroy(),o?.destroy(),this.options={},delete this.context,window.removeEventListener("resize",this.onResize),this.destroyed=!0}getCanvas(){return this.context.canvas}resize(e,n){const r=e&&n?[e,n]:LE(this.context.canvas.getContainer());re(r,this.getSize())||(jE(this,new zE(t.GraphEvent.BEFORE_SIZE_CHANGE,{size:r})),this.context.canvas.resize(...r),jE(this,new zE(t.GraphEvent.AFTER_SIZE_CHANGE,{size:r})))}async fitView(t,e){await(this.context.viewport?.fitView(t,e))}async fitCenter(t){await(this.context.viewport?.fitCenter(t))}async autoFit(){const{autoFit:t}=this.context.options;if(t)if(zt(t))"view"===t?await this.fitView():"center"===t&&await this.fitCenter();else{const{type:e,animation:n}=t;"view"===e?await this.fitView(t.options,n):"center"===e&&await this.fitCenter(n)}}async focusElement(t,e){await(this.context.viewport?.focusElements(Array.isArray(t)?t:[t],e))}async zoomBy(t,e,n){await this.context.viewport.transform({mode:"relative",scale:t,origin:n},e)}async zoomTo(t,e,n){this.context.viewport.transform({mode:"absolute",scale:t,origin:n},e)}getZoom(){return this.context.viewport.getZoom()}async rotateBy(t,e,n){await this.context.viewport.transform({mode:"relative",rotate:t,origin:n},e)}async rotateTo(t,e,n){await this.context.viewport.transform({mode:"absolute",rotate:t,origin:n},e)}getRotation(){return this.context.viewport.getRotation()}async translateBy(t,e){await this.context.viewport.transform({mode:"relative",translate:t},e)}async translateTo(t,e){await this.context.viewport.transform({mode:"absolute",translate:t},e)}getPosition(){return jc([0,0],this.getCanvasByViewport([0,0]))}async translateElementBy(t,e,n=!0){const[r,i]=Ot(t)?[t,e??!0]:[{[t]:e},n];Object.entries(r).forEach((([t,e])=>this.context.model.translateNodeBy(t,e))),await this.context.element.draw({animation:i})}async translateElementTo(t,e,n=!0){const[r,i]=Ot(t)?[t,e??!0]:[{[t]:e},n];Object.entries(r).forEach((([t,e])=>this.context.model.translateNodeTo(t,e))),await this.context.element.draw({animation:i})}getElementPosition(t){return this.context.model.getElementPosition(t)}getElementRenderStyle(t){return se(this.context.element.getElement(t).attributes,["context"])}async setElementVisibility(t,e,n=!0){const[r,i]=Ot(t)?[t,e??!0]:[{[t]:e},n],o={nodes:[],edges:[],combos:[]};Object.entries(r).forEach((([t,e])=>{const n=this.getElementType(t);o[`${n}s`].push({id:t,style:{visibility:e}})})),this.updateData(o),await this.context.element.draw({animation:i,stage:"visibility"})}async showElement(t,e){const n=Array.isArray(t)?t:[t];await this.setElementVisibility(Object.fromEntries(n.map((t=>[t,"visible"]))),e)}async hideElement(t,e){const n=Array.isArray(t)?t:[t];await this.setElementVisibility(Object.fromEntries(n.map((t=>[t,"hidden"]))),e)}getElementVisibility(t){const e=this.context.element.getElement(t);return e?.style?.visibility??"visible"}async setElementZIndex(t,e){const n={nodes:[],edges:[],combos:[]},r=Ot(t)?t:{[t]:e};Object.entries(r).forEach((([t,e])=>{const r=this.getElementType(t);n[`${r}s`].push({id:t,style:{zIndex:e}})}));const{model:i,element:o}=this.context;i.preventUpdateNodeLikeHierarchy((()=>i.updateData(n))),await o.draw({animation:!1})}async frontElement(t){const e=Array.isArray(t)?t:[t],{model:n}=this.context,r={};e.map((t=>{const e=n.getFrontZIndex(t);if("combo"===n.getElementType(t)){const i=n.getAncestorsData(t,hc).at(-1)||this.getComboData(t),o=[i,...n.getDescendantsData(Dc(i))].filter((t=>n.isCombo(Dc(t)))),a=e-UE(i);o.forEach((t=>{r[Dc(t)]=UE(t)+a}))}else r[t]=e})),await this.setElementZIndex(r)}getElementZIndex(t){return UE(this.context.model.getElementsData([t])[0])}async setElementState(e,n,r=!0){const[i,o]=Ot(e)?[e,n??!0]:[{[e]:n},r];jE(this,new GE(t.GraphEvent.BEFORE_ELEMENT_STATE_CHANGE,i));const a={nodes:[],edges:[],combos:[]};Object.entries(i).forEach((([t,e])=>{const n=this.getElementType(t);a[`${n}s`].push({id:t,style:{states:Array.isArray(e)?e:[e]}})})),this.updateData(a),await this.context.element.draw({animation:o}),jE(this,new GE(t.GraphEvent.AFTER_ELEMENT_STATE_CHANGE,i))}getElementState(t){return this.context.model.getElementState(t)}getElementRenderBounds(t){return this.context.element.getElement(t).getRenderBounds()}async collapse(t,e=!0){this.setElementCollapsibility(t,!0),await this.context.element.draw({animation:e,stage:"collapse"})}async expand(t,e=!0){this.setElementCollapsibility(t,!1),await this.context.element.draw({animation:e,stage:"expand"})}setElementCollapsibility(t,e){const n=this.getElementType(t);"node"===n?this.updateNodeData([{id:t,style:{collapsed:e}}]):"combo"===n&&this.updateComboData([{id:t,style:{collapsed:e}}])}async toDataURL(t={}){return this.context.canvas.toDataURL(t)}getCanvasByViewport(t){return Kc(this.context.canvas.viewport2Canvas($c(t)))}getViewportByCanvas(t){return Kc(this.context.canvas.canvas2Viewport($c(t)))}getClientByCanvas(t){const e=this.context.canvas.canvas2Viewport($c(t));return Kc(this.context.canvas.viewport2Canvas(e))}getCanvasByClient(t){const e=this.context.canvas.client2Viewport($c(t));return Kc(this.context.canvas.viewport2Canvas(e))}getViewportCenter(){return this.context.viewport.getViewportCenter()}getCanvasCenter(){return this.context.viewport.getCanvasCenter()}onResize=function(t,e,n){var r;return function(){var i=this,o=arguments,a=n&&!r;clearTimeout(r),r=setTimeout((function(){r=null,n||t.apply(i,o)}),e),a&&t.apply(i,o)}}((()=>{this.resize()}),300)}const tb={idOf:Dc,treeToGraphData:function(t,e){const{getNodeData:n=(t=>{if(!t.children)return t;const{children:e,style:n={},...r}=t;return{style:{...n,children:e.map((t=>t.id))},...r}}),getEdgeData:r=((t,e)=>({source:t.id,target:e.id})),getChildren:i=(t=>t.children||[])}=e||{},o=[],a=[];return DE(t,(t=>{o.push(n(t));const e=i(t);for(const n of e)a.push(r(t,n))}),(t=>i(t)),"TB"),{nodes:o,edges:a}}},eb={dark:PE,light:CE};t.BaseBehavior=Sl,t.BaseCombo=Sh,t.BaseEdge=Xh,t.BaseNode=vh,t.ComboEvent=t.NodeEvent,t.Graph=Jx,t.Theme=eb,t.Utils=tb,t.getExtension=RE,t.getExtensions=function(t){return AE[t]},t.register=OE,t.version="5.0.0"}));
6
+ */const rD=Symbol("Comlink.proxy"),iD=Symbol("Comlink.endpoint"),oD=Symbol("Comlink.releaseProxy"),aD=Symbol("Comlink.finalizer"),sD=Symbol("Comlink.thrown"),uD=t=>"object"==typeof t&&null!==t||"function"==typeof t,cD=new Map([["proxy",{canHandle:t=>uD(t)&&t[rD],serialize(t){const{port1:e,port2:n}=new MessageChannel;return hD(t,e),[n,[n]]},deserialize:t=>(t.start(),dD(t))}],["throw",{canHandle:t=>uD(t)&&sD in t,serialize({value:t}){let e;return e=t instanceof Error?{isError:!0,value:{message:t.message,name:t.name,stack:t.stack}}:{isError:!1,value:t},[e,[]]},deserialize(t){if(t.isError)throw Object.assign(new Error(t.value.message),t.value);throw t.value}}]]);function hD(t,e=globalThis,n=["*"]){e.addEventListener("message",(function r(i){if(!i||!i.data)return;if(!function(t,e){for(const n of t){if(e===n||"*"===n)return!0;if(n instanceof RegExp&&n.test(e))return!0}return!1}(n,i.origin))return void console.warn(`Invalid origin '${i.origin}' for comlink proxy`);const{id:o,type:a,path:s}=Object.assign({path:[]},i.data),u=(i.data.argumentList||[]).map(wD);let c;try{const e=s.slice(0,-1).reduce(((t,e)=>t[e]),t),n=s.reduce(((t,e)=>t[e]),t);switch(a){case"GET":c=n;break;case"SET":e[s.slice(-1)[0]]=wD(i.data.value),c=!0;break;case"APPLY":c=n.apply(e,u);break;case"CONSTRUCT":c=function(t){return Object.assign(t,{[rD]:!0})}(new n(...u));break;case"ENDPOINT":{const{port1:e,port2:n}=new MessageChannel;hD(t,n),c=function(t,e){return bD.set(t,e),t}(e,[e])}break;case"RELEASE":c=void 0;break;default:return}}catch(t){c={value:t,[sD]:0}}Promise.resolve(c).catch((t=>({value:t,[sD]:0}))).then((n=>{const[i,s]=ED(n);e.postMessage(Object.assign(Object.assign({},i),{id:o}),s),"RELEASE"===a&&(e.removeEventListener("message",r),lD(e),aD in t&&"function"==typeof t[aD]&&t[aD]())})).catch((t=>{const[n,r]=ED({value:new TypeError("Unserializable return value"),[sD]:0});e.postMessage(Object.assign(Object.assign({},n),{id:o}),r)}))})),e.start&&e.start()}function lD(t){(function(t){return"MessagePort"===t.constructor.name})(t)&&t.close()}function dD(t,e){return vD(t,[],e)}function fD(t){if(t)throw new Error("Proxy has been released and is not useable")}function pD(t){return xD(t,{type:"RELEASE"}).then((()=>{lD(t)}))}const gD=new WeakMap,mD="FinalizationRegistry"in globalThis&&new FinalizationRegistry((t=>{const e=(gD.get(t)||0)-1;gD.set(t,e),0===e&&pD(t)}));function vD(t,e=[],n=function(){}){let r=!1;const i=new Proxy(n,{get(n,o){if(fD(r),o===oD)return()=>{!function(t){mD&&mD.unregister(t)}(i),pD(t),r=!0};if("then"===o){if(0===e.length)return{then:()=>i};const n=xD(t,{type:"GET",path:e.map((t=>t.toString()))}).then(wD);return n.then.bind(n)}return vD(t,[...e,o])},set(n,i,o){fD(r);const[a,s]=ED(o);return xD(t,{type:"SET",path:[...e,i].map((t=>t.toString())),value:a},s).then(wD)},apply(n,i,o){fD(r);const a=e[e.length-1];if(a===iD)return xD(t,{type:"ENDPOINT"}).then(wD);if("bind"===a)return vD(t,e.slice(0,-1));const[s,u]=yD(o);return xD(t,{type:"APPLY",path:e.map((t=>t.toString())),argumentList:s},u).then(wD)},construct(n,i){fD(r);const[o,a]=yD(i);return xD(t,{type:"CONSTRUCT",path:e.map((t=>t.toString())),argumentList:o},a).then(wD)}});return function(t,e){const n=(gD.get(e)||0)+1;gD.set(e,n),mD&&mD.register(t,e,t)}(i,t),i}function yD(t){const e=t.map(ED);return[e.map((t=>t[0])),(n=e.map((t=>t[1])),Array.prototype.concat.apply([],n))];var n}const bD=new WeakMap;function ED(t){for(const[e,n]of cD)if(n.canHandle(t)){const[r,i]=n.serialize(t);return[{type:"HANDLER",name:e,value:r},i]}return[{type:"RAW",value:t},bD.get(t)||[]]}function wD(t){switch(t.type){case"HANDLER":return cD.get(t.name).deserialize(t.value);case"RAW":return t.value}}function xD(t,e,n){return new Promise((r=>{const i=new Array(4).fill(0).map((()=>Math.floor(Math.random()*Number.MAX_SAFE_INTEGER).toString(16))).join("-");t.addEventListener("message",(function e(n){n.data&&n.data.id&&n.data.id===i&&(t.removeEventListener("message",e),r(n.data))})),t.start&&t.start(),t.postMessage(Object.assign({id:i},e),n)}))}class MD extends Vf{constructor(t,e,n){super(),this.graph=t,this.layout=e,this.options=n,this.spawnWorker()}spawnWorker(){this.proxy=dD(new Worker(new URL("./worker.js","undefined"==typeof document&&"undefined"==typeof location?require("url").pathToFileURL(__filename).href:"undefined"==typeof document?location.href:e&&e.src||new URL("g6.min.js",document.baseURI).href),{type:"module"})),this.running&&(this.running=!1,this.execute())}execute(){var t;return a(this,void 0,void 0,(function*(){if(this.running)return this;this.running=!0;const e=o(this.layout.options,["onTick"]),n={};Object.keys(e).forEach((t=>{kt(e[t])||(n[t]=e[t])}));const r={layout:{id:this.layout.id,options:n,iterations:null===(t=this.options)||void 0===t?void 0:t.iterations},nodes:this.graph.getAllNodes(),edges:this.graph.getAllEdges()},i=new Float32Array([0]),[a]=yield this.proxy.calculateLayout(r,[i]);return a}))}stop(){return this.running=!1,this.proxy.stopLayout(),this}kill(){this.proxy[oD]()}isRunning(){return this.running}}class ND extends Sl{}var SD={exports:{}},TD=[],kD=[];function PD(t,e){if(e=e||{},void 0===t)throw new Error("insert-css: You need to provide a CSS string. Usage: insertCss(cssString[, options]).");var n,r=!0===e.prepend?"prepend":"append",i=void 0!==e.container?e.container:document.querySelector("head"),o=TD.indexOf(i);return-1===o&&(o=TD.push(i)-1,kD[o]={}),void 0!==kD[o]&&void 0!==kD[o][r]?n=kD[o][r]:(n=kD[o][r]=function(){var t=document.createElement("style");return t.setAttribute("type","text/css"),t}(),"prepend"===r?i.insertBefore(n,i.childNodes[0]):i.appendChild(n)),65279===t.charCodeAt(0)&&(t=t.substr(1,t.length)),n.styleSheet?n.styleSheet.cssText+=t:n.textContent+=t,n}SD.exports=PD;var CD=SD.exports.insertCss=PD;const AD=t=>t?parseInt(t):0;function OD(t){let e=640,n=480;const[r,i]=function(t){const e=getComputedStyle(t),n=t.clientWidth||AD(e.width),r=t.clientHeight||AD(e.height);return[n-(AD(e.paddingLeft)+AD(e.paddingRight)),r-(AD(e.paddingTop)+AD(e.paddingBottom))]}(t);e=r||e,n=i||n;return[Math.max(Vt(e)?e:1,1),Math.max(Vt(n)?n:1,1)]}function RD(t,e=!0){const n=document.createElement("div");return n.setAttribute("class",`g6-${t}`),n.style.position="absolute",n.style.display="block",e&&(n.style.top="0px",n.style.left="0px",n.style.height="100%",n.style.width="100%",n.style.overflow="hidden",n.style.pointerEvents="none"),n}class _D extends ND{static defaultOptions={trigger:"contextmenu",offset:[4,4],loadingContent:'<div class="g6-contextmenu-loading">Loading...</div>',getContent:()=>"It is a empty context menu.",enable:()=>!0};$element=RD("contextmenu",!1);constructor(t,e){super(t,Object.assign({},_D.defaultOptions,e));this.context.canvas.getContainer().appendChild(this.$element),CD("\n .g6-contextmenu {\n font-size: 12px;\n background-color: rgba(255, 255, 255, 0.96);\n border-radius: 4px;\n overflow: hidden;\n box-shadow: rgba(0, 0, 0, 0.12) 0px 6px 12px 0px;\n transition: visibility 0.2s cubic-bezier(0.23, 1, 0.32, 1) 0s, left 0.4s cubic-bezier(0.23, 1, 0.32, 1) 0s, top 0.4s cubic-bezier(0.23, 1, 0.32, 1) 0s;\n }\n\n .g6-contextmenu-ul {\n max-width: 256px;\n min-width: 96px;\n list-style: none;\n padding: 0;\n margin: 0;\n }\n\n .g6-contextmenu-li {\n padding: 8px 12px;\n cursor: pointer;\n user-select: none;\n }\n\n .g6-contextmenu-li:hover {\n background-color: #f5f5f5;\n cursor: pointer;\n }\n"),this.update(e)}async showContextmenu(t){const{enable:e,offset:n}=this.options;if("function"==typeof e&&!e(t)||!e)return void this.hideContextmenu();const r=await this.getDOMContent(t);r instanceof HTMLElement?this.$element.appendChild(r):this.$element.innerHTML=r;const i=this.context.graph.getCanvas().getContainer().getBoundingClientRect();this.$element.style.left=`${t.client.x-i.left+n[0]}px`,this.$element.style.top=`${t.client.y-i.top+n[1]}px`,this.$element.style.display="block"}hideContextmenu(){this.$element.style.display="none"}update(t){this.unbindEvents(),super.update(t),this.bindEvents()}destroy(){this.unbindEvents(),super.destroy(),this.$element.remove()}async getDOMContent(t){const{getContent:e,getItems:n}=this.options;return n?`\n <ul class="g6-contextmenu-ul">\n ${(await n(t)).map((t=>`<li class="g6-contextmenu-li" value="${t.value}">${t.name}</li>`)).join("")}\n </ul>\n `:await e(t)}bindEvents(){const{graph:t}=this.context,{trigger:e}=this.options;t.on(`canvas:${e}`,this.onTriggerEvent),t.on(`node:${e}`,this.onTriggerEvent),t.on(`edge:${e}`,this.onTriggerEvent),t.on(`combo:${e}`,this.onTriggerEvent),document.addEventListener("click",this.onMenuItemClick)}unbindEvents(){const{graph:t}=this.context,{trigger:e}=this.options;t.off(`canvas:${e}`,this.onTriggerEvent),t.off(`node:${e}`,this.onTriggerEvent),t.off(`edge:${e}`,this.onTriggerEvent),t.off(`combo:${e}`,this.onTriggerEvent),document.removeEventListener("click",this.onMenuItemClick)}onTriggerEvent=t=>{t.preventDefault?.(),this.showContextmenu(t)};onMenuItemClick=t=>{const{onClick:e}=this.options;if(t.target instanceof HTMLElement){if(t.target.className.includes("g6-contextmenu-li")){const n=t.target.getAttribute("value");e&&e(n,t.target),this.hideContextmenu()}this.context.graph.getCanvas().getContainer().contains(t.target)||this.hideContextmenu()}}}class DD extends ND{static defaultOptions={lineWidth:1,border:!0,borderLineWidth:1,borderStroke:"#0001",borderStyle:"solid",stroke:"#0001",size:20,tickCount:4,tickStrokeOpacity:.5};$element=RD("grid-line");offset=[0,0];constructor(t,e){super(t,Object.assign({},DD.defaultOptions,e));this.context.canvas.getContainer().appendChild(this.$element),this.updateStyle(),this.bindEvents()}update(t){super.update(t),this.updateStyle()}bindEvents(){const{graph:e}=this.context;e.on(t.GraphEvent.AFTER_TRANSFORM,this.onTransform)}updateStyle(){const{size:t,stroke:e,lineWidth:n,border:r,borderLineWidth:i,borderStroke:o,borderStyle:a}=this.options;Object.assign(this.$element.style,{border:r?`${i}px ${a} ${o}`:"none",backgroundImage:`linear-gradient(${e} ${n}px, transparent ${n}px), linear-gradient(90deg, ${e} ${n}px, transparent ${n}px)`,backgroundSize:`${t}px ${t}px`})}updateOffset(t){this.offset=function(t,e){return t.map((t=>t%e))}(Vc(this.offset,t),this.options.size),this.$element.style.backgroundPosition=`${this.offset[0]}px ${this.offset[1]}px`}onTransform=t=>{if(!this.options.follow)return;const{data:{translate:e}}=t;e&&this.updateOffset(e)};destroy(){this.context.graph.off(t.GraphEvent.AFTER_TRANSFORM,this.onTransform),this.$element.remove(),super.destroy()}}function ID(t,e){e(t),t.children&&t.children.forEach((function(t){t&&ID(t,e)}))}function LD(t){jD(t,!1)}function jD(t,e){var n=e?"visible":"hidden";ID(t,(function(t){t.attr("visibility",n)}))}var zD=function(t){function e(){for(var e=[],n=0;n<arguments.length;n++)e[n]=arguments[n];var r=t.apply(this,h([],c(e),!1))||this;return r.addEventListener(qa.INSERTED,(function(){LD(r)})),r}return r(e,t),e}(Ps);var FD=function(){function t(t,e,n,r){void 0===t&&(t=0),void 0===e&&(e=0),void 0===n&&(n=0),void 0===r&&(r=0),this.x=0,this.y=0,this.width=0,this.height=0,this.x=t,this.y=e,this.width=n,this.height=r}return Object.defineProperty(t.prototype,"bottom",{get:function(){return this.y+this.height},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"left",{get:function(){return this.x},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"right",{get:function(){return this.x+this.width},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"top",{get:function(){return this.y},enumerable:!1,configurable:!0}),t.fromRect=function(e){return new t(e.x,e.y,e.width,e.height)},t.prototype.toJSON=function(){return{x:this.x,y:this.y,width:this.width,height:this.height,top:this.top,right:this.right,bottom:this.bottom,left:this.left}},t.prototype.isPointIn=function(t,e){return t>=this.left&&t<=this.right&&e>=this.top&&e<=this.bottom},t}(),BD=function(t,e,n,r){void 0===n&&(n=0),void 0===r&&(r=5),Object.entries(e).forEach((function(i){var o=c(i,2),a=o[0],s=o[1],u=t;Object.prototype.hasOwnProperty.call(e,a)&&(s?It(s)?(It(t[a])||(u[a]={}),n<r?BD(t[a],s,n+1,r):u[a]=e[a]):Ot(s)?(u[a]=[],u[a]=u[a].concat(s)):u[a]=s:u[a]=s)}))},GD=function(t){for(var e=[],n=1;n<arguments.length;n++)e[n-1]=arguments[n];for(var r=0;r<e.length;r+=1)BD(t,e[r]);return t};function VD(){jD(this,"hidden"!==this.attributes.visibility)}var UD=function(t){function e(e,n){void 0===n&&(n={});var r=t.call(this,GD({},{style:n},e))||this;return r.initialized=!1,r._defaultOptions=n,r}return r(e,t),Object.defineProperty(e.prototype,"offscreenGroup",{get:function(){return this._offscreen||(this._offscreen=function(t){var e=t.appendChild(new zD({class:"offscreen"}));return LD(e),e}(this)),this._offscreen},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"defaultOptions",{get:function(){return this._defaultOptions},enumerable:!1,configurable:!0}),e.prototype.connectedCallback=function(){this.render(this.attributes,this),this.bindEvents(this.attributes,this),this.initialized=!0},e.prototype.disconnectedCallback=function(){var t;null===(t=this._offscreen)||void 0===t||t.destroy()},e.prototype.attributeChangedCallback=function(t){"visibility"===t&&VD.call(this)},e.prototype.update=function(t,e){var n;return this.attr(GD({},this.attributes,t||{})),null===(n=this.render)||void 0===n?void 0:n.call(this,this.attributes,this,e)},e.prototype.clear=function(){this.removeChildren()},e.prototype.bindEvents=function(t,e){},e}(Ts);function WD(t){return void 0===t&&(t=""),{CONTAINER:"".concat(t,"tooltip"),TITLE:"".concat(t,"tooltip-title"),LIST:"".concat(t,"tooltip-list"),LIST_ITEM:"".concat(t,"tooltip-list-item"),NAME:"".concat(t,"tooltip-list-item-name"),MARKER:"".concat(t,"tooltip-list-item-marker"),NAME_LABEL:"".concat(t,"tooltip-list-item-name-label"),VALUE:"".concat(t,"tooltip-list-item-value"),CROSSHAIR_X:"".concat(t,"tooltip-crosshair-x"),CROSSHAIR_Y:"".concat(t,"tooltip-crosshair-y")}}var HD={overflow:"hidden","white-space":"nowrap","text-overflow":"ellipsis"};function qD(t){var e;void 0===t&&(t="");var n=WD(t);return(e={})[".".concat(n.CONTAINER)]={position:"absolute",visibility:"visible","z-index":8,transition:"visibility 0.2s cubic-bezier(0.23, 1, 0.32, 1), left 0.4s cubic-bezier(0.23, 1, 0.32, 1), top 0.4s cubic-bezier(0.23, 1, 0.32, 1)","background-color":"rgba(255, 255, 255, 0.96)","box-shadow":"0 6px 12px 0 rgba(0, 0, 0, 0.12)","border-radius":"4px",color:"rgba(0, 0, 0, 0.65)","font-size":"12px","line-height":"20px",padding:"12px","min-width":"120px","max-width":"360px","font-family":"Roboto-Regular"},e[".".concat(n.TITLE)]={color:"rgba(0, 0, 0, 0.45)"},e[".".concat(n.LIST)]={margin:"0px","list-style-type":"none",padding:"0px"},e[".".concat(n.LIST_ITEM)]={"list-style-type":"none",display:"flex","line-height":"2em","align-items":"center","justify-content":"space-between","white-space":"nowrap"},e[".".concat(n.MARKER)]={width:"8px",height:"8px","border-radius":"50%",display:"inline-block","margin-right":"4px"},e[".".concat(n.NAME)]={display:"flex","align-items":"center","max-width":"216px"},e[".".concat(n.NAME_LABEL)]=i({flex:1},HD),e[".".concat(n.VALUE)]=i({display:"inline-block",float:"right",flex:1,"text-align":"right","min-width":"28px","margin-left":"30px",color:"rgba(0, 0, 0, 0.85)"},HD),e[".".concat(n.CROSSHAIR_X)]={position:"absolute",width:"1px","background-color":"rgba(0, 0, 0, 0.25)"},e[".".concat(n.CROSSHAIR_Y)]={position:"absolute",height:"1px","background-color":"rgba(0, 0, 0, 0.25)"},e}var YD=function(t){function e(e){var n,r,i=this,o=null===(r=null===(n=e.style)||void 0===n?void 0:n.template)||void 0===r?void 0:r.prefixCls,a=WD(o);return(i=t.call(this,e,{data:[],x:0,y:0,visibility:"visible",title:"",position:"bottom-right",offset:[5,5],enterable:!1,container:{x:0,y:0},bounding:null,template:{prefixCls:"",container:'<div class="'.concat(a.CONTAINER,'"></div>'),title:'<div class="'.concat(a.TITLE,'"></div>'),item:'<li class="'.concat(a.LIST_ITEM,'" data-index={index}>\n <span class="').concat(a.NAME,'">\n <span class="').concat(a.MARKER,'" style="background:{color}"></span>\n <span class="').concat(a.NAME_LABEL,'" title="{name}">{name}</span>\n </span>\n <span class="').concat(a.VALUE,'" title="{value}">{value}</span>\n </li>')},style:qD(o)})||this).timestamp=-1,i.prevCustomContentKey=i.attributes.contentKey,i.initShape(),i.render(i.attributes,i),i}return r(e,t),Object.defineProperty(e.prototype,"HTMLTooltipElement",{get:function(){return this.element},enumerable:!1,configurable:!0}),e.prototype.getContainer=function(){return this.element},Object.defineProperty(e.prototype,"elementSize",{get:function(){return{width:this.element.offsetWidth,height:this.element.offsetHeight}},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"HTMLTooltipItemsElements",{get:function(){var t=this.attributes,e=t.data,n=t.template;return e.map((function(t,e){var r=t.name,a=void 0===r?"":r,s=t.color,u=void 0===s?"black":s,c=t.index,h=o(t,["name","color","index"]),l=i({name:a,color:u,index:null!=c?c:e},h);return qe(function(t,e){return t&&e?t.replace(/\\?\{([^{}]+)\}/g,(function(t,n){return"\\"===t.charAt(0)?t.slice(1):void 0===e[n]?"":e[n]})):t}(n.item,l))}))},enumerable:!1,configurable:!0}),e.prototype.render=function(t,e){this.renderHTMLTooltipElement(),this.updatePosition()},e.prototype.destroy=function(){var e;null===(e=this.element)||void 0===e||e.remove(),t.prototype.destroy.call(this)},e.prototype.show=function(t,e){var n=this;if(void 0!==t&&void 0!==e){var r=function(){n.attributes.x=null!=t?t:n.attributes.x,n.attributes.y=null!=e?e:n.attributes.y,n.updatePosition()};"hidden"===this.element.style.visibility?this.closeTransition(r):r()}this.element.style.visibility="visible"},e.prototype.hide=function(t,e){void 0===t&&(t=0),void 0===e&&(e=0),this.attributes.enterable&&this.isCursorEntered(t,e)||(this.element.style.visibility="hidden")},e.prototype.initShape=function(){var t=this.attributes.template;this.element=qe(t.container),this.id&&this.element.setAttribute("id",this.id)},e.prototype.renderCustomContent=function(){if(void 0===this.prevCustomContentKey||this.prevCustomContentKey!==this.attributes.contentKey){this.prevCustomContentKey=this.attributes.contentKey;var t=this.attributes.content;t&&("string"==typeof t?this.element.innerHTML=t:this.element.replaceChildren(t))}},e.prototype.renderHTMLTooltipElement=function(){var t,e,n=this.attributes,r=n.template,i=n.title,o=n.enterable,a=n.style,s=n.content,u=WD(r.prefixCls),l=this.element;if(this.element.style.pointerEvents=o?"auto":"none",s)this.renderCustomContent();else{i?(l.innerHTML=r.title,l.getElementsByClassName(u.TITLE)[0].innerHTML=i):null===(e=null===(t=l.getElementsByClassName(u.TITLE))||void 0===t?void 0:t[0])||void 0===e||e.remove();var d=this.HTMLTooltipItemsElements,f=document.createElement("ul");f.className=u.LIST,f.replaceChildren.apply(f,h([],c(d),!1));var p=this.element.querySelector(".".concat(u.LIST));p?p.replaceWith(f):l.appendChild(f)}!function(t,e){Object.entries(e).forEach((function(e){var n=c(e,2),r=n[0],i=n[1];h([t],c(t.querySelectorAll(r)),!1).filter((function(t){return t.matches(r)})).forEach((function(t){t&&(t.style.cssText+=Object.entries(i).reduce((function(t,e){return"".concat(t).concat(e.join(":"),";")}),""))}))}))}(l,a)},e.prototype.getRelativeOffsetFromCursor=function(t){var e=this.attributes,n=e.position,r=e.offset,i=(t||n).split("-"),o={left:[-1,0],right:[1,0],top:[0,-1],bottom:[0,1]},a=this.elementSize,s=a.width,u=a.height,h=[-s/2,-u/2];return i.forEach((function(t){var e=c(h,2),n=e[0],i=e[1],a=c(o[t],2),l=a[0],d=a[1];h=[n+(s/2+r[0])*l,i+(u/2+r[1])*d]})),h},e.prototype.setOffsetPosition=function(t){var e=c(t,2),n=e[0],r=e[1],i=this.attributes,o=i.x,a=void 0===o?0:o,s=i.y,u=void 0===s?0:s,h=i.container,l=h.x,d=h.y;this.element.style.left="".concat(+a+l+n,"px"),this.element.style.top="".concat(+u+d+r,"px")},e.prototype.updatePosition=function(){var t=this.attributes.showDelay,e=void 0===t?60:t,n=Date.now();this.timestamp>0&&n-this.timestamp<e||(this.timestamp=n,this.setOffsetPosition(this.autoPosition(this.getRelativeOffsetFromCursor())))},e.prototype.autoPosition=function(t){var e=c(t,2),n=e[0],r=e[1],i=this.attributes,o=i.x,a=i.y,s=i.bounding,u=i.position;if(!s)return[n,r];var h=this.element,l=h.offsetWidth,d=h.offsetHeight,f=c([+o+n,+a+r],2),p=f[0],g=f[1],m={left:"right",right:"left",top:"bottom",bottom:"top"},v=s.x,y=s.y,b={left:p<v,right:p+l>v+s.width,top:g<y,bottom:g+d>y+s.height},E=[];u.split("-").forEach((function(t){b[t]?E.push(m[t]):E.push(t)}));var w=E.join("-");return this.getRelativeOffsetFromCursor(w)},e.prototype.isCursorEntered=function(t,e){if(this.element){var n=this.element.getBoundingClientRect(),r=n.x,i=n.y,o=n.width,a=n.height;return new FD(r,i,o,a).isPointIn(t,e)}return!1},e.prototype.closeTransition=function(t){var e=this,n=this.element.style.transition;this.element.style.transition="none",t(),setTimeout((function(){e.element.style.transition=n}),10)},e.tag="tooltip",e}(UD);class $D extends ND{static defaultOptions={trigger:"hover",position:"top-right",enterable:!1,enable:!0,style:{".tooltip":{visibility:"hidden"}}};currentTarget=null;tooltipElement=null;container=null;constructor(t,e){super(t,Object.assign({},$D.defaultOptions,e)),this.render(),this.bindEvents()}getEvents(){return"click"===this.options.trigger?{"node:click":this.onClick,"edge:click":this.onClick,"combo:click":this.onClick,"canvas:click":this.onPointerLeave,afterremoveitem:this.onPointerLeave,contextmenu:this.onPointerLeave,drag:this.onPointerLeave}:{"node:pointerenter":this.onPointerEnter,"node:pointermove":this.onPointerMove,"canvas:pointermove":this.onCanvasMove,"edge:pointerenter":this.onPointerEnter,"edge:pointermove":this.onPointerMove,"combo:pointerenter":this.onPointerEnter,"combo:pointermove":this.onPointerMove,contextmenu:this.onPointerLeave,"node:drag":this.onPointerLeave}}update(t){this.unbundEvents(),super.update(t),this.tooltipElement&&this.container?.removeChild(this.tooltipElement.HTMLTooltipElement),this.tooltipElement=this.initTooltip(),this.bindEvents()}render(){const{canvas:t}=this.context,e=t.getContainer();e&&(this.container=e,this.tooltipElement=this.initTooltip())}unbundEvents(){const{graph:t}=this.context,e=this.getEvents();Object.keys(e).forEach((n=>{t.off(n,e[n])}))}bindEvents(){const{graph:t}=this.context,e=this.getEvents();Object.keys(e).forEach((n=>{t.on(n,e[n])}))}isEnable=t=>{const{enable:e}=this.options;return"function"==typeof e?e(t):e};onClick=t=>{const{target:{id:e}}=t;this.currentTarget===e?(this.currentTarget=null,this.hideTooltip(t)):(this.currentTarget=e,this.showTooltip(t))};onPointerMove=t=>{const{target:e}=t;this.currentTarget&&e.id!==this.currentTarget&&this.showTooltip(t)};onPointerLeave=t=>{this.hideTooltip(t),this.currentTarget=null};onCanvasMove=t=>{this.hideTooltip(t),this.currentTarget=null};onPointerEnter=t=>{this.showTooltip(t)};showTooltipById=(t,e="node")=>{const n={targetType:e,target:{id:t}};this.showTooltip(n)};getItems=(t,e)=>{const{model:n}=this.context;switch(e){case"node":return n.getNodeData([t]);case"edge":return n.getEdgeData([t]);case"combo":return n.getComboData([t]);default:return[]}};showTooltip=t=>{const{targetType:e,client:n,target:{id:r,attributes:i={color:"#1883FF"}}}=t;if(!this.tooltipElement||!this.isEnable(t))return;const{getContent:o}=this.options,{color:a,stroke:s}=i;this.currentTarget=r;const u=this.getItems(r,e);let c,h;if(n)c=n.x,h=n.y;else{const t=oe(u,"0.style",{x:0,y:0});c=t.x,h=t.y}let l={};o?l.content=o(t,u):l={title:e,data:u.map((t=>({name:"ID",value:t.id||`${t.source} -> ${t.target}`,color:a||s})))},this.tooltipElement.update({x:c,y:h,style:{".tooltip":{visibility:"visible"}},...l})};hideTooltip=t=>{if(!t)return void this.tooltipElement?.hide();if(!this.tooltipElement||!this.isEnable(t))return;const{client:{x:e,y:n}}=t;this.tooltipElement.hide(e,n)};initTooltip=()=>{const{canvas:t}=this.context,{center:e}=t.getBounds(),n=t.getContainer(),{top:r,left:i}=n.getBoundingClientRect(),{style:o,position:a,enterable:s,container:u={x:-i,y:-r}}=this.options,[c,h]=e,[l,d]=t.getSize(),f=new YD({className:"tooltip",style:{x:c,y:h,container:u,bounding:{x:0,y:0,width:l,height:d},position:a,enterable:s,title:"",offset:[10,10],style:o}});return this.container?.appendChild(f.HTMLTooltipElement),f};destroy(){this.unbundEvents(),this.tooltipElement&&this.container?.removeChild(this.tooltipElement.HTMLTooltipElement),super.destroy()}}let XD;function KD(t,e){XD||(XD=document.createElement("canvas")),XD.width=t,XD.height=e;return XD.getContext("2d").clearRect(0,0,t,e),XD}class ZD extends ND{static defaultOptions={width:200,height:100,opacity:.2,rotate:Math.PI/12,textFill:"#000",textFontSize:16,textAlign:"center",textBaseline:"middle",backgroundRepeat:"repeat"};$element=RD("watermark");constructor(t,e){super(t,Object.assign({},ZD.defaultOptions,e));this.context.canvas.getContainer().appendChild(this.$element),this.update(e)}async update(t){super.update(t);const{width:e,height:n,text:r,imageURL:i,...o}=this.options;Object.keys(o).forEach((e=>{e.startsWith("background")&&(this.$element.style[e]=t[e])}));const a=i?await async function(t,e,n,r){const i=KD(t,e),o=i.getContext("2d"),{rotate:a,opacity:s}=r;a&&o.rotate(a),s&&(o.globalAlpha=s);const u=new Image;return u.crossOrigin="anonymous",u.src=n,new Promise((n=>{u.onload=function(){const r=t>u.width?(t-u.width)/2:0,a=e>u.height?(e-u.height)/2:0;o.drawImage(u,0,0,u.width,u.height,r,a,t-2*r,e-2*a),n(i.toDataURL())}}))}(e,n,i,o):await async function(t,e,n,r){const i=KD(t,e),o=i.getContext("2d"),{rotate:a,opacity:s,textFill:u,textFontSize:c,textFontFamily:h,textFontVariant:l,textFontWeight:d,textAlign:f,textBaseline:p}=r;return o.textAlign=f,o.textBaseline=p,o.translate(t/2,e/2),o.font=`${c}px ${h} ${l} ${d}`,a&&o.rotate(a),s&&(o.globalAlpha=s),u&&(o.fillStyle=u,o.fillText(`${n}`,0,0)),i.toDataURL()}(e,n,r,o);this.$element.style.backgroundImage=`url(${a})`}destroy(){super.destroy(),this.$element.remove()}}const QD=["#7E92B5","#f5222d","#faad14"],JD={type:"group",color:["#1783FF","#00C9C9","#F08F56","#D580FF","#7863FF","#DB9D0D","#60C42D","#FF80CA","#2491B3","#17C76F"]},tI={type:"group",color:["#99ADD1","#1783FF","#00C9C9","#F08F56","#D580FF","#7863FF","#DB9D0D","#60C42D","#FF80CA","#2491B3","#17C76F"]};function eI(t){const{bgColor:e,textColor:n,nodeColor:r,nodeColorDisabled:i,nodeStroke:o,nodeBadgePalette:a=QD,nodePaletteOptions:s=JD,edgeColor:u,edgeColorDisabled:c,edgePaletteOptions:h=tI,comboColor:l,comboColorDisabled:d,comboStroke:f,comboStrokeDisabled:p}=t;return{background:e,node:{palette:s,style:{badgeFill:e,badgeFontSize:8,badgePadding:[1,4],badgePalette:a,color:r,halo:!1,haloLineWidth:12,haloStrokeOpacity:.25,iconFill:e,iconFontSize:16,labelBackground:!1,labelBackgroundFill:e,labelBackgroundLineWidth:0,labelBackgroundOpacity:.5,labelBackgroundPadding:[0,2],labelFill:n,labelFontSize:12,portFill:r,portLineWidth:1,portStroke:o,portStrokeOpacity:.65},state:{selected:{halo:!0,labelFontSize:14,labelFontWeight:700,lineWidth:3,stroke:o},active:{halo:!0},highlight:{labelFontWeight:700,lineWidth:3,stroke:o,strokeOpacity:.85},inactive:{iconOpacity:.25,labelOpacity:.25,opacity:.25},disabled:{color:i,labelOpacity:.25}},animation:{enter:"fade",exit:"fade",visibility:"fade",update:[{fields:["x","y","color","stroke"]}]}},edge:{palette:h,style:{color:u,halo:!1,haloLineWidth:12,haloStrokeOpacity:.25,increasedLineWidthForHitTesting:2,labelBackground:!1,labelBackgroundFill:e,labelBackgroundLineWidth:0,labelBackgroundOpacity:.75,labelBackgroundPadding:[4,4,4,4],labelFill:n,labelFontSize:12,labelPlacement:"center",labelTextBaseline:"middle",lineWidth:1},state:{selected:{halo:!0,labelFontSize:14,labelFontWeight:700,lineWidth:2},active:{halo:!0},highlight:{labelFontWeight:700,lineWidth:2},inactive:{labelOpacity:.25,opacity:.25},disabled:{labelOpacity:.25,color:c}},animation:{enter:"fade",exit:"fade",visibility:"fade",update:[{fields:["color"]},{fields:["path"],shape:"key"}]}},combo:{style:{collapsedMaskFill:l,collapsedMaskFontSize:12,collapsedSize:32,color:l,haloLineWidth:12,haloStrokeOpacity:.25,labelBackground:!1,labelBackgroundFill:e,labelBackgroundLineWidth:0,labelBackgroundOpacity:.75,labelBackgroundPadding:[2,4,2,4],labelFill:n,labelFontSize:12,lineDash:0,lineWidth:1,padding:10,stroke:f},state:{selected:{halo:!0,labelFontSize:14,labelFontWeight:700,lineWidth:4},active:{halo:!0},highlight:{labelFontWeight:700,lineWidth:4},inactive:{labelOpacity:.25,opacity:.65},disabled:{color:d,labelOpacity:.25,opacity:.25,stroke:p}},animation:{enter:"fade",exit:"fade",visibility:"fade",expand:"combo-collapse-expand",collapse:"combo-collapse-expand",update:[{fields:["x","y"]},{fields:["size","color","stroke"],shape:"key"}]}}}}const nI=eI({bgColor:"#000000",textColor:"#ffffffd9",nodeColor:"#1783ff",nodeColorDisabled:"#d0e4ff",nodeStroke:"#d0e4ff",edgeColor:"#99add1",edgeColorDisabled:"#969696",comboColor:"#fdfdfd",comboColorDisabled:"#d0e4ff",comboStroke:"#99add1",comboStrokeDisabled:"#969696"}),rI=eI({bgColor:"#fff",textColor:"#000000d9",nodeColor:"#1783ff",nodeColorDisabled:"#f0f0f0",nodeStroke:"#000000",edgeColor:"#99add1",edgeColorDisabled:"#d9d9d9",comboColor:"#fdfdfd",comboColorDisabled:"#f0f0f0",comboStroke:"#99add1",comboStrokeDisabled:"#d9d9d9"}),iI={animation:{fade:[{fields:["opacity"]}],translate:[{fields:["x","y"]}],"combo-collapse-expand":[{fields:["x","y"]},{fields:["r","width","height"],shape:"key"}]},behavior:{"zoom-canvas":Ol,"drag-canvas":Cl,"drag-element":Al,"collapse-expand":kl},combo:{circle:class extends Th{constructor(t){super(t)}drawKeyShape(t,e){return this.upsert("key",Ss,this.getKeyStyle(t),e)}getKeyStyle(t){const{collapsed:e}=t,n=super.getKeyStyle(t),r=zc(n,"collapsed"),[i]=this.getKeySize(t);return{...n,...e&&r,r:i/2}}getCollapsedKeySize(t){const[e,n]=Oc(t.collapsedSize),r=Math.max(e,n)/2;return[2*r,2*r,0]}getExpandedKeySize(t){if(!re(t.size)){const[e,n]=Oc(t.size),r=Math.sqrt(e**2+n**2)/2;return[2*r,2*r,0]}const e=this.getContentBBox(t),[n,r]=Ec(e),i=Math.sqrt(n**2+r**2)/2;return[2*i,2*i,0]}getCollapsedOriginPosition(t){return Dc(t.collapsedOrigin,this.getContentBBox(t).center,this.getCollapsedKeySize(t),this.getExpandedKeySize(t),_c)}},rect:kh},edge:{cubic:Kh,line:Jh,polyline:tl,quadratic:el,"cubic-horizontal":Zh,"cubic-vertical":Qh},layout:{"antv-dagre":class{constructor(t={}){this.options=t,this.id="antv-dagre",this.options=Object.assign(Object.assign({},Kg),t)}execute(t,e){return a(this,void 0,void 0,(function*(){return this.genericDagreLayout(!1,t,e)}))}assign(t,e){return a(this,void 0,void 0,(function*(){yield this.genericDagreLayout(!0,t,e)}))}genericDagreLayout(t,e,n){return a(this,void 0,void 0,(function*(){const r=Object.assign(Object.assign({},this.options),n),{nodeSize:i,align:o,rankdir:a="TB",ranksep:s,nodesep:u,ranksepFunc:c,nodesepFunc:h,edgeLabelSpace:l,ranker:d,nodeOrder:f,begin:p,controlPoints:g,radial:m,sortByCombo:v,preset:y}=r,b=new Yf({tree:[]}),E=Yg(s||50,c),w=Yg(u||50,h);let x=w,M=E;"LR"!==a&&"RL"!==a||(x=E,M=w);const N=Xg(i,void 0),S=e.getAllNodes(),T=e.getAllEdges();let k;S.forEach((t=>{const e=N(t),n=M(t),r=e+2*x(t),i=e+2*n,o=t.data.layer;Vt(o)?b.addNode({id:t.id,data:{width:r,height:i,layer:o}}):b.addNode({id:t.id,data:{width:r,height:i}})})),v&&(b.attachTreeStructure("combo"),S.forEach((t=>{const{parentId:e}=t.data;void 0!==e&&b.hasNode(e)&&b.setParent(t.id,e,"combo")}))),T.forEach((t=>{b.addEdge({id:t.id,source:t.source,target:t.target,data:{weight:t.data.weight||1}})})),(null==y?void 0:y.length)&&(k=new Yf({nodes:y})),((t,e)=>{const{edgeLabelSpace:n,keepNodeOrder:r,prevGraph:i,rankdir:o,ranksep:a}=e;!r&&i&&yg(t,i);const s=Sg(t);let u;n&&(e.ranksep=Tg(s,{rankdir:o,ranksep:a}));try{u=vg(s,e)}catch(t){if("Not possible to find intersection inside of the rectangle"===t.message)return void console.error("The following error may be caused by improper layer setting, please make sure your manual layer setting does not violate the graph's structure:\n",t);throw t}bg(t,s)})(b,{prevGraph:k,edgeLabelSpace:l,keepNodeOrder:!!f,nodeOrder:f||[],acyclicer:"greedy",ranker:d,rankdir:a,nodesep:u,align:o});const P=[0,0];if(p){let t=1/0,e=1/0;b.getAllNodes().forEach((n=>{t>n.data.x&&(t=n.data.x),e>n.data.y&&(e=n.data.y)})),b.getAllEdges().forEach((n=>{var r;null===(r=n.data.points)||void 0===r||r.forEach((n=>{t>n.x&&(t=n.x),e>n.y&&(e=n.y)}))})),P[0]=p[0]-t,P[1]=p[1]-e}const C="LR"===a||"RL"===a;if(m);else{const t=new Set,e="BT"===a||"RL"===a?(t,e)=>e-t:(t,e)=>t-e;b.getAllNodes().forEach((e=>{e.data.x=e.data.x+P[0],e.data.y=e.data.y+P[1],t.add(C?e.data.x:e.data.y)}));const n=Array.from(t).sort(e),r=C?(t,e)=>t.x!==e.x:(t,e)=>t.y!==e.y,i=C?(t,e,n)=>{const r=Math.max(e.y,n.y),i=Math.min(e.y,n.y);return t.filter((t=>t.y<=r&&t.y>=i))}:(t,e,n)=>{const r=Math.max(e.x,n.x),i=Math.min(e.x,n.x);return t.filter((t=>t.x<=r&&t.x>=i))};b.getAllEdges().forEach(((t,e)=>{var o;l&&g&&"loop"!==t.data.type&&(t.data.controlPoints=Zg(null===(o=t.data.points)||void 0===o?void 0:o.map((({x:t,y:e})=>({x:t+P[0],y:e+P[1]}))),b.getNode(t.source),b.getNode(t.target),n,C,r,i))}))}let A=[];A=b.getAllNodes().map((t=>qg(t)));const O=b.getAllEdges();t&&(A.forEach((t=>{e.mergeNodeData(t.id,{x:t.data.x,y:t.data.y})})),O.forEach((t=>{e.mergeEdgeData(t.id,{controlPoints:t.data.controlPoints})})));return{nodes:A,edges:O}}))}},"combo-combined":class{constructor(t={}){this.options=t,this.id="comboCombined",this.options=Object.assign(Object.assign({},Av),t)}execute(t,e){return a(this,void 0,void 0,(function*(){return this.genericComboCombinedLayout(!1,t,e)}))}assign(t,e){return a(this,void 0,void 0,(function*(){yield this.genericComboCombinedLayout(!0,t,e)}))}genericComboCombinedLayout(t,e,n){return a(this,void 0,void 0,(function*(){const r=this.initVals(Object.assign(Object.assign({},this.options),n)),{center:i,treeKey:o,outerLayout:a}=r,s=e.getAllNodes().filter((t=>!t.data._isCombo)),u=e.getAllNodes().filter((t=>t.data._isCombo)),c=e.getAllEdges(),h=null==s?void 0:s.length;if(!h||1===h)return Qg(e,t,i);const l=[],d=new Map;s.forEach((t=>{d.set(t.id,t)}));const f=new Map;u.forEach((t=>{f.set(t.id,t)}));const p=new Map,g=this.getInnerGraphs(e,o,d,f,c,r,p);yield Promise.all(g);const m=new Map,v=[],y=new Map;let b=!0;e.getRoots(o).forEach((t=>{const n=p.get(t.id),r=f.get(t.id)||d.get(t.id),i={id:t.id,data:Object.assign(Object.assign({},t.data),{x:n.data.x||r.data.x,y:n.data.y||r.data.y,fx:n.data.fx||r.data.fx,fy:n.data.fy||r.data.fy,mass:n.data.mass||r.data.mass,size:n.data.size})};v.push(i),m.set(t.id,!0),isNaN(i.data.x)||0===i.data.x||isNaN(i.data.y)||0===i.data.y?(i.data.x=100*Math.random(),i.data.y=100*Math.random()):b=!1,Wg(e,[t],(e=>{e.id!==t.id&&y.set(e.id,t.id)}),"TB",o)}));const E=[];let w;if(c.forEach((t=>{const e=y.get(t.source)||t.source,n=y.get(t.target)||t.target;e!==n&&m.has(e)&&m.has(n)&&E.push({id:t.id,source:e,target:n,data:{}})})),null==v?void 0:v.length){if(1===v.length)v[0].data.x=i[0],v[0].data.y=i[1];else{const t=new Yf({nodes:v,edges:E}),e=a||new Sm;if(b&&Cv[e.id]){const e=v.length<100?new Tv:new rm;yield e.assign(t)}w=yield e.execute(t,Object.assign({center:i,kg:5,preventOverlap:!0,animate:!1},"force"===e.id?{gravity:1,factor:4,linkDistance:(t,e,n)=>(Math.max(...e.data.size)||32)/2+(Math.max(...n.data.size)||32)/2+200}:{}))}p.forEach((t=>{var e;const n=w.nodes.find((e=>e.id===t.id));if(n){const{x:e,y:r}=n.data;t.data.visited=!0,t.data.x=e,t.data.y=r,l.push({id:t.id,data:{x:e,y:r}})}const{x:r,y:i}=t.data;null===(e=t.data.nodes)||void 0===e||e.forEach((t=>{l.push({id:t.id,data:{x:t.data.x+r,y:t.data.y+i}})}))})),p.forEach((({data:t})=>{const{x:e,y:n,visited:r,nodes:i}=t;null==i||i.forEach((t=>{if(!r){const r=l.find((e=>e.id===t.id));r.data.x+=e||0,r.data.y+=n||0}}))}))}t&&l.forEach((t=>{e.mergeNodeData(t.id,{x:t.data.x,y:t.data.y})}));return{nodes:l,edges:c}}))}initVals(t){const e=Object.assign({},t),{nodeSize:n,spacing:r,comboPadding:i}=t;let o,a,s;if(a=Vt(r)?()=>r:kt(r)?r:()=>0,e.spacing=a,n)if(kt(n))o=t=>{const e=n(t),r=a(t);if(Bg(t.size)){return((t.size[0]>t.size[1]?t.size[0]:t.size[1])+r)/2}return((e||32)+r)/2};else if(Bg(n)){const t=(n[0]>n[1]?n[0]:n[1])/2;o=e=>t+a(e)/2}else{const t=n/2;o=e=>t+a(e)/2}else o=t=>{const e=a(t);if(t.size){if(Bg(t.size)){return((t.size[0]>t.size[1]?t.size[0]:t.size[1])+e)/2}if(Rt(t.size)){return((t.size.width>t.size.height?t.size.width:t.size.height)+e)/2}return(t.size+e)/2}return 32+e/2};return e.nodeSize=o,s=Vt(i)?()=>i:Bg(i)?()=>Math.max.apply(null,i):kt(i)?i:()=>0,e.comboPadding=s,e}getInnerGraphs(t,e,n,r,i,o,s){const{nodeSize:u,comboPadding:c,spacing:h,innerLayout:l}=o,d=l||new rm({}),f={center:[0,0],preventOverlap:!0,nodeSpacing:h},p=[],g=t=>{let e=(null==c?void 0:c(t))||10;return Bg(e)&&(e=Math.max(...e)),{size:e?[2*e,2*e]:[30,30],padding:e}};return t.getRoots(e).forEach((o=>{s.set(o.id,{id:o.id,data:{nodes:[],size:g(o).size}});let c=Promise.resolve();Wg(t,[o],(o=>{var h;if(!o.data._isCombo)return;const{size:l,padding:p}=g(o);if(null===(h=t.getChildren(o.id,e))||void 0===h?void 0:h.length){const h=s.get(o.id);s.set(o.id,{id:o.id,data:Object.assign({nodes:[]},null==h?void 0:h.data)});const l=new Map,g=t.getChildren(o.id,e).map((t=>{if(t.data._isCombo)return s.has(t.id)||s.set(t.id,{id:t.id,data:Object.assign({},t.data)}),l.set(t.id,!0),s.get(t.id);const e=n.get(t.id)||r.get(t.id);return l.set(t.id,!0),{id:t.id,data:Object.assign(Object.assign({},e.data),t.data)}})),m={nodes:g,edges:i.filter((t=>l.has(t.source)&&l.has(t.target)))};let v=1/0;g.forEach((t=>{var e;let{size:n}=t.data;n||(n=(null===(e=s.get(t.id))||void 0===e?void 0:e.data.size)||(null==u?void 0:u(t))||[30,30]),Vt(n)&&(n=[n,n]);const[r,i]=n;v>r&&(v=r),v>i&&(v=i),t.data.size=n})),c=c.then((()=>a(this,void 0,void 0,(function*(){const t=new Yf(m),e=yield d.assign(t,f),{minX:n,minY:r,maxX:i,maxY:a}=(t=>{let e=1/0,n=1/0,r=-1/0,i=-1/0;return t.forEach((t=>{let o=t.data.size;Bg(o)?1===o.length&&(o=[o[0],o[0]]):Vt(o)?o=[o,o]:(void 0===o||isNaN(o))&&(o=[30,30]);const a=[o[0]/2,o[1]/2],s=t.data.x-a[0],u=t.data.x+a[0],c=t.data.y-a[1],h=t.data.y+a[1];e>s&&(e=s),n>c&&(n=c),r<u&&(r=u),i<h&&(i=h)})),{minX:e,minY:n,maxX:r,maxY:i}})(g),u=(i+n)/2,c=(a+r)/2;m.nodes.forEach((t=>{t.data.x-=u,t.data.y-=c}));const h=[Math.max(i-n,v)+2*p,Math.max(a-r,v)+2*p];return s.get(o.id).data.size=h,s.get(o.id).data.nodes=g,e}))))}else s.set(o.id,{id:o.id,data:Object.assign(Object.assign({},o.data),{size:l})});return!0}),"BT",e),p.push(c)})),p}},"compact-box":Gf.compactBox,"force-atlas2":class{constructor(t={}){this.options=t,this.id="forceAtlas2",this.options=Object.assign(Object.assign({},j_),t)}execute(t,e){return a(this,void 0,void 0,(function*(){return this.genericForceAtlas2Layout(!1,t,e)}))}assign(t,e){return a(this,void 0,void 0,(function*(){this.genericForceAtlas2Layout(!0,t,e)}))}genericForceAtlas2Layout(t,e,n){return a(this,void 0,void 0,(function*(){const r=e.getAllEdges(),i=e.getAllNodes(),o=this.formatOptions(n,i.length),{width:a,height:s,prune:u,maxIteration:c,nodeSize:h,center:l}=o;if(!(null==i?void 0:i.length)||1===i.length)return Qg(e,t,l);const d=i.map((t=>qg(t,[a,s]))),f=r.filter((t=>{const{source:e,target:n}=t;return e!==n})),p=new Yf({nodes:d,edges:f}),g=this.getSizes(p,e,h);if(this.run(p,e,c,g,t,o),u){for(let t=0;t<f.length;t+=1){const{source:e,target:n}=f[t],r=p.getDegree(e),i=p.getDegree(e);if(r<=1){const t=p.getNode(n);p.mergeNodeData(e,{x:t.data.x,y:t.data.y})}else if(i<=1){const t=p.getNode(e);p.mergeNodeData(n,{x:t.data.x,y:t.data.y})}}const n=Object.assign(Object.assign({},o),{prune:!1,barnesHut:!1});this.run(p,e,100,g,t,n)}return{nodes:d,edges:r}}))}getSizes(t,e,n){const r=t.getAllNodes(),i={};for(let t=0;t<r.length;t+=1){const{id:o,data:a}=r[t];if(i[o]=10,Vt(a.size))i[o]=a.size;else if(Bg(a.size))isNaN(a.size[0])||(i[o]=Math.max(a.size[0])),isNaN(a.size[1])||(i[o]=Math.max(a.size[1]));else if(Rt(a.size))i[o]=Math.max(a.size.width,a.size.height);else if(kt(n)){const t=n(e.getNode(o));Bg(t)?i[o]=Math.max(...t):i[o]=t}else Bg(n)?i[o]=Math.max(...n):Vt(n)&&(i[o]=n)}return i}formatOptions(t={},e){const n=Object.assign(Object.assign({},this.options),t),{center:r,width:i,height:o,barnesHut:a,prune:s,maxIteration:u,kr:c,kg:h}=n;return n.width=i||"undefined"==typeof window?i:window.innerWidth,n.height=o||"undefined"==typeof window?o:window.innerHeight,n.center=r||[n.width/2,n.height/2],void 0===a&&e>250&&(n.barnesHut=!0),void 0===s&&e>100&&(n.prune=!0),0!==u||s?0===u&&s&&(n.maxIteration=100,e<=200&&e>100?n.maxIteration=500:e>200&&(n.maxIteration=950)):(n.maxIteration=250,e<=200&&e>100?n.maxIteration=1e3:e>200&&(n.maxIteration=1200)),c||(n.kr=50,e>100&&e<=500?n.kr=20:e>500&&(n.kr=1)),h||(n.kg=20,e>100&&e<=500?n.kg=10:e>500&&(n.kg=1)),n}run(t,e,n,r,i,o){const{kr:a,barnesHut:s,onTick:u}=o,c=t.getAllNodes();let h=0,l=n;const d={},f={},p={};for(let e=0;e<c.length;e+=1){const{data:n,id:r}=c[e];if(d[r]=[0,0],s){const i={id:e,rx:n.x,ry:n.y,mass:1,g:a,degree:t.getDegree(r)};p[r]=new D_(i)}}for(;l>0;)h=this.oneStep(t,{iter:l,preventOverlapIters:50,krPrime:100,sg:h,forces:d,preForces:f,bodies:p,sizes:r},o),l--,null==u||u({nodes:c,edges:e.getAllEdges()});return t}oneStep(t,e,n){const{iter:r,preventOverlapIters:i,krPrime:o,sg:a,preForces:s,bodies:u,sizes:c}=e;let{forces:h}=e;const{preventOverlap:l,barnesHut:d}=n,f=t.getAllNodes();for(let t=0;t<f.length;t+=1){const{id:e}=f[t];s[e]=[...h[e]],h[e]=[0,0]}return h=this.getAttrForces(t,r,i,c,h,n),h=d&&(l&&r>i||!l)?this.getOptRepGraForces(t,h,u,n):this.getRepGraForces(t,r,i,h,o,c,n),this.updatePos(t,h,s,a,n)}getAttrForces(t,e,n,r,i,o){const{preventOverlap:a,dissuadeHubs:s,mode:u,prune:c}=o,h=t.getAllEdges();for(let o=0;o<h.length;o+=1){const{source:l,target:d}=h[o],f=t.getNode(l),p=t.getNode(d),g=t.getDegree(l),m=t.getDegree(d);if(c&&(g<=1||m<=1))continue;const v=[p.data.x-f.data.x,p.data.y-f.data.y];let y=Math.hypot(v[0],v[1]);y=y<1e-4?1e-4:y,v[0]=v[0]/y,v[1]=v[1]/y,a&&e<n&&(y=y-r[l]-r[d]);let b=y,E=b;"linlog"===u&&(b=Math.log(1+y),E=b),s&&(b=y/g,E=y/m),a&&e<n&&y<=0?(b=0,E=0):a&&e<n&&y>0&&(b=y,E=y),i[l][0]+=b*v[0],i[d][0]-=E*v[0],i[l][1]+=b*v[1],i[d][1]-=E*v[1]}return i}getOptRepGraForces(t,e,n,r){const{kg:i,center:o,prune:a}=r,s=t.getAllNodes(),u=s.length;let c=9e10,h=-9e10,l=9e10,d=-9e10;for(let e=0;e<u;e+=1){const{id:r,data:i}=s[e];a&&t.getDegree(r)<=1||(n[r].setPos(i.x,i.y),i.x>=h&&(h=i.x),i.x<=c&&(c=i.x),i.y>=d&&(d=i.y),i.y<=l&&(l=i.y))}const f=Math.max(h-c,d-l),p=new I_({xmid:(h+c)/2,ymid:(d+l)/2,length:f,massCenter:o,mass:u}),g=new L_(p);for(let e=0;e<u;e+=1){const{id:r}=s[e];a&&t.getDegree(r)<=1||n[r].in(p)&&g.insert(n[r])}for(let r=0;r<u;r+=1){const{id:u,data:c}=s[r],h=t.getDegree(u);if(a&&h<=1)continue;n[u].resetForce(),g.updateForce(n[u]),e[u][0]-=n[u].fx,e[u][1]-=n[u].fy;const l=[c.x-o[0],c.y-o[1]];let d=Math.hypot(l[0],l[1]);d=d<1e-4?1e-4:d,l[0]=l[0]/d,l[1]=l[1]/d;const f=i*(h+1);e[u][0]-=f*l[0],e[u][1]-=f*l[1]}return e}getRepGraForces(t,e,n,r,i,o,a){const{preventOverlap:s,kr:u,kg:c,center:h,prune:l}=a,d=t.getAllNodes(),f=d.length;for(let a=0;a<f;a+=1){const p=d[a],g=t.getDegree(p.id);for(let c=a+1;c<f;c+=1){const a=d[c],h=t.getDegree(a.id);if(l&&(g<=1||h<=1))continue;const f=[a.data.x-p.data.x,a.data.y-p.data.y];let m=Math.hypot(f[0],f[1]);m=m<1e-4?1e-4:m,f[0]=f[0]/m,f[1]=f[1]/m,s&&e<n&&(m=m-o[p.id]-o[a.id]);let v=u*(g+1)*(h+1)/m;s&&e<n&&m<0?v=i*(g+1)*(h+1):s&&e<n&&0===m?v=0:s&&e<n&&m>0&&(v=u*(g+1)*(h+1)/m),r[p.id][0]-=v*f[0],r[a.id][0]+=v*f[0],r[p.id][1]-=v*f[1],r[a.id][1]+=v*f[1]}const m=[p.data.x-h[0],p.data.y-h[1]],v=Math.hypot(m[0],m[1]);m[0]=m[0]/v,m[1]=m[1]/v;const y=c*(g+1);r[p.id][0]-=y*m[0],r[p.id][1]-=y*m[1]}return r}updatePos(t,e,n,r,i){const{ks:o,tao:a,prune:s,ksmax:u}=i,c=t.getAllNodes(),h=c.length,l=[],d=[];let f=0,p=0,g=r;for(let r=0;r<h;r+=1){const{id:i}=c[r],o=t.getDegree(i);if(s&&o<=1)continue;const a=[e[i][0]-n[i][0],e[i][1]-n[i][1]],u=Math.hypot(a[0],a[1]),h=[e[i][0]+n[i][0],e[i][1]+n[i][1]],g=Math.hypot(h[0],h[1]);l[r]=u,d[r]=g/2,f+=(o+1)*l[r],p+=(o+1)*d[r]}const m=g;g=a*p/f,0!==m&&(g=g>1.5*m?1.5*m:g);for(let n=0;n<h;n+=1){const{id:r,data:i}=c[n],a=t.getDegree(r);if(s&&a<=1)continue;if(Vt(i.fx)&&Vt(i.fy))continue;let h=o*g/(1+g*Math.sqrt(l[n])),d=Math.hypot(e[r][0],e[r][1]);d=d<1e-4?1e-4:d;const f=u/d;h=h>f?f:h;const p=h*e[r][0],m=h*e[r][1];t.mergeNodeData(r,{x:i.x+p,y:i.y+m})}return g}},circular:class{constructor(t={}){this.options=t,this.id="circular",this.options=Object.assign(Object.assign({},Jg),t)}execute(t,e){return a(this,void 0,void 0,(function*(){return this.genericCircularLayout(!1,t,e)}))}assign(t,e){return a(this,void 0,void 0,(function*(){yield this.genericCircularLayout(!0,t,e)}))}genericCircularLayout(t,e,n){return a(this,void 0,void 0,(function*(){const r=Object.assign(Object.assign({},this.options),n),{width:i,height:o,center:a,divisions:s,startAngle:u=0,endAngle:c=2*Math.PI,angleRatio:h,ordering:l,clockwise:d,nodeSpacing:f,nodeSize:p}=r,g=e.getAllNodes(),m=e.getAllEdges(),[v,y,b]=em(i,o,a),E=null==g?void 0:g.length;if(!E||1===E)return Qg(e,t,b);const w=(c-u)/E;let{radius:x,startRadius:M,endRadius:N}=r;if(f){const t=Yg(10,f),e=$g(10,p);let n=-1/0;g.forEach((t=>{const r=e(t);n<r&&(n=r)}));let r=0;g.forEach(((e,i)=>{r+=0===i?n||10:(t(e)||0)+(n||10)})),x=r/(2*Math.PI)}else x||M||N?!M&&N?M=N:M&&!N&&(N=M):x=Math.min(y,v)/2;const S=w*h;let T=[];T="topology"===l?tm(e,g):"topology-directed"===l?tm(e,g,!0):"degree"===l?function(t,e){const n=[];return e.forEach(((t,e)=>{n.push(qg(t))})),n.sort(((e,n)=>t.getDegree(e.id,"both")-t.getDegree(n.id,"both"))),n}(e,g):g.map((t=>qg(t)));const k=Math.ceil(E/s);for(let t=0;t<E;++t){let e=x;e||null===M||null===N||(e=M+t*(N-M)/(E-1)),e||(e=10+100*t/(E-1));let n=u+t%k*S+2*Math.PI/s*Math.floor(t/k);d||(n=c-t%k*S-2*Math.PI/s*Math.floor(t/k)),T[t].data.x=b[0]+Math.cos(n)*e,T[t].data.y=b[1]+Math.sin(n)*e}t&&T.forEach((t=>{e.mergeNodeData(t.id,{x:t.data.x,y:t.data.y})}));return{nodes:T,edges:m}}))}},concentric:rm,d3force:class{constructor(t={}){this.options=t,this.id="d3force",this.options=Object.assign(Object.assign({},Ey),t)}execute(t,e){return a(this,void 0,void 0,(function*(){return this.genericForceLayout(!1,t,e)}))}assign(t,e){return a(this,void 0,void 0,(function*(){this.genericForceLayout(!0,t,e)}))}stop(){var t;null===(t=this.forceSimulation)||void 0===t||t.stop()}tick(t=1){this.forceSimulation.tick(t);const e={nodes:wy(this.lastLayoutNodes),edges:xy(this.lastLayoutEdges)};return this.lastAssign&&e.nodes.forEach((t=>this.lastGraph.mergeNodeData(t.id,{x:t.data.x,y:t.data.y}))),e}genericForceLayout(t,e,n){return a(this,void 0,void 0,(function*(){const r=Object.assign(Object.assign({},this.options),n),i=e.getAllNodes(),o=e.getAllEdges(),a=i.map((t=>{var e,n;return Object.assign(Object.assign({},qg(t)),{x:null===(e=t.data)||void 0===e?void 0:e.x,y:null===(n=t.data)||void 0===n?void 0:n.y})})),s=o.map((t=>qg(t)));this.lastLayoutNodes=a,this.lastLayoutEdges=s,this.lastAssign=t,this.lastGraph=e;const{alphaMin:u,alphaDecay:c,alpha:h,nodeStrength:l,edgeStrength:d,linkDistance:f,clustering:p,clusterFociStrength:g,clusterEdgeDistance:m,clusterEdgeStrength:v,clusterNodeStrength:y,clusterNodeSize:b,collideStrength:E=1,center:w=[0,0],preventOverlap:x,nodeSize:M,nodeSpacing:N,onTick:S}=r;let{forceSimulation:T}=r;return new Promise((n=>{if(T){if(p){const t=by();t.nodes(a),t.links(s)}if(T.nodes(a),s){const t=zv().id((t=>t.id)).links(s);d&&t.strength(d),f&&t.distance(f),T.force("link",t)}x&&this.overlapProcess(T,{nodeSize:M,nodeSpacing:N,collideStrength:E}),T.alpha(h).restart();const r=wy(a),i=xy(s);t&&r.forEach((t=>e.mergeNodeData(t.id,{x:t.data.x,y:t.data.y}))),n({nodes:r,edges:i})}else try{const r=my();if(l&&r.strength(l),T=gy().nodes(a),p){const t=by();t.centerX(w[0]).centerY(w[1]).template("force").strength(g),s&&t.links(s),a&&t.nodes(a),t.forceLinkDistance(m).forceLinkStrength(v).forceCharge(y).forceNodeSize(b),T.force("group",t)}if(T.force("center",function(t,e){var n,r=1;function i(){var i,o,a=n.length,s=0,u=0;for(i=0;i<a;++i)s+=(o=n[i]).x,u+=o.y;for(s=(s/a-t)*r,u=(u/a-e)*r,i=0;i<a;++i)(o=n[i]).x-=s,o.y-=u}return null==t&&(t=0),null==e&&(e=0),i.initialize=function(t){n=t},i.x=function(e){return arguments.length?(t=+e,i):t},i.y=function(t){return arguments.length?(e=+t,i):e},i.strength=function(t){return arguments.length?(r=+t,i):r},i}(w[0],w[1])).force("charge",r).alpha(h).alphaDecay(c).alphaMin(u),x&&this.overlapProcess(T,{nodeSize:M,nodeSpacing:N,collideStrength:E}),s){const t=zv().id((t=>t.id)).links(s);d&&t.strength(d),f&&t.distance(f),T.force("link",t)}T.on("tick",(()=>{const n=wy(a);null==S||S({nodes:n,edges:xy(s)}),t&&n.forEach((t=>e.mergeNodeData(t.id,{x:t.data.x,y:t.data.y})))})).on("end",(()=>{const r=wy(a);t&&r.forEach((t=>e.mergeNodeData(t.id,{x:t.data.x,y:t.data.y}))),n({nodes:r,edges:xy(s)})}))}catch(t){console.warn(t)}this.forceSimulation=T}))}))}overlapProcess(t,e){const{nodeSize:n,nodeSpacing:r,collideStrength:i}=e;let o,a;if(a=Vt(r)?()=>r:kt(r)?r:()=>0,n)if(kt(n))o=t=>n(t)+a(t);else if(Bg(n)){const t=(n[0]>n[1]?n[0]:n[1])/2;o=e=>t+a(e)}else if(Vt(n)){const t=n/2;o=e=>t+a(e)}else o=()=>10;else o=t=>{if(t.size){if(Bg(t.size)){return(t.size[0]>t.size[1]?t.size[0]:t.size[1])/2+a(t)}if(Rt(t.size)){return(t.size.width>t.size.height?t.size.width:t.size.height)/2+a(t)}return t.size/2+a(t)}return 10+a(t)};t.force("collisionForce",Iv(o).strength(i))}},dagre:__,dendrogram:Gf.dendrogram,force:Sm,fruchterman:class{constructor(t={}){this.options=t,this.id="fruchterman",this.timeInterval=0,this.running=!1,this.options=Object.assign(Object.assign({},z_),t)}execute(t,e){return a(this,void 0,void 0,(function*(){return this.genericFruchtermanLayout(!1,t,e)}))}assign(t,e){return a(this,void 0,void 0,(function*(){this.genericFruchtermanLayout(!0,t,e)}))}stop(){this.timeInterval&&"undefined"!=typeof window&&window.clearInterval(this.timeInterval),this.running=!1}tick(t=this.options.maxIteration||1){if(this.lastResult)return this.lastResult;for(let e=0;e<t;e++)this.runOneStep(this.lastGraph,this.lastClusterMap,this.lastOptions);const e={nodes:this.lastLayoutNodes,edges:this.lastLayoutEdges};return this.lastAssign&&e.nodes.forEach((t=>this.lastGraph.mergeNodeData(t.id,{x:t.data.x,y:t.data.y,z:3===this.options.dimensions?t.data.z:void 0}))),e}genericFruchtermanLayout(t,e,n){return a(this,void 0,void 0,(function*(){if(this.running)return;const r=this.formatOptions(n),{dimensions:i,width:o,height:a,center:s,clustering:u,nodeClusterBy:c,maxIteration:h,onTick:l}=r,d=e.getAllNodes(),f=e.getAllEdges();if(!(null==d?void 0:d.length)){const t={nodes:[],edges:f};return this.lastResult=t,t}if(1===d.length){t&&e.mergeNodeData(d[0].id,{x:s[0],y:s[1],z:3===i?s[2]:void 0});const n={nodes:[Object.assign(Object.assign({},d[0]),{data:Object.assign(Object.assign({},d[0].data),{x:s[0],y:s[1],z:3===i?s[2]:void 0})})],edges:f};return this.lastResult=n,n}const p=d.map((t=>qg(t,[o,a]))),g=new Yf({nodes:p,edges:f}),m={};if(u&&p.forEach((t=>{const e=t.data[c];m[e]||(m[e]={name:e,cx:0,cy:0,count:0})})),this.lastLayoutNodes=p,this.lastLayoutEdges=f,this.lastAssign=t,this.lastGraph=g,this.lastOptions=r,this.lastClusterMap=m,"undefined"==typeof window)return;let v=0;return new Promise((n=>{this.timeInterval=window.setInterval((()=>{this.running?(this.runOneStep(g,m,r),t&&p.forEach((({id:t,data:n})=>e.mergeNodeData(t,{x:n.x,y:n.y,z:3===i?n.z:void 0}))),null==l||l({nodes:p,edges:f}),v++,v>=h&&(window.clearInterval(this.timeInterval),n({nodes:p,edges:f}))):n({nodes:p,edges:f})}),0),this.running=!0}))}))}formatOptions(t={}){const e=Object.assign(Object.assign({},this.options),t),{clustering:n,nodeClusterBy:r}=e,{center:i,width:o,height:a}=e;return e.width=o||"undefined"==typeof window?o:window.innerWidth,e.height=a||"undefined"==typeof window?a:window.innerHeight,e.center=i||[e.width/2,e.height/2],e.clustering=n&&!!r,e}runOneStep(t,e,n){const{dimensions:r,height:i,width:o,gravity:a,center:s,speed:u,clustering:c,nodeClusterBy:h,clusterGravity:l}=n,d=i*o,f=Math.sqrt(d)/10,p=t.getAllNodes(),g=d/(p.length+1),m=Math.sqrt(g),v={};if(this.applyCalculate(t,v,m,g),c){for(const t in e)e[t].cx=0,e[t].cy=0,e[t].count=0;p.forEach((t=>{const{data:n}=t,r=e[n[h]];Vt(n.x)&&(r.cx+=n.x),Vt(n.y)&&(r.cy+=n.y),r.count++}));for(const t in e)e[t].cx/=e[t].count,e[t].cy/=e[t].count;const t=l||a;p.forEach(((n,r)=>{const{id:i,data:o}=n;if(!Vt(o.x)||!Vt(o.y))return;const a=e[o[h]],s=Math.sqrt((o.x-a.cx)*(o.x-a.cx)+(o.y-a.cy)*(o.y-a.cy)),u=m*t;v[i].x-=u*(o.x-a.cx)/s,v[i].y-=u*(o.y-a.cy)/s}))}p.forEach(((t,e)=>{const{id:n,data:i}=t;if(!Vt(i.x)||!Vt(i.y))return;const o=.01*m*a;v[n].x-=o*(i.x-s[0]),v[n].y-=o*(i.y-s[1]),3===r&&(v[n].z-=o*(i.z-s[2]))})),p.forEach(((e,n)=>{const{id:i,data:o}=e;if(Vt(o.fx)&&Vt(o.fy))return o.x=o.fx,o.y=o.fy,void(3===r&&(o.z=o.fz));if(!Vt(o.x)||!Vt(o.y))return;const a=Math.sqrt(v[i].x*v[i].x+v[i].y*v[i].y+(3===r?v[i].z*v[i].z:0));if(a>0){const e=Math.min(f*(u/800),a);t.mergeNodeData(i,{x:o.x+v[i].x/a*e,y:o.y+v[i].y/a*e,z:3===r?o.z+v[i].z/a*e:void 0})}}))}applyCalculate(t,e,n,r){this.calRepulsive(t,e,r),this.calAttractive(t,e,n)}calRepulsive(t,e,n){const r=t.getAllNodes();r.forEach((({data:t,id:i},o)=>{e[i]={x:0,y:0,z:0},r.forEach((({data:r,id:a},s)=>{if(o<=s||!Vt(t.x)||!Vt(r.x)||!Vt(t.y)||!Vt(r.y))return;let u=t.x-r.x,c=t.y-r.y,h=3===this.options.dimensions?t.z-r.z:0,l=u*u+c*c+h*h;0===l&&(l=1,u=.01,c=.01,h=.01);const d=n/l,f=u*d,p=c*d,g=h*d;e[i].x+=f,e[i].y+=p,e[a].x-=f,e[a].y-=p,3===this.options.dimensions&&(e[i].z+=g,e[a].z-=g)}))}))}calAttractive(t,e,n){t.getAllEdges().forEach((r=>{const{source:i,target:o}=r;if(!i||!o||i===o)return;const{data:a}=t.getNode(i),{data:s}=t.getNode(o);if(!(Vt(s.x)&&Vt(a.x)&&Vt(s.y)&&Vt(a.y)))return;const u=s.x-a.x,c=s.y-a.y,h=3===this.options.dimensions?s.z-a.z:0,l=Math.sqrt(u*u+c*c+h*h)/n,d=u*l,f=c*l,p=h*l;e[i].x+=d,e[i].y+=f,e[o].x-=d,e[o].y-=f,3===this.options.dimensions&&(e[i].z+=p,e[o].z-=p)}))}},grid:class{constructor(t={}){this.options=t,this.id="grid",this.options=Object.assign(Object.assign({},F_),t)}execute(t,e){return a(this,void 0,void 0,(function*(){return this.genericGridLayout(!1,t,e)}))}assign(t,e){return a(this,void 0,void 0,(function*(){this.genericGridLayout(!0,t,e)}))}genericGridLayout(t,e,n){return a(this,void 0,void 0,(function*(){const r=Object.assign(Object.assign({},this.options),n),{begin:i=[0,0],condense:o,preventOverlapPadding:a,preventOverlap:s,rows:u,cols:c,nodeSpacing:h,nodeSize:l,width:d,height:f,position:p}=r;let{sortBy:g}=r;const m=e.getAllNodes(),v=e.getAllEdges(),y=null==m?void 0:m.length;if(!y||1===y)return Qg(e,t,i);const b=m.map((t=>qg(t)));"id"===g||zt(g)&&void 0!==b[0].data[g]||(g="degree"),"degree"===g?b.sort(((t,n)=>e.getDegree(n.id,"both")-e.getDegree(t.id,"both"))):"id"===g?b.sort(((t,e)=>Vt(e.id)&&Vt(t.id)?e.id-t.id:`${t.id}`.localeCompare(`${e.id}`))):b.sort(((t,e)=>e.data[g]-t.data[g]));const E=d||"undefined"==typeof window?d:window.innerWidth,w=f||"undefined"==typeof window?f:window.innerHeight,x=y,M={rows:u,cols:c};if(null!=u&&null!=c)M.rows=u,M.cols=c;else if(null!=u&&null==c)M.rows=u,M.cols=Math.ceil(x/M.rows);else if(null==u&&null!=c)M.cols=c,M.rows=Math.ceil(x/M.cols);else{const t=Math.sqrt(x*w/E);M.rows=Math.round(t),M.cols=Math.round(E/w*t)}if(M.rows=Math.max(M.rows,1),M.cols=Math.max(M.cols,1),M.cols*M.rows>x){const t=B_(M),e=G_(M);(t-1)*e>=x?B_(M,t-1):(e-1)*t>=x&&G_(M,e-1)}else for(;M.cols*M.rows<x;){const t=B_(M),e=G_(M);(e+1)*t>=x?G_(M,e+1):B_(M,t+1)}let N=o?0:E/M.cols,S=o?0:w/M.rows;if(s||h){const t=Yg(10,h),n=$g(30,l,!1);b.forEach((r=>{r.data.x&&r.data.y||(r.data.x=0,r.data.y=0);const i=e.getNode(r.id),o=n(i)||30;let s,u;Bg(o)?(s=o[0],u=o[1]):(s=o,u=o);const c=void 0!==t?t(r):a,h=s+c,l=u+c;N=Math.max(N,h),S=Math.max(S,l)}))}const T={},k={row:0,col:0},P={};for(let t=0;t<b.length;t++){const n=b[t];let r;if(p&&(r=p(e.getNode(n.id))),r&&(void 0!==r.row||void 0!==r.col)){const t={row:r.row,col:r.col};if(void 0===t.col)for(t.col=0;V_(T,t);)t.col++;else if(void 0===t.row)for(t.row=0;V_(T,t);)t.row++;P[n.id]=t,U_(T,t)}H_(n,i,N,S,P,M,k,T)}const C={nodes:b,edges:v};return t&&b.forEach((t=>{e.mergeNodeData(t.id,{x:t.data.x,y:t.data.y})})),C}))}},indented:Gf.indented,mds:Tv,mindmap:Gf.mindmap,radial:class{constructor(t={}){this.options=t,this.id="radial",this.options=Object.assign(Object.assign({},X_),t)}execute(t,e){return a(this,void 0,void 0,(function*(){return this.genericRadialLayout(!1,t,e)}))}assign(t,e){return a(this,void 0,void 0,(function*(){this.genericRadialLayout(!0,t,e)}))}genericRadialLayout(t,e,n){return a(this,void 0,void 0,(function*(){const r=Object.assign(Object.assign({},this.options),n),{width:i,height:o,center:a,focusNode:s,unitRadius:u,nodeSize:c,nodeSpacing:h,strictRadial:l,preventOverlap:d,maxPreventOverlapIteration:f,sortBy:p,linkDistance:g=50,sortStrength:m=10,maxIteration:v=1e3}=r,y=e.getAllNodes(),b=e.getAllEdges(),E=i||"undefined"==typeof window?i:window.innerWidth,w=o||"undefined"==typeof window?o:window.innerHeight,x=a||[E/2,w/2];if(!(null==y?void 0:y.length)||1===y.length)return Qg(e,t,x);let M=y[0];if(zt(s)){for(let t=0;t<y.length;t++)if(y[t].id===s){M=y[t];break}}else M=s||y[0];const N=Q_(y,M.id),S=Vg({nodes:y,edges:b},!1),T=Gg(S),k=tD(T,N);J_(T,N,k+1);const P=T[N];let C=E-x[0]>x[0]?x[0]:E-x[0],A=w-x[1]>x[1]?x[1]:w-x[1];0===C&&(C=E/2),0===A&&(A=w/2);const O=Math.min(C,A),R=Math.max(...P),_=[],D=u||O/R;P.forEach(((t,e)=>{_[e]=t*D}));const I=K_(y,T,g,_,D,p,m),L=Z_(I),j=((t,e,n)=>{try{const n=Mv.mul(Mv.pow(e,2),-.5),r=n.mean("row"),i=n.mean("column"),o=n.mean();n.add(o).subRowVector(r).subColumnVector(i);const a=new Nv(n),s=Mv.sqrt(a.diagonalMatrix).diagonal();return a.leftSingularVectors.toJSON().map((e=>Mv.mul([e],[s]).toJSON()[0].splice(0,t)))}catch(t){const r=[];for(let t=0;t<e.length;t++){const t=Math.random()*n,e=Math.random()*n;r.push([t,e])}return r}})(g,I,g);let z,F=j.map((([t,e])=>({x:(isNaN(t)?Math.random()*g:t)-j[N][0],y:(isNaN(e)?Math.random()*g:e)-j[N][1]})));if(this.run(v,F,L,I,_,N),d){z=Xg(c,h);const t={nodes:y,nodeSizeFunc:z,positions:F,radii:_,height:w,width:E,strictRadial:Boolean(l),focusIdx:N,iterations:f||200,k:F.length/4.5};F=((t,e)=>{const n=Object.assign(Object.assign({},q_),e),{positions:r,iterations:i,width:o,k:a,speed:s=100,strictRadial:u,focusIdx:c,radii:h=[],nodeSizeFunc:l}=n,d=t.getAllNodes(),f=[],p=o/10;for(let t=0;t<i;t++)r.forEach(((t,e)=>{f[e]={x:0,y:0}})),Y_(d,r,f,a,h,l),$_(r,f,s,u,c,p,o,h);return r})(e,t)}const B=[];F.forEach(((t,e)=>{const n=qg(y[e]);n.data.x=t.x+x[0],n.data.y=t.y+x[1],B.push(n)})),t&&B.forEach((t=>e.mergeNodeData(t.id,{x:t.data.x,y:t.data.y})));return{nodes:B,edges:b}}))}run(t,e,n,r,i,o){for(let a=0;a<=t;a++){const s=a/t;this.oneIteration(s,e,i,r,n,o)}}oneIteration(t,e,n,r,i,o){const a=1-t;e.forEach(((s,u)=>{const c=Ug(s,{x:0,y:0}),h=0===c?0:1/c;if(u===o)return;let l=0,d=0,f=0;e.forEach(((t,e)=>{if(u===e)return;const n=Ug(s,t),o=0===n?0:1/n,a=r[e][u];f+=i[u][e],l+=i[u][e]*(t.x+a*(s.x-t.x)*o),d+=i[u][e]*(t.y+a*(s.y-t.y)*o)}));const p=0===n[u]?0:1/n[u];f*=a,f+=t*p*p,l*=a,l+=t*p*s.x*h,s.x=l/f,d*=a,d+=t*p*s.y*h,s.y=d/f}))}},random:class{constructor(t={}){this.options=t,this.id="random",this.options=Object.assign(Object.assign({},eD),t)}execute(t,e){return a(this,void 0,void 0,(function*(){return this.genericRandomLayout(!1,t,e)}))}assign(t,e){return a(this,void 0,void 0,(function*(){this.genericRandomLayout(!0,t,e)}))}genericRandomLayout(t,e,n){return a(this,void 0,void 0,(function*(){const r=Object.assign(Object.assign({},this.options),n),{center:i,width:o,height:a}=r,s=e.getAllNodes(),u=o||"undefined"==typeof window?o:window.innerWidth,c=a||"undefined"==typeof window?a:window.innerHeight,h=i||[u/2,c/2],l=[];s&&s.forEach((t=>{l.push({id:t.id,data:{x:.9*(Math.random()-.5)*u+h[0],y:.9*(Math.random()-.5)*c+h[1]}})})),t&&l.forEach((t=>e.mergeNodeData(t.id,{x:t.data.x,y:t.data.y})));return{nodes:l,edges:e.getAllEdges()}}))}}},node:{circle:wh,ellipse:Mh,image:class t extends bh{static defaultStyleProps={size:50};constructor(e){super(ee({},{style:t.defaultStyleProps},e))}getKeyStyle(t){const[e,n]=this.getSize(t);return{...super.getKeyStyle(t),width:e,height:n,anchor:[.5,.5]}}getHaloStyle(t){if(!1===t.halo)return!1;const{fill:e,stroke:n,...r}=this.getKeyStyle(t),i=zc(this.getGraphicStyle(t),"halo"),o=Number(i.lineWidth),[a,s]=Vc(this.getSize(t),[o,o]);return{...r,...i,width:a,height:s,fill:"transparent"}}getIconStyle(t){const e=super.getIconStyle(t),[n,r]=this.getSize(t);return!!e&&{width:n*Eh,height:r*Eh,...e}}drawKeyShape(t,e){return this.upsert("key",As,this.getKeyStyle(t),e)}drawHaloShape(t,e){this.upsert("halo",Is,this.getHaloStyle(t),e)}},rect:Nh,star:class extends xh{constructor(t){super(t)}getInnerR(t){return t.innerR||3*this.getOuterR(t)/8}getOuterR(t){return Math.min(...this.getSize(t))/2}getPoints(t){return e=this.getOuterR(t),n=this.getInnerR(t),[[0,-e],[n*Math.cos(3*Math.PI/10),-n*Math.sin(3*Math.PI/10)],[e*Math.cos(Math.PI/10),-e*Math.sin(Math.PI/10)],[n*Math.cos(Math.PI/10),n*Math.sin(Math.PI/10)],[e*Math.cos(3*Math.PI/10),e*Math.sin(3*Math.PI/10)],[0,n],[-e*Math.cos(3*Math.PI/10),e*Math.sin(3*Math.PI/10)],[-n*Math.cos(Math.PI/10),n*Math.sin(Math.PI/10)],[-e*Math.cos(Math.PI/10),-e*Math.sin(Math.PI/10)],[-n*Math.cos(3*Math.PI/10),-n*Math.sin(3*Math.PI/10)]];var e,n}getIconStyle(t){const e=super.getIconStyle(t),n=2*this.getInnerR(t)*Eh;return!!e&&{width:n,height:n,...e}}getPortXY(t,e){const{placement:n="top"}=e;return al(this.getKey().getLocalBounds(),n,function(t,e){const n={};return n.top=[0,-t],n.left=[-t*Math.cos(Math.PI/10),-t*Math.sin(Math.PI/10)],n["left-bottom"]=[-t*Math.cos(3*Math.PI/10),t*Math.sin(3*Math.PI/10)],n.bottom=[0,e],n["right-bottom"]=[t*Math.cos(3*Math.PI/10),t*Math.sin(3*Math.PI/10)],n.right=n.default=[t*Math.cos(Math.PI/10),-t*Math.sin(Math.PI/10)],n}(this.getOuterR(t),this.getInnerR(t)),!1)}},triangle:Sh,diamond:class extends xh{constructor(t){super(t)}getPoints(t){const[e,n]=this.getSize(t);return function(t,e){return[[0,-e/2],[t/2,0],[0,e/2],[-t/2,0]]}(e,n)}getIntersectPoint(t){const{points:e}=this.getKeyStyle(this.attributes);return ih(t,[this.attributes.x,this.attributes.y],e)}}},palette:{spectral:["rgb(158, 1, 66)","rgb(213, 62, 79)","rgb(244, 109, 67)","rgb(253, 174, 97)","rgb(254, 224, 139)","rgb(255, 255, 191)","rgb(230, 245, 152)","rgb(171, 221, 164)","rgb(102, 194, 165)","rgb(50, 136, 189)","rgb(94, 79, 162)"],oranges:["rgb(255, 245, 235)","rgb(254, 230, 206)","rgb(253, 208, 162)","rgb(253, 174, 107)","rgb(253, 141, 60)","rgb(241, 105, 19)","rgb(217, 72, 1)","rgb(166, 54, 3)","rgb(127, 39, 4)"],greens:["rgb(247, 252, 245)","rgb(229, 245, 224)","rgb(199, 233, 192)","rgb(161, 217, 155)","rgb(116, 196, 118)","rgb(65, 171, 93)","rgb(35, 139, 69)","rgb(0, 109, 44)","rgb(0, 68, 27)"],blues:["rgb(247, 251, 255)","rgb(222, 235, 247)","rgb(198, 219, 239)","rgb(158, 202, 225)","rgb(107, 174, 214)","rgb(66, 146, 198)","rgb(33, 113, 181)","rgb(8, 81, 156)","rgb(8, 48, 107)"]},theme:{dark:nI,light:rI},plugin:{"grid-line":DD,watermark:ZD,tooltip:$D,contextmenu:_D}},oI={animation:{},behavior:{},combo:{},edge:{},layout:{},node:{},palette:{},theme:{},plugin:{}};function aI(t,e,n){oI[t][e]?console.error(`The extension ${e} of ${t} has been registered before.`):Object.assign(oI[t],{[e]:n})}function sI(t,e){const n=oI[t]?.[e];if(n)return n}function uI(t,e,n,r,i=0){"TB"===r&&e(t,i);const o=n(t);if(o)for(const t of o)uI(t,e,n,r,i+1);"BT"===r&&e(t,i)}us.enableCSSParsing=!1,Object.entries(iI).forEach((([t,e])=>{Object.entries(e).forEach((([e,n])=>{aI(t,e,n)}))}));class cI{type;constructor(t){this.type=t}}class hI extends cI{data;constructor(t,e){super(t),this.data=e}}class lI extends cI{animationType;animation;data;constructor(t,e,n,r){super(t),this.animationType=e,this.animation=n,this.data=r}}class dI extends cI{data;constructor(t,e){super(t),this.data=e}}class fI extends cI{states;constructor(t,e){super(t),this.states=e}}function pI(t,e){t.emit(e.type,e)}function gI(t,e){const{datum:n,index:r,elementData:i}=e;return kt(t)?t(n,r,i):Object.fromEntries(Object.entries(t).map((([t,e])=>kt(e)?[t,e(n,r,i)]:[t,e])))}function mI(t){return t.style?.zIndex??bl("zIndex")??0}class vI extends Nl{currentTarget=null;category="behavior";constructor(t){super(t),this.forwardEvents(),this.setBehaviors(this.context.options.behaviors||[])}setBehaviors(t){this.setExtensions(t)}forwardEvents(){const e=this.context.canvas.getContainer();e&&[t.ContainerEvent.KEY_DOWN,t.ContainerEvent.KEY_UP].forEach((t=>{e.addEventListener(t,this.forwardContainerEvents.bind(this))}));const n=this.context.canvas.document;n&&[t.CanvasEvent.CLICK,t.CanvasEvent.DBLCLICK,t.CanvasEvent.POINTER_OVER,t.CanvasEvent.POINTER_LEAVE,t.CanvasEvent.POINTER_ENTER,t.CanvasEvent.POINTER_MOVE,t.CanvasEvent.POINTER_OUT,t.CanvasEvent.POINTER_DOWN,t.CanvasEvent.POINTER_UP,t.CanvasEvent.CONTEXT_MENU,t.CanvasEvent.DRAG_START,t.CanvasEvent.DRAG,t.CanvasEvent.DRAG_END,t.CanvasEvent.DRAG_ENTER,t.CanvasEvent.DRAG_OVER,t.CanvasEvent.DRAG_LEAVE,t.CanvasEvent.DROP,t.CanvasEvent.WHEEL].forEach((t=>{n.addEventListener(t,this.forwardCanvasEvents)}))}forwardCanvasEvents=e=>{const n=function(t){if(!t)return null;if(t instanceof zs)return{type:"canvas",element:t};let e=t;for(;e;){if(nl(e))return{type:"node",element:e};if(rl(e))return{type:"edge",element:e};if(il(e))return{type:"combo",element:e};e=e.parentElement}return null}(e.target);if(!n)return;const{graph:r,canvas:i}=this.context,{type:o,element:a}=n,{type:s,detail:u,button:c}=e,h={...e,target:a,targetType:o};if(s===t.CanvasEvent.POINTER_MOVE&&(this.currentTarget!==a&&(this.currentTarget&&r.emit(`${o}:${t.CanvasEvent.POINTER_LEAVE}`,{...h,target:this.currentTarget}),a&&r.emit(`${o}:${t.CanvasEvent.POINTER_ENTER}`,h)),this.currentTarget=a),s===t.CanvasEvent.CLICK&&2===c||(r.emit(`${o}:${s}`,h),r.emit(s,h)),s===t.CanvasEvent.CLICK&&2===u&&(r.emit(`${o}:${t.CanvasEvent.DBLCLICK}`,h),r.emit(t.CanvasEvent.DBLCLICK,h)),s===t.CanvasEvent.POINTER_DOWN&&2===c){const e={...h,preventDefault:()=>{i.getContainer()?.addEventListener(t.CanvasEvent.CONTEXT_MENU,(t=>t.preventDefault()),{once:!0})}};r.emit(`${o}:${t.CanvasEvent.CONTEXT_MENU}`,e),r.emit(t.CanvasEvent.CONTEXT_MENU,e)}};forwardContainerEvents(t){this.context.graph.emit(t.type,t)}}function yI(t,e){var n=e.r;t.arc(n,n,n,0,2*Math.PI,!1)}function bI(t,e){var n=e.rx,r=e.ry;if(t.ellipse)t.ellipse(n,r,n,r,0,0,2*Math.PI,!1);else{var i=n>r?n:r,o=n>r?1:n/r,a=n>r?r/n:1;t.save(),t.scale(o,a),t.arc(i,i,i,0,2*Math.PI)}}function EI(t,e){var n,r,i=e.x1,o=e.y1,a=e.x2,s=e.y2,u=e.defX,c=void 0===u?0:u,h=e.defY,l=void 0===h?0:h,d=e.markerStart,f=e.markerEnd,p=e.markerStartOffset,g=e.markerEndOffset,m=0,v=0,y=0,b=0,E=0;d&&ms(d)&&p&&(n=a-i,r=s-o,E=Math.atan2(r,n),m=Math.cos(E)*(p||0),v=Math.sin(E)*(p||0)),f&&ms(f)&&g&&(n=i-a,r=o-s,E=Math.atan2(r,n),y=Math.cos(E)*(g||0),b=Math.sin(E)*(g||0)),t.moveTo(i-c+m,o-l+v),t.lineTo(a-c+y,s-l+b)}function wI(t,e){var n,r,i=e.defX,o=void 0===i?0:i,a=e.defY,s=void 0===a?0:a,u=e.markerStart,h=e.markerEnd,l=e.markerStartOffset,d=e.markerEndOffset,f=e.path,p=f.absolutePath,g=f.segments,m=0,v=0,y=0,b=0,E=0;if(u&&ms(u)&&l){var w=c(u.parentNode.getStartTangent(),2),x=w[0],M=w[1];n=x[0]-M[0],r=x[1]-M[1],E=Math.atan2(r,n),m=Math.cos(E)*(l||0),v=Math.sin(E)*(l||0)}if(h&&ms(h)&&d){var N=c(h.parentNode.getEndTangent(),2);x=N[0],M=N[1];n=x[0]-M[0],r=x[1]-M[1],E=Math.atan2(r,n),y=Math.cos(E)*(d||0),b=Math.sin(E)*(d||0)}for(var S=0;S<p.length;S++){var T=p[S],k=T[0],P=p[S+1],C=0===S&&(0!==m||0!==v),A=(S===p.length-1||P&&("M"===P[0]||"Z"===P[0]))&&0!==y&&0!==b;switch(k){case"M":C?(t.moveTo(T[1]-o+m,T[2]-s+v),t.lineTo(T[1]-o,T[2]-s)):t.moveTo(T[1]-o,T[2]-s);break;case"L":A?t.lineTo(T[1]-o+y,T[2]-s+b):t.lineTo(T[1]-o,T[2]-s);break;case"Q":t.quadraticCurveTo(T[1]-o,T[2]-s,T[3]-o,T[4]-s),A&&t.lineTo(T[3]-o+y,T[4]-s+b);break;case"C":t.bezierCurveTo(T[1]-o,T[2]-s,T[3]-o,T[4]-s,T[5]-o,T[6]-s),A&&t.lineTo(T[5]-o+y,T[6]-s+b);break;case"A":var O=g[S].arcParams,R=O.cx,_=O.cy,D=O.rx,I=O.ry,L=O.startAngle,j=O.endAngle,z=O.xRotation,F=O.sweepFlag;if(t.ellipse)t.ellipse(R-o,_-s,D,I,z,L,j,!!(1-F));else{var B=D>I?D:I,G=D>I?1:D/I,V=D>I?I/D:1;t.translate(R-o,_-s),t.rotate(z),t.scale(G,V),t.arc(0,0,B,L,j,!!(1-F)),t.scale(1/G,1/V),t.rotate(-z),t.translate(-(R-o),-(_-s))}A&&t.lineTo(T[6]-o+y,T[7]-s+b);break;case"Z":t.closePath()}}}function xI(t,e){var n,r,i=e.defX,o=void 0===i?0:i,a=e.defY,s=void 0===a?0:a,u=e.markerStart,c=e.markerEnd,h=e.markerStartOffset,l=e.markerEndOffset,d=e.points.points,f=d.length,p=d[0][0]-o,g=d[0][1]-s,m=d[f-1][0]-o,v=d[f-1][1]-s,y=0,b=0,E=0,w=0,x=0;u&&ms(u)&&h&&(n=d[1][0]-d[0][0],r=d[1][1]-d[0][1],x=Math.atan2(r,n),y=Math.cos(x)*(h||0),b=Math.sin(x)*(h||0)),c&&ms(c)&&l&&(n=d[f-1][0]-d[0][0],r=d[f-1][1]-d[0][1],x=Math.atan2(r,n),E=Math.cos(x)*(l||0),w=Math.sin(x)*(l||0)),t.moveTo(p+(y||E),g+(b||w));for(var M=1;M<f-1;M++){var N=d[M];t.lineTo(N[0]-o,N[1]-s)}t.lineTo(m,v)}function MI(t,e){var n,r,i=e.defX,o=void 0===i?0:i,a=e.defY,s=void 0===a?0:a,u=e.markerStart,c=e.markerEnd,h=e.markerStartOffset,l=e.markerEndOffset,d=e.points.points,f=d.length,p=d[0][0]-o,g=d[0][1]-s,m=d[f-1][0]-o,v=d[f-1][1]-s,y=0,b=0,E=0,w=0,x=0;u&&ms(u)&&h&&(n=d[1][0]-d[0][0],r=d[1][1]-d[0][1],x=Math.atan2(r,n),y=Math.cos(x)*(h||0),b=Math.sin(x)*(h||0)),c&&ms(c)&&l&&(n=d[f-2][0]-d[f-1][0],r=d[f-2][1]-d[f-1][1],x=Math.atan2(r,n),E=Math.cos(x)*(l||0),w=Math.sin(x)*(l||0)),t.moveTo(p+y,g+b);for(var M=1;M<f-1;M++){var N=d[M];t.lineTo(N[0]-o,N[1]-s)}t.lineTo(m+E,v+w)}function NI(t,e){var n=e.radius,r=e.width,i=e.height,o=r,a=i;if(n&&n.some((function(t){return 0!==t}))){var s=r>0?1:-1,u=i>0?1:-1,h=s+u===0,l=c(n.map((function(t){return Gt(t,0,Math.min(Math.abs(o)/2,Math.abs(a)/2))})),4),d=l[0],f=l[1],p=l[2],g=l[3];t.moveTo(s*d,0),t.lineTo(o-s*f,0),0!==f&&t.arc(o-s*f,u*f,f,-u*Math.PI/2,s>0?0:Math.PI,h),t.lineTo(o,a-u*p),0!==p&&t.arc(o-s*p,a-u*p,p,s>0?0:Math.PI,u>0?Math.PI/2:1.5*Math.PI,h),t.lineTo(s*g,a),0!==g&&t.arc(s*g,a-u*g,g,u>0?Math.PI/2:-Math.PI/2,s>0?Math.PI:0,h),t.lineTo(0,u*d),0!==d&&t.arc(s*d,u*d,d,s>0?Math.PI:0,u>0?1.5*Math.PI:Math.PI/2,h)}else t.rect(0,0,o,a)}var SI=function(t){function e(){var e=t.apply(this,h([],c(arguments),!1))||this;return e.name="canvas-path-generator",e}return r(e,t),e.prototype.init=function(){var t,e=((t={})[Un.CIRCLE]=yI,t[Un.ELLIPSE]=bI,t[Un.RECT]=NI,t[Un.LINE]=EI,t[Un.POLYLINE]=MI,t[Un.POLYGON]=xI,t[Un.PATH]=wI,t[Un.TEXT]=void 0,t[Un.GROUP]=void 0,t[Un.IMAGE]=void 0,t[Un.HTML]=void 0,t[Un.MESH]=void 0,t);this.context.pathGeneratorFactory=e},e.prototype.destroy=function(){delete this.context.pathGeneratorFactory},e}(qn),TI=K(),kI=K(),PI=K(),CI=b(),AI=function(){function t(){var t=this;this.isHit=function(e,n,r,i){var o=t.context.pointInPathPickerFactory[e.nodeName];if(o){var a=S(CI,r),s=ct(kI,et(PI,n[0],n[1],0),a),u=e.getGeometryBounds().halfExtents,c=e.parsedStyle.anchor;if(s[0]+=(c&&c[0]||0)*u[0]*2,s[1]+=(c&&c[1]||0)*u[1]*2,o(e,new yr(s[0],s[1]),i,t.isPointInPath,t.context,t.runtime))return!0}return!1},this.isPointInPath=function(e,n){var r=t.runtime.offscreenCanvasCreator.getOrCreateContext(t.context.config.offscreenCanvas),i=t.context.pathGeneratorFactory[e.nodeName];return i&&(r.beginPath(),i(r,e.parsedStyle),r.closePath()),r.isPointInPath(n.x,n.y)}}return t.prototype.apply=function(e,n){var r,i=this,o=e.renderingService,u=e.renderingContext;this.context=e,this.runtime=n;var c=null===(r=u.root)||void 0===r?void 0:r.ownerDocument;o.hooks.pick.tapPromise(t.tag,(function(t){return a(i,void 0,void 0,(function(){return s(this,(function(e){return[2,this.pick(c,t)]}))}))})),o.hooks.pickSync.tap(t.tag,(function(t){return i.pick(c,t)}))},t.prototype.pick=function(t,e){var n,r,i=e.topmost,o=e.position,a=o.x,s=o.y,c=et(TI,a,s,0),h=t.elementsFromBBox(c[0],c[1],c[0],c[1]),l=[];try{for(var d=u(h),f=d.next();!f.done;f=d.next()){var p=f.value,g=p.getWorldTransform();if(this.isHit(p,c,g,!1)){var m=ia(p);if(m){var v=m.parsedStyle.clipPath;if(this.isHit(v,c,v.getWorldTransform(),!0)){if(i)return e.picked=[p],e;l.push(p)}}else{if(i)return e.picked=[p],e;l.push(p)}}}}catch(t){n={error:t}}finally{try{f&&!f.done&&(r=d.return)&&r.call(d)}finally{if(n)throw n.error}}return e.picked=l,e},t.tag="CanvasPicker",t}();function OI(t,e,n){var r=t.parsedStyle,i=r.r,o=r.fill,a=r.stroke,s=r.lineWidth,u=r.increasedLineWidthForHitTesting,h=r.pointerEvents,l=((s||0)+(u||0))/2,d=Mn(i,i,e.x,e.y),f=c(ua(h,o,a),2),p=f[0],g=f[1];return p&&g||n?d<=i+l:p?d<=i:!!g&&(d>=i-l&&d<=i+l)}function RI(t,e,n,r){return t/(n*n)+e/(r*r)}function _I(t,e,n){var r=t.parsedStyle,i=r.rx,o=r.ry,a=r.fill,s=r.stroke,u=r.lineWidth,h=r.increasedLineWidthForHitTesting,l=r.pointerEvents,d=e.x,f=e.y,p=c(ua(l,a,s),2),g=p[0],m=p[1],v=((u||0)+(h||0))/2,y=(d-i)*(d-i),b=(f-o)*(f-o);return g&&m||n?RI(y,b,i+v,o+v)<=1:g?RI(y,b,i,o)<=1:!!m&&(RI(y,b,i-v,o-v)>=1&&RI(y,b,i+v,o+v)<=1)}function DI(t,e,n,r,i,o){return i>=t&&i<=t+n&&o>=e&&o<=e+r}function II(t,e,n,r,i,o,a,s){var u=(Math.atan2(s-e,a-t)+2*Math.PI)%(2*Math.PI),c={x:t+n*Math.cos(u),y:e+n*Math.sin(u)};return Mn(c.x,c.y,a,s)<=o/2}function LI(t,e,n,r,i,o,a){var s=Math.min(t,n),u=Math.max(t,n),c=Math.min(e,r),h=Math.max(e,r),l=i/2;return o>=s-l&&o<=u+l&&a>=c-l&&a<=h+l&&Rn(t,e,n,r,o,a)<=i/2}function jI(t,e,n,r,i){var o=t.length;if(o<2)return!1;for(var a=0;a<o-1;a++){if(LI(t[a][0],t[a][1],t[a+1][0],t[a+1][1],e,n,r))return!0}if(i){var s=t[0],u=t[o-1];if(LI(s[0],s[1],u[0],u[1],e,n,r))return!0}return!1}var zI=1e-6;function FI(t){return Math.abs(t)<zI?0:t<0?-1:1}function BI(t,e,n){return(n[0]-t[0])*(e[1]-t[1])==(e[0]-t[0])*(n[1]-t[1])&&Math.min(t[0],e[0])<=n[0]&&n[0]<=Math.max(t[0],e[0])&&Math.min(t[1],e[1])<=n[1]&&n[1]<=Math.max(t[1],e[1])}function GI(t,e,n){var r=!1,i=t.length;if(i<=2)return!1;for(var o=0;o<i;o++){var a=t[o],s=t[(o+1)%i];if(BI(a,s,[e,n]))return!0;FI(a[1]-n)>0!=FI(s[1]-n)>0&&FI(e-(n-a[1])*(a[0]-s[0])/(a[1]-s[1])-a[0])<0&&(r=!r)}return r}function VI(t,e,n){for(var r=!1,i=0;i<t.length;i++){if(r=GI(t[i],e,n))break}return r}function UI(t,e,n){var r=t.parsedStyle,i=r.x1,o=r.y1,a=r.x2,s=r.y2,u=r.lineWidth,h=r.increasedLineWidthForHitTesting,l=r.defX,d=void 0===l?0:l,f=r.defY,p=void 0===f?0:f;return!(!c(ua(r.pointerEvents,r.fill,r.stroke),2)[1]&&!n||!u)&&LI(i,o,a,s,(u||0)+(h||0),e.x+d,e.y+p)}function WI(t,e,n,r,i,o){var a=t.parsedStyle,s=a.lineWidth,u=a.increasedLineWidthForHitTesting,h=a.stroke,l=a.fill,d=a.defX,f=void 0===d?0:d,p=a.defY,g=void 0===p?0:p,m=a.path,v=a.pointerEvents,y=m.segments,b=m.hasArc,E=m.polylines,w=m.polygons,x=c(ua(v,(null==w?void 0:w.length)&&l,h),2),M=x[0],N=x[1],S=qi(t),T=!1;return M||n?T=b?r(t,e):VI(w,e.x+f,e.y+g)||VI(E,e.x+f,e.y+g):((N||n)&&(T=function(t,e,n,r,i){for(var o=!1,a=e/2,s=0;s<t.length;s++){var u=t[s],c=u.currentPoint,h=u.params,l=u.prePoint,d=u.box;if(!d||DI(d.x-a,d.y-a,d.width+e,d.height+e,n,r))switch(u.command){case"L":case"Z":if(o=LI(l[0],l[1],c[0],c[1],e,n,r))return!0;break;case"Q":if(o=Gn(l[0],l[1],h[1],h[2],h[3],h[4],n,r)<=e/2)return!0;break;case"C":if(o=Ln(l[0],l[1],h[1],h[2],h[3],h[4],h[5],h[6],n,r,i)<=e/2)return!0;break;case"A":u.cubicParams||(u.cubicParams=ke(l[0],l[1],h[1],h[2],h[3],h[4],h[5],h[6],h[7],void 0));for(var f=u.cubicParams,p=l,g=0;g<f.length;g+=6){var m=Ln(p[0],p[1],f[g],f[g+1],f[g+2],f[g+3],f[g+4],f[g+5],n,r,i);if(p=[f[g+4],f[g+5]],o=m<=e/2)return!0}}}return o}(y,(s||0)+(u||0),e.x+f,e.y+g,S)),T)}function HI(t,e,n){var r=t.parsedStyle,i=r.stroke,o=r.fill,a=r.lineWidth,s=r.increasedLineWidthForHitTesting,u=r.points,h=r.defX,l=void 0===h?0:h,d=r.defY,f=void 0===d?0:d,p=c(ua(r.pointerEvents,o,i),2),g=p[0],m=!1;return(p[1]||n)&&(m=jI(u.points,(a||0)+(s||0),e.x+l,e.y+f,!0)),m||!g&&!n||(m=GI(u.points,e.x+l,e.y+f)),m}function qI(t,e,n){var r=t.parsedStyle,i=r.lineWidth,o=r.increasedLineWidthForHitTesting,a=r.points,s=r.defX,u=void 0===s?0:s,h=r.defY,l=void 0===h?0:h;return!(!c(ua(r.pointerEvents,r.fill,r.stroke),2)[1]&&!n||!i)&&jI(a.points,(i||0)+(o||0),e.x+u,e.y+l,!1)}function YI(t,e,n,r,i){var o=t.parsedStyle,a=o.radius,s=o.fill,u=o.stroke,h=o.lineWidth,l=o.increasedLineWidthForHitTesting,d=o.width,f=o.height,p=c(ua(o.pointerEvents,s,u),2),g=p[0],m=p[1],v=(h||0)+(l||0);if(a&&a.some((function(t){return 0!==t}))){var y=!1;return(m||n)&&(y=function(t,e,n,r,i,o,a,s){var u=c(i,4),h=u[0],l=u[1],d=u[2],f=u[3];return LI(t+h,e,t+n-l,e,o,a,s)||LI(t+n,e+l,t+n,e+r-d,o,a,s)||LI(t+n-d,e+r,t+f,e+r,o,a,s)||LI(t,e+r-f,t,e+h,o,a,s)||II(t+n-l,e+l,l,Math.PI,Math.PI,o,a,s)||II(t+n-d,e+r-d,d,0,Math.PI,o,a,s)||II(t+f,e+r-f,f,Math.PI,Math.PI,o,a,s)||II(t+h,e+h,h,Math.PI,Math.PI,o,a,s)}(0,0,d,f,a.map((function(t){return Gt(t,0,Math.min(Math.abs(d)/2,Math.abs(f)/2))})),v,e.x,e.y)),y||!g&&!n||(y=r(t,e)),y}var b=v/2;return g&&m||n?DI(0-b,0-b,d+b,f+b,e.x,e.y):g?DI(0,0,d,f,e.x,e.y):!!m&&function(t,e,n,r,i,o,a){var s=i/2;return DI(t-s,e-s,n,i,o,a)||DI(t+n-s,e-s,i,r,o,a)||DI(t+s,e+r-s,n,i,o,a)||DI(t-s,e+s,i,r,o,a)}(0,0,d,f,v,e.x,e.y)}function $I(t,e,n,r,i,o){var a=t.parsedStyle,s=a.pointerEvents,u=a.width,c=a.height;if("non-transparent-pixel"===s){var h=i.config.offscreenCanvas,l=o.offscreenCanvasCreator.getOrCreateCanvas(h),d=o.offscreenCanvasCreator.getOrCreateContext(h,{willReadFrequently:!0});return l.width=u,l.height=c,i.defaultStyleRendererFactory[Un.IMAGE].render(d,t.parsedStyle,t,void 0,void 0,void 0),d.getImageData(e.x,e.y,1,1).data.every((function(t){return 0!==t}))}return!0}var XI=function(t){function e(){var e=t.apply(this,h([],c(arguments),!1))||this;return e.name="canvas-picker",e}return r(e,t),e.prototype.init=function(){var t,e=((t={})[Un.CIRCLE]=OI,t[Un.ELLIPSE]=_I,t[Un.RECT]=YI,t[Un.LINE]=UI,t[Un.POLYLINE]=qI,t[Un.POLYGON]=HI,t[Un.PATH]=WI,t[Un.TEXT]=function(){return!0},t[Un.GROUP]=null,t[Un.IMAGE]=$I,t[Un.HTML]=null,t[Un.MESH]=null,t);this.context.pointInPathPickerFactory=e,this.addRenderingPlugin(new AI)},e.prototype.destroy=function(){delete this.context.pointInPathPickerFactory,this.removeAllRenderingPlugins()},e}(qn),KI=function(){function t(t){this.canvasRendererPluginOptions=t,this.removedRBushNodeAABBs=[],this.renderQueue=[],this.restoreStack=[],this.clearFullScreen=!1,this.vpMatrix=b(),this.dprMatrix=b(),this.tmpMat4=b(),this.vec3a=K(),this.vec3b=K(),this.vec3c=K(),this.vec3d=K()}return t.prototype.apply=function(e,n){var r=this;this.context=e;var i=e.config,o=e.camera,a=e.renderingService,s=e.renderingContext,u=e.rBushRoot,l=e.pathGeneratorFactory;this.rBush=u,this.pathGeneratorFactory=l;var d=e.contextService,f=s.root.ownerDocument.defaultView,p=function(t){var e=t.target.rBushNode;e.aabb&&r.removedRBushNodeAABBs.push(e.aabb)},g=function(t){var e=t.target.rBushNode;e.aabb&&r.removedRBushNodeAABBs.push(e.aabb)};a.hooks.init.tap(t.tag,(function(){f.addEventListener(qa.UNMOUNTED,p),f.addEventListener(qa.CULLED,g);var t=d.getDPR(),e=i.width,n=i.height,o=d.getContext();r.clearRect(o,0,0,e*t,n*t,i.background)})),a.hooks.destroy.tap(t.tag,(function(){f.removeEventListener(qa.UNMOUNTED,p),f.removeEventListener(qa.CULLED,g),r.renderQueue=[],r.removedRBushNodeAABBs=[],r.restoreStack=[]})),a.hooks.beginFrame.tap(t.tag,(function(){var t=d.getContext(),e=d.getDPR(),n=i.width,o=i.height,s=r.canvasRendererPluginOptions,u=s.dirtyObjectNumThreshold,c=s.dirtyObjectRatioThreshold,h=a.getStats(),l=h.total,f=h.rendered,p=f/l;r.clearFullScreen=a.disableDirtyRectangleRendering()||f>u&&p>c,t&&(t.resetTransform?t.resetTransform():t.setTransform(1,0,0,1,0,0),r.clearFullScreen&&r.clearRect(t,0,0,n*e,o*e,i.background))}));var m=function(t,e){t.isVisible()&&!t.isCulled()&&(r.renderDisplayObject(t,e,r.context,r.restoreStack,n),r.saveDirtyAABB(t)),(t.sortable.sorted||t.childNodes).forEach((function(t){m(t,e)}))};a.hooks.endFrame.tap(t.tag,(function(){var t=d.getContext(),e=d.getDPR();if(_(r.dprMatrix,[e,e,1]),k(r.vpMatrix,r.dprMatrix,o.getOrthoMatrix()),r.clearFullScreen)m(s.root,t);else{var a=r.safeMergeAABB.apply(r,h([r.mergeDirtyAABBs(r.renderQueue)],c(r.removedRBushNodeAABBs.map((function(t){var e=t.minX,n=t.minY,r=t.maxX,i=t.maxY,o=new dr;return o.setMinMax([e,n,0],[r,i,0]),o}))),!1));if(r.removedRBushNodeAABBs=[],dr.isEmpty(a))return void(r.renderQueue=[]);var u=r.convertAABB2Rect(a),l=u.x,p=u.y,g=u.width,v=u.height,y=ct(r.vec3a,[l,p,0],r.vpMatrix),b=ct(r.vec3b,[l+g,p,0],r.vpMatrix),E=ct(r.vec3c,[l,p+v,0],r.vpMatrix),w=ct(r.vec3d,[l+g,p+v,0],r.vpMatrix),x=Math.min(y[0],b[0],w[0],E[0]),M=Math.min(y[1],b[1],w[1],E[1]),N=Math.max(y[0],b[0],w[0],E[0]),S=Math.max(y[1],b[1],w[1],E[1]),T=Math.floor(x),P=Math.floor(M),C=Math.ceil(N-x),A=Math.ceil(S-M);t.save(),r.clearRect(t,T,P,C,A,i.background),t.beginPath(),t.rect(T,P,C,A),t.clip(),t.setTransform(r.vpMatrix[0],r.vpMatrix[1],r.vpMatrix[4],r.vpMatrix[5],r.vpMatrix[12],r.vpMatrix[13]),i.renderer.getConfig().enableDirtyRectangleRenderingDebug&&f.dispatchEvent(new Ga(vs.DIRTY_RECTANGLE,{dirtyRect:{x:T,y:P,width:C,height:A}})),r.searchDirtyObjects(a).sort((function(t,e){return t.sortable.renderOrder-e.sortable.renderOrder})).forEach((function(e){e&&e.isVisible()&&!e.isCulled()&&r.renderDisplayObject(e,t,r.context,r.restoreStack,n)})),t.restore(),r.renderQueue.forEach((function(t){r.saveDirtyAABB(t)})),r.renderQueue=[]}r.restoreStack.forEach((function(){t.restore()})),r.restoreStack=[]})),a.hooks.render.tap(t.tag,(function(t){r.clearFullScreen||r.renderQueue.push(t)}))},t.prototype.clearRect=function(t,e,n,r,i,o){t.clearRect(e,n,r,i),o&&(t.fillStyle=o,t.fillRect(e,n,r,i))},t.prototype.renderDisplayObject=function(t,e,n,r,i){var o=t.nodeName,a=r[r.length-1];!a||t.compareDocumentPosition(a)&Ua.DOCUMENT_POSITION_CONTAINS||(e.restore(),r.pop());var s=this.context.styleRendererFactory[o],u=this.pathGeneratorFactory[o],c=t.parsedStyle.clipPath;if(c){this.applyWorldTransform(e,c);var h=this.pathGeneratorFactory[c.nodeName];h&&(e.save(),r.push(t),e.beginPath(),h(e,c.parsedStyle),e.closePath(),e.clip())}s&&(this.applyWorldTransform(e,t),e.save(),this.applyAttributesToContext(e,t)),u&&(e.beginPath(),u(e,t.parsedStyle),t.nodeName!==Un.LINE&&t.nodeName!==Un.PATH&&t.nodeName!==Un.POLYLINE&&e.closePath()),s&&(s.render(e,t.parsedStyle,t,n,this,i),e.restore()),t.renderable.dirty=!1},t.prototype.convertAABB2Rect=function(t){var e=t.getMin(),n=t.getMax(),r=Math.floor(e[0]),i=Math.floor(e[1]);return{x:r,y:i,width:Math.ceil(n[0])-r,height:Math.ceil(n[1])-i}},t.prototype.mergeDirtyAABBs=function(t){var e=new dr;return t.forEach((function(t){var n=t.getRenderBounds();e.add(n);var r=t.renderable.dirtyRenderBounds;r&&e.add(r)})),e},t.prototype.searchDirtyObjects=function(t){var e=c(t.getMin(),2),n=e[0],r=e[1],i=c(t.getMax(),2),o=i[0],a=i[1];return this.rBush.search({minX:n,minY:r,maxX:o,maxY:a}).map((function(t){return t.displayObject}))},t.prototype.saveDirtyAABB=function(t){var e=t.renderable;e.dirtyRenderBounds||(e.dirtyRenderBounds=new dr);var n=t.getRenderBounds();n&&e.dirtyRenderBounds.update(n.center,n.halfExtents)},t.prototype.applyAttributesToContext=function(t,e){var n=e.parsedStyle,r=n.stroke,i=n.fill,o=n.opacity,a=n.lineDash,s=n.lineDashOffset;a&&t.setLineDash(a),Pt(s)||(t.lineDashOffset=s),Pt(o)||(t.globalAlpha*=o),Pt(r)||Array.isArray(r)||r.isNone||(t.strokeStyle=e.attributes.stroke),Pt(i)||Array.isArray(i)||i.isNone||(t.fillStyle=e.attributes.fill)},t.prototype.applyWorldTransform=function(t,e,n){var r=0,i=0,o=(e.parsedStyle||{}).anchor,a=o&&o[0]||0,s=o&&o[1]||0;if(0!==a||0!==s){var u=e.geometry.contentBounds;r=-a*(u&&2*u.halfExtents[0]||0),i=-s*(u&&2*u.halfExtents[1]||0)}n?(w(this.tmpMat4,e.getLocalTransform()),this.vec3a[0]=r,this.vec3a[1]=i,this.vec3a[2]=0,P(this.tmpMat4,this.tmpMat4,this.vec3a),k(this.tmpMat4,n,this.tmpMat4),k(this.tmpMat4,this.vpMatrix,this.tmpMat4)):(w(this.tmpMat4,e.getWorldTransform()),this.vec3a[0]=r,this.vec3a[1]=i,this.vec3a[2]=0,P(this.tmpMat4,this.tmpMat4,this.vec3a),k(this.tmpMat4,this.vpMatrix,this.tmpMat4)),t.setTransform(this.tmpMat4[0],this.tmpMat4[1],this.tmpMat4[4],this.tmpMat4[5],this.tmpMat4[12],this.tmpMat4[13])},t.prototype.safeMergeAABB=function(){for(var t=[],e=0;e<arguments.length;e++)t[e]=arguments[e];var n=new dr;return t.forEach((function(t){n.add(t)})),n},t.tag="CanvasRenderer",t}(),ZI=function(){function t(t){this.imagePool=t}return t.prototype.render=function(t,e,n,r,i,o){var a=e.fill,s=e.fillRule,u=e.opacity,c=e.fillOpacity,h=e.stroke,l=e.strokeOpacity,d=e.lineWidth,f=e.lineCap,p=e.lineJoin,g=e.shadowType,m=e.shadowColor,v=e.shadowBlur,y=e.filter,b=e.miterLimit,E=!Pt(a)&&!a.isNone,w=!Pt(h)&&!h.isNone&&d>0,x=0===a.alpha,M=!(!y||!y.length),N=!Pt(m)&&v>0,S=n.nodeName,T="inner"===g,k=w&&N&&(S===Un.PATH||S===Un.LINE||S===Un.POLYLINE||x||T);E&&(t.globalAlpha=u*c,k||QI(n,t,N),this.fill(t,n,a,s,r,i,o),k||this.clearShadowAndFilter(t,M,N)),w&&(t.globalAlpha=u*l,t.lineWidth=d,Pt(b)||(t.miterLimit=b),Pt(f)||(t.lineCap=f),Pt(p)||(t.lineJoin=p),k&&(T&&(t.globalCompositeOperation="source-atop"),QI(n,t,!0),T&&(this.stroke(t,n,h,r,i,o),t.globalCompositeOperation="source-over",this.clearShadowAndFilter(t,M,!0))),this.stroke(t,n,h,r,i,o))},t.prototype.clearShadowAndFilter=function(t,e,n){if(n&&(t.shadowColor="transparent",t.shadowBlur=0),e){var r=t.filter;!Pt(r)&&r.indexOf("drop-shadow")>-1&&(t.filter=r.replace(/drop-shadow\([^)]*\)/,"").trim()||"none")}},t.prototype.fill=function(t,e,n,r,i,o,a){var s=this;Array.isArray(n)?n.forEach((function(n){t.fillStyle=s.getColor(n,e,t),r?t.fill(r):t.fill()})):(xi(n)&&(t.fillStyle=this.getPattern(n,e,t,i,o,a)),r?t.fill(r):t.fill())},t.prototype.stroke=function(t,e,n,r,i,o){var a=this;Array.isArray(n)?n.forEach((function(n){t.strokeStyle=a.getColor(n,e,t),t.stroke()})):(xi(n)&&(t.strokeStyle=this.getPattern(n,e,t,r,i,o)),t.stroke())},t.prototype.getPattern=function(t,e,n,r,i,o){var a,s;if("rect"===t.image.nodeName){var u=t.image.parsedStyle,c=u.width,h=u.height;s=r.contextService.getDPR();var l=r.config.offscreenCanvas;(a=o.offscreenCanvasCreator.getOrCreateCanvas(l)).width=c*s,a.height=h*s;var d=o.offscreenCanvasCreator.getOrCreateContext(l),f=[];t.image.forEach((function(t){i.renderDisplayObject(t,d,r,f,o)})),f.forEach((function(){d.restore()}))}return this.imagePool.getOrCreatePatternSync(t,n,a,s,(function(){e.renderable.dirty=!0,r.renderingService.dirtify()}))},t.prototype.getColor=function(t,e,n){var r;if(t.type===_r.LinearGradient||t.type===_r.RadialGradient){var o=e.getGeometryBounds(),a=o&&2*o.halfExtents[0]||1,s=o&&2*o.halfExtents[1]||1;r=this.imagePool.getOrCreateGradient(i(i({type:t.type},t.value),{width:a,height:s}),n)}return r},t}();function QI(t,e,n){var r=t.parsedStyle,i=r.filter,o=r.shadowColor,a=r.shadowBlur,s=r.shadowOffsetX,u=r.shadowOffsetY;i&&i.length&&(e.filter=t.style.filter),n&&(e.shadowColor=o.toString(),e.shadowBlur=a||0,e.shadowOffsetX=s||0,e.shadowOffsetY=u||0)}var JI=function(){function t(t){this.imagePool=t}return t.prototype.render=function(t,e,n){var r,i=e.width,o=e.height,a=e.img,s=e.shadowColor,u=e.shadowBlur,c=i,h=o;if(zt(a)?r=this.imagePool.getImageSync(a):(c||(c=a.width),h||(h=a.height),r=a),r){QI(n,t,!Pt(s)&&u>0);try{t.drawImage(r,0,0,c,h)}catch(t){}}},t}(),tL=function(){function t(){}return t.prototype.render=function(t,e,n,r,i,o){var a=e,s=a.lineWidth,u=a.textAlign,c=a.textBaseline,h=a.lineJoin,l=a.miterLimit,d=a.letterSpacing,f=a.stroke,p=a.fill,g=a.fillOpacity,m=a.strokeOpacity,v=a.opacity,y=a.metrics,b=a.dx,E=a.dy,w=a.shadowColor,x=a.shadowBlur,M=y.font,N=y.lines,S=y.height,T=y.lineHeight,k=y.lineMetrics;t.font=M,t.lineWidth=s,t.textAlign="middle"===u?"center":u;var P=c;o.enableCSSParsing||"alphabetic"!==P||(P="bottom"),t.lineJoin=h,Pt(l)||(t.miterLimit=l);var C=0;"middle"===c?C=-S/2-T/2:"bottom"===c||"alphabetic"===c||"ideographic"===c?C=-S:"top"!==c&&"hanging"!==c||(C=-T);var A=b||0;C+=E||0,1===N.length&&("bottom"===P?(P="middle",C-=.5*S):"top"===P&&(P="middle",C+=.5*S)),t.textBaseline=P,QI(n,t,!Pt(w)&&x>0);for(var O=0;O<N.length;O++){var R=s/2+A;C+=T,Pt(f)||f.isNone||!s||this.drawLetterSpacing(t,N[O],k[O],u,R,C,d,g,m,v,!0),Pt(p)||this.drawLetterSpacing(t,N[O],k[O],u,R,C,d,g,m,v)}},t.prototype.drawLetterSpacing=function(t,e,n,r,i,o,a,s,u,c,h){if(void 0===h&&(h=!1),0!==a){var l=t.textAlign;t.textAlign="left";var d=i;"center"===r||"middle"===r?d=i-n.width/2:"right"!==r&&"end"!==r||(d=i-n.width);for(var f=Array.from(e),p=t.measureText(e).width,g=0,m=0;m<f.length;++m){var v=f[m];h?this.strokeText(t,v,d,o,u):this.fillText(t,v,d,o,s,c),d+=p-(g=t.measureText(e.substring(m+1)).width)+a,p=g}t.textAlign=l}else h?this.strokeText(t,e,i,o,u):this.fillText(t,e,i,o,s,c)},t.prototype.fillText=function(t,e,n,r,i,o){var a,s=!Pt(i)&&1!==i;s&&(a=t.globalAlpha,t.globalAlpha=i*o),t.fillText(e,n,r),s&&(t.globalAlpha=a)},t.prototype.strokeText=function(t,e,n,r,i){var o,a=!Pt(i)&&1!==i;a&&(o=t.globalAlpha,t.globalAlpha=i),t.strokeText(e,n,r),a&&(t.globalAlpha=o)},t}();!function(t){function e(){return null!==t&&t.apply(this,arguments)||this}r(e,t)}(ZI),function(t){function e(){return null!==t&&t.apply(this,arguments)||this}r(e,t)}(ZI),function(t){function e(){return null!==t&&t.apply(this,arguments)||this}r(e,t)}(ZI),function(t){function e(){return null!==t&&t.apply(this,arguments)||this}r(e,t)}(ZI),function(t){function e(){return null!==t&&t.apply(this,arguments)||this}r(e,t)}(ZI),function(t){function e(){return null!==t&&t.apply(this,arguments)||this}r(e,t)}(ZI),function(t){function e(){return null!==t&&t.apply(this,arguments)||this}r(e,t)}(ZI);var eL=function(t){function e(e){void 0===e&&(e={});var n=t.call(this)||this;return n.options=e,n.name="canvas-renderer",n}return r(e,t),e.prototype.init=function(){var t,e=i({dirtyObjectNumThreshold:500,dirtyObjectRatioThreshold:.8},this.options),n=this.context.imagePool,r=new ZI(n),o=((t={})[Un.CIRCLE]=r,t[Un.ELLIPSE]=r,t[Un.RECT]=r,t[Un.IMAGE]=new JI(n),t[Un.TEXT]=new tL,t[Un.LINE]=r,t[Un.POLYLINE]=r,t[Un.POLYGON]=r,t[Un.PATH]=r,t[Un.GROUP]=void 0,t[Un.HTML]=void 0,t[Un.MESH]=void 0,t);this.context.defaultStyleRendererFactory=o,this.context.styleRendererFactory=o,this.addRenderingPlugin(new KI(e))},e.prototype.destroy=function(){this.removeAllRenderingPlugins(),delete this.context.defaultStyleRendererFactory,delete this.context.styleRendererFactory},e}(qn),nL=function(){function t(){}return t.prototype.apply=function(e,n){var r=this,i=e.renderingService,o=e.renderingContext,a=e.config;this.context=e;var s=o.root.ownerDocument.defaultView,u=function(t){i.hooks.pointerMove.call(t)},c=function(t){i.hooks.pointerUp.call(t)},h=function(t){i.hooks.pointerDown.call(t)},l=function(t){i.hooks.pointerOver.call(t)},d=function(t){i.hooks.pointerOut.call(t)},f=function(t){i.hooks.pointerCancel.call(t)},p=function(t){i.hooks.pointerWheel.call(t)},g=function(t){i.hooks.click.call(t)};i.hooks.init.tap(t.tag,(function(){var t=r.context.contextService.getDomElement();n.globalThis.navigator.msPointerEnabled?(t.style.msContentZooming="none",t.style.msTouchAction="none"):s.supportsPointerEvents&&(t.style.touchAction="none"),s.supportsPointerEvents?function(t){n.globalThis.document.addEventListener("pointermove",u,!0),t.addEventListener("pointerdown",h,!0),t.addEventListener("pointerleave",d,!0),t.addEventListener("pointerover",l,!0),n.globalThis.addEventListener("pointerup",c,!0),n.globalThis.addEventListener("pointercancel",f,!0)}(t):function(t){n.globalThis.document.addEventListener("mousemove",u,!0),t.addEventListener("mousedown",h,!0),t.addEventListener("mouseout",d,!0),t.addEventListener("mouseover",l,!0),n.globalThis.addEventListener("mouseup",c,!0)}(t),s.supportsTouchEvents&&function(t){t.addEventListener("touchstart",h,!0),t.addEventListener("touchend",c,!0),t.addEventListener("touchmove",u,!0),t.addEventListener("touchcancel",f,!0)}(t),a.useNativeClickEvent&&t.addEventListener("click",g,!0),t.addEventListener("wheel",p,{passive:!0,capture:!0})})),i.hooks.destroy.tap(t.tag,(function(){var t=r.context.contextService.getDomElement();n.globalThis.navigator.msPointerEnabled?(t.style.msContentZooming="",t.style.msTouchAction=""):s.supportsPointerEvents&&(t.style.touchAction=""),s.supportsPointerEvents?function(t){n.globalThis.document.removeEventListener("pointermove",u,!0),t.removeEventListener("pointerdown",h,!0),t.removeEventListener("pointerleave",d,!0),t.removeEventListener("pointerover",l,!0),n.globalThis.removeEventListener("pointerup",c,!0)}(t):function(t){n.globalThis.document.removeEventListener("mousemove",u,!0),t.removeEventListener("mousedown",h,!0),t.removeEventListener("mouseout",d,!0),t.removeEventListener("mouseover",l,!0),n.globalThis.removeEventListener("mouseup",c,!0)}(t),s.supportsTouchEvents&&function(t){t.removeEventListener("touchstart",h,!0),t.removeEventListener("touchend",c,!0),t.removeEventListener("touchmove",u,!0),t.removeEventListener("touchcancel",f,!0)}(t),a.useNativeClickEvent&&t.removeEventListener("click",g,!0),t.removeEventListener("wheel",p,!0)}))},t.tag="DOMInteraction",t}(),rL=function(t){function e(){var e=t.apply(this,h([],c(arguments),!1))||this;return e.name="dom-interaction",e}return r(e,t),e.prototype.init=function(){this.addRenderingPlugin(new nL)},e.prototype.destroy=function(){this.removeAllRenderingPlugins()},e}(qn),iL=function(){function t(){this.displayObjectHTMLElementMap=new WeakMap}return t.prototype.joinTransformMatrix=function(t){return"matrix(".concat([t[0],t[1],t[4],t[5],t[12],t[13]].join(","),")")},t.prototype.apply=function(e,n){var r=this,i=e.camera,o=e.renderingContext,a=e.renderingService;this.context=e;var s=o.root.ownerDocument.defaultView,u=s.context.eventService.nativeHTMLMap,c=function(t,e){e.style.transform=r.joinTransformMatrix(t.getWorldTransform())},h=function(t){var e=t.target;if(e.nodeName===Un.HTML){r.$camera||(r.$camera=r.createCamera(i));var o=r.getOrCreateEl(e);if(r.$camera.appendChild(o),n.enableCSSParsing){var a=e.ownerDocument.documentElement.attributes;Object.keys(a).forEach((function(t){o.style[t]=a[t]}))}Object.keys(e.attributes).forEach((function(t){r.updateAttribute(t,e)})),c(e,o),u.set(o,e)}},l=function(t){var e=t.target;if(e.nodeName===Un.HTML&&r.$camera){var n=r.getOrCreateEl(e);n&&(n.remove(),u.delete(n))}},d=function(t){var e=t.target;if(e.nodeName===Un.HTML){var n=t.attrName;r.updateAttribute(n,e)}},f=function(t){var e=t.target;if(e.nodeName===Un.HTML){var n=r.getOrCreateEl(e);c(e,n)}},p=function(){if(r.$camera){var t=r.context.config,e=t.width,n=t.height;r.$camera.style.width="".concat(e||0,"px"),r.$camera.style.height="".concat(n||0,"px")}};a.hooks.init.tap(t.tag,(function(){s.addEventListener(vs.RESIZE,p),s.addEventListener(qa.MOUNTED,h),s.addEventListener(qa.UNMOUNTED,l),s.addEventListener(qa.ATTR_MODIFIED,d),s.addEventListener(qa.BOUNDS_CHANGED,f)})),a.hooks.endFrame.tap(t.tag,(function(){r.$camera&&o.renderReasons.has(La.CAMERA_CHANGED)&&(r.$camera.style.transform=r.joinTransformMatrix(i.getOrthoMatrix()))})),a.hooks.destroy.tap(t.tag,(function(){r.$camera&&r.$camera.remove(),s.removeEventListener(vs.RESIZE,p),s.removeEventListener(qa.MOUNTED,h),s.removeEventListener(qa.UNMOUNTED,l),s.removeEventListener(qa.ATTR_MODIFIED,d),s.removeEventListener(qa.BOUNDS_CHANGED,f)}))},t.prototype.createCamera=function(t){var e=this.context.config,n=e.document,r=e.width,i=e.height,o=this.context.contextService.getDomElement(),a=o.parentNode;if(a){var s="g-canvas-camera",u=a.querySelector("#"+s);if(!u){var c=(n||document).createElement("div");u=c,c.id=s,c.style.position="absolute",c.style.left="".concat(o.offsetLeft||0,"px"),c.style.top="".concat(o.offsetTop||0,"px"),c.style.transformOrigin="left top",c.style.transform=this.joinTransformMatrix(t.getOrthoMatrix()),c.style.overflow="hidden",c.style.pointerEvents="none",c.style.width="".concat(r||0,"px"),c.style.height="".concat(i||0,"px"),a.appendChild(c)}return u}return null},t.prototype.getOrCreateEl=function(t){var e=this.context.config.document,n=this.displayObjectHTMLElementMap.get(t);return n||(n=(e||document).createElement("div"),t.parsedStyle.$el=n,this.displayObjectHTMLElementMap.set(t,n),t.id&&(n.id=t.id),t.name&&n.setAttribute("name",t.name),t.className&&(n.className=t.className),n.style.position="absolute",n.style.left="0px",n.style.top="0px",n.style["will-change"]="transform",n.style.transform=this.joinTransformMatrix(t.getWorldTransform())),n},t.prototype.updateAttribute=function(t,e){var n=this.getOrCreateEl(e);switch(t){case"innerHTML":var r=e.parsedStyle.innerHTML;zt(r)?n.innerHTML=r:(n.innerHTML="",n.appendChild(r));break;case"transformOrigin":var i=e.parsedStyle.transformOrigin;n.style["transform-origin"]="".concat(i[0].value," ").concat(i[1].value);break;case"width":if(this.context.enableCSSParsing){var o=e.computedStyleMap().get("width");n.style.width=o.toString()}else{o=e.parsedStyle.width;n.style.width=Vt(o)?"".concat(o,"px"):o.toString()}break;case"height":if(this.context.enableCSSParsing){var a=e.computedStyleMap().get("height");n.style.height=a.toString()}else{a=e.parsedStyle.height;n.style.height=Vt(a)?"".concat(a,"px"):a.toString()}break;case"zIndex":var s=e.parsedStyle.zIndex;n.style["z-index"]="".concat(s);break;case"visibility":var u=e.parsedStyle.visibility;n.style.visibility=u;break;case"pointerEvents":var c=e.parsedStyle.pointerEvents;n.style.pointerEvents=c;break;case"opacity":var h=e.parsedStyle.opacity;n.style.opacity="".concat(h);break;case"fill":var l=e.parsedStyle.fill,d="";Mi(l)?d=l.isNone?"transparent":e.getAttribute("fill"):Array.isArray(l)?d=e.getAttribute("fill"):xi(l),n.style.background=d;break;case"stroke":var f=e.parsedStyle.stroke,p="";Mi(f)?p=f.isNone?"transparent":e.getAttribute("stroke"):Array.isArray(f)?p=e.getAttribute("stroke"):xi(f),n.style["border-color"]=p,n.style["border-style"]="solid";break;case"lineWidth":var g=e.parsedStyle.lineWidth;n.style["border-width"]="".concat(g||0,"px");break;case"lineDash":n.style["border-style"]="dashed";break;case"filter":var m=e.style.filter;n.style.filter=m;break;default:"x"!==t&&"y"!==t&&(Pt(e.style[t])||""===e.style[t]||(n.style[t]=e.style[t]))}},t.tag="HTMLRendering",t}(),oL=function(t){function e(){var e=t.apply(this,h([],c(arguments),!1))||this;return e.name="html-renderer",e}return r(e,t),e.prototype.init=function(){this.addRenderingPlugin(new iL)},e.prototype.destroy=function(){this.removeAllRenderingPlugins()},e}(qn),aL=function(){function t(t){this.canvasConfig=t,this.imageCache={},this.gradientCache={},this.patternCache={}}return t.prototype.getImageSync=function(t,e){return this.imageCache[t]?e&&e(this.imageCache[t]):this.getOrCreateImage(t).then((function(t){e&&e(t)})),this.imageCache[t]},t.prototype.getOrCreateImage=function(t){var e=this;if(this.imageCache[t])return Promise.resolve(this.imageCache[t]);var n=this.canvasConfig.createImage;return new Promise((function(r,i){var o;n?o=n(t):ea&&(o=new window.Image),o&&(o.onload=function(){e.imageCache[t]=o,r(o)},o.onerror=function(t){i(t)},o.crossOrigin="Anonymous",o.src=t)}))},t.prototype.getOrCreatePatternSync=function(t,e,n,r,i){var o=this.generatePatternKey(t);if(o&&this.patternCache[o])return this.patternCache[o];var a,s=t.image,u=t.repetition,c=t.transform,h=!1;zt(s)?a=this.getImageSync(s,i):n?(a=n,h=!0):a=s;var l=a&&e.createPattern(a,u);if(l){var d=void 0;d=c?Vo(po(c),new Ns({})):M(b()),h&&C(d,d,[1/r,1/r,1]),l.setTransform({a:d[0],b:d[1],c:d[4],d:d[5],e:d[12],f:d[13]})}return o&&l&&(this.patternCache[o]=l),l},t.prototype.getOrCreateGradient=function(t,e){var n=this.generateGradientKey(t),r=t.type,i=t.steps,o=t.width,a=t.height,s=t.angle,u=t.cx,c=t.cy,h=t.size;if(this.gradientCache[n])return this.gradientCache[n];var l=null;if(r===_r.LinearGradient){var d=function(t,e,n){var r=tr(n.value),i=0+t/2,o=0+e/2,a=Math.abs(t*Math.cos(r))+Math.abs(e*Math.sin(r));return{x1:i-Math.cos(r)*a/2,y1:o-Math.sin(r)*a/2,x2:i+Math.cos(r)*a/2,y2:o+Math.sin(r)*a/2}}(o,a,s),f=d.x1,p=d.y1,g=d.x2,m=d.y2;l=e.createLinearGradient(f,p,g,m)}else if(r===_r.RadialGradient){var v=function(t,e,n,r,i){var o=n.value,a=r.value;n.unit===xr.kPercentage&&(o=n.value/100*t),r.unit===xr.kPercentage&&(a=r.value/100*e);var s=Math.max(Re([0,0],[o,a]),Re([0,e],[o,a]),Re([t,e],[o,a]),Re([t,0],[o,a]));return i&&(i instanceof $r?s=i.value:i instanceof Br&&("closest-side"===i.value?s=Math.min(o,t-o,a,e-a):"farthest-side"===i.value?s=Math.max(o,t-o,a,e-a):"closest-corner"===i.value&&(s=Math.min(Re([0,0],[o,a]),Re([0,e],[o,a]),Re([t,e],[o,a]),Re([t,0],[o,a]))))),{x:o,y:a,r:s}}(o,a,u,c,h),y=v.x,b=v.y,E=v.r;l=e.createRadialGradient(y,b,0,y,b,E)}return l&&(i.forEach((function(t){var e=t.offset,n=t.color;e.unit===xr.kPercentage&&(null==l||l.addColorStop(e.value/100,n.toString()))})),this.gradientCache[n]=l),this.gradientCache[n]},t.prototype.generateGradientKey=function(t){var e=t.type,n=t.width,r=t.height,i=t.steps,o=t.angle,a=t.cx,s=t.cy,u=t.size;return"gradient-".concat(e,"-").concat((null==o?void 0:o.toString())||0,"-").concat((null==a?void 0:a.toString())||0,"-").concat((null==s?void 0:s.toString())||0,"-").concat((null==u?void 0:u.toString())||0,"-").concat(n,"-").concat(r,"-").concat(i.map((function(t){var e=t.offset,n=t.color;return"".concat(e).concat(n)})).join("-"))},t.prototype.generatePatternKey=function(t){var e=t.image,n=t.repetition;return zt(e)?"pattern-".concat(e,"-").concat(n):"rect"===e.nodeName?"pattern-".concat(e.entity,"-").concat(n):void 0},t}(),sL=function(){function t(){}return t.prototype.apply=function(e){var n=e.renderingService,r=e.renderingContext,i=e.imagePool,o=r.root.ownerDocument.defaultView,a=function(t,e,n){var r=t.parsedStyle,i=r.width,o=r.height;i&&!o?t.setAttribute("height",n/e*i):!i&&o&&t.setAttribute("width",e/n*o)},s=function(t){var e=t.target,r=e.nodeName,o=e.attributes;if(r===Un.IMAGE){var s=o.img,u=o.keepAspectRatio;zt(s)&&i.getImageSync(s,(function(t){var r=t.width,i=t.height;u&&a(e,r,i),e.renderable.dirty=!0,n.dirtify()}))}},u=function(t){var e=t.target,r=t.attrName,o=t.newValue;e.nodeName===Un.IMAGE&&"img"===r&&zt(o)&&i.getOrCreateImage(o).then((function(t){var r=t.width,i=t.height;e.attributes.keepAspectRatio&&a(e,r,i),e.renderable.dirty=!0,n.dirtify()}))};n.hooks.init.tap(t.tag,(function(){o.addEventListener(qa.MOUNTED,s),o.addEventListener(qa.ATTR_MODIFIED,u)})),n.hooks.destroy.tap(t.tag,(function(){o.removeEventListener(qa.MOUNTED,s),o.removeEventListener(qa.ATTR_MODIFIED,u)}))},t.tag="LoadImage",t}(),uL=function(t){function e(){var e=t.apply(this,h([],c(arguments),!1))||this;return e.name="image-loader",e}return r(e,t),e.prototype.init=function(){this.context.imagePool=new aL(this.context.config),this.addRenderingPlugin(new sL)},e.prototype.destroy=function(){this.removeAllRenderingPlugins()},e}(qn),cL=function(){function t(t){this.renderingContext=t.renderingContext,this.canvasConfig=t.config}return t.prototype.init=function(){var t=this.canvasConfig,e=t.container,n=t.canvas;if(n)this.$canvas=n,e&&n.parentElement!==e&&e.appendChild(n),this.$container=n.parentElement,this.canvasConfig.container=this.$container;else if(e&&(this.$container=zt(e)?document.getElementById(e):e,this.$container)){var r=document.createElement("canvas");this.$container.appendChild(r),this.$container.style.position||(this.$container.style.position="relative"),this.$canvas=r}this.context=this.$canvas.getContext("2d"),this.resize(this.canvasConfig.width,this.canvasConfig.height)},t.prototype.getContext=function(){return this.context},t.prototype.getDomElement=function(){return this.$canvas},t.prototype.getDPR=function(){return this.dpr},t.prototype.getBoundingClientRect=function(){if(this.$canvas.getBoundingClientRect)return this.$canvas.getBoundingClientRect()},t.prototype.destroy=function(){this.$container&&this.$canvas&&this.$canvas.parentNode&&this.$container.removeChild(this.$canvas)},t.prototype.resize=function(t,e){var n=this.canvasConfig.devicePixelRatio||ea&&window.devicePixelRatio||1;n=n>=1?Math.ceil(n):1,this.dpr=n,this.$canvas&&(this.$canvas.width=this.dpr*t,this.$canvas.height=this.dpr*e,function(t,e,n){ea&&t.style&&(t.style.width=e+"px",t.style.height=n+"px")}(this.$canvas,t,e)),this.renderingContext.renderReasons.add(La.CAMERA_CHANGED)},t.prototype.applyCursorStyle=function(t){this.$container&&this.$container.style&&(this.$container.style.cursor=t)},t.prototype.toDataURL=function(t){return void 0===t&&(t={}),a(this,void 0,void 0,(function(){var e,n;return s(this,(function(r){return e=t.type,n=t.encoderOptions,[2,this.context.canvas.toDataURL(e,n)]}))}))},t}(),hL=function(t){function e(){var e=t.apply(this,h([],c(arguments),!1))||this;return e.name="canvas-context-register",e}return r(e,t),e.prototype.init=function(){this.context.ContextService=cL},e.prototype.destroy=function(){delete this.context.ContextService},e}(qn),lL=function(t){function e(e){var n=t.call(this,e)||this;return n.registerPlugin(new hL),n.registerPlugin(new uL),n.registerPlugin(new SI),n.registerPlugin(new eL),n.registerPlugin(new rL),n.registerPlugin(new XI),n.registerPlugin(new oL),n}return r(e,t),e}(Yn),dL=function(){function t(t){this.dragndropPluginOptions=t}return t.prototype.apply=function(e){var n=this,r=e.renderingService,i=e.renderingContext.root.ownerDocument,o=i.defaultView,u=function(t){var e=t.target,r=e===i,u=r&&n.dragndropPluginOptions.isDocumentDraggable?i:e.closest&&e.closest("[draggable=true]");if(u){var c=!1,h=t.timeStamp,l=[t.clientX,t.clientY],d=null,f=[t.clientX,t.clientY],p=function(t){return a(n,void 0,void 0,(function(){var n,o,a,p,g,m;return s(this,(function(s){switch(s.label){case 0:if(!c){if(n=t.timeStamp-h,o=Re([t.clientX,t.clientY],l),n<=this.dragndropPluginOptions.dragstartTimeThreshold||o<=this.dragndropPluginOptions.dragstartDistanceThreshold)return[2];t.type="dragstart",u.dispatchEvent(t),c=!0}return t.type="drag",t.dx=t.clientX-f[0],t.dy=t.clientY-f[1],u.dispatchEvent(t),f=[t.clientX,t.clientY],r?[3,2]:(a="pointer"===this.dragndropPluginOptions.overlap?[t.canvasX,t.canvasY]:e.getBounds().center,[4,i.elementsFromPoint(a[0],a[1])]);case 1:p=s.sent(),g=p[p.indexOf(e)+1],m=(null==g?void 0:g.closest("[droppable=true]"))||(this.dragndropPluginOptions.isDocumentDroppable?i:null),d!==m&&(d&&(t.type="dragleave",t.target=d,d.dispatchEvent(t)),m&&(t.type="dragenter",t.target=m,m.dispatchEvent(t)),(d=m)&&(t.type="dragover",t.target=d,d.dispatchEvent(t))),s.label=2;case 2:return[2]}}))}))};o.addEventListener("pointermove",p);var g=function(t){if(c){t.detail={preventClick:!0};var e=t.clone();d&&(e.type="drop",e.target=d,d.dispatchEvent(e)),e.type="dragend",u.dispatchEvent(e),c=!1}o.removeEventListener("pointermove",p)};e.addEventListener("pointerup",g,{once:!0}),e.addEventListener("pointerupoutside",g,{once:!0})}};r.hooks.init.tap(t.tag,(function(){o.addEventListener("pointerdown",u)})),r.hooks.destroy.tap(t.tag,(function(){o.removeEventListener("pointerdown",u)}))},t.tag="Dragndrop",t}(),fL=function(t){function e(e){void 0===e&&(e={});var n=t.call(this)||this;return n.options=e,n.name="dragndrop",n}return r(e,t),e.prototype.init=function(){this.addRenderingPlugin(new dL(i({overlap:"pointer",isDocumentDraggable:!1,isDocumentDroppable:!1,dragstartDistanceThreshold:0,dragstartTimeThreshold:0},this.options)))},e.prototype.destroy=function(){this.removeAllRenderingPlugins()},e.prototype.setOptions=function(t){Object.assign(this.plugins[0].dragndropPluginOptions,t)},e}(qn);class pL{config;background;main;label;transient;transientLabel;get canvas(){return{main:this.main,label:this.label,transient:this.transient,transientLabel:this.transientLabel,background:this.background}}get document(){return this.main.document}renderers;constructor(t){this.config=t}async init(){if(Object.entries(this.canvas).every((([,t])=>!t))){const{renderer:t,background:e,...n}=this.config,r=["main","label","transient","transientLabel","background"],{renderers:i,canvas:o}=r.reduce(((e,r)=>{const i=kt(t)?t?.(r):new lL;i.registerPlugin(new fL({isDocumentDraggable:!0,isDocumentDroppable:!0,dragstartDistanceThreshold:10,dragstartTimeThreshold:100})),"main"!==r&&i.unregisterPlugin(i.getPlugin("dom-interaction"));const o=new Xs({renderer:i,supportsMutipleCanvasesInOneContainer:!0,...n});return e.renderers[r]=i,e.canvas[r]=o,this[r]=o,e}),{renderers:{},canvas:{}});this.renderers=i,Object.entries(o).forEach((([t,e])=>{const n=e.getContextService().getDomElement();n.style.position="absolute",n.style.outline="none",n.tabIndex=1,"main"!==t&&(n.style.pointerEvents="none")}))}return this.setBackground(),Promise.all(Object.values(this.canvas).map((t=>t.ready)))}getRendererType(t="main"){const e=this.renderers[t].getPlugins();for(const t of e){if("canvas-renderer"===t.name)return"canvas";if("svg-renderer"===t.name)return"svg";if("device-renderer"===t.name)return"gpu"}return"unknown"}get context(){return this.main.context}getDevice(){return this.main.context?.deviceRendererPlugin?.getDevice()}getConfig(){return this.config}setBackground(t=this.config.background){const e=this.getContainer();e&&t&&(e.style.background=t,e.style.transition="background 0.5s")}setCursor(t){Object.values(this.canvas).forEach((e=>{e.setCursor(t)}))}getSize(){return[this.config.width||0,this.config.height||0]}resize(t,e){this.config.width=t,this.config.height=e,Object.values(this.canvas).forEach((n=>{n.resize(t,e)}))}getCamera(){return this.main.getCamera()}getBounds(){return Mc(Object.values(this.canvas).map((t=>t.document.documentElement)).filter((t=>t.childNodes.length>0)).map((t=>t.getBounds())))}getContainer(){const t=this.config.container;return zt(t)?document.getElementById(t):t}appendChild(t){return this[t.style?.$layer||"main"].appendChild(t)}getContextService(){return this.main.getContextService()}viewport2Client(t){return this.main.viewport2Client(t)}viewport2Canvas(t){return this.main.viewport2Canvas(t)}client2Viewport(t){return this.main.client2Viewport(t)}canvas2Viewport(t){return this.main.canvas2Viewport(t)}async toDataURL(t={}){const e=window.devicePixelRatio||1,{width:n,height:r,renderer:i}=this.config,o=qe('<div id="virtual-image"></div>'),a=new Xs({width:n,height:r,renderer:i?.("main")||new lL,devicePixelRatio:e,container:o,background:this.background.getConfig().background});await a.ready,a.appendChild(this.background.getRoot().cloneNode(!0)),a.appendChild(this.main.getRoot().cloneNode(!0));const s=this.label.getRoot().cloneNode(!0),u=a.viewport2Canvas({x:0,y:0}),c=this.main.viewport2Canvas({x:0,y:0});s.translate([c.x-u.x,c.y-u.y]),s.scale(1/this.main.getCamera().getZoom()),a.appendChild(s),a.appendChild(this.transient.getRoot().cloneNode(!0));const h=this.main.getCamera(),l=a.getCamera();l.setZoom(h.getZoom()),l.setPosition(h.getPosition()),l.setFocalPoint(h.getFocalPoint());return a.getContextService().toDataURL(t)}destroy(){Object.values(this.canvas).forEach((t=>{const e=t.getCamera();e.landmarks?.length&&e.cancelLandmarkAnimation(),t.destroy()}))}}function gL(t,e){const{data:n,style:r,...i}=t,{data:o,style:a,...s}=e,u={...i,...s};return(n||o)&&Object.assign(u,{data:{...n,...o}}),(r||a)&&Object.assign(u,{style:{...r,...a}}),u}function mL(t){const{data:e,style:n,...r}=t,i=r;return e&&(i.data={...e}),n&&(i.style={...n}),i}function vL(t){const{id:e=Ic(t),style:n,data:r,...i}=t,o={...t,style:{...n},data:{...r}};return pc(t)?{id:e,data:o,...i}:{id:e,data:o}}function yL(t){return t.data}class bL{model;latestRemovedComboIds=new Set;comboIds=new Set;changes=[];batchCount=0;isTraceless=!1;constructor(){this.model=new Yf}pushChange(t){if(this.isTraceless)return;const{type:e}=t;if(e===ic.NodeUpdated||e===ic.EdgeUpdated||e===ic.ComboUpdated){const{value:n,original:r}=t;this.changes.push({value:mL(n),original:mL(r),type:e})}else this.changes.push({value:mL(t.value),type:e})}getChanges(){const t=this.changes;return this.changes=[],t}batch(t){this.batchCount++,this.model.batch(t),this.batchCount--}silence(t){this.isTraceless=!0,t(),this.isTraceless=!1}isCombo(t){return this.comboIds.has(t)||this.latestRemovedComboIds.has(t)}getData(){return{nodes:this.getNodeData(),edges:this.getEdgeData(),combos:this.getComboData()}}getNodeData(t){return this.model.getAllNodes().reduce(((e,n)=>{const r=yL(n);return this.isCombo(Ic(r))||(void 0===t||t.includes(Ic(r)))&&e.push(r),e}),[])}getEdgeData(t){return this.model.getAllEdges().reduce(((e,n)=>{const r=yL(n);return(void 0===t||t.includes(Ic(r)))&&e.push(r),e}),[])}getComboData(t){return this.model.getAllNodes().reduce(((e,n)=>{const r=yL(n);return this.isCombo(Ic(r))?((void 0===t||t.includes(Ic(r)))&&e.push(r),e):e}),[])}getAncestorsData(t,e){const{model:n}=this;return n.hasNode(t)&&n.hasTreeStructure(e)?n.getAncestors(t,e).map(yL):[]}getDescendantsData(t){const e=this.getElementsData([t])[0],n=[];return uI(e,(t=>{t!==e&&n.push(t)}),(t=>this.getChildrenData(Ic(t))),"TB"),n}getParentData(t,e=this.inferStructureKey(t)){const{model:n}=this;if(!e)return void console.error("The hierarchy structure key is not specified");if(!n.hasNode(t)||!n.hasTreeStructure(e))return;const r=n.getParent(t,e);return r?yL(r):void 0}getChildrenData(t){const e="node"===this.getElementType(t)?fc:dc,{model:n}=this;return n.hasNode(t)&&n.hasTreeStructure(e)?n.getChildren(t,e).map(yL):[]}inferStructureKey(t){if(this.isCombo(t))return dc}getElementData(t){return"node"===t?this.getNodeData():"edge"===t?this.getEdgeData():"combo"===t?this.getComboData():[]}getElementsData(t){return t.map((t=>{const e=this.getElementType(t);return"node"===e?this.getNodeData([t])[0]:"edge"===e?this.getEdgeData([t])[0]:this.getComboData([t])[0]}))}getNodeLikeData(t){return this.model.getAllNodes().reduce(((e,n)=>{const r=yL(n);return t?t.includes(Ic(r))&&e.push(r):e.push(r),e}),[])}getElementDataByState(t,e){return this.getElementData(t).filter((t=>t.style?.states?.includes(e)))}getElementState(t){return this.getElementsData([t])?.[0]?.style?.states||[]}hasNode(t){return this.model.hasNode(t)&&!this.isCombo(t)}hasEdge(t){return this.model.hasEdge(t)}hasCombo(t){return this.model.hasNode(t)&&this.isCombo(t)}getRelatedEdgesData(t,e="both"){return this.model.getRelatedEdges(t,e).map(yL)}getNeighborNodesData(t){return this.model.getNeighbors(t).map(yL)}setData(t){const{nodes:e=[],edges:n=[],combos:r=[]}=t,{nodes:i=[],edges:o=[],combos:a=[]}=this.getData(),s=Ml(i,e,(t=>Ic(t))),u=Ml(o,n,(t=>Ic(t))),c=Ml(a,r,(t=>Ic(t)));this.batch((()=>{this.addData({nodes:s.enter,edges:u.enter,combos:c.enter}),this.updateData({nodes:s.update,edges:u.update,combos:c.update}),this.removeData({nodes:s.exit.map(Ic),edges:u.exit.map(Ic),combos:c.exit.map(Ic)})}))}addData(t){const{nodes:e,edges:n,combos:r}=t;this.batch((()=>{this.addComboData(r),this.addNodeData(e),this.addEdgeData(n)}))}addNodeData(t=[]){t.length&&(this.model.addNodes(t.map((t=>(this.pushChange({value:t,type:ic.NodeAdded}),vL(t))))),this.updateNodeLikeHierarchy(t))}addEdgeData(t=[]){t.length&&this.model.addEdges(t.map((t=>(this.pushChange({value:t,type:ic.EdgeAdded}),vL(t)))))}addComboData(t=[]){if(!t.length)return;const{model:e}=this;e.hasTreeStructure(dc)||e.attachTreeStructure(dc),e.addNodes(t.map((t=>(this.comboIds.add(Ic(t)),this.pushChange({value:t,type:ic.ComboAdded}),vL(t))))),this.updateNodeLikeHierarchy(t)}updateNodeLikeHierarchy(t){if(!this.enableUpdateNodeLikeHierarchy)return;const{model:e}=this;t.forEach((t=>{const n=Ic(t);e.attachTreeStructure(dc),this.setParent(n,Lc(t),dc);const r=t?.style?.children;void 0!==r&&(e.attachTreeStructure(fc),r.forEach((t=>{this.setParent(t,n,fc)})))}))}enableUpdateNodeLikeHierarchy=!0;preventUpdateNodeLikeHierarchy(t){this.enableUpdateNodeLikeHierarchy=!1,t(),this.enableUpdateNodeLikeHierarchy=!0}updateData(t){const{nodes:e,edges:n,combos:r}=t;this.batch((()=>{this.updateNodeData(e),this.updateComboData(r),this.updateEdgeData(n)}))}updateNodeData(t=[]){if(!t.length)return;const{model:e}=this;this.batch((()=>{const n=[];t.forEach((t=>{const r=Ic(t),i=yL(e.getNode(r));if(ie(i,t))return;const o=gL(i,t);this.pushChange({value:o,original:i,type:ic.NodeUpdated}),e.mergeNodeData(r,o),n.push(o)})),this.updateNodeLikeHierarchy(n)}))}syncNodeDatum(t){const{model:e}=this,n=Ic(t),r=gL(yL(e.getNode(n)),t);e.mergeNodeData(n,r)}updateEdgeData(t=[]){if(!t.length)return;const{model:e}=this;this.batch((()=>{t.forEach((t=>{const n=Ic(t),r=yL(e.getEdge(n));if(ie(r,t))return;t.source&&r.source!==t.source&&e.updateEdgeSource(n,t.source),t.target&&r.target!==t.target&&e.updateEdgeTarget(n,t.target);const i=gL(r,t);e.mergeEdgeData(n,i),this.pushChange({value:i,original:r,type:ic.EdgeUpdated})}))}))}updateComboData(t=[]){if(!t.length)return;const{model:e}=this;e.batch((()=>{const n=[];t.forEach((t=>{const r=Ic(t),i=yL(e.getNode(r));if(ie(i,t))return;const o=gL(i,t);this.pushChange({value:o,original:i,type:ic.ComboUpdated}),e.mergeNodeData(r,o),n.push(o)})),this.updateNodeLikeHierarchy(n)}))}setParent(t,e,n,r=!0){if(t===e)return;const i=Lc(this.getNodeLikeData([t])[0]);if(i!==e){const n={id:t,style:{parentId:e}};this.isCombo(t)?this.syncComboDatum(n):this.syncNodeDatum(n)}this.model.setParent(t,e,n),r&&new Set([i,e]).forEach((t=>{void 0!==t&&this.refreshComboData(t)}))}refreshComboData(t){const e=this.getComboData([t])[0],n=this.getAncestorsData(t,dc);e&&this.pushChange({value:e,original:e,type:ic.ComboUpdated}),n.forEach((t=>{this.pushChange({value:t,original:t,type:ic.ComboUpdated})}))}syncComboDatum(t){const{model:e}=this,n=Ic(t),r=gL(yL(e.getNode(n)),t);e.mergeNodeData(n,r)}getElementPosition(t){return kc(this.getElementsData([t])[0])}translateNodeBy(t,e){const n=Vc(this.getElementPosition(t),[...e,0].slice(0,3));this.translateNodeTo(t,n)}translateNodeTo(t,e){const[n=0,r=0,i=0]=e;this.preventUpdateNodeLikeHierarchy((()=>{this.updateNodeData([{id:t,style:{x:n,y:r,z:i}}])}))}translateComboBy(t,e){const[n=0,r=0,i=0]=e;if([n,r,i].some(isNaN)||[n,r,i].every((t=>0===t)))return;const o=this.getComboData([t])[0];o&&uI(o,(t=>{const e=Ic(t),[o,a,s]=kc(t),u=gL(t,{style:{x:o+n,y:a+r,z:s+i}});this.pushChange({value:u,original:t,type:this.isCombo(e)?ic.ComboUpdated:ic.NodeUpdated}),this.model.mergeNodeData(e,u)}),(t=>this.getChildrenData(Ic(t))),"BT")}translateComboTo(t,e){if(e.some(isNaN))return;const[n=0,r=0,i=0]=e,o=this.getComboData([t])?.[0];if(!o)return;const[a,s,u]=kc(o),c=n-a,h=r-s,l=i-u;uI(o,(t=>{const e=Ic(t),[n,r,i]=kc(t),o=gL(t,{style:{x:n+c,y:r+h,z:i+l}});this.pushChange({value:o,original:t,type:this.isCombo(e)?ic.ComboUpdated:ic.NodeUpdated}),this.model.mergeNodeData(e,o)}),(t=>this.getChildrenData(Ic(t))),"BT")}removeData(t){const{nodes:e,edges:n,combos:r}=t;this.batch((()=>{this.removeEdgeData(n),this.removeNodeData(e),this.removeComboData(r),this.latestRemovedComboIds=new Set(r)}))}removeNodeData(t=[]){t.length&&this.batch((()=>{t.forEach((t=>{this.removeEdgeData(this.getRelatedEdgesData(t).map(Ic)),this.pushChange({value:this.getNodeData([t])[0],type:ic.NodeRemoved}),this.removeNodeLikeHierarchy(t)})),this.model.removeNodes(t)}))}removeEdgeData(t=[]){t.length&&(t.forEach((t=>this.pushChange({value:this.getEdgeData([t])[0],type:ic.EdgeRemoved}))),this.model.removeEdges(t))}removeComboData(t=[]){t.length&&this.batch((()=>{t.forEach((t=>{this.pushChange({value:this.getComboData([t])[0],type:ic.ComboRemoved}),this.removeNodeLikeHierarchy(t),this.comboIds.delete(t)})),this.model.removeNodes(t)}))}removeNodeLikeHierarchy(t){if(this.model.hasTreeStructure(dc)){const e=Lc(this.getNodeLikeData([t])[0]);this.setParent(t,void 0,dc,!1),this.model.getChildren(t,dc).forEach((t=>{const n=yL(t),r=Ic(n);this.setParent(Ic(n),e,dc,!1);const i=gL(n,{id:Ic(n),style:{parentId:e}});this.pushChange({value:i,original:n,type:this.isCombo(r)?ic.ComboUpdated:ic.NodeUpdated}),this.model.mergeNodeData(Ic(n),i)})),Zt(e)||this.refreshComboData(e)}}getElementType(t){if(this.model.hasNode(t))return this.isCombo(t)?"combo":"node";if(this.model.hasEdge(t))return"edge";throw new Error(`Unknown element type of id: ${t}`)}getFrontZIndex(t){let e=[];if("combo"===this.getElementType(t)){const n=[t,...this.getAncestorsData(t,dc).map(Ic)];e=this.getComboData().filter((t=>{const e=Ic(t),r=this.getAncestorsData(e,dc),i=r.map(Ic);return!r.some((t=>!!t.style?.collapsed))&&!n.includes(e)&&!i.includes(e)}))}else e=this.getNodeData().filter((e=>Ic(e)!==t));return Math.max(0,...e.map(mI))+1}destroy(){const{model:t}=this,e=t.getAllNodes(),n=t.getAllEdges();t.removeEdges(n.map((t=>t.id))),t.removeNodes(e.map((t=>t.id))),delete this.context}}class EL{context;container;elementMap={};shapeTypeMap={};constructor(t){this.context=t}init(){const{canvas:t}=this.context;this.container||(this.container={node:t.appendChild(new Ps({style:{zIndex:2}})),edge:t.appendChild(new Ps({style:{zIndex:1}})),combo:t.appendChild(new Ps({style:{zIndex:0}}))})}emit(t){const{graph:e}=this.context;e.emit(t.type,t)}forEachElementData(t){["node","edge","combo"].forEach((e=>{const n=this.context.model.getElementData(e);t(e,n)}))}getTheme(t){const{theme:e}=this.context.options;if(!e)return{};const n=sI("theme",e);return n?.[t]||{}}getThemeStyle(t){return this.getTheme(t).style||{}}getThemeStateStyle(t,e){const{state:n={}}=this.getTheme(t);return Object.assign({},...e.map((t=>n[t]||{})))}paletteStyle={};computePaletteStyle(){const{options:t}=this.context;this.paletteStyle={},this.forEachElementData(((e,n)=>{const r=Object.assign({},Kc(this.getTheme(e)?.palette),Kc(t[e]?.palette));!re(r)&&r?.field&&Object.assign(this.paletteStyle,function(t,e){if(!e)return{};const{type:n,color:r,field:i,invert:o}=e,a=t=>{const e=zt(r)?sI("palette",r):r;if(kt(e))return Object.fromEntries(t.map((([t,n])=>[t,e(o?1-n:n)])));if(Array.isArray(e)){const n=o?[...e].reverse():e;return Object.fromEntries(t.map((([t,r])=>[t,n[r%e.length]])))}return{}},s=(t,e)=>zt(t)?e.data?.[t]:t?.(e);if("group"===n){const e=Bt(t,(t=>{if(!i)return"default";const e=s(i,t);return e?String(e):"default"})),n=a(Object.keys(e).map(((t,e)=>[t,e]))),r={};return Object.entries(e).forEach((([t,e])=>{e.forEach((e=>{r[Ic(e)]=n[t]}))})),r}if("value"===n){const[e,n]=t.reduce((([t,e],n)=>{const r=s(i,n);if(!Vt(r))throw new Error(`Palette field ${i} is not a number`);return[Math.min(t,r),Math.max(e,r)]}),[1/0,-1/0]),r=n-e;return a(t.map((t=>[t.id,(s(i,t)-e)/r])))}}(n,r))}))}getPaletteStyle(t){const e=this.paletteStyle[t];return e?{color:e}:{}}defaultStyle={};computedElementDefaultStyle(t,e){const{options:n}=this.context,r=n[t]?.style||{};this.defaultStyle[Ic(e.datum)]=gI(r,e)}computeElementsDefaultStyle(t){this.forEachElementData(((e,n)=>{n.filter((e=>void 0===t||t.includes(Ic(e)))).forEach(((t,r)=>{this.computedElementDefaultStyle(e,{datum:t,index:r,elementData:n})}))}))}getDefaultStyle(t){return this.defaultStyle[t]||{}}getElementState(t){try{const{model:e}=this.context;return e.getElementState(t)}catch{return[]}}stateStyle={};getElementStateStyle(t,e,n){const{options:r}=this.context;return gI(r[t]?.state?.[e]||{},n)}computeElementStatesStyle(t,e,n){this.stateStyle[Ic(n.datum)]=Object.assign({},...e.map((e=>this.getElementStateStyle(t,e,n))))}computeElementsStatesStyle(t){this.forEachElementData(((e,n)=>{n.filter((e=>void 0===t||t.includes(Ic(e)))).forEach(((t,r)=>{const i=this.getElementState(Ic(t));this.computeElementStatesStyle(e,i,{datum:t,index:r,elementData:n})}))}))}getStateStyle(t){return this.stateStyle[t]||{}}computeStyle(t){this.computePaletteStyle(),this.computeElementsDefaultStyle(t),this.computeElementsStatesStyle(t)}getElement(t){return this.elementMap[t]}getNodes(){return this.container.node.children}getEdges(){return this.container.edge.children}getCombos(){return this.container.combo.children}getAnimation(t,e){const{options:n}=this.context,r=n?.[t]?.animation;if(!1===r)return!1;const i=r?.[e];if(i)return i;const o=this.getTheme(t)?.animation;if(!1===o)return!1;const a=o?.[e];return a??!1}getAnimationExecutor(t,e,n=!0,r){const{options:i}=this.context;return!1!==i.animation&&n?(n,i,o,a)=>xl(i,this.getAnimation(t,e),{},{originalStyle:o,modifiedStyle:a,states:this.getElementState(n),...r}):()=>null}getEdgeEndsContext(t){const{source:e,target:n}=t;return{sourceNode:this.getElement(e),targetNode:this.getElement(n)}}getElementComputedStyle(t,e){const n=Ic(e),r=this.getThemeStyle(t),i=this.getPaletteStyle(n),o=e.style||{},a=this.getDefaultStyle(n),s=this.getThemeStateStyle(t,this.getElementState(n)),u=this.getStateStyle(n),c=Object.assign({},r,i,o,a,s,u);if("edge"===t)Object.assign(c,this.getEdgeEndsContext(e));else if("combo"===t){const t=this.context.model.getChildrenData(n),e=!!c.collapsed?[]:t.map((t=>this.getElement(Ic(t)))).filter(Boolean);Object.assign(c,{childrenNode:e,childrenData:t})}return c.type||(c.type={node:"circle",edge:"line",combo:"circle"}[t]),c}async draw(e={animation:!0}){const n=this.computeDrawData();if(!n)return;this.init(),this.computeStyle();const{add:r,update:i,remove:o}=n,a=this.getDestroyTasks(o,e),s=this.getCreateTasks(r,e),u=this.getUpdateTasks(i,e);await(function(t,e={}){if(0===t.length)return null;const{before:n,...r}=e;e.before?.();const i=vl(t.map((t=>t())).map((t=>t())).flat().filter(Boolean));return El(i,r),i}([...a,...s,...u],e.silence?{}:{before:()=>this.emit(new hI(t.GraphEvent.BEFORE_DRAW)),beforeAnimate:e=>this.emit(new lI(t.GraphEvent.BEFORE_ANIMATE,oc.DRAW,e,n)),afterAnimate:e=>this.emit(new lI(t.GraphEvent.AFTER_ANIMATE,oc.DRAW,e,n)),after:()=>this.emit(new hI(t.GraphEvent.AFTER_DRAW))})?.finished)}computeDrawData(){const{model:t}=this.context,e=function(t){const e={Added:new Map,Updated:new Map,Removed:new Map};return t.forEach((t=>{const{type:n,value:r}=t,i=Ic(r);if("NodeAdded"===n||"EdgeAdded"===n||"ComboAdded"===n)e.Added.set(i,t);else if("NodeUpdated"===n||"EdgeUpdated"===n||"ComboUpdated"===n)if(e.Added.has(i))e.Added.set(i,{type:n.replace("Updated","Added"),value:r});else if(e.Updated.has(i)){const{original:t}=e.Updated.get(i);e.Updated.set(i,{type:n,value:r,original:t})}else e.Updated.set(i,t);else"NodeRemoved"!==n&&"EdgeRemoved"!==n&&"ComboRemoved"!==n||(e.Added.has(i)||e.Updated.has(i)?(e.Added.delete(i),e.Updated.delete(i)):e.Removed.set(i,t))})),[...Array.from(e.Added.values()),...Array.from(e.Updated.values()),...Array.from(e.Removed.values())]}(t.getChanges());if(0===e.length)return null;const{NodeAdded:n=[],NodeUpdated:r=[],NodeRemoved:i=[],EdgeAdded:o=[],EdgeUpdated:a=[],EdgeRemoved:s=[],ComboAdded:u=[],ComboUpdated:c=[],ComboRemoved:h=[]}=Bt(e,(t=>t.type)),l=t=>new Map(t.map((t=>{const e=t.value;return[Ic(e),e]}))),d={add:{nodes:l(n),edges:l(o),combos:l(u)},update:{nodes:l(r),edges:l(a),combos:l(c)},remove:{nodes:l(i),edges:l(s),combos:l(h)}},f=[this.updateRelatedEdgeFlow,this.arrangeDrawOrderFlow,this.collapseExpandFlow].reduce(((t,e)=>e(t)),d);return f}updateRelatedEdgeFlow=t=>{const{model:e}=this.context,{update:{nodes:n,edges:r,combos:i}}=t,o=(t,n)=>{e.getRelatedEdgesData(n).forEach((t=>r.set(Ic(t),t)))};return n.forEach(o),i.forEach(o),t};arrangeDrawOrderFlow=t=>{const{model:e}=this.context,n=t.add.combos,r=[];return n.forEach(((t,n)=>{const i=e.getAncestorsData(n,"combo").map((t=>Ic(t))).reverse();r.push([n,t,i.length])})),t.add.combos=new Map(r.sort((([,,t],[,,e])=>e-t)).map((([t,e])=>[t,e]))),t};collapseExpandFlow=t=>{const{model:e}=this.context,{add:n,update:r}=t,i=(e,n,r)=>{const i=`${n}s`;Object.entries(t).forEach((([t,n])=>{e===t?n[i].set(Ic(r),r):n[i].delete(Ic(r))}))},o=[...t.update.combos.entries(),...t.add.combos.entries()];for(;o.length;){const[t,a]=o.pop();if(!!a.style?.collapsed){const s=e.getDescendantsData(t),u=s.map(Ic),{internal:c,external:h}=qh(u,(t=>e.getRelatedEdgesData(t)));s.forEach((t=>{const n=Ic(t),r=o.findIndex((([t])=>t===n));-1!==r&&o.splice(r,1);const a=e.getElementType(n);i("remove",a,t)})),c.forEach((t=>i("remove","edge",t))),h.forEach((t=>{const e=Ic(t),i=u.includes(t.source)?"source":"target",o={...t,[i]:Ic(a)};n.edges.has(e)&&n.edges.set(e,o),r.edges.has(e)&&r.edges.set(e,o)}))}else{const n=e.getChildrenData(t),r=n.map(Ic),{edges:a}=qh(r,(t=>e.getRelatedEdgesData(t)));[...n,...a].forEach((t=>{const n=Ic(t),r=e.getElementType(n),a=this.getElement(n);i(a?"update":"add",r,t),"combo"===r&&o.push([n,t])}))}}return t};createElement(t,e,n){const{animator:r}=n,i=Ic(e);if(this.getElement(i))return()=>null;const{type:o,...a}=this.getElementComputedStyle(t,e),s=sI(t,o);if(!s)return()=>null;const u=this.container[t].appendChild(new s({id:i,style:{context:this.context,...a}}));return this.shapeTypeMap[i]=o,this.elementMap[i]=u,()=>r?.(i,u,{...u.attributes,opacity:0})||null}getCreateTasks(t,e){const{nodes:n,edges:r,combos:i}=t,o=[];return[["node",n],["combo",i],["edge",r]].forEach((([t,n])=>{if(0===n.size)return;const r=this.getAnimationExecutor(t,"enter");n.forEach((n=>o.push((()=>this.createElement(t,n,{...e,animator:r})))))})),o}latestElementVisibilityMap=new WeakMap;updateElement(t,e,n){const{animator:r}=n,i=Ic(e),o=this.getElement(i);if(!o)return()=>null;const{type:a,...s}=this.getElementComputedStyle(t,e);if(this.shapeTypeMap[i]!==a)return()=>(this.destroyElement(e,{...n,animation:!1})(),this.createElement(t,e,{...n,animation:!1})(),null);if("visibility"===n.stage&&"visibility"in s){dh(o,"opacity")||hh(o,"opacity");const t=lh(o,"opacity")??bl("opacity");if(this.latestElementVisibilityMap.set(o,s.visibility),"hidden"!==s.visibility)return ml(o,{visibility:"visible"}),()=>r?.(i,o,{...o.attributes,opacity:0},{opacity:t})||null;if("hidden"===s.visibility)return()=>El(r?.(i,o,{...o.attributes,opacity:t},{opacity:0})||null,{after:()=>ml(o,{visibility:this.latestElementVisibilityMap.get(o)})})}const u={...o.attributes};return ml(o,s),()=>r?.(i,o,u)||null}getUpdateTasks(t,e){const{nodes:n,edges:r,combos:i}=t,o=[["node",n],["combo",i],["edge",r]],{animation:a,stage:s}=e,u=[];return o.forEach((([t,n])=>{if(0===n.size)return[];const r=this.getAnimationExecutor(t,s||"update",a);n.forEach((n=>u.push((()=>this.updateElement(t,n,{...e,animator:r})))))})),u}destroyElement(t,e){const{animator:n}=e,r=Ic(t),i=this.elementMap[r];return i?()=>{const t=n?.(r,i,{...i.attributes},{opacity:0})||null;return El(t,{after:()=>{this.clearElement(r),i.destroy()}}),t}:()=>null}getDestroyTasks(t,e){const{nodes:n,edges:r,combos:i}=t,o=[["combo",i],["edge",r],["node",n]],{animation:a,stage:s}=e,u=[];return o.forEach((([t,n])=>{if(0===n.size)return[];const r=this.getAnimationExecutor(t,s||"exit",a);n.forEach((t=>u.push((()=>this.destroyElement(t,{...e,animator:r})))))})),u}clearElement(t){delete this.paletteStyle[t],delete this.defaultStyle[t],delete this.stateStyle[t],delete this.elementMap[t],delete this.shapeTypeMap[t]}destroy(){Object.values(this.container).forEach((t=>t.destroy())),this.elementMap={},this.shapeTypeMap={},this.defaultStyle={},this.stateStyle={},this.paletteStyle={},delete this.context}}function wL(t){return Vt(t.x)&&Vt(t.y)}class xL{context;supervisor;instance;animationResult;get presetOptions(){return{animation:!!wl(this.context.options,!0)}}get options(){const{options:t}=this.context;return t.layout}constructor(t){this.context=t}async presetLayout(t,e){if(!e)return;if(e.type)return this.stepLayout(t,e);const n=t.getAllNodes().reduce(((e,n)=>{if(!wL(n.data)){let r=[0,0,0],i=0;t.getNeighbors(n.id).forEach((t=>{if(wL(t.data)){const{x:e,y:n,z:o=0}=t.data;r=Vc(r,[e,n,o]),i++}})),i&&e.push({id:n.id,data:{x:r[0]/i,y:r[1]/i,z:r[2]/i}})}return e}),[]);this.updateElementPosition({nodes:n,edges:[]},!1)}async layout(){if(!this.options)return;const e=Array.isArray(this.options)?this.options:[this.options],{graph:n}=this.context;pI(n,new hI(t.GraphEvent.BEFORE_LAYOUT));for(const t of e){const{presetLayout:e}=t,n=this.getLayoutDataModel(t);await this.presetLayout(n,e);const r=await this.stepLayout(n,{...this.presetOptions,...t});t.animation||this.updateElementPosition(r,!1)}pI(n,new hI(t.GraphEvent.AFTER_LAYOUT))}async stepLayout(t,e){return function(t){const{type:e}=t;return["compact-box","mindmap","dendrogram","indented"].includes(e)}(e)?await this.treeLayout(t,e):await this.graphLayout(t,e)}async graphLayout(t,e){const{animation:n,enableWorker:r,iterations:i=300}=e,o=this.initGraphLayout(t,e);if(this.instance=o,r)return this.supervisor=new MD(t,o,{iterations:i}),await this.supervisor.execute();if(nD(o))return n?await o.execute(t,{onTick:t=>{this.updateElementPosition(t,!1)}}):(o.execute(t),o.stop(),o.tick(i));const a=await o.execute(t);return n&&this.updateElementPosition(a,n),a}async treeLayout(t,e){const{type:n,animation:r}=e,i=sI("layout",n);if(!i)throw new Error(`The layout type ${n} is not found`);!function(t){if(t.hasTreeStructure(fc))return;t.attachTreeStructure(fc);const e=t.getAllEdges();for(const n of e){const{source:e,target:r}=n;t.setParent(r,e,fc)}}(t);const o={nodes:[],edges:[]};return t.getRoots(fc).forEach((n=>{uI(n,(e=>{e.children=t.getSuccessors(e.id)}),(e=>t.getSuccessors(e.id)),"TB");uI(i(n,e),(t=>{const{id:e,x:n,y:r}=t;o.nodes.push({id:e,data:{x:n,y:r}})}),(t=>t.children),"TB")})),r&&this.updateElementPosition(o,r),o}stopLayout(){this.instance&&nD(this.instance)&&(this.instance.stop(),this.instance=void 0),this.supervisor&&(this.supervisor.stop(),this.supervisor=void 0),this.animationResult&&(this.animationResult.finish(),this.animationResult=void 0)}getLayoutDataModel(t){const{model:e,element:n}=this.context;if(!n)return new Yf;const{nodesFilter:r=(()=>!0)}=t,i=Object.fromEntries(n.getNodes().map((t=>[t.id,t]))),o=Object.fromEntries(n.getCombos().map((t=>[t.id,t]))),a=Object.fromEntries(n.getEdges().map((t=>[t.id,t]))),s=e.model.getAllNodes().filter((t=>r(t.data))),u=e.model.getAllEdges(),c=(function(t){const{type:e}=t;return!!["comboCombined","comboForce"].includes(e)||!("antv-dagre"!==e||!t.sortByCombo)}(t)?s:s.filter((t=>!o[t.id]&&function(t){return"hidden"!==oe(t,["style","visibility"])}(i[t.id])))).map((t=>{const{id:e}=t,n={id:e};return!!o[e]?Object.assign(n,{data:{...ML(o[e].attributes),_isCombo:!0}}):Object.assign(n,{data:ML(i[e]?.attributes||{})}),n})),h=new Map(c.map((t=>[t.id,t]))),l=u.filter((t=>{const e=h.get(t.source),n=h.get(t.target);return e&&n})).map((t=>{const{id:e,source:n,target:r}=t;return{id:e,source:n,target:r,data:ML(a[e].attributes)}})),d=new Yf({nodes:c,edges:l});return e.model.hasTreeStructure(dc)&&(d.attachTreeStructure(dc),c.forEach((t=>{const n=e.model.getParent(t.id,dc);n&&d.hasNode(n.id)&&d.setParent(t.id,n.id,dc)}))),d}initGraphLayout(t,e){const{element:n,viewport:r}=this.context,{type:i,enableWorker:o,animation:a,iterations:s,...u}=e,[c,h]=r.getCanvasSize(),l=[c/2,h/2],d=e?.nodeSize??(t=>{const e=n?.getElement(t.id),{size:r}=e?.attributes||{};return Math.max(...Oc(r))}),f=sI("layout",i);if(!f)throw new Error(`The layout type ${i} is not found`);const p={nodeSize:d,width:c,height:h,center:l,...u};return"force"===i?Object.assign(p,{getMass:n=>{const{id:r}=n,{getMass:i}=e;if(i)return i(n);const{mass:o}=n.data;return Vt(o)?o:wL(t.getNode(r).data)||wL(n.data)?10:1}}):"dagre"===i&&Object.assign(p,{preset:[]}),new f(p)}updateElementPosition(t,e){const{model:n,element:r}=this.context;if(!r)return null;const{nodes:i,edges:o}=t,a={nodes:[],edges:[],combos:[]};return i.forEach((({id:t,data:{x:e,y:n,z:r=0}})=>{a.nodes.push({id:t,style:{x:e,y:n,z:r}})})),o.forEach((({id:t,data:{points:e=[],controlPoints:n=e.slice(1,e.length-1)}})=>{n?.length&&a.edges.push({id:t,style:{controlPoints:n.map(Zc)}})})),n.updateData(a),r.draw({animation:e,silence:!0})}destroy(){this.stopLayout(),delete this.context}}const ML=t=>Object.entries(t).reduce(((t,[e,n])=>(["function","object"].includes(typeof n)||["x","y","z"].includes(e)||(t[e]=n),t)),{});class NL extends Nl{category="plugin";constructor(t){super(t),this.setPlugins(this.context.options.plugins||[])}setPlugins(t){this.setExtensions(t)}}class SL{context;get padding(){return vc(this.context.options.padding)}get paddingOffset(){const[t,e,n,r]=this.padding,[i,o,a]=[(r-e)/2,(t-n)/2,0];return[i,o,a]}constructor(t){this.context=t;const[e,n]=this.paddingOffset,{zoom:r,rotation:i,x:o=e,y:a=n}=t.options;this.transform({mode:"absolute",scale:r,translate:[o,a],rotate:i},!1)}get camera(){return this.context.canvas.getCamera()}landmarkCounter=0;createLandmark(t){return this.camera.createLandmark("landmark-"+this.landmarkCounter++,t)}getAnimation(t){const e=wl(this.context.options,t);return!!e&&function(t,e){if(null===t||!It(t))return{};var n={};return _t(e,(function(e){se.call(t,e)&&(n[e]=t[e])})),n}({...e},["easing","duration"])}getCanvasSize(){const{canvas:t}=this.context,{width:e=0,height:n=0}=t.getConfig();return[e,n]}getCanvasCenter(){const{canvas:t}=this.context,{width:e=0,height:n=0}=t.getConfig();return[e/2,n/2,0]}getViewportCenter(){const[t,e]=this.camera.getPosition();return[t,e,0]}getGraphCenter(){return this.context.graph.getViewportByCanvas(this.getCanvasCenter())}getZoom(){return this.camera.getZoom()}getRotation(){return this.camera.getRoll()}getTranslateArgs(t){const e=this.getZoom(),{camera:n}=this,{mode:r,translate:i=[]}=t,[o=0,a=0]=i,[s=0,u=0]=this.getCanvasCenter(),[c,h]=n.getPosition(),l=Hc([-o,-a],e);return"relative"===r?l:Vc([s-c,u-h],l)}getAnimationTranslateArgs(t){const{camera:e}=this,{mode:n,translate:r=[]}=t,i=this.getZoom(),o=e.getPosition(),a=e.getFocalPoint(),s=this.getCanvasCenter(),[u=0,c=0,h=0]=r,l=Hc([-u,-c,-h],i);return"relative"===n?{position:Vc(o,l),focalPoint:Vc(a,l)}:{position:Vc(s,l),focalPoint:Vc(a,l)}}getRotateArgs(t){const{mode:e,rotate:n=0}=t;return"relative"===e?n:n-this.camera.getRoll()}getAnimationRotateArgs(t){const{mode:e,rotate:n=0}=t;return{roll:"relative"===e?this.camera.getRoll()+n:n}}getZoomArgs(t){const{zoomRange:e}=this.context.options,n=this.camera.getZoom(),{mode:r,scale:i=1}=t;return Gt("relative"===r?n*i:i,...e)}async transform(e,n){const{camera:r}=this,{graph:i}=this.context,{translate:o,rotate:a,scale:s,origin:u=this.getGraphCenter()}=e;this.cancelAnimation(),pI(i,new dI(t.GraphEvent.BEFORE_TRANSFORM,e));const c=this.getAnimation(n);if(c){const n={};return o&&Object.assign(n,this.getAnimationTranslateArgs(e)),Vt(a)&&Object.assign(n,this.getAnimationRotateArgs(e)),Vt(s)&&Object.assign(n,{zoom:this.getZoomArgs(e)}),pI(i,new lI(t.GraphEvent.BEFORE_ANIMATE,oc.TRANSFORM,null,e)),new Promise((r=>{this.camera.gotoLandmark(this.createLandmark(n),{...c,onfinish:()=>{pI(i,new lI(t.GraphEvent.AFTER_ANIMATE,oc.TRANSFORM,null,e)),pI(i,new dI(t.GraphEvent.AFTER_TRANSFORM,e)),r()}})}))}if(o&&r.pan(...this.getTranslateArgs(e)),Vt(a)){const[t,n]=r.getFocalPoint();u&&r.pan(u[0]-t,u[1]-n);const i=this.getRotateArgs(e);r.rotate(0,0,i),u&&r.pan(t-u[0],n-u[1])}if(Vt(s)){const t=this.getZoomArgs(e);r.setZoomByViewportPoint(t,u)}pI(i,new dI(t.GraphEvent.AFTER_TRANSFORM,e))}async fitView(t,e){const[n,r,i,o]=this.padding,{when:a="always",direction:s="both"}=t||{},[u,c]=this.context.canvas.getSize(),h=u-o-r,l=c-n-i,d=this.context.canvas.getBounds(),f=this.getBBoxInViewport(d),[p,g]=Ec(f);if("overflow"===a&&!("x"===s&&p>=h||"y"===s&&g>=l||"both"===s&&p>=h&&g>=l))return await this.fitCenter(e);const m=h/p,v=l/g,y="x"===s?m:"y"===s?v:Math.min(m,v),b=this.getAnimation(e);await this.transform({mode:"relative",scale:y,translate:Vc(Uc(this.getCanvasCenter(),this.getBBoxInViewport(d).center),b?Hc(this.paddingOffset,y):this.paddingOffset)},b)}async fitCenter(t){const e=this.context.canvas.getBounds();await this.focus(e,t)}async focusElements(t,e){const{element:n}=this.context;if(!n)return;const r=Mc(t.map((t=>n.getElement(t).getRenderBounds())));await this.focus(r,e)}async focus(t,e){const{center:n}=this.getBBoxInViewport(t),r=Uc(this.getCanvasCenter(),n);await this.transform({mode:"relative",translate:Vc(r,this.paddingOffset)},e)}getBBoxInViewport(t){const{min:e,max:n}=t,{graph:r}=this.context,[i,o]=r.getViewportByCanvas(e),[a,s]=r.getViewportByCanvas(n),u=new dr;return u.setMinMax([i,o,0],[a,s,0]),u}cancelAnimation(){this.camera.landmarks?.length&&this.camera.cancelLandmarkAnimation()}}class TL extends Vf{options;static defaultOptions={autoResize:!1,width:800,height:600,theme:"light",rotation:0,zoom:1,zoomRange:[.01,10]};destroyed=!1;context={model:new bL};constructor(t){super(),this.options=Object.assign({},TL.defaultOptions,t),this.setOptions(this.options),this.context.graph=this,this.options.autoResize&&window.addEventListener("resize",this.onResize)}getOptions(){return this.options}setOptions(t){const{animation:e,background:n,behaviors:r,combo:i,container:o,data:a,edge:s,height:u,layout:c,node:h,padding:l,theme:d,plugins:f,width:p,zoomRange:g,zoom:m}=t;n&&this.setBackground(n),r&&this.setBehaviors(r),i&&this.setCombo(i),a&&this.setData(a),s&&this.setEdge(s),c&&this.setLayout(c),h&&this.setNode(h),d&&this.setTheme(d),f&&this.setPlugins(f),(Vt(p)||Vt(u))&&this.setSize(p??this.options.width??0,u??this.options.height??0),g&&(this.options.zoomRange=g),Vt(m)&&(this.options.zoom=m),Vt(l)&&(this.options.padding=l)}setBackground(t){this.options.background=t,this.context.canvas?.setBackground(t)}getBackground(){return this.options.background}getSize(){return this.context.canvas?this.context.canvas.getSize():[this.options.width||0,this.options.height||0]}setSize(t,e){this.options.width=t,this.options.height=e}setZoomRange(t){this.options.zoomRange=t}getZoomRange(){return this.options.zoomRange}setNode(t){this.options.node=t}setEdge(t){this.options.edge=t}setCombo(t){this.options.combo=t}getTheme(){return this.options.theme}setTheme(t){this.options.theme=kt(t)?t(this.getTheme()):t;const{background:e}=sI("theme",this.options.theme)||{};e&&!this.options.background&&this.setBackground(e)}setLayout(t){this.options.layout=kt(t)?t(this.getLayout()):t}getLayout(){return this.options.layout}setBehaviors(t){this.options.behaviors=kt(t)?t(this.getBehaviors()):t,this.context.behavior?.setBehaviors(this.options.behaviors)}updateBehavior(t){this.setBehaviors((e=>e.map((e=>Rt(e)&&e.key===t.key?{...e,...t}:e))))}getBehaviors(){return this.options.behaviors||[]}setPlugins(t){this.options.plugins=kt(t)?t(this.getPlugins()):t,this.context.plugin?.setPlugins(this.options.plugins)}updatePlugin(t){this.setPlugins((e=>e.map((e=>Rt(e)&&e.key===t.key?{...e,...t}:e))))}getPlugins(){return this.options.plugins||[]}getData(){return this.context.model.getData()}getNodeData(t){return void 0===t?this.context.model.getNodeData():Array.isArray(t)?this.context.model.getNodeData(t):this.context.model.getNodeData([t])?.[0]}getEdgeData(t){return void 0===t?this.context.model.getEdgeData():Array.isArray(t)?this.context.model.getEdgeData(t):this.context.model.getEdgeData([t])?.[0]}getComboData(t){return void 0===t?this.context.model.getComboData():Array.isArray(t)?this.context.model.getComboData(t):this.context.model.getComboData([t])?.[0]}setData(t){this.context.model.setData(kt(t)?t(this.getData()):t)}addData(t){this.context.model.addData(kt(t)?t(this.getData()):t)}addNodeData(t){this.context.model.addNodeData(kt(t)?t(this.getNodeData()):t)}addEdgeData(t){this.context.model.addEdgeData(kt(t)?t(this.getEdgeData()):t)}addComboData(t){this.context.model.addComboData(kt(t)?t(this.getComboData()):t)}updateData(t){this.context.model.updateData(kt(t)?t(this.getData()):t)}updateNodeData(t){this.context.model.updateNodeData(kt(t)?t(this.getNodeData()):t)}updateEdgeData(t){this.context.model.updateEdgeData(kt(t)?t(this.getEdgeData()):t)}updateComboData(t){this.context.model.updateComboData(kt(t)?t(this.getComboData()):t)}removeData(t){this.context.model.removeData(kt(t)?t(this.getData()):t)}removeNodeData(t){this.context.model.removeNodeData(kt(t)?t(this.getNodeData()):t)}removeEdgeData(t){this.context.model.removeEdgeData(kt(t)?t(this.getEdgeData()):t)}removeComboData(t){this.context.model.removeComboData(kt(t)?t(this.getComboData()):t)}getElementType(t){return this.context.model.getElementType(t)}getRelatedEdgesData(t,e="both"){return this.context.model.getRelatedEdgesData(t,e)}getNeighborNodesData(t){return this.context.model.getNeighborNodesData(t)}getAncestorsData(t,e){return this.context.model.getAncestorsData(t,e)}getParentData(t,e){return this.context.model.getParentData(t,e)}getChildrenData(t){return this.context.model.getChildrenData(t)}getElementDataByState(t,e){return this.context.model.getElementDataByState(t,e)}createCanvas(){if(this.context.canvas)return this.context.canvas;const{container:t="container",width:e,height:n,renderer:r,background:i}=this.options;if(t instanceof pL)this.context.canvas=t,t.setBackground(i);else{const i=zt(t)?document.getElementById(t):t;this.context.canvas=new pL({container:i,width:e,height:n,renderer:r})}return this.context.canvas}createRuntime(){this.context.options=this.options,this.context.plugin||(this.context.plugin=new NL(this.context)),this.context.viewport||(this.context.viewport=new SL(this.context)),this.context.element||(this.context.element=new EL(this.context)),this.context.layout||(this.context.layout=new xL(this.context)),this.context.behavior||(this.context.behavior=new vI(this.context))}async prepare(){if(this.destroyed)throw new Error("Graph has been destroyed");await this.createCanvas().init(),this.createRuntime()}async render(){pI(this,new hI(t.GraphEvent.BEFORE_RENDER)),await this.prepare(),await Promise.all([this.context.element?.draw(),this.context.layout?.layout()]),await this.autoFit(),pI(this,new hI(t.GraphEvent.AFTER_RENDER))}async draw(){return await this.prepare(),this.context.element.draw()}layout(){return this.context.layout.layout()}stopLayout(){return this.context.layout.stopLayout()}async clear(){this.context.model.setData({}),await this.draw()}destroy(){const{layout:t,element:e,model:n,canvas:r,behavior:i,plugin:o}=this.context;t?.destroy(),e?.destroy(),n.destroy(),r?.destroy(),i?.destroy(),o?.destroy(),this.options={},delete this.context,window.removeEventListener("resize",this.onResize),this.destroyed=!0}getCanvas(){return this.context.canvas}resize(e,n){const r=e&&n?[e,n]:OD(this.context.canvas.getContainer());ie(r,this.getSize())||(pI(this,new hI(t.GraphEvent.BEFORE_SIZE_CHANGE,{size:r})),this.context.canvas.resize(...r),pI(this,new hI(t.GraphEvent.AFTER_SIZE_CHANGE,{size:r})))}async fitView(t,e){await(this.context.viewport?.fitView(t,e))}async fitCenter(t){await(this.context.viewport?.fitCenter(t))}async autoFit(){const{autoFit:t}=this.context.options;if(t)if(zt(t))"view"===t?await this.fitView():"center"===t&&await this.fitCenter();else{const{type:e,animation:n}=t;"view"===e?await this.fitView(t.options,n):"center"===e&&await this.fitCenter(n)}}async focusElement(t,e){await(this.context.viewport?.focusElements(Array.isArray(t)?t:[t],e))}async zoomBy(t,e,n){await this.context.viewport.transform({mode:"relative",scale:t,origin:n},e)}async zoomTo(t,e,n){this.context.viewport.transform({mode:"absolute",scale:t,origin:n},e)}getZoom(){return this.context.viewport.getZoom()}async rotateBy(t,e,n){await this.context.viewport.transform({mode:"relative",rotate:t,origin:n},e)}async rotateTo(t,e,n){await this.context.viewport.transform({mode:"absolute",rotate:t,origin:n},e)}getRotation(){return this.context.viewport.getRotation()}async translateBy(t,e){await this.context.viewport.transform({mode:"relative",translate:t},e)}async translateTo(t,e){await this.context.viewport.transform({mode:"absolute",translate:t},e)}getPosition(){return Uc([0,0],this.getCanvasByViewport([0,0]))}async translateElementBy(t,e,n=!0){const[r,i]=Rt(t)?[t,e??!0]:[{[t]:e},n];Object.entries(r).forEach((([t,e])=>this.context.model.translateNodeBy(t,e))),await this.context.element.draw({animation:i})}async translateElementTo(t,e,n=!0){const[r,i]=Rt(t)?[t,e??!0]:[{[t]:e},n];Object.entries(r).forEach((([t,e])=>this.context.model.translateNodeTo(t,e))),await this.context.element.draw({animation:i})}getElementPosition(t){return this.context.model.getElementPosition(t)}getElementRenderStyle(t){return ue(this.context.element.getElement(t).attributes,["context"])}async setElementVisibility(t,e,n=!0){const[r,i]=Rt(t)?[t,e??!0]:[{[t]:e},n],o={nodes:[],edges:[],combos:[]};Object.entries(r).forEach((([t,e])=>{const n=this.getElementType(t);o[`${n}s`].push({id:t,style:{visibility:e}})})),this.updateData(o),await this.context.element.draw({animation:i,stage:"visibility"})}async showElement(t,e){const n=Array.isArray(t)?t:[t];await this.setElementVisibility(Object.fromEntries(n.map((t=>[t,"visible"]))),e)}async hideElement(t,e){const n=Array.isArray(t)?t:[t];await this.setElementVisibility(Object.fromEntries(n.map((t=>[t,"hidden"]))),e)}getElementVisibility(t){const e=this.context.element.getElement(t);return e?.style?.visibility??"visible"}async setElementZIndex(t,e){const n={nodes:[],edges:[],combos:[]},r=Rt(t)?t:{[t]:e};Object.entries(r).forEach((([t,e])=>{const r=this.getElementType(t);n[`${r}s`].push({id:t,style:{zIndex:e}})}));const{model:i,element:o}=this.context;i.preventUpdateNodeLikeHierarchy((()=>i.updateData(n))),await o.draw({animation:!1})}async frontElement(t){const e=Array.isArray(t)?t:[t],{model:n}=this.context,r={};e.map((t=>{const e=n.getFrontZIndex(t);if("combo"===n.getElementType(t)){const i=n.getAncestorsData(t,dc).at(-1)||this.getComboData(t),o=[i,...n.getDescendantsData(Ic(i))].filter((t=>n.isCombo(Ic(t)))),a=e-mI(i);o.forEach((t=>{r[Ic(t)]=mI(t)+a}))}else r[t]=e})),await this.setElementZIndex(r)}getElementZIndex(t){return mI(this.context.model.getElementsData([t])[0])}async setElementState(e,n,r=!0){const[i,o]=Rt(e)?[e,n??!0]:[{[e]:n},r];pI(this,new fI(t.GraphEvent.BEFORE_ELEMENT_STATE_CHANGE,i));const a={nodes:[],edges:[],combos:[]};Object.entries(i).forEach((([t,e])=>{const n=this.getElementType(t);a[`${n}s`].push({id:t,style:{states:Array.isArray(e)?e:[e]}})})),this.updateData(a),await this.context.element.draw({animation:o}),pI(this,new fI(t.GraphEvent.AFTER_ELEMENT_STATE_CHANGE,i))}getElementState(t){return this.context.model.getElementState(t)}getElementRenderBounds(t){return this.context.element.getElement(t).getRenderBounds()}async collapse(t,e=!0){this.setElementCollapsibility(t,!0),await this.context.element.draw({animation:e,stage:"collapse"})}async expand(t,e=!0){this.setElementCollapsibility(t,!1),await this.context.element.draw({animation:e,stage:"expand"})}setElementCollapsibility(t,e){const n=this.getElementType(t);"node"===n?this.updateNodeData([{id:t,style:{collapsed:e}}]):"combo"===n&&this.updateComboData([{id:t,style:{collapsed:e}}])}async toDataURL(t={}){return this.context.canvas.toDataURL(t)}getCanvasByViewport(t){return Zc(this.context.canvas.viewport2Canvas(Qc(t)))}getViewportByCanvas(t){return Zc(this.context.canvas.canvas2Viewport(Qc(t)))}getClientByCanvas(t){const e=this.context.canvas.canvas2Viewport(Qc(t));return Zc(this.context.canvas.viewport2Canvas(e))}getCanvasByClient(t){const e=this.context.canvas.client2Viewport(Qc(t));return Zc(this.context.canvas.viewport2Canvas(e))}getViewportCenter(){return this.context.viewport.getViewportCenter()}getCanvasCenter(){return this.context.viewport.getCanvasCenter()}onResize=function(t,e,n){var r;return function(){var i=this,o=arguments,a=n&&!r;clearTimeout(r),r=setTimeout((function(){r=null,n||t.apply(i,o)}),e),a&&t.apply(i,o)}}((()=>{this.resize()}),300)}const kL={idOf:Ic,treeToGraphData:function(t,e){const{getNodeData:n=(t=>{if(!t.children)return t;const{children:e,style:n={},...r}=t;return{style:{...n,children:e.map((t=>t.id))},...r}}),getEdgeData:r=((t,e)=>({source:t.id,target:e.id})),getChildren:i=(t=>t.children||[])}=e||{},o=[],a=[];return uI(t,(t=>{o.push(n(t));const e=i(t);for(const n of e)a.push(r(t,n))}),(t=>i(t)),"TB"),{nodes:o,edges:a}}},PL={dark:nI,light:rI};t.BaseBehavior=Tl,t.BaseCombo=Th,t.BaseEdge=Xh,t.BaseNode=bh,t.ComboEvent=t.NodeEvent,t.Graph=TL,t.Theme=PL,t.Utils=kL,t.getExtension=sI,t.getExtensions=function(t){return oI[t]},t.register=aI,t.version="5.0.0"}));